diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2014-08-26 21:28:26 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2014-08-26 21:28:26 -0700 |
commit | 66d9a80b3db7f9194ee084f210e0ae5f3a9516d7 (patch) | |
tree | 0ea9dc09d00ac612f7b356e22a18e0036ef97953 /src/aig | |
parent | 70a3474849b049c149ac1b5c4ec34dee731859d5 (diff) | |
download | abc-66d9a80b3db7f9194ee084f210e0ae5f3a9516d7.tar.gz abc-66d9a80b3db7f9194ee084f210e0ae5f3a9516d7.tar.bz2 abc-66d9a80b3db7f9194ee084f210e0ae5f3a9516d7.zip |
Adding commands to save/load best network.
Diffstat (limited to 'src/aig')
-rw-r--r-- | src/aig/gia/gia.h | 3 | ||||
-rw-r--r-- | src/aig/gia/giaDup.c | 13 | ||||
-rw-r--r-- | src/aig/gia/giaIf.c | 58 | ||||
-rw-r--r-- | src/aig/gia/giaTim.c | 104 |
4 files changed, 176 insertions, 2 deletions
diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h index fa8a6026..0ac1c740 100644 --- a/src/aig/gia/gia.h +++ b/src/aig/gia/gia.h @@ -1067,6 +1067,7 @@ extern Gia_Man_t * Gia_ManDupLastPis( Gia_Man_t * p, int nLastPis ); extern Gia_Man_t * Gia_ManDupFlip( Gia_Man_t * p, int * pInitState ); extern Gia_Man_t * Gia_ManDupCycled( Gia_Man_t * pAig, Abc_Cex_t * pCex, int nFrames ); extern Gia_Man_t * Gia_ManDup( Gia_Man_t * p ); +extern Gia_Man_t * Gia_ManDupWithAttributes( Gia_Man_t * p ); extern Gia_Man_t * Gia_ManDupZero( Gia_Man_t * p ); extern Gia_Man_t * Gia_ManDupPerm( Gia_Man_t * p, Vec_Int_t * vPiPerm ); extern Gia_Man_t * Gia_ManDupPermFlop( Gia_Man_t * p, Vec_Int_t * vFfPerm ); @@ -1180,6 +1181,7 @@ extern int Gia_ManLutFaninCount( Gia_Man_t * p ); extern int Gia_ManLutSizeMax( Gia_Man_t * p ); extern int Gia_ManLutNum( Gia_Man_t * p ); extern int Gia_ManLutLevel( Gia_Man_t * p ); +extern void Gia_ManLutParams( Gia_Man_t * p, int * pnCurLuts, int * pnCurEdges, int * pnCurLevels ); extern void Gia_ManSetRefsMapped( Gia_Man_t * p ); extern void Gia_ManSetIfParsDefault( void * pIfPars ); extern void Gia_ManMappingVerify( Gia_Man_t * p ); @@ -1313,6 +1315,7 @@ extern Gia_Man_t * Gia_ManDupNormalize( Gia_Man_t * p ); extern Gia_Man_t * Gia_ManDupUnnormalize( Gia_Man_t * p ); extern Gia_Man_t * Gia_ManDupCollapse( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t * vBoxPres ); extern int Gia_ManLevelWithBoxes( Gia_Man_t * p ); +extern int Gia_ManLutLevelWithBoxes( Gia_Man_t * p ); extern int Gia_ManVerifyWithBoxes( Gia_Man_t * pGia, void * pParsInit ); extern void * Gia_ManUpdateTimMan( Gia_Man_t * p, Vec_Int_t * vBoxPres ); extern Gia_Man_t * Gia_ManUpdateExtraAig( void * pTime, Gia_Man_t * pAig, Vec_Int_t * vBoxPres ); diff --git a/src/aig/gia/giaDup.c b/src/aig/gia/giaDup.c index b54bdee0..37deb7fd 100644 --- a/src/aig/gia/giaDup.c +++ b/src/aig/gia/giaDup.c @@ -546,6 +546,19 @@ Gia_Man_t * Gia_ManDup( Gia_Man_t * p ) pNew->pCexSeq = Abc_CexDup( p->pCexSeq, Gia_ManRegNum(p) ); return pNew; } +Gia_Man_t * Gia_ManDupWithAttributes( Gia_Man_t * p ) +{ + Gia_Man_t * pNew = Gia_ManDup(p); + Gia_ManTransferMapping( pNew, p ); + Gia_ManTransferPacking( pNew, p ); + if ( p->pManTime ) + pNew->pManTime = Tim_ManDup( (Tim_Man_t *)p->pManTime, 0 ); + if ( p->pAigExtra ) + pNew->pAigExtra = Gia_ManDup( p->pAigExtra ); + if ( p->nAnd2Delay ) + pNew->nAnd2Delay = p->nAnd2Delay; + return pNew; +} /**Function************************************************************* diff --git a/src/aig/gia/giaIf.c b/src/aig/gia/giaIf.c index 6a2520eb..050966b1 100644 --- a/src/aig/gia/giaIf.c +++ b/src/aig/gia/giaIf.c @@ -183,6 +183,56 @@ int Gia_ManLutLevel( Gia_Man_t * p ) /**Function************************************************************* + Synopsis [Prints mapping statistics.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManLutParams( Gia_Man_t * p, int * pnCurLuts, int * pnCurEdges, int * pnCurLevels ) +{ + if ( p->pManTime && Tim_ManBoxNum((Tim_Man_t *)p->pManTime) ) + { + int i; + *pnCurLuts = 0; + *pnCurEdges = 0; + Gia_ManForEachLut( p, i ) + { + (*pnCurLuts)++; + (*pnCurEdges) += Gia_ObjLutSize(p, i); + } + *pnCurLevels = Gia_ManLutLevelWithBoxes( p ); + } + else + { + Gia_Obj_t * pObj; + int i, k, iFan; + int * pLevels = ABC_CALLOC( int, Gia_ManObjNum(p) ); + *pnCurLuts = 0; + *pnCurEdges = 0; + Gia_ManForEachLut( p, i ) + { + int Level = 0; + (*pnCurLuts)++; + (*pnCurEdges) += Gia_ObjLutSize(p, i); + Gia_LutForEachFanin( p, i, iFan, k ) + if ( Level < pLevels[iFan] ) + Level = pLevels[iFan]; + pLevels[i] = Level + 1; + } + *pnCurLevels = 0; + Gia_ManForEachCo( p, pObj, k ) + if ( *pnCurLevels < pLevels[Gia_ObjFaninId0p(p, pObj)] ) + *pnCurLevels = pLevels[Gia_ObjFaninId0p(p, pObj)]; + ABC_FREE( pLevels ); + } +} + +/**Function************************************************************* + Synopsis [Assigns levels.] Description [] @@ -395,7 +445,9 @@ void Gia_ManPrintMappingStats( Gia_Man_t * p, char * pDumpFile ) Abc_Print( 1, "lev =%5d ", LevelMax ); Abc_Print( 1, "(%.2f) ", (float)Ave / Gia_ManCoNum(p) ); SetConsoleTextAttribute( hConsole, 7 ); // normal - Abc_Print( 1, "over =%5.1f %% ", 100.0 * Gia_ManComputeOverlap(p) / Gia_ManAndNum(p) ); +// Abc_Print( 1, "over =%5.1f %% ", 100.0 * Gia_ManComputeOverlap(p) / Gia_ManAndNum(p) ); + if ( p->pManTime && Tim_ManBoxNum((Tim_Man_t *)p->pManTime) ) + Abc_Print( 1, "levB =%5d ", Gia_ManLutLevelWithBoxes(p) ); Abc_Print( 1, "mem =%5.2f MB", 4.0*(Gia_ManObjNum(p) + 2*nLuts + nFanins)/(1<<20) ); Abc_Print( 1, "\n" ); } @@ -405,7 +457,9 @@ void Gia_ManPrintMappingStats( Gia_Man_t * p, char * pDumpFile ) Abc_Print( 1, "%sedge =%8d%s ", "\033[1;32m", nFanins, "\033[0m" ); // green Abc_Print( 1, "%slev =%5d%s ", "\033[1;31m", LevelMax, "\033[0m" ); // red Abc_Print( 1, "%s(%.2f)%s ", "\033[1;31m", (float)Ave / Gia_ManCoNum(p), "\033[0m" ); - Abc_Print( 1, "over =%5.1f %% ", 100.0 * Gia_ManComputeOverlap(p) / Gia_ManAndNum(p) ); +// Abc_Print( 1, "over =%5.1f %% ", 100.0 * Gia_ManComputeOverlap(p) / Gia_ManAndNum(p) ); + if ( p->pManTime && Tim_ManBoxNum((Tim_Man_t *)p->pManTime) ) + Abc_Print( 1, "levB =%5d ", Gia_ManLutLevelWithBoxes(p) ); Abc_Print( 1, "mem =%5.2f MB", 4.0*(Gia_ManObjNum(p) + 2*nLuts + nFanins)/(1<<20) ); Abc_Print( 1, "\n" ); #endif diff --git a/src/aig/gia/giaTim.c b/src/aig/gia/giaTim.c index 0e6a9252..290cae7d 100644 --- a/src/aig/gia/giaTim.c +++ b/src/aig/gia/giaTim.c @@ -486,6 +486,110 @@ int Gia_ManLevelWithBoxes( Gia_Man_t * p ) /**Function************************************************************* + Synopsis [Computes level with boxes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManLutLevelWithBoxes_rec( Gia_Man_t * p, Gia_Obj_t * pObj ) +{ + int iObj, k, iFan, Level = 0; + if ( Gia_ObjIsTravIdCurrent(p, pObj) ) + return 0; + Gia_ObjSetTravIdCurrent(p, pObj); + if ( Gia_ObjIsCi(pObj) ) + return 1; + assert( Gia_ObjIsAnd(pObj) ); + iObj = Gia_ObjId( p, pObj ); + Gia_LutForEachFanin( p, iObj, iFan, k ) + { + if ( Gia_ManLutLevelWithBoxes_rec( p, Gia_ManObj(p, iFan) ) ) + return 1; + Level = Abc_MaxInt( Level, Gia_ObjLevelId(p, iFan) ); + } + Gia_ObjSetLevelId( p, iObj, Level + 1 ); + return 0; +} +int Gia_ManLutLevelWithBoxes( Gia_Man_t * p ) +{ +// int nAnd2Delay = p->nAnd2Delay ? p->nAnd2Delay : 1; + Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime; + Gia_Obj_t * pObj, * pObjIn; + int i, k, j, curCi, curCo, LevelMax; + assert( Gia_ManRegNum(p) == 0 ); + // copy const and real PIs + Gia_ManCleanLevels( p, Gia_ManObjNum(p) ); + Gia_ObjSetLevel( p, Gia_ManConst0(p), 0 ); + Gia_ManIncrementTravId( p ); + Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) ); + for ( i = 0; i < Tim_ManPiNum(pManTime); i++ ) + { + pObj = Gia_ManPi( p, i ); +// Gia_ObjSetLevel( p, pObj, Tim_ManGetCiArrival(pManTime, i) / nAnd2Delay ); + Gia_ObjSetLevel( p, pObj, 0 ); + Gia_ObjSetTravIdCurrent( p, pObj ); + } + // create logic for each box + curCi = Tim_ManPiNum(pManTime); + curCo = 0; + for ( i = 0; i < Tim_ManBoxNum(pManTime); i++ ) + { + int nBoxInputs = Tim_ManBoxInputNum( pManTime, i ); + int nBoxOutputs = Tim_ManBoxOutputNum( pManTime, i ); + float * pDelayTable = Tim_ManBoxDelayTable( pManTime, i ); + // compute level for TFI of box inputs + for ( k = 0; k < nBoxInputs; k++ ) + { + pObj = Gia_ManPo( p, curCo + k ); + if ( Gia_ManLutLevelWithBoxes_rec( p, Gia_ObjFanin0(pObj) ) ) + { + printf( "Boxes are not in a topological order. Switching to level computation without boxes.\n" ); + return Gia_ManLevelNum( p ); + } + // set box input level + Gia_ObjSetCoLevel( p, pObj ); + } + // compute level for box outputs + for ( k = 0; k < nBoxOutputs; k++ ) + { + pObj = Gia_ManPi( p, curCi + k ); + Gia_ObjSetTravIdCurrent( p, pObj ); + // evaluate delay of this output + LevelMax = 0; + assert( nBoxInputs == (int)pDelayTable[1] ); + for ( j = 0; j < nBoxInputs && (pObjIn = Gia_ManPo(p, curCo + j)); j++ ) + if ( (int)pDelayTable[3+k*nBoxInputs+j] != -ABC_INFINITY ) +// LevelMax = Abc_MaxInt( LevelMax, Gia_ObjLevel(p, pObjIn) + ((int)pDelayTable[3+k*nBoxInputs+j] / nAnd2Delay) ); + LevelMax = Abc_MaxInt( LevelMax, Gia_ObjLevel(p, pObjIn) + 1 ); + // set box output level + Gia_ObjSetLevel( p, pObj, LevelMax ); + } + curCo += nBoxInputs; + curCi += nBoxOutputs; + } + // add remaining nodes + p->nLevels = 0; + for ( i = Tim_ManCoNum(pManTime) - Tim_ManPoNum(pManTime); i < Tim_ManCoNum(pManTime); i++ ) + { + pObj = Gia_ManPo( p, i ); + Gia_ManLutLevelWithBoxes_rec( p, Gia_ObjFanin0(pObj) ); + Gia_ObjSetCoLevel( p, pObj ); + p->nLevels = Abc_MaxInt( p->nLevels, Gia_ObjLevel(p, pObj) ); + } + curCo += Tim_ManPoNum(pManTime); + // verify counts + assert( curCi == Gia_ManPiNum(p) ); + assert( curCo == Gia_ManPoNum(p) ); +// printf( "Max level is %d.\n", p->nLevels ); + return p->nLevels; +} + +/**Function************************************************************* + Synopsis [Verify XAIG against its spec.] Description [] |