diff options
-rw-r--r-- | src/aig/gia/giaIf.c | 2 | ||||
-rw-r--r-- | src/aig/gia/giaSweep.c | 5 | ||||
-rw-r--r-- | src/aig/gia/giaTim.c | 59 | ||||
-rw-r--r-- | src/misc/tim/tim.h | 1 | ||||
-rw-r--r-- | src/misc/tim/timBox.c | 23 |
5 files changed, 77 insertions, 13 deletions
diff --git a/src/aig/gia/giaIf.c b/src/aig/gia/giaIf.c index 00252f28..b99b9a71 100644 --- a/src/aig/gia/giaIf.c +++ b/src/aig/gia/giaIf.c @@ -1146,6 +1146,8 @@ Gia_Man_t * Gia_ManPerformMapping( Gia_Man_t * p, void * pp ) if ( p->pManTime ) { pNew = Gia_ManDupWithHierarchy( p, &vNodes ); + if ( pNew == NULL ) + return NULL; pNew->pManTime = p->pManTime; p->pManTime = NULL; pNew->pAigExtra = p->pAigExtra; p->pAigExtra = NULL; p = pNew; diff --git a/src/aig/gia/giaSweep.c b/src/aig/gia/giaSweep.c index b8caa978..4ed7d3db 100644 --- a/src/aig/gia/giaSweep.c +++ b/src/aig/gia/giaSweep.c @@ -347,11 +347,14 @@ Gia_Man_t * Gia_ManFraigSweep( Gia_Man_t * p, void * pPars ) printf( "Timing manager is given but there is no GIA of boxes.\n" ); return NULL; } + // ordering AIG objects + pNew = Gia_ManDupWithHierarchy( p, NULL ); + if ( pNew == NULL ) + return NULL; // find global equivalences pGia = Gia_ManDupWithBoxes( p, p->pAigExtra ); Gia_ManFraigSweepPerform( pGia, pPars ); // transfer equivalences - pNew = Gia_ManDupWithHierarchy( p, NULL ); pReprs = Gia_ManFraigSelectReprs( pNew, pGia, ((Dch_Pars_t *)pPars)->fVerbose ); Gia_ManStop( pGia ); // reduce AIG diff --git a/src/aig/gia/giaTim.c b/src/aig/gia/giaTim.c index d6b67d7c..6a7f22a9 100644 --- a/src/aig/gia/giaTim.c +++ b/src/aig/gia/giaTim.c @@ -171,17 +171,26 @@ Gia_Man_t * Gia_ManDupUnnomalize( Gia_Man_t * p ) SeeAlso [] ***********************************************************************/ -void Gia_ManDupFindOrderWithHie_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vNodes ) +int Gia_ManDupFindOrderWithHie_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vNodes ) { if ( Gia_ObjIsTravIdCurrent(p, pObj) ) - return; + return 0; Gia_ObjSetTravIdCurrent(p, pObj); + if ( Gia_ObjIsCi(pObj) ) + { + p->pData2 = (void *)(ABC_PTRUINT_T)Gia_ObjCioId(pObj); + return 1; + } assert( Gia_ObjIsAnd(pObj) ); if ( Gia_ObjSibl(p, Gia_ObjId(p, pObj)) ) - Gia_ManDupFindOrderWithHie_rec( p, Gia_ObjSiblObj(p, Gia_ObjId(p, pObj)), vNodes ); - Gia_ManDupFindOrderWithHie_rec( p, Gia_ObjFanin0(pObj), vNodes ); - Gia_ManDupFindOrderWithHie_rec( p, Gia_ObjFanin1(pObj), vNodes ); + if ( Gia_ManDupFindOrderWithHie_rec( p, Gia_ObjSiblObj(p, Gia_ObjId(p, pObj)), vNodes ) ) + return 1; + if ( Gia_ManDupFindOrderWithHie_rec( p, Gia_ObjFanin0(pObj), vNodes ) ) + return 1; + if ( Gia_ManDupFindOrderWithHie_rec( p, Gia_ObjFanin1(pObj), vNodes ) ) + return 1; Vec_IntPush( vNodes, Gia_ObjId(p, pObj) ); + return 0; } Vec_Int_t * Gia_ManDupFindOrderWithHie( Gia_Man_t * p ) { @@ -220,7 +229,22 @@ Vec_Int_t * Gia_ManDupFindOrderWithHie( Gia_Man_t * p ) //Gia_ObjPrint( p, pObj ); //printf( "Fanin " ); //Gia_ObjPrint( p, Gia_ObjFanin0(pObj) ); - Gia_ManDupFindOrderWithHie_rec( p, Gia_ObjFanin0(pObj), vNodes ); + if ( Gia_ManDupFindOrderWithHie_rec( p, Gia_ObjFanin0(pObj), vNodes ) ) + { + int iCiNum = (int)(ABC_PTRUINT_T)p->pData2; + int iBoxNum = Tim_ManBoxFindFromCiNum( p->pManTime, iCiNum ); + printf( "Boxes are not in a topological order. The program has to terminate.\n" ); + printf( "The following information about the network may help the debugging:\n" ); + printf( "Input %d of BoxA %d (1CI = %d; 1CO = %d) has TFI with CI %d,\n", + k, i, Tim_ManBoxOutputFirst(p->pManTime, i), Tim_ManBoxInputFirst(p->pManTime, i), iCiNum ); + printf( "which corresponds to output %d of BoxB %d (1CI = %d; 1CO = %d).\n", + iCiNum - Tim_ManBoxOutputFirst(p->pManTime, iBoxNum), iBoxNum, + Tim_ManBoxOutputFirst(p->pManTime, iBoxNum), Tim_ManBoxInputFirst(p->pManTime, iBoxNum) ); + printf( "In a correct topological order, BoxB preceeds BoxA (numbers are 0-based).\n" ); + Vec_IntFree( vNodes ); + p->pData2 = NULL; + return NULL; + } } // add POs corresponding to box inputs for ( k = 0; k < Tim_ManBoxInputNum(pTime, i); k++ ) @@ -276,13 +300,15 @@ Gia_Man_t * Gia_ManDupWithHierarchy( Gia_Man_t * p, Vec_Int_t ** pvNodes ) Gia_Man_t * pNew; Gia_Obj_t * pObj; int i; + vNodes = Gia_ManDupFindOrderWithHie( p ); + if ( vNodes == NULL ) + return NULL; Gia_ManFillValue( p ); pNew = Gia_ManStart( Gia_ManObjNum(p) ); pNew->pName = Abc_UtilStrsav( p->pName ); pNew->pSpec = Abc_UtilStrsav( p->pSpec ); if ( p->pSibls ) pNew->pSibls = ABC_CALLOC( int, Gia_ManObjNum(p) ); - vNodes = Gia_ManDupFindOrderWithHie( p ); Gia_ManForEachObjVec( vNodes, p, pObj, i ) { if ( Gia_ObjIsAnd(pObj) ) @@ -424,17 +450,22 @@ Gia_Man_t * Gia_ManDupWithBoxes( Gia_Man_t * p, Gia_Man_t * pBoxes ) SeeAlso [] ***********************************************************************/ -void Gia_ManLevelWithBoxes_rec( Gia_Man_t * p, Gia_Obj_t * pObj ) +int Gia_ManLevelWithBoxes_rec( Gia_Man_t * p, Gia_Obj_t * pObj ) { if ( Gia_ObjIsTravIdCurrent(p, pObj) ) - return; + return 0; Gia_ObjSetTravIdCurrent(p, pObj); + if ( Gia_ObjIsCi(pObj) ) + return 1; assert( Gia_ObjIsAnd(pObj) ); if ( Gia_ObjSibl(p, Gia_ObjId(p, pObj)) ) Gia_ManLevelWithBoxes_rec( p, Gia_ObjSiblObj(p, Gia_ObjId(p, pObj)) ); - Gia_ManLevelWithBoxes_rec( p, Gia_ObjFanin0(pObj) ); - Gia_ManLevelWithBoxes_rec( p, Gia_ObjFanin1(pObj) ); + if ( Gia_ManLevelWithBoxes_rec( p, Gia_ObjFanin0(pObj) ) ) + return 1; + if ( Gia_ManLevelWithBoxes_rec( p, Gia_ObjFanin1(pObj) ) ) + return 1; Gia_ObjSetAndLevel( p, pObj ); + return 0; } int Gia_ManLevelWithBoxes( Gia_Man_t * p ) { @@ -463,7 +494,11 @@ int Gia_ManLevelWithBoxes( Gia_Man_t * p ) for ( k = 0; k < Tim_ManBoxInputNum(pTime, i); k++ ) { pObj = Gia_ManPo( p, curCo + k ); - Gia_ManLevelWithBoxes_rec( p, Gia_ObjFanin0(pObj) ); + if ( Gia_ManLevelWithBoxes_rec( p, Gia_ObjFanin0(pObj) ) ) + { + printf( "Boxes are not in a topological order. Switching to level computation without boxes.\n" ); + return Gia_ManLevelNum( p ); + } Gia_ObjSetCoLevel( p, pObj ); LevelMax = Abc_MaxInt( LevelMax, Gia_ObjLevel(p, pObj) ); } diff --git a/src/misc/tim/tim.h b/src/misc/tim/tim.h index bb259d7d..ef94df97 100644 --- a/src/misc/tim/tim.h +++ b/src/misc/tim/tim.h @@ -121,6 +121,7 @@ extern int Tim_ManBoxDelayTableId( Tim_Man_t * p, int iBox ); extern float * Tim_ManBoxDelayTable( Tim_Man_t * p, int iBox ); extern int Tim_ManBoxCopy( Tim_Man_t * p, int iBox ); extern void Tim_ManBoxSetCopy( Tim_Man_t * p, int iBox, int iCopy ); +extern int Tim_ManBoxFindFromCiNum( Tim_Man_t * p, int iCiNum ); /*=== timDump.c ===========================================================*/ extern Vec_Str_t * Tim_ManSave( Tim_Man_t * p, int fHieOnly ); extern Tim_Man_t * Tim_ManLoad( Vec_Str_t * p, int fHieOnly ); diff --git a/src/misc/tim/timBox.c b/src/misc/tim/timBox.c index 82488561..5d29970e 100644 --- a/src/misc/tim/timBox.c +++ b/src/misc/tim/timBox.c @@ -243,6 +243,29 @@ void Tim_ManBoxSetCopy( Tim_Man_t * p, int iBox, int iCopy ) Tim_ManBox(p, iBox)->iCopy = iCopy; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Tim_ManBoxFindFromCiNum( Tim_Man_t * p, int iCiNum ) +{ + Tim_Box_t * pBox; + int i; + assert( iCiNum >= 0 && iCiNum < Tim_ManCiNum(p) ); + if ( iCiNum < Tim_ManPiNum(p) ) + return -1; + Tim_ManForEachBox( p, pBox, i ) + if ( iCiNum < Tim_ManBoxOutputFirst(p, i) ) + return i - 1; + return -2; +} //////////////////////////////////////////////////////////////////////// /// END OF FILE /// |