diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2015-07-24 12:26:24 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2015-07-24 12:26:24 -0700 |
commit | e0630f83f5d69707c6345251cbebec0911a15fb3 (patch) | |
tree | e1f505366f1b3e59a31592b11ea61cf4c10c0e9a /src | |
parent | e9be6ecaf8a5d87c0e92ccd82b94f5439dbc82f3 (diff) | |
download | abc-e0630f83f5d69707c6345251cbebec0911a15fb3.tar.gz abc-e0630f83f5d69707c6345251cbebec0911a15fb3.tar.bz2 abc-e0630f83f5d69707c6345251cbebec0911a15fb3.zip |
Updates to Cba data-structure.
Diffstat (limited to 'src')
-rw-r--r-- | src/base/cba/cba.h | 9 | ||||
-rw-r--r-- | src/base/cba/cbaNtk.c | 50 |
2 files changed, 41 insertions, 18 deletions
diff --git a/src/base/cba/cba.h b/src/base/cba/cba.h index 546c54bd..b97b7083 100644 --- a/src/base/cba/cba.h +++ b/src/base/cba/cba.h @@ -373,9 +373,9 @@ static inline int Cba_ObjFanin( Cba_Ntk_t * p, int i, int k ) { a for ( i = 1; i < Vec_StrSize(&p->vObjType); i++ ) if ( !Cba_ObjIsBoxPrim(p, i) ) {} else #define Cba_NtkForEachFinFon( p, iFon, iFin ) \ - for ( iFin = 0; iFin < Vec_IntSize(&p->vFinFon) && (((iFon) = Vec_IntEntry(&p->vFinFon, iFin)), 1); i++ ) if ( !iFon ) {} else + for ( iFin = 0; iFin < Vec_IntSize(&p->vFinFon) && (((iFon) = Vec_IntEntry(&p->vFinFon, iFin)), 1); iFin++ ) if ( !iFon ) {} else #define Cba_NtkForEachFonName( p, NameId, iFon ) \ - for ( iFon = 0; iFon < Vec_IntSize(&p->vFonName) && (((NameId) = Vec_IntEntry(&p->vFonName, iFon)), 1); i++ ) if ( !NameId ) {} else + for ( iFon = 0; iFon < Vec_IntSize(&p->vFonName) && (((NameId) = Vec_IntEntry(&p->vFonName, iFon)), 1); iFon++ ) if ( !NameId ) {} else #define Cba_ObjForEachFin( p, iObj, iFin, k ) \ for ( k = 0, iFin = Cba_ObjFin0(p, iObj); iFin < Cba_ObjFin0(p, iObj+1); iFin++, k++ ) @@ -533,10 +533,11 @@ static inline void Cba_NtkCreateFonNames( Cba_Ntk_t * p, char * pPref ) int i, iObj, iFon, NameId; Cba_NtkCleanFonNames( p ); Cba_NtkForEachPiFon( p, iObj, iFon, i ) - Cba_FonSetName( p, iFon, Cba_ObjName(p, iFon) ); + if ( !Cba_FonName(p, iFon) ) + Cba_FonSetName( p, iFon, Cba_ObjName(p, iObj) ); Cba_NtkForEachPoDriverFon( p, iObj, iFon, i ) if ( Cba_FonIsReal(iFon) && !Cba_FonName(p, iFon) ) - Cba_FonSetName( p, iFon, Cba_ObjName(p, iFon) ); + Cba_FonSetName( p, iFon, Cba_ObjName(p, iObj) ); Vec_IntForEachEntryStart( &p->vFonName, NameId, iFon, 1 ) if ( NameId == 0 ) Vec_IntWriteEntry( &p->vFonName, iFon, Cba_ManNewStrId(p->pDesign, pPref, iFon, NULL) ); diff --git a/src/base/cba/cbaNtk.c b/src/base/cba/cbaNtk.c index 5ed4542a..8812cbac 100644 --- a/src/base/cba/cbaNtk.c +++ b/src/base/cba/cbaNtk.c @@ -132,7 +132,7 @@ Vec_Int_t * Cba_NtkCollectDfs( Cba_Ntk_t * p ) Vec_IntPush( vObjs, iObj ); assert( Vec_IntSize(vObjs) <= Cba_NtkObjNum(p) ); if ( Vec_IntSize(vObjs) != Cba_NtkObjNum(p) ) - printf( "Warning: DSF ordering collected %d out of %d objects.\n", Vec_IntSize(vObjs), Cba_NtkObjNum(p) ); + printf( "Warning: DSF ordering for module \"%s\" collected %d out of %d objects.\n", Cba_NtkName(p), Vec_IntSize(vObjs), Cba_NtkObjNum(p) ); return vObjs; } @@ -503,7 +503,7 @@ static inline int Cba_NtkInsertGiaObj( Cba_Ntk_t * p, Gia_Man_t * pGia, int iObj Cba_Man_t * Cba_ManDeriveFromGia( Gia_Man_t * pGia ) { Cba_Man_t * p = Cba_ManAlloc( pGia->pSpec, 1, NULL, NULL ); - Cba_Ntk_t * pNtk = Cba_NtkAlloc( p, Abc_NamStrFindOrAdd(p->pStrs, pGia->pName, NULL), Gia_ManCiNum(pGia), Gia_ManCoNum(pGia), 1000, 2000, 1000 ); + Cba_Ntk_t * pNtk = Cba_NtkAlloc( p, Abc_NamStrFindOrAdd(p->pStrs, pGia->pName, NULL), Gia_ManCiNum(pGia), Gia_ManCoNum(pGia), 1000, 2000, 2000 ); Vec_Int_t * vLit2Fon = Vec_IntStartFull( 2*Gia_ManObjNum(pGia) ); int i, iObj, iObjNew, NameId, iLit0, iFon0; Gia_Obj_t * pObj; @@ -530,6 +530,9 @@ Cba_Man_t * Cba_ManDeriveFromGia( Gia_Man_t * pGia ) pObj = Gia_ManObj( pGia, iObj ); iLit0 = Gia_ObjFaninLit0( pObj, iObj ); iFon0 = Cba_NtkInsertGiaLit( pNtk, iLit0, vLit2Fon ); // can be const! + iObjNew = Cba_ObjAlloc( pNtk, CBA_BOX_BUF, 1, 1 ); + Cba_ObjSetFinFon( pNtk, iObjNew, 0, iFon0 ); + iFon0 = Cba_ObjFon0(pNtk, iObjNew); // non-const fon unique for this output NameId = pGia->vNamesOut? Abc_NamStrFindOrAdd(p->pStrs, Vec_PtrEntry(pGia->vNamesOut, i), NULL) : Cba_ManNewStrId(p, "o", i, NULL); iObjNew = Cba_ObjAlloc( pNtk, CBA_OBJ_PO, 1, 0 ); Cba_ObjSetName( pNtk, iObjNew, NameId ); @@ -557,34 +560,46 @@ void Cba_NtkInsertGroup( Cba_Ntk_t * p, Vec_Int_t * vObjs, Cba_Ntk_t * pSyn ) { Vec_Int_t * vFonIns = Cba_NtkCollectInFons( p, vObjs ); Vec_Int_t * vFonOuts = Cba_NtkCollectOutFons( p, vObjs ); - int i, iObj, iObjNew, iFin, iFon; + int k, iObj, iObjNew, iFin, iFon; assert( Cba_NtkPiNum(pSyn) == Vec_IntSize(vFonIns) ); assert( Cba_NtkPoNum(pSyn) == Vec_IntSize(vFonOuts) ); // mark AIG with the input fons Cba_NtkCleanFonCopies( pSyn ); - Cba_NtkForEachPiFon( pSyn, iObj, iFon, i ) - Cba_FonSetCopy( pSyn, iFon, Vec_IntEntry(vFonIns, i) ); + Cba_NtkForEachPiFon( pSyn, iObj, iFon, k ) + Cba_FonSetCopy( pSyn, iFon, Vec_IntEntry(vFonIns, k) ); Vec_IntFree( vFonIns ); // build up internal nodes Cba_NtkCleanObjCopies( pSyn ); Cba_NtkForEachBox( pSyn, iObj ) { iObjNew = Cba_ObjDup( p, pSyn, iObj ); - Cba_ObjForEachFon( pSyn, iObj, iFon, i ) - Cba_FonSetCopy( pSyn, iFon, Cba_ObjFon(p, iObjNew, i) ); + Cba_ObjForEachFon( pSyn, iObj, iFon, k ) + Cba_FonSetCopy( pSyn, iFon, Cba_ObjFon(p, iObjNew, k) ); } // connect internal nodes Cba_NtkForEachBox( pSyn, iObj ) { iObjNew = Cba_ObjCopy( pSyn, iObj ); - Cba_ObjForEachFinFon( pSyn, iObj, iFin, iFon, i ) - Cba_ObjSetFinFon( p, iObjNew, i, Cba_FonCopy(pSyn, iFon) ); + Cba_ObjForEachFinFon( pSyn, iObj, iFin, iFon, k ) + Cba_ObjSetFinFon( p, iObjNew, k, Cba_FonCopy(pSyn, iFon) ); } // connect output fons Cba_NtkCleanFonCopies( p ); - Cba_NtkForEachPoDriverFon( pSyn, iObj, iFon, i ) - Cba_FonSetCopy( p, Vec_IntEntry(vFonOuts, i), Cba_FonCopy(pSyn, iFon) ); + Cba_NtkForEachPoDriverFon( pSyn, iObj, iFon, k ) + { + assert( Cba_FonIsReal(Cba_FonCopy(pSyn, iFon)) ); + Cba_FonSetCopy( p, Vec_IntEntry(vFonOuts, k), Cba_FonCopy(pSyn, iFon) ); + // transfer names + if ( Cba_NtkHasFonNames(p) ) + { + Cba_FonSetName( p, Cba_FonCopy(pSyn, iFon), Cba_FonName(p, Vec_IntEntry(vFonOuts, k)) ); + Cba_FonCleanName( p, Vec_IntEntry(vFonOuts, k) ); + } + } Vec_IntFree( vFonOuts ); + // delete nodes + Vec_IntForEachEntry( vObjs, iObj, k ) + Cba_ObjDelete( p, iObj ); // update fins pointing to output fons to point to the new fons if ( Cba_NtkHasFonNames(p) ) Vec_IntFillExtra( &p->vFonName, Cba_NtkFonNum(p) + 1, 0 ); @@ -592,12 +607,18 @@ void Cba_NtkInsertGroup( Cba_Ntk_t * p, Vec_Int_t * vObjs, Cba_Ntk_t * pSyn ) if ( Cba_FonIsReal(iFon) && Cba_FonCopy(p, iFon) ) { Cba_PatchFinFon( p, iFin, Cba_FonCopy(p, iFon) ); +/* if ( Cba_NtkHasFonNames(p) && Cba_FonIsReal(Cba_FonCopy(p, iFon)) ) { - Cba_FonSetName( p, Cba_FonCopy(p, iFon), Cba_FonName(p, iFon) ); - Cba_FonCleanName( p, iFon ); + if ( !Cba_FonName(p, Cba_FonCopy(p, iFon)) ) + { + Cba_FonSetName( p, Cba_FonCopy(p, iFon), Cba_FonName(p, iFon) ); + Cba_FonCleanName( p, iFon ); + } } +*/ } + Cba_NtkMissingFonNames( p, "j" ); /* // duplicate in DFS order @@ -610,8 +631,9 @@ void Cba_NtkInsertGroup( Cba_Ntk_t * p, Vec_Int_t * vObjs, Cba_Ntk_t * pSyn ) } Cba_Man_t * Cba_ManInsertGroup( Cba_Man_t * p, Vec_Int_t * vObjs, Cba_Ntk_t * pSyn ) { + extern Vec_Int_t * Clr_NtkCollectDfs( Cba_Ntk_t * p ); Cba_NtkInsertGroup( Cba_ManRoot(p), vObjs, pSyn ); - return Cba_ManDup( p, Cba_NtkCollectDfs ); + return Cba_ManDup( p, Clr_NtkCollectDfs ); } //////////////////////////////////////////////////////////////////////// |