diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2015-01-15 20:08:15 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2015-01-15 20:08:15 -0800 |
commit | 1a5a11cbc6054fc63f49a0ecb57ccdcf1bd480b0 (patch) | |
tree | 7cebf8c847744ff981be87abe4480d7285d5553b | |
parent | c7e3c8f3751ffc0e4f72bb046c8b384708cd9db8 (diff) | |
download | abc-1a5a11cbc6054fc63f49a0ecb57ccdcf1bd480b0.tar.gz abc-1a5a11cbc6054fc63f49a0ecb57ccdcf1bd480b0.tar.bz2 abc-1a5a11cbc6054fc63f49a0ecb57ccdcf1bd480b0.zip |
Various transformations of Cba_Ntk_t.
-rw-r--r-- | src/base/cba/cba.h | 6 | ||||
-rw-r--r-- | src/base/cba/cbaBlast.c | 55 | ||||
-rw-r--r-- | src/base/cba/cbaBuild.c | 4 | ||||
-rw-r--r-- | src/base/cba/cbaCom.c | 4 | ||||
-rw-r--r-- | src/base/cba/cbaSimple.c | 22 |
5 files changed, 59 insertions, 32 deletions
diff --git a/src/base/cba/cba.h b/src/base/cba/cba.h index 15e94461..70f479ab 100644 --- a/src/base/cba/cba.h +++ b/src/base/cba/cba.h @@ -308,9 +308,9 @@ static inline Cba_Man_t * Cba_ManAlloc( char * pFileName ) Cba_Man_t * p = ABC_CALLOC( Cba_Man_t, 1 ); p->pName = Extra_FileDesignName( pFileName ); p->pSpec = Abc_UtilStrsav( pFileName ); - p->pNames = Abc_NamStart( 1000, 20 ); - p->pModels = Abc_NamStart( 1000, 20 ); - p->pFuncs = Abc_NamStart( 1000, 20 ); + p->pNames = Abc_NamStart( 1000, 24 ); + p->pModels = Abc_NamStart( 1000, 24 ); + p->pFuncs = Abc_NamStart( 1000, 24 ); Vec_SetAlloc_( &p->Mem, 20 ); Vec_PtrPush( &p->vNtks, NULL ); p->iRoot = 1; diff --git a/src/base/cba/cbaBlast.c b/src/base/cba/cbaBlast.c index 26931e38..25476f43 100644 --- a/src/base/cba/cbaBlast.c +++ b/src/base/cba/cbaBlast.c @@ -42,36 +42,47 @@ ABC_NAMESPACE_IMPL_START SeeAlso [] ***********************************************************************/ -int Cba_ManAddBarbuf( Gia_Man_t * pNew, int iRes, Cba_Man_t * p, int iLNtk, int iLObj, int iRNtk, int iRObj ) +int Cba_ManAddBarbuf( Gia_Man_t * pNew, int iRes, Cba_Man_t * p, int iLNtk, int iLObj, int iRNtk, int iRObj, Vec_Int_t * vMap ) { -// if ( iRes == 0 || iRes == 1 ) -// return iRes; + int iBufLit, iIdLit; + if ( iRes == 0 || iRes == 1 ) + 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 ) + 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 ); - return Gia_ManAppendBuf( pNew, iRes ); + iBufLit = Gia_ManAppendBuf( pNew, iRes ); + if ( vMap ) + { + Vec_IntSetEntryFull( vMap, Abc_Lit2Var(iRes), Abc_Var2Lit(Vec_IntSize(pNew->vBarBufs), Abc_LitIsCompl(iRes)) ); + Vec_IntPush( pNew->vBarBufs, iBufLit ); + } + return iBufLit; } -int Cba_ManExtract_rec( Gia_Man_t * pNew, Cba_Ntk_t * p, int i ) +int Cba_ManExtract_rec( Gia_Man_t * pNew, Cba_Ntk_t * p, int i, Vec_Int_t * vMap ) { int iRes = Cba_NtkCopy( p, i ); if ( iRes >= 0 ) return iRes; if ( Cba_ObjIsCo(p, i) ) - iRes = Cba_ManExtract_rec( pNew, p, Cba_ObjFanin0(p, i) ); + iRes = Cba_ManExtract_rec( pNew, p, Cba_ObjFanin0(p, i), vMap ); else if ( Cba_ObjIsBo(p, i) ) { Cba_Ntk_t * pBox = Cba_ObjBoModel( p, i ); int iObj = Cba_NtkPo( pBox, Cba_ObjCioIndex(p, i) ); - iRes = Cba_ManExtract_rec( pNew, pBox, iObj ); - iRes = Cba_ManAddBarbuf( pNew, iRes, p->pDesign, Cba_NtkId(p), i, Cba_NtkId(pBox), iObj ); + iRes = Cba_ManExtract_rec( pNew, pBox, iObj, vMap ); + iRes = Cba_ManAddBarbuf( pNew, iRes, p->pDesign, Cba_NtkId(p), i, Cba_NtkId(pBox), iObj, vMap ); } else if ( Cba_ObjIsPi(p, i) ) { Cba_Ntk_t * pHost = Cba_NtkHostNtk( p ); int iObj = Cba_ObjBoxBi( pHost, Cba_NtkHostObj(p), Cba_ObjCioIndex(p, i) ); - iRes = Cba_ManExtract_rec( pNew, pHost, iObj ); - iRes = Cba_ManAddBarbuf( pNew, iRes, p->pDesign, Cba_NtkId(p), i, Cba_NtkId(pHost), iObj ); + iRes = Cba_ManExtract_rec( pNew, pHost, iObj, vMap ); + iRes = Cba_ManAddBarbuf( pNew, iRes, p->pDesign, Cba_NtkId(p), i, Cba_NtkId(pHost), iObj, vMap ); } else if ( Cba_ObjIsNode(p, i) ) { @@ -89,15 +100,15 @@ int Cba_ManExtract_rec( Gia_Man_t * pNew, Cba_Ntk_t * p, int i ) else if ( pFanins[0] == 1 ) { if ( Type == CBA_NODE_BUF ) - iRes = Cba_ManExtract_rec( pNew, p, pFanins[1] ); + iRes = Cba_ManExtract_rec( pNew, p, pFanins[1], vMap ); else if ( Type == CBA_NODE_INV ) - iRes = Abc_LitNot( Cba_ManExtract_rec( pNew, p, pFanins[1] ) ); + iRes = Abc_LitNot( Cba_ManExtract_rec( pNew, p, pFanins[1], vMap ) ); else assert( 0 ); } else { for ( k = 0; k < pFanins[0]; k++ ) - pLits[k] = Cba_ManExtract_rec( pNew, p, pFanins[k+1] ); + pLits[k] = Cba_ManExtract_rec( pNew, p, pFanins[k+1], vMap ); if ( Type == CBA_NODE_AND ) iRes = Gia_ManHashAnd( pNew, pLits[0], pLits[1] ); else if ( Type == CBA_NODE_OR ) @@ -117,6 +128,7 @@ Gia_Man_t * Cba_ManExtract( Cba_Man_t * p, int fVerbose ) { Cba_Ntk_t * pRoot = Cba_ManRoot(p); Gia_Man_t * pNew, * pTemp; + Vec_Int_t * vMap = NULL; int i, iObj; Vec_IntFreeP( &p->vBuf2LeafNtk ); Vec_IntFreeP( &p->vBuf2LeafObj ); @@ -132,12 +144,21 @@ Gia_Man_t * Cba_ManExtract( Cba_Man_t * p, int fVerbose ) pNew->pName = Abc_UtilStrsav(p->pName); pNew->pSpec = Abc_UtilStrsav(p->pSpec); Vec_IntFill( &p->vCopies, Cba_ManObjNum(p), -1 ); + + // primary inputs Cba_NtkForEachPi( pRoot, iObj, i ) Cba_NtkSetCopy( pRoot, iObj, Gia_ManAppendCi(pNew) ); + + // internal nodes Gia_ManHashAlloc( pNew ); + pNew->vBarBufs = Vec_IntAlloc( 10000 ); + vMap = Vec_IntStartFull( 10000 ); Cba_NtkForEachPo( pRoot, iObj, i ) - Cba_ManExtract_rec( pNew, pRoot, iObj ); + Cba_ManExtract_rec( pNew, pRoot, iObj, vMap ); + Vec_IntFreeP( &vMap ); Gia_ManHashStop( pNew ); + + // primary outputs Cba_NtkForEachPo( pRoot, iObj, i ) Gia_ManAppendCo( pNew, Cba_NtkCopy(pRoot, iObj) ); assert( Vec_IntSize(p->vBuf2LeafNtk) == pNew->nBufs ); @@ -146,9 +167,6 @@ Gia_Man_t * Cba_ManExtract( Cba_Man_t * p, int fVerbose ) pNew = Gia_ManCleanup( pTemp = pNew ); Gia_ManStop( pTemp ); Gia_ManPrintStats( pNew, NULL ); -// pNew = Gia_ManSweepHierarchy( pTemp = pNew ); -// Gia_ManStop( pTemp ); -// Gia_ManPrintStats( pNew, NULL ); return pNew; } @@ -302,7 +320,8 @@ void Cba_NtkInsertGia( Cba_Man_t * p, Gia_Man_t * pGia ) // create node and connect POs Gia_ManForEachPo( pGia, pObj, i ) Cba_NtkCreateAndConnectBuffer( pGia, pObj, pRoot, Cba_NtkPo(pRoot, i) ); - assert( Cba_NtkObjNum(pRoot) == pRoot->nObjs ); + Cba_ManForEachNtk( p, pNtk, i ) + assert( Cba_NtkObjNum(pNtk) == pNtk->nObjs ); } Cba_Man_t * Cba_ManInsertGia( Cba_Man_t * p, Gia_Man_t * pGia ) { diff --git a/src/base/cba/cbaBuild.c b/src/base/cba/cbaBuild.c index b4f95f23..b353e8f6 100644 --- a/src/base/cba/cbaBuild.c +++ b/src/base/cba/cbaBuild.c @@ -47,8 +47,6 @@ void Cba_BoxRemap( Cba_Ntk_t * pNtk, int iBox, Vec_Int_t * vMap ) Cba_Ntk_t * pBoxModel = Cba_ObjBoxModel( pNtk, iBox ); Vec_Int_t * vFanins = Cba_ObjFaninVec( pNtk, iBox ); int i, NameId; - Vec_IntForEachEntry( vMap, NameId, i ) - assert( NameId == -1 ); // map formal names into I/O indexes Cba_NtkForEachPi( pBoxModel, NameId, i ) { @@ -79,6 +77,8 @@ void Cba_NtkRemapBoxes( Cba_Ntk_t * pNtk, Vec_Int_t * vMap ) Cba_NtkForEachObjType( pNtk, Type, iBox ) if ( Type == CBA_OBJ_BOX ) Cba_BoxRemap( pNtk, iBox, vMap ); + Vec_IntForEachEntry( vMap, Type, iBox ) + assert( Type == -1 ); } // create maps of NameId and boxes void Cba_NtkFindNonDriven( Cba_Ntk_t * pNtk, Vec_Int_t * vMap, int nObjCount, Vec_Int_t * vNonDriven ) diff --git a/src/base/cba/cbaCom.c b/src/base/cba/cbaCom.c index 5f000cb0..94eb4b88 100644 --- a/src/base/cba/cbaCom.c +++ b/src/base/cba/cbaCom.c @@ -317,7 +317,9 @@ int Cba_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) extern void Cba_ManReadDesExperiment( Abc_Ntk_t * pNtk ); Abc_Ntk_t * pAbcNtk; //Cba_Ntk_t * pNtk = Cba_AbcGetNtk(pAbc); - char * pFileName = "c/hie/dump/1/netlist_1.v"; +// char * pFileName = "c/hie/dump/1/netlist_1.v"; +// char * pFileName = "c/hie/dump/3/netlist_18.v"; + char * pFileName = "c/hie/dump/1/netlist_0.v"; int c, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) diff --git a/src/base/cba/cbaSimple.c b/src/base/cba/cbaSimple.c index 8b4c336f..7d363be9 100644 --- a/src/base/cba/cbaSimple.c +++ b/src/base/cba/cbaSimple.c @@ -601,7 +601,7 @@ void Cba_PrsReadBoxes( Cba_Man_t * p, Vec_Ptr_t * vBoxes, Vec_Int_t * vTypesCur, Vec_IntPush( vFaninsCur, Cba_ManHandleArray(p, Cba_PrsReadList(p, vBox, vList, 0, 1)) ); } } -void Cba_PrsReadModule( Cba_Man_t * p, Vec_Ptr_t * vNtk ) +void Cba_PrsReadModule( Cba_Man_t * p, Cba_Ntk_t * pNtk, Vec_Ptr_t * vNtk ) { Vec_Int_t * vInputsCur = Vec_IntAlloc( 1000 ); Vec_Int_t * vOutputsCur = Vec_IntAlloc( 1000 ); @@ -612,7 +612,6 @@ void Cba_PrsReadModule( Cba_Man_t * p, Vec_Ptr_t * vNtk ) Vec_Int_t * vList = Vec_IntAlloc( 1000 ); Vec_Int_t * vBoxes = Vec_IntStart( Vec_PtrSize((Vec_Ptr_t *)Vec_PtrEntry(vNtk, 4)) ); - Cba_Ntk_t * pNtk = Cba_NtkAlloc( p, (char *)Vec_PtrEntry(vNtk, 0) ); Cba_PrsReadList( p, (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 1), vInputsCur, -1, -1 ); Cba_PrsReadList( p, (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 2), vOutputsCur, -1, -1 ); Cba_PrsReadNodes( p, (Vec_Ptr_t *)Vec_PtrEntry(vNtk, 3), vTypesCur, vFuncsCur, vInstIdsCur, vFaninsCur, vList ); @@ -640,7 +639,9 @@ Cba_Man_t * Cba_PrsReadPtr( Vec_Ptr_t * vDes ) Vec_Ptr_t * vNtk; int i; Cba_Man_t * p = Cba_ManAlloc( (char *)Vec_PtrEntry(vDes, 0) ); Vec_PtrForEachEntryStart( Vec_Ptr_t *, vDes, vNtk, i, 1 ) - Cba_PrsReadModule( p, vNtk ); + Cba_NtkAlloc( p, (char *)Vec_PtrEntry(vNtk, 0) ); + Vec_PtrForEachEntryStart( Vec_Ptr_t *, vDes, vNtk, i, 1 ) + Cba_PrsReadModule( p, Cba_ManNtk(p, i), vNtk ); return p; } @@ -669,37 +670,41 @@ void Cba_ManReadDesExperiment( Abc_Ntk_t * pNtk ) Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); // dump pFileName = Extra_FileNameGenericAppend(pNtk->pDesign->pName, "_out1.blif"); - Ptr_ManDumpBlif( pFileName, vDes ); +// Ptr_ManDumpBlif( pFileName, vDes ); printf( "Finished writing output file \"%s\". ", pFileName ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); + clk = Abc_Clock(); // derive CBA from Ptr p = Cba_PrsReadPtr( vDes ); Ptr_ManFreeDes( vDes ); // dump pFileName = Extra_FileNameGenericAppend(pNtk->pDesign->pName, "_out2.blif"); - Cba_PrsWriteBlif( pFileName, p ); +// Cba_PrsWriteBlif( pFileName, p ); printf( "Finished writing output file \"%s\". ", pFileName ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); // Abc_NamPrint( p->pNames ); + clk = Abc_Clock(); // build CBA from CBA p = Cba_ManBuild( pTemp = p ); Cba_ManFree( pTemp ); // dump pFileName = Extra_FileNameGenericAppend(pNtk->pDesign->pName, "_out3.blif"); - Cba_ManWriteBlif( pFileName, p ); +// Cba_ManWriteBlif( pFileName, p ); printf( "Finished writing output file \"%s\". ", pFileName ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); - + clk = Abc_Clock(); + // duplicate CBA p = Cba_ManDup( pTemp = p ); Cba_ManFree( pTemp ); // dump pFileName = Extra_FileNameGenericAppend(pNtk->pDesign->pName, "_out4.blif"); - Cba_ManWriteBlif( pFileName, p ); +// Cba_ManWriteBlif( pFileName, p ); printf( "Finished writing output file \"%s\". ", pFileName ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); + clk = Abc_Clock(); // CBA->GIA->CBA p = Cba_ManBlastTest( pTemp = p ); @@ -709,6 +714,7 @@ void Cba_ManReadDesExperiment( Abc_Ntk_t * pNtk ) Cba_ManWriteBlif( pFileName, p ); printf( "Finished writing output file \"%s\". ", pFileName ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); + clk = Abc_Clock(); Cba_ManFree( p ); } |