abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
primes.c File Reference
#include "espresso.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START bool 
primes_consensus_special_cases ()
 
static pcover primes_consensus_merge ()
 
static pcover and_with_cofactor ()
 
pcover primes_consensus (pcube *T)
 
static bool primes_consensus_special_cases (pcube *T, pcover *Tnew)
 
static pcover primes_consensus_merge (pcover Tl, pcover Tr, pcube cl, pcube cr)
 
static pcover and_with_cofactor (pset_family A, pset cof)
 

Function Documentation

static pcover and_with_cofactor ( )
static
static pcover and_with_cofactor ( pset_family  A,
pset  cof 
)
static

Definition at line 158 of file primes.c.

161 {
162  register pset last, p;
163 
164  foreach_set(A, last, p) {
165  INLINEset_and(p, p, cof);
166  if (cdist(p, cube.fullset) > 0) {
167  RESET(p, ACTIVE);
168  } else {
169  SET(p, ACTIVE);
170  }
171  }
172  return sf_inactive(A);
173 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define INLINEset_and(r, a, b)
Definition: espresso.h:202
#define SET(set, flag)
Definition: espresso.h:122
#define foreach_set(R, last, p)
Definition: espresso.h:135
#define RESET(set, flag)
Definition: espresso.h:123
int cdist()
unsigned int * pset
Definition: espresso.h:73
#define ACTIVE
Definition: espresso.h:129
pset_family sf_inactive()
pcover primes_consensus ( pcube T)

Definition at line 21 of file primes.c.

23 {
24  register pcube cl, cr;
25  register int best;
26  pcover Tnew, Tl, Tr;
27 
28  if (primes_consensus_special_cases(T, &Tnew) == MAYBE) {
29  cl = new_cube();
30  cr = new_cube();
31  best = binate_split_select(T, cl, cr, COMPL);
32 
33  Tl = primes_consensus(scofactor(T, cl, best));
34  Tr = primes_consensus(scofactor(T, cr, best));
35  Tnew = primes_consensus_merge(Tl, Tr, cl, cr);
36 
37  free_cube(cl);
38  free_cube(cr);
39  free_cubelist(T);
40  }
41 
42  return Tnew;
43 }
#define new_cube()
Definition: espresso.h:262
pcover primes_consensus(pcube *T)
Definition: primes.c:21
#define pcover
Definition: espresso.h:264
static pcover primes_consensus_merge()
#define free_cube(r)
Definition: espresso.h:263
static ABC_NAMESPACE_IMPL_START bool primes_consensus_special_cases()
int binate_split_select(IN pcube *T, IN register pcube cleft, IN register pcube cright, IN int debug_flag)
Definition: cofactor.c:258
pcube * scofactor(IN pcube *T, IN pcube c, IN int var)
Definition: cofactor.c:93
#define free_cubelist(T)
Definition: espresso.h:267
#define MAYBE
Definition: espresso.h:257
#define COMPL
Definition: espresso.h:351
#define pcube
Definition: espresso.h:261
static pcover primes_consensus_merge ( )
static
static pcover primes_consensus_merge ( pcover  Tl,
pcover  Tr,
pcube  cl,
pcube  cr 
)
static

Definition at line 121 of file primes.c.

124 {
125  register pcube pl, pr, lastl, lastr, pt;
126  pcover T, Tsave;
127 
128  Tl = and_with_cofactor(Tl, cl);
129  Tr = and_with_cofactor(Tr, cr);
130 
131  T = sf_new(500, Tl->sf_size);
132  pt = T->data;
133  Tsave = sf_contain(sf_join(Tl, Tr));
134 
135  foreach_set(Tl, lastl, pl) {
136  foreach_set(Tr, lastr, pr) {
137  if (cdist01(pl, pr) == 1) {
138  consensus(pt, pl, pr);
139  if (++T->count >= T->capacity) {
140  Tsave = sf_union(Tsave, sf_contain(T));
141  T = sf_new(500, Tl->sf_size);
142  pt = T->data;
143  } else {
144  pt += T->wsize;
145  }
146  }
147  }
148  }
149  free_cover(Tl);
150  free_cover(Tr);
151 
152  Tsave = sf_union(Tsave, sf_contain(T));
153  return Tsave;
154 }
int cdist01()
pset_family sf_new()
#define free_cover(r)
Definition: espresso.h:266
#define pcover
Definition: espresso.h:264
#define foreach_set(R, last, p)
Definition: espresso.h:135
ABC_NAMESPACE_IMPL_START pset_family sf_contain(INOUT pset_family A)
Definition: contain.c:37
pset_family sf_join()
static pcover and_with_cofactor()
void consensus()
pset_family sf_union(INOUT pset_family A, INOUT pset_family B)
Definition: contain.c:121
#define pcube
Definition: espresso.h:261
static ABC_NAMESPACE_IMPL_START bool primes_consensus_special_cases ( )
static
static bool primes_consensus_special_cases ( pcube T,
pcover Tnew 
)
static

Definition at line 46 of file primes.c.

49 {
50  register pcube *T1, p, ceil, cof=T[0];
51  pcube last;
52  pcover A;
53 
54  /* Check for no cubes in the cover */
55  if (T[2] == NULL) {
56  *Tnew = new_cover(0);
57  free_cubelist(T);
58  return TRUE;
59  }
60 
61  /* Check for only a single cube in the cover */
62  if (T[3] == NULL) {
63  *Tnew = sf_addset(new_cover(1), set_or(cof, cof, T[2]));
64  free_cubelist(T);
65  return TRUE;
66  }
67 
68  /* Check for a row of all 1's (implies function is a tautology) */
69  for(T1 = T+2; (p = *T1++) != NULL; ) {
70  if (full_row(p, cof)) {
71  *Tnew = sf_addset(new_cover(1), cube.fullset);
72  free_cubelist(T);
73  return TRUE;
74  }
75  }
76 
77  /* Check for a column of all 0's which can be factored out */
78  ceil = set_save(cof);
79  for(T1 = T+2; (p = *T1++) != NULL; ) {
80  INLINEset_or(ceil, ceil, p);
81  }
82  if (! setp_equal(ceil, cube.fullset)) {
83  p = new_cube();
84  (void) set_diff(p, cube.fullset, ceil);
85  (void) set_or(cof, cof, p);
86  free_cube(p);
87 
88  A = primes_consensus(T);
89  foreach_set(A, last, p) {
90  INLINEset_and(p, p, ceil);
91  }
92  *Tnew = A;
93  set_free(ceil);
94  return TRUE;
95  }
96  set_free(ceil);
97 
98  /* Collect column counts, determine unate variables, etc. */
99  massive_count(T);
100 
101  /* If single active variable not factored out above, then tautology ! */
102  if (cdata.vars_active == 1) {
103  *Tnew = sf_addset(new_cover(1), cube.fullset);
104  free_cubelist(T);
105  return TRUE;
106 
107  /* Check for unate cover */
108  } else if (cdata.vars_unate == cdata.vars_active) {
109  A = cubeunlist(T);
110  *Tnew = sf_contain(A);
111  free_cubelist(T);
112  return TRUE;
113 
114  /* Not much we can do about it */
115  } else {
116  return MAYBE;
117  }
118 }
pcover cubeunlist(pcube *A1)
Definition: cofactor.c:350
pset set_or()
#define set_free(r)
Definition: espresso.h:167
#define new_cube()
Definition: espresso.h:262
pcover primes_consensus(pcube *T)
Definition: primes.c:21
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define pcover
Definition: espresso.h:264
#define set_save(r)
Definition: espresso.h:166
#define INLINEset_and(r, a, b)
Definition: espresso.h:202
#define free_cube(r)
Definition: espresso.h:263
#define foreach_set(R, last, p)
Definition: espresso.h:135
#define INLINEset_or(r, a, b)
Definition: espresso.h:205
bool setp_equal()
ABC_NAMESPACE_IMPL_START pset_family sf_contain(INOUT pset_family A)
Definition: contain.c:37
pset_family sf_addset()
pset set_diff()
bool full_row()
#define new_cover(i)
Definition: espresso.h:265
#define TRUE
Definition: cudd.h:88
#define free_cubelist(T)
Definition: espresso.h:267
#define MAYBE
Definition: espresso.h:257
#define pcube
Definition: espresso.h:261
void massive_count(IN pcube *T)
Definition: cofactor.c:131