summaryrefslogtreecommitdiffstats
path: root/src/aig/kit
diff options
context:
space:
mode:
Diffstat (limited to 'src/aig/kit')
-rw-r--r--src/aig/kit/cloud.c992
-rw-r--r--src/aig/kit/cloud.h255
-rw-r--r--src/aig/kit/kit.h655
-rw-r--r--src/aig/kit/kitAig.c126
-rw-r--r--src/aig/kit/kitBdd.c236
-rw-r--r--src/aig/kit/kitCloud.c378
-rw-r--r--src/aig/kit/kitDec.c343
-rw-r--r--src/aig/kit/kitDsd.c3200
-rw-r--r--src/aig/kit/kitFactor.c344
-rw-r--r--src/aig/kit/kitGraph.c402
-rw-r--r--src/aig/kit/kitHop.c155
-rw-r--r--src/aig/kit/kitIsop.c330
-rw-r--r--src/aig/kit/kitPerm.c355
-rw-r--r--src/aig/kit/kitPla.c535
-rw-r--r--src/aig/kit/kitSop.c579
-rw-r--r--src/aig/kit/kitTruth.c2222
-rw-r--r--src/aig/kit/kit_.c53
-rw-r--r--src/aig/kit/module.make11
18 files changed, 0 insertions, 11171 deletions
diff --git a/src/aig/kit/cloud.c b/src/aig/kit/cloud.c
deleted file mode 100644
index fd372970..00000000
--- a/src/aig/kit/cloud.c
+++ /dev/null
@@ -1,992 +0,0 @@
-/**CFile****************************************************************
-
- FileName [cloudCore.c]
-
- PackageName [Fast application-specific BDD package.]
-
- Synopsis [The package core.]
-
- Author [Alan Mishchenko <alanmi@ece.pdx.edu>]
-
- Affiliation [ECE Department. Portland State University, Portland, Oregon.]
-
- Date [Ver. 1.0. Started - June 10, 2002.]
-
- Revision [$Id: cloudCore.c,v 1.0 2002/06/10 03:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "cloud.h"
-
-ABC_NAMESPACE_IMPL_START
-
-
-// the number of operators using cache
-static int CacheOperNum = 4;
-
-// the ratio of cache size to the unique table size for each operator
-static int CacheLogRatioDefault[4] = {
- 2, // CLOUD_OPER_AND,
- 8, // CLOUD_OPER_XOR,
- 8, // CLOUD_OPER_BDIFF,
- 8 // CLOUD_OPER_LEQ
-};
-
-// the ratio of cache size to the unique table size for each operator
-static int CacheSize[4] = {
- 2, // CLOUD_OPER_AND,
- 2, // CLOUD_OPER_XOR,
- 2, // CLOUD_OPER_BDIFF,
- 2 // CLOUD_OPER_LEQ
-};
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-// static functions
-static CloudNode * cloudMakeNode( CloudManager * dd, CloudVar v, CloudNode * t, CloudNode * e );
-static void cloudCacheAllocate( CloudManager * dd, CloudOper oper );
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function********************************************************************
-
- Synopsis [Starts the cloud manager.]
-
- Description [The first arguments is the number of elementary variables used.
- The second arguments is the number of bits of the unsigned integer used to
- represent nodes in the unique table. If the second argument is 0, the package
- assumes 23 to represent nodes, which is equivalent to 2^23 = 8,388,608 nodes.]
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-CloudManager * Cloud_Init( int nVars, int nBits )
-{
- CloudManager * dd;
- int i;
- int clk1, clk2;
-
- assert( nVars <= 100000 );
- assert( nBits < 32 );
-
- // assign the defaults
- if ( nBits == 0 )
- nBits = CLOUD_NODE_BITS;
-
- // start the manager
- dd = ABC_CALLOC( CloudManager, 1 );
- dd->nMemUsed += sizeof(CloudManager);
-
- // variables
- dd->nVars = nVars; // the number of variables allocated
- // bits
- dd->bitsNode = nBits; // the number of bits used for the node
- for ( i = 0; i < CacheOperNum; i++ )
- dd->bitsCache[i] = nBits - CacheLogRatioDefault[i];
- // shifts
- dd->shiftUnique = 8*sizeof(unsigned) - (nBits + 1); // gets node index in the hash table
- for ( i = 0; i < CacheOperNum; i++ )
- dd->shiftCache[i] = 8*sizeof(unsigned) - dd->bitsCache[i];
- // nodes
- dd->nNodesAlloc = (1 << (nBits + 1)); // 2 ^ (nBits + 1)
- dd->nNodesLimit = (1 << nBits); // 2 ^ nBits
-
- // unique table
-clk1 = clock();
- dd->tUnique = ABC_CALLOC( CloudNode, dd->nNodesAlloc );
- dd->nMemUsed += sizeof(CloudNode) * dd->nNodesAlloc;
-clk2 = clock();
-//ABC_PRT( "calloc() time", clk2 - clk1 );
-
- // set up the constant node (the only node that is not in the hash table)
- dd->nSignCur = 1;
- dd->tUnique[0].s = dd->nSignCur;
- dd->tUnique[0].v = CLOUD_CONST_INDEX;
- dd->tUnique[0].e = NULL;
- dd->tUnique[0].t = NULL;
- dd->one = dd->tUnique;
- dd->zero = Cloud_Not(dd->one);
- dd->nNodesCur = 1;
-
- // special nodes
- dd->pNodeStart = dd->tUnique + 1;
- dd->pNodeEnd = dd->tUnique + dd->nNodesAlloc;
-
- // set up the elementary variables
- dd->vars = ABC_ALLOC( CloudNode *, dd->nVars );
- dd->nMemUsed += sizeof(CloudNode *) * dd->nVars;
- for ( i = 0; i < dd->nVars; i++ )
- dd->vars[i] = cloudMakeNode( dd, i, dd->one, dd->zero );
-
- return dd;
-};
-
-/**Function********************************************************************
-
- Synopsis [Stops the cloud manager.]
-
- Description [The first arguments tells show many elementary variables are used.
- The second arguments tells how many bits of the unsigned integer are used
- to represent regular nodes in the unique table.]
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-void Cloud_Quit( CloudManager * dd )
-{
- int i;
- ABC_FREE( dd->ppNodes );
- ABC_FREE( dd->tUnique );
- ABC_FREE( dd->vars );
- for ( i = 0; i < 4; i++ )
- ABC_FREE( dd->tCaches[i] );
- ABC_FREE( dd );
-}
-
-/**Function********************************************************************
-
- Synopsis [Prepares the manager for another run.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-void Cloud_Restart( CloudManager * dd )
-{
- int i;
- assert( dd->one->s == dd->nSignCur );
- dd->nSignCur++;
- dd->one->s++;
- for ( i = 0; i < dd->nVars; i++ )
- dd->vars[i]->s++;
- dd->nNodesCur = 1 + dd->nVars;
-}
-
-/**Function********************************************************************
-
- Synopsis [This optional function allocates operation cache of the given size.]
-
- Description [Cache for each operation is allocated independently when the first
- operation of the given type is performed. The user can allocate cache of his/her
- preferred size by calling Cloud_CacheAllocate before the first operation of the
- given type is performed, but this call is optional. Argument "logratio" gives
- the binary logarithm of the ratio of the size of the unique table to that of cache.
- For example, if "logratio" is equal to 3, and the unique table will be 2^3=8 times
- larger than cache; so, if unique table is 2^23 = 8,388,608 nodes, the cache size
- will be 2^3=8 times smaller and equal to 2^20 = 1,048,576 entries.]
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-void Cloud_CacheAllocate( CloudManager * dd, CloudOper oper, int logratio )
-{
- assert( logratio > 0 ); // cache cannot be larger than the unique table
- assert( logratio < dd->bitsNode ); // cache cannot be smaller than 2 entries
-
- if ( logratio )
- {
- dd->bitsCache[oper] = dd->bitsNode - logratio;
- dd->shiftCache[oper] = 8*sizeof(unsigned) - dd->bitsCache[oper];
- }
- cloudCacheAllocate( dd, oper );
-}
-
-/**Function********************************************************************
-
- Synopsis [Internal cache allocation.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-void cloudCacheAllocate( CloudManager * dd, CloudOper oper )
-{
- int nCacheEntries = (1 << dd->bitsCache[oper]);
-
- if ( CacheSize[oper] == 1 )
- {
- dd->tCaches[oper] = (CloudCacheEntry2 *)ABC_CALLOC( CloudCacheEntry1, nCacheEntries );
- dd->nMemUsed += sizeof(CloudCacheEntry1) * nCacheEntries;
- }
- else if ( CacheSize[oper] == 2 )
- {
- dd->tCaches[oper] = (CloudCacheEntry2 *)ABC_CALLOC( CloudCacheEntry2, nCacheEntries );
- dd->nMemUsed += sizeof(CloudCacheEntry2) * nCacheEntries;
- }
- else if ( CacheSize[oper] == 3 )
- {
- dd->tCaches[oper] = (CloudCacheEntry2 *)ABC_CALLOC( CloudCacheEntry3, nCacheEntries );
- dd->nMemUsed += sizeof(CloudCacheEntry3) * nCacheEntries;
- }
-}
-
-
-
-/**Function********************************************************************
-
- Synopsis [Returns or creates a new node]
-
- Description [Checks the unique table for the existance of the node. If the node is
- present, returns the node. If the node is absent, creates a new node.]
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-CloudNode * Cloud_MakeNode( CloudManager * dd, CloudVar v, CloudNode * t, CloudNode * e )
-{
- CloudNode * pRes;
- CLOUD_ASSERT(t);
- CLOUD_ASSERT(e);
- assert( v < Cloud_V(t) && v < Cloud_V(e) ); // variable should be above in the order
- if ( Cloud_IsComplement(t) )
- {
- pRes = cloudMakeNode( dd, v, Cloud_Not(t), Cloud_Not(e) );
- if ( pRes != NULL )
- pRes = Cloud_Not(pRes);
- }
- else
- pRes = cloudMakeNode( dd, v, t, e );
- return pRes;
-}
-
-/**Function********************************************************************
-
- Synopsis [Returns or creates a new node]
-
- Description [Checks the unique table for the existance of the node. If the node is
- present, returns the node. If the node is absent, creates a new node.]
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-CloudNode * cloudMakeNode( CloudManager * dd, CloudVar v, CloudNode * t, CloudNode * e )
-{
- CloudNode * entryUnique;
-
- CLOUD_ASSERT(t);
- CLOUD_ASSERT(e);
-
- assert( ((int)v) >= 0 && ((int)v) < dd->nVars ); // the variable must be in the range
- assert( v < Cloud_V(t) && v < Cloud_V(e) ); // variable should be above in the order
- assert( !Cloud_IsComplement(t) ); // the THEN edge must not be complemented
-
- // make sure we are not searching for the constant node
- assert( t && e );
-
- // get the unique entry
- entryUnique = dd->tUnique + cloudHashCudd3(v, t, e, dd->shiftUnique);
- while ( entryUnique->s == dd->nSignCur )
- {
- // compare the node
- if ( entryUnique->v == v && entryUnique->t == t && entryUnique->e == e )
- { // the node is found
- dd->nUniqueHits++;
- return entryUnique; // returns the node
- }
- // increment the hash value modulus the hash table size
- if ( ++entryUnique - dd->tUnique == dd->nNodesAlloc )
- entryUnique = dd->tUnique + 1;
- // increment the number of steps through the table
- dd->nUniqueSteps++;
- }
- dd->nUniqueMisses++;
-
- // check if the new node can be created
- if ( ++dd->nNodesCur == dd->nNodesLimit )
- { // initiate the restart
- printf( "Cloud needs restart!\n" );
-// fflush( stdout );
-// exit(1);
- return NULL;
- }
- // create the node
- entryUnique->s = dd->nSignCur;
- entryUnique->v = v;
- entryUnique->t = t;
- entryUnique->e = e;
- return entryUnique; // returns the node
-}
-
-
-/**Function********************************************************************
-
- Synopsis [Performs the AND or two BDDs]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-CloudNode * cloudBddAnd( CloudManager * dd, CloudNode * f, CloudNode * g )
-{
- CloudNode * F, * G, * r;
- CloudCacheEntry2 * cacheEntry;
- CloudNode * fv, * fnv, * gv, * gnv, * t, * e;
- CloudVar var;
-
- assert( f <= g );
-
- // terminal cases
- F = Cloud_Regular(f);
- G = Cloud_Regular(g);
- if ( F == G )
- {
- if ( f == g )
- return f;
- else
- return dd->zero;
- }
- if ( F == dd->one )
- {
- if ( f == dd->one )
- return g;
- else
- return f;
- }
-
- // check cache
- cacheEntry = dd->tCaches[CLOUD_OPER_AND] + cloudHashCudd2(f, g, dd->shiftCache[CLOUD_OPER_AND]);
-// cacheEntry = dd->tCaches[CLOUD_OPER_AND] + cloudHashBuddy2(f, g, dd->shiftCache[CLOUD_OPER_AND]);
- r = cloudCacheLookup2( cacheEntry, dd->nSignCur, f, g );
- if ( r != NULL )
- {
- dd->nCacheHits++;
- return r;
- }
- dd->nCacheMisses++;
-
-
- // compute cofactors
- if ( cloudV(F) <= cloudV(G) )
- {
- var = cloudV(F);
- if ( Cloud_IsComplement(f) )
- {
- fnv = Cloud_Not(cloudE(F));
- fv = Cloud_Not(cloudT(F));
- }
- else
- {
- fnv = cloudE(F);
- fv = cloudT(F);
- }
- }
- else
- {
- var = cloudV(G);
- fv = fnv = f;
- }
-
- if ( cloudV(G) <= cloudV(F) )
- {
- if ( Cloud_IsComplement(g) )
- {
- gnv = Cloud_Not(cloudE(G));
- gv = Cloud_Not(cloudT(G));
- }
- else
- {
- gnv = cloudE(G);
- gv = cloudT(G);
- }
- }
- else
- {
- gv = gnv = g;
- }
-
- if ( fv <= gv )
- t = cloudBddAnd( dd, fv, gv );
- else
- t = cloudBddAnd( dd, gv, fv );
-
- if ( t == NULL )
- return NULL;
-
- if ( fnv <= gnv )
- e = cloudBddAnd( dd, fnv, gnv );
- else
- e = cloudBddAnd( dd, gnv, fnv );
-
- if ( e == NULL )
- return NULL;
-
- if ( t == e )
- r = t;
- else
- {
- if ( Cloud_IsComplement(t) )
- {
- r = cloudMakeNode( dd, var, Cloud_Not(t), Cloud_Not(e) );
- if ( r == NULL )
- return NULL;
- r = Cloud_Not(r);
- }
- else
- {
- r = cloudMakeNode( dd, var, t, e );
- if ( r == NULL )
- return NULL;
- }
- }
- cloudCacheInsert2( cacheEntry, dd->nSignCur, f, g, r );
- return r;
-}
-
-/**Function********************************************************************
-
- Synopsis [Performs the AND or two BDDs]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-static inline CloudNode * cloudBddAnd_gate( CloudManager * dd, CloudNode * f, CloudNode * g )
-{
- if ( f <= g )
- return cloudBddAnd(dd,f,g);
- else
- return cloudBddAnd(dd,g,f);
-}
-
-/**Function********************************************************************
-
- Synopsis [Performs the AND or two BDDs]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-CloudNode * Cloud_bddAnd( CloudManager * dd, CloudNode * f, CloudNode * g )
-{
- if ( Cloud_Regular(f) == NULL || Cloud_Regular(g) == NULL )
- return NULL;
- CLOUD_ASSERT(f);
- CLOUD_ASSERT(g);
- if ( dd->tCaches[CLOUD_OPER_AND] == NULL )
- cloudCacheAllocate( dd, CLOUD_OPER_AND );
- return cloudBddAnd_gate( dd, f, g );
-}
-
-/**Function********************************************************************
-
- Synopsis [Performs the OR or two BDDs]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-CloudNode * Cloud_bddOr( CloudManager * dd, CloudNode * f, CloudNode * g )
-{
- CloudNode * res;
- if ( Cloud_Regular(f) == NULL || Cloud_Regular(g) == NULL )
- return NULL;
- CLOUD_ASSERT(f);
- CLOUD_ASSERT(g);
- if ( dd->tCaches[CLOUD_OPER_AND] == NULL )
- cloudCacheAllocate( dd, CLOUD_OPER_AND );
- res = cloudBddAnd_gate( dd, Cloud_Not(f), Cloud_Not(g) );
- res = Cloud_NotCond( res, res != NULL );
- return res;
-}
-
-/**Function********************************************************************
-
- Synopsis [Performs the XOR or two BDDs]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-CloudNode * Cloud_bddXor( CloudManager * dd, CloudNode * f, CloudNode * g )
-{
- CloudNode * t0, * t1, * r;
- if ( Cloud_Regular(f) == NULL || Cloud_Regular(g) == NULL )
- return NULL;
- CLOUD_ASSERT(f);
- CLOUD_ASSERT(g);
- if ( dd->tCaches[CLOUD_OPER_AND] == NULL )
- cloudCacheAllocate( dd, CLOUD_OPER_AND );
- t0 = cloudBddAnd_gate( dd, f, Cloud_Not(g) );
- if ( t0 == NULL )
- return NULL;
- t1 = cloudBddAnd_gate( dd, Cloud_Not(f), g );
- if ( t1 == NULL )
- return NULL;
- r = Cloud_bddOr( dd, t0, t1 );
- return r;
-}
-
-
-
-/**Function********************************************************************
-
- Synopsis [Performs a DFS from f, clearing the LSB of the next
- pointers.]
-
- Description []
-
- SideEffects [None]
-
- SeeAlso [cloudSupport cloudDagSize]
-
-******************************************************************************/
-static void cloudClearMark( CloudManager * dd, CloudNode * n )
-{
- if ( !cloudNodeIsMarked(n) )
- return;
- // clear visited flag
- cloudNodeUnmark(n);
- if ( cloudIsConstant(n) )
- return;
- cloudClearMark( dd, cloudT(n) );
- cloudClearMark( dd, Cloud_Regular(cloudE(n)) );
-}
-
-/**Function********************************************************************
-
- Synopsis [Performs the recursive step of Cloud_Support.]
-
- Description [Performs the recursive step of Cloud_Support. Performs a
- DFS from f. The support is accumulated in supp as a side effect. Uses
- the LSB of the then pointer as visited flag.]
-
- SideEffects [None]
-
- SeeAlso []
-
-******************************************************************************/
-static void cloudSupport( CloudManager * dd, CloudNode * n, int * support )
-{
- if ( cloudIsConstant(n) || cloudNodeIsMarked(n) )
- return;
- // set visited flag
- cloudNodeMark(n);
- support[cloudV(n)] = 1;
- cloudSupport( dd, cloudT(n), support );
- cloudSupport( dd, Cloud_Regular(cloudE(n)), support );
-}
-
-/**Function********************************************************************
-
- Synopsis [Finds the variables on which a DD depends.]
-
- Description [Finds the variables on which a DD depends.
- Returns a BDD consisting of the product of the variables if
- successful; NULL otherwise.]
-
- SideEffects [None]
-
- SeeAlso []
-
-******************************************************************************/
-CloudNode * Cloud_Support( CloudManager * dd, CloudNode * n )
-{
- CloudNode * res;
- int * support, i;
-
- CLOUD_ASSERT(n);
-
- // allocate and initialize support array for cloudSupport
- support = ABC_CALLOC( int, dd->nVars );
-
- // compute support and clean up markers
- cloudSupport( dd, Cloud_Regular(n), support );
- cloudClearMark( dd, Cloud_Regular(n) );
-
- // transform support from array to cube
- res = dd->one;
- for ( i = dd->nVars - 1; i >= 0; i-- ) // for each level bottom-up
- if ( support[i] == 1 )
- {
- res = Cloud_bddAnd( dd, res, dd->vars[i] );
- if ( res == NULL )
- break;
- }
- ABC_FREE( support );
- return res;
-}
-
-/**Function********************************************************************
-
- Synopsis [Counts the variables on which a DD depends.]
-
- Description [Counts the variables on which a DD depends.
- Returns the number of the variables if successful; Cloud_OUT_OF_MEM
- otherwise.]
-
- SideEffects [None]
-
- SeeAlso []
-
-******************************************************************************/
-int Cloud_SupportSize( CloudManager * dd, CloudNode * n )
-{
- int * support, i, count;
-
- CLOUD_ASSERT(n);
-
- // allocate and initialize support array for cloudSupport
- support = ABC_CALLOC( int, dd->nVars );
-
- // compute support and clean up markers
- cloudSupport( dd, Cloud_Regular(n), support );
- cloudClearMark( dd, Cloud_Regular(n) );
-
- // count support variables
- count = 0;
- for ( i = 0; i < dd->nVars; i++ )
- {
- if ( support[i] == 1 )
- count++;
- }
-
- ABC_FREE( support );
- return count;
-}
-
-
-/**Function********************************************************************
-
- Synopsis [Performs the recursive step of Cloud_DagSize.]
-
- Description [Performs the recursive step of Cloud_DagSize. Returns the
- number of nodes in the graph rooted at n.]
-
- SideEffects [None]
-
-******************************************************************************/
-static int cloudDagSize( CloudManager * dd, CloudNode * n )
-{
- int tval, eval;
- if ( cloudNodeIsMarked(n) )
- return 0;
- // set visited flag
- cloudNodeMark(n);
- if ( cloudIsConstant(n) )
- return 1;
- tval = cloudDagSize( dd, cloudT(n) );
- eval = cloudDagSize( dd, Cloud_Regular(cloudE(n)) );
- return tval + eval + 1;
-
-}
-
-/**Function********************************************************************
-
- Synopsis [Counts the number of nodes in a DD.]
-
- Description [Counts the number of nodes in a DD. Returns the number
- of nodes in the graph rooted at node.]
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-int Cloud_DagSize( CloudManager * dd, CloudNode * n )
-{
- int res;
- res = cloudDagSize( dd, Cloud_Regular( n ) );
- cloudClearMark( dd, Cloud_Regular( n ) );
- return res;
-
-}
-
-
-/**Function********************************************************************
-
- Synopsis [Performs the recursive step of Cloud_DagSize.]
-
- Description [Performs the recursive step of Cloud_DagSize. Returns the
- number of nodes in the graph rooted at n.]
-
- SideEffects [None]
-
-******************************************************************************/
-static int Cloud_DagCollect_rec( CloudManager * dd, CloudNode * n, int * pCounter )
-{
- int tval, eval;
- if ( cloudNodeIsMarked(n) )
- return 0;
- // set visited flag
- cloudNodeMark(n);
- if ( cloudIsConstant(n) )
- {
- dd->ppNodes[(*pCounter)++] = n;
- return 1;
- }
- tval = Cloud_DagCollect_rec( dd, cloudT(n), pCounter );
- eval = Cloud_DagCollect_rec( dd, Cloud_Regular(cloudE(n)), pCounter );
- dd->ppNodes[(*pCounter)++] = n;
- return tval + eval + 1;
-
-}
-
-/**Function********************************************************************
-
- Synopsis [Counts the number of nodes in a DD.]
-
- Description [Counts the number of nodes in a DD. Returns the number
- of nodes in the graph rooted at node.]
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-int Cloud_DagCollect( CloudManager * dd, CloudNode * n )
-{
- int res, Counter = 0;
- if ( dd->ppNodes == NULL )
- dd->ppNodes = ABC_ALLOC( CloudNode *, dd->nNodesLimit );
- res = Cloud_DagCollect_rec( dd, Cloud_Regular( n ), &Counter );
- cloudClearMark( dd, Cloud_Regular( n ) );
- assert( res == Counter );
- return res;
-
-}
-
-/**Function********************************************************************
-
- Synopsis [Counts the number of nodes in an array of DDs.]
-
- Description [Counts the number of nodes in a DD. Returns the number
- of nodes in the graph rooted at node.]
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-int Cloud_SharingSize( CloudManager * dd, CloudNode ** pn, int nn )
-{
- int res, i;
- res = 0;
- for ( i = 0; i < nn; i++ )
- res += cloudDagSize( dd, Cloud_Regular( pn[i] ) );
- for ( i = 0; i < nn; i++ )
- cloudClearMark( dd, Cloud_Regular( pn[i] ) );
- return res;
-}
-
-
-/**Function********************************************************************
-
- Synopsis [Returns one cube contained in the given BDD.]
-
- Description []
-
- SideEffects []
-
-******************************************************************************/
-CloudNode * Cloud_GetOneCube( CloudManager * dd, CloudNode * bFunc )
-{
- CloudNode * bFunc0, * bFunc1, * res;
-
- if ( Cloud_IsConstant(bFunc) )
- return bFunc;
-
- // cofactor
- if ( Cloud_IsComplement(bFunc) )
- {
- bFunc0 = Cloud_Not( cloudE(bFunc) );
- bFunc1 = Cloud_Not( cloudT(bFunc) );
- }
- else
- {
- bFunc0 = cloudE(bFunc);
- bFunc1 = cloudT(bFunc);
- }
-
- // try to find the cube with the negative literal
- res = Cloud_GetOneCube( dd, bFunc0 );
- if ( res == NULL )
- return NULL;
-
- if ( res != dd->zero )
- {
- res = Cloud_bddAnd( dd, res, Cloud_Not(dd->vars[Cloud_V(bFunc)]) );
- }
- else
- {
- // try to find the cube with the positive literal
- res = Cloud_GetOneCube( dd, bFunc1 );
- if ( res == NULL )
- return NULL;
- assert( res != dd->zero );
- res = Cloud_bddAnd( dd, res, dd->vars[Cloud_V(bFunc)] );
- }
- return res;
-}
-
-/**Function********************************************************************
-
- Synopsis [Prints the BDD as a set of disjoint cubes to the standard output.]
-
- Description []
-
- SideEffects []
-
-******************************************************************************/
-void Cloud_bddPrint( CloudManager * dd, CloudNode * Func )
-{
- CloudNode * Cube;
- int fFirst = 1;
-
- if ( Func == dd->zero )
- printf( "Constant 0." );
- else if ( Func == dd->one )
- printf( "Constant 1." );
- else
- {
- while ( 1 )
- {
- Cube = Cloud_GetOneCube( dd, Func );
- if ( Cube == NULL || Cube == dd->zero )
- break;
- if ( fFirst ) fFirst = 0;
- else printf( " + " );
- Cloud_bddPrintCube( dd, Cube );
- Func = Cloud_bddAnd( dd, Func, Cloud_Not(Cube) );
- }
- }
- printf( "\n" );
-}
-
-/**Function********************************************************************
-
- Synopsis [Prints one cube.]
-
- Description []
-
- SideEffects []
-
-******************************************************************************/
-void Cloud_bddPrintCube( CloudManager * dd, CloudNode * bCube )
-{
- CloudNode * bCube0, * bCube1;
-
- assert( !Cloud_IsConstant(bCube) );
- while ( 1 )
- {
- // get the node structure
- if ( Cloud_IsConstant(bCube) )
- break;
-
- // cofactor the cube
- if ( Cloud_IsComplement(bCube) )
- {
- bCube0 = Cloud_Not( cloudE(bCube) );
- bCube1 = Cloud_Not( cloudT(bCube) );
- }
- else
- {
- bCube0 = cloudE(bCube);
- bCube1 = cloudT(bCube);
- }
-
- if ( bCube0 != dd->zero )
- {
- assert( bCube1 == dd->zero );
- printf( "[%d]'", cloudV(bCube) );
- bCube = bCube0;
- }
- else
- {
- assert( bCube1 != dd->zero );
- printf( "[%d]", cloudV(bCube) );
- bCube = bCube1;
- }
- }
-}
-
-
-/**Function********************************************************************
-
- Synopsis [Prints info.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-void Cloud_PrintInfo( CloudManager * dd )
-{
- if ( dd == NULL ) return;
- printf( "The number of unique table nodes allocated = %12d.\n", dd->nNodesAlloc );
- printf( "The number of unique table nodes present = %12d.\n", dd->nNodesCur );
- printf( "The number of unique table hits = %12d.\n", dd->nUniqueHits );
- printf( "The number of unique table misses = %12d.\n", dd->nUniqueMisses );
- printf( "The number of unique table steps = %12d.\n", dd->nUniqueSteps );
- printf( "The number of cache hits = %12d.\n", dd->nCacheHits );
- printf( "The number of cache misses = %12d.\n", dd->nCacheMisses );
- printf( "The current signature = %12d.\n", dd->nSignCur );
- printf( "The total memory in use = %12d.\n", dd->nMemUsed );
-}
-
-/**Function********************************************************************
-
- Synopsis [Prints the state of the hash table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-void Cloud_PrintHashTable( CloudManager * dd )
-{
- int i;
-
- for ( i = 0; i < dd->nNodesAlloc; i++ )
- if ( dd->tUnique[i].v == CLOUD_CONST_INDEX )
- printf( "-" );
- else
- printf( "+" );
- printf( "\n" );
-}
-
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/cloud.h b/src/aig/kit/cloud.h
deleted file mode 100644
index c48b55de..00000000
--- a/src/aig/kit/cloud.h
+++ /dev/null
@@ -1,255 +0,0 @@
-/**CFile****************************************************************
-
- FileName [cloud.h]
-
- PackageName [Fast application-specific BDD package.]
-
- Synopsis [Interface of the package.]
-
- Author [Alan Mishchenko <alanmi@ece.pdx.edu>]
-
- Affiliation [ECE Department. Portland State University, Portland, Oregon.]
-
- Date [Ver. 1.0. Started - June 10, 2002.]
-
- Revision [$Id: cloud.h,v 1.0 2002/06/10 03:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#ifndef __CLOUD_H__
-#define __CLOUD_H__
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <time.h>
-
-#include "abc_global.h"
-
-
-
-ABC_NAMESPACE_HEADER_START
-
-
-#ifdef _WIN32
-#define inline __inline // compatible with MS VS 6.0
-#endif
-
-////////////////////////////////////////////////////////////////////////
-// n | 2^n || n | 2^n || n | 2^n || n | 2^n //
-//====================================================================//
-// 1 | 2 || 9 | 512 || 17 | 131,072 || 25 | 33,554,432 //
-// 2 | 4 || 10 | 1,024 || 18 | 262,144 || 26 | 67,108,864 //
-// 3 | 8 || 11 | 2,048 || 19 | 524,288 || 27 | 134,217,728 //
-// 4 | 16 || 12 | 4,096 || 20 | 1,048,576 || 28 | 268,435,456 //
-// 5 | 32 || 13 | 8,192 || 21 | 2,097,152 || 29 | 536,870,912 //
-// 6 | 64 || 14 | 16,384 || 22 | 4,194,304 || 30 | 1,073,741,824 //
-// 7 | 128 || 15 | 32,768 || 23 | 8,388,608 || 31 | 2,147,483,648 //
-// 8 | 256 || 16 | 65,536 || 24 | 16,777,216 || 32 | 4,294,967,296 //
-////////////////////////////////////////////////////////////////////////
-
-// data structure typedefs
-typedef struct cloudManager CloudManager;
-typedef unsigned CloudVar;
-typedef unsigned CloudSign;
-typedef struct cloudNode CloudNode;
-typedef struct cloudCacheEntry1 CloudCacheEntry1;
-typedef struct cloudCacheEntry2 CloudCacheEntry2;
-typedef struct cloudCacheEntry3 CloudCacheEntry3;
-
-// operation codes used to set up the cache
-typedef enum {
- CLOUD_OPER_AND,
- CLOUD_OPER_XOR,
- CLOUD_OPER_BDIFF,
- CLOUD_OPER_LEQ
-} CloudOper;
-
-/*
-// the number of operators using cache
-static int CacheOperNum = 4;
-
-// the ratio of cache size to the unique table size for each operator
-static int CacheLogRatioDefault[4] = {
- 4, // CLOUD_OPER_AND,
- 8, // CLOUD_OPER_XOR,
- 8, // CLOUD_OPER_BDIFF,
- 8 // CLOUD_OPER_LEQ
-};
-
-// the ratio of cache size to the unique table size for each operator
-static int CacheSize[4] = {
- 2, // CLOUD_OPER_AND,
- 2, // CLOUD_OPER_XOR,
- 2, // CLOUD_OPER_BDIFF,
- 2 // CLOUD_OPER_LEQ
-};
-*/
-
-// data structure definitions
-struct cloudManager // the fast bdd manager
-{
- // variables
- int nVars; // the number of variables allocated
- // bits
- int bitsNode; // the number of bits used for the node
- int bitsCache[4]; // default: bitsNode - CacheSizeRatio[i]
- // shifts
- int shiftUnique; // 8*sizeof(unsigned) - (bitsNode + 1)
- int shiftCache[4]; // 8*sizeof(unsigned) - bitsCache[i]
- // nodes
- int nNodesAlloc; // 2 ^ (bitsNode + 1)
- int nNodesLimit; // 2 ^ bitsNode
- int nNodesCur; // the current number of nodes (including const1 and vars)
- // signature
- CloudSign nSignCur;
-
- // statistics
- int nMemUsed; // memory usage in bytes
- // cache stats
- int nUniqueHits; // hits in the unique table
- int nUniqueMisses; // misses in the unique table
- int nCacheHits; // hits in the caches
- int nCacheMisses; // misses in the caches
- // the number of steps through the hash table
- int nUniqueSteps;
-
- // tables
- CloudNode * tUnique; // the unique table to store BDD nodes
-
- // special nodes
- CloudNode * pNodeStart; // the pointer to the first node
- CloudNode * pNodeEnd; // the pointer to the first node out of the table
-
- // constants and variables
- CloudNode * one; // the one function
- CloudNode * zero; // the zero function
- CloudNode ** vars; // the elementary variables
-
- // temporary storage for nodes
- CloudNode ** ppNodes;
-
- // caches
- CloudCacheEntry2 * tCaches[20]; // caches
-};
-
-struct cloudNode // representation of the node in the unique table
-{
- CloudSign s; // signature
- CloudVar v; // variable
- CloudNode * e; // negative cofactor
- CloudNode * t; // positive cofactor
-};
-struct cloudCacheEntry1 // one-argument cache
-{
- CloudSign s; // signature
- CloudNode * a; // argument 1
- CloudNode * r; // result
-};
-struct cloudCacheEntry2 // the two-argument cache
-{
- CloudSign s; // signature
- CloudNode * a;
- CloudNode * b;
- CloudNode * r;
-};
-struct cloudCacheEntry3 // the three-argument cache
-{
- CloudSign s; // signature
- CloudNode * a;
- CloudNode * b;
- CloudNode * c;
- CloudNode * r;
-};
-
-
-// parameters
-#define CLOUD_NODE_BITS 23
-
-#define CLOUD_CONST_INDEX ((unsigned)0x0fffffff)
-#define CLOUD_MARK_ON ((unsigned)0x10000000)
-#define CLOUD_MARK_OFF ((unsigned)0xefffffff)
-
-// hash functions a la Buddy
-#define cloudHashBuddy2(x,y,s) ((((x)+(y))*((x)+(y)+1)/2) & ((1<<(32-(s)))-1))
-#define cloudHashBuddy3(x,y,z,s) (cloudHashBuddy2((cloudHashBuddy2((x),(y),(s))),(z),(s)) & ((1<<(32-(s)))-1))
-// hash functions a la Cudd
-#define DD_P1 12582917
-#define DD_P2 4256249
-#define DD_P3 741457
-#define DD_P4 1618033999
-#define cloudHashCudd2(f,g,s) ((((unsigned)(ABC_PTRUINT_T)(f) * DD_P1 + (unsigned)(ABC_PTRUINT_T)(g)) * DD_P2) >> (s))
-#define cloudHashCudd3(f,g,h,s) (((((unsigned)(ABC_PTRUINT_T)(f) * DD_P1 + (unsigned)(ABC_PTRUINT_T)(g)) * DD_P2 + (unsigned)(ABC_PTRUINT_T)(h)) * DD_P3) >> (s))
-
-// node complementation (using node)
-#define Cloud_Regular(p) ((CloudNode*)(((ABC_PTRUINT_T)(p)) & ~01)) // get the regular node (w/o bubble)
-#define Cloud_Not(p) ((CloudNode*)(((ABC_PTRUINT_T)(p)) ^ 01)) // complement the node
-#define Cloud_NotCond(p,c) ((CloudNode*)(((ABC_PTRUINT_T)(p)) ^ (c))) // complement the node conditionally
-#define Cloud_IsComplement(p) ((int)(((ABC_PTRUINT_T)(p)) & 01)) // check if complemented
-// checking constants (using node)
-#define Cloud_IsConstant(p) (((Cloud_Regular(p))->v & CLOUD_MARK_OFF) == CLOUD_CONST_INDEX)
-#define cloudIsConstant(p) (((p)->v & CLOUD_MARK_OFF) == CLOUD_CONST_INDEX)
-
-// retrieving values from the node (using node structure)
-#define Cloud_V(p) ((Cloud_Regular(p))->v)
-#define Cloud_E(p) ((Cloud_Regular(p))->e)
-#define Cloud_T(p) ((Cloud_Regular(p))->t)
-// retrieving values from the regular node (using node structure)
-#define cloudV(p) ((p)->v)
-#define cloudE(p) ((p)->e)
-#define cloudT(p) ((p)->t)
-// marking/unmarking (using node structure)
-#define cloudNodeMark(p) ((p)->v |= CLOUD_MARK_ON)
-#define cloudNodeUnmark(p) ((p)->v &= CLOUD_MARK_OFF)
-#define cloudNodeIsMarked(p) ((int)((p)->v & CLOUD_MARK_ON))
-
-// cache lookups and inserts (using node)
-#define cloudCacheLookup1(p,sign,f) (((p)->s == (sign) && (p)->a == (f))? ((p)->r): (0))
-#define cloudCacheLookup2(p,sign,f,g) (((p)->s == (sign) && (p)->a == (f) && (p)->b == (g))? ((p)->r): (0))
-#define cloudCacheLookup3(p,sign,f,g,h) (((p)->s == (sign) && (p)->a == (f) && (p)->b == (g) && (p)->c == (h))? ((p)->r): (0))
-// cache inserts
-#define cloudCacheInsert1(p,sign,f,r) (((p)->s = (sign)), ((p)->a = (f)), ((p)->r = (r)))
-#define cloudCacheInsert2(p,sign,f,g,r) (((p)->s = (sign)), ((p)->a = (f)), ((p)->b = (g)), ((p)->r = (r)))
-#define cloudCacheInsert3(p,sign,f,g,h,r) (((p)->s = (sign)), ((p)->a = (f)), ((p)->b = (g)), ((p)->c = (h)), ((p)->r = (r)))
-
-//#define CLOUD_ASSERT(p) (assert((p) >= (dd->pNodeStart-1) && (p) < dd->pNodeEnd))
-#define CLOUD_ASSERT(p) assert((p) >= dd->tUnique && (p) < dd->tUnique+dd->nNodesAlloc)
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-// starting/stopping
-extern CloudManager * Cloud_Init( int nVars, int nBits );
-extern void Cloud_Quit( CloudManager * dd );
-extern void Cloud_Restart( CloudManager * dd );
-extern void Cloud_CacheAllocate( CloudManager * dd, CloudOper oper, int size );
-extern CloudNode * Cloud_MakeNode( CloudManager * dd, CloudVar v, CloudNode * t, CloudNode * e );
-// support and node count
-extern CloudNode * Cloud_Support( CloudManager * dd, CloudNode * n );
-extern int Cloud_SupportSize( CloudManager * dd, CloudNode * n );
-extern int Cloud_DagSize( CloudManager * dd, CloudNode * n );
-extern int Cloud_DagCollect( CloudManager * dd, CloudNode * n );
-extern int Cloud_SharingSize( CloudManager * dd, CloudNode * * pn, int nn );
-// cubes
-extern CloudNode * Cloud_GetOneCube( CloudManager * dd, CloudNode * n );
-extern void Cloud_bddPrint( CloudManager * dd, CloudNode * Func );
-extern void Cloud_bddPrintCube( CloudManager * dd, CloudNode * Cube );
-// operations
-extern CloudNode * Cloud_bddAnd( CloudManager * dd, CloudNode * f, CloudNode * g );
-extern CloudNode * Cloud_bddOr( CloudManager * dd, CloudNode * f, CloudNode * g );
-// stats
-extern void Cloud_PrintInfo( CloudManager * dd );
-extern void Cloud_PrintHashTable( CloudManager * dd );
-
-
-
-ABC_NAMESPACE_HEADER_END
-
-
-
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/kit/kit.h b/src/aig/kit/kit.h
deleted file mode 100644
index 9e15e994..00000000
--- a/src/aig/kit/kit.h
+++ /dev/null
@@ -1,655 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kit.h]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis [External declarations.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - Dec 6, 2006.]
-
- Revision [$Id: kit.h,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#ifndef __KIT_H__
-#define __KIT_H__
-
-
-////////////////////////////////////////////////////////////////////////
-/// INCLUDES ///
-////////////////////////////////////////////////////////////////////////
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <time.h>
-#include "vec.h"
-#include "extra.h"
-#include "cloud.h"
-
-////////////////////////////////////////////////////////////////////////
-/// PARAMETERS ///
-////////////////////////////////////////////////////////////////////////
-
-
-
-ABC_NAMESPACE_HEADER_START
-
-
-////////////////////////////////////////////////////////////////////////
-/// BASIC TYPES ///
-////////////////////////////////////////////////////////////////////////
-
-typedef struct Kit_Sop_t_ Kit_Sop_t;
-struct Kit_Sop_t_
-{
- int nCubes; // the number of cubes
- unsigned * pCubes; // the storage for cubes
-};
-
-typedef struct Kit_Edge_t_ Kit_Edge_t;
-struct Kit_Edge_t_
-{
- unsigned fCompl : 1; // the complemented bit
- unsigned Node : 30; // the decomposition node pointed by the edge
-};
-
-typedef struct Kit_Node_t_ Kit_Node_t;
-struct Kit_Node_t_
-{
- Kit_Edge_t eEdge0; // the left child of the node
- Kit_Edge_t eEdge1; // the right child of the node
- // other info
- void * pFunc; // the function of the node (BDD or AIG)
- unsigned Level : 14; // the level of this node in the global AIG
- // printing info
- unsigned fNodeOr : 1; // marks the original OR node
- unsigned fCompl0 : 1; // marks the original complemented edge
- unsigned fCompl1 : 1; // marks the original complemented edge
- // latch info
- unsigned nLat0 : 5; // the number of latches on the first edge
- unsigned nLat1 : 5; // the number of latches on the second edge
- unsigned nLat2 : 5; // the number of latches on the output edge
-};
-
-typedef struct Kit_Graph_t_ Kit_Graph_t;
-struct Kit_Graph_t_
-{
- int fConst; // marks the constant 1 graph
- int nLeaves; // the number of leaves
- int nSize; // the number of nodes (including the leaves)
- int nCap; // the number of allocated nodes
- Kit_Node_t * pNodes; // the array of leaves and internal nodes
- Kit_Edge_t eRoot; // the pointer to the topmost node
-};
-
-
-// DSD node types
-typedef enum {
- KIT_DSD_NONE = 0, // 0: unknown
- KIT_DSD_CONST1, // 1: constant 1
- KIT_DSD_VAR, // 2: elementary variable
- KIT_DSD_AND, // 3: multi-input AND
- KIT_DSD_XOR, // 4: multi-input XOR
- KIT_DSD_PRIME // 5: arbitrary function of 3+ variables
-} Kit_Dsd_t;
-
-// DSD node
-typedef struct Kit_DsdObj_t_ Kit_DsdObj_t;
-struct Kit_DsdObj_t_
-{
- unsigned Id : 6; // the number of this node
- unsigned Type : 3; // none, const, var, AND, XOR, MUX, PRIME
- unsigned fMark : 1; // finished checking output
- unsigned Offset : 8; // offset to the truth table
- unsigned nRefs : 8; // offset to the truth table
- unsigned nFans : 6; // the number of fanins of this node
- unsigned char pFans[0]; // the fanin literals
-};
-
-// DSD network
-typedef struct Kit_DsdNtk_t_ Kit_DsdNtk_t;
-struct Kit_DsdNtk_t_
-{
- unsigned char nVars; // at most 16 (perhaps 18?)
- unsigned char nNodesAlloc; // the number of allocated nodes (at most nVars)
- unsigned char nNodes; // the number of nodes
- unsigned char Root; // the root of the tree
- unsigned * pMem; // memory for the truth tables (memory manager?)
- unsigned * pSupps; // supports of the nodes
- Kit_DsdObj_t** pNodes; // the nodes
-};
-
-// DSD manager
-typedef struct Kit_DsdMan_t_ Kit_DsdMan_t;
-struct Kit_DsdMan_t_
-{
- int nVars; // the maximum number of variables
- int nWords; // the number of words in TTs
- Vec_Ptr_t * vTtElems; // elementary truth tables
- Vec_Ptr_t * vTtNodes; // the node truth tables
- // BDD representation
- CloudManager * dd; // BDD package
- Vec_Ptr_t * vTtBdds; // the node truth tables
- Vec_Int_t * vNodes; // temporary array for BDD nodes
-};
-
-static inline int Kit_DsdVar2Lit( int Var, int fCompl ) { return Var + Var + fCompl; }
-static inline int Kit_DsdLit2Var( int Lit ) { return Lit >> 1; }
-static inline int Kit_DsdLitIsCompl( int Lit ) { return Lit & 1; }
-static inline int Kit_DsdLitNot( int Lit ) { return Lit ^ 1; }
-static inline int Kit_DsdLitNotCond( int Lit, int c ) { return Lit ^ (int)(c > 0); }
-static inline int Kit_DsdLitRegular( int Lit ) { return Lit & 0xfe; }
-
-static inline unsigned Kit_DsdObjOffset( int nFans ) { return (nFans >> 2) + ((nFans & 3) > 0); }
-static inline unsigned * Kit_DsdObjTruth( Kit_DsdObj_t * pObj ) { return pObj->Type == KIT_DSD_PRIME ? (unsigned *)pObj->pFans + pObj->Offset: NULL; }
-static inline int Kit_DsdNtkObjNum( Kit_DsdNtk_t * pNtk ){ return pNtk->nVars + pNtk->nNodes; }
-static inline Kit_DsdObj_t * Kit_DsdNtkObj( Kit_DsdNtk_t * pNtk, int Id ) { assert( Id >= 0 && Id < pNtk->nVars + pNtk->nNodes ); return Id < pNtk->nVars ? NULL : pNtk->pNodes[Id - pNtk->nVars]; }
-static inline Kit_DsdObj_t * Kit_DsdNtkRoot( Kit_DsdNtk_t * pNtk ) { return Kit_DsdNtkObj( pNtk, Kit_DsdLit2Var(pNtk->Root) ); }
-static inline int Kit_DsdLitIsLeaf( Kit_DsdNtk_t * pNtk, int Lit ) { int Id = Kit_DsdLit2Var(Lit); assert( Id >= 0 && Id < pNtk->nVars + pNtk->nNodes ); return Id < pNtk->nVars; }
-static inline unsigned Kit_DsdLitSupport( Kit_DsdNtk_t * pNtk, int Lit ) { int Id = Kit_DsdLit2Var(Lit); assert( Id >= 0 && Id < pNtk->nVars + pNtk->nNodes ); return pNtk->pSupps? (Id < pNtk->nVars? (1 << Id) : pNtk->pSupps[Id - pNtk->nVars]) : 0; }
-
-#define Kit_DsdNtkForEachObj( pNtk, pObj, i ) \
- for ( i = 0; (i < (pNtk)->nNodes) && ((pObj) = (pNtk)->pNodes[i]); i++ )
-#define Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i ) \
- for ( i = 0; (i < (int)(pObj)->nFans) && ((iLit) = (pObj)->pFans[i], 1); i++ )
-#define Kit_DsdObjForEachFaninReverse( pNtk, pObj, iLit, i ) \
- for ( i = (int)(pObj)->nFans - 1; (i >= 0) && ((iLit) = (pObj)->pFans[i], 1); i-- )
-
-#define Kit_PlaForEachCube( pSop, nFanins, pCube ) \
- for ( pCube = (pSop); *pCube; pCube += (nFanins) + 3 )
-#define Kit_PlaCubeForEachVar( pCube, Value, i ) \
- for ( i = 0; (pCube[i] != ' ') && (Value = pCube[i]); i++ )
-
-////////////////////////////////////////////////////////////////////////
-/// MACRO DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-#define KIT_MIN(a,b) (((a) < (b))? (a) : (b))
-#define KIT_MAX(a,b) (((a) > (b))? (a) : (b))
-#define KIT_INFINITY (100000000)
-
-static inline int Kit_CubeHasLit( unsigned uCube, int i ) { return(uCube & (unsigned)(1<<i)) > 0; }
-static inline unsigned Kit_CubeSetLit( unsigned uCube, int i ) { return uCube | (unsigned)(1<<i); }
-static inline unsigned Kit_CubeXorLit( unsigned uCube, int i ) { return uCube ^ (unsigned)(1<<i); }
-static inline unsigned Kit_CubeRemLit( unsigned uCube, int i ) { return uCube & ~(unsigned)(1<<i); }
-
-static inline int Kit_CubeContains( unsigned uLarge, unsigned uSmall ) { return (uLarge & uSmall) == uSmall; }
-static inline unsigned Kit_CubeSharp( unsigned uCube, unsigned uMask ) { return uCube & ~uMask; }
-static inline unsigned Kit_CubeMask( int nVar ) { return (~(unsigned)0) >> (32-nVar); }
-
-static inline int Kit_CubeIsMarked( unsigned uCube ) { return Kit_CubeHasLit( uCube, 31 ); }
-static inline unsigned Kit_CubeMark( unsigned uCube ) { return Kit_CubeSetLit( uCube, 31 ); }
-static inline unsigned Kit_CubeUnmark( unsigned uCube ) { return Kit_CubeRemLit( uCube, 31 ); }
-
-static inline int Kit_SopCubeNum( Kit_Sop_t * cSop ) { return cSop->nCubes; }
-static inline unsigned Kit_SopCube( Kit_Sop_t * cSop, int i ) { return cSop->pCubes[i]; }
-static inline void Kit_SopShrink( Kit_Sop_t * cSop, int nCubesNew ) { cSop->nCubes = nCubesNew; }
-static inline void Kit_SopPushCube( Kit_Sop_t * cSop, unsigned uCube ) { cSop->pCubes[cSop->nCubes++] = uCube; }
-static inline void Kit_SopWriteCube( Kit_Sop_t * cSop, unsigned uCube, int i ) { cSop->pCubes[i] = uCube; }
-
-static inline Kit_Edge_t Kit_EdgeCreate( int Node, int fCompl ) { Kit_Edge_t eEdge = { fCompl, Node }; return eEdge; }
-static inline unsigned Kit_EdgeToInt( Kit_Edge_t eEdge ) { return (eEdge.Node << 1) | eEdge.fCompl; }
-static inline Kit_Edge_t Kit_IntToEdge( unsigned Edge ) { return Kit_EdgeCreate( Edge >> 1, Edge & 1 ); }
-//static inline unsigned Kit_EdgeToInt_( Kit_Edge_t eEdge ) { return *(unsigned *)&eEdge; }
-//static inline Kit_Edge_t Kit_IntToEdge_( unsigned Edge ) { return *(Kit_Edge_t *)&Edge; }
-static inline unsigned Kit_EdgeToInt_( Kit_Edge_t m ) { union { Kit_Edge_t x; unsigned y; } v; v.x = m; return v.y; }
-static inline Kit_Edge_t Kit_IntToEdge_( unsigned m ) { union { Kit_Edge_t x; unsigned y; } v; v.y = m; return v.x; }
-
-static inline int Kit_GraphIsConst( Kit_Graph_t * pGraph ) { return pGraph->fConst; }
-static inline int Kit_GraphIsConst0( Kit_Graph_t * pGraph ) { return pGraph->fConst && pGraph->eRoot.fCompl; }
-static inline int Kit_GraphIsConst1( Kit_Graph_t * pGraph ) { return pGraph->fConst && !pGraph->eRoot.fCompl; }
-static inline int Kit_GraphIsComplement( Kit_Graph_t * pGraph ) { return pGraph->eRoot.fCompl; }
-static inline int Kit_GraphIsVar( Kit_Graph_t * pGraph ) { return pGraph->eRoot.Node < (unsigned)pGraph->nLeaves; }
-static inline void Kit_GraphComplement( Kit_Graph_t * pGraph ) { pGraph->eRoot.fCompl ^= 1; }
-static inline void Kit_GraphSetRoot( Kit_Graph_t * pGraph, Kit_Edge_t eRoot ) { pGraph->eRoot = eRoot; }
-static inline int Kit_GraphLeaveNum( Kit_Graph_t * pGraph ) { return pGraph->nLeaves; }
-static inline int Kit_GraphNodeNum( Kit_Graph_t * pGraph ) { return pGraph->nSize - pGraph->nLeaves; }
-static inline Kit_Node_t * Kit_GraphNode( Kit_Graph_t * pGraph, int i ) { return pGraph->pNodes + i; }
-static inline Kit_Node_t * Kit_GraphNodeLast( Kit_Graph_t * pGraph ) { return pGraph->pNodes + pGraph->nSize - 1; }
-static inline int Kit_GraphNodeInt( Kit_Graph_t * pGraph, Kit_Node_t * pNode ) { return pNode - pGraph->pNodes; }
-static inline int Kit_GraphNodeIsVar( Kit_Graph_t * pGraph, Kit_Node_t * pNode ) { return Kit_GraphNodeInt(pGraph,pNode) < pGraph->nLeaves; }
-static inline Kit_Node_t * Kit_GraphVar( Kit_Graph_t * pGraph ) { assert( Kit_GraphIsVar( pGraph ) ); return Kit_GraphNode( pGraph, pGraph->eRoot.Node ); }
-static inline int Kit_GraphVarInt( Kit_Graph_t * pGraph ) { assert( Kit_GraphIsVar( pGraph ) ); return Kit_GraphNodeInt( pGraph, Kit_GraphVar(pGraph) ); }
-static inline Kit_Node_t * Kit_GraphNodeFanin0( Kit_Graph_t * pGraph, Kit_Node_t * pNode ){ return Kit_GraphNodeIsVar(pGraph, pNode)? NULL : Kit_GraphNode(pGraph, pNode->eEdge0.Node); }
-static inline Kit_Node_t * Kit_GraphNodeFanin1( Kit_Graph_t * pGraph, Kit_Node_t * pNode ){ return Kit_GraphNodeIsVar(pGraph, pNode)? NULL : Kit_GraphNode(pGraph, pNode->eEdge1.Node); }
-static inline int Kit_GraphRootLevel( Kit_Graph_t * pGraph ) { return Kit_GraphNode(pGraph, pGraph->eRoot.Node)->Level; }
-
-static inline int Kit_SuppIsMinBase( int Supp ) { return (Supp & (Supp+1)) == 0; }
-
-//static inline int Kit_Float2Int( float Val ) { return *((int *)&Val); }
-//static inline float Kit_Int2Float( int Num ) { return *((float *)&Num); }
-static inline int Kit_Float2Int( float Val ) { union { int x; float y; } v; v.y = Val; return v.x; }
-static inline float Kit_Int2Float( int Num ) { union { int x; float y; } v; v.x = Num; return v.y; }
-static inline int Kit_BitWordNum( int nBits ) { return nBits/(8*sizeof(unsigned)) + ((nBits%(8*sizeof(unsigned))) > 0); }
-static inline int Kit_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
-static inline unsigned Kit_BitMask( int nBits ) { assert( nBits <= 32 ); return ~((~(unsigned)0) << nBits); }
-
-static inline void Kit_TruthSetBit( unsigned * p, int Bit ) { p[Bit>>5] |= (1<<(Bit & 31)); }
-static inline void Kit_TruthXorBit( unsigned * p, int Bit ) { p[Bit>>5] ^= (1<<(Bit & 31)); }
-static inline int Kit_TruthHasBit( unsigned * p, int Bit ) { return (p[Bit>>5] & (1<<(Bit & 31))) > 0; }
-
-static inline int Kit_WordFindFirstBit( unsigned uWord )
-{
- int i;
- for ( i = 0; i < 32; i++ )
- if ( uWord & (1 << i) )
- return i;
- return -1;
-}
-static inline int Kit_WordHasOneBit( unsigned uWord )
-{
- return (uWord & (uWord - 1)) == 0;
-}
-static inline int Kit_WordCountOnes( unsigned uWord )
-{
- uWord = (uWord & 0x55555555) + ((uWord>>1) & 0x55555555);
- uWord = (uWord & 0x33333333) + ((uWord>>2) & 0x33333333);
- uWord = (uWord & 0x0F0F0F0F) + ((uWord>>4) & 0x0F0F0F0F);
- uWord = (uWord & 0x00FF00FF) + ((uWord>>8) & 0x00FF00FF);
- return (uWord & 0x0000FFFF) + (uWord>>16);
-}
-static inline int Kit_TruthCountOnes( unsigned * pIn, int nVars )
-{
- int w, Counter = 0;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- Counter += Kit_WordCountOnes(pIn[w]);
- return Counter;
-}
-static inline int Kit_TruthFindFirstBit( unsigned * pIn, int nVars )
-{
- int w;
- for ( w = 0; w < Kit_TruthWordNum(nVars); w++ )
- if ( pIn[w] )
- return 32*w + Kit_WordFindFirstBit(pIn[w]);
- return -1;
-}
-static inline int Kit_TruthFindFirstZero( unsigned * pIn, int nVars )
-{
- int w;
- for ( w = 0; w < Kit_TruthWordNum(nVars); w++ )
- if ( ~pIn[w] )
- return 32*w + Kit_WordFindFirstBit(~pIn[w]);
- return -1;
-}
-static inline int Kit_TruthIsEqual( unsigned * pIn0, unsigned * pIn1, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- if ( pIn0[w] != pIn1[w] )
- return 0;
- return 1;
-}
-static inline int Kit_TruthIsEqualWithCare( unsigned * pIn0, unsigned * pIn1, unsigned * pCare, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- if ( (pIn0[w] & pCare[w]) != (pIn1[w] & pCare[w]) )
- return 0;
- return 1;
-}
-static inline int Kit_TruthIsOpposite( unsigned * pIn0, unsigned * pIn1, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- if ( pIn0[w] != ~pIn1[w] )
- return 0;
- return 1;
-}
-static inline int Kit_TruthIsEqualWithPhase( unsigned * pIn0, unsigned * pIn1, int nVars )
-{
- int w;
- if ( (pIn0[0] & 1) == (pIn1[0] & 1) )
- {
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- if ( pIn0[w] != pIn1[w] )
- return 0;
- }
- else
- {
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- if ( pIn0[w] != ~pIn1[w] )
- return 0;
- }
- return 1;
-}
-static inline int Kit_TruthIsConst0( unsigned * pIn, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- if ( pIn[w] )
- return 0;
- return 1;
-}
-static inline int Kit_TruthIsConst1( unsigned * pIn, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- if ( pIn[w] != ~(unsigned)0 )
- return 0;
- return 1;
-}
-static inline int Kit_TruthIsImply( unsigned * pIn1, unsigned * pIn2, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- if ( pIn1[w] & ~pIn2[w] )
- return 0;
- return 1;
-}
-static inline int Kit_TruthIsDisjoint( unsigned * pIn1, unsigned * pIn2, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- if ( pIn1[w] & pIn2[w] )
- return 0;
- return 1;
-}
-static inline int Kit_TruthIsDisjoint3( unsigned * pIn1, unsigned * pIn2, unsigned * pIn3, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- if ( pIn1[w] & pIn2[w] & pIn3[w] )
- return 0;
- return 1;
-}
-static inline void Kit_TruthCopy( unsigned * pOut, unsigned * pIn, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = pIn[w];
-}
-static inline void Kit_TruthClear( unsigned * pOut, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = 0;
-}
-static inline void Kit_TruthFill( unsigned * pOut, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = ~(unsigned)0;
-}
-static inline void Kit_TruthNot( unsigned * pOut, unsigned * pIn, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = ~pIn[w];
-}
-static inline void Kit_TruthAnd( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = pIn0[w] & pIn1[w];
-}
-static inline void Kit_TruthOr( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = pIn0[w] | pIn1[w];
-}
-static inline void Kit_TruthXor( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = pIn0[w] ^ pIn1[w];
-}
-static inline void Kit_TruthSharp( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = pIn0[w] & ~pIn1[w];
-}
-static inline void Kit_TruthNand( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = ~(pIn0[w] & pIn1[w]);
-}
-static inline void Kit_TruthAndPhase( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars, int fCompl0, int fCompl1 )
-{
- int w;
- if ( fCompl0 && fCompl1 )
- {
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = ~(pIn0[w] | pIn1[w]);
- }
- else if ( fCompl0 && !fCompl1 )
- {
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = ~pIn0[w] & pIn1[w];
- }
- else if ( !fCompl0 && fCompl1 )
- {
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = pIn0[w] & ~pIn1[w];
- }
- else // if ( !fCompl0 && !fCompl1 )
- {
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = pIn0[w] & pIn1[w];
- }
-}
-static inline void Kit_TruthOrPhase( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars, int fCompl0, int fCompl1 )
-{
- int w;
- if ( fCompl0 && fCompl1 )
- {
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = ~(pIn0[w] & pIn1[w]);
- }
- else if ( fCompl0 && !fCompl1 )
- {
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = ~pIn0[w] | pIn1[w];
- }
- else if ( !fCompl0 && fCompl1 )
- {
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = pIn0[w] | ~pIn1[w];
- }
- else // if ( !fCompl0 && !fCompl1 )
- {
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = pIn0[w] | pIn1[w];
- }
-}
-static inline void Kit_TruthMux( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, unsigned * pCtrl, int nVars )
-{
- int w;
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = (pIn0[w] & ~pCtrl[w]) | (pIn1[w] & pCtrl[w]);
-}
-static inline void Kit_TruthMuxPhase( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, unsigned * pCtrl, int nVars, int fComp0 )
-{
- int w;
- if ( fComp0 )
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = (~pIn0[w] & ~pCtrl[w]) | (pIn1[w] & pCtrl[w]);
- else
- for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
- pOut[w] = (pIn0[w] & ~pCtrl[w]) | (pIn1[w] & pCtrl[w]);
-}
-static inline void Kit_TruthIthVar( unsigned * pTruth, int nVars, int iVar )
-{
- unsigned Masks[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
- int k, nWords = (nVars <= 5 ? 1 : (1 << (nVars - 5)));
- if ( iVar < 5 )
- {
- for ( k = 0; k < nWords; k++ )
- pTruth[k] = Masks[iVar];
- }
- else
- {
- for ( k = 0; k < nWords; k++ )
- if ( k & (1 << (iVar-5)) )
- pTruth[k] = ~(unsigned)0;
- else
- pTruth[k] = 0;
- }
-}
-
-
-////////////////////////////////////////////////////////////////////////
-/// ITERATORS ///
-////////////////////////////////////////////////////////////////////////
-
-#define Kit_SopForEachCube( cSop, uCube, i ) \
- for ( i = 0; (i < Kit_SopCubeNum(cSop)) && ((uCube) = Kit_SopCube(cSop, i)); i++ )
-#define Kit_CubeForEachLiteral( uCube, Lit, nLits, i ) \
- for ( i = 0; (i < (nLits)) && ((Lit) = Kit_CubeHasLit(uCube, i)); i++ )
-
-#define Kit_GraphForEachLeaf( pGraph, pLeaf, i ) \
- for ( i = 0; (i < (pGraph)->nLeaves) && (((pLeaf) = Kit_GraphNode(pGraph, i)), 1); i++ )
-#define Kit_GraphForEachNode( pGraph, pAnd, i ) \
- for ( i = (pGraph)->nLeaves; (i < (pGraph)->nSize) && (((pAnd) = Kit_GraphNode(pGraph, i)), 1); i++ )
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/*=== kitBdd.c ==========================================================*/
-extern DdNode * Kit_SopToBdd( DdManager * dd, Kit_Sop_t * cSop, int nVars );
-extern DdNode * Kit_GraphToBdd( DdManager * dd, Kit_Graph_t * pGraph );
-extern DdNode * Kit_TruthToBdd( DdManager * dd, unsigned * pTruth, int nVars, int fMSBonTop );
-/*=== kitCloud.c ==========================================================*/
-extern CloudNode * Kit_TruthToCloud( CloudManager * dd, unsigned * pTruth, int nVars );
-extern unsigned * Kit_CloudToTruth( Vec_Int_t * vNodes, int nVars, Vec_Ptr_t * vStore, int fInv );
-extern int Kit_CreateCloud( CloudManager * dd, CloudNode * pFunc, Vec_Int_t * vNodes );
-extern int Kit_CreateCloudFromTruth( CloudManager * dd, unsigned * pTruth, int nVars, Vec_Int_t * vNodes );
-extern unsigned * Kit_TruthCompose( CloudManager * dd, unsigned * pTruth, int nVars, unsigned ** pInputs, int nVarsAll, Vec_Ptr_t * vStore, Vec_Int_t * vNodes );
-extern void Kit_TruthCofSupports( Vec_Int_t * vBddDir, Vec_Int_t * vBddInv, int nVars, Vec_Int_t * vMemory, unsigned * puSupps );
-/*=== kitDsd.c ==========================================================*/
-extern Kit_DsdMan_t * Kit_DsdManAlloc( int nVars, int nNodes );
-extern void Kit_DsdManFree( Kit_DsdMan_t * p );
-extern Kit_DsdNtk_t * Kit_DsdDeriveNtk( unsigned * pTruth, int nVars, int nLutSize );
-extern unsigned * Kit_DsdTruthCompute( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk );
-extern void Kit_DsdTruth( Kit_DsdNtk_t * pNtk, unsigned * pTruthRes );
-extern void Kit_DsdTruthPartial( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, unsigned * pTruthRes, unsigned uSupp );
-extern void Kit_DsdTruthPartialTwo( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, unsigned uSupp, int iVar, unsigned * pTruthCo, unsigned * pTruthDec );
-extern void Kit_DsdPrint( FILE * pFile, Kit_DsdNtk_t * pNtk );
-extern void Kit_DsdPrintExpanded( Kit_DsdNtk_t * pNtk );
-extern void Kit_DsdPrintFromTruth( unsigned * pTruth, int nVars );
-extern void Kit_DsdPrintFromTruth2( FILE * pFile, unsigned * pTruth, int nVars );
-extern void Kit_DsdWriteFromTruth( char * pBuffer, unsigned * pTruth, int nVars );
-extern Kit_DsdNtk_t * Kit_DsdDecompose( unsigned * pTruth, int nVars );
-extern Kit_DsdNtk_t * Kit_DsdDecomposeExpand( unsigned * pTruth, int nVars );
-extern Kit_DsdNtk_t * Kit_DsdDecomposeMux( unsigned * pTruth, int nVars, int nDecMux );
-extern void Kit_DsdVerify( Kit_DsdNtk_t * pNtk, unsigned * pTruth, int nVars );
-extern void Kit_DsdNtkFree( Kit_DsdNtk_t * pNtk );
-extern int Kit_DsdNonDsdSizeMax( Kit_DsdNtk_t * pNtk );
-extern Kit_DsdObj_t * Kit_DsdNonDsdPrimeMax( Kit_DsdNtk_t * pNtk );
-extern unsigned Kit_DsdNonDsdSupports( Kit_DsdNtk_t * pNtk );
-extern unsigned Kit_DsdGetSupports( Kit_DsdNtk_t * p );
-extern Kit_DsdNtk_t * Kit_DsdExpand( Kit_DsdNtk_t * p );
-extern Kit_DsdNtk_t * Kit_DsdShrink( Kit_DsdNtk_t * p, int pPrios[] );
-extern void Kit_DsdRotate( Kit_DsdNtk_t * p, int pFreqs[] );
-extern int Kit_DsdCofactoring( unsigned * pTruth, int nVars, int * pCofVars, int nLimit, int fVerbose );
-/*=== kitFactor.c ==========================================================*/
-extern Kit_Graph_t * Kit_SopFactor( Vec_Int_t * vCover, int fCompl, int nVars, Vec_Int_t * vMemory );
-/*=== kitGraph.c ==========================================================*/
-extern Kit_Graph_t * Kit_GraphCreate( int nLeaves );
-extern Kit_Graph_t * Kit_GraphCreateConst0();
-extern Kit_Graph_t * Kit_GraphCreateConst1();
-extern Kit_Graph_t * Kit_GraphCreateLeaf( int iLeaf, int nLeaves, int fCompl );
-extern void Kit_GraphFree( Kit_Graph_t * pGraph );
-extern Kit_Node_t * Kit_GraphAppendNode( Kit_Graph_t * pGraph );
-extern Kit_Edge_t Kit_GraphAddNodeAnd( Kit_Graph_t * pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1 );
-extern Kit_Edge_t Kit_GraphAddNodeOr( Kit_Graph_t * pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1 );
-extern Kit_Edge_t Kit_GraphAddNodeXor( Kit_Graph_t * pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1, int Type );
-extern Kit_Edge_t Kit_GraphAddNodeMux( Kit_Graph_t * pGraph, Kit_Edge_t eEdgeC, Kit_Edge_t eEdgeT, Kit_Edge_t eEdgeE, int Type );
-extern unsigned Kit_GraphToTruth( Kit_Graph_t * pGraph );
-extern Kit_Graph_t * Kit_TruthToGraph( unsigned * pTruth, int nVars, Vec_Int_t * vMemory );
-extern int Kit_GraphLeafDepth_rec( Kit_Graph_t * pGraph, Kit_Node_t * pNode, Kit_Node_t * pLeaf );
-/*=== kitHop.c ==========================================================*/
-//extern Hop_Obj_t * Kit_GraphToHop( Hop_Man_t * pMan, Kit_Graph_t * pGraph );
-//extern Hop_Obj_t * Kit_TruthToHop( Hop_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory );
-//extern Hop_Obj_t * Kit_CoverToHop( Hop_Man_t * pMan, Vec_Int_t * vCover, int nVars, Vec_Int_t * vMemory );
-/*=== kitIsop.c ==========================================================*/
-extern int Kit_TruthIsop( unsigned * puTruth, int nVars, Vec_Int_t * vMemory, int fTryBoth );
-/*=== kitPla.c ==========================================================*/
-extern int Kit_PlaIsConst0( char * pSop );
-extern int Kit_PlaIsConst1( char * pSop );
-extern int Kit_PlaIsBuf( char * pSop );
-extern int Kit_PlaIsInv( char * pSop );
-extern int Kit_PlaGetVarNum( char * pSop );
-extern int Kit_PlaGetCubeNum( char * pSop );
-extern int Kit_PlaIsComplement( char * pSop );
-extern void Kit_PlaComplement( char * pSop );
-extern char * Kit_PlaStart( void * p, int nCubes, int nVars );
-extern char * Kit_PlaCreateFromIsop( void * p, int nVars, Vec_Int_t * vCover );
-extern void Kit_PlaToIsop( char * pSop, Vec_Int_t * vCover );
-extern char * Kit_PlaStoreSop( void * p, char * pSop );
-extern char * Kit_PlaFromTruth( void * p, unsigned * pTruth, int nVars, Vec_Int_t * vCover );
-extern char * Kit_PlaFromTruthNew( unsigned * pTruth, int nVars, Vec_Int_t * vCover, Vec_Str_t * vStr );
-extern ABC_UINT64_T Kit_PlaToTruth6( char * pSop, int nVars );
-extern void Kit_PlaToTruth( char * pSop, int nVars, Vec_Ptr_t * vVars, unsigned * pTemp, unsigned * pTruth );
-/*=== kitSop.c ==========================================================*/
-extern void Kit_SopCreate( Kit_Sop_t * cResult, Vec_Int_t * vInput, int nVars, Vec_Int_t * vMemory );
-extern void Kit_SopCreateInverse( Kit_Sop_t * cResult, Vec_Int_t * vInput, int nVars, Vec_Int_t * vMemory );
-extern void Kit_SopDup( Kit_Sop_t * cResult, Kit_Sop_t * cSop, Vec_Int_t * vMemory );
-extern void Kit_SopDivideByLiteralQuo( Kit_Sop_t * cSop, int iLit );
-extern void Kit_SopDivideByCube( Kit_Sop_t * cSop, Kit_Sop_t * cDiv, Kit_Sop_t * vQuo, Kit_Sop_t * vRem, Vec_Int_t * vMemory );
-extern void Kit_SopDivideInternal( Kit_Sop_t * cSop, Kit_Sop_t * cDiv, Kit_Sop_t * vQuo, Kit_Sop_t * vRem, Vec_Int_t * vMemory );
-extern void Kit_SopMakeCubeFree( Kit_Sop_t * cSop );
-extern int Kit_SopIsCubeFree( Kit_Sop_t * cSop );
-extern void Kit_SopCommonCubeCover( Kit_Sop_t * cResult, Kit_Sop_t * cSop, Vec_Int_t * vMemory );
-extern int Kit_SopAnyLiteral( Kit_Sop_t * cSop, int nLits );
-extern int Kit_SopDivisor( Kit_Sop_t * cResult, Kit_Sop_t * cSop, int nLits, Vec_Int_t * vMemory );
-extern void Kit_SopBestLiteralCover( Kit_Sop_t * cResult, Kit_Sop_t * cSop, unsigned uCube, int nLits, Vec_Int_t * vMemory );
-/*=== kitTruth.c ==========================================================*/
-extern void Kit_TruthSwapAdjacentVars( unsigned * pOut, unsigned * pIn, int nVars, int Start );
-extern void Kit_TruthStretch( unsigned * pOut, unsigned * pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn );
-extern void Kit_TruthPermute( unsigned * pOut, unsigned * pIn, int nVars, char * pPerm, int fReturnIn );
-extern void Kit_TruthShrink( unsigned * pOut, unsigned * pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn );
-extern int Kit_TruthVarInSupport( unsigned * pTruth, int nVars, int iVar );
-extern int Kit_TruthSupportSize( unsigned * pTruth, int nVars );
-extern unsigned Kit_TruthSupport( unsigned * pTruth, int nVars );
-extern void Kit_TruthCofactor0( unsigned * pTruth, int nVars, int iVar );
-extern void Kit_TruthCofactor1( unsigned * pTruth, int nVars, int iVar );
-extern void Kit_TruthCofactor0New( unsigned * pOut, unsigned * pIn, int nVars, int iVar );
-extern void Kit_TruthCofactor1New( unsigned * pOut, unsigned * pIn, int nVars, int iVar );
-extern int Kit_TruthVarIsVacuous( unsigned * pOnset, unsigned * pOffset, int nVars, int iVar );
-extern void Kit_TruthExist( unsigned * pTruth, int nVars, int iVar );
-extern void Kit_TruthExistNew( unsigned * pRes, unsigned * pTruth, int nVars, int iVar );
-extern void Kit_TruthExistSet( unsigned * pRes, unsigned * pTruth, int nVars, unsigned uMask );
-extern void Kit_TruthForall( unsigned * pTruth, int nVars, int iVar );
-extern void Kit_TruthForallNew( unsigned * pRes, unsigned * pTruth, int nVars, int iVar );
-extern void Kit_TruthForallSet( unsigned * pRes, unsigned * pTruth, int nVars, unsigned uMask );
-extern void Kit_TruthUniqueNew( unsigned * pRes, unsigned * pTruth, int nVars, int iVar );
-extern void Kit_TruthMuxVar( unsigned * pOut, unsigned * pCof0, unsigned * pCof1, int nVars, int iVar );
-extern void Kit_TruthMuxVarPhase( unsigned * pOut, unsigned * pCof0, unsigned * pCof1, int nVars, int iVar, int fCompl0 );
-extern void Kit_TruthChangePhase( unsigned * pTruth, int nVars, int iVar );
-extern int Kit_TruthVarsSymm( unsigned * pTruth, int nVars, int iVar0, int iVar1, unsigned * pCof0, unsigned * pCof1 );
-extern int Kit_TruthVarsAntiSymm( unsigned * pTruth, int nVars, int iVar0, int iVar1, unsigned * pCof0, unsigned * pCof1 );
-extern int Kit_TruthMinCofSuppOverlap( unsigned * pTruth, int nVars, int * pVarMin );
-extern int Kit_TruthBestCofVar( unsigned * pTruth, int nVars, unsigned * pCof0, unsigned * pCof1 );
-extern void Kit_TruthCountOnesInCofs( unsigned * pTruth, int nVars, short * pStore );
-extern void Kit_TruthCountOnesInCofs0( unsigned * pTruth, int nVars, short * pStore );
-extern void Kit_TruthCountOnesInCofsSlow( unsigned * pTruth, int nVars, short * pStore, unsigned * pAux );
-extern unsigned Kit_TruthHash( unsigned * pIn, int nWords );
-extern unsigned Kit_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux, int nVars, char * pCanonPerm, short * pStore );
-extern char * Kit_TruthDumpToFile( unsigned * pTruth, int nVars, int nFile );
-extern void Kit_TruthPrintProfile( unsigned * pTruth, int nVars );
-
-
-
-ABC_NAMESPACE_HEADER_END
-
-
-
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
diff --git a/src/aig/kit/kitAig.c b/src/aig/kit/kitAig.c
deleted file mode 100644
index 88f17fc2..00000000
--- a/src/aig/kit/kitAig.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kitAig.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis [Procedures involving AIGs.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - Dec 6, 2006.]
-
- Revision [$Id: kitAig.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "kit.h"
-#include "aig.h"
-
-ABC_NAMESPACE_IMPL_START
-
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Transforms the decomposition graph into the AIG.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Kit_GraphToAigInternal( Aig_Man_t * pMan, Kit_Graph_t * pGraph )
-{
- Kit_Node_t * pNode = NULL;
- Aig_Obj_t * pAnd0, * pAnd1;
- int i;
- // check for constant function
- if ( Kit_GraphIsConst(pGraph) )
- return Aig_NotCond( Aig_ManConst1(pMan), Kit_GraphIsComplement(pGraph) );
- // check for a literal
- if ( Kit_GraphIsVar(pGraph) )
- return Aig_NotCond( (Aig_Obj_t *)Kit_GraphVar(pGraph)->pFunc, Kit_GraphIsComplement(pGraph) );
- // build the AIG nodes corresponding to the AND gates of the graph
- Kit_GraphForEachNode( pGraph, pNode, i )
- {
- pAnd0 = Aig_NotCond( (Aig_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
- pAnd1 = Aig_NotCond( (Aig_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
- pNode->pFunc = Aig_And( pMan, pAnd0, pAnd1 );
- }
- // complement the result if necessary
- return Aig_NotCond( (Aig_Obj_t *)pNode->pFunc, Kit_GraphIsComplement(pGraph) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Strashes one logic node using its SOP.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Kit_GraphToAig( Aig_Man_t * pMan, Aig_Obj_t ** pFanins, Kit_Graph_t * pGraph )
-{
- Kit_Node_t * pNode = NULL;
- int i;
- // collect the fanins
- Kit_GraphForEachLeaf( pGraph, pNode, i )
- pNode->pFunc = pFanins[i];
- // perform strashing
- return Kit_GraphToAigInternal( pMan, pGraph );
-}
-
-/**Function*************************************************************
-
- Synopsis [Strashed onen logic nodes using its truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Kit_TruthToAig( Aig_Man_t * pMan, Aig_Obj_t ** pFanins, unsigned * pTruth, int nVars, Vec_Int_t * vMemory )
-{
- Aig_Obj_t * pObj;
- Kit_Graph_t * pGraph;
- // transform truth table into the decomposition tree
- if ( vMemory == NULL )
- {
- vMemory = Vec_IntAlloc( 0 );
- pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
- Vec_IntFree( vMemory );
- }
- else
- pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
- // derive the AIG for the decomposition tree
- pObj = Kit_GraphToAig( pMan, pFanins, pGraph );
- Kit_GraphFree( pGraph );
- return pObj;
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
-ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/kitBdd.c b/src/aig/kit/kitBdd.c
deleted file mode 100644
index 1b24ac24..00000000
--- a/src/aig/kit/kitBdd.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kitBdd.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis [Procedures involving BDDs.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - Dec 6, 2006.]
-
- Revision [$Id: kitBdd.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "kit.h"
-#include "extra.h"
-
-ABC_NAMESPACE_IMPL_START
-
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Derives the BDD for the given SOP.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-DdNode * Kit_SopToBdd( DdManager * dd, Kit_Sop_t * cSop, int nVars )
-{
- DdNode * bSum, * bCube, * bTemp, * bVar;
- unsigned uCube;
- int Value, i, v;
- assert( nVars < 16 );
- // start the cover
- bSum = Cudd_ReadLogicZero(dd); Cudd_Ref( bSum );
- // check the logic function of the node
- Kit_SopForEachCube( cSop, uCube, i )
- {
- bCube = Cudd_ReadOne(dd); Cudd_Ref( bCube );
- for ( v = 0; v < nVars; v++ )
- {
- Value = ((uCube >> 2*v) & 3);
- if ( Value == 1 )
- bVar = Cudd_Not( Cudd_bddIthVar( dd, v ) );
- else if ( Value == 2 )
- bVar = Cudd_bddIthVar( dd, v );
- else
- continue;
- bCube = Cudd_bddAnd( dd, bTemp = bCube, bVar ); Cudd_Ref( bCube );
- Cudd_RecursiveDeref( dd, bTemp );
- }
- bSum = Cudd_bddOr( dd, bTemp = bSum, bCube );
- Cudd_Ref( bSum );
- Cudd_RecursiveDeref( dd, bTemp );
- Cudd_RecursiveDeref( dd, bCube );
- }
- // complement the result if necessary
- Cudd_Deref( bSum );
- return bSum;
-}
-
-/**Function*************************************************************
-
- Synopsis [Converts graph to BDD.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-DdNode * Kit_GraphToBdd( DdManager * dd, Kit_Graph_t * pGraph )
-{
- DdNode * bFunc, * bFunc0, * bFunc1;
- Kit_Node_t * pNode = NULL; // Suppress "might be used uninitialized"
- int i;
-
- // sanity checks
- assert( Kit_GraphLeaveNum(pGraph) >= 0 );
- assert( Kit_GraphLeaveNum(pGraph) <= pGraph->nSize );
-
- // check for constant function
- if ( Kit_GraphIsConst(pGraph) )
- return Cudd_NotCond( b1, Kit_GraphIsComplement(pGraph) );
- // check for a literal
- if ( Kit_GraphIsVar(pGraph) )
- return Cudd_NotCond( Cudd_bddIthVar(dd, Kit_GraphVarInt(pGraph)), Kit_GraphIsComplement(pGraph) );
-
- // assign the elementary variables
- Kit_GraphForEachLeaf( pGraph, pNode, i )
- pNode->pFunc = Cudd_bddIthVar( dd, i );
-
- // compute the function for each internal node
- Kit_GraphForEachNode( pGraph, pNode, i )
- {
- bFunc0 = Cudd_NotCond( Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
- bFunc1 = Cudd_NotCond( Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
- pNode->pFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( (DdNode *)pNode->pFunc );
- }
-
- // deref the intermediate results
- bFunc = (DdNode *)pNode->pFunc; Cudd_Ref( bFunc );
- Kit_GraphForEachNode( pGraph, pNode, i )
- Cudd_RecursiveDeref( dd, (DdNode *)pNode->pFunc );
- Cudd_Deref( bFunc );
-
- // complement the result if necessary
- return Cudd_NotCond( bFunc, Kit_GraphIsComplement(pGraph) );
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-DdNode * Kit_TruthToBdd_rec( DdManager * dd, unsigned * pTruth, int iBit, int nVars, int nVarsTotal, int fMSBonTop )
-{
- DdNode * bF0, * bF1, * bF;
- int Var;
- if ( nVars <= 5 )
- {
- unsigned uTruth, uMask;
- uMask = ((~(unsigned)0) >> (32 - (1<<nVars)));
- uTruth = (pTruth[iBit>>5] >> (iBit&31)) & uMask;
- if ( uTruth == 0 )
- return b0;
- if ( uTruth == uMask )
- return b1;
- }
- // find the variable to use
- Var = fMSBonTop? nVarsTotal-nVars : nVars-1;
- // other special cases can be added
- bF0 = Kit_TruthToBdd_rec( dd, pTruth, iBit, nVars-1, nVarsTotal, fMSBonTop ); Cudd_Ref( bF0 );
- bF1 = Kit_TruthToBdd_rec( dd, pTruth, iBit+(1<<(nVars-1)), nVars-1, nVarsTotal, fMSBonTop ); Cudd_Ref( bF1 );
- bF = Cudd_bddIte( dd, dd->vars[Var], bF1, bF0 ); Cudd_Ref( bF );
- Cudd_RecursiveDeref( dd, bF0 );
- Cudd_RecursiveDeref( dd, bF1 );
- Cudd_Deref( bF );
- return bF;
-}
-
-/**Function*************************************************************
-
- Synopsis [Compute BDD corresponding to the truth table.]
-
- Description [If truth table has N vars, the BDD depends on N topmost
- variables of the BDD manager. The most significant variable of the table
- is encoded by the topmost variable of the manager. BDD construction is
- efficient in this case because BDD is constructed one node at a time,
- by simply adding BDD nodes on top of existent BDD nodes.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-DdNode * Kit_TruthToBdd( DdManager * dd, unsigned * pTruth, int nVars, int fMSBonTop )
-{
- return Kit_TruthToBdd_rec( dd, pTruth, 0, nVars, nVars, fMSBonTop );
-}
-
-/**Function*************************************************************
-
- Synopsis [Verifies that the factoring is correct.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_SopFactorVerify( Vec_Int_t * vCover, Kit_Graph_t * pFForm, int nVars )
-{
- static DdManager * dd = NULL;
- Kit_Sop_t Sop, * cSop = &Sop;
- DdNode * bFunc1, * bFunc2;
- Vec_Int_t * vMemory;
- int RetValue;
- // get the manager
- if ( dd == NULL )
- dd = Cudd_Init( 16, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
- // derive SOP
- vMemory = Vec_IntAlloc( Vec_IntSize(vCover) );
- Kit_SopCreate( cSop, vCover, nVars, vMemory );
- // get the functions
- bFunc1 = Kit_SopToBdd( dd, cSop, nVars ); Cudd_Ref( bFunc1 );
- bFunc2 = Kit_GraphToBdd( dd, pFForm ); Cudd_Ref( bFunc2 );
-//Extra_bddPrint( dd, bFunc1 ); printf("\n");
-//Extra_bddPrint( dd, bFunc2 ); printf("\n");
- RetValue = (bFunc1 == bFunc2);
- if ( bFunc1 != bFunc2 )
- {
- int s;
- Extra_bddPrint( dd, bFunc1 ); printf("\n");
- Extra_bddPrint( dd, bFunc2 ); printf("\n");
- s = 0;
- }
- Cudd_RecursiveDeref( dd, bFunc1 );
- Cudd_RecursiveDeref( dd, bFunc2 );
- Vec_IntFree( vMemory );
- return RetValue;
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
-ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/kitCloud.c b/src/aig/kit/kitCloud.c
deleted file mode 100644
index dea56749..00000000
--- a/src/aig/kit/kitCloud.c
+++ /dev/null
@@ -1,378 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kitCloud.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis [Procedures using BDD package CLOUD.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - Dec 6, 2006.]
-
- Revision [$Id: kitCloud.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "kit.h"
-
-ABC_NAMESPACE_IMPL_START
-
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-// internal representation of the function to be decomposed
-typedef struct Kit_Mux_t_ Kit_Mux_t;
-struct Kit_Mux_t_
-{
- unsigned v : 5; // variable
- unsigned t : 12; // then edge
- unsigned e : 12; // else edge
- unsigned c : 1; // complemented attr of else edge
- unsigned i : 1; // complemented attr of top node
-};
-
-static inline int Kit_Mux2Int( Kit_Mux_t m ) { union { Kit_Mux_t x; int y; } v; v.x = m; return v.y; }
-static inline Kit_Mux_t Kit_Int2Mux( int m ) { union { Kit_Mux_t x; int y; } v; v.y = m; return v.x; }
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Derive BDD from the truth table for 5 variable functions.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-CloudNode * Kit_TruthToCloud5_rec( CloudManager * dd, unsigned uTruth, int nVars, int nVarsAll )
-{
- static unsigned uVars[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
- CloudNode * pCof0, * pCof1;
- unsigned uCof0, uCof1;
- assert( nVars <= 5 );
- if ( uTruth == 0 )
- return dd->zero;
- if ( uTruth == ~0 )
- return dd->one;
- if ( nVars == 1 )
- {
- if ( uTruth == uVars[0] )
- return dd->vars[nVarsAll-1];
- if ( uTruth == ~uVars[0] )
- return Cloud_Not(dd->vars[nVarsAll-1]);
- assert( 0 );
- }
-// Count++;
- assert( nVars > 1 );
- uCof0 = uTruth & ~uVars[nVars-1];
- uCof1 = uTruth & uVars[nVars-1];
- uCof0 |= uCof0 << (1<<(nVars-1));
- uCof1 |= uCof1 >> (1<<(nVars-1));
- if ( uCof0 == uCof1 )
- return Kit_TruthToCloud5_rec( dd, uCof0, nVars - 1, nVarsAll );
- if ( uCof0 == ~uCof1 )
- {
- pCof0 = Kit_TruthToCloud5_rec( dd, uCof0, nVars - 1, nVarsAll );
- pCof1 = Cloud_Not( pCof0 );
- }
- else
- {
- pCof0 = Kit_TruthToCloud5_rec( dd, uCof0, nVars - 1, nVarsAll );
- pCof1 = Kit_TruthToCloud5_rec( dd, uCof1, nVars - 1, nVarsAll );
- }
- return Cloud_MakeNode( dd, nVarsAll - nVars, pCof1, pCof0 );
-}
-
-/**Function********************************************************************
-
- Synopsis [Compute BDD for the truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-CloudNode * Kit_TruthToCloud_rec( CloudManager * dd, unsigned * pTruth, int nVars, int nVarsAll )
-{
- CloudNode * pCof0, * pCof1;
- unsigned * pTruth0, * pTruth1;
- if ( nVars <= 5 )
- return Kit_TruthToCloud5_rec( dd, pTruth[0], nVars, nVarsAll );
- if ( Kit_TruthIsConst0(pTruth, nVars) )
- return dd->zero;
- if ( Kit_TruthIsConst1(pTruth, nVars) )
- return dd->one;
-// Count++;
- pTruth0 = pTruth;
- pTruth1 = pTruth + Kit_TruthWordNum(nVars-1);
- if ( Kit_TruthIsEqual( pTruth0, pTruth1, nVars - 1 ) )
- return Kit_TruthToCloud_rec( dd, pTruth0, nVars - 1, nVarsAll );
- if ( Kit_TruthIsOpposite( pTruth0, pTruth1, nVars - 1 ) )
- {
- pCof0 = Kit_TruthToCloud_rec( dd, pTruth0, nVars - 1, nVarsAll );
- pCof1 = Cloud_Not( pCof0 );
- }
- else
- {
- pCof0 = Kit_TruthToCloud_rec( dd, pTruth0, nVars - 1, nVarsAll );
- pCof1 = Kit_TruthToCloud_rec( dd, pTruth1, nVars - 1, nVarsAll );
- }
- return Cloud_MakeNode( dd, nVarsAll - nVars, pCof1, pCof0 );
-}
-
-/**Function********************************************************************
-
- Synopsis [Compute BDD for the truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-CloudNode * Kit_TruthToCloud( CloudManager * dd, unsigned * pTruth, int nVars )
-{
- CloudNode * pRes;
- pRes = Kit_TruthToCloud_rec( dd, pTruth, nVars, nVars );
-// printf( "%d/%d ", Count, Cloud_DagSize(dd, pRes) );
- return pRes;
-}
-
-/**Function********************************************************************
-
- Synopsis [Transforms the array of BDDs into the integer array.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-int Kit_CreateCloud( CloudManager * dd, CloudNode * pFunc, Vec_Int_t * vNodes )
-{
- Kit_Mux_t Mux;
- int nNodes, i;
- // collect BDD nodes
- nNodes = Cloud_DagCollect( dd, pFunc );
- if ( nNodes >= (1<<12) ) // because in Kit_Mux_t edge is 12 bit
- return 0;
- assert( nNodes == Cloud_DagSize( dd, pFunc ) );
- assert( nNodes < dd->nNodesLimit );
- Vec_IntClear( vNodes );
- Vec_IntPush( vNodes, 0 ); // const1 node
- dd->ppNodes[0]->s = 0;
- for ( i = 1; i < nNodes; i++ )
- {
- dd->ppNodes[i]->s = i;
- Mux.v = dd->ppNodes[i]->v;
- Mux.t = dd->ppNodes[i]->t->s;
- Mux.e = Cloud_Regular(dd->ppNodes[i]->e)->s;
- Mux.c = Cloud_IsComplement(dd->ppNodes[i]->e);
- Mux.i = (i == nNodes - 1)? Cloud_IsComplement(pFunc) : 0;
- // put the MUX into the array
- Vec_IntPush( vNodes, Kit_Mux2Int(Mux) );
- }
- assert( Vec_IntSize(vNodes) == nNodes );
- // reset signatures
- for ( i = 0; i < nNodes; i++ )
- dd->ppNodes[i]->s = dd->nSignCur;
- return 1;
-}
-
-/**Function********************************************************************
-
- Synopsis [Transforms the array of BDDs into the integer array.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-int Kit_CreateCloudFromTruth( CloudManager * dd, unsigned * pTruth, int nVars, Vec_Int_t * vNodes )
-{
- CloudNode * pFunc;
- Cloud_Restart( dd );
- pFunc = Kit_TruthToCloud( dd, pTruth, nVars );
- Vec_IntClear( vNodes );
- return Kit_CreateCloud( dd, pFunc, vNodes );
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes composition of truth tables.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned * Kit_CloudToTruth( Vec_Int_t * vNodes, int nVars, Vec_Ptr_t * vStore, int fInv )
-{
- unsigned * pThis, * pFan0, * pFan1;
- Kit_Mux_t Mux;
- int i, Entry;
- assert( Vec_IntSize(vNodes) <= Vec_PtrSize(vStore) );
- pThis = (unsigned *)Vec_PtrEntry( vStore, 0 );
- Kit_TruthFill( pThis, nVars );
- Vec_IntForEachEntryStart( vNodes, Entry, i, 1 )
- {
- Mux = Kit_Int2Mux(Entry);
- assert( (int)Mux.e < i && (int)Mux.t < i && (int)Mux.v < nVars );
- pFan0 = (unsigned *)Vec_PtrEntry( vStore, Mux.e );
- pFan1 = (unsigned *)Vec_PtrEntry( vStore, Mux.t );
- pThis = (unsigned *)Vec_PtrEntry( vStore, i );
- Kit_TruthMuxVarPhase( pThis, pFan0, pFan1, nVars, fInv? Mux.v : nVars-1-Mux.v, Mux.c );
- }
- // complement the result
- if ( Mux.i )
- Kit_TruthNot( pThis, pThis, nVars );
- return pThis;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes composition of truth tables.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned * Kit_TruthCompose( CloudManager * dd, unsigned * pTruth, int nVars,
- unsigned ** pInputs, int nVarsAll, Vec_Ptr_t * vStore, Vec_Int_t * vNodes )
-{
- CloudNode * pFunc;
- unsigned * pThis, * pFan0, * pFan1;
- Kit_Mux_t Mux;
- int i, Entry, RetValue;
- // derive BDD from truth table
- Cloud_Restart( dd );
- pFunc = Kit_TruthToCloud( dd, pTruth, nVars );
- // convert it into nodes
- RetValue = Kit_CreateCloud( dd, pFunc, vNodes );
- if ( RetValue == 0 )
- printf( "Kit_TruthCompose(): Internal failure!!!\n" );
- // verify the result
-// pFan0 = Kit_CloudToTruth( vNodes, nVars, vStore, 0 );
-// if ( !Kit_TruthIsEqual( pTruth, pFan0, nVars ) )
-// printf( "Failed!\n" );
- // compute truth table from the BDD
- assert( Vec_IntSize(vNodes) <= Vec_PtrSize(vStore) );
- pThis = (unsigned *)Vec_PtrEntry( vStore, 0 );
- Kit_TruthFill( pThis, nVarsAll );
- Vec_IntForEachEntryStart( vNodes, Entry, i, 1 )
- {
- Mux = Kit_Int2Mux(Entry);
- pFan0 = (unsigned *)Vec_PtrEntry( vStore, Mux.e );
- pFan1 = (unsigned *)Vec_PtrEntry( vStore, Mux.t );
- pThis = (unsigned *)Vec_PtrEntry( vStore, i );
- Kit_TruthMuxPhase( pThis, pFan0, pFan1, pInputs[nVars-1-Mux.v], nVarsAll, Mux.c );
- }
- // complement the result
- if ( Mux.i )
- Kit_TruthNot( pThis, pThis, nVarsAll );
- return pThis;
-}
-
-/**Function********************************************************************
-
- Synopsis [Compute BDD for the truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-******************************************************************************/
-void Kit_TruthCofSupports( Vec_Int_t * vBddDir, Vec_Int_t * vBddInv, int nVars, Vec_Int_t * vMemory, unsigned * puSupps )
-{
- Kit_Mux_t Mux;
- unsigned * puSuppAll;
- unsigned * pThis = NULL; // Suppress "might be used uninitialized"
- unsigned * pFan0, * pFan1;
- int i, v, Var, Entry, nSupps;
- nSupps = 2 * nVars;
-
- // extend storage
- if ( Vec_IntSize( vMemory ) < nSupps * Vec_IntSize(vBddDir) )
- Vec_IntGrow( vMemory, nSupps * Vec_IntSize(vBddDir) );
- puSuppAll = (unsigned *)Vec_IntArray( vMemory );
- // clear storage for the const node
- memset( puSuppAll, 0, sizeof(unsigned) * nSupps );
- // compute supports from nodes
- Vec_IntForEachEntryStart( vBddDir, Entry, i, 1 )
- {
- Mux = Kit_Int2Mux(Entry);
- Var = nVars - 1 - Mux.v;
- pFan0 = puSuppAll + nSupps * Mux.e;
- pFan1 = puSuppAll + nSupps * Mux.t;
- pThis = puSuppAll + nSupps * i;
- for ( v = 0; v < nSupps; v++ )
- pThis[v] = pFan0[v] | pFan1[v] | (1<<Var);
- assert( pFan0[2*Var + 0] == pFan0[2*Var + 1] );
- assert( pFan1[2*Var + 0] == pFan1[2*Var + 1] );
- pThis[2*Var + 0] = pFan0[2*Var + 0];// | pFan0[2*Var + 1];
- pThis[2*Var + 1] = pFan1[2*Var + 0];// | pFan1[2*Var + 1];
- }
- // copy the result
- memcpy( puSupps, pThis, sizeof(unsigned) * nSupps );
- // compute the inverse
-
- // extend storage
- if ( Vec_IntSize( vMemory ) < nSupps * Vec_IntSize(vBddInv) )
- Vec_IntGrow( vMemory, nSupps * Vec_IntSize(vBddInv) );
- puSuppAll = (unsigned *)Vec_IntArray( vMemory );
- // clear storage for the const node
- memset( puSuppAll, 0, sizeof(unsigned) * nSupps );
- // compute supports from nodes
- Vec_IntForEachEntryStart( vBddInv, Entry, i, 1 )
- {
- Mux = Kit_Int2Mux(Entry);
-// Var = nVars - 1 - Mux.v;
- Var = Mux.v;
- pFan0 = puSuppAll + nSupps * Mux.e;
- pFan1 = puSuppAll + nSupps * Mux.t;
- pThis = puSuppAll + nSupps * i;
- for ( v = 0; v < nSupps; v++ )
- pThis[v] = pFan0[v] | pFan1[v] | (1<<Var);
- assert( pFan0[2*Var + 0] == pFan0[2*Var + 1] );
- assert( pFan1[2*Var + 0] == pFan1[2*Var + 1] );
- pThis[2*Var + 0] = pFan0[2*Var + 0];// | pFan0[2*Var + 1];
- pThis[2*Var + 1] = pFan1[2*Var + 0];// | pFan1[2*Var + 1];
- }
-
- // merge supports
- for ( Var = 0; Var < nSupps; Var++ )
- puSupps[Var] = (puSupps[Var] & Kit_BitMask(Var/2)) | (pThis[Var] & ~Kit_BitMask(Var/2));
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
-ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/kitDec.c b/src/aig/kit/kitDec.c
deleted file mode 100644
index afc7ef6c..00000000
--- a/src/aig/kit/kitDec.c
+++ /dev/null
@@ -1,343 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kitDec.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis [Decomposition manager.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - November 18, 2009.]
-
- Revision [$Id: kitDec.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "kit.h"
-
-ABC_NAMESPACE_IMPL_START
-
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-// decomposition manager
-typedef struct Kit_ManDec_t_ Kit_ManDec_t;
-struct Kit_ManDec_t_
-{
- int nVarsMax; // the max number of variables
- int nWordsMax; // the max number of words
- Vec_Ptr_t * vTruthVars; // elementary truth tables
- Vec_Ptr_t * vTruthNodes; // internal truth tables
- // current problem
- int nVarsIn; // the current number of variables
- Vec_Int_t * vLutsIn; // LUT truth tables
- Vec_Int_t * vSuppIn; // LUT supports
- char ATimeIn[64]; // variable arrival times
- // extracted information
- unsigned * pTruthIn; // computed truth table
- unsigned * pTruthOut; // computed truth table
- int nVarsOut; // the current number of variables
- int nWordsOut; // the current number of words
- char Order[32]; // new vars into old vars after supp minimization
- // computed information
- Vec_Int_t * vLutsOut; // problem decomposition
- Vec_Int_t * vSuppOut; // problem decomposition
- char ATimeOut[64]; // variable arrival times
-};
-
-static inline int Kit_DecOuputArrival( int nVars, Vec_Int_t * vLuts, char ATimes[] ) { return ATimes[nVars + Vec_IntSize(vLuts) - 1]; }
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Starts Decmetry manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_ManDec_t * Kit_ManDecStart( int nVarsMax )
-{
- Kit_ManDec_t * p;
- assert( nVarsMax <= 20 );
- p = ABC_CALLOC( Kit_ManDec_t, 1 );
- p->nVarsMax = nVarsMax;
- p->nWordsMax = Kit_TruthWordNum( p->nVarsMax );
- p->vTruthVars = Vec_PtrAllocTruthTables( p->nVarsMax );
- p->vTruthNodes = Vec_PtrAllocSimInfo( 64, p->nWordsMax );
- p->vLutsIn = Vec_IntAlloc( 50 );
- p->vSuppIn = Vec_IntAlloc( 50 );
- p->vLutsOut = Vec_IntAlloc( 50 );
- p->vSuppOut = Vec_IntAlloc( 50 );
- p->pTruthIn = ABC_ALLOC( unsigned, p->nWordsMax );
- p->pTruthOut = ABC_ALLOC( unsigned, p->nWordsMax );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Stops Decmetry manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_ManDecStop( Kit_ManDec_t * p )
-{
- ABC_FREE( p->pTruthIn );
- ABC_FREE( p->pTruthOut );
- Vec_IntFreeP( &p->vLutsIn );
- Vec_IntFreeP( &p->vSuppIn );
- Vec_IntFreeP( &p->vLutsOut );
- Vec_IntFreeP( &p->vSuppOut );
- Vec_PtrFreeP( &p->vTruthVars );
- Vec_PtrFreeP( &p->vTruthNodes );
- ABC_FREE( p );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Deriving timing information for the decomposed structure.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DecComputeOuputArrival( int nVars, Vec_Int_t * vSupps, int LutSize, char ATimesIn[], char ATimesOut[] )
-{
- int i, v, iVar, nLuts, Delay;
- nLuts = Vec_IntSize(vSupps) / LutSize;
- assert( nLuts > 0 );
- assert( Vec_IntSize(vSupps) % LutSize == 0 );
- for ( v = 0; v < nVars; v++ )
- ATimesOut[v] = ATimesIn[v];
- for ( v = 0; v < nLuts; v++ )
- {
- Delay = 0;
- for ( i = 0; i < LutSize; i++ )
- {
- iVar = Vec_IntEntry( vSupps, v * LutSize + i );
- assert( iVar < nVars + v );
- Delay = ABC_MAX( Delay, ATimesOut[iVar] );
- }
- ATimesOut[nVars + v] = Delay + 1;
- }
- return ATimesOut[nVars + nLuts - 1];
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the truth table]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DecComputeTruthOne( int LutSize, unsigned * pTruthLut, int nVars, unsigned * pTruths[], unsigned * pTemp, unsigned * pRes )
-{
- int i, v;
- Kit_TruthClear( pRes, nVars );
- for ( i = 0; i < (1<<LutSize); i++ )
- {
- if ( !Kit_TruthHasBit( pTruthLut, i ) )
- continue;
- Kit_TruthFill( pTemp, nVars );
- for ( v = 0; v < LutSize; v++ )
- if ( i & (1<<v) )
- Kit_TruthAnd( pTemp, pTemp, pTruths[v], nVars );
- else
- Kit_TruthSharp( pTemp, pTemp, pTruths[v], nVars );
- Kit_TruthOr( pRes, pRes, pTemp, nVars );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the truth table]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DecComputeTruth( Kit_ManDec_t * p, int nVars, Vec_Int_t * vSupps, int LutSize, Vec_Int_t * vLuts, unsigned * pRes )
-{
- unsigned * pResult, * pTruthLuts, * pTruths[17];
- int nTruthLutWords, i, v, iVar, nLuts;
- nLuts = Vec_IntSize(vSupps) / LutSize;
- pTruthLuts = Vec_IntArray( vLuts );
- nTruthLutWords = Kit_TruthWordNum( LutSize );
- assert( nLuts > 0 );
- assert( Vec_IntSize(vSupps) % LutSize == 0 );
- assert( nLuts * nTruthLutWords == Vec_IntSize(vLuts) );
- for ( v = 0; v < nLuts; v++ )
- {
- for ( i = 0; i < LutSize; i++ )
- {
- iVar = Vec_IntEntry( vSupps, v * LutSize + i );
- assert( iVar < nVars + v );
- pTruths[i] = (iVar < nVars)? Vec_PtrEntry(p->vTruthVars, iVar) : Vec_PtrEntry(p->vTruthNodes, iVar-nVars);
- }
- pResult = (v == nLuts - 1) ? pRes : Vec_PtrEntry(p->vTruthNodes, v);
- Kit_DecComputeTruthOne( LutSize, pTruthLuts, nVars, pTruths, Vec_PtrEntry(p->vTruthNodes, v+1), pResult );
- pTruthLuts += nTruthLutWords;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the truth table]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DecComputePattern( int nVars, unsigned * pTruth, int LutSize, int Pattern[] )
-{
- int nCofs = (1 << LutSize);
- int i, k, nMyu = 0;
- assert( LutSize <= 6 );
- assert( LutSize < nVars );
- if ( nVars - LutSize <= 5 )
- {
- unsigned uCofs[64];
- int nBits = (1 << (nVars - LutSize));
- for ( i = 0; i < nCofs; i++ )
- uCofs[i] = (pTruth[(i*nBits)/32] >> ((i*nBits)%32)) & ((1<<nBits)-1);
- for ( i = 0; i < nCofs; i++ )
- {
- for ( k = 0; k < nMyu; k++ )
- if ( uCofs[i] == uCofs[k] )
- {
- Pattern[i] = k;
- break;
- }
- if ( k == i )
- Pattern[nMyu++] = i;
- }
- }
- else
- {
- unsigned * puCofs[64];
- int nWords = (1 << (nVars - LutSize - 5));
- for ( i = 0; i < nCofs; i++ )
- puCofs[i] = pTruth + nWords;
- for ( i = 0; i < nCofs; i++ )
- {
- for ( k = 0; k < nMyu; k++ )
- if ( Kit_TruthIsEqual( puCofs[i], puCofs[k], nVars - LutSize - 5 ) )
- {
- Pattern[i] = k;
- break;
- }
- if ( k == i )
- Pattern[nMyu++] = i;
- }
- }
- return nMyu;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the number of shared variables.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DecComputeShared_rec( int Pattern[], int Vars[], int nVars, int Shared[], int iVarTry )
-{
- int Pat0[32], Pat1[32], Shared0[5], Shared1[5], VarsNext[5];
- int v, u, iVarsNext, iPat0, iPat1, m, nMints = (1 << nVars);
- int nShared0, nShared1, nShared = 0;
- for ( v = iVarTry; v < nVars; v++ )
- {
- iVarsNext = 0;
- for ( u = 0; u < nVars; u++ )
- if ( u == v )
- VarsNext[iVarsNext++] = Vars[u];
- iPat0 = iPat1 = 0;
- for ( m = 0; m < nMints; m++ )
- if ( m & (1 << v) )
- Pat1[iPat1++] = m;
- else
- Pat0[iPat0++] = m;
- assert( iPat0 == nMints / 2 );
- assert( iPat1 == nMints / 2 );
- nShared0 = Kit_DecComputeShared_rec( Pat0, VarsNext, nVars-1, Shared0, v + 1 );
- if ( nShared0 == 0 )
- continue;
- nShared1 = Kit_DecComputeShared_rec( Pat1, VarsNext, nVars-1, Shared1, v + 1 );
- if ( nShared1 == 0 )
- continue;
- Shared[nShared++] = v;
- for ( u = 0; u < nShared0; u++ )
- for ( m = 0; m < nShared1; m++ )
- if ( Shared0[u] >= 0 && Shared1[m] >= 0 && Shared0[u] == Shared1[m] )
- {
- Shared[nShared++] = Shared0[u];
- Shared0[u] = Shared1[m] = -1;
- }
- return nShared;
- }
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the number of shared variables.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DecComputeShared( int Pattern[], int LutSize, int Shared[] )
-{
- int i, Vars[6];
- assert( LutSize <= 6 );
- for ( i = 0; i < LutSize; i++ )
- Vars[i] = i;
- return Kit_DecComputeShared_rec( Pattern, Vars, LutSize, Shared, 0 );
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
-ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/kitDsd.c b/src/aig/kit/kitDsd.c
deleted file mode 100644
index dffbe315..00000000
--- a/src/aig/kit/kitDsd.c
+++ /dev/null
@@ -1,3200 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kitDsd.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis [Performs disjoint-support decomposition based on truth tables.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - Dec 6, 2006.]
-
- Revision [$Id: kitDsd.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "kit.h"
-
-ABC_NAMESPACE_IMPL_START
-
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Allocates the DSD manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_DsdMan_t * Kit_DsdManAlloc( int nVars, int nNodes )
-{
- Kit_DsdMan_t * p;
- p = ABC_ALLOC( Kit_DsdMan_t, 1 );
- memset( p, 0, sizeof(Kit_DsdMan_t) );
- p->nVars = nVars;
- p->nWords = Kit_TruthWordNum( p->nVars );
- p->vTtElems = Vec_PtrAllocTruthTables( p->nVars );
- p->vTtNodes = Vec_PtrAllocSimInfo( nNodes, p->nWords );
- p->dd = Cloud_Init( 16, 14 );
- p->vTtBdds = Vec_PtrAllocSimInfo( (1<<12), p->nWords );
- p->vNodes = Vec_IntAlloc( 512 );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Deallocates the DSD manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdManFree( Kit_DsdMan_t * p )
-{
- Cloud_Quit( p->dd );
- Vec_IntFree( p->vNodes );
- Vec_PtrFree( p->vTtBdds );
- Vec_PtrFree( p->vTtElems );
- Vec_PtrFree( p->vTtNodes );
- ABC_FREE( p );
-}
-
-/**Function*************************************************************
-
- Synopsis [Allocates the DSD node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_DsdObj_t * Kit_DsdObjAlloc( Kit_DsdNtk_t * pNtk, Kit_Dsd_t Type, int nFans )
-{
- Kit_DsdObj_t * pObj;
- int nSize = sizeof(Kit_DsdObj_t) + sizeof(unsigned) * (Kit_DsdObjOffset(nFans) + (Type == KIT_DSD_PRIME) * Kit_TruthWordNum(nFans));
- pObj = (Kit_DsdObj_t *)ABC_ALLOC( char, nSize );
- memset( pObj, 0, nSize );
- pObj->Id = pNtk->nVars + pNtk->nNodes;
- pObj->Type = Type;
- pObj->nFans = nFans;
- pObj->Offset = Kit_DsdObjOffset( nFans );
- // add the object
- if ( pNtk->nNodes == pNtk->nNodesAlloc )
- {
- pNtk->nNodesAlloc *= 2;
- pNtk->pNodes = ABC_REALLOC( Kit_DsdObj_t *, pNtk->pNodes, pNtk->nNodesAlloc );
- }
- assert( pNtk->nNodes < pNtk->nNodesAlloc );
- pNtk->pNodes[pNtk->nNodes++] = pObj;
- return pObj;
-}
-
-/**Function*************************************************************
-
- Synopsis [Deallocates the DSD node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdObjFree( Kit_DsdNtk_t * p, Kit_DsdObj_t * pObj )
-{
- ABC_FREE( pObj );
-}
-
-/**Function*************************************************************
-
- Synopsis [Allocates the DSD network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_DsdNtk_t * Kit_DsdNtkAlloc( int nVars )
-{
- Kit_DsdNtk_t * pNtk;
- pNtk = ABC_ALLOC( Kit_DsdNtk_t, 1 );
- memset( pNtk, 0, sizeof(Kit_DsdNtk_t) );
- pNtk->pNodes = ABC_ALLOC( Kit_DsdObj_t *, nVars+1 );
- pNtk->nVars = nVars;
- pNtk->nNodesAlloc = nVars+1;
- pNtk->pMem = ABC_ALLOC( unsigned, 6 * Kit_TruthWordNum(nVars) );
- return pNtk;
-}
-
-/**Function*************************************************************
-
- Synopsis [Deallocate the DSD network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdNtkFree( Kit_DsdNtk_t * pNtk )
-{
- Kit_DsdObj_t * pObj;
- unsigned i;
- Kit_DsdNtkForEachObj( pNtk, pObj, i )
- ABC_FREE( pObj );
- ABC_FREE( pNtk->pSupps );
- ABC_FREE( pNtk->pNodes );
- ABC_FREE( pNtk->pMem );
- ABC_FREE( pNtk );
-}
-
-/**Function*************************************************************
-
- Synopsis [Prints the hex unsigned into a file.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdPrintHex( FILE * pFile, unsigned * pTruth, int nFans )
-{
- int nDigits, Digit, k;
- nDigits = (1 << nFans) / 4;
- for ( k = nDigits - 1; k >= 0; k-- )
- {
- Digit = ((pTruth[k/8] >> ((k%8) * 4)) & 15);
- if ( Digit < 10 )
- fprintf( pFile, "%d", Digit );
- else
- fprintf( pFile, "%c", 'A' + Digit-10 );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Prints the hex unsigned into a file.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-char * Kit_DsdWriteHex( char * pBuff, unsigned * pTruth, int nFans )
-{
- int nDigits, Digit, k;
- nDigits = (1 << nFans) / 4;
- for ( k = nDigits - 1; k >= 0; k-- )
- {
- Digit = ((pTruth[k/8] >> ((k%8) * 4)) & 15);
- if ( Digit < 10 )
- *pBuff++ = '0' + Digit;
- else
- *pBuff++ = 'A' + Digit-10;
- }
- return pBuff;
-}
-
-/**Function*************************************************************
-
- Synopsis [Recursively print the DSD formula.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdPrint2_rec( FILE * pFile, Kit_DsdNtk_t * pNtk, int Id )
-{
- Kit_DsdObj_t * pObj;
- unsigned iLit, i;
- char Symbol;
-
- pObj = Kit_DsdNtkObj( pNtk, Id );
- if ( pObj == NULL )
- {
- assert( Id < pNtk->nVars );
- fprintf( pFile, "%c", 'a' + Id );
- return;
- }
-
- if ( pObj->Type == KIT_DSD_CONST1 )
- {
- assert( pObj->nFans == 0 );
- fprintf( pFile, "Const1" );
- return;
- }
-
- if ( pObj->Type == KIT_DSD_VAR )
- assert( pObj->nFans == 1 );
-
- if ( pObj->Type == KIT_DSD_AND )
- Symbol = '*';
- else if ( pObj->Type == KIT_DSD_XOR )
- Symbol = '+';
- else
- Symbol = ',';
-
- if ( pObj->Type == KIT_DSD_PRIME )
- fprintf( pFile, "[" );
- else
- fprintf( pFile, "(" );
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- {
- if ( Kit_DsdLitIsCompl(iLit) )
- fprintf( pFile, "!" );
- Kit_DsdPrint2_rec( pFile, pNtk, Kit_DsdLit2Var(iLit) );
- if ( i < pObj->nFans - 1 )
- fprintf( pFile, "%c", Symbol );
- }
- if ( pObj->Type == KIT_DSD_PRIME )
- fprintf( pFile, "]" );
- else
- fprintf( pFile, ")" );
-}
-
-/**Function*************************************************************
-
- Synopsis [Print the DSD formula.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdPrint2( FILE * pFile, Kit_DsdNtk_t * pNtk )
-{
-// fprintf( pFile, "F = " );
- if ( Kit_DsdLitIsCompl(pNtk->Root) )
- fprintf( pFile, "!" );
- Kit_DsdPrint2_rec( pFile, pNtk, Kit_DsdLit2Var(pNtk->Root) );
-// fprintf( pFile, "\n" );
-}
-
-/**Function*************************************************************
-
- Synopsis [Recursively print the DSD formula.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdPrint_rec( FILE * pFile, Kit_DsdNtk_t * pNtk, int Id )
-{
- Kit_DsdObj_t * pObj;
- unsigned iLit, i;
- char Symbol;
-
- pObj = Kit_DsdNtkObj( pNtk, Id );
- if ( pObj == NULL )
- {
- assert( Id < pNtk->nVars );
- fprintf( pFile, "%c", 'a' + Id );
- return;
- }
-
- if ( pObj->Type == KIT_DSD_CONST1 )
- {
- assert( pObj->nFans == 0 );
- fprintf( pFile, "Const1" );
- return;
- }
-
- if ( pObj->Type == KIT_DSD_VAR )
- assert( pObj->nFans == 1 );
-
- if ( pObj->Type == KIT_DSD_AND )
- Symbol = '*';
- else if ( pObj->Type == KIT_DSD_XOR )
- Symbol = '+';
- else
- Symbol = ',';
-
- if ( pObj->Type == KIT_DSD_PRIME )
- Kit_DsdPrintHex( pFile, Kit_DsdObjTruth(pObj), pObj->nFans );
-
- fprintf( pFile, "(" );
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- {
- if ( Kit_DsdLitIsCompl(iLit) )
- fprintf( pFile, "!" );
- Kit_DsdPrint_rec( pFile, pNtk, Kit_DsdLit2Var(iLit) );
- if ( i < pObj->nFans - 1 )
- fprintf( pFile, "%c", Symbol );
- }
- fprintf( pFile, ")" );
-}
-
-/**Function*************************************************************
-
- Synopsis [Print the DSD formula.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdPrint( FILE * pFile, Kit_DsdNtk_t * pNtk )
-{
- fprintf( pFile, "F = " );
- if ( Kit_DsdLitIsCompl(pNtk->Root) )
- fprintf( pFile, "!" );
- Kit_DsdPrint_rec( pFile, pNtk, Kit_DsdLit2Var(pNtk->Root) );
-// fprintf( pFile, "\n" );
-}
-
-/**Function*************************************************************
-
- Synopsis [Recursively print the DSD formula.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-char * Kit_DsdWrite_rec( char * pBuff, Kit_DsdNtk_t * pNtk, int Id )
-{
- Kit_DsdObj_t * pObj;
- unsigned iLit, i;
- char Symbol;
-
- pObj = Kit_DsdNtkObj( pNtk, Id );
- if ( pObj == NULL )
- {
- assert( Id < pNtk->nVars );
- *pBuff++ = 'a' + Id;
- return pBuff;
- }
-
- if ( pObj->Type == KIT_DSD_CONST1 )
- {
- assert( pObj->nFans == 0 );
- sprintf( pBuff, "%s", "Const1" );
- return pBuff + strlen("Const1");
- }
-
- if ( pObj->Type == KIT_DSD_VAR )
- assert( pObj->nFans == 1 );
-
- if ( pObj->Type == KIT_DSD_AND )
- Symbol = '*';
- else if ( pObj->Type == KIT_DSD_XOR )
- Symbol = '+';
- else
- Symbol = ',';
-
- if ( pObj->Type == KIT_DSD_PRIME )
- pBuff = Kit_DsdWriteHex( pBuff, Kit_DsdObjTruth(pObj), pObj->nFans );
-
- *pBuff++ = '(';
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- {
- if ( Kit_DsdLitIsCompl(iLit) )
- *pBuff++ = '!';
- pBuff = Kit_DsdWrite_rec( pBuff, pNtk, Kit_DsdLit2Var(iLit) );
- if ( i < pObj->nFans - 1 )
- *pBuff++ = Symbol;
- }
- *pBuff++ = ')';
- return pBuff;
-}
-
-/**Function*************************************************************
-
- Synopsis [Print the DSD formula.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdWrite( char * pBuff, Kit_DsdNtk_t * pNtk )
-{
- if ( Kit_DsdLitIsCompl(pNtk->Root) )
- *pBuff++ = '!';
- pBuff = Kit_DsdWrite_rec( pBuff, pNtk, Kit_DsdLit2Var(pNtk->Root) );
- *pBuff = 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Print the DSD formula.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdPrintExpanded( Kit_DsdNtk_t * pNtk )
-{
- Kit_DsdNtk_t * pTemp;
- pTemp = Kit_DsdExpand( pNtk );
- Kit_DsdPrint( stdout, pTemp );
- Kit_DsdNtkFree( pTemp );
-}
-
-/**Function*************************************************************
-
- Synopsis [Print the DSD formula.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdPrintFromTruth( unsigned * pTruth, int nVars )
-{
- Kit_DsdNtk_t * pTemp, * pTemp2;
-// pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 5 );
- pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 8 );
-// Kit_DsdPrintExpanded( pTemp );
- pTemp2 = Kit_DsdExpand( pTemp );
- Kit_DsdPrint( stdout, pTemp2 );
- Kit_DsdVerify( pTemp2, pTruth, nVars );
- Kit_DsdNtkFree( pTemp2 );
- Kit_DsdNtkFree( pTemp );
-}
-
-/**Function*************************************************************
-
- Synopsis [Print the DSD formula.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdPrintFromTruth2( FILE * pFile, unsigned * pTruth, int nVars )
-{
- Kit_DsdNtk_t * pTemp, * pTemp2;
- pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 0 );
- pTemp2 = Kit_DsdExpand( pTemp );
- Kit_DsdPrint2( pFile, pTemp2 );
- Kit_DsdVerify( pTemp2, pTruth, nVars );
- Kit_DsdNtkFree( pTemp2 );
- Kit_DsdNtkFree( pTemp );
-}
-
-/**Function*************************************************************
-
- Synopsis [Print the DSD formula.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdWriteFromTruth( char * pBuffer, unsigned * pTruth, int nVars )
-{
- Kit_DsdNtk_t * pTemp, * pTemp2;
-// pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 5 );
- pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 8 );
-// Kit_DsdPrintExpanded( pTemp );
- pTemp2 = Kit_DsdExpand( pTemp );
- Kit_DsdWrite( pBuffer, pTemp2 );
- Kit_DsdVerify( pTemp2, pTruth, nVars );
- Kit_DsdNtkFree( pTemp2 );
- Kit_DsdNtkFree( pTemp );
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the truth table of the DSD node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned * Kit_DsdTruthComputeNode_rec( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, int Id )
-{
- Kit_DsdObj_t * pObj;
- unsigned * pTruthRes, * pTruthFans[16], * pTruthTemp;
- unsigned i, iLit, fCompl;
-// unsigned m, nMints, * pTruthPrime, * pTruthMint;
-
- // get the node with this ID
- pObj = Kit_DsdNtkObj( pNtk, Id );
- pTruthRes = (unsigned *)Vec_PtrEntry( p->vTtNodes, Id );
-
- // special case: literal of an internal node
- if ( pObj == NULL )
- {
- assert( Id < pNtk->nVars );
- return pTruthRes;
- }
-
- // constant node
- if ( pObj->Type == KIT_DSD_CONST1 )
- {
- assert( pObj->nFans == 0 );
- Kit_TruthFill( pTruthRes, pNtk->nVars );
- return pTruthRes;
- }
-
- // elementary variable node
- if ( pObj->Type == KIT_DSD_VAR )
- {
- assert( pObj->nFans == 1 );
- iLit = pObj->pFans[0];
- pTruthFans[0] = Kit_DsdTruthComputeNode_rec( p, pNtk, Kit_DsdLit2Var(iLit) );
- if ( Kit_DsdLitIsCompl(iLit) )
- Kit_TruthNot( pTruthRes, pTruthFans[0], pNtk->nVars );
- else
- Kit_TruthCopy( pTruthRes, pTruthFans[0], pNtk->nVars );
- return pTruthRes;
- }
-
- // collect the truth tables of the fanins
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- pTruthFans[i] = Kit_DsdTruthComputeNode_rec( p, pNtk, Kit_DsdLit2Var(iLit) );
- // create the truth table
-
- // simple gates
- if ( pObj->Type == KIT_DSD_AND )
- {
- Kit_TruthFill( pTruthRes, pNtk->nVars );
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- Kit_TruthAndPhase( pTruthRes, pTruthRes, pTruthFans[i], pNtk->nVars, 0, Kit_DsdLitIsCompl(iLit) );
- return pTruthRes;
- }
- if ( pObj->Type == KIT_DSD_XOR )
- {
- Kit_TruthClear( pTruthRes, pNtk->nVars );
- fCompl = 0;
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- {
- Kit_TruthXor( pTruthRes, pTruthRes, pTruthFans[i], pNtk->nVars );
- fCompl ^= Kit_DsdLitIsCompl(iLit);
- }
- if ( fCompl )
- Kit_TruthNot( pTruthRes, pTruthRes, pNtk->nVars );
- return pTruthRes;
- }
- assert( pObj->Type == KIT_DSD_PRIME );
-/*
- // get the truth table of the prime node
- pTruthPrime = Kit_DsdObjTruth( pObj );
- // get storage for the temporary minterm
- pTruthMint = Vec_PtrEntry(p->vTtNodes, pNtk->nVars + pNtk->nNodes);
- // go through the minterms
- nMints = (1 << pObj->nFans);
- Kit_TruthClear( pTruthRes, pNtk->nVars );
- for ( m = 0; m < nMints; m++ )
- {
- if ( !Kit_TruthHasBit(pTruthPrime, m) )
- continue;
- Kit_TruthFill( pTruthMint, pNtk->nVars );
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- Kit_TruthAndPhase( pTruthMint, pTruthMint, pTruthFans[i], pNtk->nVars, 0, ((m & (1<<i)) == 0) ^ Kit_DsdLitIsCompl(iLit) );
- Kit_TruthOr( pTruthRes, pTruthRes, pTruthMint, pNtk->nVars );
- }
-*/
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- if ( Kit_DsdLitIsCompl(iLit) )
- Kit_TruthNot( pTruthFans[i], pTruthFans[i], pNtk->nVars );
- pTruthTemp = Kit_TruthCompose( p->dd, Kit_DsdObjTruth(pObj), pObj->nFans, pTruthFans, pNtk->nVars, p->vTtBdds, p->vNodes );
- Kit_TruthCopy( pTruthRes, pTruthTemp, pNtk->nVars );
- return pTruthRes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the truth table of the DSD network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned * Kit_DsdTruthCompute( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk )
-{
- unsigned * pTruthRes;
- int i;
- // assign elementary truth ables
- assert( pNtk->nVars <= p->nVars );
- for ( i = 0; i < (int)pNtk->nVars; i++ )
- Kit_TruthCopy( (unsigned *)Vec_PtrEntry(p->vTtNodes, i), (unsigned *)Vec_PtrEntry(p->vTtElems, i), p->nVars );
- // compute truth table for each node
- pTruthRes = Kit_DsdTruthComputeNode_rec( p, pNtk, Kit_DsdLit2Var(pNtk->Root) );
- // complement the truth table if needed
- if ( Kit_DsdLitIsCompl(pNtk->Root) )
- Kit_TruthNot( pTruthRes, pTruthRes, pNtk->nVars );
- return pTruthRes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the truth table of the DSD node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned * Kit_DsdTruthComputeNodeOne_rec( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, int Id, unsigned uSupp )
-{
- Kit_DsdObj_t * pObj;
- unsigned * pTruthRes, * pTruthFans[16], * pTruthTemp;
- unsigned i, iLit, fCompl, nPartial = 0;
-// unsigned m, nMints, * pTruthPrime, * pTruthMint;
-
- // get the node with this ID
- pObj = Kit_DsdNtkObj( pNtk, Id );
- pTruthRes = (unsigned *)Vec_PtrEntry( p->vTtNodes, Id );
-
- // special case: literal of an internal node
- if ( pObj == NULL )
- {
- assert( Id < pNtk->nVars );
- assert( !uSupp || uSupp != (uSupp & ~(1<<Id)) );
- return pTruthRes;
- }
-
- // constant node
- if ( pObj->Type == KIT_DSD_CONST1 )
- {
- assert( pObj->nFans == 0 );
- Kit_TruthFill( pTruthRes, pNtk->nVars );
- return pTruthRes;
- }
-
- // elementary variable node
- if ( pObj->Type == KIT_DSD_VAR )
- {
- assert( pObj->nFans == 1 );
- iLit = pObj->pFans[0];
- assert( Kit_DsdLitIsLeaf( pNtk, iLit ) );
- pTruthFans[0] = Kit_DsdTruthComputeNodeOne_rec( p, pNtk, Kit_DsdLit2Var(iLit), uSupp );
- if ( Kit_DsdLitIsCompl(iLit) )
- Kit_TruthNot( pTruthRes, pTruthFans[0], pNtk->nVars );
- else
- Kit_TruthCopy( pTruthRes, pTruthFans[0], pNtk->nVars );
- return pTruthRes;
- }
-
- // collect the truth tables of the fanins
- if ( uSupp )
- {
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- if ( uSupp != (uSupp & ~Kit_DsdLitSupport(pNtk, iLit)) )
- pTruthFans[i] = Kit_DsdTruthComputeNodeOne_rec( p, pNtk, Kit_DsdLit2Var(iLit), uSupp );
- else
- {
- pTruthFans[i] = NULL;
- nPartial = 1;
- }
- }
- else
- {
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- pTruthFans[i] = Kit_DsdTruthComputeNodeOne_rec( p, pNtk, Kit_DsdLit2Var(iLit), uSupp );
- }
- // create the truth table
-
- // simple gates
- if ( pObj->Type == KIT_DSD_AND )
- {
- Kit_TruthFill( pTruthRes, pNtk->nVars );
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- if ( pTruthFans[i] )
- Kit_TruthAndPhase( pTruthRes, pTruthRes, pTruthFans[i], pNtk->nVars, 0, Kit_DsdLitIsCompl(iLit) );
- return pTruthRes;
- }
- if ( pObj->Type == KIT_DSD_XOR )
- {
- Kit_TruthClear( pTruthRes, pNtk->nVars );
- fCompl = 0;
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- {
- if ( pTruthFans[i] )
- {
- Kit_TruthXor( pTruthRes, pTruthRes, pTruthFans[i], pNtk->nVars );
- fCompl ^= Kit_DsdLitIsCompl(iLit);
- }
- }
- if ( fCompl )
- Kit_TruthNot( pTruthRes, pTruthRes, pNtk->nVars );
- return pTruthRes;
- }
- assert( pObj->Type == KIT_DSD_PRIME );
-
- if ( uSupp && nPartial )
- {
- // find the only non-empty component
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- if ( pTruthFans[i] )
- break;
- assert( i < pObj->nFans );
- return pTruthFans[i];
- }
-/*
- // get the truth table of the prime node
- pTruthPrime = Kit_DsdObjTruth( pObj );
- // get storage for the temporary minterm
- pTruthMint = Vec_PtrEntry(p->vTtNodes, pNtk->nVars + pNtk->nNodes);
- // go through the minterms
- nMints = (1 << pObj->nFans);
- Kit_TruthClear( pTruthRes, pNtk->nVars );
- for ( m = 0; m < nMints; m++ )
- {
- if ( !Kit_TruthHasBit(pTruthPrime, m) )
- continue;
- Kit_TruthFill( pTruthMint, pNtk->nVars );
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- Kit_TruthAndPhase( pTruthMint, pTruthMint, pTruthFans[i], pNtk->nVars, 0, ((m & (1<<i)) == 0) ^ Kit_DsdLitIsCompl(iLit) );
- Kit_TruthOr( pTruthRes, pTruthRes, pTruthMint, pNtk->nVars );
- }
-*/
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- if ( Kit_DsdLitIsCompl(iLit) )
- Kit_TruthNot( pTruthFans[i], pTruthFans[i], pNtk->nVars );
- pTruthTemp = Kit_TruthCompose( p->dd, Kit_DsdObjTruth(pObj), pObj->nFans, pTruthFans, pNtk->nVars, p->vTtBdds, p->vNodes );
- Kit_TruthCopy( pTruthRes, pTruthTemp, pNtk->nVars );
- return pTruthRes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the truth table of the DSD network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned * Kit_DsdTruthComputeOne( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, unsigned uSupp )
-{
- unsigned * pTruthRes;
- int i;
- // if support is specified, request that supports are available
- if ( uSupp )
- Kit_DsdGetSupports( pNtk );
- // assign elementary truth tables
- assert( pNtk->nVars <= p->nVars );
- for ( i = 0; i < (int)pNtk->nVars; i++ )
- Kit_TruthCopy( (unsigned *)Vec_PtrEntry(p->vTtNodes, i), (unsigned *)Vec_PtrEntry(p->vTtElems, i), p->nVars );
- // compute truth table for each node
- pTruthRes = Kit_DsdTruthComputeNodeOne_rec( p, pNtk, Kit_DsdLit2Var(pNtk->Root), uSupp );
- // complement the truth table if needed
- if ( Kit_DsdLitIsCompl(pNtk->Root) )
- Kit_TruthNot( pTruthRes, pTruthRes, pNtk->nVars );
- return pTruthRes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the truth table of the DSD node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned * Kit_DsdTruthComputeNodeTwo_rec( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, int Id, unsigned uSupp, int iVar, unsigned * pTruthDec )
-{
- Kit_DsdObj_t * pObj;
- int pfBoundSet[16];
- unsigned * pTruthRes, * pTruthFans[16], * pTruthTemp;
- unsigned i, iLit, fCompl, nPartial, uSuppFan, uSuppCur;
-// unsigned m, nMints, * pTruthPrime, * pTruthMint;
- assert( uSupp > 0 );
-
- // get the node with this ID
- pObj = Kit_DsdNtkObj( pNtk, Id );
- pTruthRes = (unsigned *)Vec_PtrEntry( p->vTtNodes, Id );
- if ( pObj == NULL )
- {
- assert( Id < pNtk->nVars );
- return pTruthRes;
- }
- assert( pObj->Type != KIT_DSD_CONST1 );
- assert( pObj->Type != KIT_DSD_VAR );
-
- // count the number of intersecting fanins
- // collect the total support of the intersecting fanins
- nPartial = 0;
- uSuppFan = 0;
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- {
- uSuppCur = Kit_DsdLitSupport(pNtk, iLit);
- if ( uSupp & uSuppCur )
- {
- nPartial++;
- uSuppFan |= uSuppCur;
- }
- }
-
- // if there is no intersection, or full intersection, use simple procedure
- if ( nPartial == 0 || nPartial == pObj->nFans )
- return Kit_DsdTruthComputeNodeOne_rec( p, pNtk, Id, 0 );
-
- // if support of the component includes some other variables
- // we need to continue constructing it as usual by the two-function procedure
- if ( uSuppFan != (uSuppFan & uSupp) )
- {
- assert( nPartial == 1 );
-// return Kit_DsdTruthComputeNodeTwo_rec( p, pNtk, Id, uSupp, iVar, pTruthDec );
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- {
- if ( uSupp & Kit_DsdLitSupport(pNtk, iLit) )
- pTruthFans[i] = Kit_DsdTruthComputeNodeTwo_rec( p, pNtk, Kit_DsdLit2Var(iLit), uSupp, iVar, pTruthDec );
- else
- pTruthFans[i] = Kit_DsdTruthComputeNodeOne_rec( p, pNtk, Kit_DsdLit2Var(iLit), 0 );
- }
-
- // create composition/decomposition functions
- if ( pObj->Type == KIT_DSD_AND )
- {
- Kit_TruthFill( pTruthRes, pNtk->nVars );
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- Kit_TruthAndPhase( pTruthRes, pTruthRes, pTruthFans[i], pNtk->nVars, 0, Kit_DsdLitIsCompl(iLit) );
- return pTruthRes;
- }
- if ( pObj->Type == KIT_DSD_XOR )
- {
- Kit_TruthClear( pTruthRes, pNtk->nVars );
- fCompl = 0;
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- {
- fCompl ^= Kit_DsdLitIsCompl(iLit);
- Kit_TruthXor( pTruthRes, pTruthRes, pTruthFans[i], pNtk->nVars );
- }
- if ( fCompl )
- Kit_TruthNot( pTruthRes, pTruthRes, pNtk->nVars );
- return pTruthRes;
- }
- assert( pObj->Type == KIT_DSD_PRIME );
- }
- else
- {
- assert( uSuppFan == (uSuppFan & uSupp) );
- assert( nPartial < pObj->nFans );
- // the support of the insecting component(s) is contained in the bound-set
- // and yet there are components that are not contained in the bound set
-
- // solve the fanins and collect info, which components belong to the bound set
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- {
- pTruthFans[i] = Kit_DsdTruthComputeNodeOne_rec( p, pNtk, Kit_DsdLit2Var(iLit), 0 );
- pfBoundSet[i] = (int)((uSupp & Kit_DsdLitSupport(pNtk, iLit)) > 0);
- }
-
- // create composition/decomposition functions
- if ( pObj->Type == KIT_DSD_AND )
- {
- Kit_TruthIthVar( pTruthRes, pNtk->nVars, iVar );
- Kit_TruthFill( pTruthDec, pNtk->nVars );
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- if ( pfBoundSet[i] )
- Kit_TruthAndPhase( pTruthDec, pTruthDec, pTruthFans[i], pNtk->nVars, 0, Kit_DsdLitIsCompl(iLit) );
- else
- Kit_TruthAndPhase( pTruthRes, pTruthRes, pTruthFans[i], pNtk->nVars, 0, Kit_DsdLitIsCompl(iLit) );
- return pTruthRes;
- }
- if ( pObj->Type == KIT_DSD_XOR )
- {
- Kit_TruthIthVar( pTruthRes, pNtk->nVars, iVar );
- Kit_TruthClear( pTruthDec, pNtk->nVars );
- fCompl = 0;
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- {
- fCompl ^= Kit_DsdLitIsCompl(iLit);
- if ( pfBoundSet[i] )
- Kit_TruthXor( pTruthDec, pTruthDec, pTruthFans[i], pNtk->nVars );
- else
- Kit_TruthXor( pTruthRes, pTruthRes, pTruthFans[i], pNtk->nVars );
- }
- if ( fCompl )
- Kit_TruthNot( pTruthRes, pTruthRes, pNtk->nVars );
- return pTruthRes;
- }
- assert( pObj->Type == KIT_DSD_PRIME );
- assert( nPartial == 1 );
-
- // find the only non-empty component
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- if ( pfBoundSet[i] )
- break;
- assert( i < pObj->nFans );
-
- // save this component as the decomposed function
- Kit_TruthCopy( pTruthDec, pTruthFans[i], pNtk->nVars );
- // set the corresponding component to be the new variable
- Kit_TruthIthVar( pTruthFans[i], pNtk->nVars, iVar );
- }
-/*
- // get the truth table of the prime node
- pTruthPrime = Kit_DsdObjTruth( pObj );
- // get storage for the temporary minterm
- pTruthMint = Vec_PtrEntry(p->vTtNodes, pNtk->nVars + pNtk->nNodes);
- // go through the minterms
- nMints = (1 << pObj->nFans);
- Kit_TruthClear( pTruthRes, pNtk->nVars );
- for ( m = 0; m < nMints; m++ )
- {
- if ( !Kit_TruthHasBit(pTruthPrime, m) )
- continue;
- Kit_TruthFill( pTruthMint, pNtk->nVars );
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- Kit_TruthAndPhase( pTruthMint, pTruthMint, pTruthFans[i], pNtk->nVars, 0, ((m & (1<<i)) == 0) ^ Kit_DsdLitIsCompl(iLit) );
- Kit_TruthOr( pTruthRes, pTruthRes, pTruthMint, pNtk->nVars );
- }
-*/
-// Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
-// assert( !Kit_DsdLitIsCompl(iLit) );
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- if ( Kit_DsdLitIsCompl(iLit) )
- Kit_TruthNot( pTruthFans[i], pTruthFans[i], pNtk->nVars );
- pTruthTemp = Kit_TruthCompose( p->dd, Kit_DsdObjTruth(pObj), pObj->nFans, pTruthFans, pNtk->nVars, p->vTtBdds, p->vNodes );
- Kit_TruthCopy( pTruthRes, pTruthTemp, pNtk->nVars );
- return pTruthRes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the truth table of the DSD network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned * Kit_DsdTruthComputeTwo( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, unsigned uSupp, int iVar, unsigned * pTruthDec )
-{
- unsigned * pTruthRes, uSuppAll;
- int i;
- assert( uSupp > 0 );
- assert( pNtk->nVars <= p->nVars );
- // compute support of all nodes
- uSuppAll = Kit_DsdGetSupports( pNtk );
- // consider special case - there is no overlap
- if ( (uSupp & uSuppAll) == 0 )
- {
- Kit_TruthClear( pTruthDec, pNtk->nVars );
- return Kit_DsdTruthCompute( p, pNtk );
- }
- // consider special case - support is fully contained
- if ( (uSupp & uSuppAll) == uSuppAll )
- {
- pTruthRes = Kit_DsdTruthCompute( p, pNtk );
- Kit_TruthCopy( pTruthDec, pTruthRes, pNtk->nVars );
- Kit_TruthIthVar( pTruthRes, pNtk->nVars, iVar );
- return pTruthRes;
- }
- // assign elementary truth tables
- for ( i = 0; i < (int)pNtk->nVars; i++ )
- Kit_TruthCopy( (unsigned *)Vec_PtrEntry(p->vTtNodes, i), (unsigned *)Vec_PtrEntry(p->vTtElems, i), p->nVars );
- // compute truth table for each node
- pTruthRes = Kit_DsdTruthComputeNodeTwo_rec( p, pNtk, Kit_DsdLit2Var(pNtk->Root), uSupp, iVar, pTruthDec );
- // complement the truth table if needed
- if ( Kit_DsdLitIsCompl(pNtk->Root) )
- Kit_TruthNot( pTruthRes, pTruthRes, pNtk->nVars );
- return pTruthRes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the truth table of the DSD network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdTruth( Kit_DsdNtk_t * pNtk, unsigned * pTruthRes )
-{
- Kit_DsdMan_t * p;
- unsigned * pTruth;
- p = Kit_DsdManAlloc( pNtk->nVars, Kit_DsdNtkObjNum(pNtk) );
- pTruth = Kit_DsdTruthCompute( p, pNtk );
- Kit_TruthCopy( pTruthRes, pTruth, pNtk->nVars );
- Kit_DsdManFree( p );
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the truth table of the DSD network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdTruthPartialTwo( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, unsigned uSupp, int iVar, unsigned * pTruthCo, unsigned * pTruthDec )
-{
- unsigned * pTruth = Kit_DsdTruthComputeTwo( p, pNtk, uSupp, iVar, pTruthDec );
- if ( pTruthCo )
- Kit_TruthCopy( pTruthCo, pTruth, pNtk->nVars );
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the truth table of the DSD network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdTruthPartial( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, unsigned * pTruthRes, unsigned uSupp )
-{
- unsigned * pTruth = Kit_DsdTruthComputeOne( p, pNtk, uSupp );
- Kit_TruthCopy( pTruthRes, pTruth, pNtk->nVars );
-/*
- // verification
- {
- // compute the same function using different procedure
- unsigned * pTruthTemp = Vec_PtrEntry(p->vTtNodes, pNtk->nVars + pNtk->nNodes + 1);
- pNtk->pSupps = NULL;
- Kit_DsdTruthComputeTwo( p, pNtk, uSupp, -1, pTruthTemp );
-// if ( !Kit_TruthIsEqual( pTruthTemp, pTruthRes, pNtk->nVars ) )
- if ( !Kit_TruthIsEqualWithPhase( pTruthTemp, pTruthRes, pNtk->nVars ) )
- {
- printf( "Verification FAILED!\n" );
- Kit_DsdPrint( stdout, pNtk );
- Kit_DsdPrintFromTruth( pTruthRes, pNtk->nVars );
- Kit_DsdPrintFromTruth( pTruthTemp, pNtk->nVars );
- }
-// else
-// printf( "Verification successful.\n" );
- }
-*/
-}
-
-/**Function*************************************************************
-
- Synopsis [Counts the number of blocks of the given number of inputs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DsdCountLuts_rec( Kit_DsdNtk_t * pNtk, int nLutSize, int Id, int * pCounter )
-{
- Kit_DsdObj_t * pObj;
- unsigned iLit, i, Res0, Res1;
- pObj = Kit_DsdNtkObj( pNtk, Id );
- if ( pObj == NULL )
- return 0;
- if ( pObj->Type == KIT_DSD_AND || pObj->Type == KIT_DSD_XOR )
- {
- assert( pObj->nFans == 2 );
- Res0 = Kit_DsdCountLuts_rec( pNtk, nLutSize, Kit_DsdLit2Var(pObj->pFans[0]), pCounter );
- Res1 = Kit_DsdCountLuts_rec( pNtk, nLutSize, Kit_DsdLit2Var(pObj->pFans[1]), pCounter );
- if ( Res0 == 0 && Res1 > 0 )
- return Res1 - 1;
- if ( Res0 > 0 && Res1 == 0 )
- return Res0 - 1;
- (*pCounter)++;
- return nLutSize - 2;
- }
- assert( pObj->Type == KIT_DSD_PRIME );
- if ( (int)pObj->nFans > nLutSize ) //+ 1 )
- {
- *pCounter = 1000;
- return 0;
- }
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- Kit_DsdCountLuts_rec( pNtk, nLutSize, Kit_DsdLit2Var(iLit), pCounter );
- (*pCounter)++;
-// if ( (int)pObj->nFans == nLutSize + 1 )
-// (*pCounter)++;
- return nLutSize - pObj->nFans;
-}
-
-/**Function*************************************************************
-
- Synopsis [Counts the number of blocks of the given number of inputs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DsdCountLuts( Kit_DsdNtk_t * pNtk, int nLutSize )
-{
- int Counter = 0;
- if ( Kit_DsdNtkRoot(pNtk)->Type == KIT_DSD_CONST1 )
- return 0;
- if ( Kit_DsdNtkRoot(pNtk)->Type == KIT_DSD_VAR )
- return 0;
- Kit_DsdCountLuts_rec( pNtk, nLutSize, Kit_DsdLit2Var(pNtk->Root), &Counter );
- if ( Counter >= 1000 )
- return -1;
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the size of the largest non-DSD block.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DsdNonDsdSizeMax( Kit_DsdNtk_t * pNtk )
-{
- Kit_DsdObj_t * pObj;
- unsigned i, nSizeMax = 0;
- Kit_DsdNtkForEachObj( pNtk, pObj, i )
- {
- if ( pObj->Type != KIT_DSD_PRIME )
- continue;
- if ( nSizeMax < pObj->nFans )
- nSizeMax = pObj->nFans;
- }
- return nSizeMax;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the largest non-DSD block.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_DsdObj_t * Kit_DsdNonDsdPrimeMax( Kit_DsdNtk_t * pNtk )
-{
- Kit_DsdObj_t * pObj, * pObjMax = NULL;
- unsigned i, nSizeMax = 0;
- Kit_DsdNtkForEachObj( pNtk, pObj, i )
- {
- if ( pObj->Type != KIT_DSD_PRIME )
- continue;
- if ( nSizeMax < pObj->nFans )
- {
- nSizeMax = pObj->nFans;
- pObjMax = pObj;
- }
- }
- return pObjMax;
-}
-
-/**Function*************************************************************
-
- Synopsis [Finds the union of supports of the non-DSD blocks.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned Kit_DsdNonDsdSupports( Kit_DsdNtk_t * pNtk )
-{
- Kit_DsdObj_t * pObj;
- unsigned i, uSupport = 0;
-// ABC_FREE( pNtk->pSupps );
- Kit_DsdGetSupports( pNtk );
- Kit_DsdNtkForEachObj( pNtk, pObj, i )
- {
- if ( pObj->Type != KIT_DSD_PRIME )
- continue;
- uSupport |= Kit_DsdLitSupport( pNtk, Kit_DsdVar2Lit(pObj->Id,0) );
- }
- return uSupport;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Expands the node.]
-
- Description [Returns the new literal.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdExpandCollectAnd_rec( Kit_DsdNtk_t * p, unsigned iLit, unsigned * piLitsNew, int * nLitsNew )
-{
- Kit_DsdObj_t * pObj;
- unsigned i, iLitFanin;
- // check the end of the supergate
- pObj = Kit_DsdNtkObj( p, Kit_DsdLit2Var(iLit) );
- if ( Kit_DsdLitIsCompl(iLit) || Kit_DsdLit2Var(iLit) < p->nVars || pObj->Type != KIT_DSD_AND )
- {
- piLitsNew[(*nLitsNew)++] = iLit;
- return;
- }
- // iterate through the fanins
- Kit_DsdObjForEachFanin( p, pObj, iLitFanin, i )
- Kit_DsdExpandCollectAnd_rec( p, iLitFanin, piLitsNew, nLitsNew );
-}
-
-/**Function*************************************************************
-
- Synopsis [Expands the node.]
-
- Description [Returns the new literal.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdExpandCollectXor_rec( Kit_DsdNtk_t * p, unsigned iLit, unsigned * piLitsNew, int * nLitsNew )
-{
- Kit_DsdObj_t * pObj;
- unsigned i, iLitFanin;
- // check the end of the supergate
- pObj = Kit_DsdNtkObj( p, Kit_DsdLit2Var(iLit) );
- if ( Kit_DsdLit2Var(iLit) < p->nVars || pObj->Type != KIT_DSD_XOR )
- {
- piLitsNew[(*nLitsNew)++] = iLit;
- return;
- }
- // iterate through the fanins
- pObj = Kit_DsdNtkObj( p, Kit_DsdLit2Var(iLit) );
- Kit_DsdObjForEachFanin( p, pObj, iLitFanin, i )
- Kit_DsdExpandCollectXor_rec( p, iLitFanin, piLitsNew, nLitsNew );
- // if the literal was complemented, pass the complemented attribute somewhere
- if ( Kit_DsdLitIsCompl(iLit) )
- piLitsNew[0] = Kit_DsdLitNot( piLitsNew[0] );
-}
-
-/**Function*************************************************************
-
- Synopsis [Expands the node.]
-
- Description [Returns the new literal.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DsdExpandNode_rec( Kit_DsdNtk_t * pNew, Kit_DsdNtk_t * p, int iLit )
-{
- unsigned * pTruth, * pTruthNew;
- unsigned i, iLitFanin, piLitsNew[16], nLitsNew = 0;
- Kit_DsdObj_t * pObj, * pObjNew;
-
- // consider the case of simple gate
- pObj = Kit_DsdNtkObj( p, Kit_DsdLit2Var(iLit) );
- if ( pObj == NULL )
- return iLit;
- if ( pObj->Type == KIT_DSD_AND )
- {
- Kit_DsdExpandCollectAnd_rec( p, Kit_DsdLitRegular(iLit), piLitsNew, (int *)&nLitsNew );
- pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_AND, nLitsNew );
- for ( i = 0; i < pObjNew->nFans; i++ )
- pObjNew->pFans[i] = Kit_DsdExpandNode_rec( pNew, p, piLitsNew[i] );
- return Kit_DsdVar2Lit( pObjNew->Id, Kit_DsdLitIsCompl(iLit) );
- }
- if ( pObj->Type == KIT_DSD_XOR )
- {
- int fCompl = Kit_DsdLitIsCompl(iLit);
- Kit_DsdExpandCollectXor_rec( p, Kit_DsdLitRegular(iLit), piLitsNew, (int *)&nLitsNew );
- pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_XOR, nLitsNew );
- for ( i = 0; i < pObjNew->nFans; i++ )
- {
- pObjNew->pFans[i] = Kit_DsdExpandNode_rec( pNew, p, Kit_DsdLitRegular(piLitsNew[i]) );
- fCompl ^= Kit_DsdLitIsCompl(piLitsNew[i]);
- }
- return Kit_DsdVar2Lit( pObjNew->Id, fCompl );
- }
- assert( pObj->Type == KIT_DSD_PRIME );
-
- // create new PRIME node
- pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_PRIME, pObj->nFans );
- // copy the truth table
- pTruth = Kit_DsdObjTruth( pObj );
- pTruthNew = Kit_DsdObjTruth( pObjNew );
- Kit_TruthCopy( pTruthNew, pTruth, pObj->nFans );
- // create fanins
- Kit_DsdObjForEachFanin( pNtk, pObj, iLitFanin, i )
- {
- pObjNew->pFans[i] = Kit_DsdExpandNode_rec( pNew, p, iLitFanin );
- // complement the corresponding inputs of the truth table
- if ( Kit_DsdLitIsCompl(pObjNew->pFans[i]) )
- {
- pObjNew->pFans[i] = Kit_DsdLitRegular(pObjNew->pFans[i]);
- Kit_TruthChangePhase( pTruthNew, pObjNew->nFans, i );
- }
- }
-
- if ( pObj->nFans == 3 &&
- (pTruthNew[0] == 0xCACACACA || pTruthNew[0] == 0xC5C5C5C5 ||
- pTruthNew[0] == 0x3A3A3A3A || pTruthNew[0] == 0x35353535) )
- {
- // translate into regular MUXes
- if ( pTruthNew[0] == 0xC5C5C5C5 )
- pObjNew->pFans[0] = Kit_DsdLitNot(pObjNew->pFans[0]);
- else if ( pTruthNew[0] == 0x3A3A3A3A )
- pObjNew->pFans[1] = Kit_DsdLitNot(pObjNew->pFans[1]);
- else if ( pTruthNew[0] == 0x35353535 )
- {
- pObjNew->pFans[0] = Kit_DsdLitNot(pObjNew->pFans[0]);
- pObjNew->pFans[1] = Kit_DsdLitNot(pObjNew->pFans[1]);
- }
- pTruthNew[0] = 0xCACACACA;
- // resolve the complemented control input
- if ( Kit_DsdLitIsCompl(pObjNew->pFans[2]) )
- {
- unsigned char Temp = pObjNew->pFans[0];
- pObjNew->pFans[0] = pObjNew->pFans[1];
- pObjNew->pFans[1] = Temp;
- pObjNew->pFans[2] = Kit_DsdLitNot(pObjNew->pFans[2]);
- }
- // resolve the complemented true input
- if ( Kit_DsdLitIsCompl(pObjNew->pFans[1]) )
- {
- iLit = Kit_DsdLitNot(iLit);
- pObjNew->pFans[0] = Kit_DsdLitNot(pObjNew->pFans[0]);
- pObjNew->pFans[1] = Kit_DsdLitNot(pObjNew->pFans[1]);
- }
- return Kit_DsdVar2Lit( pObjNew->Id, Kit_DsdLitIsCompl(iLit) );
- }
- else
- {
- // if the incoming phase is complemented, absorb it into the prime node
- if ( Kit_DsdLitIsCompl(iLit) )
- Kit_TruthNot( pTruthNew, pTruthNew, pObj->nFans );
- return Kit_DsdVar2Lit( pObjNew->Id, 0 );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Expands the network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_DsdNtk_t * Kit_DsdExpand( Kit_DsdNtk_t * p )
-{
- Kit_DsdNtk_t * pNew;
- Kit_DsdObj_t * pObjNew;
- assert( p->nVars <= 16 );
- // create a new network
- pNew = Kit_DsdNtkAlloc( p->nVars );
- // consider simple special cases
- if ( Kit_DsdNtkRoot(p)->Type == KIT_DSD_CONST1 )
- {
- pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_CONST1, 0 );
- pNew->Root = Kit_DsdVar2Lit( pObjNew->Id, Kit_DsdLitIsCompl(p->Root) );
- return pNew;
- }
- if ( Kit_DsdNtkRoot(p)->Type == KIT_DSD_VAR )
- {
- pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_VAR, 1 );
- pObjNew->pFans[0] = Kit_DsdNtkRoot(p)->pFans[0];
- pNew->Root = Kit_DsdVar2Lit( pObjNew->Id, Kit_DsdLitIsCompl(p->Root) );
- return pNew;
- }
- // convert the root node
- pNew->Root = Kit_DsdExpandNode_rec( pNew, p, p->Root );
- return pNew;
-}
-
-/**Function*************************************************************
-
- Synopsis [Sorts the literals by their support.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdCompSort( int pPrios[], unsigned uSupps[], unsigned char * piLits, int nVars, unsigned piLitsRes[] )
-{
- int nSuppSizes[16], Priority[16], pOrder[16];
- int i, k, iVarBest, SuppMax, PrioMax;
- // compute support sizes and priorities of the components
- for ( i = 0; i < nVars; i++ )
- {
- assert( uSupps[i] );
- pOrder[i] = i;
- Priority[i] = KIT_INFINITY;
- for ( k = 0; k < 16; k++ )
- if ( uSupps[i] & (1 << k) )
- Priority[i] = KIT_MIN( Priority[i], pPrios[k] );
- assert( Priority[i] != 16 );
- nSuppSizes[i] = Kit_WordCountOnes(uSupps[i]);
- }
- // sort the components by pririty
- Extra_BubbleSort( pOrder, Priority, nVars, 0 );
- // find the component by with largest size and lowest priority
- iVarBest = -1;
- SuppMax = 0;
- PrioMax = 0;
- for ( i = 0; i < nVars; i++ )
- {
- if ( SuppMax < nSuppSizes[i] || (SuppMax == nSuppSizes[i] && PrioMax < Priority[i]) )
- {
- SuppMax = nSuppSizes[i];
- PrioMax = Priority[i];
- iVarBest = i;
- }
- }
- assert( iVarBest != -1 );
- // copy the resulting literals
- k = 0;
- piLitsRes[k++] = piLits[iVarBest];
- for ( i = 0; i < nVars; i++ )
- {
- if ( pOrder[i] == iVarBest )
- continue;
- piLitsRes[k++] = piLits[pOrder[i]];
- }
- assert( k == nVars );
-}
-
-/**Function*************************************************************
-
- Synopsis [Shrinks multi-input nodes.]
-
- Description [Takes the array of variable priorities pPrios.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DsdShrink_rec( Kit_DsdNtk_t * pNew, Kit_DsdNtk_t * p, int iLit, int pPrios[] )
-{
- Kit_DsdObj_t * pObj;
- Kit_DsdObj_t * pObjNew = NULL; // Suppress "might be used uninitialized"
- unsigned * pTruth, * pTruthNew;
- unsigned i, piLitsNew[16], uSupps[16];
- int iLitFanin, iLitNew;
-
- // consider the case of simple gate
- pObj = Kit_DsdNtkObj( p, Kit_DsdLit2Var(iLit) );
- if ( pObj == NULL )
- return iLit;
- if ( pObj->Type == KIT_DSD_AND )
- {
- // get the supports
- Kit_DsdObjForEachFanin( p, pObj, iLitFanin, i )
- uSupps[i] = Kit_DsdLitSupport( p, iLitFanin );
- // put the largest component last
- // sort other components in the decreasing order of priority of their vars
- Kit_DsdCompSort( pPrios, uSupps, pObj->pFans, pObj->nFans, piLitsNew );
- // construct the two-input node network
- iLitNew = Kit_DsdShrink_rec( pNew, p, piLitsNew[0], pPrios );
- for ( i = 1; i < pObj->nFans; i++ )
- {
- pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_AND, 2 );
- pObjNew->pFans[0] = Kit_DsdShrink_rec( pNew, p, piLitsNew[i], pPrios );
- pObjNew->pFans[1] = iLitNew;
- iLitNew = Kit_DsdVar2Lit( pObjNew->Id, 0 );
- }
- return Kit_DsdVar2Lit( pObjNew->Id, Kit_DsdLitIsCompl(iLit) );
- }
- if ( pObj->Type == KIT_DSD_XOR )
- {
- // get the supports
- Kit_DsdObjForEachFanin( p, pObj, iLitFanin, i )
- {
- assert( !Kit_DsdLitIsCompl(iLitFanin) );
- uSupps[i] = Kit_DsdLitSupport( p, iLitFanin );
- }
- // put the largest component last
- // sort other components in the decreasing order of priority of their vars
- Kit_DsdCompSort( pPrios, uSupps, pObj->pFans, pObj->nFans, piLitsNew );
- // construct the two-input node network
- iLitNew = Kit_DsdShrink_rec( pNew, p, piLitsNew[0], pPrios );
- for ( i = 1; i < pObj->nFans; i++ )
- {
- pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_XOR, 2 );
- pObjNew->pFans[0] = Kit_DsdShrink_rec( pNew, p, piLitsNew[i], pPrios );
- pObjNew->pFans[1] = iLitNew;
- iLitNew = Kit_DsdVar2Lit( pObjNew->Id, 0 );
- }
- return Kit_DsdVar2Lit( pObjNew->Id, Kit_DsdLitIsCompl(iLit) );
- }
- assert( pObj->Type == KIT_DSD_PRIME );
-
- // create new PRIME node
- pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_PRIME, pObj->nFans );
- // copy the truth table
- pTruth = Kit_DsdObjTruth( pObj );
- pTruthNew = Kit_DsdObjTruth( pObjNew );
- Kit_TruthCopy( pTruthNew, pTruth, pObj->nFans );
- // create fanins
- Kit_DsdObjForEachFanin( pNtk, pObj, iLitFanin, i )
- {
- pObjNew->pFans[i] = Kit_DsdShrink_rec( pNew, p, iLitFanin, pPrios );
- // complement the corresponding inputs of the truth table
- if ( Kit_DsdLitIsCompl(pObjNew->pFans[i]) )
- {
- pObjNew->pFans[i] = Kit_DsdLitRegular(pObjNew->pFans[i]);
- Kit_TruthChangePhase( pTruthNew, pObjNew->nFans, i );
- }
- }
- // if the incoming phase is complemented, absorb it into the prime node
- if ( Kit_DsdLitIsCompl(iLit) )
- Kit_TruthNot( pTruthNew, pTruthNew, pObj->nFans );
- return Kit_DsdVar2Lit( pObjNew->Id, 0 );
-}
-
-/**Function*************************************************************
-
- Synopsis [Shrinks the network.]
-
- Description [Transforms the network to have two-input nodes so that the
- higher-ordered nodes were decomposed out first.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_DsdNtk_t * Kit_DsdShrink( Kit_DsdNtk_t * p, int pPrios[] )
-{
- Kit_DsdNtk_t * pNew;
- Kit_DsdObj_t * pObjNew;
- assert( p->nVars <= 16 );
- // create a new network
- pNew = Kit_DsdNtkAlloc( p->nVars );
- // consider simple special cases
- if ( Kit_DsdNtkRoot(p)->Type == KIT_DSD_CONST1 )
- {
- pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_CONST1, 0 );
- pNew->Root = Kit_DsdVar2Lit( pObjNew->Id, Kit_DsdLitIsCompl(p->Root) );
- return pNew;
- }
- if ( Kit_DsdNtkRoot(p)->Type == KIT_DSD_VAR )
- {
- pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_VAR, 1 );
- pObjNew->pFans[0] = Kit_DsdNtkRoot(p)->pFans[0];
- pNew->Root = Kit_DsdVar2Lit( pObjNew->Id, Kit_DsdLitIsCompl(p->Root) );
- return pNew;
- }
- // convert the root node
- pNew->Root = Kit_DsdShrink_rec( pNew, p, p->Root, pPrios );
- return pNew;
-}
-
-/**Function*************************************************************
-
- Synopsis [Rotates the network.]
-
- Description [Transforms prime nodes to have the fanin with the
- highest frequency of supports go first.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdRotate( Kit_DsdNtk_t * p, int pFreqs[] )
-{
- Kit_DsdObj_t * pObj;
- unsigned * pIn, * pOut, * pTemp, k;
- int i, v, Temp, uSuppFanin, iFaninLit, WeightMax, FaninMax, nSwaps;
- int Weights[16];
- // go through the prime nodes
- Kit_DsdNtkForEachObj( p, pObj, i )
- {
- if ( pObj->Type != KIT_DSD_PRIME )
- continue;
- // count the fanin frequencies
- Kit_DsdObjForEachFanin( p, pObj, iFaninLit, k )
- {
- uSuppFanin = Kit_DsdLitSupport( p, iFaninLit );
- Weights[k] = 0;
- for ( v = 0; v < 16; v++ )
- if ( uSuppFanin & (1 << v) )
- Weights[k] += pFreqs[v] - 1;
- }
- // find the most frequent fanin
- WeightMax = 0;
- FaninMax = -1;
- for ( k = 0; k < pObj->nFans; k++ )
- if ( WeightMax < Weights[k] )
- {
- WeightMax = Weights[k];
- FaninMax = k;
- }
- // no need to reorder if there are no frequent fanins
- if ( FaninMax == -1 )
- continue;
- // move the fanins number k to the first place
- nSwaps = 0;
- pIn = Kit_DsdObjTruth(pObj);
- pOut = p->pMem;
-// for ( v = FaninMax; v < ((int)pObj->nFans)-1; v++ )
- for ( v = FaninMax-1; v >= 0; v-- )
- {
- // swap the fanins
- Temp = pObj->pFans[v];
- pObj->pFans[v] = pObj->pFans[v+1];
- pObj->pFans[v+1] = Temp;
- // swap the truth table variables
- Kit_TruthSwapAdjacentVars( pOut, pIn, pObj->nFans, v );
- pTemp = pIn; pIn = pOut; pOut = pTemp;
- nSwaps++;
- }
- if ( nSwaps & 1 )
- Kit_TruthCopy( pOut, pIn, pObj->nFans );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Compute the support.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned Kit_DsdGetSupports_rec( Kit_DsdNtk_t * p, int iLit )
-{
- Kit_DsdObj_t * pObj;
- unsigned uSupport, k;
- int iFaninLit;
- pObj = Kit_DsdNtkObj( p, Kit_DsdLit2Var(iLit) );
- if ( pObj == NULL )
- return Kit_DsdLitSupport( p, iLit );
- uSupport = 0;
- Kit_DsdObjForEachFanin( p, pObj, iFaninLit, k )
- uSupport |= Kit_DsdGetSupports_rec( p, iFaninLit );
- p->pSupps[pObj->Id - p->nVars] = uSupport;
- assert( uSupport <= 0xFFFF );
- return uSupport;
-}
-
-/**Function*************************************************************
-
- Synopsis [Compute the support.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned Kit_DsdGetSupports( Kit_DsdNtk_t * p )
-{
- Kit_DsdObj_t * pRoot;
- unsigned uSupport;
- assert( p->pSupps == NULL );
- p->pSupps = ABC_ALLOC( unsigned, p->nNodes );
- // consider simple special cases
- pRoot = Kit_DsdNtkRoot(p);
- if ( pRoot->Type == KIT_DSD_CONST1 )
- {
- assert( p->nNodes == 1 );
- uSupport = p->pSupps[0] = 0;
- }
- if ( pRoot->Type == KIT_DSD_VAR )
- {
- assert( p->nNodes == 1 );
- uSupport = p->pSupps[0] = Kit_DsdLitSupport( p, pRoot->pFans[0] );
- }
- else
- uSupport = Kit_DsdGetSupports_rec( p, p->Root );
- assert( uSupport <= 0xFFFF );
- return uSupport;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns 1 if there is a component with more than 3 inputs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DsdFindLargeBox_rec( Kit_DsdNtk_t * pNtk, int Id, int Size )
-{
- Kit_DsdObj_t * pObj;
- unsigned iLit, i, RetValue;
- pObj = Kit_DsdNtkObj( pNtk, Id );
- if ( pObj == NULL )
- return 0;
- if ( pObj->Type == KIT_DSD_PRIME && (int)pObj->nFans > Size )
- return 1;
- RetValue = 0;
- Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i )
- RetValue |= Kit_DsdFindLargeBox_rec( pNtk, Kit_DsdLit2Var(iLit), Size );
- return RetValue;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns 1 if there is a component with more than 3 inputs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DsdFindLargeBox( Kit_DsdNtk_t * pNtk, int Size )
-{
- return Kit_DsdFindLargeBox_rec( pNtk, Kit_DsdLit2Var(pNtk->Root), Size );
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns 1 if the non-DSD 4-var func is implementable with two 3-LUTs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DsdRootNodeHasCommonVars( Kit_DsdObj_t * pObj0, Kit_DsdObj_t * pObj1 )
-{
- unsigned i, k;
- for ( i = 0; i < pObj0->nFans; i++ )
- {
- if ( Kit_DsdLit2Var(pObj0->pFans[i]) >= 4 )
- continue;
- for ( k = 0; k < pObj1->nFans; k++ )
- if ( Kit_DsdLit2Var(pObj0->pFans[i]) == Kit_DsdLit2Var(pObj1->pFans[k]) )
- return 1;
- }
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns 1 if the non-DSD 4-var func is implementable with two 3-LUTs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DsdCheckVar4Dec2( Kit_DsdNtk_t * pNtk0, Kit_DsdNtk_t * pNtk1 )
-{
- assert( pNtk0->nVars == 4 );
- assert( pNtk1->nVars == 4 );
- if ( Kit_DsdFindLargeBox(pNtk0, 2) )
- return 0;
- if ( Kit_DsdFindLargeBox(pNtk1, 2) )
- return 0;
- return Kit_DsdRootNodeHasCommonVars( Kit_DsdNtkRoot(pNtk0), Kit_DsdNtkRoot(pNtk1) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs decomposition of the node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdDecompose_rec( Kit_DsdNtk_t * pNtk, Kit_DsdObj_t * pObj, unsigned uSupp, unsigned char * pPar, int nDecMux )
-{
- Kit_DsdObj_t * pRes, * pRes0, * pRes1;
- int nWords = Kit_TruthWordNum(pObj->nFans);
- unsigned * pTruth = Kit_DsdObjTruth(pObj);
- unsigned * pCofs2[2] = { pNtk->pMem, pNtk->pMem + nWords };
- unsigned * pCofs4[2][2] = { {pNtk->pMem + 2 * nWords, pNtk->pMem + 3 * nWords}, {pNtk->pMem + 4 * nWords, pNtk->pMem + 5 * nWords} };
- int i, iLit0, iLit1, nFans0, nFans1, nPairs;
- int fEquals[2][2], fOppos, fPairs[4][4];
- unsigned j, k, nFansNew, uSupp0, uSupp1;
-
- assert( pObj->nFans > 0 );
- assert( pObj->Type == KIT_DSD_PRIME );
- assert( uSupp == (uSupp0 = (unsigned)Kit_TruthSupport(pTruth, pObj->nFans)) );
-
- // compress the truth table
- if ( uSupp != Kit_BitMask(pObj->nFans) )
- {
- nFansNew = Kit_WordCountOnes(uSupp);
- Kit_TruthShrink( pNtk->pMem, pTruth, nFansNew, pObj->nFans, uSupp, 1 );
- for ( j = k = 0; j < pObj->nFans; j++ )
- if ( uSupp & (1 << j) )
- pObj->pFans[k++] = pObj->pFans[j];
- assert( k == nFansNew );
- pObj->nFans = k;
- uSupp = Kit_BitMask(pObj->nFans);
- }
-
- // consider the single variable case
- if ( pObj->nFans == 1 )
- {
- pObj->Type = KIT_DSD_NONE;
- if ( pTruth[0] == 0x55555555 )
- pObj->pFans[0] = Kit_DsdLitNot(pObj->pFans[0]);
- else
- assert( pTruth[0] == 0xAAAAAAAA );
- // update the parent pointer
- *pPar = Kit_DsdLitNotCond( pObj->pFans[0], Kit_DsdLitIsCompl(*pPar) );
- return;
- }
-
- // decompose the output
- if ( !pObj->fMark )
- for ( i = pObj->nFans - 1; i >= 0; i-- )
- {
- // get the two-variable cofactors
- Kit_TruthCofactor0New( pCofs2[0], pTruth, pObj->nFans, i );
- Kit_TruthCofactor1New( pCofs2[1], pTruth, pObj->nFans, i );
-// assert( !Kit_TruthVarInSupport( pCofs2[0], pObj->nFans, i) );
-// assert( !Kit_TruthVarInSupport( pCofs2[1], pObj->nFans, i) );
- // get the constant cofs
- fEquals[0][0] = Kit_TruthIsConst0( pCofs2[0], pObj->nFans );
- fEquals[0][1] = Kit_TruthIsConst0( pCofs2[1], pObj->nFans );
- fEquals[1][0] = Kit_TruthIsConst1( pCofs2[0], pObj->nFans );
- fEquals[1][1] = Kit_TruthIsConst1( pCofs2[1], pObj->nFans );
- fOppos = Kit_TruthIsOpposite( pCofs2[0], pCofs2[1], pObj->nFans );
- assert( !Kit_TruthIsEqual(pCofs2[0], pCofs2[1], pObj->nFans) );
- if ( fEquals[0][0] + fEquals[0][1] + fEquals[1][0] + fEquals[1][1] + fOppos == 0 )
- {
- // check the MUX decomposition
- uSupp0 = Kit_TruthSupport( pCofs2[0], pObj->nFans );
- uSupp1 = Kit_TruthSupport( pCofs2[1], pObj->nFans );
- assert( uSupp == (uSupp0 | uSupp1 | (1<<i)) );
- if ( uSupp0 & uSupp1 )
- continue;
- // perform MUX decomposition
- pRes0 = Kit_DsdObjAlloc( pNtk, KIT_DSD_PRIME, pObj->nFans );
- pRes1 = Kit_DsdObjAlloc( pNtk, KIT_DSD_PRIME, pObj->nFans );
- for ( k = 0; k < pObj->nFans; k++ )
- {
- pRes0->pFans[k] = (uSupp0 & (1 << k))? pObj->pFans[k] : 127;
- pRes1->pFans[k] = (uSupp1 & (1 << k))? pObj->pFans[k] : 127;
- }
- Kit_TruthCopy( Kit_DsdObjTruth(pRes0), pCofs2[0], pObj->nFans );
- Kit_TruthCopy( Kit_DsdObjTruth(pRes1), pCofs2[1], pObj->nFans );
- // update the current one
- assert( pObj->Type == KIT_DSD_PRIME );
- pTruth[0] = 0xCACACACA;
- pObj->nFans = 3;
- pObj->pFans[2] = pObj->pFans[i];
- pObj->pFans[0] = 2*pRes0->Id; pRes0->nRefs++;
- pObj->pFans[1] = 2*pRes1->Id; pRes1->nRefs++;
- // call recursively
- Kit_DsdDecompose_rec( pNtk, pRes0, uSupp0, pObj->pFans + 0, nDecMux );
- Kit_DsdDecompose_rec( pNtk, pRes1, uSupp1, pObj->pFans + 1, nDecMux );
- return;
- }
-
- // create the new node
- pRes = Kit_DsdObjAlloc( pNtk, KIT_DSD_AND, 2 );
- pRes->nRefs++;
- pRes->nFans = 2;
- pRes->pFans[0] = pObj->pFans[i]; pObj->pFans[i] = 127; uSupp &= ~(1 << i);
- pRes->pFans[1] = 2*pObj->Id;
- // update the parent pointer
- *pPar = Kit_DsdLitNotCond( 2 * pRes->Id, Kit_DsdLitIsCompl(*pPar) );
- // consider different decompositions
- if ( fEquals[0][0] )
- {
- Kit_TruthCopy( pTruth, pCofs2[1], pObj->nFans );
- }
- else if ( fEquals[0][1] )
- {
- pRes->pFans[0] = Kit_DsdLitNot(pRes->pFans[0]);
- Kit_TruthCopy( pTruth, pCofs2[0], pObj->nFans );
- }
- else if ( fEquals[1][0] )
- {
- *pPar = Kit_DsdLitNot(*pPar);
- pRes->pFans[1] = Kit_DsdLitNot(pRes->pFans[1]);
- Kit_TruthCopy( pTruth, pCofs2[1], pObj->nFans );
- }
- else if ( fEquals[1][1] )
- {
- *pPar = Kit_DsdLitNot(*pPar);
- pRes->pFans[0] = Kit_DsdLitNot(pRes->pFans[0]);
- pRes->pFans[1] = Kit_DsdLitNot(pRes->pFans[1]);
- Kit_TruthCopy( pTruth, pCofs2[0], pObj->nFans );
- }
- else if ( fOppos )
- {
- pRes->Type = KIT_DSD_XOR;
- Kit_TruthCopy( pTruth, pCofs2[0], pObj->nFans );
- }
- else
- assert( 0 );
- // decompose the remainder
- assert( Kit_DsdObjTruth(pObj) == pTruth );
- Kit_DsdDecompose_rec( pNtk, pObj, uSupp, pRes->pFans + 1, nDecMux );
- return;
- }
- pObj->fMark = 1;
-
- // decompose the input
- for ( i = pObj->nFans - 1; i >= 0; i-- )
- {
- assert( Kit_TruthVarInSupport( pTruth, pObj->nFans, i ) );
- // get the single variale cofactors
- Kit_TruthCofactor0New( pCofs2[0], pTruth, pObj->nFans, i );
- Kit_TruthCofactor1New( pCofs2[1], pTruth, pObj->nFans, i );
- // check the existence of MUX decomposition
- uSupp0 = Kit_TruthSupport( pCofs2[0], pObj->nFans );
- uSupp1 = Kit_TruthSupport( pCofs2[1], pObj->nFans );
- assert( uSupp == (uSupp0 | uSupp1 | (1<<i)) );
- // if one of the cofs is a constant, it is time to check the output again
- if ( uSupp0 == 0 || uSupp1 == 0 )
- {
- pObj->fMark = 0;
- Kit_DsdDecompose_rec( pNtk, pObj, uSupp, pPar, nDecMux );
- return;
- }
- assert( uSupp0 && uSupp1 );
- // get the number of unique variables
- nFans0 = Kit_WordCountOnes( uSupp0 & ~uSupp1 );
- nFans1 = Kit_WordCountOnes( uSupp1 & ~uSupp0 );
- if ( nFans0 == 1 && nFans1 == 1 )
- {
- // get the cofactors w.r.t. the unique variables
- iLit0 = Kit_WordFindFirstBit( uSupp0 & ~uSupp1 );
- iLit1 = Kit_WordFindFirstBit( uSupp1 & ~uSupp0 );
- // get four cofactors
- Kit_TruthCofactor0New( pCofs4[0][0], pCofs2[0], pObj->nFans, iLit0 );
- Kit_TruthCofactor1New( pCofs4[0][1], pCofs2[0], pObj->nFans, iLit0 );
- Kit_TruthCofactor0New( pCofs4[1][0], pCofs2[1], pObj->nFans, iLit1 );
- Kit_TruthCofactor1New( pCofs4[1][1], pCofs2[1], pObj->nFans, iLit1 );
- // check existence conditions
- fEquals[0][0] = Kit_TruthIsEqual( pCofs4[0][0], pCofs4[1][0], pObj->nFans );
- fEquals[0][1] = Kit_TruthIsEqual( pCofs4[0][1], pCofs4[1][1], pObj->nFans );
- fEquals[1][0] = Kit_TruthIsEqual( pCofs4[0][0], pCofs4[1][1], pObj->nFans );
- fEquals[1][1] = Kit_TruthIsEqual( pCofs4[0][1], pCofs4[1][0], pObj->nFans );
- if ( (fEquals[0][0] && fEquals[0][1]) || (fEquals[1][0] && fEquals[1][1]) )
- {
- // construct the MUX
- pRes = Kit_DsdObjAlloc( pNtk, KIT_DSD_PRIME, 3 );
- Kit_DsdObjTruth(pRes)[0] = 0xCACACACA;
- pRes->nRefs++;
- pRes->nFans = 3;
- pRes->pFans[0] = pObj->pFans[iLit0]; pObj->pFans[iLit0] = 127; uSupp &= ~(1 << iLit0);
- pRes->pFans[1] = pObj->pFans[iLit1]; pObj->pFans[iLit1] = 127; uSupp &= ~(1 << iLit1);
- pRes->pFans[2] = pObj->pFans[i]; pObj->pFans[i] = 2 * pRes->Id; // remains in support
- // update the node
-// if ( fEquals[0][0] && fEquals[0][1] )
-// Kit_TruthMuxVar( pTruth, pCofs4[0][0], pCofs4[0][1], pObj->nFans, i );
-// else
-// Kit_TruthMuxVar( pTruth, pCofs4[0][1], pCofs4[0][0], pObj->nFans, i );
- Kit_TruthMuxVar( pTruth, pCofs4[1][0], pCofs4[1][1], pObj->nFans, i );
- if ( fEquals[1][0] && fEquals[1][1] )
- pRes->pFans[0] = Kit_DsdLitNot(pRes->pFans[0]);
- // decompose the remainder
- Kit_DsdDecompose_rec( pNtk, pObj, uSupp, pPar, nDecMux );
- return;
- }
- }
-
- // try other inputs
- for ( k = i+1; k < pObj->nFans; k++ )
- {
- // get four cofactors ik
- Kit_TruthCofactor0New( pCofs4[0][0], pCofs2[0], pObj->nFans, k ); // 00
- Kit_TruthCofactor1New( pCofs4[0][1], pCofs2[0], pObj->nFans, k ); // 01
- Kit_TruthCofactor0New( pCofs4[1][0], pCofs2[1], pObj->nFans, k ); // 10
- Kit_TruthCofactor1New( pCofs4[1][1], pCofs2[1], pObj->nFans, k ); // 11
- // compare equal pairs
- fPairs[0][1] = fPairs[1][0] = Kit_TruthIsEqual( pCofs4[0][0], pCofs4[0][1], pObj->nFans );
- fPairs[0][2] = fPairs[2][0] = Kit_TruthIsEqual( pCofs4[0][0], pCofs4[1][0], pObj->nFans );
- fPairs[0][3] = fPairs[3][0] = Kit_TruthIsEqual( pCofs4[0][0], pCofs4[1][1], pObj->nFans );
- fPairs[1][2] = fPairs[2][1] = Kit_TruthIsEqual( pCofs4[0][1], pCofs4[1][0], pObj->nFans );
- fPairs[1][3] = fPairs[3][1] = Kit_TruthIsEqual( pCofs4[0][1], pCofs4[1][1], pObj->nFans );
- fPairs[2][3] = fPairs[3][2] = Kit_TruthIsEqual( pCofs4[1][0], pCofs4[1][1], pObj->nFans );
- nPairs = fPairs[0][1] + fPairs[0][2] + fPairs[0][3] + fPairs[1][2] + fPairs[1][3] + fPairs[2][3];
- if ( nPairs != 3 && nPairs != 2 )
- continue;
-
- // decomposition exists
- pRes = Kit_DsdObjAlloc( pNtk, KIT_DSD_AND, 2 );
- pRes->nRefs++;
- pRes->nFans = 2;
- pRes->pFans[0] = pObj->pFans[k]; pObj->pFans[k] = 2 * pRes->Id; // remains in support
- pRes->pFans[1] = pObj->pFans[i]; pObj->pFans[i] = 127; uSupp &= ~(1 << i);
- if ( !fPairs[0][1] && !fPairs[0][2] && !fPairs[0][3] ) // 00
- {
- pRes->pFans[0] = Kit_DsdLitNot(pRes->pFans[0]);
- pRes->pFans[1] = Kit_DsdLitNot(pRes->pFans[1]);
- Kit_TruthMuxVar( pTruth, pCofs4[1][1], pCofs4[0][0], pObj->nFans, k );
- }
- else if ( !fPairs[1][0] && !fPairs[1][2] && !fPairs[1][3] ) // 01
- {
- pRes->pFans[1] = Kit_DsdLitNot(pRes->pFans[1]);
- Kit_TruthMuxVar( pTruth, pCofs4[0][0], pCofs4[0][1], pObj->nFans, k );
- }
- else if ( !fPairs[2][0] && !fPairs[2][1] && !fPairs[2][3] ) // 10
- {
- pRes->pFans[0] = Kit_DsdLitNot(pRes->pFans[0]);
- Kit_TruthMuxVar( pTruth, pCofs4[0][0], pCofs4[1][0], pObj->nFans, k );
- }
- else if ( !fPairs[3][0] && !fPairs[3][1] && !fPairs[3][2] ) // 11
- {
-// unsigned uSupp0 = Kit_TruthSupport(pCofs4[0][0], pObj->nFans);
-// unsigned uSupp1 = Kit_TruthSupport(pCofs4[1][1], pObj->nFans);
-// unsigned uSupp;
-// Extra_PrintBinary( stdout, &uSupp0, pObj->nFans ); printf( "\n" );
-// Extra_PrintBinary( stdout, &uSupp1, pObj->nFans ); printf( "\n" );
- Kit_TruthMuxVar( pTruth, pCofs4[0][0], pCofs4[1][1], pObj->nFans, k );
-// uSupp = Kit_TruthSupport(pTruth, pObj->nFans);
-// Extra_PrintBinary( stdout, &uSupp, pObj->nFans ); printf( "\n" ); printf( "\n" );
- }
- else
- {
- assert( fPairs[0][3] && fPairs[1][2] );
- pRes->Type = KIT_DSD_XOR;;
- Kit_TruthMuxVar( pTruth, pCofs4[0][0], pCofs4[0][1], pObj->nFans, k );
- }
- // decompose the remainder
- Kit_DsdDecompose_rec( pNtk, pObj, uSupp, pPar, nDecMux );
- return;
- }
- }
-
- // if all decomposition methods failed and we are still above the limit, perform MUX-decomposition
- if ( nDecMux > 0 && (int)pObj->nFans > nDecMux )
- {
- int iBestVar = Kit_TruthBestCofVar( pTruth, pObj->nFans, pCofs2[0], pCofs2[1] );
- uSupp0 = Kit_TruthSupport( pCofs2[0], pObj->nFans );
- uSupp1 = Kit_TruthSupport( pCofs2[1], pObj->nFans );
- // perform MUX decomposition
- pRes0 = Kit_DsdObjAlloc( pNtk, KIT_DSD_PRIME, pObj->nFans );
- pRes1 = Kit_DsdObjAlloc( pNtk, KIT_DSD_PRIME, pObj->nFans );
- for ( k = 0; k < pObj->nFans; k++ )
- pRes0->pFans[k] = pRes1->pFans[k] = pObj->pFans[k];
- Kit_TruthCopy( Kit_DsdObjTruth(pRes0), pCofs2[0], pObj->nFans );
- Kit_TruthCopy( Kit_DsdObjTruth(pRes1), pCofs2[1], pObj->nFans );
- // update the current one
- assert( pObj->Type == KIT_DSD_PRIME );
- pTruth[0] = 0xCACACACA;
- pObj->nFans = 3;
- pObj->pFans[2] = pObj->pFans[iBestVar];
- pObj->pFans[0] = 2*pRes0->Id; pRes0->nRefs++;
- pObj->pFans[1] = 2*pRes1->Id; pRes1->nRefs++;
- // call recursively
- Kit_DsdDecompose_rec( pNtk, pRes0, uSupp0, pObj->pFans + 0, nDecMux );
- Kit_DsdDecompose_rec( pNtk, pRes1, uSupp1, pObj->pFans + 1, nDecMux );
- }
-
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs decomposition of the truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_DsdNtk_t * Kit_DsdDecomposeInt( unsigned * pTruth, int nVars, int nDecMux )
-{
- Kit_DsdNtk_t * pNtk;
- Kit_DsdObj_t * pObj;
- unsigned uSupp;
- int i, nVarsReal;
- assert( nVars <= 16 );
- pNtk = Kit_DsdNtkAlloc( nVars );
- pNtk->Root = Kit_DsdVar2Lit( pNtk->nVars, 0 );
- // create the first node
- pObj = Kit_DsdObjAlloc( pNtk, KIT_DSD_PRIME, nVars );
- assert( pNtk->pNodes[0] == pObj );
- for ( i = 0; i < nVars; i++ )
- pObj->pFans[i] = Kit_DsdVar2Lit( i, 0 );
- Kit_TruthCopy( Kit_DsdObjTruth(pObj), pTruth, nVars );
- uSupp = Kit_TruthSupport( pTruth, nVars );
- // consider special cases
- nVarsReal = Kit_WordCountOnes( uSupp );
- if ( nVarsReal == 0 )
- {
- pObj->Type = KIT_DSD_CONST1;
- pObj->nFans = 0;
- if ( pTruth[0] == 0 )
- pNtk->Root = Kit_DsdLitNot(pNtk->Root);
- return pNtk;
- }
- if ( nVarsReal == 1 )
- {
- pObj->Type = KIT_DSD_VAR;
- pObj->nFans = 1;
- pObj->pFans[0] = Kit_DsdVar2Lit( Kit_WordFindFirstBit(uSupp), (pTruth[0] & 1) );
- return pNtk;
- }
- Kit_DsdDecompose_rec( pNtk, pNtk->pNodes[0], uSupp, &pNtk->Root, nDecMux );
- return pNtk;
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs decomposition of the truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_DsdNtk_t * Kit_DsdDecompose( unsigned * pTruth, int nVars )
-{
- return Kit_DsdDecomposeInt( pTruth, nVars, 0 );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs decomposition of the truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_DsdNtk_t * Kit_DsdDecomposeExpand( unsigned * pTruth, int nVars )
-{
- Kit_DsdNtk_t * pNtk, * pTemp;
- pNtk = Kit_DsdDecomposeInt( pTruth, nVars, 0 );
- pNtk = Kit_DsdExpand( pTemp = pNtk );
- Kit_DsdNtkFree( pTemp );
- return pNtk;
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs decomposition of the truth table.]
-
- Description [Uses MUXes to break-down large prime nodes.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_DsdNtk_t * Kit_DsdDecomposeMux( unsigned * pTruth, int nVars, int nDecMux )
-{
-/*
- Kit_DsdNtk_t * pNew;
- Kit_DsdObj_t * pObjNew;
- assert( nVars <= 16 );
- // create a new network
- pNew = Kit_DsdNtkAlloc( nVars );
- // consider simple special cases
- if ( nVars == 0 )
- {
- pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_CONST1, 0 );
- pNew->Root = Kit_DsdVar2Lit( pObjNew->Id, (int)(pTruth[0] == 0) );
- return pNew;
- }
- if ( nVars == 1 )
- {
- pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_VAR, 1 );
- pObjNew->pFans[0] = Kit_DsdVar2Lit( 0, 0 );
- pNew->Root = Kit_DsdVar2Lit( pObjNew->Id, (int)(pTruth[0] != 0xAAAAAAAA) );
- return pNew;
- }
-*/
- return Kit_DsdDecomposeInt( pTruth, nVars, nDecMux );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs decomposition of the truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DsdTestCofs( Kit_DsdNtk_t * pNtk, unsigned * pTruthInit )
-{
- Kit_DsdNtk_t * pNtk0, * pNtk1, * pTemp;
-// Kit_DsdObj_t * pRoot;
- unsigned * pCofs2[2] = { pNtk->pMem, pNtk->pMem + Kit_TruthWordNum(pNtk->nVars) };
- unsigned i, * pTruth;
- int fVerbose = 1;
- int RetValue = 0;
-
- pTruth = pTruthInit;
-// pRoot = Kit_DsdNtkRoot(pNtk);
-// pTruth = Kit_DsdObjTruth(pRoot);
-// assert( pRoot->nFans == pNtk->nVars );
-
- if ( fVerbose )
- {
- printf( "Function: " );
-// Extra_PrintBinary( stdout, pTruth, (1 << pNtk->nVars) );
- Extra_PrintHexadecimal( stdout, pTruth, pNtk->nVars );
- printf( "\n" );
- Kit_DsdPrint( stdout, pNtk ), printf( "\n" );
- }
- for ( i = 0; i < pNtk->nVars; i++ )
- {
- Kit_TruthCofactor0New( pCofs2[0], pTruth, pNtk->nVars, i );
- pNtk0 = Kit_DsdDecompose( pCofs2[0], pNtk->nVars );
- pNtk0 = Kit_DsdExpand( pTemp = pNtk0 );
- Kit_DsdNtkFree( pTemp );
-
- if ( fVerbose )
- {
- printf( "Cof%d0: ", i );
- Kit_DsdPrint( stdout, pNtk0 ), printf( "\n" );
- }
-
- Kit_TruthCofactor1New( pCofs2[1], pTruth, pNtk->nVars, i );
- pNtk1 = Kit_DsdDecompose( pCofs2[1], pNtk->nVars );
- pNtk1 = Kit_DsdExpand( pTemp = pNtk1 );
- Kit_DsdNtkFree( pTemp );
-
- if ( fVerbose )
- {
- printf( "Cof%d1: ", i );
- Kit_DsdPrint( stdout, pNtk1 ), printf( "\n" );
- }
-
-// if ( Kit_DsdCheckVar4Dec2( pNtk0, pNtk1 ) )
-// RetValue = 1;
-
- Kit_DsdNtkFree( pNtk0 );
- Kit_DsdNtkFree( pNtk1 );
- }
- if ( fVerbose )
- printf( "\n" );
-
- return RetValue;
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs decomposition of the truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DsdEval( unsigned * pTruth, int nVars, int nLutSize )
-{
- Kit_DsdMan_t * p;
- Kit_DsdNtk_t * pNtk;
- unsigned * pTruthC;
- int Result;
-
- // decompose the function
- pNtk = Kit_DsdDecompose( pTruth, nVars );
- Result = Kit_DsdCountLuts( pNtk, nLutSize );
-// printf( "\n" );
-// Kit_DsdPrint( stdout, pNtk );
-// printf( "Eval = %d.\n", Result );
-
- // recompute the truth table
- p = Kit_DsdManAlloc( nVars, Kit_DsdNtkObjNum(pNtk) );
- pTruthC = Kit_DsdTruthCompute( p, pNtk );
- if ( !Kit_TruthIsEqual( pTruth, pTruthC, nVars ) )
- printf( "Verification failed.\n" );
- Kit_DsdManFree( p );
-
- Kit_DsdNtkFree( pNtk );
- return Result;
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs decomposition of the truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdVerify( Kit_DsdNtk_t * pNtk, unsigned * pTruth, int nVars )
-{
- Kit_DsdMan_t * p;
- unsigned * pTruthC;
- p = Kit_DsdManAlloc( nVars, Kit_DsdNtkObjNum(pNtk)+2 );
- pTruthC = Kit_DsdTruthCompute( p, pNtk );
- if ( !Extra_TruthIsEqual( pTruth, pTruthC, nVars ) )
- printf( "Verification failed.\n" );
- Kit_DsdManFree( p );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs decomposition of the truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdTest( unsigned * pTruth, int nVars )
-{
- Kit_DsdMan_t * p;
- unsigned * pTruthC;
- Kit_DsdNtk_t * pNtk, * pTemp;
- pNtk = Kit_DsdDecompose( pTruth, nVars );
-
-// if ( Kit_DsdFindLargeBox(pNtk, Kit_DsdLit2Var(pNtk->Root)) )
-// Kit_DsdPrint( stdout, pNtk );
-
-// if ( Kit_DsdNtkRoot(pNtk)->nFans == (unsigned)nVars && nVars == 6 )
-
-// printf( "\n" );
-// Kit_DsdPrint( stdout, pNtk );
-
- pNtk = Kit_DsdExpand( pTemp = pNtk );
- Kit_DsdNtkFree( pTemp );
-
- Kit_DsdPrint( stdout, pNtk ), printf( "\n" );
-
-// if ( Kit_DsdFindLargeBox(pNtk, Kit_DsdLit2Var(pNtk->Root)) )
-// Kit_DsdTestCofs( pNtk, pTruth );
-
- // recompute the truth table
- p = Kit_DsdManAlloc( nVars, Kit_DsdNtkObjNum(pNtk) );
- pTruthC = Kit_DsdTruthCompute( p, pNtk );
-// Extra_PrintBinary( stdout, pTruth, 1 << nVars ); printf( "\n" );
-// Extra_PrintBinary( stdout, pTruthC, 1 << nVars ); printf( "\n" );
- if ( Extra_TruthIsEqual( pTruth, pTruthC, nVars ) )
- {
-// printf( "Verification is okay.\n" );
- }
- else
- printf( "Verification failed.\n" );
- Kit_DsdManFree( p );
-
-
- Kit_DsdNtkFree( pNtk );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs decomposition of the truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdPrecompute4Vars()
-{
- Kit_DsdMan_t * p;
- Kit_DsdNtk_t * pNtk, * pTemp;
- FILE * pFile;
- unsigned uTruth;
- unsigned * pTruthC;
- char Buffer[256];
- int i, RetValue;
- int Counter1 = 0, Counter2 = 0;
-
- pFile = fopen( "5npn/npn4.txt", "r" );
- for ( i = 0; fgets( Buffer, 100, pFile ); i++ )
- {
- Buffer[6] = 0;
- Extra_ReadHexadecimal( &uTruth, Buffer+2, 4 );
- uTruth = ((uTruth & 0xffff) << 16) | (uTruth & 0xffff);
- pNtk = Kit_DsdDecompose( &uTruth, 4 );
-
- pNtk = Kit_DsdExpand( pTemp = pNtk );
- Kit_DsdNtkFree( pTemp );
-
-
- if ( Kit_DsdFindLargeBox(pNtk, 3) )
- {
-// RetValue = 0;
- RetValue = Kit_DsdTestCofs( pNtk, &uTruth );
- printf( "\n" );
- printf( "%3d : Non-DSD function %s %s\n", i, Buffer + 2, RetValue? "implementable" : "" );
- Kit_DsdPrint( stdout, pNtk ), printf( "\n" );
-
- Counter1++;
- Counter2 += RetValue;
- }
-
-/*
- printf( "%3d : Function %s ", i, Buffer + 2 );
- if ( !Kit_DsdFindLargeBox(pNtk, 3) )
- Kit_DsdPrint( stdout, pNtk );
- else
- printf( "\n" );
-*/
-
- p = Kit_DsdManAlloc( 4, Kit_DsdNtkObjNum(pNtk) );
- pTruthC = Kit_DsdTruthCompute( p, pNtk );
- if ( !Extra_TruthIsEqual( &uTruth, pTruthC, 4 ) )
- printf( "Verification failed.\n" );
- Kit_DsdManFree( p );
-
- Kit_DsdNtkFree( pNtk );
- }
- fclose( pFile );
- printf( "non-DSD = %d implementable = %d\n", Counter1, Counter2 );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Returns the set of cofactoring variables.]
-
- Description [If there is no DSD components returns 0.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DsdCofactoringGetVars( Kit_DsdNtk_t ** ppNtk, int nSize, int * pVars )
-{
- Kit_DsdObj_t * pObj;
- unsigned m;
- int i, k, v, Var, nVars, iFaninLit;
- // go through all the networks
- nVars = 0;
- for ( i = 0; i < nSize; i++ )
- {
- // go through the prime objects of each networks
- Kit_DsdNtkForEachObj( ppNtk[i], pObj, k )
- {
- if ( pObj->Type != KIT_DSD_PRIME )
- continue;
- if ( pObj->nFans == 3 )
- continue;
- // collect direct fanin variables
- Kit_DsdObjForEachFanin( ppNtk[i], pObj, iFaninLit, m )
- {
- if ( !Kit_DsdLitIsLeaf(ppNtk[i], iFaninLit) )
- continue;
- // add it to the array
- Var = Kit_DsdLit2Var( iFaninLit );
- for ( v = 0; v < nVars; v++ )
- if ( pVars[v] == Var )
- break;
- if ( v == nVars )
- pVars[nVars++] = Var;
- }
- }
- }
- return nVars;
-}
-
-/**Function*************************************************************
-
- Synopsis [Canonical decomposition into completely DSD-structure.]
-
- Description [Returns the number of cofactoring steps. Also returns
- the cofactoring variables in pVars.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_DsdCofactoring( unsigned * pTruth, int nVars, int * pCofVars, int nLimit, int fVerbose )
-{
- Kit_DsdNtk_t * ppNtks[5][16] = {
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
- };
- Kit_DsdNtk_t * pTemp;
- unsigned * ppCofs[5][16];
- int pTryVars[16], nTryVars;
- int nPrimeSizeMin, nPrimeSizeMax, nPrimeSizeCur;
- int nSuppSizeMin, nSuppSizeMax, iVarBest;
- int i, k, v, nStep, nSize, nMemSize;
- assert( nLimit < 5 );
-
- // allocate storage for cofactors
- nMemSize = Kit_TruthWordNum(nVars);
- ppCofs[0][0] = ABC_ALLOC( unsigned, 80 * nMemSize );
- nSize = 0;
- for ( i = 0; i < 5; i++ )
- for ( k = 0; k < 16; k++ )
- ppCofs[i][k] = ppCofs[0][0] + nMemSize * nSize++;
- assert( nSize == 80 );
-
- // copy the function
- Kit_TruthCopy( ppCofs[0][0], pTruth, nVars );
- ppNtks[0][0] = Kit_DsdDecompose( ppCofs[0][0], nVars );
-
- if ( fVerbose )
- printf( "\nProcessing prime function with %d support variables:\n", nVars );
-
- // perform recursive cofactoring
- for ( nStep = 0; nStep < nLimit; nStep++ )
- {
- nSize = (1 << nStep);
- // find the variables to use in the cofactoring step
- nTryVars = Kit_DsdCofactoringGetVars( ppNtks[nStep], nSize, pTryVars );
- if ( nTryVars == 0 )
- break;
- // cofactor w.r.t. the above variables
- iVarBest = -1;
- nPrimeSizeMin = 10000;
- nSuppSizeMin = 10000;
- for ( v = 0; v < nTryVars; v++ )
- {
- nPrimeSizeMax = 0;
- nSuppSizeMax = 0;
- for ( i = 0; i < nSize; i++ )
- {
- // cofactor and decompose cofactors
- Kit_TruthCofactor0New( ppCofs[nStep+1][2*i+0], ppCofs[nStep][i], nVars, pTryVars[v] );
- Kit_TruthCofactor1New( ppCofs[nStep+1][2*i+1], ppCofs[nStep][i], nVars, pTryVars[v] );
- ppNtks[nStep+1][2*i+0] = Kit_DsdDecompose( ppCofs[nStep+1][2*i+0], nVars );
- ppNtks[nStep+1][2*i+1] = Kit_DsdDecompose( ppCofs[nStep+1][2*i+1], nVars );
- // compute the largest non-decomp block
- nPrimeSizeCur = Kit_DsdNonDsdSizeMax(ppNtks[nStep+1][2*i+0]);
- nPrimeSizeMax = KIT_MAX( nPrimeSizeMax, nPrimeSizeCur );
- nPrimeSizeCur = Kit_DsdNonDsdSizeMax(ppNtks[nStep+1][2*i+1]);
- nPrimeSizeMax = KIT_MAX( nPrimeSizeMax, nPrimeSizeCur );
- // compute the sum total of supports
- nSuppSizeMax += Kit_TruthSupportSize( ppCofs[nStep+1][2*i+0], nVars );
- nSuppSizeMax += Kit_TruthSupportSize( ppCofs[nStep+1][2*i+1], nVars );
- // free the networks
- Kit_DsdNtkFree( ppNtks[nStep+1][2*i+0] );
- Kit_DsdNtkFree( ppNtks[nStep+1][2*i+1] );
- }
- // find the min max support size of the prime component
- if ( nPrimeSizeMin > nPrimeSizeMax || (nPrimeSizeMin == nPrimeSizeMax && nSuppSizeMin > nSuppSizeMax) )
- {
- nPrimeSizeMin = nPrimeSizeMax;
- nSuppSizeMin = nSuppSizeMax;
- iVarBest = pTryVars[v];
- }
- }
- assert( iVarBest != -1 );
- // save the variable
- if ( pCofVars )
- pCofVars[nStep] = iVarBest;
- // cofactor w.r.t. the best
- for ( i = 0; i < nSize; i++ )
- {
- Kit_TruthCofactor0New( ppCofs[nStep+1][2*i+0], ppCofs[nStep][i], nVars, iVarBest );
- Kit_TruthCofactor1New( ppCofs[nStep+1][2*i+1], ppCofs[nStep][i], nVars, iVarBest );
- ppNtks[nStep+1][2*i+0] = Kit_DsdDecompose( ppCofs[nStep+1][2*i+0], nVars );
- ppNtks[nStep+1][2*i+1] = Kit_DsdDecompose( ppCofs[nStep+1][2*i+1], nVars );
- if ( fVerbose )
- {
- ppNtks[nStep+1][2*i+0] = Kit_DsdExpand( pTemp = ppNtks[nStep+1][2*i+0] );
- Kit_DsdNtkFree( pTemp );
- ppNtks[nStep+1][2*i+1] = Kit_DsdExpand( pTemp = ppNtks[nStep+1][2*i+1] );
- Kit_DsdNtkFree( pTemp );
-
- printf( "Cof%d%d: ", nStep+1, 2*i+0 );
- Kit_DsdPrint( stdout, ppNtks[nStep+1][2*i+0] ), printf( "\n" );
- printf( "Cof%d%d: ", nStep+1, 2*i+1 );
- Kit_DsdPrint( stdout, ppNtks[nStep+1][2*i+1] ), printf( "\n" );
- }
- }
- }
-
- // free the networks
- for ( i = 0; i < 5; i++ )
- for ( k = 0; k < 16; k++ )
- if ( ppNtks[i][k] )
- Kit_DsdNtkFree( ppNtks[i][k] );
- ABC_FREE( ppCofs[0][0] );
-
- assert( nStep <= nLimit );
- return nStep;
-}
-
-/**Function*************************************************************
-
- Synopsis [Canonical decomposition into completely DSD-structure.]
-
- Description [Returns the number of cofactoring steps. Also returns
- the cofactoring variables in pVars.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_DsdPrintCofactors( unsigned * pTruth, int nVars, int nCofLevel, int fVerbose )
-{
- Kit_DsdNtk_t * ppNtks[32] = {0}, * pTemp;
- unsigned * ppCofs[5][16];
- int piCofVar[5];
- int nPrimeSizeMax, nPrimeSizeCur, nSuppSizeMax;
- int i, k, v1, v2, v3, v4, s, nSteps, nSize, nMemSize;
- assert( nCofLevel < 5 );
-
- // print the function
- ppNtks[0] = Kit_DsdDecompose( pTruth, nVars );
- ppNtks[0] = Kit_DsdExpand( pTemp = ppNtks[0] );
- Kit_DsdNtkFree( pTemp );
- if ( fVerbose )
- Kit_DsdPrint( stdout, ppNtks[0] ), printf( "\n" );
- Kit_DsdNtkFree( ppNtks[0] );
-
- // allocate storage for cofactors
- nMemSize = Kit_TruthWordNum(nVars);
- ppCofs[0][0] = ABC_ALLOC( unsigned, 80 * nMemSize );
- nSize = 0;
- for ( i = 0; i < 5; i++ )
- for ( k = 0; k < 16; k++ )
- ppCofs[i][k] = ppCofs[0][0] + nMemSize * nSize++;
- assert( nSize == 80 );
-
- // copy the function
- Kit_TruthCopy( ppCofs[0][0], pTruth, nVars );
-
- if ( nCofLevel == 1 )
- for ( v1 = 0; v1 < nVars; v1++ )
- {
- nSteps = 0;
- piCofVar[nSteps++] = v1;
-
- printf( " Variables { " );
- for ( i = 0; i < nSteps; i++ )
- printf( "%c ", 'a' + piCofVar[i] );
- printf( "}\n" );
-
- // single cofactors
- for ( s = 1; s <= nSteps; s++ )
- {
- for ( k = 0; k < s; k++ )
- {
- nSize = (1 << k);
- for ( i = 0; i < nSize; i++ )
- {
- Kit_TruthCofactor0New( ppCofs[k+1][2*i+0], ppCofs[k][i], nVars, piCofVar[k] );
- Kit_TruthCofactor1New( ppCofs[k+1][2*i+1], ppCofs[k][i], nVars, piCofVar[k] );
- }
- }
- }
- // compute DSD networks
- nSize = (1 << nSteps);
- nPrimeSizeMax = 0;
- nSuppSizeMax = 0;
- for ( i = 0; i < nSize; i++ )
- {
- ppNtks[i] = Kit_DsdDecompose( ppCofs[nSteps][i], nVars );
- ppNtks[i] = Kit_DsdExpand( pTemp = ppNtks[i] );
- Kit_DsdNtkFree( pTemp );
- if ( fVerbose )
- {
- printf( "Cof%d%d: ", nSteps, i );
- Kit_DsdPrint( stdout, ppNtks[i] ), printf( "\n" );
- }
- // compute the largest non-decomp block
- nPrimeSizeCur = Kit_DsdNonDsdSizeMax(ppNtks[i]);
- nPrimeSizeMax = KIT_MAX( nPrimeSizeMax, nPrimeSizeCur );
- Kit_DsdNtkFree( ppNtks[i] );
- nSuppSizeMax += Kit_TruthSupportSize( ppCofs[nSteps][i], nVars );
- }
- printf( "Max = %2d. Supps = %2d.\n", nPrimeSizeMax, nSuppSizeMax );
- }
-
- if ( nCofLevel == 2 )
- for ( v1 = 0; v1 < nVars; v1++ )
- for ( v2 = v1+1; v2 < nVars; v2++ )
- {
- nSteps = 0;
- piCofVar[nSteps++] = v1;
- piCofVar[nSteps++] = v2;
-
- printf( " Variables { " );
- for ( i = 0; i < nSteps; i++ )
- printf( "%c ", 'a' + piCofVar[i] );
- printf( "}\n" );
-
- // single cofactors
- for ( s = 1; s <= nSteps; s++ )
- {
- for ( k = 0; k < s; k++ )
- {
- nSize = (1 << k);
- for ( i = 0; i < nSize; i++ )
- {
- Kit_TruthCofactor0New( ppCofs[k+1][2*i+0], ppCofs[k][i], nVars, piCofVar[k] );
- Kit_TruthCofactor1New( ppCofs[k+1][2*i+1], ppCofs[k][i], nVars, piCofVar[k] );
- }
- }
- }
- // compute DSD networks
- nSize = (1 << nSteps);
- nPrimeSizeMax = 0;
- nSuppSizeMax = 0;
- for ( i = 0; i < nSize; i++ )
- {
- ppNtks[i] = Kit_DsdDecompose( ppCofs[nSteps][i], nVars );
- ppNtks[i] = Kit_DsdExpand( pTemp = ppNtks[i] );
- Kit_DsdNtkFree( pTemp );
- if ( fVerbose )
- {
- printf( "Cof%d%d: ", nSteps, i );
- Kit_DsdPrint( stdout, ppNtks[i] ), printf( "\n" );
- }
- // compute the largest non-decomp block
- nPrimeSizeCur = Kit_DsdNonDsdSizeMax(ppNtks[i]);
- nPrimeSizeMax = KIT_MAX( nPrimeSizeMax, nPrimeSizeCur );
- Kit_DsdNtkFree( ppNtks[i] );
- nSuppSizeMax += Kit_TruthSupportSize( ppCofs[nSteps][i], nVars );
- }
- printf( "Max = %2d. Supps = %2d.\n", nPrimeSizeMax, nSuppSizeMax );
- }
-
- if ( nCofLevel == 3 )
- for ( v1 = 0; v1 < nVars; v1++ )
- for ( v2 = v1+1; v2 < nVars; v2++ )
- for ( v3 = v2+1; v3 < nVars; v3++ )
- {
- nSteps = 0;
- piCofVar[nSteps++] = v1;
- piCofVar[nSteps++] = v2;
- piCofVar[nSteps++] = v3;
-
- printf( " Variables { " );
- for ( i = 0; i < nSteps; i++ )
- printf( "%c ", 'a' + piCofVar[i] );
- printf( "}\n" );
-
- // single cofactors
- for ( s = 1; s <= nSteps; s++ )
- {
- for ( k = 0; k < s; k++ )
- {
- nSize = (1 << k);
- for ( i = 0; i < nSize; i++ )
- {
- Kit_TruthCofactor0New( ppCofs[k+1][2*i+0], ppCofs[k][i], nVars, piCofVar[k] );
- Kit_TruthCofactor1New( ppCofs[k+1][2*i+1], ppCofs[k][i], nVars, piCofVar[k] );
- }
- }
- }
- // compute DSD networks
- nSize = (1 << nSteps);
- nPrimeSizeMax = 0;
- nSuppSizeMax = 0;
- for ( i = 0; i < nSize; i++ )
- {
- ppNtks[i] = Kit_DsdDecompose( ppCofs[nSteps][i], nVars );
- ppNtks[i] = Kit_DsdExpand( pTemp = ppNtks[i] );
- Kit_DsdNtkFree( pTemp );
- if ( fVerbose )
- {
- printf( "Cof%d%d: ", nSteps, i );
- Kit_DsdPrint( stdout, ppNtks[i] ), printf( "\n" );
- }
- // compute the largest non-decomp block
- nPrimeSizeCur = Kit_DsdNonDsdSizeMax(ppNtks[i]);
- nPrimeSizeMax = KIT_MAX( nPrimeSizeMax, nPrimeSizeCur );
- Kit_DsdNtkFree( ppNtks[i] );
- nSuppSizeMax += Kit_TruthSupportSize( ppCofs[nSteps][i], nVars );
- }
- printf( "Max = %2d. Supps = %2d.\n", nPrimeSizeMax, nSuppSizeMax );
- }
-
- if ( nCofLevel == 4 )
- for ( v1 = 0; v1 < nVars; v1++ )
- for ( v2 = v1+1; v2 < nVars; v2++ )
- for ( v3 = v2+1; v3 < nVars; v3++ )
- for ( v4 = v3+1; v4 < nVars; v4++ )
- {
- nSteps = 0;
- piCofVar[nSteps++] = v1;
- piCofVar[nSteps++] = v2;
- piCofVar[nSteps++] = v3;
- piCofVar[nSteps++] = v4;
-
- printf( " Variables { " );
- for ( i = 0; i < nSteps; i++ )
- printf( "%c ", 'a' + piCofVar[i] );
- printf( "}\n" );
-
- // single cofactors
- for ( s = 1; s <= nSteps; s++ )
- {
- for ( k = 0; k < s; k++ )
- {
- nSize = (1 << k);
- for ( i = 0; i < nSize; i++ )
- {
- Kit_TruthCofactor0New( ppCofs[k+1][2*i+0], ppCofs[k][i], nVars, piCofVar[k] );
- Kit_TruthCofactor1New( ppCofs[k+1][2*i+1], ppCofs[k][i], nVars, piCofVar[k] );
- }
- }
- }
- // compute DSD networks
- nSize = (1 << nSteps);
- nPrimeSizeMax = 0;
- nSuppSizeMax = 0;
- for ( i = 0; i < nSize; i++ )
- {
- ppNtks[i] = Kit_DsdDecompose( ppCofs[nSteps][i], nVars );
- ppNtks[i] = Kit_DsdExpand( pTemp = ppNtks[i] );
- Kit_DsdNtkFree( pTemp );
- if ( fVerbose )
- {
- printf( "Cof%d%d: ", nSteps, i );
- Kit_DsdPrint( stdout, ppNtks[i] ), printf( "\n" );
- }
- // compute the largest non-decomp block
- nPrimeSizeCur = Kit_DsdNonDsdSizeMax(ppNtks[i]);
- nPrimeSizeMax = KIT_MAX( nPrimeSizeMax, nPrimeSizeCur );
- Kit_DsdNtkFree( ppNtks[i] );
- nSuppSizeMax += Kit_TruthSupportSize( ppCofs[nSteps][i], nVars );
- }
- printf( "Max = %2d. Supps = %2d.\n", nPrimeSizeMax, nSuppSizeMax );
- }
-
-
- ABC_FREE( ppCofs[0][0] );
-}
-
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-char ** Kit_DsdNpn4ClassNames()
-{
- static const char * pNames[222] = {
- "F = 0", /* 0 */
- "F = (!d*(!c*(!b*!a)))", /* 1 */
- "F = (!d*(!c*!b))", /* 2 */
- "F = (!d*(!c*(b+a)))", /* 3 */
- "F = (!d*(!c*!(b*a)))", /* 4 */
- "F = (!d*!c)", /* 5 */
- "F = (!d*16(a,b,c))", /* 6 */
- "F = (!d*17(a,b,c))", /* 7 */
- "F = (!d*18(a,b,c))", /* 8 */
- "F = (!d*19(a,b,c))", /* 9 */
- "F = (!d*CA(!b,!c,a))", /* 10 */
- "F = (!d*(c+!(!b*!a)))", /* 11 */
- "F = (!d*!(c*!(!b*!a)))", /* 12 */
- "F = (!d*(c+b))", /* 13 */
- "F = (!d*3D(a,b,c))", /* 14 */
- "F = (!d*!(c*b))", /* 15 */
- "F = (!d*(c+(b+!a)))", /* 16 */
- "F = (!d*6B(a,b,c))", /* 17 */
- "F = (!d*!(c*!(b+a)))", /* 18 */
- "F = (!d*7E(a,b,c))", /* 19 */
- "F = (!d*!(c*(b*a)))", /* 20 */
- "F = (!d)", /* 21 */
- "F = 0116(a,b,c,d)", /* 22 */
- "F = 0117(a,b,c,d)", /* 23 */
- "F = 0118(a,b,c,d)", /* 24 */
- "F = 0119(a,b,c,d)", /* 25 */
- "F = 011A(a,b,c,d)", /* 26 */
- "F = 011B(a,b,c,d)", /* 27 */
- "F = 29((!b*!a),c,d)", /* 28 */
- "F = 2B((!b*!a),c,d)", /* 29 */
- "F = 012C(a,b,c,d)", /* 30 */
- "F = 012D(a,b,c,d)", /* 31 */
- "F = 012F(a,b,c,d)", /* 32 */
- "F = 013C(a,b,c,d)", /* 33 */
- "F = 013D(a,b,c,d)", /* 34 */
- "F = 013E(a,b,c,d)", /* 35 */
- "F = 013F(a,b,c,d)", /* 36 */
- "F = 0168(a,b,c,d)", /* 37 */
- "F = 0169(a,b,c,d)", /* 38 */
- "F = 016A(a,b,c,d)", /* 39 */
- "F = 016B(a,b,c,d)", /* 40 */
- "F = 016E(a,b,c,d)", /* 41 */
- "F = 016F(a,b,c,d)", /* 42 */
- "F = 017E(a,b,c,d)", /* 43 */
- "F = 017F(a,b,c,d)", /* 44 */
- "F = 0180(a,b,c,d)", /* 45 */
- "F = 0181(a,b,c,d)", /* 46 */
- "F = 0182(a,b,c,d)", /* 47 */
- "F = 0183(a,b,c,d)", /* 48 */
- "F = 0186(a,b,c,d)", /* 49 */
- "F = 0187(a,b,c,d)", /* 50 */
- "F = 0189(a,b,c,d)", /* 51 */
- "F = 018B(a,b,c,d)", /* 52 */
- "F = 018F(a,b,c,d)", /* 53 */
- "F = 0196(a,b,c,d)", /* 54 */
- "F = 0197(a,b,c,d)", /* 55 */
- "F = 0198(a,b,c,d)", /* 56 */
- "F = 0199(a,b,c,d)", /* 57 */
- "F = 019A(a,b,c,d)", /* 58 */
- "F = 019B(a,b,c,d)", /* 59 */
- "F = 019E(a,b,c,d)", /* 60 */
- "F = 019F(a,b,c,d)", /* 61 */
- "F = 42(a,(!c*!b),d)", /* 62 */
- "F = 46(a,(!c*!b),d)", /* 63 */
- "F = 4A(a,(!c*!b),d)", /* 64 */
- "F = CA((!c*!b),!d,a)", /* 65 */
- "F = 01AC(a,b,c,d)", /* 66 */
- "F = 01AD(a,b,c,d)", /* 67 */
- "F = 01AE(a,b,c,d)", /* 68 */
- "F = 01AF(a,b,c,d)", /* 69 */
- "F = 01BC(a,b,c,d)", /* 70 */
- "F = 01BD(a,b,c,d)", /* 71 */
- "F = 01BE(a,b,c,d)", /* 72 */
- "F = 01BF(a,b,c,d)", /* 73 */
- "F = 01E8(a,b,c,d)", /* 74 */
- "F = 01E9(a,b,c,d)", /* 75 */
- "F = 01EA(a,b,c,d)", /* 76 */
- "F = 01EB(a,b,c,d)", /* 77 */
- "F = 25((!b*!a),c,d)", /* 78 */
- "F = !CA(d,c,(!b*!a))", /* 79 */
- "F = (d+!(!c*(!b*!a)))", /* 80 */
- "F = 16(b,c,d)", /* 81 */
- "F = 033D(a,b,c,d)", /* 82 */
- "F = 17(b,c,d)", /* 83 */
- "F = ((!d*!a)+(!c*!b))", /* 84 */
- "F = !(!(!c*!b)*!(!d*!a))", /* 85 */
- "F = 0358(a,b,c,d)", /* 86 */
- "F = 0359(a,b,c,d)", /* 87 */
- "F = 035A(a,b,c,d)", /* 88 */
- "F = 035B(a,b,c,d)", /* 89 */
- "F = 035E(a,b,c,d)", /* 90 */
- "F = 035F(a,b,c,d)", /* 91 */
- "F = 0368(a,b,c,d)", /* 92 */
- "F = 0369(a,b,c,d)", /* 93 */
- "F = 036A(a,b,c,d)", /* 94 */
- "F = 036B(a,b,c,d)", /* 95 */
- "F = 036C(a,b,c,d)", /* 96 */
- "F = 036D(a,b,c,d)", /* 97 */
- "F = 036E(a,b,c,d)", /* 98 */
- "F = 036F(a,b,c,d)", /* 99 */
- "F = 037C(a,b,c,d)", /* 100 */
- "F = 037D(a,b,c,d)", /* 101 */
- "F = 037E(a,b,c,d)", /* 102 */
- "F = 18(b,c,d)", /* 103 */
- "F = 03C1(a,b,c,d)", /* 104 */
- "F = 19(b,c,d)", /* 105 */
- "F = 03C5(a,b,c,d)", /* 106 */
- "F = 03C6(a,b,c,d)", /* 107 */
- "F = 03C7(a,b,c,d)", /* 108 */
- "F = CA(!c,!d,b)", /* 109 */
- "F = 03D4(a,b,c,d)", /* 110 */
- "F = 03D5(a,b,c,d)", /* 111 */
- "F = 03D6(a,b,c,d)", /* 112 */
- "F = 03D7(a,b,c,d)", /* 113 */
- "F = 03D8(a,b,c,d)", /* 114 */
- "F = 03D9(a,b,c,d)", /* 115 */
- "F = 03DB(a,b,c,d)", /* 116 */
- "F = 03DC(a,b,c,d)", /* 117 */
- "F = 03DD(a,b,c,d)", /* 118 */
- "F = 03DE(a,b,c,d)", /* 119 */
- "F = (d+!(!c*!b))", /* 120 */
- "F = ((d+c)*(b+a))", /* 121 */
- "F = 0661(a,b,c,d)", /* 122 */
- "F = 0662(a,b,c,d)", /* 123 */
- "F = 0663(a,b,c,d)", /* 124 */
- "F = (!(d*c)*(b+a))", /* 125 */
- "F = 0667(a,b,c,d)", /* 126 */
- "F = 29((b+a),c,d)", /* 127 */
- "F = 066B(a,b,c,d)", /* 128 */
- "F = 2B((b+a),c,d)", /* 129 */
- "F = 0672(a,b,c,d)", /* 130 */
- "F = 0673(a,b,c,d)", /* 131 */
- "F = 0676(a,b,c,d)", /* 132 */
- "F = 0678(a,b,c,d)", /* 133 */
- "F = 0679(a,b,c,d)", /* 134 */
- "F = 067A(a,b,c,d)", /* 135 */
- "F = 067B(a,b,c,d)", /* 136 */
- "F = 067E(a,b,c,d)", /* 137 */
- "F = 24((b+a),c,d)", /* 138 */
- "F = 0691(a,b,c,d)", /* 139 */
- "F = 0693(a,b,c,d)", /* 140 */
- "F = 26((b+a),c,d)", /* 141 */
- "F = 0697(a,b,c,d)", /* 142 */
- "F = !CA(d,c,(b+a))", /* 143 */
- "F = 06B0(a,b,c,d)", /* 144 */
- "F = 06B1(a,b,c,d)", /* 145 */
- "F = 06B2(a,b,c,d)", /* 146 */
- "F = 06B3(a,b,c,d)", /* 147 */
- "F = 06B4(a,b,c,d)", /* 148 */
- "F = 06B5(a,b,c,d)", /* 149 */
- "F = 06B6(a,b,c,d)", /* 150 */
- "F = 06B7(a,b,c,d)", /* 151 */
- "F = 06B9(a,b,c,d)", /* 152 */
- "F = 06BD(a,b,c,d)", /* 153 */
- "F = 2C((b+a),c,d)", /* 154 */
- "F = 06F1(a,b,c,d)", /* 155 */
- "F = 06F2(a,b,c,d)", /* 156 */
- "F = CA((b+a),!d,c)", /* 157 */
- "F = (d+!(!c*!(b+!a)))", /* 158 */
- "F = 0776(a,b,c,d)", /* 159 */
- "F = 16((b*a),c,d)", /* 160 */
- "F = 0779(a,b,c,d)", /* 161 */
- "F = 077A(a,b,c,d)", /* 162 */
- "F = 077E(a,b,c,d)", /* 163 */
- "F = 07B0(a,b,c,d)", /* 164 */
- "F = 07B1(a,b,c,d)", /* 165 */
- "F = 07B4(a,b,c,d)", /* 166 */
- "F = 07B5(a,b,c,d)", /* 167 */
- "F = 07B6(a,b,c,d)", /* 168 */
- "F = 07BC(a,b,c,d)", /* 169 */
- "F = 07E0(a,b,c,d)", /* 170 */
- "F = 07E1(a,b,c,d)", /* 171 */
- "F = 07E2(a,b,c,d)", /* 172 */
- "F = 07E3(a,b,c,d)", /* 173 */
- "F = 07E6(a,b,c,d)", /* 174 */
- "F = 07E9(a,b,c,d)", /* 175 */
- "F = 1C((b*a),c,d)", /* 176 */
- "F = 07F1(a,b,c,d)", /* 177 */
- "F = 07F2(a,b,c,d)", /* 178 */
- "F = (d+!(!c*!(b*a)))", /* 179 */
- "F = (d+c)", /* 180 */
- "F = 1668(a,b,c,d)", /* 181 */
- "F = 1669(a,b,c,d)", /* 182 */
- "F = 166A(a,b,c,d)", /* 183 */
- "F = 166B(a,b,c,d)", /* 184 */
- "F = 166E(a,b,c,d)", /* 185 */
- "F = 167E(a,b,c,d)", /* 186 */
- "F = 1681(a,b,c,d)", /* 187 */
- "F = 1683(a,b,c,d)", /* 188 */
- "F = 1686(a,b,c,d)", /* 189 */
- "F = 1687(a,b,c,d)", /* 190 */
- "F = 1689(a,b,c,d)", /* 191 */
- "F = 168B(a,b,c,d)", /* 192 */
- "F = 168E(a,b,c,d)", /* 193 */
- "F = 1696(a,b,c,d)", /* 194 */
- "F = 1697(a,b,c,d)", /* 195 */
- "F = 1698(a,b,c,d)", /* 196 */
- "F = 1699(a,b,c,d)", /* 197 */
- "F = 169A(a,b,c,d)", /* 198 */
- "F = 169B(a,b,c,d)", /* 199 */
- "F = 169E(a,b,c,d)", /* 200 */
- "F = 16A9(a,b,c,d)", /* 201 */
- "F = 16AC(a,b,c,d)", /* 202 */
- "F = 16AD(a,b,c,d)", /* 203 */
- "F = 16BC(a,b,c,d)", /* 204 */
- "F = (d+E9(a,b,c))", /* 205 */
- "F = 177E(a,b,c,d)", /* 206 */
- "F = 178E(a,b,c,d)", /* 207 */
- "F = 1796(a,b,c,d)", /* 208 */
- "F = 1798(a,b,c,d)", /* 209 */
- "F = 179A(a,b,c,d)", /* 210 */
- "F = 17AC(a,b,c,d)", /* 211 */
- "F = (d+E8(a,b,c))", /* 212 */
- "F = (d+E7(a,b,c))", /* 213 */
- "F = 19E1(a,b,c,d)", /* 214 */
- "F = 19E3(a,b,c,d)", /* 215 */
- "F = (d+E6(a,b,c))", /* 216 */
- "F = 1BD8(a,b,c,d)", /* 217 */
- "F = (d+CA(b,c,a))", /* 218 */
- "F = (d+(c+(!b*!a)))", /* 219 */
- "F = (d+(c+!b))", /* 220 */
- "F = (d+(c+(b+a)))" /* 221 */
- };
- return (char **)pNames;
-}
-
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
-ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/kitFactor.c b/src/aig/kit/kitFactor.c
deleted file mode 100644
index ec4775ca..00000000
--- a/src/aig/kit/kitFactor.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kitFactor.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis [Algebraic factoring.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - Dec 6, 2006.]
-
- Revision [$Id: kitFactor.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "kit.h"
-
-ABC_NAMESPACE_IMPL_START
-
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-// factoring fails if intermediate memory usage exceed this limit
-#define KIT_FACTOR_MEM_LIMIT (1<<20)
-
-static Kit_Edge_t Kit_SopFactor_rec( Kit_Graph_t * pFForm, Kit_Sop_t * cSop, int nLits, Vec_Int_t * vMemory );
-static Kit_Edge_t Kit_SopFactorLF_rec( Kit_Graph_t * pFForm, Kit_Sop_t * cSop, Kit_Sop_t * cSimple, int nLits, Vec_Int_t * vMemory );
-static Kit_Edge_t Kit_SopFactorTrivial( Kit_Graph_t * pFForm, Kit_Sop_t * cSop, int nLits );
-static Kit_Edge_t Kit_SopFactorTrivialCube( Kit_Graph_t * pFForm, unsigned uCube, int nLits );
-
-extern int Kit_SopFactorVerify( Vec_Int_t * cSop, Kit_Graph_t * pFForm, int nVars );
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Factors the cover.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Graph_t * Kit_SopFactor( Vec_Int_t * vCover, int fCompl, int nVars, Vec_Int_t * vMemory )
-{
- Kit_Sop_t Sop, * cSop = &Sop;
- Kit_Graph_t * pFForm;
- Kit_Edge_t eRoot;
-// int nCubes;
-
- // works for up to 15 variables because division procedure
- // used the last bit for marking the cubes going to the remainder
- assert( nVars < 16 );
-
- // check for trivial functions
- if ( Vec_IntSize(vCover) == 0 )
- return Kit_GraphCreateConst0();
- if ( Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover, 0) == 0 )
- return Kit_GraphCreateConst1();
-
- // prepare memory manager
-// Vec_IntClear( vMemory );
- Vec_IntGrow( vMemory, KIT_FACTOR_MEM_LIMIT );
-
- // perform CST
- Kit_SopCreateInverse( cSop, vCover, 2 * nVars, vMemory ); // CST
-
- // start the factored form
- pFForm = Kit_GraphCreate( nVars );
- // factor the cover
- eRoot = Kit_SopFactor_rec( pFForm, cSop, 2 * nVars, vMemory );
- // finalize the factored form
- Kit_GraphSetRoot( pFForm, eRoot );
- if ( fCompl )
- Kit_GraphComplement( pFForm );
-
- // verify the factored form
-// nCubes = Vec_IntSize(vCover);
-// Vec_IntShrink( vCover, nCubes );
-// if ( !Kit_SopFactorVerify( vCover, pFForm, nVars ) )
-// printf( "Verification has failed.\n" );
- return pFForm;
-}
-
-/**Function*************************************************************
-
- Synopsis [Recursive factoring procedure.]
-
- Description [For the pseudo-code, see Hachtel/Somenzi,
- Logic synthesis and verification algorithms, Kluwer, 1996, p. 432.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Edge_t Kit_SopFactor_rec( Kit_Graph_t * pFForm, Kit_Sop_t * cSop, int nLits, Vec_Int_t * vMemory )
-{
- Kit_Sop_t Div, Quo, Rem, Com;
- Kit_Sop_t * cDiv = &Div, * cQuo = &Quo, * cRem = &Rem, * cCom = &Com;
- Kit_Edge_t eNodeDiv, eNodeQuo, eNodeRem, eNodeAnd;
-
- // make sure the cover contains some cubes
- assert( Kit_SopCubeNum(cSop) > 0 );
-
- // get the divisor
- if ( !Kit_SopDivisor(cDiv, cSop, nLits, vMemory) )
- return Kit_SopFactorTrivial( pFForm, cSop, nLits );
-
- // divide the cover by the divisor
- Kit_SopDivideInternal( cSop, cDiv, cQuo, cRem, vMemory );
-
- // check the trivial case
- assert( Kit_SopCubeNum(cQuo) > 0 );
- if ( Kit_SopCubeNum(cQuo) == 1 )
- return Kit_SopFactorLF_rec( pFForm, cSop, cQuo, nLits, vMemory );
-
- // make the quotient cube ABC_FREE
- Kit_SopMakeCubeFree( cQuo );
-
- // divide the cover by the quotient
- Kit_SopDivideInternal( cSop, cQuo, cDiv, cRem, vMemory );
-
- // check the trivial case
- if ( Kit_SopIsCubeFree( cDiv ) )
- {
- eNodeDiv = Kit_SopFactor_rec( pFForm, cDiv, nLits, vMemory );
- eNodeQuo = Kit_SopFactor_rec( pFForm, cQuo, nLits, vMemory );
- eNodeAnd = Kit_GraphAddNodeAnd( pFForm, eNodeDiv, eNodeQuo );
- if ( Kit_SopCubeNum(cRem) == 0 )
- return eNodeAnd;
- eNodeRem = Kit_SopFactor_rec( pFForm, cRem, nLits, vMemory );
- return Kit_GraphAddNodeOr( pFForm, eNodeAnd, eNodeRem );
- }
-
- // get the common cube
- Kit_SopCommonCubeCover( cCom, cDiv, vMemory );
-
- // solve the simple problem
- return Kit_SopFactorLF_rec( pFForm, cSop, cCom, nLits, vMemory );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Internal recursive factoring procedure for the leaf case.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Edge_t Kit_SopFactorLF_rec( Kit_Graph_t * pFForm, Kit_Sop_t * cSop, Kit_Sop_t * cSimple, int nLits, Vec_Int_t * vMemory )
-{
- Kit_Sop_t Div, Quo, Rem;
- Kit_Sop_t * cDiv = &Div, * cQuo = &Quo, * cRem = &Rem;
- Kit_Edge_t eNodeDiv, eNodeQuo, eNodeRem, eNodeAnd;
- assert( Kit_SopCubeNum(cSimple) == 1 );
- // get the most often occurring literal
- Kit_SopBestLiteralCover( cDiv, cSop, Kit_SopCube(cSimple, 0), nLits, vMemory );
- // divide the cover by the literal
- Kit_SopDivideByCube( cSop, cDiv, cQuo, cRem, vMemory );
- // get the node pointer for the literal
- eNodeDiv = Kit_SopFactorTrivialCube( pFForm, Kit_SopCube(cDiv, 0), nLits );
- // factor the quotient and remainder
- eNodeQuo = Kit_SopFactor_rec( pFForm, cQuo, nLits, vMemory );
- eNodeAnd = Kit_GraphAddNodeAnd( pFForm, eNodeDiv, eNodeQuo );
- if ( Kit_SopCubeNum(cRem) == 0 )
- return eNodeAnd;
- eNodeRem = Kit_SopFactor_rec( pFForm, cRem, nLits, vMemory );
- return Kit_GraphAddNodeOr( pFForm, eNodeAnd, eNodeRem );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Factoring cube.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Edge_t Kit_SopFactorTrivialCube_rec( Kit_Graph_t * pFForm, unsigned uCube, int nStart, int nFinish )
-{
- Kit_Edge_t eNode1, eNode2;
- int i, iLit = -1, nLits, nLits1, nLits2;
- assert( uCube );
- // count the number of literals in this interval
- nLits = 0;
- for ( i = nStart; i < nFinish; i++ )
- if ( Kit_CubeHasLit(uCube, i) )
- {
- iLit = i;
- nLits++;
- }
- assert( iLit != -1 );
- // quit if there is only one literal
- if ( nLits == 1 )
- return Kit_EdgeCreate( iLit/2, iLit%2 ); // CST
- // split the literals into two parts
- nLits1 = nLits/2;
- nLits2 = nLits - nLits1;
-// nLits2 = nLits/2;
-// nLits1 = nLits - nLits2;
- // find the splitting point
- nLits = 0;
- for ( i = nStart; i < nFinish; i++ )
- if ( Kit_CubeHasLit(uCube, i) )
- {
- if ( nLits == nLits1 )
- break;
- nLits++;
- }
- // recursively construct the tree for the parts
- eNode1 = Kit_SopFactorTrivialCube_rec( pFForm, uCube, nStart, i );
- eNode2 = Kit_SopFactorTrivialCube_rec( pFForm, uCube, i, nFinish );
- return Kit_GraphAddNodeAnd( pFForm, eNode1, eNode2 );
-}
-
-/**Function*************************************************************
-
- Synopsis [Factoring cube.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Edge_t Kit_SopFactorTrivialCube( Kit_Graph_t * pFForm, unsigned uCube, int nLits )
-{
- return Kit_SopFactorTrivialCube_rec( pFForm, uCube, 0, nLits );
-}
-
-/**Function*************************************************************
-
- Synopsis [Factoring SOP.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Edge_t Kit_SopFactorTrivial_rec( Kit_Graph_t * pFForm, unsigned * pCubes, int nCubes, int nLits )
-{
- Kit_Edge_t eNode1, eNode2;
- int nCubes1, nCubes2;
- if ( nCubes == 1 )
- return Kit_SopFactorTrivialCube_rec( pFForm, pCubes[0], 0, nLits );
- // split the cubes into two parts
- nCubes1 = nCubes/2;
- nCubes2 = nCubes - nCubes1;
-// nCubes2 = nCubes/2;
-// nCubes1 = nCubes - nCubes2;
- // recursively construct the tree for the parts
- eNode1 = Kit_SopFactorTrivial_rec( pFForm, pCubes, nCubes1, nLits );
- eNode2 = Kit_SopFactorTrivial_rec( pFForm, pCubes + nCubes1, nCubes2, nLits );
- return Kit_GraphAddNodeOr( pFForm, eNode1, eNode2 );
-}
-
-/**Function*************************************************************
-
- Synopsis [Factoring the cover, which has no algebraic divisors.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Edge_t Kit_SopFactorTrivial( Kit_Graph_t * pFForm, Kit_Sop_t * cSop, int nLits )
-{
- return Kit_SopFactorTrivial_rec( pFForm, cSop->pCubes, cSop->nCubes, nLits );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Testing procedure for the factoring code.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_FactorTest( unsigned * pTruth, int nVars )
-{
- Vec_Int_t * vCover, * vMemory;
- Kit_Graph_t * pGraph;
-// unsigned uTruthRes;
- int RetValue;
-
- // derive SOP
- vCover = Vec_IntAlloc( 0 );
- RetValue = Kit_TruthIsop( pTruth, nVars, vCover, 0 );
- assert( RetValue == 0 );
-
- // derive factored form
- vMemory = Vec_IntAlloc( 0 );
- pGraph = Kit_SopFactor( vCover, 0, nVars, vMemory );
-/*
- // derive truth table
- assert( nVars <= 5 );
- uTruthRes = Kit_GraphToTruth( pGraph );
- if ( uTruthRes != pTruth[0] )
- printf( "Verification failed!" );
-*/
- printf( "Vars = %2d. Cubes = %3d. FFNodes = %3d. FF_memory = %3d.\n",
- nVars, Vec_IntSize(vCover), Kit_GraphNodeNum(pGraph), Vec_IntSize(vMemory) );
-
- Vec_IntFree( vMemory );
- Vec_IntFree( vCover );
- Kit_GraphFree( pGraph );
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
-ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/kitGraph.c b/src/aig/kit/kitGraph.c
deleted file mode 100644
index e4eea885..00000000
--- a/src/aig/kit/kitGraph.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kitGraph.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis [Decomposition graph representation.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - Dec 6, 2006.]
-
- Revision [$Id: kitGraph.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "kit.h"
-
-ABC_NAMESPACE_IMPL_START
-
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Creates a graph with the given number of leaves.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Graph_t * Kit_GraphCreate( int nLeaves )
-{
- Kit_Graph_t * pGraph;
- pGraph = ABC_ALLOC( Kit_Graph_t, 1 );
- memset( pGraph, 0, sizeof(Kit_Graph_t) );
- pGraph->nLeaves = nLeaves;
- pGraph->nSize = nLeaves;
- pGraph->nCap = 2 * nLeaves + 50;
- pGraph->pNodes = ABC_ALLOC( Kit_Node_t, pGraph->nCap );
- memset( pGraph->pNodes, 0, sizeof(Kit_Node_t) * pGraph->nSize );
- return pGraph;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates constant 0 graph.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Graph_t * Kit_GraphCreateConst0()
-{
- Kit_Graph_t * pGraph;
- pGraph = ABC_ALLOC( Kit_Graph_t, 1 );
- memset( pGraph, 0, sizeof(Kit_Graph_t) );
- pGraph->fConst = 1;
- pGraph->eRoot.fCompl = 1;
- return pGraph;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates constant 1 graph.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Graph_t * Kit_GraphCreateConst1()
-{
- Kit_Graph_t * pGraph;
- pGraph = ABC_ALLOC( Kit_Graph_t, 1 );
- memset( pGraph, 0, sizeof(Kit_Graph_t) );
- pGraph->fConst = 1;
- return pGraph;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates the literal graph.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Graph_t * Kit_GraphCreateLeaf( int iLeaf, int nLeaves, int fCompl )
-{
- Kit_Graph_t * pGraph;
- assert( 0 <= iLeaf && iLeaf < nLeaves );
- pGraph = Kit_GraphCreate( nLeaves );
- pGraph->eRoot.Node = iLeaf;
- pGraph->eRoot.fCompl = fCompl;
- return pGraph;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates a graph with the given number of leaves.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_GraphFree( Kit_Graph_t * pGraph )
-{
- ABC_FREE( pGraph->pNodes );
- ABC_FREE( pGraph );
-}
-
-/**Function*************************************************************
-
- Synopsis [Appends a new node to the graph.]
-
- Description [This procedure is meant for internal use.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Node_t * Kit_GraphAppendNode( Kit_Graph_t * pGraph )
-{
- Kit_Node_t * pNode;
- if ( pGraph->nSize == pGraph->nCap )
- {
- pGraph->pNodes = ABC_REALLOC( Kit_Node_t, pGraph->pNodes, 2 * pGraph->nCap );
- pGraph->nCap = 2 * pGraph->nCap;
- }
- pNode = pGraph->pNodes + pGraph->nSize++;
- memset( pNode, 0, sizeof(Kit_Node_t) );
- return pNode;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates an AND node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Edge_t Kit_GraphAddNodeAnd( Kit_Graph_t * pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1 )
-{
- Kit_Node_t * pNode;
- // get the new node
- pNode = Kit_GraphAppendNode( pGraph );
- // set the inputs and other info
- pNode->eEdge0 = eEdge0;
- pNode->eEdge1 = eEdge1;
- pNode->fCompl0 = eEdge0.fCompl;
- pNode->fCompl1 = eEdge1.fCompl;
- return Kit_EdgeCreate( pGraph->nSize - 1, 0 );
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates an OR node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Edge_t Kit_GraphAddNodeOr( Kit_Graph_t * pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1 )
-{
- Kit_Node_t * pNode;
- // get the new node
- pNode = Kit_GraphAppendNode( pGraph );
- // set the inputs and other info
- pNode->eEdge0 = eEdge0;
- pNode->eEdge1 = eEdge1;
- pNode->fCompl0 = eEdge0.fCompl;
- pNode->fCompl1 = eEdge1.fCompl;
- // make adjustments for the OR gate
- pNode->fNodeOr = 1;
- pNode->eEdge0.fCompl = !pNode->eEdge0.fCompl;
- pNode->eEdge1.fCompl = !pNode->eEdge1.fCompl;
- return Kit_EdgeCreate( pGraph->nSize - 1, 1 );
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates an XOR node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Edge_t Kit_GraphAddNodeXor( Kit_Graph_t * pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1, int Type )
-{
- Kit_Edge_t eNode0, eNode1, eNode;
- if ( Type == 0 )
- {
- // derive the first AND
- eEdge0.fCompl ^= 1;
- eNode0 = Kit_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
- eEdge0.fCompl ^= 1;
- // derive the second AND
- eEdge1.fCompl ^= 1;
- eNode1 = Kit_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
- // derive the final OR
- eNode = Kit_GraphAddNodeOr( pGraph, eNode0, eNode1 );
- }
- else
- {
- // derive the first AND
- eNode0 = Kit_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
- // derive the second AND
- eEdge0.fCompl ^= 1;
- eEdge1.fCompl ^= 1;
- eNode1 = Kit_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
- // derive the final OR
- eNode = Kit_GraphAddNodeOr( pGraph, eNode0, eNode1 );
- eNode.fCompl ^= 1;
- }
- return eNode;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates an XOR node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Edge_t Kit_GraphAddNodeMux( Kit_Graph_t * pGraph, Kit_Edge_t eEdgeC, Kit_Edge_t eEdgeT, Kit_Edge_t eEdgeE, int Type )
-{
- Kit_Edge_t eNode0, eNode1, eNode;
- if ( Type == 0 )
- {
- // derive the first AND
- eNode0 = Kit_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeT );
- // derive the second AND
- eEdgeC.fCompl ^= 1;
- eNode1 = Kit_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeE );
- // derive the final OR
- eNode = Kit_GraphAddNodeOr( pGraph, eNode0, eNode1 );
- }
- else
- {
- // complement the arguments
- eEdgeT.fCompl ^= 1;
- eEdgeE.fCompl ^= 1;
- // derive the first AND
- eNode0 = Kit_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeT );
- // derive the second AND
- eEdgeC.fCompl ^= 1;
- eNode1 = Kit_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeE );
- // derive the final OR
- eNode = Kit_GraphAddNodeOr( pGraph, eNode0, eNode1 );
- eNode.fCompl ^= 1;
- }
- return eNode;
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned Kit_GraphToTruth( Kit_Graph_t * pGraph )
-{
- unsigned uTruths[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
- unsigned uTruth = 0, uTruth0, uTruth1;
- Kit_Node_t * pNode;
- int i;
-
- // sanity checks
- assert( Kit_GraphLeaveNum(pGraph) >= 0 );
- assert( Kit_GraphLeaveNum(pGraph) <= pGraph->nSize );
- assert( Kit_GraphLeaveNum(pGraph) <= 5 );
-
- // check for constant function
- if ( Kit_GraphIsConst(pGraph) )
- return Kit_GraphIsComplement(pGraph)? 0 : ~((unsigned)0);
- // check for a literal
- if ( Kit_GraphIsVar(pGraph) )
- return Kit_GraphIsComplement(pGraph)? ~uTruths[Kit_GraphVarInt(pGraph)] : uTruths[Kit_GraphVarInt(pGraph)];
-
- // assign the elementary variables
- Kit_GraphForEachLeaf( pGraph, pNode, i )
- pNode->pFunc = (void *)(long)uTruths[i];
-
- // compute the function for each internal node
- Kit_GraphForEachNode( pGraph, pNode, i )
- {
- uTruth0 = (unsigned)(long)Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc;
- uTruth1 = (unsigned)(long)Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc;
- uTruth0 = pNode->eEdge0.fCompl? ~uTruth0 : uTruth0;
- uTruth1 = pNode->eEdge1.fCompl? ~uTruth1 : uTruth1;
- uTruth = uTruth0 & uTruth1;
- pNode->pFunc = (void *)(long)uTruth;
- }
-
- // complement the result if necessary
- return Kit_GraphIsComplement(pGraph)? ~uTruth : uTruth;
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the factored form from the truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Kit_Graph_t * Kit_TruthToGraph( unsigned * pTruth, int nVars, Vec_Int_t * vMemory )
-{
- Kit_Graph_t * pGraph;
- int RetValue;
- // derive SOP
- RetValue = Kit_TruthIsop( pTruth, nVars, vMemory, 1 ); // tried 1 and found not useful in "renode"
- if ( RetValue == -1 )
- return NULL;
- if ( Vec_IntSize(vMemory) > (1<<16) )
- return NULL;
-// printf( "Isop size = %d.\n", Vec_IntSize(vMemory) );
- assert( RetValue == 0 || RetValue == 1 );
- // derive factored form
- pGraph = Kit_SopFactor( vMemory, RetValue, nVars, vMemory );
- return pGraph;
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the maximum depth from the leaf to the root.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_GraphLeafDepth_rec( Kit_Graph_t * pGraph, Kit_Node_t * pNode, Kit_Node_t * pLeaf )
-{
- int Depth0, Depth1, Depth;
- if ( pNode == pLeaf )
- return 0;
- if ( Kit_GraphNodeIsVar(pGraph, pNode) )
- return -100;
- Depth0 = Kit_GraphLeafDepth_rec( pGraph, Kit_GraphNodeFanin0(pGraph, pNode), pLeaf );
- Depth1 = Kit_GraphLeafDepth_rec( pGraph, Kit_GraphNodeFanin1(pGraph, pNode), pLeaf );
- Depth = KIT_MAX( Depth0, Depth1 );
- Depth = (Depth == -100) ? -100 : Depth + 1;
- return Depth;
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/kitHop.c b/src/aig/kit/kitHop.c
deleted file mode 100644
index 9dfa67a8..00000000
--- a/src/aig/kit/kitHop.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kitHop.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis [Procedures involving AIGs.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - Dec 6, 2006.]
-
- Revision [$Id: kitHop.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "kit.h"
-#include "hop.h"
-
-ABC_NAMESPACE_IMPL_START
-
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Transforms the decomposition graph into the AIG.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Hop_Obj_t * Kit_GraphToHopInternal( Hop_Man_t * pMan, Kit_Graph_t * pGraph )
-{
- Kit_Node_t * pNode = NULL;
- Hop_Obj_t * pAnd0, * pAnd1;
- int i;
- // check for constant function
- if ( Kit_GraphIsConst(pGraph) )
- return Hop_NotCond( Hop_ManConst1(pMan), Kit_GraphIsComplement(pGraph) );
- // check for a literal
- if ( Kit_GraphIsVar(pGraph) )
- return Hop_NotCond( (Hop_Obj_t *)Kit_GraphVar(pGraph)->pFunc, Kit_GraphIsComplement(pGraph) );
- // build the AIG nodes corresponding to the AND gates of the graph
- Kit_GraphForEachNode( pGraph, pNode, i )
- {
- pAnd0 = Hop_NotCond( (Hop_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
- pAnd1 = Hop_NotCond( (Hop_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
- pNode->pFunc = Hop_And( pMan, pAnd0, pAnd1 );
- }
- // complement the result if necessary
- return Hop_NotCond( (Hop_Obj_t *)pNode->pFunc, Kit_GraphIsComplement(pGraph) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Strashes one logic node using its SOP.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Hop_Obj_t * Kit_GraphToHop( Hop_Man_t * pMan, Kit_Graph_t * pGraph )
-{
- Kit_Node_t * pNode = NULL;
- int i;
- // collect the fanins
- Kit_GraphForEachLeaf( pGraph, pNode, i )
- pNode->pFunc = Hop_IthVar( pMan, i );
- // perform strashing
- return Kit_GraphToHopInternal( pMan, pGraph );
-}
-
-/**Function*************************************************************
-
- Synopsis [Strashed onen logic nodes using its truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Hop_Obj_t * Kit_TruthToHop( Hop_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory )
-{
- Hop_Obj_t * pObj;
- Kit_Graph_t * pGraph;
- // transform truth table into the decomposition tree
- if ( vMemory == NULL )
- {
- vMemory = Vec_IntAlloc( 0 );
- pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
- Vec_IntFree( vMemory );
- }
- else
- pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
- if ( pGraph == NULL )
- {
- printf( "Kit_TruthToHop(): Converting truth table to AIG has failed for function:\n" );
- Kit_DsdPrintFromTruth( pTruth, nVars ); printf( "\n" );
- }
- // derive the AIG for the decomposition tree
- pObj = Kit_GraphToHop( pMan, pGraph );
- Kit_GraphFree( pGraph );
- return pObj;
-}
-
-/**Function*************************************************************
-
- Synopsis [Strashes one logic node using its SOP.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Hop_Obj_t * Kit_CoverToHop( Hop_Man_t * pMan, Vec_Int_t * vCover, int nVars, Vec_Int_t * vMemory )
-{
- Kit_Graph_t * pGraph;
- Hop_Obj_t * pFunc;
- // perform factoring
- Vec_IntClear( vMemory );
- pGraph = Kit_SopFactor( vCover, 0, nVars, vMemory );
- // convert graph to the AIG
- pFunc = Kit_GraphToHop( pMan, pGraph );
- Kit_GraphFree( pGraph );
- return pFunc;
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
-ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/kitIsop.c b/src/aig/kit/kitIsop.c
deleted file mode 100644
index fc017c0e..00000000
--- a/src/aig/kit/kitIsop.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kitIsop.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis [ISOP computation based on Morreale's algorithm.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - Dec 6, 2006.]
-
- Revision [$Id: kitIsop.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "kit.h"
-
-ABC_NAMESPACE_IMPL_START
-
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-// ISOP computation fails if intermediate memory usage exceed this limit
-#define KIT_ISOP_MEM_LIMIT (1<<20)
-
-// static procedures to compute ISOP
-static unsigned * Kit_TruthIsop_rec( unsigned * puOn, unsigned * puOnDc, int nVars, Kit_Sop_t * pcRes, Vec_Int_t * vStore );
-static unsigned Kit_TruthIsop5_rec( unsigned uOn, unsigned uOnDc, int nVars, Kit_Sop_t * pcRes, Vec_Int_t * vStore );
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Computes ISOP from TT.]
-
- Description [Returns the cover in vMemory. Uses the rest of array in vMemory
- as an intermediate memory storage. Returns the cover with -1 cubes, if the
- the computation exceeded the memory limit (KIT_ISOP_MEM_LIMIT words of
- intermediate data).]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_TruthIsop( unsigned * puTruth, int nVars, Vec_Int_t * vMemory, int fTryBoth )
-{
- Kit_Sop_t cRes, * pcRes = &cRes;
- Kit_Sop_t cRes2, * pcRes2 = &cRes2;
- unsigned * pResult;
- int RetValue = 0;
- assert( nVars >= 0 && nVars < 16 );
- // if nVars < 5, make sure it does not depend on those vars
-// for ( i = nVars; i < 5; i++ )
-// assert( !Kit_TruthVarInSupport(puTruth, 5, i) );
- // prepare memory manager
- Vec_IntClear( vMemory );
- Vec_IntGrow( vMemory, KIT_ISOP_MEM_LIMIT );
- // compute ISOP for the direct polarity
- pResult = Kit_TruthIsop_rec( puTruth, puTruth, nVars, pcRes, vMemory );
- if ( pcRes->nCubes == -1 )
- {
- vMemory->nSize = -1;
- return -1;
- }
- assert( Kit_TruthIsEqual( puTruth, pResult, nVars ) );
- if ( pcRes->nCubes == 0 || (pcRes->nCubes == 1 && pcRes->pCubes[0] == 0) )
- {
- vMemory->pArray[0] = 0;
- Vec_IntShrink( vMemory, pcRes->nCubes );
- return 0;
- }
- if ( fTryBoth )
- {
- // compute ISOP for the complemented polarity
- Kit_TruthNot( puTruth, puTruth, nVars );
- pResult = Kit_TruthIsop_rec( puTruth, puTruth, nVars, pcRes2, vMemory );
- if ( pcRes2->nCubes >= 0 )
- {
- assert( Kit_TruthIsEqual( puTruth, pResult, nVars ) );
- if ( pcRes->nCubes > pcRes2->nCubes )
- {
- RetValue = 1;
- pcRes = pcRes2;
- }
- }
- Kit_TruthNot( puTruth, puTruth, nVars );
- }
-// printf( "%d ", vMemory->nSize );
- // move the cover representation to the beginning of the memory buffer
- memmove( vMemory->pArray, pcRes->pCubes, pcRes->nCubes * sizeof(unsigned) );
- Vec_IntShrink( vMemory, pcRes->nCubes );
- return RetValue;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes ISOP 6 variables or more.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned * Kit_TruthIsop_rec( unsigned * puOn, unsigned * puOnDc, int nVars, Kit_Sop_t * pcRes, Vec_Int_t * vStore )
-{
- Kit_Sop_t cRes0, cRes1, cRes2;
- Kit_Sop_t * pcRes0 = &cRes0, * pcRes1 = &cRes1, * pcRes2 = &cRes2;
- unsigned * puRes0, * puRes1, * puRes2;
- unsigned * puOn0, * puOn1, * puOnDc0, * puOnDc1, * pTemp, * pTemp0, * pTemp1;
- int i, k, Var, nWords, nWordsAll;
-// assert( Kit_TruthIsImply( puOn, puOnDc, nVars ) );
- // allocate room for the resulting truth table
- nWordsAll = Kit_TruthWordNum( nVars );
- pTemp = Vec_IntFetch( vStore, nWordsAll );
- if ( pTemp == NULL )
- {
- pcRes->nCubes = -1;
- return NULL;
- }
- // check for constants
- if ( Kit_TruthIsConst0( puOn, nVars ) )
- {
- pcRes->nCubes = 0;
- pcRes->pCubes = NULL;
- Kit_TruthClear( pTemp, nVars );
- return pTemp;
- }
- if ( Kit_TruthIsConst1( puOnDc, nVars ) )
- {
- pcRes->nCubes = 1;
- pcRes->pCubes = Vec_IntFetch( vStore, 1 );
- if ( pcRes->pCubes == NULL )
- {
- pcRes->nCubes = -1;
- return NULL;
- }
- pcRes->pCubes[0] = 0;
- Kit_TruthFill( pTemp, nVars );
- return pTemp;
- }
- assert( nVars > 0 );
- // find the topmost var
- for ( Var = nVars-1; Var >= 0; Var-- )
- if ( Kit_TruthVarInSupport( puOn, nVars, Var ) ||
- Kit_TruthVarInSupport( puOnDc, nVars, Var ) )
- break;
- assert( Var >= 0 );
- // consider a simple case when one-word computation can be used
- if ( Var < 5 )
- {
- unsigned uRes = Kit_TruthIsop5_rec( puOn[0], puOnDc[0], Var+1, pcRes, vStore );
- for ( i = 0; i < nWordsAll; i++ )
- pTemp[i] = uRes;
- return pTemp;
- }
- assert( Var >= 5 );
- nWords = Kit_TruthWordNum( Var );
- // cofactor
- puOn0 = puOn; puOn1 = puOn + nWords;
- puOnDc0 = puOnDc; puOnDc1 = puOnDc + nWords;
- pTemp0 = pTemp; pTemp1 = pTemp + nWords;
- // solve for cofactors
- Kit_TruthSharp( pTemp0, puOn0, puOnDc1, Var );
- puRes0 = Kit_TruthIsop_rec( pTemp0, puOnDc0, Var, pcRes0, vStore );
- if ( pcRes0->nCubes == -1 )
- {
- pcRes->nCubes = -1;
- return NULL;
- }
- Kit_TruthSharp( pTemp1, puOn1, puOnDc0, Var );
- puRes1 = Kit_TruthIsop_rec( pTemp1, puOnDc1, Var, pcRes1, vStore );
- if ( pcRes1->nCubes == -1 )
- {
- pcRes->nCubes = -1;
- return NULL;
- }
- Kit_TruthSharp( pTemp0, puOn0, puRes0, Var );
- Kit_TruthSharp( pTemp1, puOn1, puRes1, Var );
- Kit_TruthOr( pTemp0, pTemp0, pTemp1, Var );
- Kit_TruthAnd( pTemp1, puOnDc0, puOnDc1, Var );
- puRes2 = Kit_TruthIsop_rec( pTemp0, pTemp1, Var, pcRes2, vStore );
- if ( pcRes2->nCubes == -1 )
- {
- pcRes->nCubes = -1;
- return NULL;
- }
- // create the resulting cover
- pcRes->nCubes = pcRes0->nCubes + pcRes1->nCubes + pcRes2->nCubes;
- pcRes->pCubes = Vec_IntFetch( vStore, pcRes->nCubes );
- if ( pcRes->pCubes == NULL )
- {
- pcRes->nCubes = -1;
- return NULL;
- }
- k = 0;
- for ( i = 0; i < pcRes0->nCubes; i++ )
- pcRes->pCubes[k++] = pcRes0->pCubes[i] | (1 << ((Var<<1)+0));
- for ( i = 0; i < pcRes1->nCubes; i++ )
- pcRes->pCubes[k++] = pcRes1->pCubes[i] | (1 << ((Var<<1)+1));
- for ( i = 0; i < pcRes2->nCubes; i++ )
- pcRes->pCubes[k++] = pcRes2->pCubes[i];
- assert( k == pcRes->nCubes );
- // create the resulting truth table
- Kit_TruthOr( pTemp0, puRes0, puRes2, Var );
- Kit_TruthOr( pTemp1, puRes1, puRes2, Var );
- // copy the table if needed
- nWords <<= 1;
- for ( i = 1; i < nWordsAll/nWords; i++ )
- for ( k = 0; k < nWords; k++ )
- pTemp[i*nWords + k] = pTemp[k];
- // verify in the end
-// assert( Kit_TruthIsImply( puOn, pTemp, nVars ) );
-// assert( Kit_TruthIsImply( pTemp, puOnDc, nVars ) );
- return pTemp;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes ISOP for 5 variables or less.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned Kit_TruthIsop5_rec( unsigned uOn, unsigned uOnDc, int nVars, Kit_Sop_t * pcRes, Vec_Int_t * vStore )
-{
- unsigned uMasks[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
- Kit_Sop_t cRes0, cRes1, cRes2;
- Kit_Sop_t * pcRes0 = &cRes0, * pcRes1 = &cRes1, * pcRes2 = &cRes2;
- unsigned uOn0, uOn1, uOnDc0, uOnDc1, uRes0, uRes1, uRes2;
- int i, k, Var;
- assert( nVars <= 5 );
- assert( (uOn & ~uOnDc) == 0 );
- if ( uOn == 0 )
- {
- pcRes->nCubes = 0;
- pcRes->pCubes = NULL;
- return 0;
- }
- if ( uOnDc == 0xFFFFFFFF )
- {
- pcRes->nCubes = 1;
- pcRes->pCubes = Vec_IntFetch( vStore, 1 );
- if ( pcRes->pCubes == NULL )
- {
- pcRes->nCubes = -1;
- return 0;
- }
- pcRes->pCubes[0] = 0;
- return 0xFFFFFFFF;
- }
- assert( nVars > 0 );
- // find the topmost var
- for ( Var = nVars-1; Var >= 0; Var-- )
- if ( Kit_TruthVarInSupport( &uOn, 5, Var ) ||
- Kit_TruthVarInSupport( &uOnDc, 5, Var ) )
- break;
- assert( Var >= 0 );
- // cofactor
- uOn0 = uOn1 = uOn;
- uOnDc0 = uOnDc1 = uOnDc;
- Kit_TruthCofactor0( &uOn0, Var + 1, Var );
- Kit_TruthCofactor1( &uOn1, Var + 1, Var );
- Kit_TruthCofactor0( &uOnDc0, Var + 1, Var );
- Kit_TruthCofactor1( &uOnDc1, Var + 1, Var );
- // solve for cofactors
- uRes0 = Kit_TruthIsop5_rec( uOn0 & ~uOnDc1, uOnDc0, Var, pcRes0, vStore );
- if ( pcRes0->nCubes == -1 )
- {
- pcRes->nCubes = -1;
- return 0;
- }
- uRes1 = Kit_TruthIsop5_rec( uOn1 & ~uOnDc0, uOnDc1, Var, pcRes1, vStore );
- if ( pcRes1->nCubes == -1 )
- {
- pcRes->nCubes = -1;
- return 0;
- }
- uRes2 = Kit_TruthIsop5_rec( (uOn0 & ~uRes0) | (uOn1 & ~uRes1), uOnDc0 & uOnDc1, Var, pcRes2, vStore );
- if ( pcRes2->nCubes == -1 )
- {
- pcRes->nCubes = -1;
- return 0;
- }
- // create the resulting cover
- pcRes->nCubes = pcRes0->nCubes + pcRes1->nCubes + pcRes2->nCubes;
- pcRes->pCubes = Vec_IntFetch( vStore, pcRes->nCubes );
- if ( pcRes->pCubes == NULL )
- {
- pcRes->nCubes = -1;
- return 0;
- }
- k = 0;
- for ( i = 0; i < pcRes0->nCubes; i++ )
- pcRes->pCubes[k++] = pcRes0->pCubes[i] | (1 << ((Var<<1)+0));
- for ( i = 0; i < pcRes1->nCubes; i++ )
- pcRes->pCubes[k++] = pcRes1->pCubes[i] | (1 << ((Var<<1)+1));
- for ( i = 0; i < pcRes2->nCubes; i++ )
- pcRes->pCubes[k++] = pcRes2->pCubes[i];
- assert( k == pcRes->nCubes );
- // derive the final truth table
- uRes2 |= (uRes0 & ~uMasks[Var]) | (uRes1 & uMasks[Var]);
-// assert( (uOn & ~uRes2) == 0 );
-// assert( (uRes2 & ~uOnDc) == 0 );
- return uRes2;
-}
-
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
-ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/kitPerm.c b/src/aig/kit/kitPerm.c
deleted file mode 100644
index d3e9ff5a..00000000
--- a/src/aig/kit/kitPerm.c
+++ /dev/null
@@ -1,355 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kitPerm.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis [Procedures for permuting truth tables.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - Oct 26, 2011.]
-
- Revision [$Id: kitPerm.c,v 1.00 2011/11/26 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <time.h>
-
-#define inline __inline // compatible with MS VS 6.0
-
-//ABC_NAMESPACE_IMPL_START
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-typedef unsigned __int64 word;
-typedef unsigned short shot;
-typedef unsigned char byte;
-
-static shot S[256] =
-{
- 0x0000, 0x0001, 0x0004, 0x0005, 0x0010, 0x0011, 0x0014, 0x0015,
- 0x0040, 0x0041, 0x0044, 0x0045, 0x0050, 0x0051, 0x0054, 0x0055,
- 0x0100, 0x0101, 0x0104, 0x0105, 0x0110, 0x0111, 0x0114, 0x0115,
- 0x0140, 0x0141, 0x0144, 0x0145, 0x0150, 0x0151, 0x0154, 0x0155,
- 0x0400, 0x0401, 0x0404, 0x0405, 0x0410, 0x0411, 0x0414, 0x0415,
- 0x0440, 0x0441, 0x0444, 0x0445, 0x0450, 0x0451, 0x0454, 0x0455,
- 0x0500, 0x0501, 0x0504, 0x0505, 0x0510, 0x0511, 0x0514, 0x0515,
- 0x0540, 0x0541, 0x0544, 0x0545, 0x0550, 0x0551, 0x0554, 0x0555,
- 0x1000, 0x1001, 0x1004, 0x1005, 0x1010, 0x1011, 0x1014, 0x1015,
- 0x1040, 0x1041, 0x1044, 0x1045, 0x1050, 0x1051, 0x1054, 0x1055,
- 0x1100, 0x1101, 0x1104, 0x1105, 0x1110, 0x1111, 0x1114, 0x1115,
- 0x1140, 0x1141, 0x1144, 0x1145, 0x1150, 0x1151, 0x1154, 0x1155,
- 0x1400, 0x1401, 0x1404, 0x1405, 0x1410, 0x1411, 0x1414, 0x1415,
- 0x1440, 0x1441, 0x1444, 0x1445, 0x1450, 0x1451, 0x1454, 0x1455,
- 0x1500, 0x1501, 0x1504, 0x1505, 0x1510, 0x1511, 0x1514, 0x1515,
- 0x1540, 0x1541, 0x1544, 0x1545, 0x1550, 0x1551, 0x1554, 0x1555,
- 0x4000, 0x4001, 0x4004, 0x4005, 0x4010, 0x4011, 0x4014, 0x4015,
- 0x4040, 0x4041, 0x4044, 0x4045, 0x4050, 0x4051, 0x4054, 0x4055,
- 0x4100, 0x4101, 0x4104, 0x4105, 0x4110, 0x4111, 0x4114, 0x4115,
- 0x4140, 0x4141, 0x4144, 0x4145, 0x4150, 0x4151, 0x4154, 0x4155,
- 0x4400, 0x4401, 0x4404, 0x4405, 0x4410, 0x4411, 0x4414, 0x4415,
- 0x4440, 0x4441, 0x4444, 0x4445, 0x4450, 0x4451, 0x4454, 0x4455,
- 0x4500, 0x4501, 0x4504, 0x4505, 0x4510, 0x4511, 0x4514, 0x4515,
- 0x4540, 0x4541, 0x4544, 0x4545, 0x4550, 0x4551, 0x4554, 0x4555,
- 0x5000, 0x5001, 0x5004, 0x5005, 0x5010, 0x5011, 0x5014, 0x5015,
- 0x5040, 0x5041, 0x5044, 0x5045, 0x5050, 0x5051, 0x5054, 0x5055,
- 0x5100, 0x5101, 0x5104, 0x5105, 0x5110, 0x5111, 0x5114, 0x5115,
- 0x5140, 0x5141, 0x5144, 0x5145, 0x5150, 0x5151, 0x5154, 0x5155,
- 0x5400, 0x5401, 0x5404, 0x5405, 0x5410, 0x5411, 0x5414, 0x5415,
- 0x5440, 0x5441, 0x5444, 0x5445, 0x5450, 0x5451, 0x5454, 0x5455,
- 0x5500, 0x5501, 0x5504, 0x5505, 0x5510, 0x5511, 0x5514, 0x5515,
- 0x5540, 0x5541, 0x5544, 0x5545, 0x5550, 0x5551, 0x5554, 0x5555
-};
-
-static byte P[256] =
-{
- 0x00, 0x01, 0x10, 0x11, 0x04, 0x05, 0x14, 0x15, 0x40, 0x41, 0x50, 0x51, 0x44, 0x45, 0x54, 0x55,
- 0x02, 0x03, 0x12, 0x13, 0x06, 0x07, 0x16, 0x17, 0x42, 0x43, 0x52, 0x53, 0x46, 0x47, 0x56, 0x57,
- 0x20, 0x21, 0x30, 0x31, 0x24, 0x25, 0x34, 0x35, 0x60, 0x61, 0x70, 0x71, 0x64, 0x65, 0x74, 0x75,
- 0x22, 0x23, 0x32, 0x33, 0x26, 0x27, 0x36, 0x37, 0x62, 0x63, 0x72, 0x73, 0x66, 0x67, 0x76, 0x77,
- 0x08, 0x09, 0x18, 0x19, 0x0c, 0x0d, 0x1c, 0x1d, 0x48, 0x49, 0x58, 0x59, 0x4c, 0x4d, 0x5c, 0x5d,
- 0x0a, 0x0b, 0x1a, 0x1b, 0x0e, 0x0f, 0x1e, 0x1f, 0x4a, 0x4b, 0x5a, 0x5b, 0x4e, 0x4f, 0x5e, 0x5f,
- 0x28, 0x29, 0x38, 0x39, 0x2c, 0x2d, 0x3c, 0x3d, 0x68, 0x69, 0x78, 0x79, 0x6c, 0x6d, 0x7c, 0x7d,
- 0x2a, 0x2b, 0x3a, 0x3b, 0x2e, 0x2f, 0x3e, 0x3f, 0x6a, 0x6b, 0x7a, 0x7b, 0x6e, 0x6f, 0x7e, 0x7f,
- 0x80, 0x81, 0x90, 0x91, 0x84, 0x85, 0x94, 0x95, 0xc0, 0xc1, 0xd0, 0xd1, 0xc4, 0xc5, 0xd4, 0xd5,
- 0x82, 0x83, 0x92, 0x93, 0x86, 0x87, 0x96, 0x97, 0xc2, 0xc3, 0xd2, 0xd3, 0xc6, 0xc7, 0xd6, 0xd7,
- 0xa0, 0xa1, 0xb0, 0xb1, 0xa4, 0xa5, 0xb4, 0xb5, 0xe0, 0xe1, 0xf0, 0xf1, 0xe4, 0xe5, 0xf4, 0xf5,
- 0xa2, 0xa3, 0xb2, 0xb3, 0xa6, 0xa7, 0xb6, 0xb7, 0xe2, 0xe3, 0xf2, 0xf3, 0xe6, 0xe7, 0xf6, 0xf7,
- 0x88, 0x89, 0x98, 0x99, 0x8c, 0x8d, 0x9c, 0x9d, 0xc8, 0xc9, 0xd8, 0xd9, 0xcc, 0xcd, 0xdc, 0xdd,
- 0x8a, 0x8b, 0x9a, 0x9b, 0x8e, 0x8f, 0x9e, 0x9f, 0xca, 0xcb, 0xda, 0xdb, 0xce, 0xcf, 0xde, 0xdf,
- 0xa8, 0xa9, 0xb8, 0xb9, 0xac, 0xad, 0xbc, 0xbd, 0xe8, 0xe9, 0xf8, 0xf9, 0xec, 0xed, 0xfc, 0xfd,
- 0xaa, 0xab, 0xba, 0xbb, 0xae, 0xaf, 0xbe, 0xbf, 0xea, 0xeb, 0xfa, 0xfb, 0xee, 0xef, 0xfe, 0xff
-};
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_PermCreateS()
-{
- int i, n, r;
- for ( i = 0; i < 256; i++ )
- {
- if ( i % 8 == 0 )
- printf( "\n" );
- for ( r = n = 0; n < 8; n++ )
- r |= ((i & (1 << n)) << n);
- printf( "0x%04x, ", r );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_PermCreateP()
-{
- int i, s1, s2, r;
- for ( i = 0; i < 256; i++ )
- {
- if ( i % 16 == 0 )
- printf( "\n" );
- s1 = i & 0x0A;
- s2 = i & 0x50;
- r = i ^ s1 ^ s2 ^ (s1 << 3) ^ (s2 >> 3);
- assert( r < 256 );
- printf( "0x%02x, ", r );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Kit_PermCycleOne( shot * s, byte * b, int v )
-{
- int i, n = (1 << (v-3));
- assert( v > 2 && v < 16 );
- for ( i = 0; i < n; i++ )
- s[i] = S[b[i]] | (S[b[i+n]] << 1);
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Kit_PermCycleMany( shot * s, byte * b, int V, int v )
-{
- int i, n = (1 << (V - 1 - v)), m = (1 << (v-2));
- assert( v > 2 && v < V );
- for ( i = 0; i < n; i++, s += (m >> 1), b += m )
- Kit_PermCycleOne( s, b, v );
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_PermCompute( word * o, word * i, int V )
-{
- word * t;
- int v, n = (1 << (V-3));
- assert( V >= 6 && V <= 16 );
- for ( v = 0; v < n; v++ )
- ((byte *)i)[v] = P[((byte *)i)[v]];
- for ( v = 3; v < V; v++ )
- {
- Kit_PermCycleMany( (shot *)o, (byte *)i, V, v );
- t = i; i = o; o = t;
- }
- if ( V & 1 )
- {
- n = (1 << (V-6));
- for ( v = 0; v < n; v++ )
- o[v] = i[v];
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_PermComputeNaive( word * F, int nVars )
-{
- extern void If_CluReverseOrder( word * pF, int nVars, int * V2P, int * P2V, int iVarStart );
- int i, V2P[16], P2V[16];
- for ( i = 0; i < nVars; i++ )
- V2P[i] = P2V[i] = i;
- If_CluReverseOrder( F, nVars, V2P, P2V, 0 );
-}
-
-
-word M ( word f1, word f2, int n)
-{
- word temp = 0;
- word a = 1;
- int i;
- for( i = 0; i < n; i++)
- temp = temp + (((f1>>i)&a) << (2*i) ) + (((f2>>i)&a) << (2*i+1));
- return temp;
-}
-
-word Tf ( word f, int n)
-{
- if(n==1)
- return f;
- else
- {
-// int x = (int)pow(2,n-1);
- int x;
- x = (1 << (n-1));
- return ( M (Tf( (f << x) >> x, n-1), Tf( (f >> x), n-1), x) ); //def. of M just below the function
- }
-}
-
-
-#define ABC_PRT(a,t) (printf("%s = ", (a)), printf("%7.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC)))
-#define NFUNCS (1<<20)
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_PermComputeTest()
-{
- word * T = (word *)malloc( 8 * NFUNCS );
- word i, o, w = 0;
- int k, b, clk;
-
- srand( 0 );
-
- clk = clock();
- for ( k = 0; k < NFUNCS; k++ )
- for ( b = 0; b < 8; b++ )
- ((byte *)(T + k))[b] = (byte)(rand() & 0xFF);
- ABC_PRT( "Assign", clock() - clk );
-
-// T[0] = 0xacaccacaaccaacca;
-// Kit_DsdPrintFromTruth( T, 6 );
-
- // perform measurements
- clk = clock();
- for ( k = 0; k < NFUNCS; k++ )
- {
- i = T[k];
-// Kit_PermComputeNaive( &i, 6 );
- Tf( i, 6 );
- }
- ABC_PRT( "Perm1 ", clock() - clk );
-
- // perform measurements
- clk = clock();
- for ( k = 0; k < NFUNCS; k++ )
- {
- i = T[k];
- Kit_PermCompute( &o, &i, 6 );
-
-// w = T[k];
-// Kit_PermComputeNaive( &w, 6 );
-// assert( w == o );
- }
- ABC_PRT( "Perm2 ", clock() - clk );
-
- assert( w == 0 );
- free( T );
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-`
-***********************************************************************/
-void Kit_PermComputeTest_()
-{
- word t, s;
- t = 0xacaccacaaccaacca;
-// Kit_DsdPrintFromTruth( &t, 6 ); printf( "\n" );
- s = Tf( t, 6 );
-// Kit_PermComputeNaive( &t, 6 );
-// Kit_DsdPrintFromTruth( &s, 6 ); printf( "\n" );
-}
-
-/*
- {
- extern void Kit_PermComputeTest();
- Kit_PermComputeTest();
- }
-*/
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
-//ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/kitPla.c b/src/aig/kit/kitPla.c
deleted file mode 100644
index df6d4e11..00000000
--- a/src/aig/kit/kitPla.c
+++ /dev/null
@@ -1,535 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kitPla.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis [Manipulating SOP in the form of a C-string.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - Dec 6, 2006.]
-
- Revision [$Id: kitPla.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "kit.h"
-#include "aig.h"
-
-ABC_NAMESPACE_IMPL_START
-
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Checks if the cover is constant 0.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_PlaIsConst0( char * pSop )
-{
- return pSop[0] == ' ' && pSop[1] == '0';
-}
-
-/**Function*************************************************************
-
- Synopsis [Checks if the cover is constant 1.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_PlaIsConst1( char * pSop )
-{
- return pSop[0] == ' ' && pSop[1] == '1';
-}
-
-/**Function*************************************************************
-
- Synopsis [Checks if the cover is a buffer.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_PlaIsBuf( char * pSop )
-{
- if ( pSop[4] != 0 )
- return 0;
- if ( (pSop[0] == '1' && pSop[2] == '1') || (pSop[0] == '0' && pSop[2] == '0') )
- return 1;
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Checks if the cover is an inverter.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_PlaIsInv( char * pSop )
-{
- if ( pSop[4] != 0 )
- return 0;
- if ( (pSop[0] == '0' && pSop[2] == '1') || (pSop[0] == '1' && pSop[2] == '0') )
- return 1;
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Reads the number of variables in the cover.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_PlaGetVarNum( char * pSop )
-{
- char * pCur;
- for ( pCur = pSop; *pCur != '\n'; pCur++ )
- if ( *pCur == 0 )
- return -1;
- return pCur - pSop - 2;
-}
-
-/**Function*************************************************************
-
- Synopsis [Reads the number of cubes in the cover.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_PlaGetCubeNum( char * pSop )
-{
- char * pCur;
- int nCubes = 0;
- if ( pSop == NULL )
- return 0;
- for ( pCur = pSop; *pCur; pCur++ )
- nCubes += (*pCur == '\n');
- return nCubes;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_PlaIsComplement( char * pSop )
-{
- char * pCur;
- for ( pCur = pSop; *pCur; pCur++ )
- if ( *pCur == '\n' )
- return (int)(*(pCur - 1) == '0' || *(pCur - 1) == 'n');
- assert( 0 );
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_PlaComplement( char * pSop )
-{
- char * pCur;
- for ( pCur = pSop; *pCur; pCur++ )
- if ( *pCur == '\n' )
- {
- if ( *(pCur - 1) == '0' )
- *(pCur - 1) = '1';
- else if ( *(pCur - 1) == '1' )
- *(pCur - 1) = '0';
- else if ( *(pCur - 1) == 'x' )
- *(pCur - 1) = 'n';
- else if ( *(pCur - 1) == 'n' )
- *(pCur - 1) = 'x';
- else
- assert( 0 );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates the constant 1 cover with the given number of variables and cubes.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-char * Kit_PlaStart( void * p, int nCubes, int nVars )
-{
- Aig_MmFlex_t * pMan = (Aig_MmFlex_t *)p;
- char * pSopCover, * pCube;
- int i, Length;
-
- Length = nCubes * (nVars + 3);
- pSopCover = Aig_MmFlexEntryFetch( pMan, Length + 1 );
- memset( pSopCover, '-', Length );
- pSopCover[Length] = 0;
-
- for ( i = 0; i < nCubes; i++ )
- {
- pCube = pSopCover + i * (nVars + 3);
- pCube[nVars + 0] = ' ';
- pCube[nVars + 1] = '1';
- pCube[nVars + 2] = '\n';
- }
- return pSopCover;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates the cover from the ISOP computed from TT.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-char * Kit_PlaCreateFromIsop( void * p, int nVars, Vec_Int_t * vCover )
-{
- Aig_MmFlex_t * pMan = (Aig_MmFlex_t *)p;
- char * pSop, * pCube;
- int i, k, Entry, Literal;
- assert( Vec_IntSize(vCover) > 0 );
- if ( Vec_IntSize(vCover) == 0 )
- return NULL;
- // start the cover
- pSop = Kit_PlaStart( pMan, Vec_IntSize(vCover), nVars );
- // create cubes
- Vec_IntForEachEntry( vCover, Entry, i )
- {
- pCube = pSop + i * (nVars + 3);
- for ( k = 0; k < nVars; k++ )
- {
- Literal = 3 & (Entry >> (k << 1));
- if ( Literal == 1 )
- pCube[k] = '0';
- else if ( Literal == 2 )
- pCube[k] = '1';
- else if ( Literal != 0 )
- assert( 0 );
- }
- }
- return pSop;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates the cover from the ISOP computed from TT.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_PlaToIsop( char * pSop, Vec_Int_t * vCover )
-{
- char * pCube;
- int k, nVars, Entry;
- nVars = Kit_PlaGetVarNum( pSop );
- assert( nVars > 0 );
- // create cubes
- Vec_IntClear( vCover );
- for ( pCube = pSop; *pCube; pCube += nVars + 3 )
- {
- Entry = 0;
- for ( k = nVars - 1; k >= 0; k-- )
- if ( pCube[k] == '0' )
- Entry = (Entry << 2) | 1;
- else if ( pCube[k] == '1' )
- Entry = (Entry << 2) | 2;
- else if ( pCube[k] == '-' )
- Entry = (Entry << 2);
- else
- assert( 0 );
- Vec_IntPush( vCover, Entry );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Allocates memory and copies the SOP into it.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-char * Kit_PlaStoreSop( void * p, char * pSop )
-{
- Aig_MmFlex_t * pMan = (Aig_MmFlex_t *)p;
- char * pStore;
- pStore = Aig_MmFlexEntryFetch( pMan, strlen(pSop) + 1 );
- strcpy( pStore, pSop );
- return pStore;
-}
-
-/**Function*************************************************************
-
- Synopsis [Transforms truth table into the SOP.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-char * Kit_PlaFromTruth( void * p, unsigned * pTruth, int nVars, Vec_Int_t * vCover )
-{
- Aig_MmFlex_t * pMan = (Aig_MmFlex_t *)p;
- char * pSop;
- int RetValue;
- if ( Kit_TruthIsConst0(pTruth, nVars) )
- return Kit_PlaStoreSop( pMan, " 0\n" );
- if ( Kit_TruthIsConst1(pTruth, nVars) )
- return Kit_PlaStoreSop( pMan, " 1\n" );
- RetValue = Kit_TruthIsop( pTruth, nVars, vCover, 0 ); // 1 );
- assert( RetValue == 0 || RetValue == 1 );
- pSop = Kit_PlaCreateFromIsop( pMan, nVars, vCover );
- if ( RetValue )
- Kit_PlaComplement( pSop );
- return pSop;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Creates the cover from the ISOP computed from TT.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-char * Kit_PlaFromIsop( Vec_Str_t * vStr, int nVars, Vec_Int_t * vCover )
-{
- int i, k, Entry, Literal;
- assert( Vec_IntSize(vCover) > 0 );
- if ( Vec_IntSize(vCover) == 0 )
- return NULL;
- Vec_StrClear( vStr );
- Vec_IntForEachEntry( vCover, Entry, i )
- {
- for ( k = 0; k < nVars; k++ )
- {
- Literal = 3 & (Entry >> (k << 1));
- if ( Literal == 1 )
- Vec_StrPush( vStr, '0' );
- else if ( Literal == 2 )
- Vec_StrPush( vStr, '1' );
- else if ( Literal == 0 )
- Vec_StrPush( vStr, '-' );
- else
- assert( 0 );
- }
- Vec_StrPush( vStr, ' ' );
- Vec_StrPush( vStr, '1' );
- Vec_StrPush( vStr, '\n' );
- }
- Vec_StrPush( vStr, '\0' );
- return Vec_StrArray( vStr );
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates the SOP from TT.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-char * Kit_PlaFromTruthNew( unsigned * pTruth, int nVars, Vec_Int_t * vCover, Vec_Str_t * vStr )
-{
- char * pResult;
- // transform truth table into the SOP
- int RetValue = Kit_TruthIsop( pTruth, nVars, vCover, 1 );
- assert( RetValue == 0 || RetValue == 1 );
- // check the case of constant cover
- if ( Vec_IntSize(vCover) == 0 || (Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover,0) == 0) )
- {
- assert( RetValue == 0 );
- Vec_StrClear( vStr );
- Vec_StrAppend( vStr, (Vec_IntSize(vCover) == 0) ? " 0\n" : " 1\n" );
- Vec_StrPush( vStr, '\0' );
- return Vec_StrArray( vStr );
- }
- pResult = Kit_PlaFromIsop( vStr, nVars, vCover );
- if ( RetValue )
- Kit_PlaComplement( pResult );
- if ( nVars < 6 )
- assert( pTruth[0] == (unsigned)Kit_PlaToTruth6(pResult, nVars) );
- else if ( nVars == 6 )
- assert( *((ABC_UINT64_T*)pTruth) == Kit_PlaToTruth6(pResult, nVars) );
- return pResult;
-}
-
-/**Function*************************************************************
-
- Synopsis [Converts SOP into a truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-ABC_UINT64_T Kit_PlaToTruth6( char * pSop, int nVars )
-{
- static ABC_UINT64_T Truth[8] = {
- 0xAAAAAAAAAAAAAAAA,
- 0xCCCCCCCCCCCCCCCC,
- 0xF0F0F0F0F0F0F0F0,
- 0xFF00FF00FF00FF00,
- 0xFFFF0000FFFF0000,
- 0xFFFFFFFF00000000,
- 0x0000000000000000,
- 0xFFFFFFFFFFFFFFFF
- };
- ABC_UINT64_T valueAnd, valueOr = Truth[6];
- int v, lit = 0;
- assert( nVars < 7 );
- do {
- valueAnd = Truth[7];
- for ( v = 0; v < nVars; v++, lit++ )
- {
- if ( pSop[lit] == '1' )
- valueAnd &= Truth[v];
- else if ( pSop[lit] == '0' )
- valueAnd &= ~Truth[v];
- else if ( pSop[lit] != '-' )
- assert( 0 );
- }
- valueOr |= valueAnd;
- assert( pSop[lit] == ' ' );
- lit++;
- lit++;
- assert( pSop[lit] == '\n' );
- lit++;
- } while ( pSop[lit] );
- if ( Kit_PlaIsComplement(pSop) )
- valueOr = ~valueOr;
- return valueOr;
-}
-
-/**Fnction*************************************************************
-
- Synopsis [Converting SOP into a truth table.]
-
- Description [The SOP is represented as a C-string, as documented in
- file "bblif.h". The truth table is returned as a bit-string composed
- of 2^nVars bits. For functions of less than 6 variables, the full
- machine word is returned. (The truth table looks as if the function
- had 5 variables.) The use of this procedure should be limited to
- Boolean functions with no more than 16 inputs.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_PlaToTruth( char * pSop, int nVars, Vec_Ptr_t * vVars, unsigned * pTemp, unsigned * pTruth )
-{
- int v, c, nCubes, fCompl = 0;
- assert( pSop != NULL );
- assert( nVars >= 0 );
- if ( strlen(pSop) % (nVars + 3) != 0 )
- {
- printf( "Kit_PlaToTruth(): SOP is represented incorrectly.\n" );
- return;
- }
- // iterate through the cubes
- Kit_TruthClear( pTruth, nVars );
- nCubes = strlen(pSop) / (nVars + 3);
- for ( c = 0; c < nCubes; c++ )
- {
- fCompl = (pSop[nVars+1] == '0');
- Kit_TruthFill( pTemp, nVars );
- // iterate through the literals of the cube
- for ( v = 0; v < nVars; v++ )
- if ( pSop[v] == '1' )
- Kit_TruthAnd( pTemp, pTemp, (unsigned *)Vec_PtrEntry(vVars, v), nVars );
- else if ( pSop[v] == '0' )
- Kit_TruthSharp( pTemp, pTemp, (unsigned *)Vec_PtrEntry(vVars, v), nVars );
- // add cube to storage
- Kit_TruthOr( pTruth, pTruth, pTemp, nVars );
- // go to the next cube
- pSop += (nVars + 3);
- }
- if ( fCompl )
- Kit_TruthNot( pTruth, pTruth, nVars );
-}
-
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
-ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/kitSop.c b/src/aig/kit/kitSop.c
deleted file mode 100644
index 21ea69b8..00000000
--- a/src/aig/kit/kitSop.c
+++ /dev/null
@@ -1,579 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kitSop.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis [Procedures involving SOPs.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - Dec 6, 2006.]
-
- Revision [$Id: kitSop.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "kit.h"
-
-ABC_NAMESPACE_IMPL_START
-
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Creates SOP from the cube array.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_SopCreate( Kit_Sop_t * cResult, Vec_Int_t * vInput, int nVars, Vec_Int_t * vMemory )
-{
- unsigned uCube;
- int i;
- // start the cover
- cResult->nCubes = 0;
- cResult->pCubes = Vec_IntFetch( vMemory, Vec_IntSize(vInput) );
- // add the cubes
- Vec_IntForEachEntry( vInput, uCube, i )
- Kit_SopPushCube( cResult, uCube );
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates SOP from the cube array.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_SopCreateInverse( Kit_Sop_t * cResult, Vec_Int_t * vInput, int nLits, Vec_Int_t * vMemory )
-{
- unsigned uCube, uMask = 0;
- int i, nCubes = Vec_IntSize(vInput);
- // start the cover
- cResult->nCubes = 0;
- cResult->pCubes = Vec_IntFetch( vMemory, nCubes );
- // add the cubes
-// Vec_IntForEachEntry( vInput, uCube, i )
- for ( i = 0; i < nCubes; i++ )
- {
- uCube = Vec_IntEntry( vInput, i );
- uMask = ((uCube | (uCube >> 1)) & 0x55555555);
- uMask |= (uMask << 1);
- Kit_SopPushCube( cResult, uCube ^ uMask );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Duplicates SOP.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_SopDup( Kit_Sop_t * cResult, Kit_Sop_t * cSop, Vec_Int_t * vMemory )
-{
- unsigned uCube;
- int i;
- // start the cover
- cResult->nCubes = 0;
- cResult->pCubes = Vec_IntFetch( vMemory, Kit_SopCubeNum(cSop) );
- // add the cubes
- Kit_SopForEachCube( cSop, uCube, i )
- Kit_SopPushCube( cResult, uCube );
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the quotient of division by literal.]
-
- Description [Reduces the cover to be equal to the result of
- division of the given cover by the literal.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_SopDivideByLiteralQuo( Kit_Sop_t * cSop, int iLit )
-{
- unsigned uCube;
- int i, k = 0;
- Kit_SopForEachCube( cSop, uCube, i )
- {
- if ( Kit_CubeHasLit(uCube, iLit) )
- Kit_SopWriteCube( cSop, Kit_CubeRemLit(uCube, iLit), k++ );
- }
- Kit_SopShrink( cSop, k );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Divides cover by one cube.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_SopDivideByCube( Kit_Sop_t * cSop, Kit_Sop_t * cDiv, Kit_Sop_t * vQuo, Kit_Sop_t * vRem, Vec_Int_t * vMemory )
-{
- unsigned uCube, uDiv;
- int i;
- // get the only cube
- assert( Kit_SopCubeNum(cDiv) == 1 );
- uDiv = Kit_SopCube(cDiv, 0);
- // allocate covers
- vQuo->nCubes = 0;
- vQuo->pCubes = Vec_IntFetch( vMemory, Kit_SopCubeNum(cSop) );
- vRem->nCubes = 0;
- vRem->pCubes = Vec_IntFetch( vMemory, Kit_SopCubeNum(cSop) );
- // sort the cubes
- Kit_SopForEachCube( cSop, uCube, i )
- {
- if ( Kit_CubeContains( uCube, uDiv ) )
- Kit_SopPushCube( vQuo, Kit_CubeSharp(uCube, uDiv) );
- else
- Kit_SopPushCube( vRem, uCube );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Divides cover by one cube.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_SopDivideInternal( Kit_Sop_t * cSop, Kit_Sop_t * cDiv, Kit_Sop_t * vQuo, Kit_Sop_t * vRem, Vec_Int_t * vMemory )
-{
- unsigned uCube, uDiv;
- unsigned uCube2 = 0; // Suppress "might be used uninitialized"
- unsigned uDiv2, uQuo;
- int i, i2, k, k2, nCubesRem;
- assert( Kit_SopCubeNum(cSop) >= Kit_SopCubeNum(cDiv) );
- // consider special case
- if ( Kit_SopCubeNum(cDiv) == 1 )
- {
- Kit_SopDivideByCube( cSop, cDiv, vQuo, vRem, vMemory );
- return;
- }
- // allocate quotient
- vQuo->nCubes = 0;
- vQuo->pCubes = Vec_IntFetch( vMemory, Kit_SopCubeNum(cSop) / Kit_SopCubeNum(cDiv) );
- // for each cube of the cover
- // it either belongs to the quotient or to the remainder
- Kit_SopForEachCube( cSop, uCube, i )
- {
- // skip taken cubes
- if ( Kit_CubeIsMarked(uCube) )
- continue;
- // find a matching cube in the divisor
- uDiv = ~0;
- Kit_SopForEachCube( cDiv, uDiv, k )
- if ( Kit_CubeContains( uCube, uDiv ) )
- break;
- // the cube is not found
- if ( k == Kit_SopCubeNum(cDiv) )
- continue;
- // the quotient cube exists
- uQuo = Kit_CubeSharp( uCube, uDiv );
- // find corresponding cubes for other cubes of the divisor
- uDiv2 = ~0;
- Kit_SopForEachCube( cDiv, uDiv2, k2 )
- {
- if ( k2 == k )
- continue;
- // find a matching cube
- Kit_SopForEachCube( cSop, uCube2, i2 )
- {
- // skip taken cubes
- if ( Kit_CubeIsMarked(uCube2) )
- continue;
- // check if the cube can be used
- if ( Kit_CubeContains( uCube2, uDiv2 ) && uQuo == Kit_CubeSharp( uCube2, uDiv2 ) )
- break;
- }
- // the case when the cube is not found
- if ( i2 == Kit_SopCubeNum(cSop) )
- break;
- }
- // we did not find some cubes - continue looking at other cubes
- if ( k2 != Kit_SopCubeNum(cDiv) )
- continue;
- // we found all cubes - add the quotient cube
- Kit_SopPushCube( vQuo, uQuo );
-
- // mark the first cube
- Kit_SopWriteCube( cSop, Kit_CubeMark(uCube), i );
- // mark other cubes that have this quotient
- Kit_SopForEachCube( cDiv, uDiv2, k2 )
- {
- if ( k2 == k )
- continue;
- // find a matching cube
- Kit_SopForEachCube( cSop, uCube2, i2 )
- {
- // skip taken cubes
- if ( Kit_CubeIsMarked(uCube2) )
- continue;
- // check if the cube can be used
- if ( Kit_CubeContains( uCube2, uDiv2 ) && uQuo == Kit_CubeSharp( uCube2, uDiv2 ) )
- break;
- }
- assert( i2 < Kit_SopCubeNum(cSop) );
- // the cube is found, mark it
- // (later we will add all unmarked cubes to the remainder)
- Kit_SopWriteCube( cSop, Kit_CubeMark(uCube2), i2 );
- }
- }
- // determine the number of cubes in the remainder
- nCubesRem = Kit_SopCubeNum(cSop) - Kit_SopCubeNum(vQuo) * Kit_SopCubeNum(cDiv);
- // allocate remainder
- vRem->nCubes = 0;
- vRem->pCubes = Vec_IntFetch( vMemory, nCubesRem );
- // finally add the remaining unmarked cubes to the remainder
- // and clean the marked cubes in the cover
- Kit_SopForEachCube( cSop, uCube, i )
- {
- if ( !Kit_CubeIsMarked(uCube) )
- {
- Kit_SopPushCube( vRem, uCube );
- continue;
- }
- Kit_SopWriteCube( cSop, Kit_CubeUnmark(uCube), i );
- }
- assert( nCubesRem == Kit_SopCubeNum(vRem) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the common cube.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline unsigned Kit_SopCommonCube( Kit_Sop_t * cSop )
-{
- unsigned uMask, uCube;
- int i;
- uMask = ~(unsigned)0;
- Kit_SopForEachCube( cSop, uCube, i )
- uMask &= uCube;
- return uMask;
-}
-
-/**Function*************************************************************
-
- Synopsis [Makes the cover cube-ABC_FREE.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_SopMakeCubeFree( Kit_Sop_t * cSop )
-{
- unsigned uMask, uCube;
- int i;
- uMask = Kit_SopCommonCube( cSop );
- if ( uMask == 0 )
- return;
- // remove the common cube
- Kit_SopForEachCube( cSop, uCube, i )
- Kit_SopWriteCube( cSop, Kit_CubeSharp(uCube, uMask), i );
-}
-
-/**Function*************************************************************
-
- Synopsis [Checks if the cover is cube-ABC_FREE.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_SopIsCubeFree( Kit_Sop_t * cSop )
-{
- return Kit_SopCommonCube( cSop ) == 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates SOP composes of the common cube of the given SOP.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_SopCommonCubeCover( Kit_Sop_t * cResult, Kit_Sop_t * cSop, Vec_Int_t * vMemory )
-{
- assert( Kit_SopCubeNum(cSop) > 0 );
- cResult->nCubes = 0;
- cResult->pCubes = Vec_IntFetch( vMemory, 1 );
- Kit_SopPushCube( cResult, Kit_SopCommonCube(cSop) );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Find any literal that occurs more than once.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_SopAnyLiteral( Kit_Sop_t * cSop, int nLits )
-{
- unsigned uCube;
- int i, k, nLitsCur;
- // go through each literal
- for ( i = 0; i < nLits; i++ )
- {
- // go through all the cubes
- nLitsCur = 0;
- Kit_SopForEachCube( cSop, uCube, k )
- if ( Kit_CubeHasLit(uCube, i) )
- nLitsCur++;
- if ( nLitsCur > 1 )
- return i;
- }
- return -1;
-}
-
-/**Function*************************************************************
-
- Synopsis [Find the least often occurring literal.]
-
- Description [Find the least often occurring literal among those
- that occur more than once.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_SopWorstLiteral( Kit_Sop_t * cSop, int nLits )
-{
- unsigned uCube;
- int i, k, iMin, nLitsMin, nLitsCur;
- int fUseFirst = 1;
-
- // go through each literal
- iMin = -1;
- nLitsMin = 1000000;
- for ( i = 0; i < nLits; i++ )
- {
- // go through all the cubes
- nLitsCur = 0;
- Kit_SopForEachCube( cSop, uCube, k )
- if ( Kit_CubeHasLit(uCube, i) )
- nLitsCur++;
- // skip the literal that does not occur or occurs once
- if ( nLitsCur < 2 )
- continue;
- // check if this is the best literal
- if ( fUseFirst )
- {
- if ( nLitsMin > nLitsCur )
- {
- nLitsMin = nLitsCur;
- iMin = i;
- }
- }
- else
- {
- if ( nLitsMin >= nLitsCur )
- {
- nLitsMin = nLitsCur;
- iMin = i;
- }
- }
- }
- if ( nLitsMin < 1000000 )
- return iMin;
- return -1;
-}
-
-/**Function*************************************************************
-
- Synopsis [Find the least often occurring literal.]
-
- Description [Find the least often occurring literal among those
- that occur more than once.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_SopBestLiteral( Kit_Sop_t * cSop, int nLits, unsigned uMask )
-{
- unsigned uCube;
- int i, k, iMax, nLitsMax, nLitsCur;
- int fUseFirst = 1;
-
- // go through each literal
- iMax = -1;
- nLitsMax = -1;
- for ( i = 0; i < nLits; i++ )
- {
- if ( !Kit_CubeHasLit(uMask, i) )
- continue;
- // go through all the cubes
- nLitsCur = 0;
- Kit_SopForEachCube( cSop, uCube, k )
- if ( Kit_CubeHasLit(uCube, i) )
- nLitsCur++;
- // skip the literal that does not occur or occurs once
- if ( nLitsCur < 2 )
- continue;
- // check if this is the best literal
- if ( fUseFirst )
- {
- if ( nLitsMax < nLitsCur )
- {
- nLitsMax = nLitsCur;
- iMax = i;
- }
- }
- else
- {
- if ( nLitsMax <= nLitsCur )
- {
- nLitsMax = nLitsCur;
- iMax = i;
- }
- }
- }
- if ( nLitsMax >= 0 )
- return iMax;
- return -1;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes a level-zero kernel.]
-
- Description [Modifies the cover to contain one level-zero kernel.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_SopDivisorZeroKernel_rec( Kit_Sop_t * cSop, int nLits )
-{
- int iLit;
- // find any literal that occurs at least two times
- iLit = Kit_SopWorstLiteral( cSop, nLits );
- if ( iLit == -1 )
- return;
- // derive the cube-free quotient
- Kit_SopDivideByLiteralQuo( cSop, iLit ); // the same cover
- Kit_SopMakeCubeFree( cSop ); // the same cover
- // call recursively
- Kit_SopDivisorZeroKernel_rec( cSop, nLits ); // the same cover
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes the quick divisor of the cover.]
-
- Description [Returns 0, if there is no divisor other than trivial.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_SopDivisor( Kit_Sop_t * cResult, Kit_Sop_t * cSop, int nLits, Vec_Int_t * vMemory )
-{
- if ( Kit_SopCubeNum(cSop) <= 1 )
- return 0;
- if ( Kit_SopAnyLiteral( cSop, nLits ) == -1 )
- return 0;
- // duplicate the cover
- Kit_SopDup( cResult, cSop, vMemory );
- // perform the kerneling
- Kit_SopDivisorZeroKernel_rec( cResult, nLits );
- assert( Kit_SopCubeNum(cResult) > 0 );
- return 1;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Create the one-literal cover with the best literal from cSop.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_SopBestLiteralCover( Kit_Sop_t * cResult, Kit_Sop_t * cSop, unsigned uCube, int nLits, Vec_Int_t * vMemory )
-{
- int iLitBest;
- // get the best literal
- iLitBest = Kit_SopBestLiteral( cSop, nLits, uCube );
- // start the cover
- cResult->nCubes = 0;
- cResult->pCubes = Vec_IntFetch( vMemory, 1 );
- // set the cube
- Kit_SopPushCube( cResult, Kit_CubeSetLit(0, iLitBest) );
-}
-
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
-ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/kitTruth.c b/src/aig/kit/kitTruth.c
deleted file mode 100644
index bd8bbb1c..00000000
--- a/src/aig/kit/kitTruth.c
+++ /dev/null
@@ -1,2222 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kitTruth.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis [Procedures involving truth tables.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - Dec 6, 2006.]
-
- Revision [$Id: kitTruth.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "kit.h"
-
-ABC_NAMESPACE_IMPL_START
-
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Swaps two adjacent variables in the truth table.]
-
- Description [Swaps var number Start and var number Start+1 (0-based numbers).
- The input truth table is pIn. The output truth table is pOut.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthSwapAdjacentVars( unsigned * pOut, unsigned * pIn, int nVars, int iVar )
-{
- static unsigned PMasks[4][3] = {
- { 0x99999999, 0x22222222, 0x44444444 },
- { 0xC3C3C3C3, 0x0C0C0C0C, 0x30303030 },
- { 0xF00FF00F, 0x00F000F0, 0x0F000F00 },
- { 0xFF0000FF, 0x0000FF00, 0x00FF0000 }
- };
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step, Shift;
-
- assert( iVar < nVars - 1 );
- if ( iVar < 4 )
- {
- Shift = (1 << iVar);
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & PMasks[iVar][0]) | ((pIn[i] & PMasks[iVar][1]) << Shift) | ((pIn[i] & PMasks[iVar][2]) >> Shift);
- }
- else if ( iVar > 4 )
- {
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 4*Step )
- {
- for ( i = 0; i < Step; i++ )
- pOut[i] = pIn[i];
- for ( i = 0; i < Step; i++ )
- pOut[Step+i] = pIn[2*Step+i];
- for ( i = 0; i < Step; i++ )
- pOut[2*Step+i] = pIn[Step+i];
- for ( i = 0; i < Step; i++ )
- pOut[3*Step+i] = pIn[3*Step+i];
- pIn += 4*Step;
- pOut += 4*Step;
- }
- }
- else // if ( iVar == 4 )
- {
- for ( i = 0; i < nWords; i += 2 )
- {
- pOut[i] = (pIn[i] & 0x0000FFFF) | ((pIn[i+1] & 0x0000FFFF) << 16);
- pOut[i+1] = (pIn[i+1] & 0xFFFF0000) | ((pIn[i] & 0xFFFF0000) >> 16);
- }
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Swaps two adjacent variables in the truth table.]
-
- Description [Swaps var number Start and var number Start+1 (0-based numbers).
- The input truth table is pIn. The output truth table is pOut.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthSwapAdjacentVars2( unsigned * pIn, unsigned * pOut, int nVars, int Start )
-{
- int nWords = (nVars <= 5)? 1 : (1 << (nVars-5));
- int i, k, Step;
-
- assert( Start < nVars - 1 );
- switch ( Start )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & 0x99999999) | ((pIn[i] & 0x22222222) << 1) | ((pIn[i] & 0x44444444) >> 1);
- return;
- case 1:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & 0xC3C3C3C3) | ((pIn[i] & 0x0C0C0C0C) << 2) | ((pIn[i] & 0x30303030) >> 2);
- return;
- case 2:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & 0xF00FF00F) | ((pIn[i] & 0x00F000F0) << 4) | ((pIn[i] & 0x0F000F00) >> 4);
- return;
- case 3:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & 0xFF0000FF) | ((pIn[i] & 0x0000FF00) << 8) | ((pIn[i] & 0x00FF0000) >> 8);
- return;
- case 4:
- for ( i = 0; i < nWords; i += 2 )
- {
- pOut[i] = (pIn[i] & 0x0000FFFF) | ((pIn[i+1] & 0x0000FFFF) << 16);
- pOut[i+1] = (pIn[i+1] & 0xFFFF0000) | ((pIn[i] & 0xFFFF0000) >> 16);
- }
- return;
- default:
- Step = (1 << (Start - 5));
- for ( k = 0; k < nWords; k += 4*Step )
- {
- for ( i = 0; i < Step; i++ )
- pOut[i] = pIn[i];
- for ( i = 0; i < Step; i++ )
- pOut[Step+i] = pIn[2*Step+i];
- for ( i = 0; i < Step; i++ )
- pOut[2*Step+i] = pIn[Step+i];
- for ( i = 0; i < Step; i++ )
- pOut[3*Step+i] = pIn[3*Step+i];
- pIn += 4*Step;
- pOut += 4*Step;
- }
- return;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Expands the truth table according to the phase.]
-
- Description [The input and output truth tables are in pIn/pOut. The current number
- of variables is nVars. The total number of variables in nVarsAll. The last argument
- (Phase) contains shows where the variables should go.]
-
- SideEffects [The input truth table is modified.]
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthStretch( unsigned * pOut, unsigned * pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn )
-{
- unsigned * pTemp;
- int i, k, Var = nVars - 1, Counter = 0;
- for ( i = nVarsAll - 1; i >= 0; i-- )
- if ( Phase & (1 << i) )
- {
- for ( k = Var; k < i; k++ )
- {
- Kit_TruthSwapAdjacentVars( pOut, pIn, nVarsAll, k );
- pTemp = pIn; pIn = pOut; pOut = pTemp;
- Counter++;
- }
- Var--;
- }
- assert( Var == -1 );
- // swap if it was moved an even number of times
- if ( fReturnIn ^ !(Counter & 1) )
- Kit_TruthCopy( pOut, pIn, nVarsAll );
-}
-
-/**Function*************************************************************
-
- Synopsis [Shrinks the truth table according to the phase.]
-
- Description [The input and output truth tables are in pIn/pOut. The current number
- of variables is nVars. The total number of variables in nVarsAll. The last argument
- (Phase) shows what variables should remain.]
-
- SideEffects [The input truth table is modified.]
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthShrink( unsigned * pOut, unsigned * pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn )
-{
- unsigned * pTemp;
- int i, k, Var = 0, Counter = 0;
- for ( i = 0; i < nVarsAll; i++ )
- if ( Phase & (1 << i) )
- {
- for ( k = i-1; k >= Var; k-- )
- {
- Kit_TruthSwapAdjacentVars( pOut, pIn, nVarsAll, k );
- pTemp = pIn; pIn = pOut; pOut = pTemp;
- Counter++;
- }
- Var++;
- }
- assert( Var == nVars );
- // swap if it was moved an even number of times
- if ( fReturnIn ^ !(Counter & 1) )
- Kit_TruthCopy( pOut, pIn, nVarsAll );
-}
-
-/**Function*************************************************************
-
- Synopsis [Implement give permutation.]
-
- Description [The input and output truth tables are in pIn/pOut.
- The number of variables is nVars. Permutation is in pPerm.]
-
- SideEffects [The input truth table is modified.]
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthPermute( unsigned * pOut, unsigned * pIn, int nVars, char * pPerm, int fReturnIn )
-{
- unsigned * pTemp;
- int i, Temp, fChange, Counter = 0;
- do {
- fChange = 0;
- for ( i = 0; i < nVars-1; i++ )
- {
- assert( pPerm[i] != pPerm[i+1] );
- if ( pPerm[i] <= pPerm[i+1] )
- continue;
- Counter++;
- fChange = 1;
-
- Temp = pPerm[i];
- pPerm[i] = pPerm[i+1];
- pPerm[i+1] = Temp;
-
- Kit_TruthSwapAdjacentVars( pOut, pIn, nVars, i );
- pTemp = pIn; pIn = pOut; pOut = pTemp;
- }
- } while ( fChange );
- if ( fReturnIn ^ !(Counter & 1) )
- Kit_TruthCopy( pOut, pIn, nVars );
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns 1 if TT depends on the given variable.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_TruthVarInSupport( unsigned * pTruth, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- if ( (pTruth[i] & 0x55555555) != ((pTruth[i] & 0xAAAAAAAA) >> 1) )
- return 1;
- return 0;
- case 1:
- for ( i = 0; i < nWords; i++ )
- if ( (pTruth[i] & 0x33333333) != ((pTruth[i] & 0xCCCCCCCC) >> 2) )
- return 1;
- return 0;
- case 2:
- for ( i = 0; i < nWords; i++ )
- if ( (pTruth[i] & 0x0F0F0F0F) != ((pTruth[i] & 0xF0F0F0F0) >> 4) )
- return 1;
- return 0;
- case 3:
- for ( i = 0; i < nWords; i++ )
- if ( (pTruth[i] & 0x00FF00FF) != ((pTruth[i] & 0xFF00FF00) >> 8) )
- return 1;
- return 0;
- case 4:
- for ( i = 0; i < nWords; i++ )
- if ( (pTruth[i] & 0x0000FFFF) != ((pTruth[i] & 0xFFFF0000) >> 16) )
- return 1;
- return 0;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- if ( pTruth[i] != pTruth[Step+i] )
- return 1;
- pTruth += 2*Step;
- }
- return 0;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the number of support vars.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_TruthSupportSize( unsigned * pTruth, int nVars )
-{
- int i, Counter = 0;
- for ( i = 0; i < nVars; i++ )
- Counter += Kit_TruthVarInSupport( pTruth, nVars, i );
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns support of the function.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned Kit_TruthSupport( unsigned * pTruth, int nVars )
-{
- int i, Support = 0;
- for ( i = 0; i < nVars; i++ )
- if ( Kit_TruthVarInSupport( pTruth, nVars, i ) )
- Support |= (1 << i);
- return Support;
-}
-
-
-
-/**Function*************************************************************
-
- Synopsis [Computes negative cofactor of the function.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthCofactor0( unsigned * pTruth, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = (pTruth[i] & 0x55555555) | ((pTruth[i] & 0x55555555) << 1);
- return;
- case 1:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = (pTruth[i] & 0x33333333) | ((pTruth[i] & 0x33333333) << 2);
- return;
- case 2:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = (pTruth[i] & 0x0F0F0F0F) | ((pTruth[i] & 0x0F0F0F0F) << 4);
- return;
- case 3:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = (pTruth[i] & 0x00FF00FF) | ((pTruth[i] & 0x00FF00FF) << 8);
- return;
- case 4:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = (pTruth[i] & 0x0000FFFF) | ((pTruth[i] & 0x0000FFFF) << 16);
- return;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- pTruth[Step+i] = pTruth[i];
- pTruth += 2*Step;
- }
- return;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes negative cofactor of the function.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_TruthCofactor0Count( unsigned * pTruth, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step, Counter = 0;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- Counter += Kit_WordCountOnes(pTruth[i] & 0x55555555);
- return Counter;
- case 1:
- for ( i = 0; i < nWords; i++ )
- Counter += Kit_WordCountOnes(pTruth[i] & 0x33333333);
- return Counter;
- case 2:
- for ( i = 0; i < nWords; i++ )
- Counter += Kit_WordCountOnes(pTruth[i] & 0x0F0F0F0F);
- return Counter;
- case 3:
- for ( i = 0; i < nWords; i++ )
- Counter += Kit_WordCountOnes(pTruth[i] & 0x00FF00FF);
- return Counter;
- case 4:
- for ( i = 0; i < nWords; i++ )
- Counter += Kit_WordCountOnes(pTruth[i] & 0x0000FFFF);
- return Counter;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- Counter += Kit_WordCountOnes(pTruth[i]);
- pTruth += 2*Step;
- }
- return Counter;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes positive cofactor of the function.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthCofactor1( unsigned * pTruth, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = (pTruth[i] & 0xAAAAAAAA) | ((pTruth[i] & 0xAAAAAAAA) >> 1);
- return;
- case 1:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = (pTruth[i] & 0xCCCCCCCC) | ((pTruth[i] & 0xCCCCCCCC) >> 2);
- return;
- case 2:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = (pTruth[i] & 0xF0F0F0F0) | ((pTruth[i] & 0xF0F0F0F0) >> 4);
- return;
- case 3:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = (pTruth[i] & 0xFF00FF00) | ((pTruth[i] & 0xFF00FF00) >> 8);
- return;
- case 4:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = (pTruth[i] & 0xFFFF0000) | ((pTruth[i] & 0xFFFF0000) >> 16);
- return;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- pTruth[i] = pTruth[Step+i];
- pTruth += 2*Step;
- }
- return;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes positive cofactor of the function.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthCofactor0New( unsigned * pOut, unsigned * pIn, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & 0x55555555) | ((pIn[i] & 0x55555555) << 1);
- return;
- case 1:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & 0x33333333) | ((pIn[i] & 0x33333333) << 2);
- return;
- case 2:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & 0x0F0F0F0F) | ((pIn[i] & 0x0F0F0F0F) << 4);
- return;
- case 3:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & 0x00FF00FF) | ((pIn[i] & 0x00FF00FF) << 8);
- return;
- case 4:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & 0x0000FFFF) | ((pIn[i] & 0x0000FFFF) << 16);
- return;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- pOut[i] = pOut[Step+i] = pIn[i];
- pIn += 2*Step;
- pOut += 2*Step;
- }
- return;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes positive cofactor of the function.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthCofactor1New( unsigned * pOut, unsigned * pIn, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & 0xAAAAAAAA) | ((pIn[i] & 0xAAAAAAAA) >> 1);
- return;
- case 1:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & 0xCCCCCCCC) | ((pIn[i] & 0xCCCCCCCC) >> 2);
- return;
- case 2:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & 0xF0F0F0F0) | ((pIn[i] & 0xF0F0F0F0) >> 4);
- return;
- case 3:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & 0xFF00FF00) | ((pIn[i] & 0xFF00FF00) >> 8);
- return;
- case 4:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pIn[i] & 0xFFFF0000) | ((pIn[i] & 0xFFFF0000) >> 16);
- return;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- pOut[i] = pOut[Step+i] = pIn[Step+i];
- pIn += 2*Step;
- pOut += 2*Step;
- }
- return;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes negative cofactor of the function.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_TruthVarIsVacuous( unsigned * pOnset, unsigned * pOffset, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- if ( ((pOnset[i] & (pOffset[i] >> 1)) | (pOffset[i] & (pOnset[i] >> 1))) & 0x55555555 )
- return 0;
- return 1;
- case 1:
- for ( i = 0; i < nWords; i++ )
- if ( ((pOnset[i] & (pOffset[i] >> 2)) | (pOffset[i] & (pOnset[i] >> 2))) & 0x33333333 )
- return 0;
- return 1;
- case 2:
- for ( i = 0; i < nWords; i++ )
- if ( ((pOnset[i] & (pOffset[i] >> 4)) | (pOffset[i] & (pOnset[i] >> 4))) & 0x0F0F0F0F )
- return 0;
- return 1;
- case 3:
- for ( i = 0; i < nWords; i++ )
- if ( ((pOnset[i] & (pOffset[i] >> 8)) | (pOffset[i] & (pOnset[i] >> 8))) & 0x00FF00FF )
- return 0;
- return 1;
- case 4:
- for ( i = 0; i < nWords; i++ )
- if ( ((pOnset[i] & (pOffset[i] >> 16)) | (pOffset[i] & (pOnset[i] >> 16))) & 0x0000FFFF )
- return 0;
- return 1;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- if ( (pOnset[i] & pOffset[Step+i]) | (pOffset[i] & pOnset[Step+i]) )
- return 0;
- pOnset += 2*Step;
- pOffset += 2*Step;
- }
- return 1;
- }
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Existentially quantifies the variable.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthExist( unsigned * pTruth, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] |= ((pTruth[i] & 0xAAAAAAAA) >> 1) | ((pTruth[i] & 0x55555555) << 1);
- return;
- case 1:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] |= ((pTruth[i] & 0xCCCCCCCC) >> 2) | ((pTruth[i] & 0x33333333) << 2);
- return;
- case 2:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] |= ((pTruth[i] & 0xF0F0F0F0) >> 4) | ((pTruth[i] & 0x0F0F0F0F) << 4);
- return;
- case 3:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] |= ((pTruth[i] & 0xFF00FF00) >> 8) | ((pTruth[i] & 0x00FF00FF) << 8);
- return;
- case 4:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] |= ((pTruth[i] & 0xFFFF0000) >> 16) | ((pTruth[i] & 0x0000FFFF) << 16);
- return;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- {
- pTruth[i] |= pTruth[Step+i];
- pTruth[Step+i] = pTruth[i];
- }
- pTruth += 2*Step;
- }
- return;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Existentially quantifies the variable.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthExistNew( unsigned * pRes, unsigned * pTruth, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] | ((pTruth[i] & 0xAAAAAAAA) >> 1) | ((pTruth[i] & 0x55555555) << 1);
- return;
- case 1:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] | ((pTruth[i] & 0xCCCCCCCC) >> 2) | ((pTruth[i] & 0x33333333) << 2);
- return;
- case 2:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] | ((pTruth[i] & 0xF0F0F0F0) >> 4) | ((pTruth[i] & 0x0F0F0F0F) << 4);
- return;
- case 3:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] | ((pTruth[i] & 0xFF00FF00) >> 8) | ((pTruth[i] & 0x00FF00FF) << 8);
- return;
- case 4:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] | ((pTruth[i] & 0xFFFF0000) >> 16) | ((pTruth[i] & 0x0000FFFF) << 16);
- return;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- {
- pRes[i] = pTruth[i] | pTruth[Step+i];
- pRes[Step+i] = pRes[i];
- }
- pRes += 2*Step;
- pTruth += 2*Step;
- }
- return;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Existantially quantifies the set of variables.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthExistSet( unsigned * pRes, unsigned * pTruth, int nVars, unsigned uMask )
-{
- int v;
- Kit_TruthCopy( pRes, pTruth, nVars );
- for ( v = 0; v < nVars; v++ )
- if ( uMask & (1 << v) )
- Kit_TruthExist( pRes, nVars, v );
-}
-
-/**Function*************************************************************
-
- Synopsis [Unversally quantifies the variable.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthForall( unsigned * pTruth, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] &= ((pTruth[i] & 0xAAAAAAAA) >> 1) | ((pTruth[i] & 0x55555555) << 1);
- return;
- case 1:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] &= ((pTruth[i] & 0xCCCCCCCC) >> 2) | ((pTruth[i] & 0x33333333) << 2);
- return;
- case 2:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] &= ((pTruth[i] & 0xF0F0F0F0) >> 4) | ((pTruth[i] & 0x0F0F0F0F) << 4);
- return;
- case 3:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] &= ((pTruth[i] & 0xFF00FF00) >> 8) | ((pTruth[i] & 0x00FF00FF) << 8);
- return;
- case 4:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] &= ((pTruth[i] & 0xFFFF0000) >> 16) | ((pTruth[i] & 0x0000FFFF) << 16);
- return;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- {
- pTruth[i] &= pTruth[Step+i];
- pTruth[Step+i] = pTruth[i];
- }
- pTruth += 2*Step;
- }
- return;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Universally quantifies the variable.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthForallNew( unsigned * pRes, unsigned * pTruth, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] & (((pTruth[i] & 0xAAAAAAAA) >> 1) | ((pTruth[i] & 0x55555555) << 1));
- return;
- case 1:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] & (((pTruth[i] & 0xCCCCCCCC) >> 2) | ((pTruth[i] & 0x33333333) << 2));
- return;
- case 2:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] & (((pTruth[i] & 0xF0F0F0F0) >> 4) | ((pTruth[i] & 0x0F0F0F0F) << 4));
- return;
- case 3:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] & (((pTruth[i] & 0xFF00FF00) >> 8) | ((pTruth[i] & 0x00FF00FF) << 8));
- return;
- case 4:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] & (((pTruth[i] & 0xFFFF0000) >> 16) | ((pTruth[i] & 0x0000FFFF) << 16));
- return;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- {
- pRes[i] = pTruth[i] & pTruth[Step+i];
- pRes[Step+i] = pRes[i];
- }
- pRes += 2*Step;
- pTruth += 2*Step;
- }
- return;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Universally quantifies the variable.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthUniqueNew( unsigned * pRes, unsigned * pTruth, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] ^ (((pTruth[i] & 0xAAAAAAAA) >> 1) | ((pTruth[i] & 0x55555555) << 1));
- return;
- case 1:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] ^ (((pTruth[i] & 0xCCCCCCCC) >> 2) | ((pTruth[i] & 0x33333333) << 2));
- return;
- case 2:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] ^ (((pTruth[i] & 0xF0F0F0F0) >> 4) | ((pTruth[i] & 0x0F0F0F0F) << 4));
- return;
- case 3:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] ^ (((pTruth[i] & 0xFF00FF00) >> 8) | ((pTruth[i] & 0x00FF00FF) << 8));
- return;
- case 4:
- for ( i = 0; i < nWords; i++ )
- pRes[i] = pTruth[i] ^ (((pTruth[i] & 0xFFFF0000) >> 16) | ((pTruth[i] & 0x0000FFFF) << 16));
- return;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- {
- pRes[i] = pTruth[i] ^ pTruth[Step+i];
- pRes[Step+i] = pRes[i];
- }
- pRes += 2*Step;
- pTruth += 2*Step;
- }
- return;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the number of minterms in the Boolean difference.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_TruthBooleanDiffCount( unsigned * pTruth, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step, Counter = 0;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- Counter += Kit_WordCountOnes( (pTruth[i] ^ (pTruth[i] >> 1)) & 0x55555555 );
- return Counter;
- case 1:
- for ( i = 0; i < nWords; i++ )
- Counter += Kit_WordCountOnes( (pTruth[i] ^ (pTruth[i] >> 2)) & 0x33333333 );
- return Counter;
- case 2:
- for ( i = 0; i < nWords; i++ )
- Counter += Kit_WordCountOnes( (pTruth[i] ^ (pTruth[i] >> 4)) & 0x0F0F0F0F );
- return Counter;
- case 3:
- for ( i = 0; i < nWords; i++ )
- Counter += Kit_WordCountOnes( (pTruth[i] ^ (pTruth[i] >> 8)) & 0x00FF00FF );
- return Counter;
- case 4:
- for ( i = 0; i < nWords; i++ )
- Counter += Kit_WordCountOnes( (pTruth[i] ^ (pTruth[i] >>16)) & 0x0000FFFF );
- return Counter;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- Counter += Kit_WordCountOnes( pTruth[i] ^ pTruth[Step+i] );
- pTruth += 2*Step;
- }
- return Counter;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the number of minterms in the Boolean difference.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_TruthXorCount( unsigned * pTruth0, unsigned * pTruth1, int nVars )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, Counter = 0;
- for ( i = 0; i < nWords; i++ )
- Counter += Kit_WordCountOnes( pTruth0[i] ^ pTruth1[i] );
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis [Universally quantifies the set of variables.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthForallSet( unsigned * pRes, unsigned * pTruth, int nVars, unsigned uMask )
-{
- int v;
- Kit_TruthCopy( pRes, pTruth, nVars );
- for ( v = 0; v < nVars; v++ )
- if ( uMask & (1 << v) )
- Kit_TruthForall( pRes, nVars, v );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Multiplexes two functions with the given variable.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthMuxVar( unsigned * pOut, unsigned * pCof0, unsigned * pCof1, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pCof0[i] & 0x55555555) | (pCof1[i] & 0xAAAAAAAA);
- return;
- case 1:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pCof0[i] & 0x33333333) | (pCof1[i] & 0xCCCCCCCC);
- return;
- case 2:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pCof0[i] & 0x0F0F0F0F) | (pCof1[i] & 0xF0F0F0F0);
- return;
- case 3:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pCof0[i] & 0x00FF00FF) | (pCof1[i] & 0xFF00FF00);
- return;
- case 4:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (pCof0[i] & 0x0000FFFF) | (pCof1[i] & 0xFFFF0000);
- return;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- {
- pOut[i] = pCof0[i];
- pOut[Step+i] = pCof1[Step+i];
- }
- pOut += 2*Step;
- pCof0 += 2*Step;
- pCof1 += 2*Step;
- }
- return;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Multiplexes two functions with the given variable.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthMuxVarPhase( unsigned * pOut, unsigned * pCof0, unsigned * pCof1, int nVars, int iVar, int fCompl0 )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step;
-
- if ( fCompl0 == 0 )
- {
- Kit_TruthMuxVar( pOut, pCof0, pCof1, nVars, iVar );
- return;
- }
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (~pCof0[i] & 0x55555555) | (pCof1[i] & 0xAAAAAAAA);
- return;
- case 1:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (~pCof0[i] & 0x33333333) | (pCof1[i] & 0xCCCCCCCC);
- return;
- case 2:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (~pCof0[i] & 0x0F0F0F0F) | (pCof1[i] & 0xF0F0F0F0);
- return;
- case 3:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (~pCof0[i] & 0x00FF00FF) | (pCof1[i] & 0xFF00FF00);
- return;
- case 4:
- for ( i = 0; i < nWords; i++ )
- pOut[i] = (~pCof0[i] & 0x0000FFFF) | (pCof1[i] & 0xFFFF0000);
- return;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- {
- pOut[i] = ~pCof0[i];
- pOut[Step+i] = pCof1[Step+i];
- }
- pOut += 2*Step;
- pCof0 += 2*Step;
- pCof1 += 2*Step;
- }
- return;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Checks symmetry of two variables.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_TruthVarsSymm( unsigned * pTruth, int nVars, int iVar0, int iVar1, unsigned * pCof0, unsigned * pCof1 )
-{
- static unsigned uTemp0[32], uTemp1[32];
- if ( pCof0 == NULL )
- {
- assert( nVars <= 10 );
- pCof0 = uTemp0;
- }
- if ( pCof1 == NULL )
- {
- assert( nVars <= 10 );
- pCof1 = uTemp1;
- }
- // compute Cof01
- Kit_TruthCopy( pCof0, pTruth, nVars );
- Kit_TruthCofactor0( pCof0, nVars, iVar0 );
- Kit_TruthCofactor1( pCof0, nVars, iVar1 );
- // compute Cof10
- Kit_TruthCopy( pCof1, pTruth, nVars );
- Kit_TruthCofactor1( pCof1, nVars, iVar0 );
- Kit_TruthCofactor0( pCof1, nVars, iVar1 );
- // compare
- return Kit_TruthIsEqual( pCof0, pCof1, nVars );
-}
-
-/**Function*************************************************************
-
- Synopsis [Checks antisymmetry of two variables.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_TruthVarsAntiSymm( unsigned * pTruth, int nVars, int iVar0, int iVar1, unsigned * pCof0, unsigned * pCof1 )
-{
- static unsigned uTemp0[32], uTemp1[32];
- if ( pCof0 == NULL )
- {
- assert( nVars <= 10 );
- pCof0 = uTemp0;
- }
- if ( pCof1 == NULL )
- {
- assert( nVars <= 10 );
- pCof1 = uTemp1;
- }
- // compute Cof00
- Kit_TruthCopy( pCof0, pTruth, nVars );
- Kit_TruthCofactor0( pCof0, nVars, iVar0 );
- Kit_TruthCofactor0( pCof0, nVars, iVar1 );
- // compute Cof11
- Kit_TruthCopy( pCof1, pTruth, nVars );
- Kit_TruthCofactor1( pCof1, nVars, iVar0 );
- Kit_TruthCofactor1( pCof1, nVars, iVar1 );
- // compare
- return Kit_TruthIsEqual( pCof0, pCof1, nVars );
-}
-
-/**Function*************************************************************
-
- Synopsis [Changes phase of the function w.r.t. one variable.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthChangePhase( unsigned * pTruth, int nVars, int iVar )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Step;
- unsigned Temp;
-
- assert( iVar < nVars );
- switch ( iVar )
- {
- case 0:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = ((pTruth[i] & 0x55555555) << 1) | ((pTruth[i] & 0xAAAAAAAA) >> 1);
- return;
- case 1:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = ((pTruth[i] & 0x33333333) << 2) | ((pTruth[i] & 0xCCCCCCCC) >> 2);
- return;
- case 2:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = ((pTruth[i] & 0x0F0F0F0F) << 4) | ((pTruth[i] & 0xF0F0F0F0) >> 4);
- return;
- case 3:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = ((pTruth[i] & 0x00FF00FF) << 8) | ((pTruth[i] & 0xFF00FF00) >> 8);
- return;
- case 4:
- for ( i = 0; i < nWords; i++ )
- pTruth[i] = ((pTruth[i] & 0x0000FFFF) << 16) | ((pTruth[i] & 0xFFFF0000) >> 16);
- return;
- default:
- Step = (1 << (iVar - 5));
- for ( k = 0; k < nWords; k += 2*Step )
- {
- for ( i = 0; i < Step; i++ )
- {
- Temp = pTruth[i];
- pTruth[i] = pTruth[Step+i];
- pTruth[Step+i] = Temp;
- }
- pTruth += 2*Step;
- }
- return;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes minimum overlap in supports of cofactors.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_TruthMinCofSuppOverlap( unsigned * pTruth, int nVars, int * pVarMin )
-{
- static unsigned uCofactor[16];
- int i, ValueCur, ValueMin, VarMin;
- unsigned uSupp0, uSupp1;
- int nVars0, nVars1;
- assert( nVars <= 9 );
- ValueMin = 32;
- VarMin = -1;
- for ( i = 0; i < nVars; i++ )
- {
- // get negative cofactor
- Kit_TruthCopy( uCofactor, pTruth, nVars );
- Kit_TruthCofactor0( uCofactor, nVars, i );
- uSupp0 = Kit_TruthSupport( uCofactor, nVars );
- nVars0 = Kit_WordCountOnes( uSupp0 );
-//Kit_PrintBinary( stdout, &uSupp0, 8 ); printf( "\n" );
- // get positive cofactor
- Kit_TruthCopy( uCofactor, pTruth, nVars );
- Kit_TruthCofactor1( uCofactor, nVars, i );
- uSupp1 = Kit_TruthSupport( uCofactor, nVars );
- nVars1 = Kit_WordCountOnes( uSupp1 );
-//Kit_PrintBinary( stdout, &uSupp1, 8 ); printf( "\n" );
- // get the number of common vars
- ValueCur = Kit_WordCountOnes( uSupp0 & uSupp1 );
- if ( ValueMin > ValueCur && nVars0 <= 5 && nVars1 <= 5 )
- {
- ValueMin = ValueCur;
- VarMin = i;
- }
- if ( ValueMin == 0 )
- break;
- }
- if ( pVarMin )
- *pVarMin = VarMin;
- return ValueMin;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Find the best cofactoring variable.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_TruthBestCofVar( unsigned * pTruth, int nVars, unsigned * pCof0, unsigned * pCof1 )
-{
- int i, iBestVar, nSuppSizeCur0, nSuppSizeCur1, nSuppSizeCur, nSuppSizeMin;
- if ( Kit_TruthIsConst0(pTruth, nVars) || Kit_TruthIsConst1(pTruth, nVars) )
- return -1;
- // iterate through variables
- iBestVar = -1;
- nSuppSizeMin = KIT_INFINITY;
- for ( i = 0; i < nVars; i++ )
- {
- // cofactor the functiona and get support sizes
- Kit_TruthCofactor0New( pCof0, pTruth, nVars, i );
- Kit_TruthCofactor1New( pCof1, pTruth, nVars, i );
- nSuppSizeCur0 = Kit_TruthSupportSize( pCof0, nVars );
- nSuppSizeCur1 = Kit_TruthSupportSize( pCof1, nVars );
- nSuppSizeCur = nSuppSizeCur0 + nSuppSizeCur1;
- // compare this variable with other variables
- if ( nSuppSizeMin > nSuppSizeCur )
- {
- nSuppSizeMin = nSuppSizeCur;
- iBestVar = i;
- }
- }
- assert( iBestVar != -1 );
- // cofactor w.r.t. this variable
- Kit_TruthCofactor0New( pCof0, pTruth, nVars, iBestVar );
- Kit_TruthCofactor1New( pCof1, pTruth, nVars, iBestVar );
- return iBestVar;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Counts the number of 1's in each cofactor.]
-
- Description [The resulting numbers are stored in the array of shorts,
- whose length is 2*nVars. The number of 1's is counted in a different
- space than the original function. For example, if the function depends
- on k variables, the cofactors are assumed to depend on k-1 variables.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthCountOnesInCofs( unsigned * pTruth, int nVars, short * pStore )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Counter;
- memset( pStore, 0, sizeof(short) * 2 * nVars );
- if ( nVars <= 5 )
- {
- if ( nVars > 0 )
- {
- pStore[2*0+0] = Kit_WordCountOnes( pTruth[0] & 0x55555555 );
- pStore[2*0+1] = Kit_WordCountOnes( pTruth[0] & 0xAAAAAAAA );
- }
- if ( nVars > 1 )
- {
- pStore[2*1+0] = Kit_WordCountOnes( pTruth[0] & 0x33333333 );
- pStore[2*1+1] = Kit_WordCountOnes( pTruth[0] & 0xCCCCCCCC );
- }
- if ( nVars > 2 )
- {
- pStore[2*2+0] = Kit_WordCountOnes( pTruth[0] & 0x0F0F0F0F );
- pStore[2*2+1] = Kit_WordCountOnes( pTruth[0] & 0xF0F0F0F0 );
- }
- if ( nVars > 3 )
- {
- pStore[2*3+0] = Kit_WordCountOnes( pTruth[0] & 0x00FF00FF );
- pStore[2*3+1] = Kit_WordCountOnes( pTruth[0] & 0xFF00FF00 );
- }
- if ( nVars > 4 )
- {
- pStore[2*4+0] = Kit_WordCountOnes( pTruth[0] & 0x0000FFFF );
- pStore[2*4+1] = Kit_WordCountOnes( pTruth[0] & 0xFFFF0000 );
- }
- return;
- }
- // nVars >= 6
- // count 1's for all other variables
- for ( k = 0; k < nWords; k++ )
- {
- Counter = Kit_WordCountOnes( pTruth[k] );
- for ( i = 5; i < nVars; i++ )
- if ( k & (1 << (i-5)) )
- pStore[2*i+1] += Counter;
- else
- pStore[2*i+0] += Counter;
- }
- // count 1's for the first five variables
- for ( k = 0; k < nWords/2; k++ )
- {
- pStore[2*0+0] += Kit_WordCountOnes( (pTruth[0] & 0x55555555) | ((pTruth[1] & 0x55555555) << 1) );
- pStore[2*0+1] += Kit_WordCountOnes( (pTruth[0] & 0xAAAAAAAA) | ((pTruth[1] & 0xAAAAAAAA) >> 1) );
- pStore[2*1+0] += Kit_WordCountOnes( (pTruth[0] & 0x33333333) | ((pTruth[1] & 0x33333333) << 2) );
- pStore[2*1+1] += Kit_WordCountOnes( (pTruth[0] & 0xCCCCCCCC) | ((pTruth[1] & 0xCCCCCCCC) >> 2) );
- pStore[2*2+0] += Kit_WordCountOnes( (pTruth[0] & 0x0F0F0F0F) | ((pTruth[1] & 0x0F0F0F0F) << 4) );
- pStore[2*2+1] += Kit_WordCountOnes( (pTruth[0] & 0xF0F0F0F0) | ((pTruth[1] & 0xF0F0F0F0) >> 4) );
- pStore[2*3+0] += Kit_WordCountOnes( (pTruth[0] & 0x00FF00FF) | ((pTruth[1] & 0x00FF00FF) << 8) );
- pStore[2*3+1] += Kit_WordCountOnes( (pTruth[0] & 0xFF00FF00) | ((pTruth[1] & 0xFF00FF00) >> 8) );
- pStore[2*4+0] += Kit_WordCountOnes( (pTruth[0] & 0x0000FFFF) | ((pTruth[1] & 0x0000FFFF) << 16) );
- pStore[2*4+1] += Kit_WordCountOnes( (pTruth[0] & 0xFFFF0000) | ((pTruth[1] & 0xFFFF0000) >> 16) );
- pTruth += 2;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Counts the number of 1's in each negative cofactor.]
-
- Description [The resulting numbers are stored in the array of shorts,
- whose length is nVars. The number of 1's is counted in a different
- space than the original function. For example, if the function depends
- on k variables, the cofactors are assumed to depend on k-1 variables.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthCountOnesInCofs0( unsigned * pTruth, int nVars, short * pStore )
-{
- int nWords = Kit_TruthWordNum( nVars );
- int i, k, Counter;
- memset( pStore, 0, sizeof(short) * nVars );
- if ( nVars <= 5 )
- {
- if ( nVars > 0 )
- pStore[0] = Kit_WordCountOnes( pTruth[0] & 0x55555555 );
- if ( nVars > 1 )
- pStore[1] = Kit_WordCountOnes( pTruth[0] & 0x33333333 );
- if ( nVars > 2 )
- pStore[2] = Kit_WordCountOnes( pTruth[0] & 0x0F0F0F0F );
- if ( nVars > 3 )
- pStore[3] = Kit_WordCountOnes( pTruth[0] & 0x00FF00FF );
- if ( nVars > 4 )
- pStore[4] = Kit_WordCountOnes( pTruth[0] & 0x0000FFFF );
- return;
- }
- // nVars >= 6
- // count 1's for all other variables
- for ( k = 0; k < nWords; k++ )
- {
- Counter = Kit_WordCountOnes( pTruth[k] );
- for ( i = 5; i < nVars; i++ )
- if ( (k & (1 << (i-5))) == 0 )
- pStore[i] += Counter;
- }
- // count 1's for the first five variables
- for ( k = 0; k < nWords/2; k++ )
- {
- pStore[0] += Kit_WordCountOnes( (pTruth[0] & 0x55555555) | ((pTruth[1] & 0x55555555) << 1) );
- pStore[1] += Kit_WordCountOnes( (pTruth[0] & 0x33333333) | ((pTruth[1] & 0x33333333) << 2) );
- pStore[2] += Kit_WordCountOnes( (pTruth[0] & 0x0F0F0F0F) | ((pTruth[1] & 0x0F0F0F0F) << 4) );
- pStore[3] += Kit_WordCountOnes( (pTruth[0] & 0x00FF00FF) | ((pTruth[1] & 0x00FF00FF) << 8) );
- pStore[4] += Kit_WordCountOnes( (pTruth[0] & 0x0000FFFF) | ((pTruth[1] & 0x0000FFFF) << 16) );
- pTruth += 2;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Counts the number of 1's in each cofactor.]
-
- Description [Verifies the above procedure.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthCountOnesInCofsSlow( unsigned * pTruth, int nVars, short * pStore, unsigned * pAux )
-{
- int i;
- for ( i = 0; i < nVars; i++ )
- {
- Kit_TruthCofactor0New( pAux, pTruth, nVars, i );
- pStore[2*i+0] = Kit_TruthCountOnes( pAux, nVars ) / 2;
- Kit_TruthCofactor1New( pAux, pTruth, nVars, i );
- pStore[2*i+1] = Kit_TruthCountOnes( pAux, nVars ) / 2;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Canonicize the truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned Kit_TruthHash( unsigned * pIn, int nWords )
-{
- // The 1,024 smallest prime numbers used to compute the hash value
- // http://www.math.utah.edu/~alfeld/math/primelist.html
- static int HashPrimes[1024] = { 2, 3, 5,
- 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,
- 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191,
- 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283,
- 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401,
- 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509,
- 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631,
- 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751,
- 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877,
- 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997,
- 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091,
- 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193,
- 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291,
- 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423,
- 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493,
- 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601,
- 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699,
- 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811,
- 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931,
- 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029,
- 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137,
- 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267,
- 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357,
- 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459,
- 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593,
- 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693,
- 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791,
- 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903,
- 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023,
- 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167,
- 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271,
- 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373,
- 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511,
- 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607,
- 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709,
- 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833,
- 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931,
- 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057,
- 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177,
- 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283,
- 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423,
- 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547,
- 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657,
- 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789,
- 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931,
- 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011,
- 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147,
- 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279,
- 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413,
- 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507,
- 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647,
- 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743,
- 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857,
- 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007,
- 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121,
- 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247,
- 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343,
- 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473,
- 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607,
- 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733,
- 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857,
- 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971,
- 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103,
- 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229,
- 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369,
- 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517,
- 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603,
- 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723,
- 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873,
- 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009,
- 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123,
- 8147, 8161 };
- int i;
- unsigned uHashKey;
- assert( nWords <= 1024 );
- uHashKey = 0;
- for ( i = 0; i < nWords; i++ )
- uHashKey ^= HashPrimes[i] * pIn[i];
- return uHashKey;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Canonicize the truth table.]
-
- Description [Returns the phase. ]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-unsigned Kit_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux, int nVars, char * pCanonPerm, short * pStore )
-{
-// short pStore2[32];
- unsigned * pIn = pInOut, * pOut = pAux, * pTemp;
- int nWords = Kit_TruthWordNum( nVars );
- int i, Temp, fChange, Counter, nOnes;//, k, j, w, Limit;
- unsigned uCanonPhase;
-
- // canonicize output
- uCanonPhase = 0;
-
- nOnes = Kit_TruthCountOnes(pIn, nVars);
- //if(pIn[0] & 1)
- if ( (nOnes > nWords * 16) )//|| ((nOnes == nWords * 16) && (pIn[0] & 1)) )
- {
- uCanonPhase |= (1 << nVars);
- Kit_TruthNot( pIn, pIn, nVars );
- }
-
- // collect the minterm counts
- Kit_TruthCountOnesInCofs( pIn, nVars, pStore );
-/*
- Kit_TruthCountOnesInCofsSlow( pIn, nVars, pStore2, pAux );
- for ( i = 0; i < 2*nVars; i++ )
- {
- assert( pStore[i] == pStore2[i] );
- }
-*/
- // canonicize phase
- for ( i = 0; i < nVars; i++ )
- {
- if ( pStore[2*i+0] <= pStore[2*i+1] )
- continue;
- uCanonPhase |= (1 << i);
- Temp = pStore[2*i+0];
- pStore[2*i+0] = pStore[2*i+1];
- pStore[2*i+1] = Temp;
- Kit_TruthChangePhase( pIn, nVars, i );
- }
-
-// Kit_PrintHexadecimal( stdout, pIn, nVars );
-// printf( "\n" );
-
- // permute
- Counter = 0;
- do {
- fChange = 0;
- for ( i = 0; i < nVars-1; i++ )
- {
- if ( pStore[2*i] <= pStore[2*(i+1)] )
- continue;
- Counter++;
- fChange = 1;
-
- Temp = pCanonPerm[i];
- pCanonPerm[i] = pCanonPerm[i+1];
- pCanonPerm[i+1] = Temp;
-
- Temp = pStore[2*i];
- pStore[2*i] = pStore[2*(i+1)];
- pStore[2*(i+1)] = Temp;
-
- Temp = pStore[2*i+1];
- pStore[2*i+1] = pStore[2*(i+1)+1];
- pStore[2*(i+1)+1] = Temp;
-
- // if the polarity of variables is different, swap them
- if ( ((uCanonPhase & (1 << i)) > 0) != ((uCanonPhase & (1 << (i+1))) > 0) )
- {
- uCanonPhase ^= (1 << i);
- uCanonPhase ^= (1 << (i+1));
- }
-
- Kit_TruthSwapAdjacentVars( pOut, pIn, nVars, i );
- pTemp = pIn; pIn = pOut; pOut = pTemp;
- }
- } while ( fChange );
-
-
-/*
- Extra_PrintBinary( stdout, &uCanonPhase, nVars+1 ); printf( " : " );
- for ( i = 0; i < nVars; i++ )
- printf( "%d=%d/%d ", pCanonPerm[i], pStore[2*i], pStore[2*i+1] );
- printf( " C = %d\n", Counter );
- Extra_PrintHexadecimal( stdout, pIn, nVars );
- printf( "\n" );
-*/
-
-/*
- // process symmetric variable groups
- uSymms = 0;
- for ( i = 0; i < nVars-1; i++ )
- {
- if ( pStore[2*i] != pStore[2*(i+1)] ) // i and i+1 cannot be symmetric
- continue;
- if ( pStore[2*i] != pStore[2*i+1] )
- continue;
- if ( Kit_TruthVarsSymm( pIn, nVars, i, i+1 ) )
- continue;
- if ( Kit_TruthVarsAntiSymm( pIn, nVars, i, i+1 ) )
- Kit_TruthChangePhase( pIn, nVars, i+1 );
- }
-*/
-
-/*
- // process symmetric variable groups
- uSymms = 0;
- for ( i = 0; i < nVars-1; i++ )
- {
- if ( pStore[2*i] != pStore[2*(i+1)] ) // i and i+1 cannot be symmetric
- continue;
- // i and i+1 can be symmetric
- // find the end of this group
- for ( k = i+1; k < nVars; k++ )
- if ( pStore[2*i] != pStore[2*k] )
- break;
- Limit = k;
- assert( i < Limit-1 );
- // go through the variables in this group
- for ( j = i + 1; j < Limit; j++ )
- {
- // check symmetry
- if ( Kit_TruthVarsSymm( pIn, nVars, i, j ) )
- {
- uSymms |= (1 << j);
- continue;
- }
- // they are phase-unknown
- if ( pStore[2*i] == pStore[2*i+1] )
- {
- if ( Kit_TruthVarsAntiSymm( pIn, nVars, i, j ) )
- {
- Kit_TruthChangePhase( pIn, nVars, j );
- uCanonPhase ^= (1 << j);
- uSymms |= (1 << j);
- continue;
- }
- }
-
- // they are not symmetric - move j as far as it goes in the group
- for ( k = j; k < Limit-1; k++ )
- {
- Counter++;
-
- Temp = pCanonPerm[k];
- pCanonPerm[k] = pCanonPerm[k+1];
- pCanonPerm[k+1] = Temp;
-
- assert( pStore[2*k] == pStore[2*(k+1)] );
- Kit_TruthSwapAdjacentVars( pOut, pIn, nVars, k );
- pTemp = pIn; pIn = pOut; pOut = pTemp;
- }
- Limit--;
- j--;
- }
- i = Limit - 1;
- }
-*/
-
- // swap if it was moved an even number of times
- if ( Counter & 1 )
- Kit_TruthCopy( pOut, pIn, nVars );
- return uCanonPhase;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Fast counting minterms in the cofactors of a function.]
-
- Description [Returns the total number of minterms in the function.
- The resulting array (pRes) contains the number of minterms in 0-cofactor
- w.r.t. each variables. The additional array (pBytes) is used for internal
- storage. It should have the size equal to the number of truth table bytes.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Kit_TruthCountMinterms( unsigned * pTruth, int nVars, int * pRes, int * pBytesInit )
-{
- // the number of 1s if every byte as well as in the 0-cofactors w.r.t. three variables
- static unsigned Table[256] = {
- 0x00000000, 0x01010101, 0x01010001, 0x02020102, 0x01000101, 0x02010202, 0x02010102, 0x03020203,
- 0x01000001, 0x02010102, 0x02010002, 0x03020103, 0x02000102, 0x03010203, 0x03010103, 0x04020204,
- 0x00010101, 0x01020202, 0x01020102, 0x02030203, 0x01010202, 0x02020303, 0x02020203, 0x03030304,
- 0x01010102, 0x02020203, 0x02020103, 0x03030204, 0x02010203, 0x03020304, 0x03020204, 0x04030305,
- 0x00010001, 0x01020102, 0x01020002, 0x02030103, 0x01010102, 0x02020203, 0x02020103, 0x03030204,
- 0x01010002, 0x02020103, 0x02020003, 0x03030104, 0x02010103, 0x03020204, 0x03020104, 0x04030205,
- 0x00020102, 0x01030203, 0x01030103, 0x02040204, 0x01020203, 0x02030304, 0x02030204, 0x03040305,
- 0x01020103, 0x02030204, 0x02030104, 0x03040205, 0x02020204, 0x03030305, 0x03030205, 0x04040306,
- 0x00000101, 0x01010202, 0x01010102, 0x02020203, 0x01000202, 0x02010303, 0x02010203, 0x03020304,
- 0x01000102, 0x02010203, 0x02010103, 0x03020204, 0x02000203, 0x03010304, 0x03010204, 0x04020305,
- 0x00010202, 0x01020303, 0x01020203, 0x02030304, 0x01010303, 0x02020404, 0x02020304, 0x03030405,
- 0x01010203, 0x02020304, 0x02020204, 0x03030305, 0x02010304, 0x03020405, 0x03020305, 0x04030406,
- 0x00010102, 0x01020203, 0x01020103, 0x02030204, 0x01010203, 0x02020304, 0x02020204, 0x03030305,
- 0x01010103, 0x02020204, 0x02020104, 0x03030205, 0x02010204, 0x03020305, 0x03020205, 0x04030306,
- 0x00020203, 0x01030304, 0x01030204, 0x02040305, 0x01020304, 0x02030405, 0x02030305, 0x03040406,
- 0x01020204, 0x02030305, 0x02030205, 0x03040306, 0x02020305, 0x03030406, 0x03030306, 0x04040407,
- 0x00000001, 0x01010102, 0x01010002, 0x02020103, 0x01000102, 0x02010203, 0x02010103, 0x03020204,
- 0x01000002, 0x02010103, 0x02010003, 0x03020104, 0x02000103, 0x03010204, 0x03010104, 0x04020205,
- 0x00010102, 0x01020203, 0x01020103, 0x02030204, 0x01010203, 0x02020304, 0x02020204, 0x03030305,
- 0x01010103, 0x02020204, 0x02020104, 0x03030205, 0x02010204, 0x03020305, 0x03020205, 0x04030306,
- 0x00010002, 0x01020103, 0x01020003, 0x02030104, 0x01010103, 0x02020204, 0x02020104, 0x03030205,
- 0x01010003, 0x02020104, 0x02020004, 0x03030105, 0x02010104, 0x03020205, 0x03020105, 0x04030206,
- 0x00020103, 0x01030204, 0x01030104, 0x02040205, 0x01020204, 0x02030305, 0x02030205, 0x03040306,
- 0x01020104, 0x02030205, 0x02030105, 0x03040206, 0x02020205, 0x03030306, 0x03030206, 0x04040307,
- 0x00000102, 0x01010203, 0x01010103, 0x02020204, 0x01000203, 0x02010304, 0x02010204, 0x03020305,
- 0x01000103, 0x02010204, 0x02010104, 0x03020205, 0x02000204, 0x03010305, 0x03010205, 0x04020306,
- 0x00010203, 0x01020304, 0x01020204, 0x02030305, 0x01010304, 0x02020405, 0x02020305, 0x03030406,
- 0x01010204, 0x02020305, 0x02020205, 0x03030306, 0x02010305, 0x03020406, 0x03020306, 0x04030407,
- 0x00010103, 0x01020204, 0x01020104, 0x02030205, 0x01010204, 0x02020305, 0x02020205, 0x03030306,
- 0x01010104, 0x02020205, 0x02020105, 0x03030206, 0x02010205, 0x03020306, 0x03020206, 0x04030307,
- 0x00020204, 0x01030305, 0x01030205, 0x02040306, 0x01020305, 0x02030406, 0x02030306, 0x03040407,
- 0x01020205, 0x02030306, 0x02030206, 0x03040307, 0x02020306, 0x03030407, 0x03030307, 0x04040408
- };
- unsigned uSum;
- unsigned char * pTruthC, * pLimit;
- int * pBytes = pBytesInit;
- int i, iVar, Step, nWords, nBytes, nTotal;
-
- assert( nVars <= 20 );
-
- // clear storage
- memset( pRes, 0, sizeof(int) * nVars );
-
- // count the number of one's in 0-cofactors of the first three variables
- nTotal = uSum = 0;
- nWords = Kit_TruthWordNum( nVars );
- nBytes = nWords * 4;
- pTruthC = (unsigned char *)pTruth;
- pLimit = pTruthC + nBytes;
- for ( ; pTruthC < pLimit; pTruthC++ )
- {
- uSum += Table[*pTruthC];
- *pBytes++ = (Table[*pTruthC] & 0xff);
- if ( (uSum & 0xff) > 246 )
- {
- nTotal += (uSum & 0xff);
- pRes[0] += ((uSum >> 8) & 0xff);
- pRes[2] += ((uSum >> 16) & 0xff);
- pRes[3] += ((uSum >> 24) & 0xff);
- uSum = 0;
- }
- }
- if ( uSum )
- {
- nTotal += (uSum & 0xff);
- pRes[0] += ((uSum >> 8) & 0xff);
- pRes[1] += ((uSum >> 16) & 0xff);
- pRes[2] += ((uSum >> 24) & 0xff);
- }
-
- // count all other variables
- for ( iVar = 3, Step = 1; Step < nBytes; Step *= 2, iVar++ )
- for ( i = 0; i < nBytes; i += Step + Step )
- {
- pRes[iVar] += pBytesInit[i];
- pBytesInit[i] += pBytesInit[i+Step];
- }
- assert( pBytesInit[0] == nTotal );
- assert( iVar == nVars );
-
- for ( i = 0; i < nVars; i++ )
- assert( pRes[i] == Kit_TruthCofactor0Count(pTruth, nVars, i) );
- return nTotal;
-}
-
-/**Function*************************************************************
-
- Synopsis [Prints the hex unsigned into a file.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_PrintHexadecimal( FILE * pFile, unsigned Sign[], int nVars )
-{
- int nDigits, Digit, k;
- // write the number into the file
- nDigits = (1 << nVars) / 4;
- for ( k = nDigits - 1; k >= 0; k-- )
- {
- Digit = ((Sign[k/8] >> ((k%8) * 4)) & 15);
- if ( Digit < 10 )
- fprintf( pFile, "%d", Digit );
- else
- fprintf( pFile, "%c", 'a' + Digit-10 );
- }
-// fprintf( pFile, "\n" );
-}
-
-/**Function*************************************************************
-
- Synopsis [Fast counting minterms for the functions.]
-
- Description [Returns 0 if the function is a constant.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthCountMintermsPrecomp()
-{
- int bit_count[256] = {
- 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
- 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
- 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
- 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
- 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
- 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
- 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
- 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
- };
- unsigned i, uWord;
- for ( i = 0; i < 256; i++ )
- {
- if ( i % 8 == 0 )
- printf( "\n" );
- uWord = bit_count[i];
- uWord |= (bit_count[i & 0x55] << 8);
- uWord |= (bit_count[i & 0x33] << 16);
- uWord |= (bit_count[i & 0x0f] << 24);
- printf( "0x" );
- Kit_PrintHexadecimal( stdout, &uWord, 5 );
- printf( ", " );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Dumps truth table into a file.]
-
- Description [Generates script file for reading into ABC.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-char * Kit_TruthDumpToFile( unsigned * pTruth, int nVars, int nFile )
-{
- static char pFileName[100];
- FILE * pFile;
- sprintf( pFileName, "tt\\s%04d", nFile );
- pFile = fopen( pFileName, "w" );
- fprintf( pFile, "rt " );
- Kit_PrintHexadecimal( pFile, pTruth, nVars );
- fprintf( pFile, "; bdd; sop; ps\n" );
- fclose( pFile );
- return pFileName;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Dumps truth table into a file.]
-
- Description [Generates script file for reading into ABC.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthPrintProfile_int( unsigned * pTruth, int nVars )
-{
- int Mints[20];
- int Mints0[20];
- int Mints1[20];
- int Unique1[20];
- int Total2[20][20];
- int Unique2[20][20];
- int Common2[20][20];
- int nWords = Kit_TruthWordNum( nVars );
- int * pBytes = ABC_ALLOC( int, nWords * 4 );
- unsigned * pIn = ABC_ALLOC( unsigned, nWords );
- unsigned * pOut = ABC_ALLOC( unsigned, nWords );
- unsigned * pCof00 = ABC_ALLOC( unsigned, nWords );
- unsigned * pCof01 = ABC_ALLOC( unsigned, nWords );
- unsigned * pCof10 = ABC_ALLOC( unsigned, nWords );
- unsigned * pCof11 = ABC_ALLOC( unsigned, nWords );
- unsigned * pTemp;
- int nTotalMints, nTotalMints0, nTotalMints1;
- int v, u, i, iVar, nMints1;
- int Cof00, Cof01, Cof10, Cof11;
- int Coz00, Coz01, Coz10, Coz11;
- assert( nVars <= 20 );
- assert( nVars >= 6 );
-
- nTotalMints = Kit_TruthCountMinterms( pTruth, nVars, Mints, pBytes );
- for ( v = 0; v < nVars; v++ )
- Unique1[v] = Kit_TruthBooleanDiffCount( pTruth, nVars, v );
-
- for ( v = 0; v < nVars; v++ )
- for ( u = 0; u < nVars; u++ )
- Total2[v][u] = Unique2[v][u] = Common2[v][u] = -1;
-
- nMints1 = (1<<(nVars-2));
- for ( v = 0; v < nVars; v++ )
- {
- // move this var to be the first
- Kit_TruthCopy( pIn, pTruth, nVars );
-// Extra_PrintBinary( stdout, pIn, (1<<nVars) ); printf( "\n" );
- for ( i = v; i < nVars - 1; i++ )
- {
- Kit_TruthSwapAdjacentVars( pOut, pIn, nVars, i );
- pTemp = pIn; pIn = pOut; pOut = pTemp;
- }
-// Extra_PrintBinary( stdout, pIn, (1<<nVars) ); printf( "\n" );
-// printf( "\n" );
-
-
- // count minterms in both cofactor
- nTotalMints0 = Kit_TruthCountMinterms( pIn, nVars-1, Mints0, pBytes );
- nTotalMints1 = Kit_TruthCountMinterms( pIn+nWords/2, nVars-1, Mints1, pBytes );
- assert( nTotalMints == nTotalMints0 + nTotalMints1 );
-/*
- for ( u = 0; u < nVars-1; u++ )
- printf( "%2d ", Mints0[u] );
- printf( "\n" );
-
- for ( u = 0; u < nVars-1; u++ )
- printf( "%2d ", Mints1[u] );
- printf( "\n" );
-*/
- for ( u = 0; u < nVars-1; u++ )
- {
- if ( u < v )
- iVar = u;
- else
- iVar = u + 1;
- assert( v != iVar );
- // get minter counts in the cofactors
- Cof00 = Mints0[u]; Coz00 = nMints1 - Cof00;
- Cof01 = nTotalMints0-Mints0[u]; Coz01 = nMints1 - Cof01;
- Cof10 = Mints1[u]; Coz10 = nMints1 - Cof10;
- Cof11 = nTotalMints1-Mints1[u]; Coz11 = nMints1 - Cof11;
-
- assert( Cof00 >= 0 && Cof00 <= nMints1 );
- assert( Cof01 >= 0 && Cof01 <= nMints1 );
- assert( Cof10 >= 0 && Cof10 <= nMints1 );
- assert( Cof11 >= 0 && Cof11 <= nMints1 );
-
- assert( Coz00 >= 0 && Coz00 <= nMints1 );
- assert( Coz01 >= 0 && Coz01 <= nMints1 );
- assert( Coz10 >= 0 && Coz10 <= nMints1 );
- assert( Coz11 >= 0 && Coz11 <= nMints1 );
-
- Common2[v][iVar] = Common2[iVar][v] = Cof00 * Coz11 + Coz00 * Cof11 + Cof01 * Coz10 + Coz01 * Cof10;
-
- Total2[v][iVar] = Total2[iVar][v] =
- Cof00 * Coz01 + Coz00 * Cof01 +
- Cof00 * Coz10 + Coz00 * Cof10 +
- Cof00 * Coz11 + Coz00 * Cof11 +
- Cof01 * Coz10 + Coz01 * Cof10 +
- Cof01 * Coz11 + Coz01 * Cof11 +
- Cof10 * Coz11 + Coz10 * Cof11 ;
-
-
- Kit_TruthCofactor0New( pCof00, pIn, nVars-1, u );
- Kit_TruthCofactor1New( pCof01, pIn, nVars-1, u );
- Kit_TruthCofactor0New( pCof10, pIn+nWords/2, nVars-1, u );
- Kit_TruthCofactor1New( pCof11, pIn+nWords/2, nVars-1, u );
-
- Unique2[v][iVar] = Unique2[iVar][v] =
- Kit_TruthXorCount( pCof00, pCof01, nVars-1 ) +
- Kit_TruthXorCount( pCof00, pCof10, nVars-1 ) +
- Kit_TruthXorCount( pCof00, pCof11, nVars-1 ) +
- Kit_TruthXorCount( pCof01, pCof10, nVars-1 ) +
- Kit_TruthXorCount( pCof01, pCof11, nVars-1 ) +
- Kit_TruthXorCount( pCof10, pCof11, nVars-1 );
- }
- }
-
- printf( "\n" );
- printf( " V: " );
- for ( v = 0; v < nVars; v++ )
- printf( "%8c ", v+'a' );
- printf( "\n" );
-
- printf( " M: " );
- for ( v = 0; v < nVars; v++ )
- printf( "%8d ", Mints[v] );
- printf( "\n" );
-
- printf( " U: " );
- for ( v = 0; v < nVars; v++ )
- printf( "%8d ", Unique1[v] );
- printf( "\n" );
- printf( "\n" );
-
- printf( "Unique:\n" );
- for ( i = 0; i < nVars; i++ )
- {
- printf( " %2d ", i );
- for ( v = 0; v < nVars; v++ )
- printf( "%8d ", Unique2[i][v] );
- printf( "\n" );
- }
-
- printf( "Common:\n" );
- for ( i = 0; i < nVars; i++ )
- {
- printf( " %2d ", i );
- for ( v = 0; v < nVars; v++ )
- printf( "%8d ", Common2[i][v] );
- printf( "\n" );
- }
-
- printf( "Total:\n" );
- for ( i = 0; i < nVars; i++ )
- {
- printf( " %2d ", i );
- for ( v = 0; v < nVars; v++ )
- printf( "%8d ", Total2[i][v] );
- printf( "\n" );
- }
-
- ABC_FREE( pIn );
- ABC_FREE( pOut );
- ABC_FREE( pCof00 );
- ABC_FREE( pCof01 );
- ABC_FREE( pCof10 );
- ABC_FREE( pCof11 );
- ABC_FREE( pBytes );
-}
-
-/**Function*************************************************************
-
- Synopsis [Dumps truth table into a file.]
-
- Description [Generates script file for reading into ABC.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Kit_TruthPrintProfile( unsigned * pTruth, int nVars )
-{
- unsigned uTruth[2];
- if ( nVars >= 6 )
- {
- Kit_TruthPrintProfile_int( pTruth, nVars );
- return;
- }
- assert( nVars >= 2 );
- uTruth[0] = pTruth[0];
- uTruth[1] = pTruth[0];
- Kit_TruthPrintProfile( uTruth, 6 );
-}
-
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
-ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/kit_.c b/src/aig/kit/kit_.c
deleted file mode 100644
index 37be0b49..00000000
--- a/src/aig/kit/kit_.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/**CFile****************************************************************
-
- FileName [kit_.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Computation kit.]
-
- Synopsis []
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - Dec 6, 2006.]
-
- Revision [$Id: kit_.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "kit.h"
-
-ABC_NAMESPACE_IMPL_START
-
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
-ABC_NAMESPACE_IMPL_END
-
diff --git a/src/aig/kit/module.make b/src/aig/kit/module.make
deleted file mode 100644
index a592aeec..00000000
--- a/src/aig/kit/module.make
+++ /dev/null
@@ -1,11 +0,0 @@
-SRC += src/aig/kit/kitAig.c \
- src/aig/kit/kitBdd.c \
- src/aig/kit/kitCloud.c src/aig/kit/cloud.c \
- src/aig/kit/kitDsd.c \
- src/aig/kit/kitFactor.c \
- src/aig/kit/kitGraph.c \
- src/aig/kit/kitHop.c \
- src/aig/kit/kitIsop.c \
- src/aig/kit/kitPla.c \
- src/aig/kit/kitSop.c \
- src/aig/kit/kitTruth.c