abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cloud.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "misc/util/abc_global.h"

Go to the source code of this file.

Data Structures

struct  cloudManager
 
struct  cloudNode
 
struct  cloudCacheEntry1
 
struct  cloudCacheEntry2
 
struct  cloudCacheEntry3
 

Macros

#define CLOUD_NODE_BITS   23
 
#define CLOUD_CONST_INDEX   ((unsigned)0x0fffffff)
 
#define CLOUD_MARK_ON   ((unsigned)0x10000000)
 
#define CLOUD_MARK_OFF   ((unsigned)0xefffffff)
 
#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))
 
#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))
 
#define Cloud_Regular(p)   ((CloudNode*)(((ABC_PTRUINT_T)(p)) & ~01))
 
#define Cloud_Not(p)   ((CloudNode*)(((ABC_PTRUINT_T)(p)) ^ 01))
 
#define Cloud_NotCond(p, c)   ((CloudNode*)(((ABC_PTRUINT_T)(p)) ^ (c)))
 
#define Cloud_IsComplement(p)   ((int)(((ABC_PTRUINT_T)(p)) & 01))
 
#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)
 
#define Cloud_V(p)   ((Cloud_Regular(p))->v)
 
#define Cloud_E(p)   ((Cloud_Regular(p))->e)
 
#define Cloud_T(p)   ((Cloud_Regular(p))->t)
 
#define cloudV(p)   ((p)->v)
 
#define cloudE(p)   ((p)->e)
 
#define cloudT(p)   ((p)->t)
 
#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))
 
#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))
 
#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->tUnique && (p) < dd->tUnique+dd->nNodesAlloc)
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
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
 

Enumerations

enum  CloudOper { CLOUD_OPER_AND, CLOUD_OPER_XOR, CLOUD_OPER_BDIFF, CLOUD_OPER_LEQ }
 

Functions

CloudManagerCloud_Init (int nVars, int nBits)
 FUNCTION DECLARATIONS ///. More...
 
void Cloud_Quit (CloudManager *dd)
 
void Cloud_Restart (CloudManager *dd)
 
void Cloud_CacheAllocate (CloudManager *dd, CloudOper oper, int size)
 
CloudNodeCloud_MakeNode (CloudManager *dd, CloudVar v, CloudNode *t, CloudNode *e)
 
CloudNodeCloud_Support (CloudManager *dd, CloudNode *n)
 
int Cloud_SupportSize (CloudManager *dd, CloudNode *n)
 
int Cloud_DagSize (CloudManager *dd, CloudNode *n)
 
int Cloud_DagCollect (CloudManager *dd, CloudNode *n)
 
int Cloud_SharingSize (CloudManager *dd, CloudNode **pn, int nn)
 
CloudNodeCloud_GetOneCube (CloudManager *dd, CloudNode *n)
 
void Cloud_bddPrint (CloudManager *dd, CloudNode *Func)
 
void Cloud_bddPrintCube (CloudManager *dd, CloudNode *Cube)
 
CloudNodeCloud_bddAnd (CloudManager *dd, CloudNode *f, CloudNode *g)
 
CloudNodeCloud_bddOr (CloudManager *dd, CloudNode *f, CloudNode *g)
 
void Cloud_PrintInfo (CloudManager *dd)
 
void Cloud_PrintHashTable (CloudManager *dd)
 

Macro Definition Documentation

#define CLOUD_ASSERT (   p)    assert((p) >= dd->tUnique && (p) < dd->tUnique+dd->nNodesAlloc)

Definition at line 216 of file cloud.h.

#define CLOUD_CONST_INDEX   ((unsigned)0x0fffffff)

Definition at line 169 of file cloud.h.

#define Cloud_E (   p)    ((Cloud_Regular(p))->e)

Definition at line 195 of file cloud.h.

#define Cloud_IsComplement (   p)    ((int)(((ABC_PTRUINT_T)(p)) & 01))

Definition at line 188 of file cloud.h.

#define Cloud_IsConstant (   p)    (((Cloud_Regular(p))->v & CLOUD_MARK_OFF) == CLOUD_CONST_INDEX)

Definition at line 190 of file cloud.h.

#define CLOUD_MARK_OFF   ((unsigned)0xefffffff)

Definition at line 171 of file cloud.h.

#define CLOUD_MARK_ON   ((unsigned)0x10000000)

Definition at line 170 of file cloud.h.

