From fd5e6caf13f2a52ba61c69a85c9bf44ef5db169c Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Thu, 16 Dec 2021 00:39:09 +0100 Subject: [PATCH] preserve line ordering regardless of awk hash implementation in tedax netlists as done for vhdl and verilog; include a couple of tedax netlist checks in xschemtest --- src/tedax.awk | 33 ++++++++++++++++++++++++++------- tests/xschemtest.tcl | 17 ++++++++++------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/tedax.awk b/src/tedax.awk index 1f55f824..4b8d9b64 100755 --- a/src/tedax.awk +++ b/src/tedax.awk @@ -66,6 +66,7 @@ $1=="device"||$1=="footprint"{ for(i=3; i<=NF;i++) { fp = ((i==3) ? $i : fp " " $i) } + if(!(inst_name in footprint)) footprint_num[footprint_n++] = inst_name footprint[inst_name] = fp } next @@ -80,6 +81,7 @@ $1=="device"||$1=="footprint"{ for(i=3; i<=NF;i++) { dev = ((i==3) ? $i : dev " " $i) } + if(!(inst_name in device)) device_num[device_n++] = inst_name device[inst_name] = dev } next @@ -101,17 +103,18 @@ $1=="device"||$1=="footprint"{ # conn lines need not to be printed but pinslot and pinidx lines do. for(i=1; i<=numslots;i++) { curr_pin = (nn>1) ? pinlist_arr[i]: pinlist_arr[1] - if(!((inst_name, curr_pin) in arr) || arr[inst_name, curr_pin]=="" || arr[inst_name, curr_pin] ~/^--UNCONN--/) { + if(!((inst_name,curr_pin) in arr)) arr_num[arr_n++] = (inst_name SUBSEP curr_pin) + if(!((inst_name,curr_pin) in arr) || arr[inst_name,curr_pin]=="" || arr[inst_name,curr_pin] ~/^--UNCONN--/) { if(curr_pin == pin_number) { - arr[inst_name, curr_pin]=net_name SUBSEP pin_index SUBSEP pin_name SUBSEP i SUBSEP slotted + arr[inst_name,curr_pin]=net_name SUBSEP pin_index SUBSEP pin_name SUBSEP i SUBSEP slotted } else { - arr[inst_name, curr_pin]="--UNCONN--" SUBSEP pin_index SUBSEP pin_name SUBSEP i SUBSEP slotted + arr[inst_name,curr_pin]="--UNCONN--" SUBSEP pin_index SUBSEP pin_name SUBSEP i SUBSEP slotted } # hidden connections (VCC, VSS on slotted devices, usually) specified on instance have higher # precedence w.r.t. default specified in symbol. } else if($0 ~ /# instance_based/ && curr_pin==pin_number) { # overwrite with instance specified net name. - arr[inst_name, curr_pin]=net_name SUBSEP pin_index SUBSEP pin_name SUBSEP i SUBSEP slotted + arr[inst_name,curr_pin]=net_name SUBSEP pin_index SUBSEP pin_name SUBSEP i SUBSEP slotted } } next @@ -127,7 +130,8 @@ $1=="device"||$1=="footprint"{ } /^end netlist/{ - for(i in arr) { + for(ii = 0; ii < arr_n; ii++) { # used to preserve ordering + i = arr_num[ii] if(arr[i]) { split(i, i_arr, SUBSEP) split(arr[i], n_arr, SUBSEP) @@ -141,12 +145,27 @@ $1=="device"||$1=="footprint"{ print "pinname", i_arr[1], i_arr[2], n_arr[3] } } - for(i in footprint) print "footprint", i, footprint[i] - for(i in device) print "device", i, device[i] + + for(ii = 0; ii < footprint_n; ii++) { # used to preserve ordering + i = footprint_num[ii] + print "footprint", i, footprint[i] + } + + for(ii = 0; ii < device_n; ii++) { # used to preserve ordering + i = device_num[ii] + print "device", i, device[i] + } print $0 delete arr + delete arr_num # used to preserve ordering + arr_n = 0 delete footprint + delete footprint_num # used to preserve ordering + footprint_n = 0 delete device + delete device_num # used to preserve ordering + device_n = 0 + next } diff --git a/tests/xschemtest.tcl b/tests/xschemtest.tcl index fdcfe894..856d1ccb 100644 --- a/tests/xschemtest.tcl +++ b/tests/xschemtest.tcl @@ -162,18 +162,21 @@ proc test_xschem_simulation {{f simulate_ff.sch}} { proc netlist_test {} { global netlist_dir foreach {f t h} { - rom8k.sch spice 1466291334 - greycnt.sch verilog 3391559642 - autozero_comp.sch spice 2011673313 - loading.sch vhdl 2601437773 - mos_power_ampli.sch spice 1186348644 - LCC_instances.sch spice 824427889 - simulate_ff.sch spice 1321596936 + rom8k.sch spice 1466291334 + greycnt.sch verilog 3391559642 + autozero_comp.sch spice 2011673313 + loading.sch vhdl 2601437773 + mos_power_ampli.sch spice 1186348644 + hierarchical_tedax.sch tedax 998070173 + LCC_instances.sch spice 824427889 + pcb_test1.sch tedax 1295717013 + simulate_ff.sch spice 1321596936 } { xschem set netlist_type $t xschem load [abs_sym_path $f] xschem netlist if {$t eq {verilog}} { set t v} + if {$t eq {tedax}} { set t tdx} set netlist_file $netlist_dir/[file rootname $f].$t ## check netlist hashes, compare with gold hashes set netlist_hash [xschem hash_file $netlist_file 1]