Net tracer script problem

I use the following ruby script to save my net trace result with specified layer to a new cell, but I face some problem.
Its layer id saved in class NetElement is not a valid layer index in the layout I parse in.
The layer id would be 10^9+1.
I guess the reason is the net trace result is built from the LOP NOT(i.e., "MetalDown_NOT_CutMetal") defined in the symbol, not the original layer in the layout.
And I haven't found any function to get the layer/datattype # or naming in the symbol of this layer yet.
Is there any way to do such a thing?
The Klayout version I used is 0.25.8

The script:
layout = RBA::Layout::new
layout.read("trace.gds")

tech = RBA::NetTracerTechnology::new
tech.symbol( "MetalDown_NOT_CutMetal", "1/0-4/0")
tech.connection( "MetalDown_NOT_CutMetal" , "2/0", "3/0")

MetalDown: 1/0

MetalUp: 3/0

VIA: 2/0

CutMetal: 4/0

tracer = RBA::NetTracer::new
tracer.trace(tech, layout , layout .top_cell, RBA::Point::new(0/layout.dbu, 0/layout.dbu), layout.find_layer(1, 0) )
trace_result_cell = layout.create_cell("trace_result")
tracer.each_element do |e|
###try to save MetalDown_NOT_CutMetal only, but failed
e_layer_info = layout.get_info(e.layer)
if e_layer_info.layer == 1 && e_layer_info.layer == 0
trace_result_cell .shpaes(e.layer).insert(e.shape,e.trans)
end

###trace_result_cell.shapes(layout.layer(5,0) ).insert(e.shape,e.trans)

end
layout.write("check_result.gds")