#define CLOUD_NODE_BITS   23

Definition at line 167 of file cloud.h.

#define Cloud_Not (   p)    ((CloudNode*)(((ABC_PTRUINT_T)(p)) ^ 01))

Definition at line 186 of file cloud.h.

#define Cloud_NotCond (   p,
 
)    ((CloudNode*)(((ABC_PTRUINT_T)(p)) ^ (c)))

Definition at line 187 of file cloud.h.

#define Cloud_Regular (   p)    ((CloudNode*)(((ABC_PTRUINT_T)(p)) & ~01))

Definition at line 185 of file cloud.h.

#define Cloud_T (   p)    ((Cloud_Regular(p))->t)

Definition at line 196 of file cloud.h.

#define Cloud_V (   p)    ((Cloud_Regular(p))->v)

Definition at line 194 of file cloud.h.

#define cloudCacheInsert1 (   p,
  sign,
  f,
 
)    (((p)->s = (sign)), ((p)->a = (f)), ((p)->r = (r)))

Definition at line 211 of file cloud.h.

#define cloudCacheInsert2 (   p,
  sign,
  f,
  g,
 
)    (((p)->s = (sign)), ((p)->a = (f)), ((p)->b = (g)), ((p)->r = (r)))

Definition at line 212 of file cloud.h.

#define cloudCacheInsert3 (   p,
  sign,
  f,
  g,
  h,
 
)    (((p)->s = (sign)), ((p)->a = (f)), ((p)->b = (g)), ((p)->c = (h)), ((p)->r = (r)))

Definition at line 213 of file cloud.h.

#define cloudCacheLookup1 (   p,
  sign,
 
)    (((p)->s == (sign) && (p)->a == (f))? ((p)->r): (0))

Definition at line 207 of file cloud.h.

#define cloudCacheLookup2 (   p,
  sign,
  f,
 
)    (((p)->s == (sign) && (p)->a == (f) && (p)->b == (g))? ((p)->r): (0))

Definition at line 208 of file cloud.h.

#define cloudCacheLookup3 (   p,
  sign,
  f,
  g,
 
)    (((p)->s == (sign) && (p)->a == (f) && (p)->b == (g) && (p)->c == (h))? ((p)->r): (0))

Definition at line 209 of file cloud.h.

#define cloudE (   p)    ((p)->e)

Definition at line 199 of file cloud.h.

#define cloudHashBuddy2 (   x,
  y,
 
)    ((((x)+(y))*((x)+(y)+1)/2) & ((1<<(32-(s)))-1))

Definition at line 174 of file cloud.h.

#define cloudHashBuddy3 (   x,
  y,
  z,
 
)    (cloudHashBuddy2((cloudHashBuddy2((x),(y),(s))),(z),(s)) & ((1<<(32-(s)))-1))

Definition at line 175 of file cloud.h.

#define cloudHashCudd2 (   f,
  g,
 
)    ((((unsigned)(ABC_PTRUINT_T)(f) * DD_P1 + (unsigned)(ABC_PTRUINT_T)(g)) * DD_P2) >> (s))

Definition at line 181 of file cloud.h.

#define cloudHashCudd3 (   f,
  g,
  h,
 
)    (((((unsigned)(ABC_PTRUINT_T)(f) * DD_P1 + (unsigned)(ABC_PTRUINT_T)(g)) * DD_P2 + (unsigned)(ABC_PTRUINT_T)(h)) * DD_P3) >> (s))

Definition at line 182 of file cloud.h.

#define cloudIsConstant (   p)    (((p)->v & CLOUD_MARK_OFF) == CLOUD_CONST_INDEX)

Definition at line 191 of file cloud.h.

#define cloudNodeIsMarked (   p)    ((int)((p)->v & CLOUD_MARK_ON))

Definition at line 204 of file cloud.h.

#define cloudNodeMark (   p)    ((p)->v |= CLOUD_MARK_ON)

Definition at line 202 of file cloud.h.

#define cloudNodeUnmark (   p)    ((p)->v &= CLOUD_MARK_OFF)

Definition at line 203 of file cloud.h.

#define cloudT (   p)    ((p)->t)

Definition at line 200 of file cloud.h.

#define cloudV (   p)    ((p)->v)

Definition at line 198 of file cloud.h.

#define DD_P1   12582917

Definition at line 177 of file cloud.h.

#define DD_P2   4256249

Definition at line 178 of file cloud.h.

#define DD_P3   741457

