From 46ab68ba17a6b50c5fd2a4c0566dc3e805bc11bd Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 9 Apr 2014 12:51:08 -0700 Subject: Cleanup and bug fixing in hierarchy handling. --- src/base/abc/abc.h | 1 + src/base/abc/abcBarBuf.c | 4 ++++ src/base/abc/abcLib.c | 27 +++++++++++++++++++++++++-- src/base/abc/abcNtk.c | 3 --- src/base/main/main.h | 1 - src/base/main/mainFrame.c | 3 --- src/base/main/mainInt.h | 1 - src/base/ver/verCore.c | 34 +++++++++++++++++++++++++++------- 8 files changed, 57 insertions(+), 17 deletions(-) (limited to 'src/base') diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h index d6aafd08..c4a93dca 100644 --- a/src/base/abc/abc.h +++ b/src/base/abc/abc.h @@ -668,6 +668,7 @@ extern ABC_DLL void Abc_NtkConvertDcLatches( Abc_Ntk_t * pNtk ); extern ABC_DLL Vec_Ptr_t * Abc_NtkConverLatchNamesIntoNumbers( Abc_Ntk_t * pNtk ); /*=== abcLib.c ==========================================================*/ extern ABC_DLL Abc_Des_t * Abc_DesCreate( char * pName ); +extern ABC_DLL void Abc_DesCleanManPointer( Abc_Des_t * p, void * pMan ); extern ABC_DLL void Abc_DesFree( Abc_Des_t * p, Abc_Ntk_t * pNtk ); extern ABC_DLL void Abc_DesPrint( Abc_Des_t * p ); extern ABC_DLL int Abc_DesAddModel( Abc_Des_t * p, Abc_Ntk_t * pNtk ); diff --git a/src/base/abc/abcBarBuf.c b/src/base/abc/abcBarBuf.c index 6df8fd5a..a31ea665 100644 --- a/src/base/abc/abcBarBuf.c +++ b/src/base/abc/abcBarBuf.c @@ -308,7 +308,11 @@ Abc_Ntk_t * Abc_NtkFromBarBufs( Abc_Ntk_t * pNtkBase, Abc_Ntk_t * pNtk ) Abc_ObjAddFanin( pObj->pCopy, Abc_NtkFromBarBufs_rec(pObj->pCopy->pNtk, Abc_ObjFanin0(pObj)) ); // transfer net names Abc_NtkForEachCi( pNtk, pObj, i ) + { + if ( Abc_ObjFanoutNum(pObj->pCopy) == 0 ) // handle PI without fanout + Abc_ObjAddFanin( Abc_NtkCreateNet(pObj->pCopy->pNtk), pObj->pCopy ); Nm_ManStoreIdName( pObj->pCopy->pNtk->pManName, Abc_ObjFanout0(pObj->pCopy)->Id, Abc_ObjFanout0(pObj->pCopy)->Type, Abc_ObjName(Abc_ObjFanout0(pObj)), NULL ); + } Abc_NtkForEachCo( pNtk, pObj, i ) Nm_ManStoreIdName( pObj->pCopy->pNtk->pManName, Abc_ObjFanin0(pObj->pCopy)->Id, Abc_ObjFanin0(pObj->pCopy)->Type, Abc_ObjName(Abc_ObjFanin0(pObj)), NULL ); return pNtkNew; diff --git a/src/base/abc/abcLib.c b/src/base/abc/abcLib.c index 8e229975..9a8c36f2 100644 --- a/src/base/abc/abcLib.c +++ b/src/base/abc/abcLib.c @@ -56,6 +56,30 @@ Abc_Des_t * Abc_DesCreate( char * pName ) return p; } +/**Function************************************************************* + + Synopsis [Removes all pointers to the manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Abc_DesCleanManPointer( Abc_Des_t * p, void * pMan ) +{ + Abc_Ntk_t * pTemp; + int i; + if ( p == NULL ) + return; + if ( p->pManFunc == pMan ) + p->pManFunc = NULL; + Vec_PtrForEachEntry( Abc_Ntk_t *, p->vModules, pTemp, i ) + if ( pTemp->pManFunc == pMan ) + pTemp->pManFunc = NULL; +} + /**Function************************************************************* Synopsis [Frees the library.] @@ -83,9 +107,8 @@ void Abc_DesFree( Abc_Des_t * p, Abc_Ntk_t * pNtkSave ) { if ( pNtk == pNtkSave ) continue; -// pNtk->pManFunc = NULL; pNtk->pDesign = NULL; - if ( pNtkSave && pNtk->pManFunc == pNtkSave->pManFunc ) + if ( (pNtkSave && pNtk->pManFunc == pNtkSave->pManFunc) || (pNtk->pManFunc == p->pManFunc) ) pNtk->pManFunc = NULL; Abc_NtkDelete( pNtk ); } diff --git a/src/base/abc/abcNtk.c b/src/base/abc/abcNtk.c index c3294d98..8012d3a7 100644 --- a/src/base/abc/abcNtk.c +++ b/src/base/abc/abcNtk.c @@ -1327,10 +1327,7 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk ) // free node attributes Vec_PtrForEachEntry( Abc_Obj_t *, pNtk->vAttrs, pAttrMan, i ) if ( pAttrMan ) - { -//printf( "deleting attr\n" ); Vec_AttFree( (Vec_Att_t *)pAttrMan, 1 ); - } assert( pNtk->pSCLib == NULL ); Vec_IntFreeP( &pNtk->vGates ); Vec_PtrFree( pNtk->vAttrs ); diff --git a/src/base/main/main.h b/src/base/main/main.h index e58fa75b..38867e88 100644 --- a/src/base/main/main.h +++ b/src/base/main/main.h @@ -102,7 +102,6 @@ extern ABC_DLL void * Abc_FrameReadLibBox(); extern ABC_DLL void * Abc_FrameReadLibGen(); extern ABC_DLL void * Abc_FrameReadLibGen2(); extern ABC_DLL void * Abc_FrameReadLibSuper(); -extern ABC_DLL void * Abc_FrameReadLibVer(); extern ABC_DLL void * Abc_FrameReadLibScl(); extern ABC_DLL void * Abc_FrameReadManDd(); extern ABC_DLL void * Abc_FrameReadManDec(); diff --git a/src/base/main/mainFrame.c b/src/base/main/mainFrame.c index 277c86ee..c3af051a 100644 --- a/src/base/main/mainFrame.c +++ b/src/base/main/mainFrame.c @@ -56,7 +56,6 @@ void * Abc_FrameReadLibBox() { return s_GlobalFr void * Abc_FrameReadLibGen() { return s_GlobalFrame->pLibGen; } void * Abc_FrameReadLibGen2() { return s_GlobalFrame->pLibGen2; } void * Abc_FrameReadLibSuper() { return s_GlobalFrame->pLibSuper; } -void * Abc_FrameReadLibVer() { return s_GlobalFrame->pLibVer; } void * Abc_FrameReadLibScl() { return s_GlobalFrame->pLibScl; } void * Abc_FrameReadManDd() { if ( s_GlobalFrame->dd == NULL ) s_GlobalFrame->dd = Cudd_Init( 0, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 ); return s_GlobalFrame->dd; } void * Abc_FrameReadManDec() { if ( s_GlobalFrame->pManDec == NULL ) s_GlobalFrame->pManDec = Dec_ManStart(); return s_GlobalFrame->pManDec; } @@ -82,7 +81,6 @@ void Abc_FrameSetLibBox( void * pLib ) { s_GlobalFrame->pL void Abc_FrameSetLibGen( void * pLib ) { s_GlobalFrame->pLibGen = pLib; } void Abc_FrameSetLibGen2( void * pLib ) { s_GlobalFrame->pLibGen2 = pLib; } void Abc_FrameSetLibSuper( void * pLib ) { s_GlobalFrame->pLibSuper = pLib; } -void Abc_FrameSetLibVer( void * pLib ) { s_GlobalFrame->pLibVer = pLib; } void Abc_FrameSetFlag( char * pFlag, char * pValue ) { Cmd_FlagUpdateValue( s_GlobalFrame, pFlag, pValue ); } void Abc_FrameSetCex( Abc_Cex_t * pCex ) { ABC_FREE( s_GlobalFrame->pCex ); s_GlobalFrame->pCex = pCex; } void Abc_FrameSetNFrames( int nFrames ) { ABC_FREE( s_GlobalFrame->pCex ); s_GlobalFrame->nFrames = nFrames; } @@ -189,7 +187,6 @@ void Abc_FrameDeallocate( Abc_Frame_t * p ) if ( p->vCexVec ) Vec_PtrFreeFree( p->vCexVec ); if ( p->vPoEquivs ) Vec_VecFree( (Vec_Vec_t *)p->vPoEquivs ); if ( p->vStatuses ) Vec_IntFree( p->vStatuses ); - if ( p->pLibVer ) Abc_DesFree( (Abc_Des_t *)p->pLibVer, NULL ); if ( p->pManDec ) Dec_ManStop( (Dec_Man_t *)p->pManDec ); if ( p->dd ) Extra_StopManager( p->dd ); if ( p->vStore ) Vec_PtrFree( p->vStore ); diff --git a/src/base/main/mainInt.h b/src/base/main/mainInt.h index c5b7de58..73844c2b 100644 --- a/src/base/main/mainInt.h +++ b/src/base/main/mainInt.h @@ -92,7 +92,6 @@ struct Abc_Frame_t_ void * pLibGen; // the current genlib void * pLibGen2; // the current genlib void * pLibSuper; // the current supergate library - void * pLibVer; // the current Verilog library void * pLibScl; // the current Liberty library // timing constraints char * pDrivingCell; // name of the driving cell diff --git a/src/base/ver/verCore.c b/src/base/ver/verCore.c index bb0f243f..c1d7baa8 100644 --- a/src/base/ver/verCore.c +++ b/src/base/ver/verCore.c @@ -1743,12 +1743,6 @@ int Ver_ParseBox( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkBox ) pNode->pCopy = (Abc_Obj_t *)vBundles; while ( 1 ) { -/* - if ( Ver_StreamGetLineNumber(pMan->pReader) == 5967 ) - { - int x = 0; - } -*/ // allocate the bundle (formal name + array of actual nets) pBundle = ABC_ALLOC( Ver_Bundle_t, 1 ); pBundle->pNameFormal = NULL; @@ -2073,6 +2067,21 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox ) Abc_NtkForEachPo( pNtkBox, pTerm, i ) Abc_ObjFanin0(pTerm)->pCopy = NULL; */ + + // check the number of actual nets is the same as the number of formal nets + if ( Vec_PtrSize(vBundles) > Abc_NtkPiNum(pNtkBox) + Abc_NtkPoNum(pNtkBox) ) + { + sprintf( pMan->sError, "The number of actual IOs (%d) is bigger than the number of formal IOs (%d) when instantiating network %s in box %s.", + Vec_PtrSize(vBundles), Abc_NtkPiNum(pNtkBox) + Abc_NtkPoNum(pNtkBox), pNtkBox->pName, Abc_ObjName(pBox) ); + // free the bundling + Vec_PtrForEachEntry( Ver_Bundle_t *, vBundles, pBundle, k ) + Ver_ParseFreeBundle( pBundle ); + Vec_PtrFree( vBundles ); + pBox->pCopy = NULL; + Ver_ParsePrintErrorMessage( pMan ); + return 0; + } + // check if some of them do not have formal names Vec_PtrForEachEntry( Ver_Bundle_t *, vBundles, pBundle, k ) if ( pBundle->pNameFormal == NULL ) @@ -2090,6 +2099,11 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox ) { sprintf( pMan->sError, "The number of actual IOs (%d) is different from the number of formal IOs (%d) when instantiating network %s in box %s.", Vec_PtrSize(vBundles), Abc_NtkPiNum(pNtkBox) + Abc_NtkPoNum(pNtkBox), pNtkBox->pName, Abc_ObjName(pBox) ); + // free the bundling + Vec_PtrForEachEntry( Ver_Bundle_t *, vBundles, pBundle, k ) + Ver_ParseFreeBundle( pBundle ); + Vec_PtrFree( vBundles ); + pBox->pCopy = NULL; Ver_ParsePrintErrorMessage( pMan ); return 0; } @@ -2235,6 +2249,11 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox ) { sprintf( pMan->sError, "It looks like formal output %s is driving a constant net (%s) when instantiating network %s in box %s.", pBundle->pNameFormal, Abc_ObjName(pNetAct), pNtkBox->pName, Abc_ObjName(pBox) ); + // free the bundling + Vec_PtrForEachEntry( Ver_Bundle_t *, vBundles, pBundle, k ) + Ver_ParseFreeBundle( pBundle ); + Vec_PtrFree( vBundles ); + pBox->pCopy = NULL; Ver_ParsePrintErrorMessage( pMan ); return 0; } @@ -2826,13 +2845,14 @@ void Ver_ParsePrintLog( Ver_Man_t * pMan ) ***********************************************************************/ int Ver_ParseAttachBoxes( Ver_Man_t * pMan ) { + int fPrintLog = 0; Abc_Ntk_t * pNtk = NULL; Ver_Bundle_t * pBundle; Vec_Ptr_t * vUndefs; int i, RetValue, Counter, nMaxBoxSize; // print the log file - if ( pMan->pDesign->vModules && Vec_PtrSize(pMan->pDesign->vModules) > 1 ) + if ( fPrintLog && pMan->pDesign->vModules && Vec_PtrSize(pMan->pDesign->vModules) > 1 ) Ver_ParsePrintLog( pMan ); // connect defined boxes -- cgit v1.2.3