mirror of https://github.com/YosysHQ/abc.git
Experiments with simulation.
This commit is contained in:
parent
f9309ce949
commit
5a1184460b
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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" );
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
@ -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 ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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 )
|
||||
|
|
|
|||
Loading…
Reference in New Issue