|
| 1 | +# Exercise the sta::sta_to_db_* SWIG bindings on a flat design. |
| 2 | +# |
| 3 | +# All instances/pins/nets/ports are leaves (no dbModInst / dbModNet / |
| 4 | +# dbModITerm / dbModBTerm exist), so: |
| 5 | +# * sta_to_db_inst, _pin, _port, _net resolve to the matching dbInst / |
| 6 | +# dbITerm / dbBTerm / dbNet. |
| 7 | +# * sta_to_db_mod_inst, _mod_pin, _mod_port, _mod_net all return NULL. |
| 8 | +source "helpers.tcl" |
| 9 | + |
| 10 | +read_lef example1.lef |
| 11 | +read_liberty example1_slow.lib |
| 12 | +read_def example1.def |
| 13 | + |
| 14 | +proc check { label obj } { |
| 15 | + if { $obj == "NULL" } { |
| 16 | + puts "$label: NULL" |
| 17 | + return |
| 18 | + } |
| 19 | + set name [$obj getName] |
| 20 | + if { [catch { set hier [$obj getHierarchicalName] }] } { |
| 21 | + puts "$label: $name" |
| 22 | + } else { |
| 23 | + puts "$label: $name (hier: $hier)" |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +proc check_port { label port } { |
| 28 | + if { $port == "NULL" } { |
| 29 | + puts "$label: <no port>" |
| 30 | + } else { |
| 31 | + puts "$label: [get_property $port full_name]" |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +# --- leaf instance --- |
| 36 | +puts "# leaf instance r1" |
| 37 | +set inst [get_cells r1] |
| 38 | +check " sta_to_db_inst" [sta::sta_to_db_inst $inst] |
| 39 | +check " sta_to_db_mod_inst" [sta::sta_to_db_mod_inst $inst] |
| 40 | + |
| 41 | +# --- leaf instance pin --- |
| 42 | +puts "# leaf pin r1/D" |
| 43 | +set pin [get_pin r1/D] |
| 44 | +check " sta_to_db_pin" [sta::sta_to_db_pin $pin] |
| 45 | +check " sta_to_db_mod_pin" [sta::sta_to_db_mod_pin $pin] |
| 46 | +check_port " sta_pin_to_port" [sta::sta_pin_to_port $pin] |
| 47 | + |
| 48 | +# --- top-level Port --- |
| 49 | +puts "# top-level port clk1" |
| 50 | +set port [lindex [get_ports clk1] 0] |
| 51 | +check " sta_to_db_port" [sta::sta_to_db_port $port] |
| 52 | +check " sta_to_db_mod_port" [sta::sta_to_db_mod_port $port] |
| 53 | + |
| 54 | +# --- a flat dbNet --- |
| 55 | +puts "# net r1q" |
| 56 | +set net [get_net r1q] |
| 57 | +check " sta_to_db_net" [sta::sta_to_db_net $net] |
| 58 | +check " sta_to_db_mod_net" [sta::sta_to_db_mod_net $net] |
| 59 | + |
| 60 | +# --- LibertyCell -> dbMaster, LibertyPort -> dbMTerm --- |
| 61 | +puts "# liberty cell BUF_X1" |
| 62 | +set lib_cell [get_property [get_cells u1] liberty_cell] |
| 63 | +check " sta_to_db_master" [sta::sta_to_db_master $lib_cell] |
| 64 | + |
| 65 | +puts "# liberty port BUF_X1/A" |
| 66 | +set lib_port [lindex [get_lib_pins NangateOpenCellLibrary_slow/BUF_X1/A] 0] |
| 67 | +check " sta_to_db_mterm" [sta::sta_to_db_mterm $lib_port] |
0 commit comments