diff --git a/src/est/src/EstimateParasitics.cpp b/src/est/src/EstimateParasitics.cpp index 4e0ee2cdebc..3188c9f85cf 100644 --- a/src/est/src/EstimateParasitics.cpp +++ b/src/est/src/EstimateParasitics.cpp @@ -1324,6 +1324,21 @@ void EstimateParasitics::setParasiticsSrc(ParasiticsSrc src) void EstimateParasitics::eraseParasitics(const sta::Net* net) { + // Deleting a dbNet only disconnects its parasitic network's pin nodes, and + // sta::Net* is the dbNet pointer, so once odb recycles the slot the next net + // inherits a driver-less network. Delete it, not just the invalid marker. + // + // deleteParasiticNetwork() and not deleteParasitics(): the latter resolves + // drivers(net), which by now has no driver and would cache an empty entry + // keyed on a dbNet about to be freed. + for (Scene* scene : scenes_) { + for (const sta::MinMax* mm : sta::MinMax::range()) { + Parasitics* parasitics = scene->parasitics(mm); + if (parasitics) { + parasitics->deleteParasiticNetwork(net); + } + } + } parasitics_invalid_.erase(net); } diff --git a/src/est/test/BUILD b/src/est/test/BUILD index e73651a5898..1f546febf09 100644 --- a/src/est/test/BUILD +++ b/src/est/test/BUILD @@ -14,6 +14,7 @@ TESTS = [ "make_parasitics5", "make_parasitics6", "make_parasitics7", + "prima_net_recycle", "set_wire_rc_tech", "set_wire_rc_tech_errors", "set_wire_rc_rdl_ignored", @@ -41,7 +42,11 @@ filegroup( [regression_test( name = test_name, - data = [":test_resources"], + data = [ + ":test_resources", + "//test:asap7_ccs_data", + "//test:asap7_data", + ], ) for test_name in TESTS] cc_test( diff --git a/src/est/test/CMakeLists.txt b/src/est/test/CMakeLists.txt index 5309e233568..b48fe21418d 100644 --- a/src/est/test/CMakeLists.txt +++ b/src/est/test/CMakeLists.txt @@ -10,6 +10,7 @@ or_integration_tests( make_parasitics5 make_parasitics6 make_parasitics7 + prima_net_recycle set_wire_rc_tech set_wire_rc_tech_errors set_wire_rc_rdl_ignored diff --git a/src/est/test/prima_net_recycle.def b/src/est/test/prima_net_recycle.def new file mode 100644 index 00000000000..4cfffe1664e --- /dev/null +++ b/src/est/test/prima_net_recycle.def @@ -0,0 +1,49 @@ +VERSION 5.8 ; +DIVIDERCHAR "/" ; +BUSBITCHARS "[]" ; +DESIGN prima_net_recycle ; +UNITS DISTANCE MICRONS 1000 ; +DIEAREA ( 0 0 ) ( 4000 4000 ) ; +ROW ROW_0 asap7sc7p5t 540 540 N DO 54 BY 1 STEP 54 0 ; +ROW ROW_1 asap7sc7p5t 540 810 FS DO 54 BY 1 STEP 54 0 ; +ROW ROW_2 asap7sc7p5t 540 1080 N DO 54 BY 1 STEP 54 0 ; +ROW ROW_3 asap7sc7p5t 540 1350 FS DO 54 BY 1 STEP 54 0 ; +ROW ROW_4 asap7sc7p5t 540 1620 N DO 54 BY 1 STEP 54 0 ; +ROW ROW_5 asap7sc7p5t 540 1890 FS DO 54 BY 1 STEP 54 0 ; +ROW ROW_6 asap7sc7p5t 540 2160 N DO 54 BY 1 STEP 54 0 ; +ROW ROW_7 asap7sc7p5t 540 2430 FS DO 54 BY 1 STEP 54 0 ; +ROW ROW_8 asap7sc7p5t 540 2700 N DO 54 BY 1 STEP 54 0 ; +ROW ROW_9 asap7sc7p5t 540 2970 FS DO 54 BY 1 STEP 54 0 ; +COMPONENTS 6 ; + - l0 INVx2_ASAP7_75t_R + PLACED ( 2376 2430 ) FS ; + - l1 INVx2_ASAP7_75t_R + PLACED ( 2700 1890 ) FS ; + - l2 INVx2_ASAP7_75t_R + PLACED ( 2700 2160 ) N ; + - r1 DFFHQx4_ASAP7_75t_R + PLACED ( 1674 2700 ) N ; + - r2 DFFHQx4_ASAP7_75t_R + PLACED ( 1998 2970 ) FS ; + - u1 INVx2_ASAP7_75t_R + PLACED ( 2754 2430 ) FS ; +END COMPONENTS +PINS 3 ; + - clk + NET clk + DIRECTION INPUT + USE SIGNAL + + PORT + + LAYER M5 ( -12 -42 ) ( 12 42 ) + + PLACED ( 2124 3958 ) N ; + - in + NET in + DIRECTION INPUT + USE SIGNAL + + PORT + + LAYER M5 ( -12 -42 ) ( 12 42 ) + + PLACED ( 1932 3958 ) N ; + - out + NET out + DIRECTION OUTPUT + USE SIGNAL + + PORT + + LAYER M5 ( -12 -42 ) ( 12 42 ) + + PLACED ( 2028 3958 ) N ; +END PINS +NETS 8 ; + - clk ( PIN clk ) ( r2 CLK ) ( r1 CLK ) + USE SIGNAL ; + - d1 ( l1 Y ) + USE SIGNAL ; + - d2 ( l2 Y ) + USE SIGNAL ; + - in ( PIN in ) ( r1 D ) + USE SIGNAL ; + - n0 ( u1 A ) ( r1 Q ) + USE SIGNAL ; + - n1 ( u1 Y ) ( l2 A ) ( l1 A ) ( l0 A ) + USE SIGNAL ; + - n2 ( r2 D ) ( l0 Y ) + USE SIGNAL ; + - out ( PIN out ) ( r2 Q ) + USE SIGNAL ; +END NETS +END DESIGN diff --git a/src/est/test/prima_net_recycle.ok b/src/est/test/prima_net_recycle.ok new file mode 100644 index 00000000000..04820bafd5e --- /dev/null +++ b/src/est/test/prima_net_recycle.ok @@ -0,0 +1,9 @@ +[INFO ODB-0227] LEF file: ../../../test/asap7/asap7_tech_1x_201209.lef, created 30 layers, 9 vias +[INFO ODB-0227] LEF file: ../../../test/asap7/asap7sc7p5t_28_R_1x_220121a.lef, created 212 library cells +[INFO ODB-0127] Reading DEF file: prima_net_recycle.def +[INFO ODB-0128] Design: prima_net_recycle +[INFO ODB-0130] Created 3 pins. +[INFO ODB-0131] Created 6 components and 26 component-terminals. +[INFO ODB-0133] Created 8 nets and 14 connections. +[INFO ODB-0134] Finished DEF file: prima_net_recycle.def +worst slack max 402.83 diff --git a/src/est/test/prima_net_recycle.tcl b/src/est/test/prima_net_recycle.tcl new file mode 100644 index 00000000000..10b21125d24 --- /dev/null +++ b/src/est/test/prima_net_recycle.tcl @@ -0,0 +1,43 @@ +# Destroying a dbNet must delete its parasitic network annotation. +# +# sta::Net* is the dbNet pointer (dbNetwork::dbToSta is a reinterpret_cast) and +# ConcreteParasitics keys parasitic_network_map_ by it. dbNet::destroy() only +# disconnects the network's pin nodes, leaving a driver-less network annotated +# on the dead net. odb recycles the dbNet slot, so the next net created lands +# on the same sta::Net* and inherits it. PrimaDelayCalc then finds no node for +# its driver pin, builds a zero-node circuit, and indexes an empty +# threshold_times_ -- before the fix this aborted here. +# +# prima is required: the default calculator reduces each network to pi-Elmore +# and deletes it, so there is nothing left to inherit. It must also be +# selected before estimate_parasitics for the same reason. +read_lef ../../../test/asap7/asap7_tech_1x_201209.lef +read_lef ../../../test/asap7/asap7sc7p5t_28_R_1x_220121a.lef +read_liberty ../../../test/asap7/asap7_small_ccs.lib.gz +read_def prima_net_recycle.def + +create_clock -name clk -period 500 clk +set_input_delay -clock clk 0 in +set_input_transition 10 {clk in} + +set_layer_rc -layer M3 -resistance 3.63251E-02 -capacitance 1.53955E-01 +set_wire_rc -layer M3 +sta::set_delay_calculator prima +estimate_parasitics -placement + +# Rebuild n1 with the identical pin set. The netlist is unchanged afterwards; +# only the recycled sta::Net* differs. +set block [ord::get_db_block] +set net [$block findNet n1] +set pins {} +foreach iterm [$net getITerms] { + lappend pins [list [[$iterm getInst] getName] [[$iterm getMTerm] getName]] +} +odb::dbNet_destroy $net + +set net [odb::dbNet_create $block n1] +foreach pin $pins { + odb::dbITerm_connect [[$block findInst [lindex $pin 0]] findITerm [lindex $pin 1]] $net +} + +report_worst_slack -max diff --git a/src/est/test/prima_net_recycle.v b/src/est/test/prima_net_recycle.v new file mode 100644 index 00000000000..629de87096d --- /dev/null +++ b/src/est/test/prima_net_recycle.v @@ -0,0 +1,25 @@ +// Minimal asap7 netlist for prima_net_recycle. +// Only cells present in asap7/asap7_small.lib.gz (the in-tree CCS liberty). +// +// l0/l1/l2 exist to load n1 past 1.44fF, the lowest +// total_output_net_capacitance in the CCS tables. Below that, +// PrimaDelayCalc::checkArgs() falls back to the table calculator and the +// stale-parasitic path is never reached. +module prima_net_recycle (clk, in, out); + input clk; + input in; + output out; + + wire n0; + wire n1; + wire n2; + wire d1; + wire d2; + + DFFHQx4_ASAP7_75t_R r1 (.CLK(clk), .D(in), .Q(n0)); + INVx2_ASAP7_75t_R u1 (.A(n0), .Y(n1)); + INVx2_ASAP7_75t_R l0 (.A(n1), .Y(n2)); + INVx2_ASAP7_75t_R l1 (.A(n1), .Y(d1)); + INVx2_ASAP7_75t_R l2 (.A(n1), .Y(d2)); + DFFHQx4_ASAP7_75t_R r2 (.CLK(clk), .D(n2), .Q(out)); +endmodule diff --git a/test/BUILD b/test/BUILD index f9917185a0c..21745f4f923 100644 --- a/test/BUILD +++ b/test/BUILD @@ -116,6 +116,24 @@ filegroup( visibility = ["//visibility:public"], ) +filegroup( + name = "asap7_data", + srcs = [ + "asap7/asap7_tech_1x_201209.lef", + "asap7/asap7sc7p5t_28_R_1x_220121a.lef", + ], + visibility = ["//visibility:public"], +) + +# CCS (current source model) liberty. Required by delay calculators that need +# output current waveforms, e.g. prima; the asap7 libs above are NLDM only. +# Holds four cells: AND2x2, BUFx2, DFFHQx4, INVx2. +filegroup( + name = "asap7_ccs_data", + srcs = ["asap7/asap7_small_ccs.lib.gz"], + visibility = ["//visibility:public"], +) + filegroup( name = "regression_resources", # TODO Refine glob later. diff --git a/test/asap7/asap7_small_ccs.lib.gz b/test/asap7/asap7_small_ccs.lib.gz new file mode 100644 index 00000000000..47c561fb121 Binary files /dev/null and b/test/asap7/asap7_small_ccs.lib.gz differ