diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2015-02-04 16:29:55 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2015-02-04 16:29:55 -0800 |
commit | 8410daf3e49f142dc94587d77680d7cdcfe06b5a (patch) | |
tree | 1421944373a2581eaef995c392efe2dfd712affb /src/base | |
parent | eb270018b92d949953cba3017ae6a540260598c1 (diff) | |
download | abc-8410daf3e49f142dc94587d77680d7cdcfe06b5a.tar.gz abc-8410daf3e49f142dc94587d77680d7cdcfe06b5a.tar.bz2 abc-8410daf3e49f142dc94587d77680d7cdcfe06b5a.zip |
Improvements and tuning of CBA with buffering/sizing.
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/abc/abc.h | 2 | ||||
-rw-r--r-- | src/base/abc/abcDfs.c | 13 | ||||
-rw-r--r-- | src/base/abc/abcFunc.c | 2 | ||||
-rw-r--r-- | src/base/abc/abcObj.c | 2 | ||||
-rw-r--r-- | src/base/abci/abcPrint.c | 4 | ||||
-rw-r--r-- | src/base/cba/cba.h | 16 | ||||
-rw-r--r-- | src/base/cba/cbaBlast.c | 68 | ||||
-rw-r--r-- | src/base/io/ioWriteBlif.c | 15 |
8 files changed, 65 insertions, 57 deletions
diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h index c23a711a..bf84226b 100644 --- a/src/base/abc/abc.h +++ b/src/base/abc/abc.h @@ -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 diff --git a/src/base/abc/abcDfs.c b/src/base/abc/abcDfs.c index 9dd2b4bf..811a6929 100644 --- a/src/base/abc/abcDfs.c +++ b/src/base/abc/abcDfs.c @@ -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 ) diff --git a/src/base/abc/abcFunc.c b/src/base/abc/abcFunc.c index 782091d7..6e9e3d09 100644 --- a/src/base/abc/abcFunc.c +++ b/src/base/abc/abcFunc.c @@ -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; } diff --git a/src/base/abc/abcObj.c b/src/base/abc/abcObj.c index 94a5f0bb..91d89026 100644 --- a/src/base/abc/abcObj.c +++ b/src/base/abc/abcObj.c @@ -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 ); } } diff --git a/src/base/abci/abcPrint.c b/src/base/abci/abcPrint.c index 02c06e65..361f1e99 100644 --- a/src/base/abci/abcPrint.c +++ b/src/base/abci/abcPrint.c @@ -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) ) diff --git a/src/base/cba/cba.h b/src/base/cba/cba.h index f1b94390..2ac3ed35 100644 --- a/src/base/cba/cba.h +++ b/src/base/cba/cba.h @@ -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 ); diff --git a/src/base/cba/cbaBlast.c b/src/base/cba/cbaBlast.c index 2f955241..aff8799a 100644 --- a/src/base/cba/cbaBlast.c +++ b/src/base/cba/cbaBlast.c @@ -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) ) { diff --git a/src/base/io/ioWriteBlif.c b/src/base/io/ioWriteBlif.c index 65546c01..88544d9f 100644 --- a/src/base/io/ioWriteBlif.c +++ b/src/base/io/ioWriteBlif.c @@ -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 { |