Correctly remove VHDL Entity and Bit properties.

* Bug: In CRL Core, in Vst driver, remove VhdlEntity (from Cell) and
    BitProperty/Bit (from Net) with the property remove and not the
    destroy() method. The BitProperty removal was completly forgotten
    leading to the use of removed Signals when doing multiple saves
    (hence core-dump).
* Change: In CRL Core, in Vst driver, never save as Signals the DeepNets
    as they are created by a virtual flatten and do not connect any
    instances at top level. Note that they will exists in the physical
    file if routing layout has been created.
This commit is contained in:
Jean-Paul Chaput 2015-09-06 17:24:04 +02:00
parent 7669c66597
commit 1adefabb2f
4 changed files with 23 additions and 18 deletions

View File

@ -111,16 +111,17 @@ namespace Vhdl {
if (_flags == NoFlags) _flags = EntityMode; if (_flags == NoFlags) _flags = EntityMode;
forEach ( Net*, inet, cell->getNets() ) { for ( Net* net : cell->getNets() ) {
if (not inet->isExternal() and (flags & ComponentMode)) continue; if (net->isDeepNet()) continue;
if (not net->isExternal() and (flags & ComponentMode)) continue;
string stem; string stem;
size_t index = 0; size_t index = 0;
if (parseNetName(*inet,stem,index)) { if (parseNetName(net,stem,index)) {
if (inet->isGlobal()) { if (net->isGlobal()) {
cerr << Warning( "Vhdl::Entity::Entity(): Net is both vectorized and global, this is not allowed.\n" cerr << Warning( "Vhdl::Entity::Entity(): Net is both vectorized and global, this is not allowed.\n"
" On Net <%s> of Cell <%s>." " On Net <%s> of Cell <%s>."
, getString(inet->getName()).c_str() , getString(net->getName()).c_str()
, getString(cell->getName()).c_str() , getString(cell->getName()).c_str()
) << endl; ) << endl;
} }
@ -128,12 +129,12 @@ namespace Vhdl {
VectorSignal* signal = const_cast<VectorSignal*>( dynamic_cast<const VectorSignal*>( getSignal(stem) ) ); VectorSignal* signal = const_cast<VectorSignal*>( dynamic_cast<const VectorSignal*>( getSignal(stem) ) );
if (not signal) if (not signal)
signal = new VectorSignal ( stem ); signal = new VectorSignal ( stem );
signal->addNet( index, *inet ); signal->addNet( index, net );
_signals.insert( signal ); _signals.insert( signal );
} else { } else {
_signals.insert( new ScalarSignal(*inet) ); _signals.insert( new ScalarSignal(net) );
if (inet->isGlobal()) if (net->isGlobal())
_globals.insert( new ScalarSignal(*inet) ); _globals.insert( new ScalarSignal(net) );
} }
} }
@ -144,6 +145,7 @@ namespace Vhdl {
Entity::~Entity () Entity::~Entity ()
{ {
for ( auto signal : _signals ) delete signal; for ( auto signal : _signals ) delete signal;
for ( auto global : _globals ) delete global;
for ( auto ientity=_entities.begin() ; ientity!=_entities.end() ; ++ientity ) { for ( auto ientity=_entities.begin() ; ientity!=_entities.end() ; ++ientity ) {
if (*ientity == this) { if (*ientity == this) {
_entities.erase( ientity ); _entities.erase( ientity );
@ -210,19 +212,20 @@ namespace Vhdl {
{ {
if (isEntityMode()) return; if (isEntityMode()) return;
forEach ( Net*, inet, getCell()->getNets() ) { for ( Net* net : getCell()->getNets() ) {
if (inet->isExternal()) continue; if (net->isDeepNet()) continue;
if (net->isExternal()) continue;
string stem; string stem;
size_t index = 0; size_t index = 0;
if (parseNetName(*inet,stem,index)) { if (parseNetName(net,stem,index)) {
VectorSignal* signal = const_cast<VectorSignal*>( dynamic_cast<const VectorSignal*>( getSignal(stem) ) ); VectorSignal* signal = const_cast<VectorSignal*>( dynamic_cast<const VectorSignal*>( getSignal(stem) ) );
if (not signal) if (not signal)
signal = new VectorSignal ( stem ); signal = new VectorSignal ( stem );
signal->addNet( index, *inet ); signal->addNet( index, net );
_signals.insert( signal ); _signals.insert( signal );
} else { } else {
_signals.insert( new ScalarSignal(*inet) ); _signals.insert( new ScalarSignal(net) );
} }
} }
} }
@ -518,7 +521,7 @@ namespace Vhdl {
void EntityExtension::destroy ( Cell* cell ) void EntityExtension::destroy ( Cell* cell )
{ {
Property* property = cell->getProperty( EntityProperty::getPropertyName() ); Property* property = cell->getProperty( EntityProperty::getPropertyName() );
if (property) static_cast<EntityProperty*>(property)->destroy(); if (property) cell->remove( property );
_owner = NULL; _owner = NULL;
_cache = NULL; _cache = NULL;

View File

@ -102,7 +102,7 @@ namespace Vhdl {
{ } { }
ScalarSignal::~ScalarSignal () ScalarSignal::~ScalarSignal ()
{ } { _bit->destroy(); }
bool ScalarSignal::isScalar () const { return true; } bool ScalarSignal::isScalar () const { return true; }
bool ScalarSignal::isVector () const { return false; } bool ScalarSignal::isVector () const { return false; }
@ -150,7 +150,7 @@ namespace Vhdl {
{ } { }
VectorSignal::~VectorSignal () VectorSignal::~VectorSignal ()
{ for ( auto bit : _bits ) bit->getProperty()->destroy(); } { for ( auto bit : _bits ) bit->destroy(); }
bool VectorSignal::isScalar () const { return false; } bool VectorSignal::isScalar () const { return false; }

View File

@ -59,6 +59,7 @@ namespace Vhdl {
const Signal* getSignal () const; const Signal* getSignal () const;
std::string getName () const; std::string getName () const;
size_t getIndex () const; size_t getIndex () const;
inline void destroy ();
std::string _getString () const; std::string _getString () const;
Record* _getRecord () const; Record* _getRecord () const;
private: private:
@ -151,6 +152,7 @@ namespace Vhdl {
inline BitProperty* Bit::getProperty () const { return (BitProperty*)((ptrdiff_t)(this) - _offset); } inline BitProperty* Bit::getProperty () const { return (BitProperty*)((ptrdiff_t)(this) - _offset); }
inline const Net* Bit::getNet () const { return (const Net*)getProperty()->getOwner(); } inline const Net* Bit::getNet () const { return (const Net*)getProperty()->getOwner(); }
inline void Bit::destroy () { ((Net*)getProperty()->getOwner())->remove( getProperty() ); }
} // Vhdl Namespace. } // Vhdl Namespace.

View File

@ -8,7 +8,7 @@
// | Alliance / Hurricane Interface | // | Alliance / Hurricane Interface |
// | | // | |
// | Author : Jean-Paul CHAPUT | // | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | // | E-mail : Jean-Paul.Chaput@lip6.fr |
// | =============================================================== | // | =============================================================== |
// | C++ Module : "./PyCRL.cpp" | // | C++ Module : "./PyCRL.cpp" |
// +-----------------------------------------------------------------+ // +-----------------------------------------------------------------+