Comments

  • Hi,

    any chance to get this code formatted as Markdown? It very difficult to read. Use triple backticks before and after the code.

    Does the example work in the user interface?

    At least there is one typo ("shpaes"), so I don't think this code every worked.

    Matthias

  • Sorry for the hard-to-read pure text format.
    I hope this time it would be better.

    layout = RBA::Layout::new
    layout.read("trace.gds")
    tracer = RBA::NetTracer::new
    
    tech = RBA::NetTracerTechnology::new
    ###MetalDown: 1/0
    ###MetalUp: 3/0
    ###VIA: 2/0
    ###CutMetal: 4/0
    
    tech.symbol( "MetalDown_NOT_CutMetal", "1/0-4/0")
    tech.connection( "MetalDown_NOT_CutMetal" , "2/0", "3/0")
    
    tracer.trace(tech, layout , layout .top_cell, RBA::Point::new(0/layout.dbu, 0/layout.dbu), layout.find_layer(1, 0) )
    
    trace_result_cell = layout.create_cell("trace_result")
    
    
    tracer.each_element do |e| 
        e_layer_info = layout.get_info(e.layer)
        if e_layer_info.layer == 1 && e_layer_info.layer == 0
            trace_result_cell .shpaes(e.layer).insert(e.shape,e.trans)
        end  
        ###trace_result_cell.shapes(layout.layer(5,0) ).insert(e.shape,e.trans)
    
    
    end
    
    layout.write("check_result.gds")
    
  • edited July 2019

    More readable, but the typo is still there.

    The issue is that symbolic layers aren't original layers. They are computed internally. In order to store such shapes you'll need to create new layers in the layout and use these for output.

    Like (not tested):

    layer_ids = {}
    gds_layer = 100
    ...
    
    tracer.each_element do |e| 
        if e.layer not in symbolic_layers:
            symbolic_layers[e.layer] = layout.insert_layer(start_layer, 0)
            gds_layer += 1
        trace_result_cell.shapes(layer_ids[e.layer]).insert(e.shape, e.trans)
    

    Matthias

  • edited January 2021
    Matthais
    Question how do you define the symbolic_layers I have looked and not seen any documentation regarding this other than this it's vague
    Use the symbol table to specify derived layers and to assign names to layer/datatype combinations. A symbolic layer must have a name which can 
    be used in the connectivity table instead of the original layers. In addition, an expression must be specified that defines the contents of the layer.
    
  • @tagger5896

    First, it's "Matthias" :)

    Second: please don't indent your text - Markdown formatting will turn it into a code piece.

    An third: the documentation (https://www.klayout.de/doc-qt5/manual/net_tracing.html) refers this this page for the description of the symbolic layers: https://www.klayout.de/doc-qt5/about/symbolic_layers.html

    Matthias

  • Gotcha new too the fourm thanks for the info

  • I am trying too get this code to work with no success
    using another example as well posted in the documentation and I would like too save the output to another file
    check_results.gds , the trace_result_cell_shapes is not writing too the check_results.gds.
    I have an extensive Cadence Skill Eda background but this is all new :)

    Enter your Ruby code here

    ly = RBA::CellView::active.layout
    tracer = RBA::NetTracer::new
    tech = RBA::NetTracerTechnology::new
    layout = RBA::Layout::new
    layer_ids = {}
    gds_layer = 100
    tech.connection("9/0", "10/0", "11/0")
    tracer.trace(tech, ly, ly.top_cell, RBA::Point::new(2600, 3100), ly.find_layer(9, 0))
    trace_result_cell = layout.create_cell("E:/Klayout/si4all/samples/check_result.gds")

    tracer.each_element do |e|
    trace_result_cell.shapes(e.layer).insert(e.shape,e.trans)
    gds_layer += 1
    puts e.shape
    layout.write("E:/Klayout/si4all/samples/check_result.gds")
    end

  • Can't say I know anything about anything, but this:

    "The layer id would be 10^9+1."

    makes me wonder about stuff like:

    • can this expression be evaluated, if indeed it's put
      in that literal form to "whatever receives it"?

    • is that billion-plus-one within range of the variable
      (?) that's catching it? Why so huge a number when
      there's, what, 256 layers times 256 datatypes in
      GDS-II?

  • dick,
    Ya I hear ya coming from a Cadence Skill background , trying too wrap my head around this syntax
    i am so used to cv = geGetCellView() the sel = geGetSelectedSet() then and the command line sel~>??

  • edited January 2021

    @tagger5896 Please forget about Skill .. I have not attempted to replicate this API. I also don't want to. Be aware that most vendor specific concepts in the EDA industry are protected by copyright. So I cannot and will not copy that.

    I could be more helpful if you'd explain what you're attempting to achieve. I see you're trying to create a cell, but why passing a file name for the cell name?

    In your code there is at least one more bug: a "layer" is given by a layer ID (which is an integer number). A layer ID is prepared in the context of a layout from a layer specification (which is GDS layer/datatype and/or name). As you trace nets on one layout, but prepare a different layout for writing the shape, you need to translate the layer ID from the original layout to the target layout. So

    # this is wrong:
    trace_result_cell.shapes(e.layer).insert(e.shape,e.trans)
    
    # this is how to translate the layer
    layer_spec = ly.get_info(e.layer)
    layer_id_in_target_layout = layout.layer(layer_spec)
    trace_result_cell.shapes(layer_id_in_target_layout).insert(e.shape,e.trans)
    

    Matthias

  • Matthias,
    Thanks for the explanation this achieves
    what I was looking for I was just going by previous examples
    listed in the forum as guidance.

  • Hi Matthias! @Matthias
    -code:
    tracer.each_element do |e|
    puts("Start")
    puts ("e.shape.type: #{e.shape.type}")
    puts ("e.layer: #{e.layer} .e.cell_index: #{e.cell_index}")
    if e.shape.type != 1
    puts ("e.layer: #{e.layer} .ly.get_info(e.layer): #{ly.get_info(e.layer)} .ly.layer(ly.get_info(e.layer)) #{ly.layer(ly.get_info(e.layer))} .e.shape.layer: #{e.shape.layer}")
    else
    puts ("ly.get_info(e.layer):: ERROR")
    end
    puts("End")
    -result :
    Start
    e.shape.type: 15
    e.layer: 7 .e.cell_index: 4
    e.layer: 7 .ly.get_info(e.layer): 51/200 .ly.layer(ly.get_info(e.layer)) 7 .e.shape.layer: 7
    End
    Start
    e.shape.type: 15
    e.layer: 7 .e.cell_index: 4
    e.layer: 7 .ly.get_info(e.layer): 51/200 .ly.layer(ly.get_info(e.layer)) 7 .e.shape.layer: 7
    End
    Start
    e.shape.type: 1
    e.layer: 1000000001 .e.cell_index: 1525
    ly.get_info(e.layer):: ERROR
    End
    Start
    e.shape.type: 1
    e.layer: 1000000007 .e.cell_index: 1525
    ly.get_info(e.layer):: ERROR
    End

    -question: how can i get the e.layer is an integer number? i have bug puts (ly.get_info(e.layer)) when e.shape.type =1.

    Best Regards,
    shipfire (chipcom)

  • @shipfire First, please open a new discussion for such questions. This discussion is already old. Second, please use MarkDown for marking code. A line with triple backticks before and after the code works wonders (same as on GitHub for example).

    Regarding the error, I assume that your net tracer script has symbolic (computed) layers. These generate shapes but do not map to layers from the layout. So get_info returns an error.

    Matthias

  • I see, Thanks @Matthias !

Sign In or Register to comment.