Skip to content

Commit

Permalink
dft: preserve region/group/source_type in ReplaceCell
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Liberty <[email protected]>
  • Loading branch information
maliberty committed Dec 31, 2024
1 parent cfca311 commit 89f7a56
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 25 deletions.
32 changes: 23 additions & 9 deletions src/dft/src/utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,28 @@ odb::dbInst* ReplaceCell(
std::vector<std::tuple<std::string, odb::dbNet*>> 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
Expand All @@ -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;
}
Expand Down
28 changes: 28 additions & 0 deletions src/dft/test/one_cell_sky130.def
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions src/dft/test/one_cell_sky130.defok
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions src/dft/test/one_cell_sky130.ok
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -61,3 +65,4 @@ Instance ff1
Q output output1
Q_N output (unconnected)
No differences found.
No differences found.
7 changes: 5 additions & 2 deletions src/dft/test/one_cell_sky130.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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}]

Expand All @@ -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
14 changes: 0 additions & 14 deletions src/dft/test/one_cell_sky130.v

This file was deleted.

0 comments on commit 89f7a56

Please sign in to comment.