From 89f7a56843dae0419009045298c664e88e71bd06 Mon Sep 17 00:00:00 2001 From: Matt Liberty Date: Tue, 31 Dec 2024 20:40:26 +0000 Subject: [PATCH] dft: preserve region/group/source_type in ReplaceCell Signed-off-by: Matt Liberty --- src/dft/src/utils/Utils.cpp | 32 +++++++++++++++++++++--------- src/dft/test/one_cell_sky130.def | 28 ++++++++++++++++++++++++++ src/dft/test/one_cell_sky130.defok | 31 +++++++++++++++++++++++++++++ src/dft/test/one_cell_sky130.ok | 5 +++++ src/dft/test/one_cell_sky130.tcl | 7 +++++-- src/dft/test/one_cell_sky130.v | 14 ------------- 6 files changed, 92 insertions(+), 25 deletions(-) create mode 100644 src/dft/test/one_cell_sky130.def create mode 100644 src/dft/test/one_cell_sky130.defok delete mode 100644 src/dft/test/one_cell_sky130.v diff --git a/src/dft/src/utils/Utils.cpp b/src/dft/src/utils/Utils.cpp index 5ad9fde30b8..24f89617464 100644 --- a/src/dft/src/utils/Utils.cpp +++ b/src/dft/src/utils/Utils.cpp @@ -85,14 +85,28 @@ odb::dbInst* ReplaceCell( std::vector> port_name_to_net; PopulatePortNameToNet(old_instance, port_name_to_net); - odb::dbInst* new_instance - = odb::dbInst::create(top_block, new_master, /*name=*/"tmp_scan_flop"); - std::string old_cell_name = old_instance->getName(); - - odb::dbPlacementStatus placement_status = old_instance->getPlacementStatus(); - if (placement_status.isPlaced()) { - new_instance->setTransform(old_instance->getTransform()); - new_instance->setPlacementStatus(placement_status); + const std::string cell_name = old_instance->getName(); + const odb::dbPlacementStatus placement_status + = old_instance->getPlacementStatus(); + const odb::dbSourceType source_type = old_instance->getSourceType(); + odb::dbRegion* region = old_instance->getRegion(); + odb::dbGroup* group = old_instance->getGroup(); + odb::dbModule* module = old_instance->getModule(); + + odb::dbInst* new_instance = odb::dbInst::create(top_block, + new_master, + /*name=*/"tmp_scan_flop", + /*physical_only=*/false, + module); + + new_instance->setTransform(old_instance->getTransform()); + new_instance->setPlacementStatus(placement_status); + new_instance->setSourceType(source_type); + if (region) { + region->addInst(new_instance); + } + if (group) { + group->addInst(new_instance); } // Delete the old cell @@ -102,7 +116,7 @@ odb::dbInst* ReplaceCell( ConnectPinsToNets(new_instance, port_name_to_net, port_mapping); // Rename as the old cell - new_instance->rename(old_cell_name.c_str()); + new_instance->rename(cell_name.c_str()); return new_instance; } diff --git a/src/dft/test/one_cell_sky130.def b/src/dft/test/one_cell_sky130.def new file mode 100644 index 00000000000..ed7aa06fc53 --- /dev/null +++ b/src/dft/test/one_cell_sky130.def @@ -0,0 +1,28 @@ +VERSION 5.8 ; +DIVIDERCHAR "/" ; +BUSBITCHARS "[]" ; +DESIGN one_cell ; +UNITS DISTANCE MICRONS 1000 ; +REGIONS 1 ; + - region ( 0 0 ) ( 2000 2000 ) ; +END REGIONS +COMPONENTS 1 ; + - ff1 sky130_fd_sc_hd__dfstp_1 + PLACED ( 1000 1000 ) N + + REGION region ; +END COMPONENTS +GROUPS 1 ; + - group ff1 + REGION region ; +END GROUPS +PINS 4 ; + - clock + NET clock + DIRECTION INPUT + USE SIGNAL ; + - output1 + NET output1 + DIRECTION OUTPUT + USE SIGNAL ; + - port1 + NET port1 + DIRECTION INPUT + USE SIGNAL ; + - set_b + NET set_b + DIRECTION INPUT + USE SIGNAL ; +END PINS +NETS 4 ; + - clock ( PIN clock ) ( ff1 CLK ) + USE SIGNAL ; + - output1 ( PIN output1 ) ( ff1 Q ) + USE SIGNAL ; + - port1 ( PIN port1 ) ( ff1 D ) + USE SIGNAL ; + - set_b ( PIN set_b ) ( ff1 SET_B ) + USE SIGNAL ; +END NETS +END DESIGN diff --git a/src/dft/test/one_cell_sky130.defok b/src/dft/test/one_cell_sky130.defok new file mode 100644 index 00000000000..b9944f9e2fb --- /dev/null +++ b/src/dft/test/one_cell_sky130.defok @@ -0,0 +1,31 @@ +VERSION 5.8 ; +DIVIDERCHAR "/" ; +BUSBITCHARS "[]" ; +DESIGN one_cell ; +UNITS DISTANCE MICRONS 1000 ; +REGIONS 1 ; + - region ( 0 0 ) ( 2000 2000 ) ; +END REGIONS +COMPONENTS 1 ; + - ff1 sky130_fd_sc_hd__sdfsbp_1 + PLACED ( 1000 1000 ) N + REGION region ; +END COMPONENTS +PINS 6 ; + - clock + NET clock + DIRECTION INPUT + USE SIGNAL ; + - output1 + NET output1 + DIRECTION OUTPUT + USE SIGNAL ; + - port1 + NET port1 + DIRECTION INPUT + USE SIGNAL ; + - scan_enable_1 + NET scan_enable_1 + DIRECTION INPUT + USE SCAN ; + - scan_in_1 + NET scan_in_1 + DIRECTION INPUT + USE SCAN ; + - set_b + NET set_b + DIRECTION INPUT + USE SIGNAL ; +END PINS +NETS 6 ; + - clock ( PIN clock ) ( ff1 CLK ) + USE SIGNAL ; + - output1 ( PIN output1 ) ( ff1 Q ) + USE SIGNAL ; + - port1 ( PIN port1 ) ( ff1 D ) + USE SIGNAL ; + - scan_enable_1 ( PIN scan_enable_1 ) ( ff1 SCE ) + USE SCAN ; + - scan_in_1 ( PIN scan_in_1 ) ( ff1 SCD ) + USE SCAN ; + - set_b ( PIN set_b ) ( ff1 SET_B ) + USE SIGNAL ; +END NETS +GROUPS 1 ; + - group ff1 + REGION region ; +END GROUPS +END DESIGN diff --git a/src/dft/test/one_cell_sky130.ok b/src/dft/test/one_cell_sky130.ok index ab785342e9b..40eaa9eb698 100644 --- a/src/dft/test/one_cell_sky130.ok +++ b/src/dft/test/one_cell_sky130.ok @@ -1,5 +1,9 @@ [INFO ODB-0227] LEF file: sky130hd/sky130hd.tlef, created 13 layers, 25 vias [INFO ODB-0227] LEF file: sky130hd/sky130_fd_sc_hd_merged.lef, created 437 library cells +[INFO ODB-0128] Design: one_cell +[INFO ODB-0130] Created 4 pins. +[INFO ODB-0131] Created 1 components and 6 component-terminals. +[INFO ODB-0133] Created 4 nets and 4 connections. Instance ff1 Cell: sky130_fd_sc_hd__dfstp_1 Library: sky130_fd_sc_hd_merged @@ -61,3 +65,4 @@ Instance ff1 Q output output1 Q_N output (unconnected) No differences found. +No differences found. diff --git a/src/dft/test/one_cell_sky130.tcl b/src/dft/test/one_cell_sky130.tcl index 6fbe1928940..f80485d9ca2 100644 --- a/src/dft/test/one_cell_sky130.tcl +++ b/src/dft/test/one_cell_sky130.tcl @@ -4,8 +4,7 @@ read_lef sky130hd/sky130hd.tlef read_lef sky130hd/sky130_fd_sc_hd_merged.lef read_liberty sky130hd/sky130_fd_sc_hd__tt_025C_1v80.lib -read_verilog one_cell_sky130.v -link_design one_cell +read_def one_cell_sky130.def create_clock -name main_clock -period 2.0000 -waveform {0.0000 1.0000} [get_ports {clock}] @@ -22,3 +21,7 @@ report_instance ff1 set verilog_file [make_result_file one_cell_sky130.v] write_verilog $verilog_file diff_files $verilog_file one_cell_sky130.vok + +set def_file [make_result_file one_cell_sky130.def] +write_def $def_file +diff_files $def_file one_cell_sky130.defok diff --git a/src/dft/test/one_cell_sky130.v b/src/dft/test/one_cell_sky130.v deleted file mode 100644 index 961c63ff082..00000000000 --- a/src/dft/test/one_cell_sky130.v +++ /dev/null @@ -1,14 +0,0 @@ -module one_cell(port1, clock, output1, set_b); - input port1; - input clock; - input set_b; - output output1; - - sky130_fd_sc_hd__dfstp_1 ff1( - .Q(output1), - .D(port1), - .CLK(clock), - .SET_B(set_b) - ); - -endmodule