XOR vs. DIFF Tool?

edited February 2011 in KLayout Support
I wish to ask what the differences are between these two tools, specifically if one choses "Run XOR on differences" within the Diff Tool

Tools -> Verification -> XOR Tool
Tools -> Verification -> Diff Tool

On several designs, we've run both the XOR and Diff tool. If we select Run XOR within Diff Tool, we seem to regularly get the same result between the two tools. HOWEVER, the Diff Tool runs much, much faster. On one design, the XOR Tool takes about 1 minute to complete. The Diff Tool with Run XOR runs in seconds ... and both are giving the same results in the Marker Browser.

Can you explain the reason for the Diff Tool running so much faster? And, your expected usage of the two tools ... when you might use one tool over the other?

Thanks.

Comments

  • edited February 2011

    Hallo,

    you're right, the two tools serve the same purpose.

    However, there is a important difference:

    The XOR tool performs a comparison of the merged polygons as seen from the top cell. This basically verifies the equivalence of two layouts in the physical sense. That means that both layouts will produce the same results when manufactured. It does not imply any equivalence of the structure of the file (whether it is build from paths for polygons, whether the shapes are merged or split, how the hierarchy is built and so on). Basically, two layouts can produce the same mask but be build very differently. The XOR tool takes that into account by performing a rigorous comparison of the two layouts using a XOR algorithm on the flattened layout. In that respect, this approach is brute force, hence slow.

    The Diff tool assumes that the differences are not that much structural, but only minor differences exist. So it compares the structure of one layout vs. the other. It will report every instance and every shape that cannot be found in the other file. That comparison is based on simple object-by-object comparisons and is very fast. It can also detect structural changes which may be more meaningful than XOR results. For example, a shifted cell will create a lot of XOR's but just one report in the Diff tool's result. Also, the Diff tool can detect changes of text objects which the XOR cannot detect, since texts are not part of the polygon representation. On the other hand, the Diff tool may detect differences which do not have a physical effect. For example, if a cell is rotated and it's content is rotated such that this rotation compensates the cell's rotation, the physical effect will be zero but the structure of the layout has changed. There are also cases, where a difference in the shapes may not have an effect, because a shape disappears or appears while being completely covered by another shape: in that case, there is a structural difference but no physical.

    The "perform XOR on differences" option of the Diff tool tries to combine the best of the two worlds: it uses the Diff tool to detect differences and run a XOR on the differences. This will not truly produce the same results as the full XOR (yet), but should have a better performance while rendering similar results.

    Bottom line is: use Diff for detecting minor differences (such as ECO's) and XOR's if you are interested in mask level effects or you expect huge structural changes. Also, the XOR tool offers the "tolerance" and tiling feature. The Diff tool doesn't.

    One note on performance: right now, the XOR is a simple flat one. It cannot compete with many commercial tools, although, for example when the input is already flat, it can be an alternative. Consider using the tiling feature to keep the memory footprint to a reasonable level. Because of the flat approach, the intermediate data may take a considerable amount of memory. Using tiling reduces that size.

    Hopefully that was comprehensible.

    Best regards,

    Matthias

  • edited November -1
    Hi,

    I am able to run XOR within diff Tool using GUI. I want to run this in batch mode using command line argument. could you please help me out?

    Thanks,
    Akshay
  • edited October 2014

    Hi Akshay,

    I am sorry, but the diff tool is not available in batch mode currently. There is a simplified version of the diff algorithm available as a standalone tool on Linux, but mainly for test purposes.

    I will file this request, but unless you are capable of modifying the C++ sources to your requirements, I don't see a quick way to achieve this.

    A pure XOR however can be run in batch mode using a DRC script. But that is not a "diff". Or are you meaning XOR in fact?

    Matthias

  • edited November -1
    Hi Matthias,

    thanks for your quick reply. i want XOR with in diff tool not a pure XOR tool. i tried it in GUI mode and it is showing the result what i was expecting. i want to run this on list of Lef files by some automation. for this i require batch commands without invoking GUI. Let me know if there is other way around to achieve this. Also could you please give me some more details about diff algorithm? i will appreciate your help.

    Thanks,
    Akshay
  • edited November -1

    Hi,

    as I said, there is no batch mode available for the diff tool currently.

    If you have some C++ coding skills you may be able to extract the functionality from extDiffToolDialog.cc. Another option is to take the test utility in "strmcmp.cc" as a basis for a batch tool.

    Regarding the algorithm: it basically consist of two parts: the first part is to identify matching cells. There are multiple ways, the most simple one is employ name identity, but the default algorithm is to identify cells by their location in the layout. This way it is possible to identify cells which have been renamed. The second part is to walk through the list of matched cell pairs and identify parts which are in both cells and which are just in one of these cells. Every part not having a counterpart in the other cells will be reported.

    Matthias

  • edited November -1
    Hi Matthias,

    I am not so good at C++ coding but I will try it. can you provide me commands to run pure XOR using DRC script? i want to try that too.

    Thanks,
    Akshay
  • edited November -1

    Hi Akshay,

    maybe, strmcmp already does what you need. If you run Linux, all you need to do is to build KLayout from the sources (see "Download & Build"). In the binary folder you'll get a "strmcmp" utility which you simply call with both layout files. It will print a list of differences. However, it will not take LEF directly (LEF is not a simple layout file) and will not offer all the options of the diff tool.

    Below you find a generic XOR script using the DRC functionality. Please see the notes for details.

    Matthias

    # 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
    
  • edited November -1
    Hi Matthias,

    I tried strmxor utility to xor between two LEF. As you told, it will not take LEF directly. i need to import LEF and then save it as ".gds" to convert lef to gds. Is there any batch command exists to covert "lef to gds"?

    Thanks for the Help.
  • edited November -1

    Not yet, I'm sorry. LEF is not like the usual stream formats. It requires additional configuration and that is not readily available in the context of the batch mode tools.

    You can have look at "extLEFImporter.cc" and "extDEFImporter.cc" if you want to code the conversion yourself in C++.

    Matthias

Sign In or Register to comment.