Definition at line 179 of file cloud.h.

#define DD_P4   1618033999

Definition at line 180 of file cloud.h.

Typedef Documentation

Definition at line 56 of file cloud.h.

Definition at line 57 of file cloud.h.

Definition at line 58 of file cloud.h.

typedef typedefABC_NAMESPACE_HEADER_START struct cloudManager CloudManager

CFile****************************************************************

FileName [cloud.h]

PackageName [Fast application-specific BDD package.]

Synopsis [Interface of the package.]

Author [Alan Mishchenko alanm.nosp@m.i@ec.nosp@m.e.pdx.nosp@m..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

]

Definition at line 52 of file cloud.h.

typedef struct cloudNode CloudNode

Definition at line 55 of file cloud.h.

typedef unsigned CloudSign

Definition at line 54 of file cloud.h.

typedef unsigned CloudVar

Definition at line 53 of file cloud.h.

Enumeration Type Documentation

enum CloudOper
Enumerator
CLOUD_OPER_AND 
CLOUD_OPER_XOR 
CLOUD_OPER_BDIFF 
CLOUD_OPER_LEQ 

Definition at line 61 of file cloud.h.

Function Documentation

CloudNode* Cloud_bddAnd ( CloudManager dd,
CloudNode f,
CloudNode g 
)

Function********************************************************************

Synopsis [Performs the AND or two BDDs]

Description []

SideEffects []

SeeAlso []

Definition at line 489 of file cloud.c.

490 {
491  if ( Cloud_Regular(f) == NULL || Cloud_Regular(g) == NULL )
492  return NULL;
493  CLOUD_ASSERT(f);
494  CLOUD_ASSERT(g);
495  if ( dd->tCaches[CLOUD_OPER_AND] == NULL )
497  return cloudBddAnd_gate( dd, f, g );
498 }
#define CLOUD_ASSERT(p)
Definition: cloud.h:216
#define Cloud_Regular(p)
Definition: cloud.h:185
static void cloudCacheAllocate(CloudManager *dd, CloudOper oper)
Definition: cloud.c:219
static CloudNode * cloudBddAnd_gate(CloudManager *dd, CloudNode *f, CloudNode *g)
Definition: cloud.c:470
CloudNode* Cloud_bddOr ( CloudManager dd,
CloudNode f,
CloudNode g 
)

Function********************************************************************

Synopsis [Performs the OR or two BDDs]

Description []

SideEffects []

SeeAlso []

Definition at line 511 of file cloud.c.

512 {
513  CloudNode * res;
514  if ( Cloud_Regular(f) == NULL || Cloud_Regular(g) == NULL )
515  return NULL;
516  CLOUD_ASSERT(f);
517  CLOUD_ASSERT(g);
518  if ( dd->tCaches[CLOUD_OPER_AND] == NULL )
520  res = cloudBddAnd_gate( dd, Cloud_Not(f), Cloud_Not(g) );
521  res = Cloud_NotCond( res, res != NULL );
522  return res;
523 }
#define Cloud_NotCond(p, c)
Definition: cloud.h:187
#define CLOUD_ASSERT(p)
Definition: cloud.h:216
#define Cloud_Not(p)
Definition: cloud.h:186
#define Cloud_Regular(p)
Definition: cloud.h:185
static void cloudCacheAllocate(CloudManager *dd, CloudOper oper)
Definition: cloud.c:219
static CloudNode * cloudBddAnd_gate(CloudManager *dd, CloudNode *f, CloudNode *g)
Definition: cloud.c:470
void Cloud_bddPrint ( CloudManager dd,
CloudNode Func 
)

Function********************************************************************

Synopsis [Prints the BDD as a set of disjoint cubes to the standard output.]

Description []

SideEffects []

Definition at line 866 of file cloud.c.

867 {
868  CloudNode * Cube;
869  int fFirst = 1;
870 
871  if ( Func == dd->zero )
872  printf( "Constant 0." );
873  else if ( Func == dd->one )
874  printf( "Constant 1." );
875  else
876  {
877  while ( 1 )
878  {
879  Cube = Cloud_GetOneCube( dd, Func );
880  if ( Cube == NULL || Cube == dd->zero )
881  break;
882  if ( fFirst ) fFirst = 0;
883  else printf( " + " );
884  Cloud_bddPrintCube( dd, Cube );
885  Func = Cloud_bddAnd( dd, Func, Cloud_Not(Cube) );
886  }
887  }
888  printf( "\n" );
889 }
CloudNode * Cloud_GetOneCube(CloudManager *dd, CloudNode *bFunc)
Definition: cloud.c:817
#define Cloud_Not(p)
Definition: cloud.h:186
CloudNode * Cloud_bddAnd(CloudManager *dd, CloudNode *f, CloudNode *g)
Definition: cloud.c:489
void Cloud_bddPrintCube(CloudManager *dd, CloudNode *bCube)
Definition: cloud.c:900
void Cloud_bddPrintCube ( CloudManager dd,
CloudNode bCube 
)

Function********************************************************************

Synopsis [Prints one cube.]

Description []

SideEffects []

Definition at line 900 of file cloud.c.

901 {
902  CloudNode * bCube0, * bCube1;
903 
904  assert( !Cloud_IsConstant(bCube) );
905  while ( 1 )
906  {
907  // get the node structure
908  if ( Cloud_IsConstant(bCube) )
909  break;
910 
911  // cofactor the cube
912  if ( Cloud_IsComplement(bCube) )
913  {
914  bCube0 = Cloud_Not( cloudE(bCube) );
915  bCube1 = Cloud_Not( cloudT(bCube) );
916  }
917  else
918  {
919  bCube0 = cloudE(bCube);
920  bCube1 = cloudT(bCube);
921  }
922 
923  if ( bCube0 != dd->zero )
924  {
925  assert( bCube1 == dd->zero );
926  printf( "[%d]'", cloudV(bCube) );
927  bCube = bCube0;
928  }
929  else
930  {
931  assert( bCube1 != dd->zero );
932  printf( "[%d]", cloudV(bCube) );
933  bCube = bCube1;
934  }
935  }
936 }
#define Cloud_IsComplement(p)
Definition: cloud.h:188
#define Cloud_Not(p)
Definition: cloud.h:186
#define cloudV(p)
Definition: cloud.h:198
#define Cloud_IsConstant(p)
Definition: cloud.h:190
#define cloudE(p)
Definition: cloud.h:199
#define assert(ex)
Definition: util_old.h:213
#define cloudT(p)
Definition: cloud.h:200
void Cloud_CacheAllocate ( CloudManager dd,
CloudOper  oper,
int  logratio 
)

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 []

Definition at line 195 of file cloud.c.

196 {
197  assert( logratio > 0 ); // cache cannot be larger than the unique table
198  assert( logratio < dd->bitsNode ); // cache cannot be smaller than 2 entries
199 
200  if ( logratio )
201  {
202  dd->bitsCache[oper] = dd->bitsNode - logratio;
203  dd->shiftCache[oper] = 8*sizeof(unsigned) - dd->bitsCache[oper];
204  }
205  cloudCacheAllocate( dd, oper );
206 }
static void cloudCacheAllocate(CloudManager *dd, CloudOper oper)
Definition: cloud.c:219
#define assert(ex)
Definition: util_old.h:213
int Cloud_DagCollect ( CloudManager dd,
CloudNode n 
)

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 []

Definition at line 772 of file cloud.c.

773 {
774  int res, Counter = 0;
775  if ( dd->ppNodes == NULL )
776  dd->ppNodes = ABC_ALLOC( CloudNode *, dd->nNodesLimit );
777  res = Cloud_DagCollect_rec( dd, Cloud_Regular( n ), &Counter );
778  cloudClearMark( dd, Cloud_Regular( n ) );
779  assert( res == Counter );
780  return res;
781 
782 }
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void cloudClearMark(CloudManager *dd, CloudNode *n)
Definition: cloud.c:569
#define Cloud_Regular(p)
Definition: cloud.h:185
static int Cloud_DagCollect_rec(CloudManager *dd, CloudNode *n, int *pCounter)
Definition: cloud.c:741
static int Counter
#define assert(ex)
Definition: util_old.h:213
int Cloud_DagSize ( CloudManager dd,
CloudNode n 
)

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 []

Definition at line 721 of file cloud.c.

722 {
723  int res;
724  res = cloudDagSize( dd, Cloud_Regular( n ) );
725  cloudClearMark( dd, Cloud_Regular( n ) );
726  return res;
727 
728 }
static int cloudDagSize(CloudManager *dd, CloudNode *n)
Definition: cloud.c:694
static void cloudClearMark(CloudManager *dd, CloudNode *n)
Definition: cloud.c:569
#define Cloud_Regular(p)
Definition: cloud.h:185
CloudNode* Cloud_GetOneCube ( CloudManager dd,
CloudNode bFunc 
)

Function********************************************************************

Synopsis [Returns one cube contained in the given BDD.]

Description []

SideEffects []

Definition at line 817 of file cloud.c.

818 {
819  CloudNode * bFunc0, * bFunc1, * res;
820 
821  if ( Cloud_IsConstant(bFunc) )
822  return bFunc;
823 
824  // cofactor
825  if ( Cloud_IsComplement(bFunc) )
826  {
827  bFunc0 = Cloud_Not( cloudE(bFunc) );
828  bFunc1 = Cloud_Not( cloudT(bFunc) );
829  }
830  else
831  {
832  bFunc0 = cloudE(bFunc);
833  bFunc1 = cloudT(bFunc);
834  }
835 
836  // try to find the cube with the negative literal
837  res = Cloud_GetOneCube( dd, bFunc0 );
838  if ( res == NULL )
839  return NULL;
840 
841  if ( res != dd->zero )
842  {
843  res = Cloud_bddAnd( dd, res, Cloud_Not(dd->vars[Cloud_V(bFunc)]) );
844  }
845  else
846  {
847  // try to find the cube with the positive literal
848  res = Cloud_GetOneCube( dd, bFunc1 );
849  if ( res == NULL )
850  return NULL;
851  assert( res != dd->zero );
852  res = Cloud_bddAnd( dd, res, dd->vars[Cloud_V(bFunc)] );
853  }
854  return res;
855 }
#define Cloud_IsComplement(p)
Definition: cloud.h:188
CloudNode * Cloud_GetOneCube(CloudManager *dd, CloudNode *bFunc)
Definition: cloud.c:817
#define Cloud_Not(p)
Definition: cloud.h:186
CloudNode * Cloud_bddAnd(CloudManager *dd, CloudNode *f, CloudNode *g)
Definition: cloud.c:489
#define Cloud_V(p)
Definition: cloud.h:194
#define Cloud_IsConstant(p)
Definition: cloud.h:190
#define cloudE(p)
Definition: cloud.h:199
#define assert(ex)
Definition: util_old.h:213
#define cloudT(p)
Definition: cloud.h:200
CloudManager* Cloud_Init ( int  nVars,
int  nBits 
)

FUNCTION DECLARATIONS ///.

FUNCTION DECLARATIONS ///.

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 []

Definition at line 70 of file cloud.c.

71 {
72  CloudManager * dd;
73  int i;
74  abctime clk1, clk2;
75 
76  assert( nVars <= 100000 );
77  assert( nBits < 32 );
78 
79  // assign the defaults
80  if ( nBits == 0 )
81  nBits = CLOUD_NODE_BITS;
82 
83  // start the manager
84  dd = ABC_CALLOC( CloudManager, 1 );
85  dd->nMemUsed += sizeof(CloudManager);
86 
87  // variables
88  dd->nVars = nVars; // the number of variables allocated
89  // bits
90  dd->bitsNode = nBits; // the number of bits used for the node
91  for ( i = 0; i < CacheOperNum; i++ )
92  dd->bitsCache[i] = nBits - CacheLogRatioDefault[i];
93  // shifts
94  dd->shiftUnique = 8*sizeof(unsigned) - (nBits + 1); // gets node index in the hash table
95  for ( i = 0; i < CacheOperNum; i++ )
96  dd->shiftCache[i] = 8*sizeof(unsigned) - dd->bitsCache[i];
97  // nodes
98  dd->nNodesAlloc = (1 << (nBits + 1)); // 2 ^ (nBits + 1)
99  dd->nNodesLimit = (1 << nBits); // 2 ^ nBits
100 
101  // unique table
102 clk1 = Abc_Clock();
103  dd->tUnique = ABC_CALLOC( CloudNode, dd->nNodesAlloc );
104  dd->nMemUsed += sizeof(CloudNode) * dd->nNodesAlloc;
105 clk2 = Abc_Clock();
106 //ABC_PRT( "calloc() time", clk2 - clk1 );
107 
108  // set up the constant node (the only node that is not in the hash table)
109  dd->nSignCur = 1;
110  dd->tUnique[0].s = dd->nSignCur;
111  dd->tUnique[0].v = CLOUD_CONST_INDEX;
112  dd->tUnique[0].e = NULL;
113  dd->tUnique[0].t = NULL;
114  dd->one = dd->tUnique;
115  dd->zero = Cloud_Not(dd->one);
116  dd->nNodesCur = 1;
117 
118  // special nodes
119  dd->pNodeStart = dd->tUnique + 1;
120  dd->pNodeEnd = dd->tUnique + dd->nNodesAlloc;
121 
122  // set up the elementary variables
123  dd->vars = ABC_ALLOC( CloudNode *, dd->nVars );
124  dd->nMemUsed += sizeof(CloudNode *) * dd->nVars;
125  for ( i = 0; i < dd->nVars; i++ )
126  dd->vars[i] = cloudMakeNode( dd, i, dd->one, dd->zero );
127 
128  return dd;
129 };
typedefABC_NAMESPACE_HEADER_START struct cloudManager CloudManager
Definition: cloud.h:52
static ABC_NAMESPACE_IMPL_START int CacheOperNum
Definition: cloud.c:26
#define CLOUD_NODE_BITS
Definition: cloud.h:167
#define CLOUD_CONST_INDEX
Definition: cloud.h:169
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define Cloud_Not(p)
Definition: cloud.h:186
static abctime Abc_Clock()
Definition: abc_global.h:279
for(p=first;p->value< newval;p=p->next)
static int CacheLogRatioDefault[4]
Definition: cloud.c:29
struct cloudNode CloudNode
Definition: cloud.h:55
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
static CloudNode * cloudMakeNode(CloudManager *dd, CloudVar v, CloudNode *t, CloudNode *e)
FUNCTION DECLARATIONS ///.
Definition: cloud.c:283
CloudNode* Cloud_MakeNode ( CloudManager dd,
CloudVar  v,
CloudNode t,
CloudNode e 
)

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 []

