Commit e0630f83 by Alan Mishchenko

Updates to Cba data-structure.

parent e9be6eca
...@@ -373,9 +373,9 @@ static inline int Cba_ObjFanin( Cba_Ntk_t * p, int i, int k ) { a ...@@ -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 for ( i = 1; i < Vec_StrSize(&p->vObjType); i++ ) if ( !Cba_ObjIsBoxPrim(p, i) ) {} else
#define Cba_NtkForEachFinFon( p, iFon, iFin ) \ #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 ) \ #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 ) \ #define Cba_ObjForEachFin( p, iObj, iFin, k ) \
for ( k = 0, iFin = Cba_ObjFin0(p, iObj); iFin < Cba_ObjFin0(p, iObj+1); 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 ) ...@@ -533,10 +533,11 @@ static inline void Cba_NtkCreateFonNames( Cba_Ntk_t * p, char * pPref )
int i, iObj, iFon, NameId; int i, iObj, iFon, NameId;
Cba_NtkCleanFonNames( p ); Cba_NtkCleanFonNames( p );
Cba_NtkForEachPiFon( p, iObj, iFon, i ) 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 ) Cba_NtkForEachPoDriverFon( p, iObj, iFon, i )
if ( Cba_FonIsReal(iFon) && !Cba_FonName(p, iFon) ) 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 ) Vec_IntForEachEntryStart( &p->vFonName, NameId, iFon, 1 )
if ( NameId == 0 ) if ( NameId == 0 )
Vec_IntWriteEntry( &p->vFonName, iFon, Cba_ManNewStrId(p->pDesign, pPref, iFon, NULL) ); Vec_IntWriteEntry( &p->vFonName, iFon, Cba_ManNewStrId(p->pDesign, pPref, iFon, NULL) );
......
...@@ -132,7 +132,7 @@ Vec_Int_t * Cba_NtkCollectDfs( Cba_Ntk_t * p ) ...@@ -132,7 +132,7 @@ Vec_Int_t * Cba_NtkCollectDfs( Cba_Ntk_t * p )
Vec_IntPush( vObjs, iObj ); Vec_IntPush( vObjs, iObj );
assert( Vec_IntSize(vObjs) <= Cba_NtkObjNum(p) ); assert( Vec_IntSize(vObjs) <= Cba_NtkObjNum(p) );
if ( 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; return vObjs;
} }
...@@ -503,7 +503,7 @@ static inline int Cba_NtkInsertGiaObj( Cba_Ntk_t * p, Gia_Man_t * pGia, int iObj ...@@ -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 * Cba_ManDeriveFromGia( Gia_Man_t * pGia )
{ {
Cba_Man_t * p = Cba_ManAlloc( pGia->pSpec, 1, NULL, NULL ); 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) ); Vec_Int_t * vLit2Fon = Vec_IntStartFull( 2*Gia_ManObjNum(pGia) );
int i, iObj, iObjNew, NameId, iLit0, iFon0; int i, iObj, iObjNew, NameId, iLit0, iFon0;
Gia_Obj_t * pObj; Gia_Obj_t * pObj;
...@@ -530,6 +530,9 @@ Cba_Man_t * Cba_ManDeriveFromGia( Gia_Man_t * pGia ) ...@@ -530,6 +530,9 @@ Cba_Man_t * Cba_ManDeriveFromGia( Gia_Man_t * pGia )
pObj = Gia_ManObj( pGia, iObj ); pObj = Gia_ManObj( pGia, iObj );
iLit0 = Gia_ObjFaninLit0( pObj, iObj ); iLit0 = Gia_ObjFaninLit0( pObj, iObj );
iFon0 = Cba_NtkInsertGiaLit( pNtk, iLit0, vLit2Fon ); // can be const! 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); 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 ); iObjNew = Cba_ObjAlloc( pNtk, CBA_OBJ_PO, 1, 0 );
Cba_ObjSetName( pNtk, iObjNew, NameId ); Cba_ObjSetName( pNtk, iObjNew, NameId );
...@@ -557,34 +560,46 @@ void Cba_NtkInsertGroup( Cba_Ntk_t * p, Vec_Int_t * vObjs, Cba_Ntk_t * pSyn ) ...@@ -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 * vFonIns = Cba_NtkCollectInFons( p, vObjs );
Vec_Int_t * vFonOuts = Cba_NtkCollectOutFons( 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_NtkPiNum(pSyn) == Vec_IntSize(vFonIns) );
assert( Cba_NtkPoNum(pSyn) == Vec_IntSize(vFonOuts) ); assert( Cba_NtkPoNum(pSyn) == Vec_IntSize(vFonOuts) );
// mark AIG with the input fons // mark AIG with the input fons
Cba_NtkCleanFonCopies( pSyn ); Cba_NtkCleanFonCopies( pSyn );
Cba_NtkForEachPiFon( pSyn, iObj, iFon, i ) Cba_NtkForEachPiFon( pSyn, iObj, iFon, k )
Cba_FonSetCopy( pSyn, iFon, Vec_IntEntry(vFonIns, i) ); Cba_FonSetCopy( pSyn, iFon, Vec_IntEntry(vFonIns, k) );
Vec_IntFree( vFonIns ); Vec_IntFree( vFonIns );
// build up internal nodes // build up internal nodes
Cba_NtkCleanObjCopies( pSyn ); Cba_NtkCleanObjCopies( pSyn );
Cba_NtkForEachBox( pSyn, iObj ) Cba_NtkForEachBox( pSyn, iObj )
{ {
iObjNew = Cba_ObjDup( p, pSyn, iObj ); iObjNew = Cba_ObjDup( p, pSyn, iObj );
Cba_ObjForEachFon( pSyn, iObj, iFon, i ) Cba_ObjForEachFon( pSyn, iObj, iFon, k )
Cba_FonSetCopy( pSyn, iFon, Cba_ObjFon(p, iObjNew, i) ); Cba_FonSetCopy( pSyn, iFon, Cba_ObjFon(p, iObjNew, k) );
} }
// connect internal nodes // connect internal nodes
Cba_NtkForEachBox( pSyn, iObj ) Cba_NtkForEachBox( pSyn, iObj )
{ {
iObjNew = Cba_ObjCopy( pSyn, iObj ); iObjNew = Cba_ObjCopy( pSyn, iObj );
Cba_ObjForEachFinFon( pSyn, iObj, iFin, iFon, i ) Cba_ObjForEachFinFon( pSyn, iObj, iFin, iFon, k )
Cba_ObjSetFinFon( p, iObjNew, i, Cba_FonCopy(pSyn, iFon) ); Cba_ObjSetFinFon( p, iObjNew, k, Cba_FonCopy(pSyn, iFon) );
} }
// connect output fons // connect output fons
Cba_NtkCleanFonCopies( p ); Cba_NtkCleanFonCopies( p );
Cba_NtkForEachPoDriverFon( pSyn, iObj, iFon, i ) Cba_NtkForEachPoDriverFon( pSyn, iObj, iFon, k )
Cba_FonSetCopy( p, Vec_IntEntry(vFonOuts, i), Cba_FonCopy(pSyn, iFon) ); {
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 ); 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 // update fins pointing to output fons to point to the new fons
if ( Cba_NtkHasFonNames(p) ) if ( Cba_NtkHasFonNames(p) )
Vec_IntFillExtra( &p->vFonName, Cba_NtkFonNum(p) + 1, 0 ); 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 ) ...@@ -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) ) if ( Cba_FonIsReal(iFon) && Cba_FonCopy(p, iFon) )
{ {
Cba_PatchFinFon( p, iFin, Cba_FonCopy(p, iFon) ); Cba_PatchFinFon( p, iFin, Cba_FonCopy(p, iFon) );
/*
if ( Cba_NtkHasFonNames(p) && Cba_FonIsReal(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) ); if ( !Cba_FonName(p, Cba_FonCopy(p, iFon)) )
Cba_FonCleanName( p, iFon ); {
Cba_FonSetName( p, Cba_FonCopy(p, iFon), Cba_FonName(p, iFon) );
Cba_FonCleanName( p, iFon );
}
} }
*/
} }
Cba_NtkMissingFonNames( p, "j" ); Cba_NtkMissingFonNames( p, "j" );
/* /*
// duplicate in DFS order // duplicate in DFS order
...@@ -610,8 +631,9 @@ void Cba_NtkInsertGroup( Cba_Ntk_t * p, Vec_Int_t * vObjs, Cba_Ntk_t * pSyn ) ...@@ -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 ) 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 ); Cba_NtkInsertGroup( Cba_ManRoot(p), vObjs, pSyn );
return Cba_ManDup( p, Cba_NtkCollectDfs ); return Cba_ManDup( p, Clr_NtkCollectDfs );
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment