Skip to content

Commit 7f08365

Browse files
committed
check if user specified latch cell is a valid latch when using with -use_latch
Signed-off-by: Thinh Nguyen <nguyenthinh19011@gmail.com>
1 parent 77b3f76 commit 7f08365

1 file changed

Lines changed: 23 additions & 7 deletions

File tree

src/ram/src/ram.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,17 +1123,33 @@ void RamGen::generate(const int mask_size,
11231123
buffer_cell_ = nullptr;
11241124
aoi22_cell_ = nullptr;
11251125
latch_cell_ = nullptr;
1126-
findMasters();
11271126

1128-
// using -use_latch will override specified storage cell to avoid collision in
1129-
// what storage cells are used
11301127
if (use_latch_ && storage_cell_) {
1131-
logger_->warn(RAM,
1132-
37,
1133-
"-storage_cell is ignored when -use_latch is enabled. Latch "
1134-
"cells will be auto selected from the library instead.");
1128+
auto sta_cell = network_->dbToSta(storage_cell_);
1129+
auto liberty = network_->libertyCell(sta_cell);
1130+
bool is_latch = false;
1131+
auto port_iter = std::unique_ptr<sta::ConcreteCellPortIterator>(
1132+
liberty->portIterator());
1133+
while (port_iter->hasNext()) {
1134+
auto lp = port_iter->next()->libertyPort();
1135+
if (lp && lp->isLatchData()) {
1136+
is_latch = true;
1137+
break;
1138+
}
1139+
}
1140+
if (!is_latch) {
1141+
logger_->error(RAM,
1142+
37,
1143+
"-storage_cell {} is not a latch cell. Please provide a "
1144+
"latch cell when setting -use_latch 1.",
1145+
storage_cell_->getName());
1146+
}
1147+
latch_cell_ = storage_cell_;
1148+
storage_cell_ = nullptr;
11351149
}
11361150

1151+
findMasters();
1152+
11371153
auto chip = db_->getChip();
11381154
if (!chip) {
11391155
chip = odb::dbChip::create(

0 commit comments

Comments
 (0)