strmcmp question

Hi, I'm starting to use klayout very deeply, and it's pretty amazing that it can substitute Calibre DesignRev at times. I am now trying to compare two gds files to find missing (BNOTA) polygons in one gds. The utility strmcmp seems to be doing this. But there are syntaxes that I don't understand in the output, such as this:
Not in a but in b:
(22250, 5250; 21700,5000) w=20 bx=0 ex=0 r=false
Not in b but in a:
(90,150;250,430) [4]
(310,150;530,430) [8]
What do the w, bx, ex, r mean?
What does the bracketed index mean [4] and [8]?

Thanks for replying!


  • Hi,

    strmcmp does a object-by-object compare, but not a geometrical one. So it does not do a boolean operation. The output indicates shapes. The one with the "w=..." etc. is a path (w is the width), the others are boxes. The titles of the sections tell which shape type is indicated. In this case these are Boxes:

    ERROR: Boxes differ for layer 7/0 in cell INV
    Not in b but in a:
    Not in a but in b:

    The value in brackets indicates user property variants, but not precisely which ones. I can add the exact property information if needed.

    If you do not want to see differences in properties, use "strmcmp -np".

    I think you are looking for the strmxor tool, if you need geometrical differences, not shape objects. There is a discussion related to the difference between XOR and strcmp here: Bottom line is, that a DRC script is more versatile. You can chose the type of operation and also introduce some other things like a post-XOR undersize to eliminate small differences.


  • Hi Matthias,
    Thanks for the information. What I have are two gds drawn with different dbu, but their x,y coordinates match. Their gds maps are also different, so I tried to use the multi-mapping layermap syntax. What I want is to get 'B not A' coordinates and plot those coordinates back into a gds. I tried strmxor, but that only reports the count of different polygons, so strmcmp still seems to be what I need. I collected all the coordinates reported under 'Not in a but in b' and plotted it using gdstk.

    In a.gds, I have a gds number for all ppoly, 7/*, e.g. 7/1, 7/2...7/340.
    In b.gds, I have a gds number for ppoly and another gds number for pgate (11/0 and 26/0 respectively, and they do not overlap). All the polygons for these two layers in b.gds match the polygons for a.gds's ppoly in location and shape.

    Hence, I created this multi-mapping:
    1. alayermapfile:
    + 7/*:11/0
    + 7/*:28/0
    2. blayermapfile:

    Then I used this command: strmcmp -np --a-skip-unknown-layers --b-skip-unknown-layers --a-layer-map-file=alayermapfile --b-layer-map-file=blayermapfile a.gds b.gds
    However, I find that ppoly of b.gds is reported under 'Not in a but in b'. I expected that it shouldn't be reported as it is found in both gds.

  • I've also tried using the XOR DRC script mentioned in that forum post, but because I can't specify the different layer mapping files (and don't know how to), the resulting ol gds is everything.

  • I am not sure I understand.

    I tried to create a sample:



    I hope I got it right.

    I understood you basically want to compare all shapes to all shapes.

    So I wonder why not mapping everything to one layer - for example 11/0:

    strmcmp -am "7/*:11/0" -as -bm "11,28/0:11/0" -bs a.gds b.gds 

    At least in my simple example, the compare works, if the database units are the same. This command also works for "strmxor".

    However, if the DBUs are not the same, the compare reports differences. A solution is to first bring the layouts to the same DBU, i.e. using

    strm2oas -od <output-dbu> in.oas out.oas

    BTW: "strm2oas" also accepts "-am", "-as" (this is called "-im", "-is" there) and this is great way to test your mapping.


  • Thank you, that was genius! Yes, I think this way will work!

Sign In or Register to comment.