Compare text record of two gds files using klayout

Hi All,

I have used below command to compare two gds files :-
klayout -r xor.drc -rd a=test.gds -rd ca=ABC -rd b=test2.gds -rd cb=ABC -rd o=a.gds -zz

where test.gds and test2.gds are two gds files
and ABC is top structure name present in above two gds files.
and a.gds is output file.

and xor.drc has data as:


A general XOR script

This script uses KLayout's DRC language to implement a generic

XOR between two layouts. The name of the layouts is given

in $a and $b. Optionally, the cell names can be given in $ca and $cb.

The output will be sent to a RDB named $o.

Tiling can be enabled by setting $ts to the tile size (either a

single number of width,height).

#

For layout-to-layout XOR, run this script with

./klayout -r xor.drc -rd a=a.gds -rd b=b.gds -rd ol=xor.gds -zz

(replace a.gds, b.gds and xor.gds with the names of your input and

output)

#

For layout-to-layout XOR with specific cells, run this script with

./klayout -r xor.drc -rd a=a.gds -rd ca=CELLA -rd b=b.gds -rd cb=CELLB -rd ol=xor.gds -zz

(replace CELLA and CELLB with the names of the cells to XOR

against)

#

For layout-to-layout XOR with tiling, run this script with

./klayout -r xor.drc -rd ts=TILE_SIZE -rd a=a.gds -rd b=b.gds -rd ol=xor.gds -zz

(replace TILE_SIZE by the desired tile size in micrometer units)

#

For layout-to-layout XOR with multiple cores, run this script with

./klayout -r xor.drc -rd thr=NUM_CORES -rd a=a.gds -rd b=b.gds -rd ol=xor.gds -zz

(replace NUM_CORES by the desired number of cores to utilize

#

For layout-to-RDB XOR, run this script with

./klayout -r xor.drc -rd a=a.gds -rd b=b.gds -rd o=xor.lyrdb -zz

(replace xor.lyrdb with the desired output file name)

#

enable timing output

verbose

set up input a

a = source($a)
$ca && a = a.cell($ca)

set up input b

b = source($b)
$cb && b = b.cell($cb)

send output to a RDB (name from $o) or layout (name from $ol, output

cell name optionally from $co)

$o && report("XOR #{$a} vs. #{$b}", $o)
$ol && target($ol, $co || "XOR")

optionally select tiling

$ts && tiles($ts)

optionally select tiling

$thr && threads($thr)

collect all common layers

layers = {}
[ a.layout, b.layout ].each do |ly|
ly.layer_indices.each do |li|
i = ly.get_info(li)
layers[i.to_s] = i
end
end

perform the XOR's

layers.keys.sort.each do |l|
i = layers[l]
info("--- Running XOR for #{l} ---")
x = a.input(l) ^ b.input(l)
info("XOR differences: #{x.data.size}")
$o && x.output(l, "XOR results for layer #{l}")
$ol && x.output(i.layer, i.datatype, i.name)
end


But above command is not comparing text records present in 2 gds files.

Kindly share how to compare text records of two gds files using klayout.

Thanks & Regards,
Garima

Comments

  • Could you please reformat your code in Markdown (put lines with triple backticks in front and after the code)? This is unreadable.

    Matthias

  • edited August 2019

    Hi Matthias,

    Thanks for you response.
    I have used below command to compare two gds files :-
    klayout -r xor.drc -rd a=test.gds -rd ca=ABC -rd b=test2.gds -rd cb=ABC -rd o=a.gds -zz

    where test.gds and test2.gds are two gds files
    and ABC is top structure name present in above two gds files.
    and a.gds is output file.

    and xor.drc has data as:

    # enable timing output
    verbose
    
    # set up input a
    a = source($a)
    $ca && a = a.cell($ca)
    
    # set up input b
    b = source($b)
    $cb && b = b.cell($cb)
    
    # send output to a RDB (name from $o) or layout (name from $ol, output 
    # cell name optionally from $co)
    $o && report("XOR #{$a} vs. #{$b}", $o)
    $ol && target($ol, $co || "XOR")
    
    # optionally select tiling
    $ts && tiles($ts)
    
    # optionally select tiling
    $thr && threads($thr)
    
    # collect all common layers
    layers = {}
    [ a.layout, b.layout ].each do |ly|
      ly.layer_indices.each do |li|
        i = ly.get_info(li)
        layers[i.to_s] = i
      end
    end
    
    # perform the XOR's
    layers.keys.sort.each do |l|
      i = layers[l]
      info("--- Running XOR for #{l} ---")
      x = a.input(l) ^ b.input(l)
      info("XOR differences: #{x.data.size}")
      $o && x.output(l, "XOR results for layer #{l}")
      $ol && x.output(i.layer, i.datatype, i.name)
    end
    

    But above command is not comparing text records present in 2 gds files.

    Kindly share how to compare text records of two gds files using klayout.

    Yesterday I have used strmcmp and it is comparing text record present in gds files.

    But sometimes strmcmp tool is showing differences for files if there is no shape difference in those gds files ( and using xor.drc it was not showing any difference.)

    So, could you please share that for comparing 2 gds files, can we use it as :
    1) Command "klayout -r xor.drc--rd a=test.gds -rd ca=ABC -rd b=test2.gds -rd cb=ABC -rd o=a.gds -zz" mentioned above , for all records except text records (As it ignores text record comparison)?

    2)Could we assume that if there is no difference using step 1 command then those 2 gds files are equivalent?

    2) Using command strmcmp in order to compare only text records of gds files? (As strmcmp command showing difference for those cases too where step 1 is not showing any difference)

    Kindly share your thoughts.

    Thanks & Regards,
    Garima

  • Hi Garima,

    thanks ... this is much better.

    Basically XOR is a geometrical compare: it will produce the areas covered by layout in only one file. XOR is insensitive against the way the layout is drawn (wether it's a polygon, a path or a box), it considers layout "as if flat", it ignores overlapping shapes and treats them as one shape etc. So it's a "physical" compare: two masks which are XOR-equivalent will produce the same chip.

    But text objects aren't physical objects - they are logical objects used for marking a position. They will not appear on a mask and do not have an area. Hence XOR is insensitive against text objects.

    strmcmp (which is just a break-out version of Tools/Diff Tool) does a logical compare. It will report differences in the structure - the precise arrangement of polygons, in the cell hierarchy and even in cell names. Texts are also considered part of the "structure", so text differences are reported too.

    You should decide what is the intention of your compare: if you need a structural compare, use "diff" (or strmcmp). If you need a mask compare, use "XOR" (of strmxor).

    If you want to code a text diff in a script, your entry point will be the LayoutDiff class: https://www.klayout.de/doc-qt4/code/class_LayoutDiff.html

    Regards,

    Matthias

  • Hi Matthias,

    Thanks for your help.

  • Hi Matthias,

    Thanks for your help.

Sign In or Register to comment.