mirror of https://github.com/YosysHQ/abc.git
Return the class representative of each function.
This commit is contained in:
parent
6842b8cdbc
commit
8e5af90c41
|
|
@ -181,7 +181,7 @@ void Abc_TruthNpnPerform( Abc_TtStore_t * p, int NpnType, int fVerbose )
|
|||
char pCanonPerm[16];
|
||||
unsigned uCanonPhase=0;
|
||||
abctime clk = Abc_Clock();
|
||||
int i, nClasses = -1;
|
||||
int i;
|
||||
|
||||
char * pAlgoName = NULL;
|
||||
if ( NpnType == 0 )
|
||||
|
|
@ -309,12 +309,12 @@ void Abc_TruthNpnPerform( Abc_TtStore_t * p, int NpnType, int fVerbose )
|
|||
// Extra_PrintHex( stdout, (unsigned *)p->pFuncs[i], p->nVars ), Abc_TruthNpnPrint(NULL, uCanonPhase, p->nVars), printf( "\n" );
|
||||
printf( "\n" );
|
||||
}
|
||||
nClasses = Abc_TtManNumClasses( pMan );
|
||||
// nClasses = Abc_TtManNumClasses( pMan );
|
||||
Abc_TtManStop( pMan );
|
||||
}
|
||||
else assert( 0 );
|
||||
clk = Abc_Clock() - clk;
|
||||
printf( "Classes =%9d ", nClasses == -1 ? Abc_TruthNpnCountUnique(p) : nClasses );
|
||||
printf( "Classes =%9d ", Abc_TruthNpnCountUnique(p) );
|
||||
Abc_PrintTime( 1, "Time", clk );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1059,8 +1059,27 @@ unsigned Abc_TtCanonicizePhase( word * pTruth, int nVars )
|
|||
struct Abc_TtMan_t_
|
||||
{
|
||||
Vec_Mem_t * vTtMem[TT_NUM_TABLES]; // truth table memory and hash tables
|
||||
Vec_Int_t ** vRepres; // pointers to the representatives from the last hierarchical level
|
||||
};
|
||||
|
||||
Vec_Int_t ** Abc_TtRepresStart() {
|
||||
Vec_Int_t ** vRepres = ABC_ALLOC(Vec_Int_t *, TT_NUM_TABLES - 1);
|
||||
int i;
|
||||
// create a list of pointers for each level of the hierarchy
|
||||
for (i = 0; i < (TT_NUM_TABLES - 1); i++) {
|
||||
vRepres[i] = Vec_IntAlloc(1);
|
||||
}
|
||||
return vRepres;
|
||||
}
|
||||
|
||||
void Abc_TtRepresStop(Vec_Int_t ** vRepres) {
|
||||
int i;
|
||||
for (i = 0; i < (TT_NUM_TABLES - 1); i++) {
|
||||
Vec_IntFree(vRepres[i]);
|
||||
}
|
||||
ABC_FREE( vRepres );
|
||||
}
|
||||
|
||||
Abc_TtMan_t * Abc_TtManStart( int nVars )
|
||||
{
|
||||
Abc_TtMan_t * p = ABC_CALLOC( Abc_TtMan_t, 1 );
|
||||
|
|
@ -1070,6 +1089,7 @@ Abc_TtMan_t * Abc_TtManStart( int nVars )
|
|||
p->vTtMem[i] = Vec_MemAlloc( nWords, 12 );
|
||||
Vec_MemHashAlloc( p->vTtMem[i], 10000 );
|
||||
}
|
||||
p->vRepres = Abc_TtRepresStart();
|
||||
return p;
|
||||
}
|
||||
void Abc_TtManStop( Abc_TtMan_t * p )
|
||||
|
|
@ -1080,6 +1100,7 @@ void Abc_TtManStop( Abc_TtMan_t * p )
|
|||
Vec_MemHashFree( p->vTtMem[i] );
|
||||
Vec_MemFreeP( &p->vTtMem[i] );
|
||||
}
|
||||
Abc_TtRepresStop(p->vRepres);
|
||||
ABC_FREE( p );
|
||||
}
|
||||
int Abc_TtManNumClasses( Abc_TtMan_t * p )
|
||||
|
|
@ -1096,6 +1117,9 @@ unsigned Abc_TtCanonicizeHie( Abc_TtMan_t * p, word * pTruthInit, int nVars, cha
|
|||
int nOnes, nWords = Abc_TtWordNum( nVars );
|
||||
int i, k, truthId;
|
||||
int * pSpot;
|
||||
int vTruthId[TT_NUM_TABLES-1];
|
||||
int fLevelFound;
|
||||
word * pRepTruth;
|
||||
assert( nVars <= 16 );
|
||||
|
||||
Abc_TtCopy( pTruth, pTruthInit, nWords, 0 );
|
||||
|
|
@ -1113,9 +1137,11 @@ unsigned Abc_TtCanonicizeHie( Abc_TtMan_t * p, word * pTruthInit, int nVars, cha
|
|||
}
|
||||
// check cache
|
||||
pSpot = Vec_MemHashLookup( p->vTtMem[0], pTruth );
|
||||
if ( *pSpot != -1 )
|
||||
return 0;
|
||||
truthId = Vec_MemHashInsert( p->vTtMem[0], pTruth );
|
||||
if ( *pSpot != -1 ) {
|
||||
fLevelFound = 0;
|
||||
goto end_repres;
|
||||
}
|
||||
vTruthId[0] = Vec_MemHashInsert( p->vTtMem[0], pTruth );
|
||||
|
||||
// normalize phase
|
||||
Abc_TtCountOnesInCofs( pTruth, nVars, pStore );
|
||||
|
|
@ -1130,9 +1156,11 @@ unsigned Abc_TtCanonicizeHie( Abc_TtMan_t * p, word * pTruthInit, int nVars, cha
|
|||
}
|
||||
// check cache
|
||||
pSpot = Vec_MemHashLookup( p->vTtMem[1], pTruth );
|
||||
if ( *pSpot != -1 )
|
||||
return 0;
|
||||
truthId = Vec_MemHashInsert( p->vTtMem[1], pTruth );
|
||||
if ( *pSpot != -1 ) {
|
||||
fLevelFound = 1;
|
||||
goto end_repres;
|
||||
}
|
||||
vTruthId[1] = Vec_MemHashInsert( p->vTtMem[1], pTruth );
|
||||
|
||||
// normalize permutation
|
||||
{
|
||||
|
|
@ -1157,9 +1185,11 @@ unsigned Abc_TtCanonicizeHie( Abc_TtMan_t * p, word * pTruthInit, int nVars, cha
|
|||
}
|
||||
// check cache
|
||||
pSpot = Vec_MemHashLookup( p->vTtMem[2], pTruth );
|
||||
if ( *pSpot != -1 )
|
||||
return 0;
|
||||
truthId = Vec_MemHashInsert( p->vTtMem[2], pTruth );
|
||||
if ( *pSpot != -1 ) {
|
||||
fLevelFound = 2;
|
||||
goto end_repres;
|
||||
}
|
||||
vTruthId[2] = Vec_MemHashInsert( p->vTtMem[2], pTruth );
|
||||
|
||||
// iterate TT permutations for tied variables
|
||||
for ( k = 0; k < 5; k++ )
|
||||
|
|
@ -1179,9 +1209,11 @@ unsigned Abc_TtCanonicizeHie( Abc_TtMan_t * p, word * pTruthInit, int nVars, cha
|
|||
}
|
||||
// check cache
|
||||
pSpot = Vec_MemHashLookup( p->vTtMem[3], pTruth );
|
||||
if ( *pSpot != -1 )
|
||||
return 0;
|
||||
truthId = Vec_MemHashInsert( p->vTtMem[3], pTruth );
|
||||
if ( *pSpot != -1 ) {
|
||||
fLevelFound = 3;
|
||||
goto end_repres;
|
||||
}
|
||||
vTruthId[3] = Vec_MemHashInsert( p->vTtMem[3], pTruth );
|
||||
|
||||
// perform exact NPN using groups
|
||||
if ( fExact ) {
|
||||
|
|
@ -1224,9 +1256,21 @@ unsigned Abc_TtCanonicizeHie( Abc_TtMan_t * p, word * pTruthInit, int nVars, cha
|
|||
}
|
||||
// check cache
|
||||
pSpot = Vec_MemHashLookup( p->vTtMem[4], pTruth );
|
||||
if ( *pSpot != -1 )
|
||||
return 0;
|
||||
truthId = Vec_MemHashInsert( p->vTtMem[4], pTruth );
|
||||
fLevelFound = 4;
|
||||
if ( *pSpot != -1 ) {
|
||||
goto end_repres;
|
||||
}
|
||||
*pSpot = Vec_MemHashInsert( p->vTtMem[4], pTruth );
|
||||
|
||||
end_repres:
|
||||
// return the class representative
|
||||
if(fLevelFound < (TT_NUM_TABLES - 1))
|
||||
truthId = Vec_IntEntry(p->vRepres[fLevelFound], *pSpot);
|
||||
else truthId = *pSpot;
|
||||
for(i = 0; i < fLevelFound; i++)
|
||||
Vec_IntSetEntry(p->vRepres[i], vTruthId[i], truthId);
|
||||
pRepTruth = Vec_MemReadEntry(p->vTtMem[TT_NUM_TABLES-1], truthId);
|
||||
Abc_TtCopy( pTruthInit, pRepTruth, nWords, 0 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue