Discrepancy in dbu in GUI and seen by the PCell script

Hi, Matthias!

I have a PCell written in python that should draw an element. According to the fab rules the dbu should be 0.005 micron,
which I set in "Layout Properties" and in "Technology manager" right after starting KLayout. So these parameters are shown me
when I check these sections in GUI. However, parallel to this, my PCell script sees dbu = 0.001 micron. As a result, my elements turn out to be
5 times larger than intended. I could not find a way to change the dbu. Setting the element parameters 5 times smaller does not help either, since
Klayout considers them too small to draw in a proper smooth way.
Could you, please, help me solve this issue?

Thank you in advance



  • Hi Mikhail,

    basically the DBU your PCell code works with does not have to be the target DBU. So if you set up a PCell library, it will use it's own local layout object which provides the context. This layout can have any DBU you desire. By default this is 1nm.

    When you use a PCell in another layout (the client), the layout from the PCell is translated to the client's DBU automatically.

    So it's important that inside the PCell generation code you create layout with the database unit given by the local layout. The easiest way to achieve this is to use the "D..." versions of the shapes which allow you to use micrometer units.

    If you do this properly, a PCell is agnostic with respect to the client layout's database unit. With the exception that the translation may involve rounding and small-scale layout distortions. Using 1nm for the PCell library however translates to usual sub-nm database units like 0.25nm without rounding.

    If 1 nm is too coarse for your PCell, you can use a smaller DBU - for example 0.5nm - by properly configuring the layout in the library constructor:

    class PCellLib(pya.Library):
      def __init__(self):
        self.description = "A Python PCell library"
        # PCell uses 0.5nm database unit:
        self.layout().dbu = 0.0005
        self.layout().register_pcell("PCell", PCell("description"))


  • Hi, Matthias!

    Thank you for you answer. In fact, I have the dbu assigned in the PCell script as you explain in your answer. However, no effect was made. But I figure out the problem by installing older versio of KLayout - 0.26.5 (It used to be 0.26.11). Now, with 0.26.5 the sizes are correct.

Sign In or Register to comment.