diff options
-rw-r--r-- | abclib.dsp | 4 | ||||
-rw-r--r-- | src/aig/gia/gia.h | 4 | ||||
-rw-r--r-- | src/aig/gia/giaMan.c | 48 | ||||
-rw-r--r-- | src/aig/gia/giaSim4.c | 54 | ||||
-rw-r--r-- | src/aig/gia/giaUtil.c | 52 | ||||
-rw-r--r-- | src/aig/gia/module.make | 1 | ||||
-rw-r--r-- | src/base/abci/abc.c | 50 |
7 files changed, 205 insertions, 8 deletions
@@ -5027,6 +5027,10 @@ SOURCE=.\src\aig\gia\giaSim2.c # End Source File # Begin Source File +SOURCE=.\src\aig\gia\giaSim4.c +# End Source File +# Begin Source File + SOURCE=.\src\aig\gia\giaSort.c # End Source File # Begin Source File diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h index 1160819e..9b5e5cdc 100644 --- a/src/aig/gia/gia.h +++ b/src/aig/gia/gia.h @@ -1474,7 +1474,7 @@ extern void Gia_ManPrintStatsMiter( Gia_Man_t * p, int fVerbose ) extern void Gia_ManSetRegNum( Gia_Man_t * p, int nRegs ); extern void Gia_ManReportImprovement( Gia_Man_t * p, Gia_Man_t * pNew ); extern void Gia_ManPrintNpnClasses( Gia_Man_t * p ); -extern void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName ); +extern void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName, Vec_Int_t * vObjs ); /*=== giaMem.c ===========================================================*/ extern Gia_MmFixed_t * Gia_MmFixedStart( int nEntrySize, int nEntriesMax ); extern void Gia_MmFixedStop( Gia_MmFixed_t * p, int fVerbose ); @@ -1695,6 +1695,8 @@ extern Vec_Int_t * Gia_ManSaveValue( Gia_Man_t * p ); extern void Gia_ManLoadValue( Gia_Man_t * p, Vec_Int_t * vValues ); extern Vec_Int_t * Gia_ManFirstFanouts( Gia_Man_t * p ); extern int Gia_ManCheckSuppOverlap( Gia_Man_t * p, int iNode1, int iNode2 ); +extern int Gia_ManCountPisWithFanout( Gia_Man_t * p ); +extern int Gia_ManCountPosWithNonZeroDrivers( Gia_Man_t * p ); /*=== giaCTas.c ===========================================================*/ typedef struct Tas_Man_t_ Tas_Man_t; diff --git a/src/aig/gia/giaMan.c b/src/aig/gia/giaMan.c index 4f0c4d0c..6831600a 100644 --- a/src/aig/gia/giaMan.c +++ b/src/aig/gia/giaMan.c @@ -1220,12 +1220,14 @@ void Gia_ManWriteNames( FILE * pFile, char c, int n, Vec_Ptr_t * vNames, int Sta fFirst = 0; } } -void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName ) +void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName, Vec_Int_t * vObjs ) { FILE * pFile; Gia_Obj_t * pObj; Vec_Bit_t * vInvs, * vUsed; - int i, nDigits, nDigits2; + int nDigits = Abc_Base10Log( Gia_ManObjNum(p) ); + int nDigits2 = Abc_Base10Log( Gia_ManPiNum(p) ); + int i, k, iObj; if ( Gia_ManRegNum(p) ) { printf( "Currently cannot write sequential AIG.\n" ); @@ -1241,9 +1243,15 @@ void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName ) vInvs = Gia_ManGenUsed( p, 0 ); vUsed = Gia_ManGenUsed( p, 1 ); - fprintf( pFile, "// This Verilog file is written by ABC on %s\n\n", Extra_TimeStamp() ); + //fprintf( pFile, "// This Verilog file is written by ABC on %s\n\n", Extra_TimeStamp() ); - fprintf( pFile, "module %s (\n ", p->pName ); + fprintf( pFile, "module " ); + for ( i = 0; i < (int)strlen(p->pName); i++ ) + if ( isalpha(p->pName[i]) || isdigit(p->pName[i]) ) + fprintf( pFile, "%c", p->pName[i] ); + else + fprintf( pFile, "_" ); + fprintf( pFile, " (\n ", p->pName ); Gia_ManWriteNames( pFile, 'x', Gia_ManPiNum(p), p->vNamesIn, 4, 4, NULL ); fprintf( pFile, ",\n " ); @@ -1272,9 +1280,21 @@ void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName ) fprintf( pFile, ";\n\n" ); } + if ( vObjs ) + { + fprintf( pFile, " wire " ); + Vec_IntForEachEntry( vObjs, iObj, i ) + fprintf( pFile, " t_%d%s", i, i==Vec_IntSize(vObjs)-1 ? "" : "," ); + fprintf( pFile, ";\n\n" ); + Vec_IntForEachEntry( vObjs, iObj, i ) + { + fprintf( pFile, " buf( %s,", Gia_ObjGetDumpName(NULL, 'n', iObj, nDigits) ); + fprintf( pFile, " t_%d );\n", i ); + } + fprintf( pFile, "\n" ); + } + // input inverters - nDigits = Abc_Base10Log( Gia_ManObjNum(p) ); - nDigits2 = Abc_Base10Log( Gia_ManPiNum(p) ); Gia_ManForEachPi( p, pObj, i ) { if ( Vec_BitEntry(vUsed, Gia_ObjId(p, pObj)) ) @@ -1293,6 +1313,15 @@ void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName ) fprintf( pFile, "\n" ); Gia_ManForEachAnd( p, pObj, i ) { + if ( vObjs ) + { + Vec_IntForEachEntry( vObjs, iObj, k ) + if ( iObj == i ) + break; + if ( k < Vec_IntSize(vObjs) ) + continue; + } + fprintf( pFile, " and( %s,", Gia_ObjGetDumpName(NULL, 'n', i, nDigits) ); fprintf( pFile, " %s,", Gia_ObjGetDumpName(NULL, (char)(Gia_ObjFaninC0(pObj)? 'i':'n'), Gia_ObjFaninId0(pObj, i), nDigits) ); fprintf( pFile, " %s );\n", Gia_ObjGetDumpName(NULL, (char)(Gia_ObjFaninC1(pObj)? 'i':'n'), Gia_ObjFaninId1(pObj, i), nDigits) ); @@ -1308,11 +1337,18 @@ void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName ) nDigits2 = Abc_Base10Log( Gia_ManPoNum(p) ); Gia_ManForEachPo( p, pObj, i ) { +/* fprintf( pFile, " assign %s = ", Gia_ObjGetDumpName(p->vNamesOut, 'z', i, nDigits2) ); if ( Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) ) fprintf( pFile, "1\'b%d;\n", Gia_ObjFaninC0(pObj) ); else fprintf( pFile, "%s;\n", Gia_ObjGetDumpName(NULL, (char)(Gia_ObjFaninC0(pObj)? 'i':'n'), Gia_ObjFaninId0p(p, pObj), nDigits) ); +*/ + fprintf( pFile, " buf( %s, ", Gia_ObjGetDumpName(p->vNamesOut, 'z', i, nDigits2) ); + if ( Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) ) + fprintf( pFile, "1\'b%d );\n", Gia_ObjFaninC0(pObj) ); + else + fprintf( pFile, "%s );\n", Gia_ObjGetDumpName(NULL, (char)(Gia_ObjFaninC0(pObj)? 'i':'n'), Gia_ObjFaninId0p(p, pObj), nDigits) ); } fprintf( pFile, "\nendmodule\n\n" ); diff --git a/src/aig/gia/giaSim4.c b/src/aig/gia/giaSim4.c new file mode 100644 index 00000000..ad0b7a21 --- /dev/null +++ b/src/aig/gia/giaSim4.c @@ -0,0 +1,54 @@ +/**CFile**************************************************************** + + FileName [giaSim4.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Simulation engine.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaSim4.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +ABC_NAMESPACE_IMPL_START + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_Sim4Try( char * pFileName0, char * pFileName1, int fVerbose ) +{ +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + +ABC_NAMESPACE_IMPL_END + diff --git a/src/aig/gia/giaUtil.c b/src/aig/gia/giaUtil.c index feac7d08..eadc2a86 100644 --- a/src/aig/gia/giaUtil.c +++ b/src/aig/gia/giaUtil.c @@ -2142,6 +2142,58 @@ int Gia_ManCheckSuppOverlap( Gia_Man_t * p, int iNode1, int iNode2 ) return Result; } + +/**Function************************************************************* + + Synopsis [Count PIs with fanout.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManCountPisWithFanout( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int i, Count = 0; + Gia_ManForEachCi( p, pObj, i ) + pObj->fMark0 = 0; + Gia_ManForEachAnd( p, pObj, i ) + { + Gia_ObjFanin0(pObj)->fMark0 = 1; + Gia_ObjFanin1(pObj)->fMark0 = 1; + } + Gia_ManForEachCo( p, pObj, i ) + Gia_ObjFanin0(pObj)->fMark0 = 1; + Gia_ManForEachCi( p, pObj, i ) + Count += pObj->fMark0; + Gia_ManForEachObj( p, pObj, i ) + pObj->fMark0 = 0; + return Count; +} + +/**Function************************************************************* + + Synopsis [Count POs driven by non-zero driver.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManCountPosWithNonZeroDrivers( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int i, Count = 0; + Gia_ManForEachCo( p, pObj, i ) + Count += Gia_ObjFaninLit0(pObj, Gia_ObjId(p, pObj)) != 0; + return Count; +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/gia/module.make b/src/aig/gia/module.make index 3fc41108..c6751a3c 100644 --- a/src/aig/gia/module.make +++ b/src/aig/gia/module.make @@ -73,6 +73,7 @@ SRC += src/aig/gia/giaAig.c \ src/aig/gia/giaShrink7.c \ src/aig/gia/giaSim.c \ src/aig/gia/giaSim2.c \ + src/aig/gia/giaSim4.c \ src/aig/gia/giaSort.c \ src/aig/gia/giaSpeedup.c \ src/aig/gia/giaSplit.c \ diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index ec234fae..8d8f1ba4 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -137,6 +137,7 @@ static int Abc_CommandTestNpn ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandTestRPO ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRunEco ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRunGen ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandRunSim ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRefactor ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -839,6 +840,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "LogiCS", "testrpo", Abc_CommandTestRPO, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "runeco", Abc_CommandRunEco, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "rungen", Abc_CommandRunGen, 0 ); + Cmd_CommandAdd( pAbc, "Synthesis", "runsim", Abc_CommandRunSim, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "rewrite", Abc_CommandRewrite, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "refactor", Abc_CommandRefactor, 1 ); @@ -7017,6 +7019,52 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Gia_Sim4Try( char * pFileName0, char * pFileName1, int fVerbose ); + int c, fVerbose = 1; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) + { + switch ( c ) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( argc - globalUtilOptind != 2 ) + { + Abc_Print( 1, "Expecting two file names on the command line.\n" ); + goto usage; + } + Gia_Sim4Try( argv[globalUtilOptind+0], argv[globalUtilOptind+1], fVerbose ); + return 0; + +usage: + Abc_Print( -2, "usage: runsim <file1> <file2> [-vh]\n" ); + Abc_Print( -2, "\t experimental command\n" ); + 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"); + return 1; +} + + /**Function************************************************************* @@ -30398,7 +30446,7 @@ int Abc_CommandAbc9Write( Abc_Frame_t * pAbc, int argc, char ** argv ) Gia_ManStop( pGia ); } else if ( fVerilog ) - Gia_ManDumpVerilog( pAbc->pGia, pFileName ); + Gia_ManDumpVerilog( pAbc->pGia, pFileName, NULL ); else if ( fMiniAig ) Gia_ManWriteMiniAig( pAbc->pGia, pFileName ); else if ( fMiniLut ) |