28 static unsigned Map_CanonComputePhase(
unsigned uTruths[][2],
int nVars,
unsigned uTruth,
unsigned uPhase );
29 static void Map_CanonComputePhase6(
unsigned uTruths[][2],
int nVars,
unsigned uTruth[],
unsigned uPhase,
unsigned uTruthRes[] );
48 int Map_CanonComputeSlow(
unsigned uTruths[][2],
int nVarsMax,
int nVarsReal,
unsigned uTruth[],
unsigned char * puPhases,
unsigned uTruthRes[] )
50 unsigned uTruthPerm[2];
51 int nMints, nPhases, m;
54 nMints = (1 << nVarsReal);
58 for ( m = 0; m < nMints; m++ )
61 if ( uTruthRes[0] > uTruthPerm[0] )
63 uTruthRes[0] = uTruthPerm[0];
65 puPhases[nPhases++] = (
unsigned char)m;
67 else if ( uTruthRes[0] == uTruthPerm[0] )
70 puPhases[nPhases++] = (
unsigned char)m;
73 uTruthRes[1] = uTruthRes[0];
79 for ( m = 0; m < nMints; m++ )
82 if ( uTruthRes[1] > uTruthPerm[1] || (uTruthRes[1] == uTruthPerm[1] && uTruthRes[0] > uTruthPerm[0]) )
84 uTruthRes[0] = uTruthPerm[0];
85 uTruthRes[1] = uTruthPerm[1];
87 puPhases[nPhases++] = (
unsigned char)m;
89 else if ( uTruthRes[1] == uTruthPerm[1] && uTruthRes[0] == uTruthPerm[0] )
92 puPhases[nPhases++] = (
unsigned char)m;
115 for ( v = 0, Shift = 1; v < nVars; v++, Shift <<= 1 )
116 if ( uPhase & Shift )
117 uTruth = (((uTruth & ~uTruths[v][0]) << Shift) | ((uTruth & uTruths[v][0]) >> Shift));
132 void Map_CanonComputePhase6(
unsigned uTruths[][2],
int nVars,
unsigned uTruth[],
unsigned uPhase,
unsigned uTruthRes[] )
138 uTruthRes[0] = uTruth[0];
139 uTruthRes[1] = uTruth[1];
143 for ( v = 0, Shift = 1; v < nVars; v++, Shift <<= 1 )
144 if ( uPhase & Shift )
148 uTruthRes[0] = (((uTruthRes[0] & ~uTruths[v][0]) << Shift) | ((uTruthRes[0] & uTruths[v][0]) >> Shift));
149 uTruthRes[1] = (((uTruthRes[1] & ~uTruths[v][1]) << Shift) | ((uTruthRes[1] & uTruths[v][1]) >> Shift));
153 uTemp = uTruthRes[0];
154 uTruthRes[0] = uTruthRes[1];
155 uTruthRes[1] = uTemp;
175 unsigned uTruth0, uTruth1;
176 unsigned uCanon0, uCanon1, uCanonBest;
177 unsigned uPhaseBest = 16;
187 uTruth0 = uTruth[0] & 0xFFFF;
188 assert( p->pCounters[uTruth0] > 0 );
189 uTruthRes[0] = (p->uCanons[uTruth0] << 16) | p->uCanons[uTruth0];
190 uTruthRes[1] = uTruthRes[0];
191 puPhases[0] = p->uPhases[uTruth0][0];
197 uTruth0 = uTruth[0] & 0xFFFF;
198 uTruth1 = (uTruth[0] >> 16);
201 uTruthRes[0] = p->uCanons[uTruth0];
202 uTruthRes[1] = uTruthRes[0];
203 Limit = (p->pCounters[uTruth0] > 4)? 4 : p->pCounters[uTruth0];
204 for ( i = 0; i < Limit; i++ )
205 puPhases[i] = p->uPhases[uTruth0][i];
208 else if ( uTruth0 == 0 )
210 uTruthRes[0] = p->uCanons[uTruth1];
211 uTruthRes[1] = uTruthRes[0];
212 Limit = (p->pCounters[uTruth1] > 4)? 4 : p->pCounters[uTruth1];
213 for ( i = 0; i < Limit; i++ )
215 puPhases[i] = p->uPhases[uTruth1][i];
216 puPhases[i] |= (1 << 4);
220 uCanon0 = p->uCanons[uTruth0];
221 uCanon1 = p->uCanons[uTruth1];
222 if ( uCanon0 >= uCanon1 )
224 assert( p->pCounters[uTruth1] > 0 );
225 uCanonBest = 0xFFFFFFFF;
226 for ( i = 0; i < p->pCounters[uTruth1]; i++ )
229 if ( uCanonBest > uCanon0 )
231 uCanonBest = uCanon0;
232 uPhaseBest = p->uPhases[uTruth1][i];
233 assert( uPhaseBest < 16 );
236 uTruthRes[0] = (uCanon1 << 16) | uCanonBest;
237 uTruthRes[1] = uTruthRes[0];
238 puPhases[0] = uPhaseBest;
241 else if ( uCanon0 < uCanon1 )
243 assert( p->pCounters[uTruth0] > 0 );
244 uCanonBest = 0xFFFFFFFF;
245 for ( i = 0; i < p->pCounters[uTruth0]; i++ )
248 if ( uCanonBest > uCanon1 )
250 uCanonBest = uCanon1;
251 uPhaseBest = p->uPhases[uTruth0][i];
252 assert( uPhaseBest < 16 );
255 uTruthRes[0] = (uCanon0 << 16) | uCanonBest;
256 uTruthRes[1] = uTruthRes[0];
257 puPhases[0] = uPhaseBest | (1 << 4);
#define MAP_MASK(n)
INCLUDES ///.
for(p=first;p->value< newval;p=p->next)
static void Map_CanonComputePhase6(unsigned uTruths[][2], int nVars, unsigned uTruth[], unsigned uPhase, unsigned uTruthRes[])
#define ABC_NAMESPACE_IMPL_END
#define ABC_NAMESPACE_IMPL_START
typedefABC_NAMESPACE_HEADER_START struct Map_ManStruct_t_ Map_Man_t
INCLUDES ///.
int Map_CanonComputeFast(Map_Man_t *p, int nVarsMax, int nVarsReal, unsigned uTruth[], unsigned char *puPhases, unsigned uTruthRes[])
static ABC_NAMESPACE_IMPL_START unsigned Map_CanonComputePhase(unsigned uTruths[][2], int nVars, unsigned uTruth, unsigned uPhase)
DECLARATIONS ///.
int Map_CanonComputeSlow(unsigned uTruths[][2], int nVarsMax, int nVarsReal, unsigned uTruth[], unsigned char *puPhases, unsigned uTruthRes[])
FUNCTION DEFINITIONS ///.