From 00242f2fb229ac13b61e2e280d44603d5191d235 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 4 Jun 2016 17:31:15 -0700 Subject: New profiling features for word-level optimizations. --- src/base/wlc/wlc.h | 2 +- src/base/wlc/wlcBlast.c | 115 +++++++++++++++++++++++++++++++--------------- src/base/wlc/wlcCom.c | 12 +++-- src/base/wlc/wlcReadVer.c | 2 +- src/base/wlc/wlcSim.c | 2 +- 5 files changed, 90 insertions(+), 43 deletions(-) (limited to 'src/base/wlc') diff --git a/src/base/wlc/wlc.h b/src/base/wlc/wlc.h index 0165a0a4..7fe091d9 100644 --- a/src/base/wlc/wlc.h +++ b/src/base/wlc/wlc.h @@ -257,7 +257,7 @@ extern Vec_Int_t * Wlc_NtkFindUifableMultiplierPairs( Wlc_Ntk_t * p ); extern Wlc_Ntk_t * Wlc_NtkAbstractNodes( Wlc_Ntk_t * pNtk, Vec_Int_t * vNodes ); extern Wlc_Ntk_t * Wlc_NtkUifNodePairs( Wlc_Ntk_t * pNtk, Vec_Int_t * vPairs ); /*=== wlcBlast.c ========================================================*/ -extern Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds, int fGiaSimple ); +extern Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds, int fGiaSimple, int fAddOutputs ); /*=== wlcCom.c ========================================================*/ extern void Wlc_SetNtk( Abc_Frame_t * pAbc, Wlc_Ntk_t * pNtk ); /*=== wlcNtk.c ========================================================*/ diff --git a/src/base/wlc/wlcBlast.c b/src/base/wlc/wlcBlast.c index 826dbfa1..727e3d26 100644 --- a/src/base/wlc/wlcBlast.c +++ b/src/base/wlc/wlcBlast.c @@ -716,14 +716,14 @@ void Wlc_BlastSquare( Gia_Man_t * pNew, int * pNum, int nNum, Vec_Int_t * vTmp, SeeAlso [] ***********************************************************************/ -Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds, int fGiaSimple ) +Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds, int fGiaSimple, int fAddOutputs ) { int fVerbose = 0; int fUseOldMultiplierBlasting = 0; Tim_Man_t * pManTime = NULL; Gia_Man_t * pTemp, * pNew, * pExtra = NULL; Wlc_Obj_t * pObj; - Vec_Int_t * vBits = &p->vBits, * vTemp0, * vTemp1, * vTemp2, * vRes; + Vec_Int_t * vBits = &p->vBits, * vTemp0, * vTemp1, * vTemp2, * vRes, * vAddOutputs = NULL, * vAddObjs = NULL; int nBits = Wlc_NtkPrepareBits( p ); int nRange, nRange0, nRange1, nRange2; int i, k, b, iFanin, iLit, nAndPrev, * pFans0, * pFans1, * pFans2; @@ -743,6 +743,10 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds, int fGiaSimple pNew->fGiaSimple = fGiaSimple; if ( !fGiaSimple ) Gia_ManHashAlloc( pNew ); + if ( fAddOutputs ) + vAddOutputs = Vec_IntAlloc( 100 ); + if ( fAddOutputs ) + vAddObjs = Vec_IntAlloc( 100 ); // prepare for AIG with boxes if ( vBoxIds ) { @@ -1183,6 +1187,17 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds, int fGiaSimple else assert( 0 ); assert( Vec_IntSize(vBits) == Wlc_ObjCopy(p, i) ); Vec_IntAppend( vBits, vRes ); + if ( vAddOutputs && !Wlc_ObjIsCo(pObj) && + ( + (pObj->Type >= WLC_OBJ_MUX && pObj->Type <= WLC_OBJ_ROTATE_L) || + (pObj->Type >= WLC_OBJ_COMP_EQU && pObj->Type <= WLC_OBJ_COMP_MOREEQU) || + (pObj->Type >= WLC_OBJ_ARI_ADD && pObj->Type <= WLC_OBJ_ARI_SQUARE) + ) + ) + { + Vec_IntAppend( vAddOutputs, vRes ); + Vec_IntPush( vAddObjs, Wlc_ObjId(p, pObj) ); + } p->nAnds[pObj->Type] += Gia_ManAndNum(pNew) - nAndPrev; } p->nAnds[0] = Gia_ManAndNum(pNew); @@ -1194,6 +1209,14 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds, int fGiaSimple // create COs Wlc_NtkForEachCo( p, pObj, i ) { + // create additional PO literals + if ( vAddOutputs && pObj->fIsFi ) + { + Vec_IntForEachEntry( vAddOutputs, iLit, k ) + Gia_ManAppendCo( pNew, iLit ); + printf( "Created %d additional POs for %d interesting internal word-level variables.\n", Vec_IntSize(vAddOutputs), Vec_IntSize(vAddObjs) ); + Vec_IntFreeP( &vAddOutputs ); + } nRange = Wlc_ObjRange( pObj ); pFans0 = Vec_IntEntryP( vBits, Wlc_ObjCopy(p, Wlc_ObjId(p, pObj)) ); if ( fVerbose ) @@ -1307,42 +1330,62 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds, int fGiaSimple Vec_PtrPush( pNew->vNamesIn, Abc_UtilStrsav("abc_reset_flop") ); assert( Vec_PtrSize(pNew->vNamesIn) == Gia_ManCiNum(pNew) ); // create output names -/* - pNew->vNamesOut = Vec_PtrAlloc( Gia_ManCoNum(pNew) ); - Wlc_NtkForEachCo( p, pObj, i ) - if ( Wlc_ObjIsPo(pObj) ) + if ( vAddObjs ) { - char * pName = Wlc_ObjName(p, Wlc_ObjId(p, pObj)); - nRange = Wlc_ObjRange( pObj ); - if ( nRange == 1 ) - Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(pName) ); - else - for ( k = 0; k < nRange; k++ ) - { - char Buffer[1000]; - sprintf( Buffer, "%s[%d]", pName, k ); - Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(Buffer) ); - } - } - if ( fAdded ) - Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav("abc_reset_flop_in") ); - Wlc_NtkForEachCo( p, pObj, i ) - if ( !Wlc_ObjIsPo(pObj) ) - { - char * pName = Wlc_ObjName(p, Wlc_ObjId(p, pObj)); - nRange = Wlc_ObjRange( pObj ); - if ( nRange == 1 ) - Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(pName) ); - else - for ( k = 0; k < nRange; k++ ) - { - char Buffer[1000]; - sprintf( Buffer, "%s[%d]", pName, k ); - Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(Buffer) ); - } + // add real primary outputs + pNew->vNamesOut = Vec_PtrAlloc( Gia_ManCoNum(pNew) ); + Wlc_NtkForEachCo( p, pObj, i ) + if ( Wlc_ObjIsPo(pObj) ) + { + char * pName = Wlc_ObjName(p, Wlc_ObjId(p, pObj)); + nRange = Wlc_ObjRange( pObj ); + if ( nRange == 1 ) + Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(pName) ); + else + for ( k = 0; k < nRange; k++ ) + { + char Buffer[1000]; + sprintf( Buffer, "%s[%d]", pName, k ); + Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(Buffer) ); + } + } + // add internal primary outputs + Wlc_NtkForEachObjVec( vAddObjs, p, pObj, i ) + { + char * pName = Wlc_ObjName(p, Wlc_ObjId(p, pObj)); + nRange = Wlc_ObjRange( pObj ); + if ( nRange == 1 ) + Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(pName) ); + else + for ( k = 0; k < nRange; k++ ) + { + char Buffer[1000]; + sprintf( Buffer, "%s[%d]", pName, k ); + Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(Buffer) ); + } + } + Vec_IntFreeP( &vAddObjs ); + // add flop outputs + if ( fAdded ) + Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav("abc_reset_flop_in") ); + Wlc_NtkForEachCo( p, pObj, i ) + if ( !Wlc_ObjIsPo(pObj) ) + { + char * pName = Wlc_ObjName(p, Wlc_ObjId(p, pObj)); + nRange = Wlc_ObjRange( pObj ); + if ( nRange == 1 ) + Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(pName) ); + else + for ( k = 0; k < nRange; k++ ) + { + char Buffer[1000]; + sprintf( Buffer, "%s[%d]", pName, k ); + Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(Buffer) ); + } + } + assert( Vec_PtrSize(pNew->vNamesOut) == Gia_ManCoNum(pNew) ); } - assert( Vec_PtrSize(pNew->vNamesOut) == Gia_ManCoNum(pNew) ); -*/ + pNew->pSpec = Abc_UtilStrsav( p->pSpec ? p->pSpec : p->pName ); // dump the miter parts if ( 0 ) diff --git a/src/base/wlc/wlcCom.c b/src/base/wlc/wlcCom.c index 4bdb66c2..77bf36ba 100644 --- a/src/base/wlc/wlcCom.c +++ b/src/base/wlc/wlcCom.c @@ -338,15 +338,18 @@ int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv ) Wlc_Ntk_t * pNtk = Wlc_AbcGetNtk(pAbc); Vec_Int_t * vBoxIds = NULL; Gia_Man_t * pNew = NULL; - int c, fGiaSimple = 0, fMulti = 0, fVerbose = 0; + int c, fGiaSimple = 0, fAddOutputs = 0, fMulti = 0, fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "cmvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "comvh" ) ) != EOF ) { switch ( c ) { case 'c': fGiaSimple ^= 1; break; + case 'o': + fAddOutputs ^= 1; + break; case 'm': fMulti ^= 1; break; @@ -371,7 +374,7 @@ int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( 1, "Warning: There is no multipliers in the design.\n" ); } // transform - pNew = Wlc_NtkBitBlast( pNtk, vBoxIds, fGiaSimple ); + pNew = Wlc_NtkBitBlast( pNtk, vBoxIds, fGiaSimple, fAddOutputs ); Vec_IntFreeP( &vBoxIds ); if ( pNew == NULL ) { @@ -381,9 +384,10 @@ int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_FrameUpdateGia( pAbc, pNew ); return 0; usage: - Abc_Print( -2, "usage: %%blast [-cmvh]\n" ); + Abc_Print( -2, "usage: %%blast [-comvh]\n" ); Abc_Print( -2, "\t performs bit-blasting of the word-level design\n" ); Abc_Print( -2, "\t-c : toggle using AIG w/o const propagation and strashing [default = %s]\n", fGiaSimple? "yes": "no" ); + Abc_Print( -2, "\t-o : toggle using additional POs on the word-level boundaries [default = %s]\n", fAddOutputs? "yes": "no" ); Abc_Print( -2, "\t-m : toggle creating boxes for all multipliers in the design [default = %s]\n", fMulti? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); diff --git a/src/base/wlc/wlcReadVer.c b/src/base/wlc/wlcReadVer.c index 7753d24d..824cf80b 100644 --- a/src/base/wlc/wlcReadVer.c +++ b/src/base/wlc/wlcReadVer.c @@ -1291,7 +1291,7 @@ void Io_ReadWordTest( char * pFileName ) return; Wlc_WriteVer( pNtk, "test.v", 0, 0 ); - pNew = Wlc_NtkBitBlast( pNtk, NULL, 0 ); + pNew = Wlc_NtkBitBlast( pNtk, NULL, 0, 0 ); Gia_AigerWrite( pNew, "test.aig", 0, 0 ); Gia_ManStop( pNew ); diff --git a/src/base/wlc/wlcSim.c b/src/base/wlc/wlcSim.c index 6cd081a5..73d5307f 100644 --- a/src/base/wlc/wlcSim.c +++ b/src/base/wlc/wlcSim.c @@ -129,7 +129,7 @@ Vec_Ptr_t * Wlc_NtkSimulate( Wlc_Ntk_t * p, Vec_Int_t * vNodes, int nWords, int { Gia_Obj_t * pObj; Vec_Ptr_t * vOne, * vRes; - Gia_Man_t * pGia = Wlc_NtkBitBlast( p, NULL, 0 ); + Gia_Man_t * pGia = Wlc_NtkBitBlast( p, NULL, 0, 0 ); Wlc_Obj_t * pWlcObj; int f, i, k, w, nBits, Counter = 0; // allocate simulation info for one timeframe -- cgit v1.2.3