summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2020-04-10 12:40:04 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2020-04-10 12:40:04 -0700
commit747c6a6da5ead32aaa42341dfd347d90b05ded6e (patch)
tree7e8f6e2ae262218b30a0928ac38bae3efb630bb1 /src
parent6e2e054509f3707fb5ad0a064e3733e9e7c6ee6f (diff)
downloadabc-747c6a6da5ead32aaa42341dfd347d90b05ded6e.tar.gz
abc-747c6a6da5ead32aaa42341dfd347d90b05ded6e.tar.bz2
abc-747c6a6da5ead32aaa42341dfd347d90b05ded6e.zip
Various changes.
Diffstat (limited to 'src')
-rw-r--r--src/base/abci/abc.c57
-rw-r--r--src/base/acb/acbFunc.c11
-rw-r--r--src/base/acb/acbUtil.c103
3 files changed, 151 insertions, 20 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 5dab06f8..ec201a34 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -7045,17 +7045,20 @@ usage:
***********************************************************************/
int Abc_CommandRunEco( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- extern void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fVerbose, int fVeryVerbose );
+ extern void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fVerbose, int fVeryVerbose );
char * pFileNames[4] = {NULL};
- int c, fCheck = 0, fVerbose = 0, fVeryVerbose = 0;
+ int c, fCheck = 0, fRandom = 0, fVerbose = 0, fVeryVerbose = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "cvwh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "crvwh" ) ) != EOF )
{
switch ( c )
{
case 'c':
fCheck ^= 1;
break;
+ case 'r':
+ fRandom ^= 1;
+ break;
case 'v':
fVerbose ^= 1;
break;
@@ -7076,12 +7079,22 @@ int Abc_CommandRunEco( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
for ( c = 0; c < argc - globalUtilOptind; c++ )
+ {
+ FILE * pFile = fopen( argv[globalUtilOptind+c], "rb" );
+ if ( pFile == NULL )
+ {
+ printf( "Cannot open input file \"%s\".\n", argv[globalUtilOptind+c] );
+ return 0;
+ }
+ else
+ fclose( pFile );
pFileNames[c] = argv[globalUtilOptind+c];
- Acb_NtkRunEco( pFileNames, fCheck, fVerbose, fVeryVerbose );
+ }
+ Acb_NtkRunEco( pFileNames, fCheck, fRandom, fVerbose, fVeryVerbose );
return 0;
usage:
- Abc_Print( -2, "usage: runeco [-cvwh] <implementation> <specification> <weights>\n" );
+ Abc_Print( -2, "usage: runeco [-crvwh] <implementation> <specification> <weights>\n" );
Abc_Print( -2, "\t performs computation of patch functions during ECO,\n" );
Abc_Print( -2, "\t as described in the following paper: A. Q. Dao et al\n" );
Abc_Print( -2, "\t \"Efficient computation of ECO patch functions\", Proc. DAC\'18\n" );
@@ -7090,6 +7103,7 @@ usage:
Abc_Print( -2, "\t http://cad-contest-2017.el.cycu.edu.tw/Problem_A/default.html as follows:\n" );
Abc_Print( -2, "\t \"runeco unit1/F.v unit1/G.v unit1/weight.txt; cec -n out.v unit1/G.v\")\n" );
Abc_Print( -2, "\t-c : toggle checking that the problem has a solution [default = %s]\n", fCheck? "yes": "no" );
+ Abc_Print( -2, "\t-r : toggle using random permutation of support variables [default = %s]\n", fRandom? "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");
@@ -7158,11 +7172,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 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 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, fVerbose = 0, fVeryVerbose = 0;
+ int c, nWords = 8, nBeam = 4, LevL = -1, LevU = -1, fOrder = 0, fFancy = 0, fUseBuf = 0, fRandom = 0, fUseWeights = 0, fVerbose = 0, fVeryVerbose = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "WBLUofbvwh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "WBLUofbruvwh" ) ) != EOF )
{
switch ( c )
{
@@ -7219,6 +7233,12 @@ int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'b':
fUseBuf ^= 1;
break;
+ case 'r':
+ fRandom ^= 1;
+ break;
+ case 'u':
+ fUseWeights ^= 1;
+ break;
case 'v':
fVerbose ^= 1;
break;
@@ -7239,11 +7259,22 @@ int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv )
Gia_ManRandom(1);
for ( c = 0; c < argc - globalUtilOptind; c++ )
pFileNames[c] = argv[globalUtilOptind+c];
- Acb_NtkRunSim( pFileNames, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fVerbose, fVeryVerbose );
+ for ( c = 0; c < argc - globalUtilOptind - 1; c++ )
+ {
+ FILE * pFile = fopen( pFileNames[c], "rb" );
+ if ( pFile == NULL )
+ {
+ printf( "Cannot open input file \"%s\".\n", pFileNames[c] );
+ return 0;
+ }
+ else
+ fclose( pFile );
+ }
+ Acb_NtkRunSim( pFileNames, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fRandom, fUseWeights, fVerbose, fVeryVerbose );
return 0;
usage:
- Abc_Print( -2, "usage: runsim [-WBLU] [-ofbvwh] [-N <num>] <file1> <file2> <file3>\n" );
+ Abc_Print( -2, "usage: runsim [-WBLU] [-ofbruvwh] [-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 );
@@ -7252,8 +7283,10 @@ usage:
Abc_Print( -2, "\t-o : toggle using a different node ordering [default = %s]\n", fOrder? "yes": "no" );
Abc_Print( -2, "\t-f : toggle using experimental feature [default = %s]\n", fFancy? "yes": "no" );
Abc_Print( -2, "\t-b : toggle using buffers [default = %s]\n", fUseBuf? "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-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-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");
return 1;
}
diff --git a/src/base/acb/acbFunc.c b/src/base/acb/acbFunc.c
index e23dedbd..3f5a27fb 100644
--- a/src/base/acb/acbFunc.c
+++ b/src/base/acb/acbFunc.c
@@ -2748,7 +2748,7 @@ void Acb_NtkTestRun2( char * pFileNames[3], int fVerbose )
SeeAlso []
***********************************************************************/
-void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fVerbose, int fVeryVerbose )
+void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fVerbose, int fVeryVerbose )
{
char Command[1000]; int Result = 1;
Acb_Ntk_t * pNtkF = Acb_VerilogSimpleRead( pFileNames[0], pFileNames[2] );
@@ -2758,8 +2758,12 @@ void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fVerbose, int fVeryVer
//int * pArray = Vec_IntArray( &pNtkF->vTargets );
//ABC_SWAP( int, pArray[7], pArray[4] );
//Vec_IntReverseOrder( &pNtkF->vTargets );
- //Vec_IntPermute( &pNtkF->vTargets );
- //Vec_IntPrint( &pNtkF->vTargets );
+ if ( fRandom )
+ {
+ printf( "Permuting targets as follows: " );
+ Vec_IntPermute( &pNtkF->vTargets );
+ Vec_IntPrint( &pNtkF->vTargets );
+ }
assert( Acb_NtkCiNum(pNtkF) == Acb_NtkCiNum(pNtkG) );
assert( Acb_NtkCoNum(pNtkF) == Acb_NtkCoNum(pNtkG) );
@@ -2783,6 +2787,7 @@ void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fVerbose, int fVeryVer
pFileNames[1], pFileNames[3] ? pFileNames[3] : "out.v" );
if ( Result && Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ) )
fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
+ printf( "\n" );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/base/acb/acbUtil.c b/src/base/acb/acbUtil.c
index 131aeb7a..e899e163 100644
--- a/src/base/acb/acbUtil.c
+++ b/src/base/acb/acbUtil.c
@@ -912,20 +912,113 @@ void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames,
Synopsis []
Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Acb_Ntk4CollectAdd( Acb_Ntk_t * pNtk, int iObj, Vec_Int_t * vRes, Vec_Int_t * vDists, int Dist )
+{
+ if ( Acb_ObjSetTravIdCur(pNtk, iObj) )
+ return;
+ Vec_IntWriteEntry( vDists, iObj, Dist );
+ Vec_IntPush( vRes, iObj );
+}
+void Acb_Ntk4CollectRing( Acb_Ntk_t * pNtk, Vec_Int_t * vStart, Vec_Int_t * vRes, Vec_Int_t * vDists )
+{
+ int i, iObj;
+ Vec_IntForEachEntry( vStart, iObj, i )
+ {
+ int k, iFanin, * pFanins, Weight = Vec_IntEntry(vDists, iObj);
+ Acb_ObjForEachFaninFast( pNtk, iObj, pFanins, iFanin, k )
+ Acb_Ntk4CollectAdd( pNtk, iFanin, vRes, vDists, Weight + 1*(Acb_ObjFaninNum(pNtk, iObj) > 1) );
+ Acb_ObjForEachFanout( pNtk, iObj, iFanin, k )
+ Acb_Ntk4CollectAdd( pNtk, iFanin, vRes, vDists, Weight + 2*(Acb_ObjFaninNum(pNtk, iObj) > 1) );
+ }
+}
+void Acb_Ntk4DumpWeightsInt( Acb_Ntk_t * pNtk, Vec_Int_t * vObjs, char * pFileName )
+{
+ int i, iObj;//, Weight;
+ Vec_Int_t * vDists, * vStart, * vNexts;
+ FILE * pFile = fopen( pFileName, "wb" );
+ if ( pFile == NULL )
+ {
+ printf( "Canont open input file \"%s\".\n", pFileName );
+ return;
+ }
+ vStart = Vec_IntAlloc( 100 );
+ vNexts = Vec_IntAlloc( 100 );
+ vDists = Vec_IntStart( Acb_NtkObjNumMax(pNtk) );
+ Acb_NtkIncTravId( pNtk );
+ Vec_IntForEachEntry( vObjs, iObj, i )
+ {
+ Acb_ObjSetTravIdCur(pNtk, iObj);
+ Vec_IntWriteEntry( vDists, iObj, 1 );
+ Vec_IntPush( vStart, iObj );
+ }
+ while ( 1 )
+ {
+ Acb_Ntk4CollectRing( pNtk, vStart, vNexts, vDists );
+ if ( Vec_IntSize(vNexts) == 0 )
+ break;
+ Vec_IntClear( vStart );
+ ABC_SWAP( Vec_Int_t, *vStart, *vNexts );
+ }
+ Vec_IntFree( vStart );
+ Vec_IntFree( vNexts );
+ // create weights
+// Vec_IntForEachEntry( vDists, Weight, i )
+// if ( Weight && Acb_ObjNameStr(pNtk, i)[0] != '1' )
+// fprintf( pFile, "%s %d\n", Acb_ObjNameStr(pNtk, i), 10000+Weight );
+ Acb_NtkForEachObj( pNtk, iObj )
+ {
+ char * pName = Acb_ObjNameStr(pNtk, iObj);
+ int Weight = Vec_IntEntry(vDists, iObj);
+ if ( Weight == 0 )
+ Weight = 10000;
+ fprintf( pFile, "%s %d\n", pName, 100000+Weight );
+ }
+
+ Vec_IntFree( vDists );
+ fclose( pFile );
+}
+void Acb_Ntk4DumpWeights( char * pFileNameIn, Vec_Ptr_t * vObjNames, char * pFileName )
+{
+ char * pName; int i, iObj;
+ Vec_Int_t * vObjs = Vec_IntAlloc( Vec_PtrSize(vObjNames) );
+ Acb_Ntk_t * pNtkF = Acb_VerilogSimpleRead( pFileNameIn, NULL );
+ Acb_NtkCreateFanout( pNtkF );
+ Vec_PtrForEachEntry( char *, vObjNames, pName, i )
+ {
+ Acb_NtkForEachObj( pNtkF, iObj )
+ if ( !strcmp(Acb_ObjNameStr(pNtkF, iObj), pName) )
+ Vec_IntPush( vObjs, iObj );
+ }
+ Acb_Ntk4DumpWeightsInt( pNtkF, vObjs, pFileName );
+ Acb_ManFree( pNtkF->pDesign );
+ Vec_IntFree( vObjs );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
SideEffects []
SeeAlso []
***********************************************************************/
-void Acb_NtkRunSim( char * pFileName[4], int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fVerbose, int fVeryVerbose )
+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 fVerbose, int fVeryVerbose )
{
extern 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 );
- extern void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fVerbose, int fVeryVerbose );
- char * pFileNames[4] = { pFileName[2], pFileName[1], NULL, pFileName[2] };
+ extern void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fVerbose, int fVeryVerbose );
+ char * pFileNames[4] = { pFileName[2], pFileName[1], fUseWeights ? "weights.txt" : NULL, pFileName[2] };
if ( Gia_Sim4Try( pFileName[0], pFileName[1], pFileName[2], nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fVerbose ) )
- Acb_NtkRunEco( pFileNames, 1, fVerbose, fVeryVerbose );
-}
+ Acb_NtkRunEco( pFileNames, 1, fRandom, fVerbose, fVeryVerbose );
+}
////////////////////////////////////////////////////////////////////////