Skip to content

Commit

Permalink
Merge in latest master
Browse files Browse the repository at this point in the history
Signed-off-by: andyfox-rushc <[email protected]>
  • Loading branch information
andyfox-rushc committed Dec 3, 2024
2 parents e639568 + dca06c6 commit 523fda1
Show file tree
Hide file tree
Showing 173 changed files with 595,066 additions and 589,834 deletions.
82 changes: 82 additions & 0 deletions src/OpenRoad.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,88 @@ proc add_global_connection { args } {
$keys(-pin_pattern) $net $do_connect
}

sta::define_cmd_args "place_inst" {-name inst_name \
-orientation orientation
-origin xy_origin \
[-cell library_cell] \
[-status status]}
proc place_inst { args } {
if { [ord::get_db_block] == "NULL" } {
utl::error ORD 55 "Design must be loaded before calling place_cell."
}

set db [ord::get_db]
set block [ord::get_db_block]

sta::parse_key_args "place_cell" args \
keys {-cell -origin -orientation -name -status}

set placement_status "PLACED"
if { [info exists keys(-status)] } {
set placement_status $keys(-status)
}

if { [info exists keys(-cell)] } {
set cell_name $keys(-cell)
if { [set cell_master [$db findMaster $cell_name]] == "NULL" } {
utl::error ORD 56 "Cell $cell_name not loaded into design."
}
}

if { [info exists keys(-name)] } {
set inst_name [lindex $keys(-name) 0]
} else {
utl::error ORD 57 "-name is a required argument to the place_cell command."
}

if { [info exists keys(-orientation)] } {
set orient $keys(-orientation)
} else {
utl::error ORD 58 "No orientation specified for $inst_name."
}

# Verify center/origin
if { [info exists keys(-origin)] } {
set origin $keys(-origin)
if { [llength $origin] != 2 } {
utl::error ORD 59 "Origin is $origin, but must be a list of 2 numbers."
}
if { [catch { set x [ord::microns_to_dbu [lindex $origin 0]] } msg] } {
utl::error ORD 60 "Invalid value specified for x value, [lindex $origin 0], $msg."
}
if { [catch { set y [ord::microns_to_dbu [lindex $origin 1]] } msg] } {
utl::error ORD 61 "Invalid value specified for y value, [lindex $origin 1], $msg."
}
} else {
utl::error ORD 62 "No origin specified for $inst_name."
}

if { [set inst [$block findInst $inst_name]] == "NULL" } {
if { [info exists keys(-cell)] } {
set inst [odb::dbInst_create $block $cell_master $inst_name]
} else {
utl::error ORD 63 \
"Instance $inst_name not in the design, -cell must be specified to create a new instance."
}
} else {
if { [info exists keys(-cell)] } {
set master_name [[$inst getMaster] getName]
if { $master_name != $cell_name } {
utl::error ORD 64 \
"Instance $inst_name expected to be $cell_name, but is actually $master_name."
}
}
}

if { $inst == "NULL" } {
utl::error ORD 65 "Cannot create instance $inst_name of $cell_name."
}

$inst setOrigin $x $y
$inst setOrient $orient
$inst setPlacementStatus $placement_status
}

################################################################

