Filter out redundant plugs that have no connection inside cell while export Verilog netlist. (#84)

Co-authored-by: Serge Rabyking <serge.rabyking@chipflow.io>
This commit is contained in:
lanserge 2023-11-10 13:56:58 +00:00 committed by GitHub
parent 8e5db42aff
commit 500d4446c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 0 deletions

View File

@ -112,6 +112,21 @@ namespace CRL {
return bus;
}
static bool _cellHasNetPlug(Cell* cell, Net* net)
{
for(Instance* instance: cell->getInstances()) // go through all cells instances that form our cell
{
for(Plug* plug: instance->getPlugs()) // plugs are connect points of the cells
{
if (plug->getNet() == net)
{
return true;
}
}
}
return false;
}
static void _write_cell(ofstream &out, Cell* cell)
{
out << std::endl;
@ -309,6 +324,12 @@ namespace CRL {
{
continue;
}
if (!instance->isTerminalNetlist()&&
!_cellHasNetPlug(instance->getMasterCell(), net))
{
// the plug is redundant and actually has no connection inside cell
continue;
}
// insert in sorted order
auto it = std::lower_bound(conns.begin(), conns.end(), plug,
[](Plug* lhs, Plug* rhs) -> bool