Fairly compute the flat numbers of instances in a design.

* New: In AllianceFramework::getInstancesCount(), add a flag TerminalNetlist
    to stop recursion on "terminal for netlist" instance level. This is to
    avoid counting physical only or non-routed instances inside hard macros,
    like SRAM blocks. This was leading to an overstimation of the "size"
    in number of gates of the routing problem.
* Change: In KatanaEngine CTOR, call for the terminal for netlist number of
    gates...
This commit is contained in:
Jean-Paul Chaput 2021-11-26 11:29:23 +01:00
parent 966a25181f
commit 7c0f1fcf58
3 changed files with 24 additions and 19 deletions

View File

@ -858,18 +858,19 @@ namespace CRL {
{ {
size_t gates = 0; size_t gates = 0;
forEach ( Instance*, iinstance, cell->getInstances() ) { for ( Instance* instance : cell->getInstances() ) {
CatalogProperty *catalogProperty = static_cast<CatalogProperty*> CatalogProperty *catalogProperty = static_cast<CatalogProperty*>
((*iinstance)->getMasterCell()->getProperty ( CatalogProperty::getPropertyName()) ); (instance->getMasterCell()->getProperty ( CatalogProperty::getPropertyName()) );
if ( catalogProperty != NULL ) { if (catalogProperty) {
Catalog::State* state = catalogProperty->getState (); Catalog::State* state = catalogProperty->getState();
if ( (flags & IgnoreFeeds) and state->isFeed() ) continue; if ((flags & IgnoreFeeds) and state->isFeed()) continue;
} }
++gates; if (not (flags & TerminalNetlist) or instance->getMasterCell()->isTerminalNetlist())
++gates;
if ( flags & Recursive ) { if (flags & Recursive) {
gates += getInstancesCount ( iinstance->getMasterCell(), flags ); gates += getInstancesCount( instance->getMasterCell(), flags );
} }
} }

View File

@ -42,19 +42,20 @@ namespace CRL {
class AllianceFramework : public DBo { class AllianceFramework : public DBo {
typedef DBo Super; typedef DBo Super;
public: public:
enum FunctionsFlags { NoFlags = 0 enum FunctionsFlags { NoFlags = 0
, NoPythonInit = (1<<0) , NoPythonInit = (1<<0)
}; };
enum InstancesCountFlags { Recursive = (1<<0) enum InstancesCountFlags { Recursive = (1<<0)
, IgnoreFeeds = (1<<1) , IgnoreFeeds = (1<<1)
, TerminalNetlist = (1<<1)
}; };
enum LibraryFlags { CreateLibrary = (1<<0) enum LibraryFlags { CreateLibrary = (1<<0)
, AppendLibrary = (1<<1) , AppendLibrary = (1<<1)
, HasCatalog = (1<<2) , HasCatalog = (1<<2)
}; };
enum NotifyFlags { AddedLibrary = (1<<0) enum NotifyFlags { AddedLibrary = (1<<0)
, RemovedLibrary = (1<<1) , RemovedLibrary = (1<<1)
, ConfigChanged = (1<<2) , ConfigChanged = (1<<2)
}; };
public: public:
static AllianceFramework* create ( unsigned long flags=NoFlags ); static AllianceFramework* create ( unsigned long flags=NoFlags );

View File

@ -202,6 +202,7 @@ namespace Katana {
//Entity::setMemoryLimit( 1024 ); // 1Gb. //Entity::setMemoryLimit( 1024 ); // 1Gb.
addMeasure<size_t>( "Gates" addMeasure<size_t>( "Gates"
, AllianceFramework::getInstancesCount(cell,AllianceFramework::IgnoreFeeds , AllianceFramework::getInstancesCount(cell,AllianceFramework::IgnoreFeeds
|AllianceFramework::TerminalNetlist
|AllianceFramework::Recursive) ); |AllianceFramework::Recursive) );
} }
@ -671,6 +672,8 @@ namespace Katana {
ostringstream result; ostringstream result;
bool isSymbolic = bool isSymbolic =
const_cast<KatanaEngine*>(this)->getConfiguration()->getRoutingGauge()->isSymbolic(); const_cast<KatanaEngine*>(this)->getConfiguration()->getRoutingGauge()->isSymbolic();
// Max symbolic wire: 100000L, max real wire: 2mm.
uint64_t maxWL = (isSymbolic) ? 100000 : 2000000;
AutoSegmentLut::const_iterator ilut = _getAutoSegmentLut().begin(); AutoSegmentLut::const_iterator ilut = _getAutoSegmentLut().begin();
for ( ; ilut != _getAutoSegmentLut().end() ; ilut++ ) { for ( ; ilut != _getAutoSegmentLut().end() ; ilut++ ) {
@ -682,7 +685,7 @@ namespace Katana {
wl = (unsigned long long)DbU::toLambda( segment->getLength() ); wl = (unsigned long long)DbU::toLambda( segment->getLength() );
else else
wl = (unsigned long long)DbU::toPhysical( segment->getLength(), DbU::UnitPower::Nano ); wl = (unsigned long long)DbU::toPhysical( segment->getLength(), DbU::UnitPower::Nano );
if (wl > 100000) { if (wl > maxWL) {
cerr << Error("KatanaEngine::printCompletion(): Suspiciously long wire: %llu for %p:%s" cerr << Error("KatanaEngine::printCompletion(): Suspiciously long wire: %llu for %p:%s"
,wl,ilut->first,getString(segment).c_str()) << endl; ,wl,ilut->first,getString(segment).c_str()) << endl;
continue; continue;