abc/src/base/abci/abcNpn.c
// hashes truth tables and collects unique ones
hashes truth tables and collects unique ones
hashes truth tables and collects unique ones
int Abc_TruthNpnCountUnique( Abc_TtStore_t * p )
{
    int nTableSize = Abc_PrimeCudd(p->nFuncs);
    int * pTable = ABC_FALLOC( int, nTableSize );
    int * pNexts = ABC_FALLOC( int, nTableSize );
    int i, k, Key;
    for ( i = 0; i < p->nFuncs; i++ )
    {
        Key = Abc_TruthHashKey( p->pFuncs[i], p->nWords, nTableSize );
        if ( Abc_TruthHashLookup( p->pFuncs, i, p->nWords, pTable, pNexts, Key ) ) 
            p->pFuncs[i] = NULL;
        else 
            pNexts[i] = pTable[Key], pTable[Key] = i;
    }
    ABC_FREE( pTable );
    ABC_FREE( pNexts );
    assert( p->pFuncs[0] != NULL );
    for ( i = k = 1; i < p->nFuncs; i++ )
        if ( p->pFuncs[i] != NULL )
            p->pFuncs[k++] = p->pFuncs[i];
    return (p->nFuncs = k);
}
int Abc_TruthNpnCountUnique ( Abc_TtStore_t * p ) { int nTableSize = Abc_PrimeCudd ( p -> nFuncs ) ; int * pTable = ABC_FALLOC ( int , nTableSize ) ; int * pNexts = ABC_FALLOC ( int , nTableSize ) ; int i , k , Key ; for ( i = 0 ; i < p -> nFuncs ; i ++ ) { Key = Abc_TruthHashKey ( p -> pFuncs [ i ] , p -> nWords , nTableSize ) ; if ( Abc_TruthHashLookup ( p -> pFuncs , i , p -> nWords , pTable , pNexts , Key ) ) p -> pFuncs [ i ] = NULL ; else pNexts [ i ] = pTable [ Key ] , pTable [ Key ] = i ; } ABC_FREE ( pTable ) ; ABC_FREE ( pNexts ) ; assert ( p -> pFuncs [ 0 ] != NULL ) ; for ( i = k = 1 ; i < p -> nFuncs ; i ++ ) if ( p -> pFuncs [ i ] != NULL ) p -> pFuncs [ k ++ ] = p -> pFuncs [ i ] ; return ( p -> nFuncs = k ) ; }
hashes truth tables and collects unique ones
hashes truth tables and collects unique ones
// allocate hash table // hash functions // found equal // there is no equal (the first time this one occurs so far) // count the number of unqiue functions