Issue when attempting to use LayoutToNetlist::build_all_nets

the doc shows the 3rd argument as a lmap, however I get the following error when running it:
Unexpected object type (expected hash, got RBA::LayerMapping) for argument #3 ('lmap') in LayoutToNetlist::build_all_nets
Below is the code segment:
# Performs netlist extraction
startTime = Time.now
#LayoutToNetlist::BuildNetHierarchyMode BNH_SubcircuitCells
lm = RBA::LayerMapping::new
_lm.create_full(_layout,_layout)
_cm = RBA::CellMapping::new
_cm.for_single_cell_full(_cell, _cell)
l2n.cell_mapping_into(_layout, _cell, with_device_cells = false)
l2n.build_all_nets(_cm, _layout, _lm, net_cell_name_prefix = "net
", netname_prop = nil, circuit_cell_name_prefix = nil, device_cell_name_prefix = nil)
l2n.threads=4
l2n.extract_netlist
totalTime = Time.now - startTime
f.puts "netlist runtime #{sprintf('%.2f', totalTime)};\n"
f.close

Any advice would be greatly appreciated...

Comments

  • Is that a paste error or do you write "lm" once and "_lm" the second time?

    You can basically format code by placing a line with a triple backtick before and after the code (like GitHub Markdown for example).

    But basically the problem is that "lmap" is not a LayerMapping object but a Ruby or Python hash. Here is some sample code:

        # build_all_nets
    
        ly = RBA::Layout::new
        ly.create_cell("TOP")
    
        cm = l2n.cell_mapping_into(ly, ly.top_cell)
    
        lmap = { 
          ly.insert_layer(RBA::LayerInfo::new(10, 0)) => l2n.layer_by_name("psd"),
          ly.insert_layer(RBA::LayerInfo::new(11, 0)) => l2n.layer_by_name("nsd"),
          ly.insert_layer(RBA::LayerInfo::new(3, 0)) => l2n.layer_by_name("poly"),
          ly.insert_layer(RBA::LayerInfo::new(4, 0)) => l2n.layer_by_name("diff_cont"),
          ly.insert_layer(RBA::LayerInfo::new(5, 0)) => l2n.layer_by_name("poly_cont"),
          ly.insert_layer(RBA::LayerInfo::new(6, 0)) => l2n.layer_by_name("metal1"),
          ly.insert_layer(RBA::LayerInfo::new(7, 0)) => l2n.layer_by_name("via1"),
          ly.insert_layer(RBA::LayerInfo::new(8, 0)) => l2n.layer_by_name("metal2")
        }
    

    You also can't use named parameters the way you did. In Ruby, named parameters are written with a colon (e.g. "fun(param: 17)"). But that does not matter as KLayout's API does not support named parameters (technically because it is derived from C++ which does not have argument names).

    Matthias

  • I updated the use a hash for the mapping between the layout and netlist,
    however the script fails with the message:
    The netlist has not been extracted yet in LayoutToNetlist::build_all_nets

    I am sending a test-case zip file containing 4 gerber artwork files, the ipc-356 netlist file & the ruby script

  • Where did you send this to? I have not seen a mail.

    Matthias

  • I just sent a new message to klayoutadmin containing the zip file
    I may have not sent it correctly the first time :(

  • I finally realized the failure message was pointing out the error in my code...
    I moved the extract_netlist() call before the build_all_nets() call & it works correctly now

Sign In or Register to comment.