summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/base/abci/abc.c14
-rw-r--r--src/base/acb/acbFunc.c18
-rw-r--r--src/base/acb/acbUtil.c4
-rw-r--r--src/misc/util/abc_global.h1
-rw-r--r--src/misc/util/utilNam.c2
-rw-r--r--src/misc/util/utilSort.c101
-rw-r--r--src/misc/vec/vecInt.h46
-rw-r--r--src/opt/sbd/sbdCut2.c6
8 files changed, 175 insertions, 17 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 009843ff..eb7e50f6 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -7106,11 +7106,11 @@ usage:
***********************************************************************/
int Abc_CommandRunEco( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- extern void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose );
+ extern void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fUnitW, int fVerbose, int fVeryVerbose );
char * pFileNames[4] = {NULL};
- int c, nTimeout = 0, fCheck = 0, fRandom = 0, fInputs = 0, fVerbose = 0, fVeryVerbose = 0;
+ int c, nTimeout = 0, fCheck = 0, fRandom = 0, fInputs = 0, fUnitW = 0, fVerbose = 0, fVeryVerbose = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "Tcrivwh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "Tcriuvwh" ) ) != EOF )
{
switch ( c )
{
@@ -7134,6 +7134,9 @@ int Abc_CommandRunEco( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'i':
fInputs ^= 1;
break;
+ case 'u':
+ fUnitW ^= 1;
+ break;
case 'v':
fVerbose ^= 1;
break;
@@ -7165,11 +7168,11 @@ int Abc_CommandRunEco( Abc_Frame_t * pAbc, int argc, char ** argv )
fclose( pFile );
pFileNames[c] = argv[globalUtilOptind+c];
}
- Acb_NtkRunEco( pFileNames, nTimeout, fCheck, fRandom, fInputs, fVerbose, fVeryVerbose );
+ Acb_NtkRunEco( pFileNames, nTimeout, fCheck, fRandom, fInputs, fUnitW, fVerbose, fVeryVerbose );
return 0;
usage:
- Abc_Print( -2, "usage: runeco [-T num] [-crivwh] <implementation> <specification> <weights>\n" );
+ Abc_Print( -2, "usage: runeco [-T num] [-criuvwh] <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" );
@@ -7181,6 +7184,7 @@ usage:
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-i : toggle using primary inputs as support variables [default = %s]\n", fInputs? "yes": "no" );
+ Abc_Print( -2, "\t-u : toggle using unit weights [default = %s]\n", fUnitW? "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");
diff --git a/src/base/acb/acbFunc.c b/src/base/acb/acbFunc.c
index ee468e88..a1d6568c 100644
--- a/src/base/acb/acbFunc.c
+++ b/src/base/acb/acbFunc.c
@@ -854,12 +854,18 @@ Vec_Int_t * Acb_NtkFindDivsCis( Acb_Ntk_t * p, Vec_Int_t * vSupp )
printf( "Divisors are %d support variables (CIs in the TFO of the targets).\n", Vec_IntSize(vSupp) );
return vDivs;
}
-Vec_Int_t * Acb_NtkFindDivs( Acb_Ntk_t * p, Vec_Int_t * vSupp, Vec_Bit_t * vBlock, int fVerbose )
+Vec_Int_t * Acb_NtkFindDivs( Acb_Ntk_t * p, Vec_Int_t * vSupp, Vec_Bit_t * vBlock, int fUnitW, int fVerbose )
{
int fPrintWeights = 0;
int nDivLimit = 5000;
int i, iObj;
Vec_Int_t * vDivs = Vec_IntAlloc( 1000 );
+ if ( fUnitW )
+ {
+ Acb_NtkForEachNode( p, iObj )
+ if ( Acb_ObjWeight(p, iObj) > 0 )
+ Vec_IntWriteEntry( &p->vObjWeight, iObj, 1 );
+ }
// mark inputs
Acb_NtkIncTravId( p );
Acb_NtkForEachCiVec( vSupp, p, iObj, i )
@@ -2863,7 +2869,7 @@ Vec_Ptr_t * Acb_TransformPatchFunctions( Vec_Ptr_t * vSops, Vec_Wec_t * vSupps,
SeeAlso []
***********************************************************************/
-int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4], int nTimeout, int fCisOnly, int fInputs, int fCheck, int fVerbose, int fVeryVerbose )
+int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4], int nTimeout, int fCisOnly, int fInputs, int fCheck, int fUnitW, int fVerbose, int fVeryVerbose )
{
extern Gia_Man_t * Abc_SopSynthesizeOne( char * pSop, int fClp );
@@ -2879,7 +2885,7 @@ int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4]
Vec_Int_t * vSuppF = Acb_NtkFindSupp( pNtkF, vRoots );
Vec_Int_t * vSuppG = Acb_NtkFindSupp( pNtkG, vRoots );
Vec_Int_t * vSupp = Vec_IntTwoMerge( vSuppF, vSuppG );
- Vec_Int_t * vDivs = (fCisOnly || fInputs) ? Acb_NtkFindDivsCis( pNtkF, vSupp ) : Acb_NtkFindDivs( pNtkF, vSupp, vBlock, fVerbose );
+ Vec_Int_t * vDivs = (fCisOnly || fInputs) ? Acb_NtkFindDivsCis( pNtkF, vSupp ) : Acb_NtkFindDivs( pNtkF, vSupp, vBlock, fUnitW, fVerbose );
Vec_Int_t * vNodesF = Acb_NtkFindNodes( pNtkF, vRoots, vDivs );
Vec_Int_t * vNodesG = Acb_NtkFindNodes( pNtkG, vRoots, NULL );
@@ -3129,7 +3135,7 @@ void Acb_NtkTestRun2( char * pFileNames[3], int fVerbose )
SeeAlso []
***********************************************************************/
-void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose )
+void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fUnitW, int fVerbose, int fVeryVerbose )
{
char Command[1000]; int Result = 1;
Acb_Ntk_t * pNtkF = Acb_VerilogSimpleRead( pFileNames[0], pFileNames[2] );
@@ -3151,10 +3157,10 @@ void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom,
Acb_IntallLibrary( Abc_FrameReadSignalNames() != NULL );
- if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, nTimeout, 0, fInputs, fCheck, fVerbose, fVeryVerbose ) )
+ if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, nTimeout, 0, fInputs, fCheck, fUnitW, fVerbose, fVeryVerbose ) )
{
// printf( "General computation timed out. Trying inputs only.\n\n" );
-// if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, nTimeout, 1, fInputs, fCheck, fVerbose, fVeryVerbose ) )
+// if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, nTimeout, 1, fInputs, fCheck, fUnitW, fVerbose, fVeryVerbose ) )
// printf( "Input-only computation also timed out.\n\n" );
printf( "Computation did not succeed.\n" );
Result = 0;
diff --git a/src/base/acb/acbUtil.c b/src/base/acb/acbUtil.c
index d0d53e18..b6adb6b3 100644
--- a/src/base/acb/acbUtil.c
+++ b/src/base/acb/acbUtil.c
@@ -1273,10 +1273,10 @@ void Acb_Ntk4DumpWeights( char * pFileNameIn, Vec_Ptr_t * vObjNames, char * pFil
void Acb_NtkRunSim( char * pFileName[4], int nTimeout, 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 )
{
extern int Gia_Sim4Try( char * pFileName0, char * pFileName1, char * pFileName2, int nTimeout, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fSkipMffc, int fVerbose );
- extern void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose );
+ extern void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fUnitW, int fVerbose, int fVeryVerbose );
char * pFileNames[4] = { pFileName[2], pFileName[1], fUseWeights ? (char *)"weights.txt" : NULL, pFileName[2] };
if ( Gia_Sim4Try( pFileName[0], pFileName[1], pFileName[2], nTimeout, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fSkipMffc, fVerbose ) )
- Acb_NtkRunEco( pFileNames, nTimeout, 1, fRandom, fInputs, fVerbose, fVeryVerbose );
+ Acb_NtkRunEco( pFileNames, nTimeout, 1, fRandom, fInputs, 0, fVerbose, fVeryVerbose );
}
diff --git a/src/misc/util/abc_global.h b/src/misc/util/abc_global.h
index 34bd5057..f6076399 100644
--- a/src/misc/util/abc_global.h
+++ b/src/misc/util/abc_global.h
@@ -515,6 +515,7 @@ static inline void Abc_ReverseOrder( int * pA, int nA )
// sorting
extern void Abc_MergeSort( int * pInput, int nSize );
extern int * Abc_MergeSortCost( int * pCosts, int nSize );
+extern void Abc_MergeSortCost2( int * pInput, int nSize, int * pCost );
extern void Abc_QuickSort1( word * pData, int nSize, int fDecrease );
extern void Abc_QuickSort2( word * pData, int nSize, int fDecrease );
extern void Abc_QuickSort3( word * pData, int nSize, int fDecrease );
diff --git a/src/misc/util/utilNam.c b/src/misc/util/utilNam.c
index b1d2702c..f6539f03 100644
--- a/src/misc/util/utilNam.c
+++ b/src/misc/util/utilNam.c
@@ -164,7 +164,7 @@ void Abc_NamSave( Abc_Nam_t * p, char * pFileName )
Abc_Nam_t * Abc_NamLoad( char * pFileName )
{
Abc_Nam_t * p;
- int fFound, NameId, nLineSize = 1 << 20;
+ int fFound, NameId = -1, nLineSize = 1 << 20;
char * pBuffer = ABC_ALLOC( char, nLineSize+1 );
FILE * pFile = fopen( pFileName, "rb" );
if ( pFile == NULL ) { printf( "Count node open output file %s\n", pFileName ); return NULL; }
diff --git a/src/misc/util/utilSort.c b/src/misc/util/utilSort.c
index 31890503..679017ed 100644
--- a/src/misc/util/utilSort.c
+++ b/src/misc/util/utilSort.c
@@ -137,6 +137,107 @@ void Abc_MergeSort( int * pInput, int nSize )
}
+/**Function*************************************************************
+
+ Synopsis [Merging two lists of entries.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_SortMergeCost2( int * p1Beg, int * p1End, int * p2Beg, int * p2End, int * pOut, int * pCost )
+{
+ int nEntries = (p1End - p1Beg) + (p2End - p2Beg);
+ int * pOutBeg = pOut;
+ while ( p1Beg < p1End && p2Beg < p2End )
+ {
+ if ( pCost[*p1Beg] == pCost[*p2Beg] )
+ *pOut++ = *p1Beg++, *pOut++ = *p2Beg++;
+ else if ( pCost[*p1Beg] < pCost[*p2Beg] )
+ *pOut++ = *p1Beg++;
+ else // if ( pCost[*p1Beg] > pCost[*p2Beg] )
+ *pOut++ = *p2Beg++;
+ }
+ while ( p1Beg < p1End )
+ *pOut++ = *p1Beg++;
+ while ( p2Beg < p2End )
+ *pOut++ = *p2Beg++;
+ assert( pOut - pOutBeg == nEntries );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Recursive sorting.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_SortCost2_rec( int * pInBeg, int * pInEnd, int * pOutBeg, int * pCost )
+{
+ int nSize = pInEnd - pInBeg;
+ assert( nSize > 0 );
+ if ( nSize == 1 )
+ return;
+ if ( nSize == 2 )
+ {
+ if ( pCost[pInBeg[0]] > pCost[pInBeg[1]] )
+ {
+ pInBeg[0] ^= pInBeg[1];
+ pInBeg[1] ^= pInBeg[0];
+ pInBeg[0] ^= pInBeg[1];
+ }
+ }
+ else if ( nSize < 8 )
+ {
+ int temp, i, j, best_i;
+ for ( i = 0; i < nSize-1; i++ )
+ {
+ best_i = i;
+ for ( j = i+1; j < nSize; j++ )
+ if ( pCost[pInBeg[j]] < pCost[pInBeg[best_i]] )
+ best_i = j;
+ temp = pInBeg[i];
+ pInBeg[i] = pInBeg[best_i];
+ pInBeg[best_i] = temp;
+ }
+ }
+ else
+ {
+ Abc_SortCost2_rec( pInBeg, pInBeg + nSize/2, pOutBeg, pCost );
+ Abc_SortCost2_rec( pInBeg + nSize/2, pInEnd, pOutBeg + nSize/2, pCost );
+ Abc_SortMergeCost2( pInBeg, pInBeg + nSize/2, pInBeg + nSize/2, pInEnd, pOutBeg, pCost );
+ memcpy( pInBeg, pOutBeg, sizeof(int) * nSize );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the sorted array of integers.]
+
+ Description [This procedure is about 10% faster than qsort().]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_MergeSortCost2( int * pInput, int nSize, int * pCost )
+{
+ int * pOutput;
+ if ( nSize < 2 )
+ return;
+ pOutput = (int *) malloc( sizeof(int) * nSize );
+ Abc_SortCost2_rec( pInput, pInput + nSize, pOutput, pCost );
+ free( pOutput );
+}
+
/**Function*************************************************************
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h
index c2f8cd61..df90f73f 100644
--- a/src/misc/vec/vecInt.h
+++ b/src/misc/vec/vecInt.h
@@ -864,6 +864,52 @@ static inline void Vec_IntPushOrderCost( Vec_Int_t * p, int Entry, Vec_Int_t * v
/**Function*************************************************************
+ Synopsis [Check if the array is ordered.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Vec_IntIsOrdered( Vec_Int_t * p, int fReverse )
+{
+ int i;
+ if ( fReverse )
+ {
+ for ( i = 1; i < p->nSize; i++ )
+ if ( p->pArray[i-1] < p->pArray[i] )
+ return 0;
+ }
+ else
+ {
+ for ( i = 1; i < p->nSize; i++ )
+ if ( p->pArray[i-1] > p->pArray[i] )
+ return 0;
+ }
+ return 1;
+}
+static inline int Vec_IntIsOrderedCost( Vec_Int_t * p, Vec_Int_t * vCost, int fReverse )
+{
+ int i;
+ if ( fReverse )
+ {
+ for ( i = 1; i < p->nSize; i++ )
+ if ( Vec_IntEntry(vCost, p->pArray[i-1]) < Vec_IntEntry(vCost, p->pArray[i]) )
+ return 0;
+ }
+ else
+ {
+ for ( i = 1; i < p->nSize; i++ )
+ if ( Vec_IntEntry(vCost, p->pArray[i-1]) > Vec_IntEntry(vCost, p->pArray[i]) )
+ return 0;
+ }
+ return 1;
+}
+
+/**Function*************************************************************
+
Synopsis [Inserts the entry while preserving the increasing order.]
Description []
diff --git a/src/opt/sbd/sbdCut2.c b/src/opt/sbd/sbdCut2.c
index b4a8be74..b9ef4d82 100644
--- a/src/opt/sbd/sbdCut2.c
+++ b/src/opt/sbd/sbdCut2.c
@@ -193,7 +193,7 @@ static inline int Sbd_ManCutExpandOne( Gia_Man_t * p, Vec_Int_t * vMirrors, Vec_
Vec_IntPushOrder( vCut, Fan1 );
return 1;
}
-void Vec_IntIsOrdered( Vec_Int_t * vCut )
+void Vec_IntOrdered( Vec_Int_t * vCut )
{
int i, Prev, Entry;
Prev = Vec_IntEntry( vCut, 0 );
@@ -229,7 +229,7 @@ void Sbd_ManCutReload( Vec_Int_t * vMirrors, Vec_Int_t * vLutLevs, int LevStop,
else
Vec_IntPush( vCutBot, Entry );
}
- Vec_IntIsOrdered( vCut );
+ Vec_IntOrdered( vCut );
}
int Sbd_ManCutCollect_rec( Gia_Man_t * p, Vec_Int_t * vMirrors, int iObj, int LevStop, Vec_Int_t * vLutLevs, Vec_Int_t * vCut )
{
@@ -267,7 +267,7 @@ int Sbd_ManCutReduceTop( Gia_Man_t * p, Vec_Int_t * vMirrors, int iObj, Vec_Int_
{
int i, Entry, Lit0m, Lit1m, Fan0, Fan1;
int LevStop = Vec_IntEntry(vLutLevs, iObj) - 2;
- Vec_IntIsOrdered( vCut );
+ Vec_IntOrdered( vCut );
Vec_IntForEachEntryReverse( vCutTop, Entry, i )
{
Gia_Obj_t * pObj = Gia_ManObj( p, Entry );