diff options
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/abci/abc.c | 5 | ||||
-rw-r--r-- | src/base/abci/abcNpn.c | 74 | ||||
-rw-r--r-- | src/base/abci/abcRec.c | 8 | ||||
-rw-r--r-- | src/base/abci/abcRec2.c | 11 |
4 files changed, 70 insertions, 28 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 940e2643..25c77048 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -4907,10 +4907,11 @@ usage: Abc_Print( -2, "\t testbench for computing semi-canonical forms of Boolean functions\n" ); Abc_Print( -2, "\t-A <num> : semi-caninical form computation algorithm [default = %d]\n", NpnType ); Abc_Print( -2, "\t 0: none (reading and writing the file)\n" ); - Abc_Print( -2, "\t 1: exact canonical form (work only for 6 variables)\n" ); + Abc_Print( -2, "\t 1: exact canonical form (works only for 6 variables)\n" ); Abc_Print( -2, "\t 2: semi-canonical form by counting 1s in cofactors\n" ); Abc_Print( -2, "\t 3: semi-canonical form by minimizing truth table value\n" ); - Abc_Print( -2, "\t 4: hybrid semi-canonical form (work only for 6 variables)\n" ); + Abc_Print( -2, "\t 4: hybrid semi-canonical form (works only for 6 variables)\n" ); + Abc_Print( -2, "\t 5: Jake's hybrid semi-canonical form (works up to 16 variables)\n" ); Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; diff --git a/src/base/abci/abcNpn.c b/src/base/abci/abcNpn.c index 6e753e3b..e8c9168d 100644 --- a/src/base/abci/abcNpn.c +++ b/src/base/abci/abcNpn.c @@ -41,10 +41,10 @@ ABC_NAMESPACE_IMPL_START typedef struct Abc_TtStore_t_ Abc_TtStore_t; struct Abc_TtStore_t_ { - int nVars; - int nWords; - int nFuncs; - word ** pFuncs; + int nVars; + int nWords; + int nFuncs; + word ** pFuncs; }; extern Abc_TtStore_t * Abc_TtStoreLoad( char * pFileName ); @@ -84,6 +84,26 @@ int Abc_TruthNpnCountUnique( Abc_TtStore_t * p ) /**Function************************************************************* + Synopsis [Prints out one NPN transform.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Abc_TruthNpnPrint( char * pCanonPerm, unsigned uCanonPhase, int nVars ) +{ + int i; + printf( " %c = ( ", Abc_InfoHasBit(&uCanonPhase, nVars) ? 'Z':'z' ); + for ( i = 0; i < nVars; i++ ) + printf( "%c%s", pCanonPerm[i] + ('A'-'a') * Abc_InfoHasBit(&uCanonPhase, pCanonPerm[i]-'a'), i == nVars-1 ? "":"," ); + printf( " ) " ); +} + +/**Function************************************************************* + Synopsis [Apply decomposition to the truth table.] Description [Returns the number of AIG nodes.] @@ -95,24 +115,25 @@ int Abc_TruthNpnCountUnique( Abc_TtStore_t * p ) ***********************************************************************/ void Abc_TruthNpnPerform( Abc_TtStore_t * p, int NpnType, int fVerbose ) { - short pStore[16]; - char pCanonPerm[16]; unsigned pAux[2048]; - + char pCanonPerm[32]; + unsigned uCanonPhase=0; clock_t clk = clock(); - int i;//, nFuncs = 0; + int i; char * pAlgoName = NULL; if ( NpnType == 0 ) - pAlgoName = "uniqifying "; + pAlgoName = "uniqifying "; else if ( NpnType == 1 ) - pAlgoName = "exact NPN "; + pAlgoName = "exact NPN "; else if ( NpnType == 2 ) - pAlgoName = "counting 1s "; + pAlgoName = "counting 1s "; else if ( NpnType == 3 ) - pAlgoName = "minimizing TT"; + pAlgoName = "minimizing TT "; else if ( NpnType == 4 ) - pAlgoName = "hybrid NPN "; + pAlgoName = "hybrid NPN "; + else if ( NpnType == 5 ) + pAlgoName = "Jake's hybrid NPN"; assert( p->nVars <= 16 ); if ( pAlgoName ) @@ -157,9 +178,10 @@ void Abc_TruthNpnPerform( Abc_TtStore_t * p, int NpnType, int fVerbose ) { if ( fVerbose ) printf( "%7d : ", i ); - Kit_TruthSemiCanonicize( (unsigned *)p->pFuncs[i], pAux, p->nVars, pCanonPerm, pStore ); + resetPCanonPermArray(pCanonPerm, p->nVars); + uCanonPhase = Kit_TruthSemiCanonicize( (unsigned *)p->pFuncs[i], pAux, p->nVars, pCanonPerm ); if ( fVerbose ) - Extra_PrintHex( stdout, (unsigned *)p->pFuncs[i], p->nVars ), printf( "\n" ); + Extra_PrintHex( stdout, (unsigned *)p->pFuncs[i], p->nVars ), Abc_TruthNpnPrint(pCanonPerm, uCanonPhase, p->nVars), printf( "\n" ); } } else if ( NpnType == 3 ) @@ -168,9 +190,10 @@ void Abc_TruthNpnPerform( Abc_TtStore_t * p, int NpnType, int fVerbose ) { if ( fVerbose ) printf( "%7d : ", i ); - Kit_TruthSemiCanonicize_new( (unsigned *)p->pFuncs[i], pAux, p->nVars, pCanonPerm ); + resetPCanonPermArray(pCanonPerm, p->nVars); + uCanonPhase = Kit_TruthSemiCanonicize_new( (unsigned *)p->pFuncs[i], pAux, p->nVars, pCanonPerm ); if ( fVerbose ) - Extra_PrintHex( stdout, (unsigned *)p->pFuncs[i], p->nVars ), printf( "\n" ); + Extra_PrintHex( stdout, (unsigned *)p->pFuncs[i], p->nVars ), Abc_TruthNpnPrint(pCanonPerm, uCanonPhase, p->nVars), printf( "\n" ); } } else if ( NpnType == 4 ) @@ -181,7 +204,8 @@ void Abc_TruthNpnPerform( Abc_TtStore_t * p, int NpnType, int fVerbose ) { if ( fVerbose ) printf( "%7d : ", i ); - Kit_TruthSemiCanonicize( (unsigned *)p->pFuncs[i], pAux, p->nVars, pCanonPerm, pStore ); + resetPCanonPermArray(pCanonPerm, p->nVars); + Kit_TruthSemiCanonicize( (unsigned *)p->pFuncs[i], pAux, p->nVars, pCanonPerm ); *((word *)p->pFuncs[i]) = Extra_Truth6MinimumHeuristic( *((word *)p->pFuncs[i]) ); if ( fVerbose ) Extra_PrintHex( stdout, (unsigned *)p->pFuncs[i], p->nVars ), printf( "\n" ); @@ -190,6 +214,18 @@ void Abc_TruthNpnPerform( Abc_TtStore_t * p, int NpnType, int fVerbose ) else printf( "This feature only works for 6-variable functions.\n" ); } + else if ( NpnType == 5 ) + { + for ( i = 0; i < p->nFuncs; i++ ) + { + if ( fVerbose ) + printf( "%7d : ", i ); + resetPCanonPermArray(pCanonPerm, p->nVars); + uCanonPhase = luckyCanonicizer_final_fast( p->pFuncs[i], p->nVars, pCanonPerm ); + if ( fVerbose ) + Extra_PrintHex( stdout, (unsigned *)p->pFuncs[i], p->nVars ), Abc_TruthNpnPrint(pCanonPerm, uCanonPhase, p->nVars), printf( "\n" ); + } + } else assert( 0 ); clk = clock() - clk; @@ -248,7 +284,7 @@ int Abc_NpnTest( char * pFileName, int NpnType, int fVerbose ) { if ( fVerbose ) printf( "Using truth tables from file \"%s\"...\n", pFileName ); - if ( NpnType >= 0 && NpnType <= 4 ) + if ( NpnType >= 0 && NpnType <= 5 ) Abc_TruthNpnTest( pFileName, NpnType, fVerbose ); else printf( "Unknown canonical form value (%d).\n", NpnType ); diff --git a/src/base/abci/abcRec.c b/src/base/abci/abcRec.c index 83780233..cd2cae93 100644 --- a/src/base/abci/abcRec.c +++ b/src/base/abci/abcRec.c @@ -881,7 +881,7 @@ Hop_Obj_t * Abc_RecToHop( Hop_Man_t * pMan, If_Man_t * pIfMan, If_Cut_t * pCut, for (i = 0; i < nLeaves; i++) pCanonPerm[i] = i; - uCanonPhase = Kit_TruthSemiCanonicize(pInOut, pTemp, nLeaves, pCanonPerm, (short*)s_pMan->pMints); + uCanonPhase = Kit_TruthSemiCanonicize(pInOut, pTemp, nLeaves, pCanonPerm); If_CutTruthStretch(pInOut, nLeaves, nVars); pCandMin = Abc_NtkRecLookUpBest(pIfMan, pCut, pInOut, pCanonPerm, pCompl,NULL); Vec_PtrGrow(s_pMan->vLabels, Abc_NtkObjNumMax(pAig)); @@ -2252,7 +2252,7 @@ clk = clock(); // semi-canonicize the truth table clk = clock(); - uCanonPhase = Kit_TruthSemiCanonicize( pInOut, pTemp, nLeaves, pCanonPerm, (short *)s_pMan->pMints ); + uCanonPhase = Kit_TruthSemiCanonicize( pInOut, pTemp, nLeaves, pCanonPerm ); If_CutTruthStretch(pInOut, nLeaves, s_pMan->nVars); s_pMan->timeCanon += clock() - clk; // pCanonPerm and uCanonPhase show what was the variable corresponding to each var in the current truth @@ -2819,7 +2819,7 @@ int If_CutDelayRecCost(If_Man_t* p, If_Cut_t* pCut, If_Obj_t * pObj) //canonicize for (i = 0; i < nLeaves; i++) pCanonPerm[i] = i; - uCanonPhase = Kit_TruthSemiCanonicize(pInOut, pTemp, nLeaves, pCanonPerm, (short*)s_pMan->pMints); + uCanonPhase = Kit_TruthSemiCanonicize(pInOut, pTemp, nLeaves, pCanonPerm); If_CutTruthStretch(pInOut, nLeaves, nVars); s_pMan->timeIfCanonicize += clock() - timeCanonicize; timeDelayComput = clock(); @@ -2997,7 +2997,7 @@ int If_CutDelayRecCost(If_Man_t* p, If_Cut_t* pCut, If_Obj_t * pObj) pCanonPerm[i] = i; // canonicize the truth table - uCanonPhase = Kit_TruthSemiCanonicize( pInOut, pTemp, nVars, pCanonPerm, (short *)s_pMan->pMints ); + uCanonPhase = Kit_TruthSemiCanonicize( pInOut, pTemp, nVars, pCanonPerm ); // get hold of the curresponding class ppSpot = Abc_NtkRecTableLookup( s_pMan, pInOut, nVars ); diff --git a/src/base/abci/abcRec2.c b/src/base/abci/abcRec2.c index 460436ef..4edda73a 100644 --- a/src/base/abci/abcRec2.c +++ b/src/base/abci/abcRec2.c @@ -1183,6 +1183,11 @@ for ( i = 0; i < p->nBins; i++ ) for ( entry = p->pBins[i]; entry != REC_EMPTY_ID; entry = Rec_Obj(p, entry)->pCopy ) { int tmp = 0; + + assert( 0 ); + // added the next line to silence the warning that 'pEntry' is not initialized + pEntry = -1; + // pTruth = (unsigned*)Vec_PtrEntry(p->vTtNodes, entry); pTruth = Rec_MemReadEntry( p, Rec_Obj(p, pEntry)->truthID ); /*if ( (int)Kit_TruthSupport(pTruth, nVars) != (1<<nVars)-1 ) @@ -1525,7 +1530,7 @@ clk = clock(); // semi-canonicize the truth table clk = clock(); - uCanonPhase = Kit_TruthSemiCanonicize( pInOut, pTemp, nLeaves, pCanonPerm, (short *)s_pMan->pMints ); + uCanonPhase = Kit_TruthSemiCanonicize( pInOut, pTemp, nLeaves, pCanonPerm ); If_CutTruthStretch(pInOut, nLeaves, s_pMan->nVars); s_pMan->timeCanon += clock() - clk; // pCanonPerm and uCanonPhase show what was the variable corresponding to each var in the current truth @@ -1875,7 +1880,7 @@ int If_CutDelayRecCost2(If_Man_t* p, If_Cut_t* pCut, If_Obj_t * pObj) //canonicize for (i = 0; i < nLeaves; i++) pCanonPerm[i] = i; - uCanonPhase = Kit_TruthSemiCanonicize(pInOut, pTemp, nLeaves, pCanonPerm, (short*)s_pMan->pMints); + uCanonPhase = Kit_TruthSemiCanonicize(pInOut, pTemp, nLeaves, pCanonPerm); If_CutTruthStretch(pInOut, nLeaves, nVars); s_pMan->timeIfCanonicize += clock() - timeCanonicize; timeDelayComput = clock(); @@ -1986,7 +1991,7 @@ Hop_Obj_t * Abc_RecToHop2( Hop_Man_t * pMan, If_Man_t * pIfMan, If_Cut_t * pCut, for (i = 0; i < nLeaves; i++) pCanonPerm[i] = i; - uCanonPhase = Kit_TruthSemiCanonicize(pInOut, pTemp, nLeaves, pCanonPerm, (short*)s_pMan->pMints); + uCanonPhase = Kit_TruthSemiCanonicize(pInOut, pTemp, nLeaves, pCanonPerm); If_CutTruthStretch(pInOut, nLeaves, nVars); pCandMin = Abc_NtkRecLookUpBest(pIfMan, pCut, pInOut, pCanonPerm, pCompl,NULL); |