diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/mapper/mapperCanon.c | 49 | ||||
-rw-r--r-- | src/map/mapper/mapperCore.c | 2 | ||||
-rw-r--r-- | src/map/mapper/mapperCreate.c | 2 | ||||
-rw-r--r-- | src/map/mapper/mapperCut.c | 8 | ||||
-rw-r--r-- | src/map/mapper/mapperTruth.c | 56 |
5 files changed, 98 insertions, 19 deletions
diff --git a/src/map/mapper/mapperCanon.c b/src/map/mapper/mapperCanon.c index 4937fd0e..2b0f261f 100644 --- a/src/map/mapper/mapperCanon.c +++ b/src/map/mapper/mapperCanon.c @@ -170,13 +170,26 @@ void Map_CanonComputePhase6( unsigned uTruths[][2], int nVars, unsigned uTruth[] int Map_CanonComputeFast( Map_Man_t * p, int nVarsMax, int nVarsReal, unsigned uTruth[], unsigned char * puPhases, unsigned uTruthRes[] ) { unsigned uTruth0, uTruth1; - unsigned uCanon0, uCanon1, uCanonBest; + unsigned uCanon0, uCanon1, uCanonBest, uPhaseBest; int i, Limit; - if ( nVarsMax != 5 || nVarsReal < 5 ) + if ( nVarsMax == 6 ) return Map_CanonComputeSlow( p->uTruths, nVarsMax, nVarsReal, uTruth, puPhases, uTruthRes ); + if ( nVarsReal < 5 ) + { +// return Map_CanonComputeSlow( p->uTruths, nVarsMax, nVarsReal, uTruth, puPhases, uTruthRes ); + + uTruth0 = uTruth[0] & 0xFFFF; + assert( p->pCounters[uTruth0] > 0 ); + uTruthRes[0] = (p->uCanons[uTruth0] << 16) | p->uCanons[uTruth0]; + uTruthRes[1] = uTruthRes[0]; + puPhases[0] = p->uPhases[uTruth0][0]; + return 1; + } + assert( nVarsMax == 5 ); + assert( nVarsReal == 5 ); uTruth0 = uTruth[0] & 0xFFFF; uTruth1 = (uTruth[0] >> 16); if ( uTruth1 == 0 ) @@ -202,7 +215,7 @@ int Map_CanonComputeFast( Map_Man_t * p, int nVarsMax, int nVarsReal, unsigned u } uCanon0 = p->uCanons[uTruth0]; uCanon1 = p->uCanons[uTruth1]; - if ( uCanon0 && uCanon1 && uCanon0 > uCanon1 ) // using nCanon1 as the main one + if ( uCanon0 >= uCanon1 ) // using nCanon1 as the main one { assert( p->pCounters[uTruth1] > 0 ); uCanonBest = 0xFFFF; @@ -210,16 +223,17 @@ int Map_CanonComputeFast( Map_Man_t * p, int nVarsMax, int nVarsReal, unsigned u { uCanon0 = Extra_TruthPolarize( uTruth0, p->uPhases[uTruth1][i], 4 ); if ( uCanonBest > uCanon0 ) + { uCanonBest = uCanon0; + uPhaseBest = p->uPhases[uTruth1][i]; + } } uTruthRes[0] = (uCanon1 << 16) | uCanonBest; uTruthRes[1] = uTruthRes[0]; - Limit = (p->pCounters[uTruth1] > 4)? 4 : p->pCounters[uTruth1]; - for ( i = 0; i < Limit; i++ ) - puPhases[i] = p->uPhases[uTruth1][i]; - return Limit; + puPhases[0] = uPhaseBest; + return 1; } - else if ( uCanon0 && uCanon1 && uCanon0 < uCanon1 ) + else if ( uCanon0 < uCanon1 ) { assert( p->pCounters[uTruth0] > 0 ); uCanonBest = 0xFFFF; @@ -227,22 +241,27 @@ int Map_CanonComputeFast( Map_Man_t * p, int nVarsMax, int nVarsReal, unsigned u { uCanon1 = Extra_TruthPolarize( uTruth1, p->uPhases[uTruth0][i], 4 ); if ( uCanonBest > uCanon1 ) + { uCanonBest = uCanon1; + uPhaseBest = p->uPhases[uTruth0][i]; + } } uTruthRes[0] = (uCanon0 << 16) | uCanonBest; uTruthRes[1] = uTruthRes[0]; - Limit = (p->pCounters[uTruth0] > 4)? 4 : p->pCounters[uTruth0]; - for ( i = 0; i < Limit; i++ ) - { - puPhases[i] = p->uPhases[uTruth0][i]; - puPhases[i] |= (1 << 4); - } - return Limit; + puPhases[0] = uPhaseBest | (1 << 4); + return 1; } else + { + assert( 0 ); return Map_CanonComputeSlow( p->uTruths, nVarsMax, nVarsReal, uTruth, puPhases, uTruthRes ); + } } + + + + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/map/mapper/mapperCore.c b/src/map/mapper/mapperCore.c index 16cbfd5c..a43bcdc1 100644 --- a/src/map/mapper/mapperCore.c +++ b/src/map/mapper/mapperCore.c @@ -69,7 +69,7 @@ int Map_Mapping( Map_Man_t * p ) Map_MappingTruths( p ); p->timeTruth = clock() - clk; ////////////////////////////////////////////////////////////////////// -//PRT( "Truths", clock() - clk ); +PRT( "Truths", clock() - clk ); ////////////////////////////////////////////////////////////////////// // compute the minimum-delay mapping diff --git a/src/map/mapper/mapperCreate.c b/src/map/mapper/mapperCreate.c index dc056f34..738d099c 100644 --- a/src/map/mapper/mapperCreate.c +++ b/src/map/mapper/mapperCreate.c @@ -197,7 +197,7 @@ Map_Man_t * Map_ManCreate( int nInputs, int nOutputs, int fVerbose ) assert( p->nVarsMax > 0 ); if ( p->nVarsMax == 5 ) - Extra_Truth4VarN( &p->uCanons, &p->uPhases, &p->pCounters, 16 ); + Extra_Truth4VarN( &p->uCanons, &p->uPhases, &p->pCounters, 8 ); // start various data structures Map_TableCreate( p ); diff --git a/src/map/mapper/mapperCut.c b/src/map/mapper/mapperCut.c index 0c3a0910..b5ce4018 100644 --- a/src/map/mapper/mapperCut.c +++ b/src/map/mapper/mapperCut.c @@ -692,6 +692,7 @@ int Map_MappingCountAllCuts( Map_Man_t * pMan ) Map_Cut_t * pCut; int i, nCuts; // int nCuts55 = 0, nCuts5x = 0, nCuts4x = 0, nCuts3x = 0; +// int pCounts[7] = {0}; nCuts = 0; for ( i = 0; i < pMan->nBins; i++ ) for ( pNode = pMan->pBins[i]; pNode; pNode = pNode->pNext ) @@ -708,9 +709,14 @@ int Map_MappingCountAllCuts( Map_Man_t * pMan ) nCuts4x++; else if ( Map_CutRegular(pCut->pOne)->nLeaves == 3 || Map_CutRegular(pCut->pTwo)->nLeaves == 3 ) nCuts3x++; -*/ +*/ +// pCounts[ Map_CutRegular(pCut->pOne)->nLeaves ]++; +// pCounts[ Map_CutRegular(pCut->pTwo)->nLeaves ]++; } // printf( "Total cuts = %6d. 55 = %6d. 5x = %6d. 4x = %6d. 3x = %6d.\n", nCuts, nCuts55, nCuts5x, nCuts4x, nCuts3x ); + +// printf( "Total cuts = %6d. 6= %6d. 5= %6d. 4= %6d. 3= %6d. 2= %6d. 1= %6d.\n", +// nCuts, pCounts[6], pCounts[5], pCounts[4], pCounts[3], pCounts[2], pCounts[1] ); return nCuts; } diff --git a/src/map/mapper/mapperTruth.c b/src/map/mapper/mapperTruth.c index 54fc0391..7eabf4df 100644 --- a/src/map/mapper/mapperTruth.c +++ b/src/map/mapper/mapperTruth.c @@ -93,8 +93,13 @@ void Map_TruthsCut( Map_Man_t * p, Map_Cut_t * pCut ) // unsigned uCanon1, uCanon2; unsigned uTruth[2], uCanon[2]; unsigned char uPhases[16]; - int fUseFast = 1; + unsigned * uCanon2; + char * pPhases2; + int fUseFast = 0; + int fUseRec = 1; + extern int Map_CanonCompute( int nVarsMax, int nVarsReal, unsigned * pt, unsigned ** pptRes, char ** ppfRes ); + // generally speaking, 1-input cut can be matched into a wire! if ( pCut->nLeaves == 1 ) return; @@ -112,6 +117,21 @@ void Map_TruthsCut( Map_Man_t * p, Map_Cut_t * pCut ) // compute the canonical form for the positive phase if ( fUseFast ) Map_CanonComputeFast( p, p->nVarsMax, pCut->nLeaves, uTruth, uPhases, uCanon ); + else if ( fUseRec ) + { +// Map_CanonComputeSlow( p->uTruths, p->nVarsMax, pCut->nLeaves, uTruth, uPhases, uCanon ); + Extra_TruthCanonFastN( p->nVarsMax, pCut->nLeaves, uTruth, &uCanon2, &pPhases2 ); +/* + if ( uCanon[0] != uCanon2[0] || uPhases[0] != pPhases2[0] ) + { + int k = 0; + Map_CanonCompute( p->nVarsMax, pCut->nLeaves, uTruth, &uCanon2, &pPhases2 ); + } +*/ + uCanon[0] = uCanon2[0]; + uCanon[1] = (p->nVarsMax == 6)? uCanon2[1] : uCanon2[0]; + uPhases[0] = pPhases2[0]; + } else Map_CanonComputeSlow( p->uTruths, p->nVarsMax, pCut->nLeaves, uTruth, uPhases, uCanon ); pCut->M[1].pSupers = Map_SuperTableLookupC( p->pSuperLib, uCanon ); @@ -125,6 +145,21 @@ void Map_TruthsCut( Map_Man_t * p, Map_Cut_t * pCut ) uTruth[1] = ~uTruth[1]; if ( fUseFast ) Map_CanonComputeFast( p, p->nVarsMax, pCut->nLeaves, uTruth, uPhases, uCanon ); + else if ( fUseRec ) + { +// Map_CanonComputeSlow( p->uTruths, p->nVarsMax, pCut->nLeaves, uTruth, uPhases, uCanon ); + Extra_TruthCanonFastN( p->nVarsMax, pCut->nLeaves, uTruth, &uCanon2, &pPhases2 ); +/* + if ( uCanon[0] != uCanon2[0] || uPhases[0] != pPhases2[0] ) + { + int k = 0; + Map_CanonCompute( p->nVarsMax, pCut->nLeaves, uTruth, &uCanon2, &pPhases2 ); + } +*/ + uCanon[0] = uCanon2[0]; + uCanon[1] = (p->nVarsMax == 6)? uCanon2[1] : uCanon2[0]; + uPhases[0] = pPhases2[0]; + } else Map_CanonComputeSlow( p->uTruths, p->nVarsMax, pCut->nLeaves, uTruth, uPhases, uCanon ); pCut->M[0].pSupers = Map_SuperTableLookupC( p->pSuperLib, uCanon ); @@ -243,6 +278,25 @@ void Map_CutsCollect_rec( Map_Cut_t * pCut, Map_NodeVec_t * vVisited ) Map_NodeVecPush( vVisited, (Map_Node_t *)pCut ); } +/* + { + unsigned * uCanon2; + char * pPhases2; + + Map_CanonComputeSlow( p->uTruths, p->nVarsMax, pCut->nLeaves, uTruth, uPhases, uCanon ); + Map_CanonCompute( p->nVarsMax, pCut->nLeaves, uTruth, &uCanon2, &pPhases2 ); + if ( uCanon2[0] != uCanon[0] ) + { + int v = 0; + Map_CanonCompute( p->nVarsMax, pCut->nLeaves, uTruth, &uCanon2, &pPhases2 ); + Map_CanonComputeFast( p, p->nVarsMax, pCut->nLeaves, uTruth, uPhases, uCanon ); + } +// else +// { +// printf( "Correct.\n" ); +// } + } +*/ //////////////////////////////////////////////////////////////////////// /// END OF FILE /// |