Definition at line 254 of file cloud.c.

255 {
256  CloudNode * pRes;
257  CLOUD_ASSERT(t);
258  CLOUD_ASSERT(e);
259  assert( v < Cloud_V(t) && v < Cloud_V(e) ); // variable should be above in the order
260  if ( Cloud_IsComplement(t) )
261  {
262  pRes = cloudMakeNode( dd, v, Cloud_Not(t), Cloud_Not(e) );
263  if ( pRes != NULL )
264  pRes = Cloud_Not(pRes);
265  }
266  else
267  pRes = cloudMakeNode( dd, v, t, e );
268  return pRes;
269 }
#define Cloud_IsComplement(p)
Definition: cloud.h:188
#define CLOUD_ASSERT(p)
Definition: cloud.h:216
#define Cloud_Not(p)
Definition: cloud.h:186
#define Cloud_V(p)
Definition: cloud.h:194
#define assert(ex)
Definition: util_old.h:213
static CloudNode * cloudMakeNode(CloudManager *dd, CloudVar v, CloudNode *t, CloudNode *e)
FUNCTION DECLARATIONS ///.
Definition: cloud.c:283
void Cloud_PrintHashTable ( CloudManager dd)

Function********************************************************************

Synopsis [Prints the state of the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 975 of file cloud.c.

976 {
977  int i;
978 
979  for ( i = 0; i < dd->nNodesAlloc; i++ )
980  if ( dd->tUnique[i].v == CLOUD_CONST_INDEX )
981  printf( "-" );
982  else
983  printf( "+" );
984  printf( "\n" );
985 }
#define CLOUD_CONST_INDEX
Definition: cloud.h:169
void Cloud_PrintInfo ( CloudManager dd)

Function********************************************************************

Synopsis [Prints info.]

Description []

SideEffects []

SeeAlso []

Definition at line 950 of file cloud.c.

951 {
952  if ( dd == NULL ) return;
953  printf( "The number of unique table nodes allocated = %12d.\n", dd->nNodesAlloc );
954  printf( "The number of unique table nodes present = %12d.\n", dd->nNodesCur );
955  printf( "The number of unique table hits = %12d.\n", dd->nUniqueHits );
956  printf( "The number of unique table misses = %12d.\n", dd->nUniqueMisses );
957  printf( "The number of unique table steps = %12d.\n", dd->nUniqueSteps );
958  printf( "The number of cache hits = %12d.\n", dd->nCacheHits );
959  printf( "The number of cache misses = %12d.\n", dd->nCacheMisses );
960  printf( "The current signature = %12d.\n", dd->nSignCur );
961  printf( "The total memory in use = %12d.\n", dd->nMemUsed );
962 }
void Cloud_Quit ( CloudManager 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 []

Definition at line 144 of file cloud.c.

145 {
146  int i;
147  ABC_FREE( dd->ppNodes );
148  ABC_FREE( dd->tUnique );
149  ABC_FREE( dd->vars );
150  for ( i = 0; i < 4; i++ )
151  ABC_FREE( dd->tCaches[i] );
152  ABC_FREE( dd );
153 }
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Cloud_Restart ( CloudManager dd)

Function********************************************************************

Synopsis [Prepares the manager for another run.]

Description []

SideEffects []

SeeAlso []

Definition at line 166 of file cloud.c.

167 {
168  int i;
169  assert( dd->one->s == dd->nSignCur );
170  dd->nSignCur++;
171  dd->one->s++;
172  for ( i = 0; i < dd->nVars; i++ )
173  dd->vars[i]->s++;
174  dd->nNodesCur = 1 + dd->nVars;
175 }
#define assert(ex)
Definition: util_old.h:213
int Cloud_SharingSize ( CloudManager dd,
CloudNode **  pn,
int  nn 
)

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 []

Definition at line 796 of file cloud.c.

797 {
798  int res, i;
799  res = 0;
800  for ( i = 0; i < nn; i++ )
801  res += cloudDagSize( dd, Cloud_Regular( pn[i] ) );
802  for ( i = 0; i < nn; i++ )
803  cloudClearMark( dd, Cloud_Regular( pn[i] ) );
804  return res;
805 }
static int cloudDagSize(CloudManager *dd, CloudNode *n)
Definition: cloud.c:694
static void cloudClearMark(CloudManager *dd, CloudNode *n)
Definition: cloud.c:569
#define Cloud_Regular(p)
Definition: cloud.h:185
CloudNode* Cloud_Support ( CloudManager dd,
CloudNode n 
)

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 []

Definition at line 618 of file cloud.c.

619 {
620  CloudNode * res;
621  int * support, i;
622 
623  CLOUD_ASSERT(n);
624 
625  // allocate and initialize support array for cloudSupport
626  support = ABC_CALLOC( int, dd->nVars );
627 
628  // compute support and clean up markers
629  cloudSupport( dd, Cloud_Regular(n), support );
630  cloudClearMark( dd, Cloud_Regular(n) );
631 
632  // transform support from array to cube
633  res = dd->one;
634  for ( i = dd->nVars - 1; i >= 0; i-- ) // for each level bottom-up
635  if ( support[i] == 1 )
636  {
637  res = Cloud_bddAnd( dd, res, dd->vars[i] );
638  if ( res == NULL )
639  break;
640  }
641  ABC_FREE( support );
642  return res;
643 }
#define CLOUD_ASSERT(p)
Definition: cloud.h:216
static void cloudClearMark(CloudManager *dd, CloudNode *n)
Definition: cloud.c:569
#define Cloud_Regular(p)
Definition: cloud.h:185
CloudNode * Cloud_bddAnd(CloudManager *dd, CloudNode *f, CloudNode *g)
Definition: cloud.c:489
int support
Definition: abcSaucy.c:64
static void cloudSupport(CloudManager *dd, CloudNode *n, int *support)
Definition: cloud.c:594
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
int Cloud_SupportSize ( CloudManager dd,
CloudNode n 
)

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 []

Definition at line 658 of file cloud.c.

659 {
660  int * support, i, count;
661 
662  CLOUD_ASSERT(n);
663 
664  // allocate and initialize support array for cloudSupport
665  support = ABC_CALLOC( int, dd->nVars );
666 
667  // compute support and clean up markers
668  cloudSupport( dd, Cloud_Regular(n), support );
669  cloudClearMark( dd, Cloud_Regular(n) );
670 
671  // count support variables
672  count = 0;
673  for ( i = 0; i < dd->nVars; i++ )
674  {
675  if ( support[i] == 1 )
676  count++;
677  }
678 
679  ABC_FREE( support );
680  return count;
681 }
#define CLOUD_ASSERT(p)
Definition: cloud.h:216
static void cloudClearMark(CloudManager *dd, CloudNode *n)
Definition: cloud.c:569
#define Cloud_Regular(p)
Definition: cloud.h:185
int support
Definition: abcSaucy.c:64
static void cloudSupport(CloudManager *dd, CloudNode *n, int *support)
Definition: cloud.c:594
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230