namespace eval ord {
Expand Down
22 changes: 22 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,28 @@ ord::get_die_area
ord::get_core_area
```

The `place_inst` command is used to place an instance. If -cell is
given then a new instance may be created as well as placed.

```
sta::define_cmd_args "place_inst" {-name inst_name \
-orientation orientation
-origin xy_origin \
[-cell library_cell] \
[-status status]}
```

##### Options

| Switch Name | Description |
| ----- | ----- |
| `-name` | The name of the instance |
| `-orientaton` | The orientation of the instance. |
| `-origin` | The x and y coordinates for where the instance is placed. |
| `[-cell]` | Required if a new instance is to be created. |
| `[-status]` | The placement status of the instance. Default PLACED |


## FAQs

Check out [GitHub discussion](https://github.com/The-OpenROAD-Project/OpenROAD/discussions/categories/q-a?discussions_q=category%3AQ%26A+openroad+in%3Atitle)
Expand Down
3 changes: 1 addition & 2 deletions src/dbSta/include/db_sta/dbNetwork.hh
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ class dbNetwork : public ConcreteNetwork
std::vector<dbModule*>& parent_hierarchy);
dbModule* findHighestCommonModule(std::vector<dbModule*>& itree1,
std::vector<dbModule*>& itree2);
dbModule* findModule(const char* name);
Instance* findHierInstance(const char* name);
void replaceDesign(Instance* instance, dbModule* module);
void replaceDesign(dbModInst* mod_inst, dbModule* module);

////////////////////////////////////////////////////////////////
//
Expand Down
59 changes: 2 additions & 57 deletions src/dbSta/src/dbNetwork.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3181,64 +3181,9 @@ void dbNetwork::hierarchicalConnect(dbITerm* source_pin,
}
}

// Find a hierarchical module with a given name
// TODO: support finding uninstantiated modules
dbModule* dbNetwork::findModule(const char* name)
{
dbModule* module = nullptr;
Instance* top_inst = topInstance();
std::unique_ptr<InstanceChildIterator> child_iter{childIterator(top_inst)};
while (child_iter->hasNext()) {
Instance* child = child_iter->next();
if (network_->isHierarchical(child)) {
dbInst* db_inst;
dbModInst* mod_inst;
staToDb(child, db_inst, mod_inst);
if (mod_inst) {
dbModule* master = mod_inst->getMaster();
if (master) {
if (strcmp(master->getName(), name) == 0) {
module = master;
break;
}
}
}
}
}
return module;
}

// Find a hierarchical instance with a given name
Instance* dbNetwork::findHierInstance(const char* name)
{
Instance* inst = nullptr;
Instance* top_inst = topInstance();
std::unique_ptr<InstanceChildIterator> child_iter{childIterator(top_inst)};
while (child_iter->hasNext()) {
Instance* child = child_iter->next();
if (network_->isHierarchical(child)
&& strcmp(network_->name(child), name) == 0) {
inst = child;
break;
}
}
return inst;
}

void dbNetwork::replaceDesign(Instance* instance, dbModule* module)
void dbNetwork::replaceDesign(dbModInst* mod_inst, dbModule* module)
{
dbInst* db_inst;
dbModInst* mod_inst;
staToDb(instance, db_inst, mod_inst);
if (mod_inst) {
mod_inst->swapMaster(module);
} else {
logger_->error(ORD,
1104,
"Instance {} cannot be replaced because it is not a "
"hierarchical module",
network_->name(instance));
}
mod_inst->swapMaster(module);
}

} // namespace sta
20 changes: 2 additions & 18 deletions src/dbSta/src/dbSta.i
Original file line number Diff line number Diff line change
Expand Up @@ -190,28 +190,12 @@ write_verilog_cmd(const char *filename,
delete remove_cells;
}

Instance*
find_hier_inst_cmd(const char *name)
{
ord::OpenRoad *openroad = ord::getOpenRoad();
sta::dbNetwork *db_network = openroad->getDbNetwork();
return db_network->findHierInstance(name);
}

odb::dbModule*
find_module_cmd(const char *name)
{
ord::OpenRoad *openroad = ord::getOpenRoad();
sta::dbNetwork *db_network = openroad->getDbNetwork();
return db_network->findModule(name);
}

void
replace_design_cmd(Instance* inst, odb::dbModule* module)
replace_design_cmd(odb::dbModInst* mod_inst, odb::dbModule* module)
{
ord::OpenRoad *openroad = ord::getOpenRoad();
sta::dbNetwork *db_network = openroad->getDbNetwork();
db_network->replaceDesign(inst, module);
db_network->replaceDesign(mod_inst, module);
}

%} // inline
9 changes: 6 additions & 3 deletions src/dbSta/src/dbSta.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,11 @@ define_cmd_args "replace_design" {instance module}
proc replace_design { instance module } {
set design [get_design_error $module]
if { $design != "NULL" } {
set inst [find_hier_inst_cmd $instance]
replace_design_cmd $inst $design
set modinst [[ord::get_db_block] findModInst $instance]
if { $modinst == "NULL" } {
sta_error 1003 "Unable to find $instance"
}
replace_design_cmd $modinst $design
return 1
}
return 0
Expand All @@ -128,7 +131,7 @@ proc get_design_error { arg } {
if { [llength $arg] > 1 } {
sta_error 200 "module must be a single module."
}
set design [find_module_cmd $arg]
set design [[ord::get_db_block] findModule $arg]
if { $design == "NULL" } {
sta_error 201 "module $arg cannot be found."
}
Expand Down
2 changes: 2 additions & 0 deletions src/dpl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ from `FILLER_` use `-prefix <new prefix>`.
```tcl
filler_placement
[-prefix prefix]
[-verbose]
filler_masters
```

Expand All @@ -87,6 +88,7 @@ filler_placement
| Switch Name | Description |
| ----- | ----- |
| `-prefix` | Prefix to name the filler cells. The default value is `FILLER_`. |
| `-verbose` | Print the filler cell usage. |
| `filler_masters` | Filler master cells. |

### Remove Fillers
Expand Down
6 changes: 4 additions & 2 deletions src/dpl/include/dpl/Opendp.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ class Opendp
void checkPlacement(bool verbose,
bool disallow_one_site_gaps = false,
const string& report_file_name = "");
void fillerPlacement(dbMasterSeq* filler_masters, const char* prefix);
void fillerPlacement(dbMasterSeq* filler_masters,
const char* prefix,
bool verbose);
void removeFillers();
void optimizeMirroring();

Expand Down Expand Up @@ -363,7 +365,7 @@ class Opendp
// Filler placement.
// gap (in sites) -> seq of masters by implant
map<dbTechLayer*, GapFillers> gap_fillers_;
int filler_count_ = 0;
map<dbMaster*, int> filler_count_;
bool have_fillers_ = false;
bool have_one_site_cells_ = false;

Expand Down
1 change: 0 additions & 1 deletion src/dpl/src/CheckPlacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,6 @@ bool Opendp::isCrWtBlClass(const Cell* cell)
case dbMasterType::PAD_INOUT:
case dbMasterType::PAD_POWER:
case dbMasterType::PAD_SPACER:
case dbMasterType::NONE:
return false;
}
// gcc warniing
Expand Down
31 changes: 27 additions & 4 deletions src/dpl/src/FillerPlacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ Opendp::MasterByImplant Opendp::splitByImplant(dbMasterSeq* filler_masters)
return mapping;
}

void Opendp::fillerPlacement(dbMasterSeq* filler_masters, const char* prefix)
void Opendp::fillerPlacement(dbMasterSeq* filler_masters,
const char* prefix,
bool verbose)
{
if (cells_.empty()) {
importDb();
Expand All @@ -92,15 +94,36 @@ void Opendp::fillerPlacement(dbMasterSeq* filler_masters, const char* prefix)
}

gap_fillers_.clear();
filler_count_ = 0;
filler_count_.clear();
initGrid();
setGridCells();

for (GridY row{0}; row < grid_->getRowCount(); row++) {
placeRowFillers(row, prefix, filler_masters_by_implant);
}

logger_->info(DPL, 1, "Placed {} filler instances.", filler_count_);
int filler_count = 0;
int max_filler_master = 0;
for (const auto& [master, count] : filler_count_) {
filler_count += count;
max_filler_master = std::max(max_filler_master, count);
}
logger_->info(DPL, 1, "Placed {} filler instances.", filler_count);

if (verbose) {
logger_->report("Filler usage:");
int max_master_len = 0;
for (const auto& [master, count] : filler_count_) {
max_master_len = std::max(max_master_len,
static_cast<int>(master->getName().size()));
}
const int count_offset = fmt::format("{}", max_filler_master).size();
for (const auto& [master, count] : filler_count_) {
const int line_offset
= count_offset + max_master_len - master->getName().size();
logger_->report(" {}: {:>{}}", master->getName(), count, line_offset);
}
}
}

void Opendp::setGridCells()
Expand Down Expand Up @@ -197,7 +220,7 @@ void Opendp::placeRowFillers(GridY row,
inst->setLocation(x.v, y.v);
inst->setPlacementStatus(dbPlacementStatus::PLACED);
inst->setSourceType(odb::dbSourceType::DIST);
filler_count_++;
filler_count_[master]++;
k += master->getWidth() / site_width.v;
}
j += gap;
Expand Down
1 change: 0 additions & 1 deletion src/dpl/src/Objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ bool Cell::isStdCell() const
case dbMasterType::PAD_INOUT:
case dbMasterType::PAD_POWER:
case dbMasterType::PAD_SPACER:
case dbMasterType::NONE:
return false;
}
// gcc warniing
Expand Down
5 changes: 3 additions & 2 deletions src/dpl/src/Opendp.i
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ set_padding_inst(odb::dbInst *inst,

void
filler_placement_cmd(dpl::dbMasterSeq *filler_masters,
const char* prefix)
const char* prefix,
bool verbose)
{
dpl::Opendp *opendp = ord::OpenRoad::openRoad()->getOpendp();
opendp->fillerPlacement(filler_masters, prefix);
opendp->fillerPlacement(filler_masters, prefix, verbose);
}

void
Expand Down
6 changes: 3 additions & 3 deletions src/dpl/src/Opendp.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ proc set_placement_padding { args } {
}
}

sta::define_cmd_args "filler_placement" { [-prefix prefix] filler_masters }
sta::define_cmd_args "filler_placement" { [-prefix prefix] [-verbose] filler_masters }

proc filler_placement { args } {
sta::parse_key_args "filler_placement" args \
keys {-prefix} flags {}
keys {-prefix} flags {-verbose}

set prefix "FILLER_"
if { [info exists keys(-prefix)] } {
Expand All @@ -133,7 +133,7 @@ proc filler_placement { args } {

sta::check_argc_eq1 "filler_placement" $args
set filler_masters [dpl::get_masters_arg "filler_masters" [lindex $args 0]]
dpl::filler_placement_cmd $filler_masters $prefix
dpl::filler_placement_cmd $filler_masters $prefix [info exists flags(-verbose)]
}

sta::define_cmd_args "remove_fillers" {}
Expand Down
Loading

0 comments on commit 523fda1

Please sign in to comment.