Improvements and tuning of CBA with buffering/sizing.

This commit is contained in:
Alan Mishchenko
2015-02-04 16:29:55 -08:00
parent eb270018b9
commit 8410daf3e4
13 changed files with 142 additions and 85 deletions
+1 -1
View File
@@ -358,7 +358,7 @@ static inline int Abc_ObjIsLatch( Abc_Obj_t * pObj ) { return pO
static inline int Abc_ObjIsBox( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_LATCH || pObj->Type == ABC_OBJ_WHITEBOX || pObj->Type == ABC_OBJ_BLACKBOX; }
static inline int Abc_ObjIsWhitebox( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_WHITEBOX;}
static inline int Abc_ObjIsBlackbox( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_BLACKBOX;}
static inline int Abc_ObjIsBarBuf( Abc_Obj_t * pObj ) { return Abc_NtkIsLogic(pObj->pNtk) && Abc_ObjIsNode(pObj) && Vec_IntSize(&pObj->vFanins) == 1 && pObj->pData == NULL; }
static inline int Abc_ObjIsBarBuf( Abc_Obj_t * pObj ) { return Abc_NtkHasMapping(pObj->pNtk) && Abc_ObjIsNode(pObj) && Vec_IntSize(&pObj->vFanins) == 1 && pObj->pData == NULL; }
static inline void Abc_ObjBlackboxToWhitebox( Abc_Obj_t * pObj ) { assert( Abc_ObjIsBlackbox(pObj) ); pObj->Type = ABC_OBJ_WHITEBOX; pObj->pNtk->nObjCounts[ABC_OBJ_BLACKBOX]--; pObj->pNtk->nObjCounts[ABC_OBJ_WHITEBOX]++; }
// working with fanin/fanout edges
+8 -5
View File
@@ -87,14 +87,17 @@ Vec_Ptr_t * Abc_NtkDfs( Abc_Ntk_t * pNtk, int fCollectAll )
Abc_NtkIncrementTravId( pNtk );
// start the array of nodes
vNodes = Vec_PtrAlloc( 100 );
Abc_NtkForEachObj( pNtk, pObj, i )
if ( pNtk->nBarBufs2 > 0 )
Abc_NtkForEachBarBuf( pNtk, pObj, i )
{
Abc_NodeSetTravIdCurrent( pObj );
Abc_NtkDfs_rec( Abc_ObjFanin0Ntk(Abc_ObjFanin0(pObj)), vNodes );
Vec_PtrPush( vNodes, pObj );
}
Abc_NtkForEachCo( pNtk, pObj, i )
{
if ( !Abc_ObjIsCo(pObj) && !Abc_ObjIsBarBuf(pObj) )
continue;
Abc_NodeSetTravIdCurrent( pObj );
Abc_NtkDfs_rec( Abc_ObjFanin0Ntk(Abc_ObjFanin0(pObj)), vNodes );
if ( Abc_ObjIsBarBuf(pObj) )
Vec_PtrPush( vNodes, pObj );
}
// collect dangling nodes if asked to
if ( fCollectAll )
+1 -1
View File
@@ -1081,7 +1081,6 @@ int Abc_NtkMapToSop( Abc_Ntk_t * pNtk )
// update the functionality manager
assert( pNtk->pManFunc == Abc_FrameReadLibGen() );
pNtk->pManFunc = Mem_FlexStart();
pNtk->ntkFunc = ABC_FUNC_SOP;
// update the nodes
Abc_NtkForEachNode( pNtk, pNode, i )
{
@@ -1091,6 +1090,7 @@ int Abc_NtkMapToSop( Abc_Ntk_t * pNtk )
assert( Abc_SopGetVarNum(pSop) == Abc_ObjFaninNum(pNode) );
pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, pSop );
}
pNtk->ntkFunc = ABC_FUNC_SOP;
return 1;
}
+1 -1
View File
@@ -377,7 +377,7 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, int fCopyName
else if ( Abc_NtkHasAig(pNtkNew) )
pObjNew->pData = Hop_Transfer((Hop_Man_t *)pObj->pNtk->pManFunc, (Hop_Man_t *)pNtkNew->pManFunc, (Hop_Obj_t *)pObj->pData, Abc_ObjFaninNum(pObj));
else if ( Abc_NtkHasMapping(pNtkNew) )
pObjNew->pData = pObj->pData;
pObjNew->pData = pObj->pData, pNtkNew->nBarBufs2 += !pObj->pData;
else assert( 0 );
}
}
+2 -2
View File
@@ -1073,7 +1073,7 @@ void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary )
// count the gates by name
CounterTotal = 0;
Abc_NtkForEachNode( pNtk, pObj, i )
Abc_NtkForEachNodeNotBarBuf( pNtk, pObj, i )
{
if ( i == 0 ) continue;
Mio_GateSetValue( (Mio_Gate_t *)pObj->pData, 1 + Mio_GateReadValue((Mio_Gate_t *)pObj->pData) );
@@ -1128,7 +1128,7 @@ void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary )
// get hold of the SOP of the node
CountConst = CountBuf = CountInv = CountAnd = CountOr = CountOther = CounterTotal = 0;
Abc_NtkForEachNode( pNtk, pObj, i )
Abc_NtkForEachNodeNotBarBuf( pNtk, pObj, i )
{
if ( i == 0 ) continue;
if ( Abc_NtkHasMapping(pNtk) )
+8 -8
View File
@@ -157,10 +157,10 @@ struct Cba_Man_t_
int nNtks; // number of current networks
Cba_Ntk_t * pNtks; // networks
// user data
Vec_Int_t * vBuf2RootNtk;
Vec_Int_t * vBuf2RootObj;
Vec_Int_t * vBuf2LeafNtk;
Vec_Int_t * vBuf2LeafObj;
Vec_Int_t vBuf2RootNtk;
Vec_Int_t vBuf2RootObj;
Vec_Int_t vBuf2LeafNtk;
Vec_Int_t vBuf2LeafObj;
void * pMioLib;
void ** ppGraphs;
int ElemGates[4];
@@ -574,10 +574,10 @@ static inline void Cba_ManFree( Cba_Man_t * p )
Cba_Ntk_t * pNtk; int i;
Cba_ManForEachNtk( p, pNtk, i )
Cba_NtkFree( pNtk );
Vec_IntFreeP( &p->vBuf2LeafNtk );
Vec_IntFreeP( &p->vBuf2LeafObj );
Vec_IntFreeP( &p->vBuf2RootNtk );
Vec_IntFreeP( &p->vBuf2RootObj );
Vec_IntErase( &p->vBuf2LeafNtk );
Vec_IntErase( &p->vBuf2LeafObj );
Vec_IntErase( &p->vBuf2RootNtk );
Vec_IntErase( &p->vBuf2RootObj );
Abc_NamDeref( p->pStrs );
Abc_NamDeref( p->pMods );
ABC_FREE( p->pName );
+32 -36
View File
@@ -90,12 +90,12 @@ int Cba_ManAddBarbuf( Gia_Man_t * pNew, int iRes, Cba_Man_t * p, int iLNtk, int
return iRes;
assert( iRes > 0 );
if ( vMap && Abc_Lit2Var(iRes) < Vec_IntSize(vMap) && (iIdLit = Vec_IntEntry(vMap, Abc_Lit2Var(iRes))) >= 0 &&
Vec_IntEntry(p->vBuf2LeafNtk, Abc_Lit2Var(iIdLit)) == iLNtk && Vec_IntEntry(p->vBuf2RootNtk, Abc_Lit2Var(iIdLit)) == iRNtk )
Vec_IntEntry(&p->vBuf2LeafNtk, Abc_Lit2Var(iIdLit)) == iLNtk && Vec_IntEntry(&p->vBuf2RootNtk, Abc_Lit2Var(iIdLit)) == iRNtk )
return Abc_LitNotCond( Vec_IntEntry(pNew->vBarBufs, Abc_Lit2Var(iIdLit)), Abc_LitIsCompl(iRes) ^ Abc_LitIsCompl(iIdLit) );
Vec_IntPush( p->vBuf2LeafNtk, iLNtk );
Vec_IntPush( p->vBuf2LeafObj, iLObj );
Vec_IntPush( p->vBuf2RootNtk, iRNtk );
Vec_IntPush( p->vBuf2RootObj, iRObj );
Vec_IntPush( &p->vBuf2LeafNtk, iLNtk );
Vec_IntPush( &p->vBuf2LeafObj, iLObj );
Vec_IntPush( &p->vBuf2RootNtk, iRNtk );
Vec_IntPush( &p->vBuf2RootObj, iRObj );
iBufLit = Gia_ManAppendBuf( pNew, iRes );
if ( vMap )
{
@@ -196,14 +196,10 @@ Gia_Man_t * Cba_ManExtract( Cba_Man_t * p, int fBuffers, int fVerbose )
Vec_Int_t * vMap = NULL;
int i, iObj;
Vec_IntFreeP( &p->vBuf2LeafNtk );
Vec_IntFreeP( &p->vBuf2LeafObj );
Vec_IntFreeP( &p->vBuf2RootNtk );
Vec_IntFreeP( &p->vBuf2RootObj );
p->vBuf2LeafNtk = Vec_IntAlloc( 1000 );
p->vBuf2LeafObj = Vec_IntAlloc( 1000 );
p->vBuf2RootNtk = Vec_IntAlloc( 1000 );
p->vBuf2RootObj = Vec_IntAlloc( 1000 );
Vec_IntClear( &p->vBuf2LeafNtk );
Vec_IntClear( &p->vBuf2LeafObj );
Vec_IntClear( &p->vBuf2RootNtk );
Vec_IntClear( &p->vBuf2RootObj );
Cba_ManForEachNtk( p, pNtk, i )
Cba_NtkStartCopies(pNtk);
@@ -231,7 +227,7 @@ Gia_Man_t * Cba_ManExtract( Cba_Man_t * p, int fBuffers, int fVerbose )
// primary outputs
Cba_NtkForEachPo( pRoot, iObj, i )
Gia_ManAppendCo( pNew, Cba_ObjCopy(pRoot, iObj) );
assert( Vec_IntSize(p->vBuf2LeafNtk) == pNew->nBufs );
assert( Vec_IntSize(&p->vBuf2LeafNtk) == pNew->nBufs );
// cleanup
pNew = Gia_ManCleanup( pTemp = pNew );
@@ -254,14 +250,14 @@ Gia_Man_t * Cba_ManExtract( Cba_Man_t * p, int fBuffers, int fVerbose )
void Cba_ManMarkNodesGia( Cba_Man_t * p, Gia_Man_t * pGia )
{
Gia_Obj_t * pObj; int i, Count = 0;
assert( Vec_IntSize(p->vBuf2LeafNtk) == Gia_ManBufNum(pGia) );
assert( Vec_IntSize(&p->vBuf2LeafNtk) == Gia_ManBufNum(pGia) );
Gia_ManConst0(pGia)->Value = 0;
Gia_ManForEachPi( pGia, pObj, i )
pObj->Value = 0;
Gia_ManForEachAnd( pGia, pObj, i )
{
if ( Gia_ObjIsBuf(pObj) )
pObj->Value = Vec_IntEntry( p->vBuf2LeafNtk, Count++ );
pObj->Value = Vec_IntEntry( &p->vBuf2LeafNtk, Count++ );
else
{
pObj->Value = Gia_ObjFanin0(pObj)->Value;
@@ -278,21 +274,21 @@ void Cba_ManMarkNodesGia( Cba_Man_t * p, Gia_Man_t * pGia )
void Cba_ManRemapBarbufs( Cba_Man_t * pNew, Cba_Man_t * p )
{
Cba_Ntk_t * pNtk; int Entry, i;
assert( p->vBuf2RootNtk != NULL );
assert( pNew->vBuf2RootNtk == NULL );
pNew->vBuf2RootNtk = Vec_IntDup( p->vBuf2RootNtk );
pNew->vBuf2RootObj = Vec_IntDup( p->vBuf2RootObj );
pNew->vBuf2LeafNtk = Vec_IntDup( p->vBuf2LeafNtk );
pNew->vBuf2LeafObj = Vec_IntDup( p->vBuf2LeafObj );
Vec_IntForEachEntry( p->vBuf2LeafObj, Entry, i )
assert( Vec_IntSize(&p->vBuf2RootNtk) );
assert( !Vec_IntSize(&pNew->vBuf2RootNtk) );
Vec_IntAppend( &pNew->vBuf2RootNtk, &p->vBuf2RootNtk );
Vec_IntAppend( &pNew->vBuf2RootObj, &p->vBuf2RootObj );
Vec_IntAppend( &pNew->vBuf2LeafNtk, &p->vBuf2LeafNtk );
Vec_IntAppend( &pNew->vBuf2LeafObj, &p->vBuf2LeafObj );
Vec_IntForEachEntry( &p->vBuf2LeafObj, Entry, i )
{
pNtk = Cba_ManNtk( p, Vec_IntEntry(p->vBuf2LeafNtk, i) );
Vec_IntWriteEntry( pNew->vBuf2LeafObj, i, Cba_ObjCopy(pNtk, Entry) );
pNtk = Cba_ManNtk( p, Vec_IntEntry(&p->vBuf2LeafNtk, i) );
Vec_IntWriteEntry( &pNew->vBuf2LeafObj, i, Cba_ObjCopy(pNtk, Entry) );
}
Vec_IntForEachEntry( p->vBuf2RootObj, Entry, i )
Vec_IntForEachEntry( &p->vBuf2RootObj, Entry, i )
{
pNtk = Cba_ManNtk( p, Vec_IntEntry(p->vBuf2RootNtk, i) );
Vec_IntWriteEntry( pNew->vBuf2RootObj, i, Cba_ObjCopy(pNtk, Entry) );
pNtk = Cba_ManNtk( p, Vec_IntEntry(&p->vBuf2RootNtk, i) );
Vec_IntWriteEntry( &pNew->vBuf2RootObj, i, Cba_ObjCopy(pNtk, Entry) );
}
}
void Cba_NtkCreateAndConnectBuffer( Gia_Man_t * pGia, Gia_Obj_t * pObj, Cba_Ntk_t * p, int iTerm )
@@ -326,13 +322,13 @@ void Cba_NtkInsertGia( Cba_Man_t * p, Gia_Man_t * pGia )
{
if ( Gia_ObjIsBuf(pObj) )
{
pNtk = Cba_ManNtk( p, Vec_IntEntry(p->vBuf2RootNtk, Count) );
iTerm = Vec_IntEntry( p->vBuf2RootObj, Count );
pNtk = Cba_ManNtk( p, Vec_IntEntry(&p->vBuf2RootNtk, Count) );
iTerm = Vec_IntEntry( &p->vBuf2RootObj, Count );
assert( Cba_ObjIsCo(pNtk, iTerm) );
if ( Cba_ObjFanin(pNtk, iTerm) == -1 ) // not a feedthrough
Cba_NtkCreateAndConnectBuffer( pGia, pObj, pNtk, iTerm );
// prepare leaf
pObj->Value = Vec_IntEntry( p->vBuf2LeafObj, Count++ );
pObj->Value = Vec_IntEntry( &p->vBuf2LeafObj, Count++ );
}
else
{
@@ -424,13 +420,13 @@ static inline int Abc_NodeIsSeriousGate( Abc_Obj_t * p )
void Cba_ManMarkNodesAbc( Cba_Man_t * p, Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj, * pFanin; int i, k, Count = 0;
assert( Vec_IntSize(p->vBuf2LeafNtk) == pNtk->nBarBufs2 );
assert( Vec_IntSize(&p->vBuf2LeafNtk) == pNtk->nBarBufs2 );
Abc_NtkForEachPi( pNtk, pObj, i )
pObj->iTemp = 0;
Abc_NtkForEachNode( pNtk, pObj, i )
{
if ( Abc_ObjIsBarBuf(pObj) )
pObj->iTemp = Vec_IntEntry( p->vBuf2LeafNtk, Count++ );
pObj->iTemp = Vec_IntEntry( &p->vBuf2LeafNtk, Count++ );
else if ( Abc_NodeIsSeriousGate(pObj) )
{
pObj->iTemp = Abc_ObjFanin0(pObj)->iTemp;
@@ -505,13 +501,13 @@ void Cba_NtkInsertNtk( Cba_Man_t * p, Abc_Ntk_t * pNtk )
{
if ( Abc_ObjIsBarBuf(pObj) )
{
pCbaNtk = Cba_ManNtk( p, Vec_IntEntry(p->vBuf2RootNtk, Count) );
iTerm = Vec_IntEntry( p->vBuf2RootObj, Count );
pCbaNtk = Cba_ManNtk( p, Vec_IntEntry(&p->vBuf2RootNtk, Count) );
iTerm = Vec_IntEntry( &p->vBuf2RootObj, Count );
assert( Cba_ObjIsCo(pCbaNtk, iTerm) );
if ( Cba_ObjFanin(pCbaNtk, iTerm) == -1 ) // not a feedthrough
Cba_NtkCreateOrConnectFanin( Abc_ObjFanin0(pObj), pCbaNtk, iTerm );
// prepare leaf
pObj->iTemp = Vec_IntEntry( p->vBuf2LeafObj, Count++ );
pObj->iTemp = Vec_IntEntry( &p->vBuf2LeafObj, Count++ );
}
else if ( Abc_NodeIsSeriousGate(pObj) )
{
+12 -3
View File
@@ -615,9 +615,18 @@ int Io_NtkWriteNode( FILE * pFile, Abc_Obj_t * pNode, int Length )
if ( Abc_NtkHasMapping(pNode->pNtk) )
{
// write the .gate line
fprintf( pFile, ".gate" );
RetValue = Io_NtkWriteNodeGate( pFile, pNode, Length );
fprintf( pFile, "\n" );
if ( Abc_ObjIsBarBuf(pNode) )
{
fprintf( pFile, ".barbuf " );
fprintf( pFile, "%s %s", Abc_ObjName(Abc_ObjFanin0(pNode)), Abc_ObjName(Abc_ObjFanout0(pNode)) );
fprintf( pFile, "\n" );
}
else
{
fprintf( pFile, ".gate" );
RetValue = Io_NtkWriteNodeGate( pFile, pNode, Length );
fprintf( pFile, "\n" );
}
}
else
{