diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2018-12-09 15:18:12 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2018-12-09 15:18:12 -0800 |
commit | 36585eff57d16171bb4a53fdc6348613d44eabe6 (patch) | |
tree | 4c0368dc4b7022f5aa80282d3301b784465adbdb /src/base/wlc | |
parent | fe03f0423de9718b122d6200042ecb553520fb0f (diff) | |
download | abc-36585eff57d16171bb4a53fdc6348613d44eabe6.tar.gz abc-36585eff57d16171bb4a53fdc6348613d44eabe6.tar.bz2 abc-36585eff57d16171bb4a53fdc6348613d44eabe6.zip |
Experiments with retiming (adding new APIs).
Diffstat (limited to 'src/base/wlc')
-rw-r--r-- | src/base/wlc/wlc.h | 1 | ||||
-rw-r--r-- | src/base/wlc/wlcCom.c | 22 | ||||
-rw-r--r-- | src/base/wlc/wlcNdr.c | 3 | ||||
-rw-r--r-- | src/base/wlc/wlcNtk.c | 19 | ||||
-rw-r--r-- | src/base/wlc/wlcReadVer.c | 4 | ||||
-rw-r--r-- | src/base/wlc/wlcShow.c | 26 |
6 files changed, 61 insertions, 14 deletions
diff --git a/src/base/wlc/wlc.h b/src/base/wlc/wlc.h index 3a84031e..6547da13 100644 --- a/src/base/wlc/wlc.h +++ b/src/base/wlc/wlc.h @@ -282,6 +282,7 @@ static inline int Wlc_ObjIsPi( Wlc_Obj_t * p ) static inline int Wlc_ObjIsPo( Wlc_Obj_t * p ) { return p->fIsPo; } static inline int Wlc_ObjIsCi( Wlc_Obj_t * p ) { return p->Type == WLC_OBJ_PI || p->Type == WLC_OBJ_FO; } static inline int Wlc_ObjIsCo( Wlc_Obj_t * p ) { return p->fIsPo || p->fIsFi; } +static inline int Wlc_ObjIsFf( Wlc_Ntk_t * p, int i ) { return Wlc_NtkObj(p, i)->Type == WLC_OBJ_FF; } static inline int Wlc_ObjId( Wlc_Ntk_t * p, Wlc_Obj_t * pObj ) { return pObj - p->pObjs; } static inline int Wlc_ObjCiId( Wlc_Obj_t * p ) { assert( Wlc_ObjIsCi(p) ); return p->Fanins[1]; } diff --git a/src/base/wlc/wlcCom.c b/src/base/wlc/wlcCom.c index 6df2c840..90ad0671 100644 --- a/src/base/wlc/wlcCom.c +++ b/src/base/wlc/wlcCom.c @@ -19,6 +19,7 @@ ***********************************************************************/ #include "wlc.h" +#include "base/wln/wln.h" #include "base/main/mainInt.h" #include "aig/miniaig/ndr.h" @@ -1250,7 +1251,7 @@ usage: ******************************************************************************/ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern void Wln_NtkRetimeTest( char * pFileName ); + extern void Wln_NtkRetimeTest( char * pFileName, int fVerbose ); FILE * pFile; char * pFileName = NULL; int c, fVerbose = 0; @@ -1268,6 +1269,23 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv ) goto usage; } } + if ( pAbc->pNdr ) + { + Vec_Int_t * vMoves; + Wln_Ntk_t * pNtk = Wln_NtkFromNdr( pAbc->pNdr ); + Wln_NtkRetimeCreateDelayInfo( pNtk ); + if ( pNtk == NULL ) + { + printf( "Transforming NDR into internal represnetation has failed.\n" ); + return 0; + } + vMoves = Wln_NtkRetime( pNtk, fVerbose ); + Wln_NtkFree( pNtk ); + ABC_FREE( pAbc->pNdrArray ); + if ( vMoves ) pAbc->pNdrArray = Vec_IntReleaseNewArray( vMoves ); + Vec_IntFreeP( &vMoves ); + return 0; + } if ( argc != globalUtilOptind + 1 ) { printf( "Abc_CommandRetime(): Input file name should be given on the command line.\n" ); @@ -1284,7 +1302,7 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; } fclose( pFile ); - Wln_NtkRetimeTest( pFileName ); + Wln_NtkRetimeTest( pFileName, fVerbose ); return 0; usage: Abc_Print( -2, "usage: %%retime [-vh]\n" ); diff --git a/src/base/wlc/wlcNdr.c b/src/base/wlc/wlcNdr.c index 16c7d778..7591aaf3 100644 --- a/src/base/wlc/wlcNdr.c +++ b/src/base/wlc/wlcNdr.c @@ -499,7 +499,8 @@ Wlc_Ntk_t * Wlc_ReadNdr( char * pFileName ) Wlc_Ntk_t * pNtk = Wlc_NtkFromNdr( pData ); //char * ppNames[10] = { NULL, "a", "b", "c", "d", "e", "f", "g", "h", "i" }; //Ndr_WriteVerilog( NULL, pData, ppNames ); - Ndr_Delete( pData ); + //Ndr_Delete( pData ); + Abc_FrameInputNdr( Abc_FrameGetGlobalFrame(), pData ); return pNtk; } void Wlc_ReadNdrTest() diff --git a/src/base/wlc/wlcNtk.c b/src/base/wlc/wlcNtk.c index f64fccaf..8038d9e6 100644 --- a/src/base/wlc/wlcNtk.c +++ b/src/base/wlc/wlcNtk.c @@ -357,8 +357,8 @@ int Wlc_NtkCreateLevelsRev( Wlc_Ntk_t * p ) ***********************************************************************/ void Wlc_NtkCreateLevels_rec( Wlc_Ntk_t * p, Wlc_Obj_t * pObj ) { - int k, iFanin, Level = 0; - if ( Vec_IntEntry(&p->vLevels, Wlc_ObjId(p, pObj)) > 0 ) + int k, iFanin, Level = 0, iObj = Wlc_ObjId(p, pObj); + if ( Wlc_ObjIsCi(pObj) || Wlc_ObjIsFf(p, iObj) || Wlc_ObjFaninNum(pObj) == 0 || Wlc_ObjLevel(p, pObj) > 0 ) return; Wlc_ObjForEachFanin( pObj, iFanin, k ) if ( iFanin ) Wlc_NtkCreateLevels_rec( p, Wlc_NtkObj(p, iFanin) ); @@ -368,11 +368,18 @@ void Wlc_NtkCreateLevels_rec( Wlc_Ntk_t * p, Wlc_Obj_t * pObj ) } int Wlc_NtkCreateLevels( Wlc_Ntk_t * p ) { - Wlc_Obj_t * pObj; int i; + Wlc_Obj_t * pObj; int i, LeveMax = 0; Vec_IntFill( &p->vLevels, Wlc_NtkObjNumMax(p), 0 ); - Wlc_NtkForEachCo( p, pObj, i ) + Wlc_NtkForEachObj( p, pObj, i ) Wlc_NtkCreateLevels_rec( p, pObj ); - return Vec_IntFindMax( &p->vLevels ); + Wlc_NtkForEachObj( p, pObj, i ) + if ( !Wlc_ObjIsCi(pObj) && Wlc_ObjFaninNum(pObj) ) + Vec_IntAddToEntry( &p->vLevels, i, 1 ); + LeveMax = Vec_IntFindMax( &p->vLevels ); + Wlc_NtkForEachFf2( p, pObj, i ) + Vec_IntWriteEntry( &p->vLevels, Wlc_ObjId(p, pObj), LeveMax+1 ); + Wlc_NtkPrintObjects( p ); + return LeveMax+1; } /**Function************************************************************* @@ -662,6 +669,8 @@ void Wlc_NtkPrintDistrib( Wlc_Ntk_t * p, int fTwoSides, int fVerbose ) void Wlc_NtkPrintNode( Wlc_Ntk_t * p, Wlc_Obj_t * pObj ) { printf( "%8d : ", Wlc_ObjId(p, pObj) ); + if ( Vec_IntSize(&p->vLevels) ) + printf( "Lev = %2d ", Vec_IntEntry(&p->vLevels, Wlc_ObjId(p,pObj)) ); printf( "%6d%s = ", Wlc_ObjRange(pObj), Wlc_ObjIsSigned(pObj) ? "s" : " " ); if ( pObj->Type == WLC_OBJ_PI ) { diff --git a/src/base/wlc/wlcReadVer.c b/src/base/wlc/wlcReadVer.c index d8187bd4..e2b61c6f 100644 --- a/src/base/wlc/wlcReadVer.c +++ b/src/base/wlc/wlcReadVer.c @@ -1284,7 +1284,7 @@ startword: else if ( Wlc_PrsStrCmp( pStart, "ABC_DFFRSE" ) ) { int NameId[10] = {0}, fFound, fFlopIn, fFlopClk, fFlopRst, fFlopSet, fFlopEna, fFlopAsync, fFlopSre, fFlopInit, fFlopOut; - pStart += strlen("ABC_DFF"); + pStart += strlen("ABC_DFFRSE"); while ( 1 ) { pStart = Wlc_PrsFindSymbol( pStart, '.' ); @@ -1348,7 +1348,7 @@ startword: else if ( Wlc_PrsStrCmp( pStart, "ABC_DFF" ) ) { int NameId = -1, NameIdIn = -1, NameIdOut = -1, fFound, nBits = 1, fFlopIn, fFlopOut; - pStart += strlen("ABC_DFFRSE"); + pStart += strlen("ABC_DFF"); while ( 1 ) { pStart = Wlc_PrsFindSymbol( pStart, '.' ); diff --git a/src/base/wlc/wlcShow.c b/src/base/wlc/wlcShow.c index b78437e8..50da3e5b 100644 --- a/src/base/wlc/wlcShow.c +++ b/src/base/wlc/wlcShow.c @@ -237,13 +237,31 @@ void Wlc_NtkDumpDot( Wlc_Ntk_t * p, char * pFileName, Vec_Int_t * vBold ) // the labeling node of this level fprintf( pFile, " Level%d;\n", 0 ); // generate the CI nodes - Wlc_NtkForEachCi( p, pNode, i ) + Wlc_NtkForEachObj( p, pNode, i ) { + if ( !Wlc_ObjIsCi(pNode) && Wlc_ObjFaninNum(pNode) > 0 ) + continue; if ( vBold && !pNode->Mark ) continue; - fprintf( pFile, " Node%d [label = \"%d:%s %d\"", Wlc_ObjId(p, pNode), Wlc_ObjId(p, pNode), Wlc_ObjName(p, Wlc_ObjId(p, pNode)), Wlc_ObjRange(pNode) ); - fprintf( pFile, ", shape = %s", i < Wlc_NtkPiNum(p) ? "triangle" : "box" ); - fprintf( pFile, ", color = coral, fillcolor = coral" ); + if ( pNode->Type == WLC_OBJ_CONST ) + { + //char * pName = Wlc_ObjName(p, i); + fprintf( pFile, " Node%d [label = \"%d:%d\'h", i, i, Wlc_ObjRange(pNode) ); + if ( Wlc_ObjRange(pNode) > 64 ) + { + Abc_TtPrintHexArrayRev( pFile, (word *)Wlc_ObjConstValue(pNode), 16 ); + fprintf( pFile, "..." ); + } + else + Abc_TtPrintHexArrayRev( pFile, (word *)Wlc_ObjConstValue(pNode), (Wlc_ObjRange(pNode) + 3) / 4 ); + fprintf( pFile, "\"" ); + } + else + { + fprintf( pFile, " Node%d [label = \"%d:%s %d\"", Wlc_ObjId(p, pNode), Wlc_ObjId(p, pNode), Wlc_ObjName(p, Wlc_ObjId(p, pNode)), Wlc_ObjRange(pNode) ); + fprintf( pFile, ", shape = %s", (Vec_IntSize(&p->vFfs2) > 0 || i < Wlc_NtkPiNum(p)) ? "triangle" : "box" ); + fprintf( pFile, ", color = coral, fillcolor = coral" ); + } fprintf( pFile, "];\n" ); } fprintf( pFile, "}" ); |