Commit fd877c3f by Alan Mishchenko

Several improvements to CBA data-structure.

parent 0f9001c9
......@@ -138,8 +138,8 @@ struct Cba_Ntk_t_
Vec_Int_t vOutputs; // outputs
// object attributes
Vec_Str_t vType; // types
Vec_Int_t vIndex; // index
Vec_Int_t vFanin; // fanin
Vec_Int_t vIndex; // index
Vec_Int_t vName; // original NameId or InstId
Vec_Int_t vRange; // range
Vec_Int_t vCopy; // copy
......@@ -237,10 +237,10 @@ static inline int Cba_ObjIsBoxPrim( Cba_Ntk_t * p, int i ) { r
static inline int Cba_ObjIsGate( Cba_Ntk_t * p, int i ) { return Cba_ObjType(p, i) == CBA_BOX_GATE; }
static inline int Cba_ObjIsCi( Cba_Ntk_t * p, int i ) { return Cba_ObjIsPi(p, i) || Cba_ObjIsBo(p, i); }
static inline int Cba_ObjIsCo( Cba_Ntk_t * p, int i ) { return Cba_ObjIsPo(p, i) || Cba_ObjIsBi(p, i); }
static inline int Cba_ObjIsCio( Cba_Ntk_t * p, int i ) { return Cba_ObjIsCi(p, i) || Cba_ObjIsCo(p, i); }
static inline int Cba_ObjIsCio( Cba_Ntk_t * p, int i ) { return Cba_ObjType(p, i) < CBA_OBJ_BOX; }
static inline int Cba_ObjIndex( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vIndex, i); }
static inline int Cba_ObjFanin( Cba_Ntk_t * p, int i ) { assert(Cba_ObjIsCo(p, i)); return Vec_IntEntry(&p->vFanin, i); }
static inline int Cba_ObjIndex( Cba_Ntk_t * p, int i ) { assert(Cba_ObjIsCio(p, i)); return Vec_IntEntry(&p->vIndex, i); }
static inline int Cba_ObjFaninTwo( Cba_Ntk_t * p, int i ) { return Cba_ObjFanin(p, Cba_ObjFanin(p, i)); }
static inline int Cba_ObjName( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vName, i); }
static inline int Cba_ObjRange( Cba_Ntk_t * p, int i ) { return Vec_IntEntry(&p->vRange, i); }
......@@ -248,6 +248,7 @@ static inline int Cba_ObjCopy( Cba_Ntk_t * p, int i ) { r
static inline char * Cba_ObjNameStr( Cba_Ntk_t * p, int i ) { return Cba_NtkStr(p, Cba_ObjName(p, i)); }
static inline char * Cba_ObjRangeStr( Cba_Ntk_t * p, int i ) { return Cba_NtkStr(p, Cba_ObjRange(p, i)); }
static inline void Cba_ObjSetFanin( Cba_Ntk_t * p, int i, int x ) { assert(Cba_ObjFanin(p, i) == -1); Vec_IntWriteEntry( &p->vFanin, i, x ); }
static inline void Cba_ObjSetIndex( Cba_Ntk_t * p, int i, int x ) { assert(Cba_ObjIndex(p, i) == -1); Vec_IntWriteEntry( &p->vIndex, i, x ); }
static inline void Cba_ObjSetName( Cba_Ntk_t * p, int i, int x ) { assert(Cba_ObjName(p, i) == 0); Vec_IntWriteEntry( &p->vName, i, x ); }
static inline void Cba_ObjSetRange( Cba_Ntk_t * p, int i, int x ) { assert(Cba_ObjRange(p, i) == 0); Vec_IntWriteEntry( &p->vRange, i, x ); }
static inline void Cba_ObjSetCopy( Cba_Ntk_t * p, int i, int x ) { assert(Cba_ObjCopy(p, i) == -1); Vec_IntWriteEntry( &p->vCopy, i, x ); }
......@@ -261,8 +262,8 @@ static inline int Cba_BoxBiBox( Cba_Ntk_t * p, int i ) { a
static inline int Cba_BoxBoBox( Cba_Ntk_t * p, int i ) { assert(Cba_ObjIsBo(p, i)); return i - 1 - Cba_ObjIndex(p, i); }
static inline int Cba_BoxFanin( Cba_Ntk_t * p, int b, int i ) { return Cba_ObjFanin(p, Cba_BoxBi(p, b, i)); }
static inline int Cba_BoxNtkId( Cba_Ntk_t * p, int i ) { assert(Cba_ObjIsBox(p, i)); return Cba_ObjIndex(p, i); }
static inline void Cba_BoxSetNtkId( Cba_Ntk_t * p, int i, int x ) { assert(Cba_ManNtkIsOk(p->pDesign, x));Vec_IntWriteEntry(&p->vIndex, i, x); }
static inline int Cba_BoxNtkId( Cba_Ntk_t * p, int i ) { assert(Cba_ObjIsBox(p, i)); return Vec_IntEntry(&p->vFanin, i); }
static inline void Cba_BoxSetNtkId( Cba_Ntk_t * p, int i, int x ) { assert(Cba_ObjIsBox(p, i) && Cba_ManNtkIsOk(p->pDesign, x)); Vec_IntWriteEntry(&p->vFanin, i, x); }
static inline int Cba_BoxBiNtkId( Cba_Ntk_t * p, int i ) { assert(Cba_ObjIsBi(p, i)); return Cba_BoxNtkId(p, Cba_BoxBiBox(p, i)); }
static inline int Cba_BoxBoNtkId( Cba_Ntk_t * p, int i ) { assert(Cba_ObjIsBo(p, i)); return Cba_BoxNtkId(p, Cba_BoxBoBox(p, i)); }
static inline Cba_Ntk_t * Cba_BoxNtk( Cba_Ntk_t * p, int i ) { return Cba_ManNtk( p->pDesign, Cba_BoxNtkId(p, i) ); }
......@@ -287,6 +288,8 @@ static inline char * Cba_BoxNtkName( Cba_Ntk_t * p, int i ) { r
#define Cba_NtkForEachPo( p, iObj, i ) \
for ( i = 0; (i < Cba_NtkPoNum(p)) && (((iObj) = Vec_IntEntry(&p->vOutputs, i)), 1); i++ )
#define Cba_NtkForEachObj( p, i ) \
for ( i = 0; (i < Cba_NtkObjNum(p)); i++ )
#define Cba_NtkForEachObjType( p, Type, i ) \
for ( i = 0; (i < Cba_NtkObjNum(p)) && (((Type) = Cba_ObjType(p, i)), 1); i++ )
......@@ -336,35 +339,21 @@ static inline char * Cba_BoxNtkName( Cba_Ntk_t * p, int i ) { r
SeeAlso []
***********************************************************************/
static inline int Cba_ObjAlloc( Cba_Ntk_t * p, Cba_ObjType_t Type, int Index, int Fanin )
static inline int Cba_ObjAlloc( Cba_Ntk_t * p, Cba_ObjType_t Type, int Fanin )
{
int iObj = Cba_NtkObjNum(p);
assert( iObj == Vec_IntSize(&p->vIndex) );
assert( iObj == Vec_IntSize(&p->vFanin) );
if ( Type == CBA_OBJ_PI )
{
assert( Index == -1 || Index == Vec_IntSize(&p->vInputs) );
Vec_IntPush( &p->vIndex, Vec_IntSize(&p->vInputs) );
Vec_IntPush( &p->vInputs, iObj );
}
else if ( Type == CBA_OBJ_PO )
{
assert( Index == -1 || Index == Vec_IntSize(&p->vOutputs) );
Vec_IntPush( &p->vIndex, Vec_IntSize(&p->vOutputs) );
Vec_IntPush( &p->vOutputs, iObj );
}
else
{
assert( Type >= CBA_OBJ_BOX || Index >= 0 );
Vec_IntPush( &p->vIndex, Index );
}
Vec_StrPush( &p->vType, (char)Type );
Vec_IntPush( &p->vFanin, Fanin );
return iObj;
}
static inline int Cba_ObjDup( Cba_Ntk_t * pNew, Cba_Ntk_t * p, int i )
{
int iObj = Cba_ObjAlloc( pNew, Cba_ObjType(p, i), Cba_ObjIndex(p, i), -1 );
int iObj = Cba_ObjAlloc( pNew, Cba_ObjType(p, i), Cba_ObjIsBox(p, i) ? Cba_BoxNtkId(p, i) : -1 );
if ( Cba_NtkHasNames(p) && Cba_NtkHasNames(pNew) )
Cba_ObjSetName( pNew, iObj, Cba_ObjName(p, i) );
if ( Cba_NtkHasRanges(p) && Cba_NtkHasRanges(pNew) )
......@@ -376,10 +365,10 @@ static inline int Cba_BoxAlloc( Cba_Ntk_t * p, Cba_ObjType_t Type, int nIns, int
{
int i, iObj;
for ( i = nIns - 1; i >= 0; i-- )
Cba_ObjAlloc( p, CBA_OBJ_BI, i, -1 );
iObj = Cba_ObjAlloc( p, Type, iNtk, -1 );
Cba_ObjAlloc( p, CBA_OBJ_BI, -1 );
iObj = Cba_ObjAlloc( p, Type, iNtk );
for ( i = 0; i < nOuts; i++ )
Cba_ObjAlloc( p, CBA_OBJ_BO, i, iObj );
Cba_ObjAlloc( p, CBA_OBJ_BO, -1 );
return iObj;
}
static inline int Cba_BoxDup( Cba_Ntk_t * pNew, Cba_Ntk_t * p, int iBox )
......@@ -420,7 +409,6 @@ static inline void Cba_NtkAlloc( Cba_Ntk_t * pNew, int NameId, int nIns, int nOu
Vec_IntGrow( &pNew->vInputs, nIns );
Vec_IntGrow( &pNew->vOutputs, nOuts );
Vec_StrGrow( &pNew->vType, nObjs );
Vec_IntGrow( &pNew->vIndex, nObjs );
Vec_IntGrow( &pNew->vFanin, nObjs );
// check if the network is unique
NtkId = Abc_NamStrFindOrAdd( pNew->pDesign->pMods, Cba_NtkStr(pNew, NameId), &fFound );
......@@ -474,8 +462,8 @@ static inline void Cba_NtkFree( Cba_Ntk_t * p )
Vec_IntErase( &p->vInputs );
Vec_IntErase( &p->vOutputs );
Vec_StrErase( &p->vType );
Vec_IntErase( &p->vIndex );
Vec_IntErase( &p->vFanin );
Vec_IntErase( &p->vIndex );
Vec_IntErase( &p->vName );
Vec_IntErase( &p->vRange );
Vec_IntErase( &p->vCopy );
......@@ -487,8 +475,8 @@ static inline int Cba_NtkMemory( Cba_Ntk_t * p )
nMem += Vec_IntMemory(&p->vInputs);
nMem += Vec_IntMemory(&p->vOutputs);
nMem += Vec_StrMemory(&p->vType);
nMem += Vec_IntMemory(&p->vIndex);
nMem += Vec_IntMemory(&p->vFanin);
nMem += Vec_IntMemory(&p->vIndex);
nMem += Vec_IntMemory(&p->vName);
nMem += Vec_IntMemory(&p->vRange);
nMem += Vec_IntMemory(&p->vCopy);
......@@ -506,6 +494,22 @@ static inline void Cba_NtkPrintStats( Cba_Ntk_t * p )
printf( "-> %s", Cba_NtkName(Cba_NtkHostNtk(p)) );
printf( "\n" );
}
static inline void Cba_NtkDeriveIndex( Cba_Ntk_t * p )
{
int i, iObj, iTerm;
Vec_IntFill( &p->vIndex, Cba_NtkObjNum(p), -1 );
Cba_NtkForEachPi( p, iObj, i )
Cba_ObjSetIndex( p, iObj, i );
Cba_NtkForEachPo( p, iObj, i )
Cba_ObjSetIndex( p, iObj, i );
Cba_NtkForEachBox( p, iObj )
{
Cba_BoxForEachBi( p, iObj, iTerm, i )
Cba_ObjSetIndex( p, iTerm, i );
Cba_BoxForEachBo( p, iObj, iTerm, i )
Cba_ObjSetIndex( p, iTerm, i );
}
}
/**Function*************************************************************
......@@ -551,12 +555,15 @@ static inline Cba_Man_t * Cba_ManStart( Cba_Man_t * p, int nNtks )
}
static inline Cba_Man_t * Cba_ManDup( Cba_Man_t * p )
{
Cba_Ntk_t * pNtk; int i;
Cba_Ntk_t * pNtk, * pHost; int i;
Cba_Man_t * pNew = Cba_ManStart( p, Cba_ManNtkNum(p) );
Cba_ManForEachNtk( p, pNtk, i )
Cba_NtkSetCopy( pNtk, i );
Cba_ManForEachNtk( p, pNtk, i )
Cba_NtkDup( Cba_NtkCopyNtk(pNew, pNtk), pNtk );
Cba_ManForEachNtk( p, pNtk, i )
if ( (pHost = Cba_NtkHostNtk(pNtk)) )
Cba_NtkSetHost( Cba_NtkCopyNtk(pNew, pNtk), Cba_NtkCopy(pHost), Cba_ObjCopy(pHost, Cba_NtkHostObj(pNtk)) );
return pNew;
}
static inline Cba_Man_t * Cba_ManDupUserBoxes( Cba_Man_t * p )
......
......@@ -202,7 +202,10 @@ Gia_Man_t * Cba_ManExtract( Cba_Man_t * p, int fBuffers, int fVerbose )
Vec_IntClear( &p->vBuf2RootObj );
Cba_ManForEachNtk( p, pNtk, i )
Cba_NtkStartCopies(pNtk);
{
Cba_NtkDeriveIndex( pNtk );
Cba_NtkStartCopies( pNtk );
}
// start the manager
pNew = Gia_ManStart( Cba_ManNodeNum(p) );
......@@ -297,15 +300,15 @@ void Cba_NtkCreateAndConnectBuffer( Gia_Man_t * pGia, Gia_Obj_t * pObj, Cba_Ntk_
if ( pGia && Gia_ObjFaninId0p(pGia, pObj) > 0 )
{
assert( Cba_ObjName(p, Gia_ObjFanin0(pObj)->Value) != Cba_ObjName(p, iTerm) ); // not a feedthrough
iObj = Cba_ObjAlloc( p, CBA_OBJ_BI, 0, Gia_ObjFanin0(pObj)->Value );
iObj = Cba_ObjAlloc( p, CBA_OBJ_BI, Gia_ObjFanin0(pObj)->Value );
Cba_ObjSetName( p, iObj, Cba_ObjName(p, Gia_ObjFanin0(pObj)->Value) );
Cba_ObjAlloc( p, Gia_ObjFaninC0(pObj) ? CBA_BOX_INV : CBA_BOX_BUF, -1, -1 );
Cba_ObjAlloc( p, Gia_ObjFaninC0(pObj) ? CBA_BOX_INV : CBA_BOX_BUF, -1 );
}
else
{
Cba_ObjAlloc( p, pGia && Gia_ObjFaninC0(pObj) ? CBA_BOX_C1 : CBA_BOX_C0, -1, -1 );
Cba_ObjAlloc( p, pGia && Gia_ObjFaninC0(pObj) ? CBA_BOX_C1 : CBA_BOX_C0, -1 );
}
iObj = Cba_ObjAlloc( p, CBA_OBJ_BO, 0, -1 );
iObj = Cba_ObjAlloc( p, CBA_OBJ_BO, -1 );
Cba_ObjSetName( p, iObj, Cba_ObjName(p, iTerm) );
Cba_ObjSetFanin( p, iTerm, iObj );
}
......@@ -348,12 +351,12 @@ void Cba_NtkInsertGia( Cba_Man_t * p, Gia_Man_t * pGia )
else
Type = CBA_BOX_AND;
// create box
iTerm = Cba_ObjAlloc( pNtk, CBA_OBJ_BI, 1, iLit1 );
iTerm = Cba_ObjAlloc( pNtk, CBA_OBJ_BI, iLit1 );
Cba_ObjSetName( pNtk, iTerm, Cba_ObjName(pNtk, iLit1) );
iTerm = Cba_ObjAlloc( pNtk, CBA_OBJ_BI, 0, iLit0 );
iTerm = Cba_ObjAlloc( pNtk, CBA_OBJ_BI, iLit0 );
Cba_ObjSetName( pNtk, iTerm, Cba_ObjName(pNtk, iLit0) );
Cba_ObjAlloc( pNtk, Type, -1, -1 );
pObj->Value = Cba_ObjAlloc( pNtk, CBA_OBJ_BO, 0, -1 );
Cba_ObjAlloc( pNtk, Type, -1 );
pObj->Value = Cba_ObjAlloc( pNtk, CBA_OBJ_BO, -1 );
}
}
assert( Count == Gia_ManBufNum(pGia) );
......@@ -453,16 +456,16 @@ void Cba_NtkCreateOrConnectFanin( Abc_Obj_t * pFanin, Cba_Ntk_t * p, int iTerm )
else if ( pFanin && (Abc_ObjIsPi(pFanin) || Abc_ObjIsBarBuf(pFanin) || Abc_NodeIsSeriousGate(pFanin)) ) // PI/BO or gate with name
{
assert( Cba_ObjName(p, pFanin->iTemp) != Cba_ObjName(p, iTerm) ); // not a feedthrough
iObj = Cba_ObjAlloc( p, CBA_OBJ_BI, 0, pFanin->iTemp );
iObj = Cba_ObjAlloc( p, CBA_OBJ_BI, pFanin->iTemp );
Cba_ObjSetName( p, iObj, Cba_ObjName(p, pFanin->iTemp) );
Cba_ObjAlloc( p, CBA_BOX_GATE, p->pDesign->ElemGates[2], -1 ); // buffer
iObj = Cba_ObjAlloc( p, CBA_OBJ_BO, 0, -1 );
Cba_ObjAlloc( p, CBA_BOX_GATE, p->pDesign->ElemGates[2] ); // buffer
iObj = Cba_ObjAlloc( p, CBA_OBJ_BO, -1 );
}
else
{
assert( !pFanin || Abc_NodeIsConst0(pFanin) || Abc_NodeIsConst1(pFanin) );
Cba_ObjAlloc( p, CBA_BOX_GATE, p->pDesign->ElemGates[(pFanin && Abc_NodeIsConst1(pFanin))], -1 ); // const 0/1
iObj = Cba_ObjAlloc( p, CBA_OBJ_BO, 0, -1 );
Cba_ObjAlloc( p, CBA_BOX_GATE, p->pDesign->ElemGates[(pFanin && Abc_NodeIsConst1(pFanin))] ); // const 0/1
iObj = Cba_ObjAlloc( p, CBA_OBJ_BO, -1 );
}
Cba_ObjSetName( p, iObj, Cba_ObjName(p, iTerm) );
Cba_ObjSetFanin( p, iTerm, iObj );
......@@ -514,11 +517,11 @@ void Cba_NtkInsertNtk( Cba_Man_t * p, Abc_Ntk_t * pNtk )
pCbaNtk = Cba_ManNtk( p, pObj->iTemp );
for ( k = Abc_ObjFaninNum(pObj)-1; k >= 0; k-- )
{
iTerm = Cba_ObjAlloc( pCbaNtk, CBA_OBJ_BI, k, Abc_ObjFanin(pObj, k)->iTemp );
iTerm = Cba_ObjAlloc( pCbaNtk, CBA_OBJ_BI, Abc_ObjFanin(pObj, k)->iTemp );
Cba_ObjSetName( pCbaNtk, iTerm, Cba_ObjName(pCbaNtk, Abc_ObjFanin(pObj, k)->iTemp) );
}
Cba_ObjAlloc( pCbaNtk, CBA_BOX_GATE, Abc_NamStrFind(p->pMods, Mio_GateReadName((Mio_Gate_t *)pObj->pData)), -1 );
pObj->iTemp = Cba_ObjAlloc( pCbaNtk, CBA_OBJ_BO, 0, -1 );
Cba_ObjAlloc( pCbaNtk, CBA_BOX_GATE, Abc_NamStrFind(p->pMods, Mio_GateReadName((Mio_Gate_t *)pObj->pData)) );
pObj->iTemp = Cba_ObjAlloc( pCbaNtk, CBA_OBJ_BO, -1 );
}
}
assert( Count == pNtk->nBarBufs2 );
......
......@@ -44,7 +44,7 @@ ABC_NAMESPACE_IMPL_START
***********************************************************************/
int CbaManReadCbaLine( Vec_Str_t * vOut, int * pPos, char * pBuffer, char * pLimit )
{
char c;
char c;
while ( (c = Vec_StrEntry(vOut, (*pPos)++)) != '\n' && pBuffer < pLimit )
*pBuffer++ = c;
*pBuffer = 0;
......@@ -94,11 +94,19 @@ void Cba_ManReadCbaVecInt( Vec_Str_t * vOut, int * pPos, Vec_Int_t * p, int nSiz
}
void Cba_ManReadCbaNtk( Vec_Str_t * vOut, int * pPos, Cba_Ntk_t * pNtk )
{
Cba_ManReadCbaVecInt( vOut, pPos, &pNtk->vInputs, 4 * Cba_NtkPiNumAlloc(pNtk) );
Cba_ManReadCbaVecInt( vOut, pPos, &pNtk->vOutputs, 4 * Cba_NtkPoNumAlloc(pNtk) );
Cba_ManReadCbaVecStr( vOut, pPos, &pNtk->vType, Cba_NtkObjNumAlloc(pNtk) );
Cba_ManReadCbaVecInt( vOut, pPos, &pNtk->vIndex, 4 * Cba_NtkObjNumAlloc(pNtk) );
Cba_ManReadCbaVecInt( vOut, pPos, &pNtk->vFanin, 4 * Cba_NtkObjNumAlloc(pNtk) );
int i, Type;
Cba_ManReadCbaVecStr( vOut, pPos, &pNtk->vType, Cba_NtkObjNumAlloc(pNtk) );
Cba_ManReadCbaVecInt( vOut, pPos, &pNtk->vFanin, 4 * Cba_NtkObjNumAlloc(pNtk) );
Cba_NtkForEachObjType( pNtk, Type, i )
{
if ( Type == CBA_OBJ_PI )
Vec_IntPush( &pNtk->vInputs, i );
if ( Type == CBA_OBJ_PO )
Vec_IntPush( &pNtk->vOutputs, i );
}
assert( Cba_NtkPiNum(pNtk) == Cba_NtkPiNumAlloc(pNtk) );
assert( Cba_NtkPoNum(pNtk) == Cba_NtkPoNumAlloc(pNtk) );
assert( Cba_NtkObjNum(pNtk) == Cba_NtkObjNumAlloc(pNtk) );
}
Cba_Man_t * Cba_ManReadCbaInt( Vec_Str_t * vOut )
{
......@@ -186,11 +194,8 @@ Cba_Man_t * Cba_ManReadCba( char * pFileName )
***********************************************************************/
void Cba_ManWriteCbaNtk( Vec_Str_t * vOut, Cba_Ntk_t * pNtk )
{
Vec_StrPushBuffer( vOut, (char *)Vec_IntArray(&pNtk->vInputs), 4 * Cba_NtkPiNum(pNtk) );
Vec_StrPushBuffer( vOut, (char *)Vec_IntArray(&pNtk->vOutputs), 4 * Cba_NtkPoNum(pNtk) );
Vec_StrPushBuffer( vOut, (char *)Vec_StrArray(&pNtk->vType), Cba_NtkObjNum(pNtk) );
Vec_StrPushBuffer( vOut, (char *)Vec_IntArray(&pNtk->vIndex), 4 * Cba_NtkObjNum(pNtk) );
Vec_StrPushBuffer( vOut, (char *)Vec_IntArray(&pNtk->vFanin), 4 * Cba_NtkObjNum(pNtk) );
Vec_StrPushBuffer( vOut, (char *)Vec_StrArray(&pNtk->vType), Cba_NtkObjNum(pNtk) );
Vec_StrPushBuffer( vOut, (char *)Vec_IntArray(&pNtk->vFanin), 4 * Cba_NtkObjNum(pNtk) );
}
void Cba_ManWriteCbaInt( Vec_Str_t * vOut, Cba_Man_t * p )
{
......
......@@ -507,7 +507,7 @@ int Cba_CommandClp( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( 1, "Cba_CommandGet(): There is no current design.\n" );
return 0;
}
pNew = Cba_ManDup( p );
pNew = Cba_ManCollapse( p );
Cba_AbcUpdateMan( pAbc, pNew );
return 0;
usage:
......
......@@ -115,7 +115,7 @@ int Cba_ManClpObjNum_rec( Cba_Ntk_t * p )
if ( p->Count >= 0 )
return p->Count;
Cba_NtkForEachBox( p, i )
Counter += Cba_ObjIsBoxUser(p, i) ? Cba_ManClpObjNum_rec( Cba_BoxNtk(p, i) ) : Cba_BoxSize(p, i);
Counter += Cba_ObjIsBoxUser(p, i) ? Cba_ManClpObjNum_rec( Cba_BoxNtk(p, i) ) + 3*Cba_BoxBoNum(p, i) : Cba_BoxSize(p, i);
return (p->Count = Counter);
}
int Cba_ManClpObjNum( Cba_Man_t * p )
......@@ -220,37 +220,49 @@ int Cba_NtkDfsUserBoxes( Cba_Ntk_t * p )
***********************************************************************/
void Cba_NtkCollapse_rec( Cba_Ntk_t * pNew, Cba_Ntk_t * p, Vec_Int_t * vSigs )
{
int i, k, iObj, iTerm;
int i, iObj, iObjNew, iTerm;
Cba_NtkStartCopies( p );
// set PI copies
assert( Vec_IntSize(vSigs) == Cba_NtkPiNum(p) );
Cba_NtkForEachPi( p, iObj, i )
Cba_ObjSetCopy( p, iObj, Vec_IntEntry(vSigs, i) );
// duplicate internal objects
// duplicate internal objects and create buffers for hierarchy instances
Cba_NtkForEachBox( p, iObj )
if ( Cba_ObjIsBoxPrim(p, iObj) )
if ( Cba_ObjIsBoxPrim( p, iObj ) )
Cba_BoxDup( pNew, p, iObj );
// duplicate user moduled in DFS order
Vec_IntForEachEntry( &p->vArray, iObj, i )
{
assert( Cba_ObjIsBoxUser(p, iObj) );
Vec_IntClear( vSigs );
Cba_BoxForEachBi( p, iObj, iTerm, k )
Vec_IntPush( vSigs, Cba_ObjCopy(p, Cba_ObjFanin(p, iTerm)) );
Cba_NtkCollapse_rec( pNew, Cba_BoxNtk(p, iObj), vSigs );
assert( Vec_IntSize(vSigs) == Cba_BoxBoNum(p, iObj) );
Cba_BoxForEachBo( p, iObj, iTerm, k )
Cba_ObjSetCopy( p, iTerm, Vec_IntEntry(vSigs, k) );
}
// connect objects
Cba_NtkForEachBi( p, iObj )
Cba_ObjSetFanin( pNew, Cba_ObjCopy(p, iObj), Cba_ObjCopy(p, Cba_ObjFanin(p, iObj)) );
else
{
Cba_BoxForEachBo( p, iObj, iTerm, i )
{
iObjNew = Cba_ObjAlloc( pNew, CBA_OBJ_BI, -1 );
iObjNew = Cba_ObjAlloc( pNew, CBA_BOX_BUF, -1 ); // buffer
iObjNew = Cba_ObjAlloc( pNew, CBA_OBJ_BO, -1 );
Cba_ObjSetCopy( p, iTerm, iObjNew );
}
}
// duplicate user modules and connect objects
Cba_NtkForEachBox( p, iObj )
if ( Cba_ObjIsBoxPrim( p, iObj ) )
{
Cba_BoxForEachBi( p, iObj, iTerm, i )
Cba_ObjSetFanin( pNew, Cba_ObjCopy(p, iTerm), Cba_ObjCopy(p, Cba_ObjFanin(p, iTerm)) );
}
else
{
Vec_IntClear( vSigs );
Cba_BoxForEachBi( p, iObj, iTerm, i )
Vec_IntPush( vSigs, Cba_ObjCopy(p, Cba_ObjFanin(p, iTerm)) );
Cba_NtkCollapse_rec( pNew, Cba_BoxNtk(p, iObj), vSigs );
assert( Vec_IntSize(vSigs) == Cba_BoxBoNum(p, iObj) );
Cba_BoxForEachBo( p, iObj, iTerm, i )
Cba_ObjSetFanin( pNew, Cba_ObjCopy(p, iTerm)-2, Vec_IntEntry(vSigs, i) );
}
// collect POs
Vec_IntClear( vSigs );
Cba_NtkForEachPo( p, iObj, i )
Vec_IntPush( vSigs, Cba_ObjCopy(p, Cba_ObjFanin(p, iObj)) );
}
Cba_Man_t * Cba_ManCollapseInt( Cba_Man_t * p )
Cba_Man_t * Cba_ManCollapse( Cba_Man_t * p )
{
int i, iObj;
Vec_Int_t * vSigs = Vec_IntAlloc( 1000 );
......@@ -259,29 +271,26 @@ Cba_Man_t * Cba_ManCollapseInt( Cba_Man_t * p )
Cba_Ntk_t * pRootNew = Cba_ManRoot( pNew );
Cba_NtkAlloc( pRootNew, Cba_NtkNameId(pRoot), Cba_NtkPiNum(pRoot), Cba_NtkPoNum(pRoot), Cba_ManClpObjNum(p) );
Cba_NtkForEachPi( pRoot, iObj, i )
Vec_IntPush( vSigs, Cba_ObjAlloc(pRootNew, CBA_OBJ_PI, i, -1) );
Vec_IntPush( vSigs, Cba_ObjAlloc(pRootNew, CBA_OBJ_PI, -1) );
Cba_NtkCollapse_rec( pRootNew, pRoot, vSigs );
assert( Vec_IntSize(vSigs) == Cba_NtkPoNum(pRoot) );
Cba_NtkForEachPo( pRoot, iObj, i )
Cba_ObjAlloc( pRootNew, CBA_OBJ_PO, i, Vec_IntEntry(vSigs, i) );
Cba_ObjAlloc( pRootNew, CBA_OBJ_PO, Vec_IntEntry(vSigs, i) );
assert( Cba_NtkObjNum(pRootNew) == Cba_NtkObjNumAlloc(pRootNew) );
Vec_IntFree( vSigs );
/*
// transfer PI/PO names
Cba_NtkStartNames( pRootNew );
Cba_NtkForEachPo( pRoot, iObj, i )
Cba_ObjSetName( pRootNew, Cba_NtkPo(pRootNew, i), Cba_ObjName(pRoot, iObj) );
Cba_NtkForEachPo( pRoot, iObj, i )
Cba_ObjSetName( pRootNew, Cba_NtkPo(pRootNew, i), Cba_ObjName(pRoot, iObj) );
if ( Cba_NtkHasNames(pRoot) )
{
Cba_NtkStartNames( pRootNew );
Cba_NtkForEachPo( pRoot, iObj, i )
Cba_ObjSetName( pRootNew, Cba_NtkPo(pRootNew, i), Cba_ObjName(pRoot, iObj) );
Cba_NtkForEachPo( pRoot, iObj, i )
Cba_ObjSetName( pRootNew, Cba_NtkPo(pRootNew, i), Cba_ObjName(pRoot, iObj) );
}
*/
return pNew;
}
Cba_Man_t * Cba_ManCollapse( Cba_Man_t * p )
{
Cba_Ntk_t * pNtk; int i;
Cba_ManForEachNtk( p, pNtk, i )
if ( !Cba_NtkDfsUserBoxes(pNtk) )
return NULL;
return Cba_ManCollapseInt( p );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
......
......@@ -147,7 +147,7 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
{
if ( Vec_IntEntry(vMap, NameId) != -1 )
printf( "Primary inputs %d and %d have the same name.\n", Vec_IntEntry(vMap, NameId), i );
iObj = Cba_ObjAlloc( pNew, CBA_OBJ_PI, -1, -1 );
iObj = Cba_ObjAlloc( pNew, CBA_OBJ_PI, -1 );
Cba_ObjSetName( pNew, iObj, NameId );
Vec_IntWriteEntry( vMap, NameId, iObj );
}
......@@ -250,7 +250,7 @@ void Prs_ManBuildNtk( Cba_Ntk_t * pNew, Vec_Ptr_t * vDes, Prs_Ntk_t * pNtk, Vec_
}
Prs_NtkForEachPo( pNtk, NameId, i )
{
iObj = Cba_ObjAlloc( pNew, CBA_OBJ_PO, -1, Vec_IntEntry(vMap, NameId) );
iObj = Cba_ObjAlloc( pNew, CBA_OBJ_PO, Vec_IntEntry(vMap, NameId) );
Cba_ObjSetName( pNew, iObj, NameId );
}
if ( nNonDriven )
......
......@@ -289,7 +289,7 @@ int Cba_NtkDeriveFromPtr( Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk, Vec_Int_t * vMap,
NameId = Abc_NamStrFindOrAdd( pNtk->pDesign->pStrs, pName, NULL );
if ( Vec_IntGetEntryFull(vMap, NameId) != -1 )
{ printf( "PI with name \"%s\" is not unique module \"%s\".\n", pName, pModuleName ); return 0; }
iObj = Cba_ObjAlloc( pNtk, CBA_OBJ_PI, -1, -1 );
iObj = Cba_ObjAlloc( pNtk, CBA_OBJ_PI, -1 );
Cba_ObjSetName( pNtk, iObj, NameId );
Vec_IntSetEntryFull( vMap, NameId, iObj );
}
......@@ -340,7 +340,7 @@ int Cba_NtkDeriveFromPtr( Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk, Vec_Int_t * vMap,
NameId = Abc_NamStrFindOrAdd( pNtk->pDesign->pStrs, pName, NULL );
if ( Vec_IntGetEntryFull(vMap, NameId) == -1 )
printf( "PO with name \"%s\" in not driven in module \"%s\".\n", pName, pModuleName );
iObj = Cba_ObjAlloc( pNtk, CBA_OBJ_PO, -1, Vec_IntGetEntryFull(vMap, NameId) );
iObj = Cba_ObjAlloc( pNtk, CBA_OBJ_PO, Vec_IntGetEntryFull(vMap, NameId) );
Cba_ObjSetName( pNtk, iObj, NameId );
}
// update map
......
......@@ -322,7 +322,7 @@ void Abc_SclDnsizePerformInt( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPa
Vec_IntFree( vEvals );
Vec_IntFree( vTryLater );
if ( !pPars->fVerbose )
printf( " \r" );
printf( " \r" );
// report runtime
p->timeTotal = Abc_Clock() - p->timeTotal;
......
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