From 13795bec488bea3fb3d9f9dd38a1a88878bc8e20 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Mon, 31 Oct 2022 16:31:30 +0100 Subject: [PATCH] Add Environement attribute (pattern) to match the FF names. --- crlcore/src/ccore/Environment.cpp | 35 +++++++++++++++---- crlcore/src/ccore/crlcore/AllianceFramework.h | 17 +++++---- crlcore/src/ccore/crlcore/Environment.h | 6 ++++ crlcore/src/pyCRL/PyAllianceFramework.cpp | 18 ++++++++++ crlcore/src/pyCRL/PyEnvironment.cpp | 35 +++++++++++-------- etesian/src/EtesianEngine.cpp | 4 +-- 6 files changed, 85 insertions(+), 30 deletions(-) diff --git a/crlcore/src/ccore/Environment.cpp b/crlcore/src/ccore/Environment.cpp index bab54097..d7fabfbd 100644 --- a/crlcore/src/ccore/Environment.cpp +++ b/crlcore/src/ccore/Environment.cpp @@ -68,19 +68,22 @@ namespace CRL { , _GROUND ("vss") , _CLOCK ("^ck$") , _BLOCKAGE ("^blockage$") - , _pad ("^.*_px$") + , _pad (".*_px$") + , _register (".*dff.*") , _LIBRARIES () , _PowerRegex (new regex_t) , _GroundRegex (new regex_t) , _ClockRegex (new regex_t) , _BlockageRegex (new regex_t) , _padRegex (new regex_t) + , _registerRegex (new regex_t) { - setPOWER ( "vdd" ); - setGROUND ( "vss" ); - setCLOCK ( "^ck$" ); - setBLOCKAGE( "^blockage$" ); - setPad ( "^.*_px$" ); + setPOWER ( _POWER .c_str() ); + setGROUND ( _GROUND .c_str() ); + setCLOCK ( _CLOCK .c_str() ); + setBLOCKAGE( _BLOCKAGE.c_str() ); + setPad ( _pad .c_str() ); + setRegister( _register.c_str() ); _LIBRARIES.append( ".", "working" ); } @@ -93,11 +96,13 @@ namespace CRL { regfree( _ClockRegex ); regfree( _BlockageRegex ); regfree( _padRegex ); + regfree( _registerRegex ); delete _PowerRegex; delete _GroundRegex; delete _ClockRegex; delete _BlockageRegex; delete _padRegex; + delete _registerRegex; } @@ -136,6 +141,13 @@ namespace CRL { } + bool Environment::isRegister ( const char* name ) const + { + if (not _registerRegex) return false; + return regexec ( _registerRegex, name, 0, NULL, 0 ) == 0; + } + + void Environment::setPOWER ( const char* value ) { _POWER = value; @@ -171,6 +183,13 @@ namespace CRL { } + void Environment::setRegister ( const char* value ) + { + _register = value; + _setRegex ( _registerRegex , _register , "Register" ); + } + + string Environment::getPrint () const { ostringstream s; @@ -204,7 +223,8 @@ namespace CRL { << Dots::asString( " - Clock Signal" , _CLOCK ) << "\n" << Dots::asString( " - Blockages" , _BLOCKAGE ) << "\n" << " o Special Cells.\n" - << Dots::asString( " - Pads" , _pad ) << "\n\n"; + << Dots::asString( " - Pads" , _pad ) << "\n" + << Dots::asString( " - Registers" , _register ) << "\n\n"; return s.str(); } @@ -327,6 +347,7 @@ namespace CRL { record->add ( getSlot ( "_CLOCK" , &_CLOCK ) ); record->add ( getSlot ( "_BLOCKAGE" , &_BLOCKAGE ) ); record->add ( getSlot ( "_pad" , &_pad ) ); + record->add ( getSlot ( "_register" , &_register ) ); record->add ( getSlot ( "_LIBRARIES" , &_LIBRARIES ) ); return record; } diff --git a/crlcore/src/ccore/crlcore/AllianceFramework.h b/crlcore/src/ccore/crlcore/AllianceFramework.h index 5bf83b9e..c1564fd1 100644 --- a/crlcore/src/ccore/crlcore/AllianceFramework.h +++ b/crlcore/src/ccore/crlcore/AllianceFramework.h @@ -1,7 +1,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC 2008-2018, All Rights Reserved +// Copyright (c) Sorbonne Université 2008-2022, All Rights Reserved // // +-----------------------------------------------------------------+ // | C O R I O L I S | @@ -13,10 +13,7 @@ // | C++ Header : "./crlcore/AllianceFramework.h" | // +-----------------------------------------------------------------+ - -#ifndef CRL_ALLIANCE_FRAMEWORK_H -#define CRL_ALLIANCE_FRAMEWORK_H - +#pragma once #include #include #include "hurricane/Cell.h" @@ -87,6 +84,10 @@ namespace CRL { inline bool isPad ( const string& name ); inline bool isPad ( const Name& name ); inline bool isPad ( const Cell* ); + inline bool isRegister ( const char* name ); + inline bool isRegister ( const string& name ); + inline bool isRegister ( const Name& name ); + inline bool isRegister ( const Cell* ); // Accessors. inline Environment* getEnvironment (); inline Catalog* getCatalog (); @@ -176,6 +177,10 @@ namespace CRL { inline bool AllianceFramework::isPad ( const string& name ) { return isPad(name.c_str()); } inline bool AllianceFramework::isPad ( const Name& name ) { return isPad(getString(name)); } inline bool AllianceFramework::isPad ( const Cell* cell ) { return isPad(cell->getName()); } + inline bool AllianceFramework::isRegister ( const char* name ) { return _environment.isRegister(name); } + inline bool AllianceFramework::isRegister ( const string& name ) { return isRegister(name.c_str()); } + inline bool AllianceFramework::isRegister ( const Name& name ) { return isRegister(getString(name)); } + inline bool AllianceFramework::isRegister ( const Cell* cell ) { return isRegister(cell->getName()); } inline Environment* AllianceFramework::getEnvironment () { return &_environment; } inline Catalog* AllianceFramework::getCatalog () { return &_catalog; } inline const Name& AllianceFramework::getParentLibraryName @@ -206,5 +211,3 @@ namespace CRL { INSPECTOR_P_SUPPORT(CRL::AllianceFramework); - -#endif // CRL_ALLIANCE_FRAMEWORK_H diff --git a/crlcore/src/ccore/crlcore/Environment.h b/crlcore/src/ccore/crlcore/Environment.h index 64185f8b..a42bd697 100644 --- a/crlcore/src/ccore/crlcore/Environment.h +++ b/crlcore/src/ccore/crlcore/Environment.h @@ -53,6 +53,7 @@ namespace CRL { inline const std::string& getCLOCK () const; inline const std::string& getBLOCKAGE () const; inline const std::string& getPad () const; + inline const std::string& getRegister () const; inline const std::string& getCATALOG () const; inline SearchPath& getLIBRARIES (); std::string getLIBRARYPath ( size_t i ); @@ -62,6 +63,7 @@ namespace CRL { bool isCLOCK ( const char* name ) const; bool isBLOCKAGE ( const char* name ) const; bool isPad ( const char* name ) const; + bool isRegister ( const char* name ) const; // Modifiers. void validate () const; inline void setDisplayStyle ( const char* ); @@ -76,6 +78,7 @@ namespace CRL { void setCLOCK ( const char* value ); void setBLOCKAGE ( const char* value ); void setPad ( const char* value ); + void setRegister ( const char* value ); inline void setCATALOG ( const char* value ); void setWORKING_LIBRARY ( const char* value ); void addSYSTEM_LIBRARY ( const char* value, const char* libName, unsigned int mode=Append ); @@ -100,12 +103,14 @@ namespace CRL { std::string _CLOCK; std::string _BLOCKAGE; std::string _pad; + std::string _register; SearchPath _LIBRARIES; regex_t* _PowerRegex; regex_t* _GroundRegex; regex_t* _ClockRegex; regex_t* _BlockageRegex; regex_t* _padRegex; + regex_t* _registerRegex; private: void _setRegex ( regex_t*& regex, const std::string& pattern, const char* name ); }; @@ -124,6 +129,7 @@ namespace CRL { inline const std::string& Environment::getCLOCK () const { return _CLOCK; } inline const std::string& Environment::getBLOCKAGE () const { return _BLOCKAGE; } inline const std::string& Environment::getPad () const { return _pad; } + inline const std::string& Environment::getRegister () const { return _register; } inline const std::string& Environment::getCATALOG () const { return _CATALOG; } inline SearchPath& Environment::getLIBRARIES () { return _LIBRARIES; } diff --git a/crlcore/src/pyCRL/PyAllianceFramework.cpp b/crlcore/src/pyCRL/PyAllianceFramework.cpp index f83cacee..b7583fde 100644 --- a/crlcore/src/pyCRL/PyAllianceFramework.cpp +++ b/crlcore/src/pyCRL/PyAllianceFramework.cpp @@ -351,6 +351,22 @@ extern "C" { } + static PyObject* PyAllianceFramework_isRegister ( PyAllianceFramework* self, PyObject* args ) + { + cdebug_log(30,0) << "PyAllianceFramework_isRegister ()" << endl; + char* name = NULL; + HTRY + METHOD_HEAD("AllianceFramework.isRegister()") + if ( not PyArg_ParseTuple(args,"s",&name) ) { + PyErr_SetString ( ConstructorError, "invalid number of parameters for Cell AllianceFramework.isRegister()."); + return NULL; + } + if (af->isRegister(name)) Py_RETURN_TRUE; + HCATCH + Py_RETURN_FALSE; + } + + static PyObject* PyAllianceFramework_isCLOCK ( PyAllianceFramework* self, PyObject* args ) { cdebug_log(30,0) << "PyAllianceFramework_isCLOCK ()" << endl; @@ -622,6 +638,8 @@ extern "C" { , "Load in memory all Cells from an Alliance Library." } , { "isPad" , (PyCFunction)PyAllianceFramework_isPad , METH_VARARGS , "Tells if a cell name is a Pad." } + , { "isRegister" , (PyCFunction)PyAllianceFramework_isRegister , METH_VARARGS + , "Tells if a cell name is a register (flip-flop)." } , { "isCLOCK" , (PyCFunction)PyAllianceFramework_isCLOCK , METH_VARARGS , "Tells if a net name matches the clock pattern." } , { "isInCatalog" , (PyCFunction)PyAllianceFramework_isInCatalog , METH_VARARGS diff --git a/crlcore/src/pyCRL/PyEnvironment.cpp b/crlcore/src/pyCRL/PyEnvironment.cpp index 4b79cf45..67403533 100644 --- a/crlcore/src/pyCRL/PyEnvironment.cpp +++ b/crlcore/src/pyCRL/PyEnvironment.cpp @@ -145,26 +145,28 @@ extern "C" { // Standart Accessors (Attributes). - DirectGetStringAttribute(PyEnvironment_getCORIOLIS_TOP ,getCORIOLIS_TOP ,PyEnvironment,Environment) - DirectGetStringAttribute(PyEnvironment_getDisplayStyle ,getDisplayStyle ,PyEnvironment,Environment) - DirectGetLongAttribute (PyEnvironment_getSCALE_X ,getSCALE_X ,PyEnvironment,Environment) - DirectGetStringAttribute(PyEnvironment_getIN_LO ,getIN_LO ,PyEnvironment,Environment) - DirectGetStringAttribute(PyEnvironment_getIN_PH ,getIN_PH ,PyEnvironment,Environment) - DirectGetStringAttribute(PyEnvironment_getOUT_LO ,getOUT_LO ,PyEnvironment,Environment) - DirectGetStringAttribute(PyEnvironment_getOUT_PH ,getOUT_PH ,PyEnvironment,Environment) - DirectGetStringAttribute(PyEnvironment_getPOWER ,getPOWER ,PyEnvironment,Environment) - DirectGetStringAttribute(PyEnvironment_getGROUND ,getGROUND ,PyEnvironment,Environment) - DirectGetStringAttribute(PyEnvironment_getCLOCK ,getCLOCK ,PyEnvironment,Environment) - DirectGetStringAttribute(PyEnvironment_getBLOCKAGE ,getBLOCKAGE ,PyEnvironment,Environment) - DirectGetStringAttribute(PyEnvironment_getPad ,getPad ,PyEnvironment,Environment) - DirectGetStringAttribute(PyEnvironment_getCATALOG ,getCATALOG ,PyEnvironment,Environment) - DirectGetStringAttribute(PyEnvironment_getPrint ,getPrint ,PyEnvironment,Environment) + DirectGetStringAttribute(PyEnvironment_getCORIOLIS_TOP,getCORIOLIS_TOP,PyEnvironment,Environment) + DirectGetStringAttribute(PyEnvironment_getDisplayStyle,getDisplayStyle,PyEnvironment,Environment) + DirectGetLongAttribute (PyEnvironment_getSCALE_X ,getSCALE_X ,PyEnvironment,Environment) + DirectGetStringAttribute(PyEnvironment_getIN_LO ,getIN_LO ,PyEnvironment,Environment) + DirectGetStringAttribute(PyEnvironment_getIN_PH ,getIN_PH ,PyEnvironment,Environment) + DirectGetStringAttribute(PyEnvironment_getOUT_LO ,getOUT_LO ,PyEnvironment,Environment) + DirectGetStringAttribute(PyEnvironment_getOUT_PH ,getOUT_PH ,PyEnvironment,Environment) + DirectGetStringAttribute(PyEnvironment_getPOWER ,getPOWER ,PyEnvironment,Environment) + DirectGetStringAttribute(PyEnvironment_getGROUND ,getGROUND ,PyEnvironment,Environment) + DirectGetStringAttribute(PyEnvironment_getCLOCK ,getCLOCK ,PyEnvironment,Environment) + DirectGetStringAttribute(PyEnvironment_getBLOCKAGE ,getBLOCKAGE ,PyEnvironment,Environment) + DirectGetStringAttribute(PyEnvironment_getPad ,getPad ,PyEnvironment,Environment) + DirectGetStringAttribute(PyEnvironment_getRegister ,getRegister ,PyEnvironment,Environment) + DirectGetStringAttribute(PyEnvironment_getCATALOG ,getCATALOG ,PyEnvironment,Environment) + DirectGetStringAttribute(PyEnvironment_getPrint ,getPrint ,PyEnvironment,Environment) DirectIsAFromCStringAttribute(PyEnvironment_isPOWER ,isPOWER ,PyEnvironment,Environment) DirectIsAFromCStringAttribute(PyEnvironment_isGROUND ,isGROUND ,PyEnvironment,Environment) DirectIsAFromCStringAttribute(PyEnvironment_isCLOCK ,isCLOCK ,PyEnvironment,Environment) DirectIsAFromCStringAttribute(PyEnvironment_isBLOCKAGE,isBLOCKAGE,PyEnvironment,Environment) DirectIsAFromCStringAttribute(PyEnvironment_isPad ,isPad ,PyEnvironment,Environment) + DirectIsAFromCStringAttribute(PyEnvironment_isRegister,isRegister,PyEnvironment,Environment) // Standart Mutators (Attributes). DirectSetCStringAttribute(PyEnvironment_setDisplayStyle ,setDisplayStyle ,PyEnvironment,Environment) @@ -178,6 +180,7 @@ extern "C" { DirectSetCStringAttribute(PyEnvironment_setCLOCK ,setCLOCK ,PyEnvironment,Environment) DirectSetCStringAttribute(PyEnvironment_setBLOCKAGE ,setBLOCKAGE ,PyEnvironment,Environment) DirectSetCStringAttribute(PyEnvironment_setPad ,setPad ,PyEnvironment,Environment) + DirectSetCStringAttribute(PyEnvironment_setRegister ,setRegister ,PyEnvironment,Environment) DirectSetCStringAttribute(PyEnvironment_setCATALOG ,setCATALOG ,PyEnvironment,Environment) DirectSetCStringAttribute(PyEnvironment_setWORKING_LIBRARY,setWORKING_LIBRARY,PyEnvironment,Environment) @@ -227,6 +230,8 @@ extern "C" { , "Checks if a name is a blockage net name." } , { "isPad" , (PyCFunction)PyEnvironment_isPad , METH_VARARGS , "Checks if a name is a pad cell name." } + , { "isRegister" , (PyCFunction)PyEnvironment_isRegister , METH_VARARGS + , "Checks if a name is a register cell name." } , { "validate" , (PyCFunction)PyEnvironment_validate , METH_NOARGS , "Validate the coherency of the settings (raise an exception)." } , { "setDisplayStyle" , (PyCFunction)PyEnvironment_setDisplayStyle , METH_VARARGS @@ -251,6 +256,8 @@ extern "C" { , "Sets the blockage net recognition regular expression." } , { "setPad" , (PyCFunction)PyEnvironment_setPad , METH_VARARGS , "Sets the pad cell recognition regular expression." } + , { "setRegister" , (PyCFunction)PyEnvironment_setRegister , METH_VARARGS + , "Sets the register cell recognition regular expression." } , { "setCATALOG" , (PyCFunction)PyEnvironment_setCATALOG , METH_VARARGS , "Sets the name of the per library catalog file." } , { "setWORKING_LIBRARY" , (PyCFunction)PyEnvironment_setWORKING_LIBRARY , METH_VARARGS diff --git a/etesian/src/EtesianEngine.cpp b/etesian/src/EtesianEngine.cpp index 28a3dcc8..a01a5c14 100644 --- a/etesian/src/EtesianEngine.cpp +++ b/etesian/src/EtesianEngine.cpp @@ -752,7 +752,7 @@ namespace Etesian { if (instance == getBlockInstance()) continue; string masterName = getString( instance->getMasterCell()->getName() ); Box instanceAb = instance->getAbutmentBox(); - if (masterName.substr(0,3) == "sff") { + if (af->isRegister(masterName)) { ++registerNb; registerLength += instanceAb.getWidth(); } @@ -774,7 +774,7 @@ namespace Etesian { Instance* instance = static_cast(occurrence.getEntity()); Box instanceAb = instance->getAbutmentBox(); string masterName = getString( instance->getMasterCell()->getName() ); - if (masterName.substr(0,3) == "sff") { + if (af->isRegister(masterName)) { ++registerNb; registerLength += instanceAb.getWidth(); }