Commit 083c1218 authored by Alan Mishchenko's avatar Alan Mishchenko

Improving MFFC computation code.

parent fb769cf9
......@@ -41,7 +41,7 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
int Gia_Sim4Try( char * pFileName0, char * pFileName1, char * pFileName2, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fVerbose )
int Gia_Sim4Try( char * pFileName0, char * pFileName1, char * pFileName2, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fSkipMffc, int fVerbose )
{
return 0;
}
......
......@@ -7194,11 +7194,11 @@ usage:
***********************************************************************/
int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern void Acb_NtkRunSim( char * pFileName[4], int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fVerbose, int fVeryVerbose );
extern void Acb_NtkRunSim( char * pFileName[4], int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fSkipMffc, int fVerbose, int fVeryVerbose );
char * pFileNames[4] = {NULL, NULL, "out.v", NULL};
int c, nWords = 8, nBeam = 4, LevL = -1, LevU = -1, fOrder = 0, fFancy = 0, fUseBuf = 0, fRandom = 0, fUseWeights = 0, fInputs = 0, fVerbose = 0, fVeryVerbose = 0;
int c, nWords = 8, nBeam = 4, LevL = -1, LevU = -1, fOrder = 0, fFancy = 0, fUseBuf = 0, fRandom = 0, fUseWeights = 0, fInputs = 0, fSkipMffc = 0, fVerbose = 0, fVeryVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "WBLUofbruivwh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "WBLUofbruimvwh" ) ) != EOF )
{
switch ( c )
{
......@@ -7264,6 +7264,9 @@ int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'i':
fInputs ^= 1;
break;
case 'm':
fSkipMffc ^= 1;
break;
case 'v':
fVerbose ^= 1;
break;
......@@ -7295,11 +7298,11 @@ int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv )
else
fclose( pFile );
}
Acb_NtkRunSim( pFileNames, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fRandom, fUseWeights, fInputs, fVerbose, fVeryVerbose );
Acb_NtkRunSim( pFileNames, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fRandom, fUseWeights, fInputs, fSkipMffc, fVerbose, fVeryVerbose );
return 0;
usage:
Abc_Print( -2, "usage: runsim [-WBLU] [-ofbruivwh] [-N <num>] <file1> <file2> <file3>\n" );
Abc_Print( -2, "usage: runsim [-WBLU] [-ofbruimvwh] [-N <num>] <file1> <file2> <file3>\n" );
Abc_Print( -2, "\t experimental simulation command\n" );
Abc_Print( -2, "\t-W <num> : the number of words of simulation info [default = %d]\n", nWords );
Abc_Print( -2, "\t-B <num> : the beam width parameter [default = %d]\n", nBeam );
......@@ -7311,6 +7314,7 @@ usage:
Abc_Print( -2, "\t-r : toggle using random permutation of support variables [default = %s]\n", fRandom? "yes": "no" );
Abc_Print( -2, "\t-u : toggle using topological info to select support variables [default = %s]\n", fUseWeights? "yes": "no" );
Abc_Print( -2, "\t-i : toggle using primary inputs as support variables [default = %s]\n", fInputs? "yes": "no" );
Abc_Print( -2, "\t-m : toggle MFFC nodes as candidate divisors [default = %s]\n", fSkipMffc? "yes": "no" );
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-w : toggle printing more verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
......@@ -1942,44 +1942,17 @@ Vec_Int_t * Acb_GetUsedDivs( Vec_Int_t * vDivs, Vec_Int_t * vUsed )
Vec_IntPush( vRes, iObj );
return vRes;
}
Vec_Int_t * Acb_GetDerefedNodes( Acb_Ntk_t * p )
{
Vec_Ptr_t * vNames = Abc_FrameReadSignalNames();
if ( vNames != NULL )
{
Vec_Int_t * vNodes = Vec_IntAlloc( 100 );
Vec_Int_t * vMap = Vec_IntStartFull( Abc_NamObjNumMax(p->pDesign->pStrs) );
int i, iObj; char * pName;
Acb_NtkForEachObj( p, iObj )
if ( Acb_ObjName(p, iObj) )
Vec_IntWriteEntry( vMap, Acb_ObjName(p, iObj), iObj );
Vec_PtrForEachEntry( char *, vNames, pName, i )
{
int NameId = Abc_NamStrFindOrAdd( p->pDesign->pStrs, pName, NULL );
if ( NameId == 0 )
{
printf( "Cannot find name ID for name %s\n", pName );
Vec_IntFree( vMap );
Vec_IntFree( vNodes );
return NULL;
}
else if ( Vec_IntEntry(vMap, NameId) == -1 )
{
printf( "Cannot find obj ID for name %s\n", pName );
Vec_IntFree( vMap );
Vec_IntFree( vNodes );
return NULL;
}
else
Vec_IntPush( vNodes, Vec_IntEntry(vMap, NameId) );
}
Vec_IntFree( vMap );
return vNodes;
}
return NULL;
Vec_Ptr_t * Acb_SignalNames( Acb_Ntk_t * p, Vec_Int_t * vObjs )
{
Vec_Ptr_t * vNames = Vec_PtrAlloc( Vec_IntSize(vObjs) );
int i, iObj;
Vec_IntForEachEntry( vObjs, iObj, i )
Vec_PtrPush( vNames, Acb_ObjNameStr(p, iObj) );
return vNames;
}
Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUsed, Vec_Ptr_t * vSops, Vec_Ptr_t * vGias, Vec_Int_t * vTars )
{
extern int Acb_NtkCollectMfsGates( char * pFileName, Vec_Ptr_t * vNamesRefed, Vec_Ptr_t * vNamesDerefed, int nGates1[5] );
extern Vec_Wec_t * Abc_SopSynthesize( Vec_Ptr_t * vSops );
extern Vec_Wec_t * Abc_GiaSynthesize( Vec_Ptr_t * vGias, Gia_Man_t * pMulti );
Vec_Wec_t * vGates = vGias ? Abc_GiaSynthesize(vGias, NULL) : Abc_SopSynthesize(vSops); Vec_Int_t * vGate;
......@@ -1989,15 +1962,13 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs
Vec_Ptr_t * vNames = Acb_GenerateSignalNames( p, vDivs, vUsed, nWires, vTars, vGates );
Vec_Str_t * vStr = Vec_StrAlloc( 100 );
Vec_Int_t * vSup = Acb_GetUsedDivs( vDivs, vUsed );
Vec_Int_t * vDrf = Acb_GetDerefedNodes( p );
Vec_Ptr_t * vSpN = Acb_SignalNames( p, vSup );
Vec_Int_t * vTfi = Acb_ObjCollectTfiVec( p, vSup );
Vec_Int_t * vTfo = Acb_ObjCollectTfoVec( p, vTars );
int nPiCount = Acb_NtkCountPiBuffers( p, vSup );
int nPoCount = Acb_NtkCountPoDrivers( p, vTars );
int nMffc = vDrf ? Vec_IntSize(vTars) + Acb_NtkFindMffcSize( p, vSup, vDrf, nGates1 ) : 0;
int * pCounts = Abc_FrameReadGateCounts();
for ( i = 0; i < 5; i++ )
nGates1[i] += pCounts[i];
int nMffc = Abc_FrameReadSpecName() ? Acb_NtkCollectMfsGates( Abc_FrameReadSpecName(), vSpN, Abc_FrameReadSignalNames(), nGates1 ) : 0;
Vec_PtrFree( vSpN );
Vec_IntFree( vSup );
Vec_WecForEachLevelStartStop( vGates, vGate, i, Vec_IntSize(vUsed), Vec_IntSize(vUsed)+nWires )
{
......@@ -2017,9 +1988,9 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs
Vec_StrPrintF( vStr, "// Patch : in = %d out = %d : pi_in = %d po_out = %d : tfi = %d tfo = %d\n", Vec_IntSize(vUsed), nOuts, nPiCount, nPoCount, Vec_IntSize(vTfi), Vec_IntSize(vTfo) );
Vec_StrPrintF( vStr, "// Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires, nGates0[0], nGates0[1], nGates0[2], nGates0[3], nGates0[4] );
if ( vDrf != NULL )
if ( Abc_FrameReadSpecName() )
Vec_StrPrintF( vStr, "// Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nMffc, nGates1[0], nGates1[1], nGates1[2], nGates1[3], nGates1[4] );
if ( vDrf != NULL )
if ( Abc_FrameReadSpecName() )
Vec_StrPrintF( vStr, "// TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires-nMffc, nGates0[0]-nGates1[0], nGates0[1]-nGates1[1], nGates0[2]-nGates1[2], nGates0[3]-nGates1[3], nGates0[4]-nGates1[4] );
Vec_StrPrintF( vStr, "\n" );
......@@ -2084,12 +2055,11 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs
printf( "\n" );
printf( "Patch : in = %d out = %d : pi_in = %d po_out = %d : tfi = %d tfo = %d\n", Vec_IntSize(vUsed), nOuts, nPiCount, nPoCount, Vec_IntSize(vTfi), Vec_IntSize(vTfo) );
printf( "Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires, nGates0[0], nGates0[1], nGates0[2], nGates0[3], nGates0[4] );
if ( vDrf != NULL )
if ( Abc_FrameReadSpecName() )
printf( "Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nMffc, nGates1[0], nGates1[1], nGates1[2], nGates1[3], nGates1[4] );
if ( vDrf != NULL )
if ( Abc_FrameReadSpecName() )
printf( "TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires-nMffc, nGates0[0]-nGates1[0], nGates0[1]-nGates1[1], nGates0[2]-nGates1[2], nGates0[3]-nGates1[3], nGates0[4]-nGates1[4] );
printf( "\n" );
Vec_IntFreeP( &vDrf );
return vStr;
}
......@@ -2209,11 +2179,11 @@ Vec_Str_t * Acb_GeneratePatch2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t *
printf( "Synthesized patch with %d inputs, %d outputs and %d gates.\n", nIns, nOuts, nWires );
return vStr;
}
void Acb_GenerateFile2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * vOuts, char * pFileName, char * pFileNameOut )
void Acb_GenerateFile2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * vOuts, char * pFileName, char * pFileNameOut, int fSkipMffc )
{
extern void Acb_GenerateFilePatch( Vec_Str_t * p, char * pFileNamePatch );
extern void Acb_GenerateFileOut( Vec_Str_t * vPatchLine, char * pFileNameF, char * pFileNameOut, Vec_Str_t * vPatch );
extern void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames, int fNumber );
extern void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames, int fNumber, int fSkipMffc );
Vec_Str_t * vInst = Acb_GenerateInstance2( vIns, vOuts );
Vec_Str_t * vPatch = Acb_GeneratePatch2( pGia, vIns, vOuts );
//printf( "%s", Vec_StrArray(vPatch) );
......@@ -2221,7 +2191,7 @@ void Acb_GenerateFile2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * vOuts, c
// generate output files
Acb_GenerateFilePatch( vPatch, "patch.v" );
printf( "Finished dumping patch file \"%s\".\n", "patch.v" );
Acb_NtkInsert( pFileName, "temp.v", vOuts, 0 );
Acb_NtkInsert( pFileName, "temp.v", vOuts, 0, fSkipMffc );
printf( "Finished dumping intermediate file \"%s\".\n", "temp.v" );
Acb_GenerateFileOut( vInst, "temp.v", pFileNameOut, vPatch );
printf( "Finished dumping the resulting file \"%s\".\n", pFileNameOut );
......
This diff is collapsed.
......@@ -106,7 +106,7 @@ extern ABC_DLL void * Abc_FrameReadManDec();
extern ABC_DLL void * Abc_FrameReadManDsd();
extern ABC_DLL void * Abc_FrameReadManDsd2();
extern ABC_DLL Vec_Ptr_t * Abc_FrameReadSignalNames();
extern ABC_DLL int * Abc_FrameReadGateCounts();
extern ABC_DLL char * Abc_FrameReadSpecName();
extern ABC_DLL char * Abc_FrameReadFlag( char * pFlag );
extern ABC_DLL int Abc_FrameIsFlagEnabled( char * pFlag );
......@@ -150,6 +150,7 @@ extern ABC_DLL void Abc_FrameSetStr( Vec_Str_t * vInv );
extern ABC_DLL void Abc_FrameSetJsonStrs( Abc_Nam_t * pStrs );
extern ABC_DLL void Abc_FrameSetJsonObjs( Vec_Wec_t * vObjs );
extern ABC_DLL void Abc_FrameSetSignalNames( Vec_Ptr_t * vNames );
extern ABC_DLL void Abc_FrameSetSpecName( char * pFileName );
extern ABC_DLL int Abc_FrameCheckPoConst( Abc_Frame_t * p, int iPoNum );
......
......@@ -68,7 +68,7 @@ void * Abc_FrameReadManDsd() { return s_GlobalFr
void * Abc_FrameReadManDsd2() { return s_GlobalFrame->pManDsd2; }
char * Abc_FrameReadFlag( char * pFlag ) { return Cmd_FlagReadByName( s_GlobalFrame, pFlag ); }
Vec_Ptr_t * Abc_FrameReadSignalNames() { return s_GlobalFrame->vSignalNames; }
int * Abc_FrameReadGateCounts() { return s_GlobalFrame->pGateCounts; }
char * Abc_FrameReadSpecName() { return s_GlobalFrame->pSpecName; }
int Abc_FrameReadBmcFrames( Abc_Frame_t * p ) { return s_GlobalFrame->nFrames; }
int Abc_FrameReadProbStatus( Abc_Frame_t * p ) { return s_GlobalFrame->Status; }
......@@ -105,6 +105,7 @@ void Abc_FrameSetInv( Vec_Int_t * vInv ) { Vec_IntFreeP(&s_G
void Abc_FrameSetJsonStrs( Abc_Nam_t * pStrs ) { Abc_NamDeref( s_GlobalFrame->pJsonStrs ); s_GlobalFrame->pJsonStrs = pStrs; }
void Abc_FrameSetJsonObjs( Vec_Wec_t * vObjs ) { Vec_WecFreeP(&s_GlobalFrame->vJsonObjs ); s_GlobalFrame->vJsonObjs = vObjs; }
void Abc_FrameSetSignalNames( Vec_Ptr_t * vNames ) { if ( s_GlobalFrame->vSignalNames ) Vec_PtrFreeFree( s_GlobalFrame->vSignalNames ); s_GlobalFrame->vSignalNames = vNames; }
void Abc_FrameSetSpecName( char * pFileName ) { ABC_FREE( s_GlobalFrame->pSpecName ); s_GlobalFrame->pSpecName = pFileName; }
int Abc_FrameIsBatchMode() { return s_GlobalFrame ? s_GlobalFrame->fBatchMode : 0; }
......@@ -236,6 +237,7 @@ void Abc_FrameDeallocate( Abc_Frame_t * p )
Vec_PtrFreeP( &p->vLTLProperties_global );
if ( p->vSignalNames )
Vec_PtrFreeFree( p->vSignalNames );
ABC_FREE( p->pSpecName );
Abc_FrameDeleteAllNetworks( p );
ABC_FREE( p->pDrivingCell );
ABC_FREE( p->pCex2 );
......
......@@ -134,7 +134,7 @@ struct Abc_Frame_t_
Vec_Ptr_t * vPlugInComBinPairs; // pairs of command and its binary name
Vec_Ptr_t * vLTLProperties_global; // related to LTL
Vec_Ptr_t * vSignalNames; // temporary storage for signal names
int pGateCounts[5];// temporary gate counts
char * pSpecName;
void * pSave1;
void * pSave2;
void * pSave3;
......
......@@ -624,6 +624,26 @@ static inline void Vec_PtrCopy( Vec_Ptr_t * pDest, Vec_Ptr_t * pSour )
pDest->nSize = pSour->nSize;
}
/**Function*************************************************************
Synopsis [Print names stored in the array.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Vec_PtrPrintNames( Vec_Ptr_t * p )
{
char * pName; int i;
printf( "Vector has %d entries: {", Vec_PtrSize(p) );
Vec_PtrForEachEntry( char *, p, pName, i )
printf( "%s ", pName );
printf( " }\n" );
}
/**Function*************************************************************
Synopsis []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment