Layer Mapping when importing & combining cif files without losing the layer names

Hi all,
I want to combine several cif files in one layout without merging the layers together, even if the layer names are the same.
For this, layermapping with offsets exists and worked fine if I set cif_keep_layer_names=false.
However, the original layer names are then lost. (And I haven't found a way to get the names from anywhere).
If I keep cif_keep_layer_names=true the layermapping with offsets does not work anymore (or I use the wrong syntax).
Is there any workaround?
Best regards
Frank

Comments

  • Hi Frank,

    Can you give an example for the layer mapping you use?

    Matthias

  • Hi Matthias,
    First of all, a big thank you for the great support you give here on the forum and the fantastic Klayout program.

    I've simplified my problem (I used the same file twice for import; in reality these are different files and I have a loop for the files):

      f='path\test1.cif'
      mw = Application.instance.main_window
      ly = mw.create_layout(1).layout
      ly_view = mw.current_view
      ly.dbu = 0.001
    
      lo=RBA::LoadLayoutOptions::new
      lo.cif_keep_layer_names=false
      lo.cif_create_other_layers=true
      lo.cif_layer_map.map("*/* : *+100/*", ly.layers)
      #ly.insert_layer(LayerInfo.new(0,0)) #if this layer is already created I have problems using layer numbers
    
      puts ly.layers-1
      ly.read(f, lo)
      puts "#{ly.layers-1}    #{ly.get_info(ly.layers-1)}"
    
      lo.cif_layer_map.map("*/* : *+200/*", ly.layers)
      ly.read(f, lo)
      puts "#{ly.layers-1}    #{ly.get_info(ly.layers-1)}"
    
      ly_view.select_cell(ly.cell('CIF_TOP').cell_index,0)
      ly_view.add_missing_layers; ly_view.max_hier; ly_view.zoom_fit 
    

    with test1.cif:

    L L0;
    L L1;
    DS1 100 1;
    9 MainSymbol;
    L L0;
    B 5 1000 0 -495 0 30000;
    B 5 1000 0 -485 0 30000;
    L L1;
    B 5 1000 0 -475 0 30000;
    B 5 1000 0 -465 0 30000;
    DF;
    C 1;
    E
    

    If I change the Layernames in the cif File to something else (e.g. L0 -> Layername0), they are always imported using the name.
    In order to work with every file, I should always import the layers with cif_keep_layer_names=true.
    However, I haven't found any working syntax for the map string that works with names and wildcards.
    So if I don't want to mix the layers of different files while reading,
    maybe the best way is to create new (layout)layers for all layers after importing with a unique name or number and move the content there and the delete old one?
    (I didn't find a command to rename the (layout.)layers after they were created. Is this correct?)

    Best regards
    Frank

  • edited March 2021

    Hi Frank,

    a general comment first: names and layer/datatype numbers are contrary definitions. A layer inside the database is either numbered or named or both. In any case, a layer is primarily identified by layer/datatype number and if there is none, by name.

    Layer mapping works by providing a match and target expression. A match expression can be a number + number/number pair or a layer name or both. numbers will match to input layer numbers, names to input layer names. Only for numbers, wildcards and ranges are allowed.

    As CIF has names only, the usual use case for layer mapping is to supply name-to-number translation for saving to GDS. So a typical CIF (or DXF, LEF/DEF ...) mapping will look like:

    metal1 : 17/0
    via1 : 18/0
    metal2 : 19/0
    ...
    

    Which assigns layer 17, datatype 0 to a CIF layer called "metal1". No wildcards possible in the layer names.

    If however, your CIF file uses "pseudo-numeric" layer names such as "17", these "names" will be converted into layer/datatype numbers. "17" is converted to 17/0, "L17D3" to 17/3. The "cif_keep_layer_names" option controls whether this happens (false) or the names stay names even if they are numeric (true).

    So if you use "cif_keep_layer_names = false", then the CIF reader may convert names to numbers. In this case, a mapping like */* : *+200/* may have the desired effect, but the layer name is lost. Except for layers which have a non-numeric text like "metal1". I'd use this option only if your CIF file is guaranteed to have only numerical layer names. In that case, it's not a loss if the layer names are gone.

    Otherwise, I'd try to work with a expanded layer map such as the one above. Such a layer map is quite common in PDKs to map between name-only and number-only formats. You can basically generate such a table inside your script and use different numbers for each pass.

    One comment about reading multiple layout files into the same layout: while this is very simple, it's also highly dangerous: if you use the same cell name in both files, the content of these cells will be mixed. This may have extreme consequences such as hierarchy complexity explosion and loss of layout features. For this reason, the next major release will have an option to mitigate the risk of this case by creating cell variants.

    Regards,

    Matthias

Sign In or Register to comment.