abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
exp.h File Reference

Go to the source code of this file.

Macros

#define EXP_CONST0   -1
 INCLUDES ///. More...
 
#define EXP_CONST1   -2
 

Functions

static Vec_Int_tExp_Const0 ()
 
static Vec_Int_tExp_Const1 ()
 
static int Exp_IsConst (Vec_Int_t *p)
 
static int Exp_IsConst0 (Vec_Int_t *p)
 
static int Exp_IsConst1 (Vec_Int_t *p)
 
static Vec_Int_tExp_Var (int iVar)
 
static int Exp_LitShift (int nVars, int Lit, int Shift)
 
static int Exp_IsLit (Vec_Int_t *p)
 
static int Exp_NodeNum (Vec_Int_t *p)
 
static Vec_Int_tExp_Not (Vec_Int_t *p)
 
static void Exp_PrintLit (int nVars, int Lit)
 
static void Exp_Print (int nVars, Vec_Int_t *p)
 
static Vec_Int_tExp_Reverse (Vec_Int_t *p)
 
static void Exp_PrintReverse (int nVars, Vec_Int_t *p)
 
static Vec_Int_tExp_And (int *pMan, int nVars, Vec_Int_t *p0, Vec_Int_t *p1, int fCompl0, int fCompl1)
 
static Vec_Int_tExp_Or (int *pMan, int nVars, Vec_Int_t *p0, Vec_Int_t *p1)
 
static Vec_Int_tExp_Xor (int *pMan, int nVars, Vec_Int_t *p0, Vec_Int_t *p1)
 
static word Exp_Truth6Lit (int nVars, int Lit, word *puFanins, word *puNodes)
 
static word Exp_Truth6 (int nVars, Vec_Int_t *p, word *puFanins)
 
static void Exp_TruthLit (int nVars, int Lit, word **puFanins, word **puNodes, word *pRes, int nWords)
 
static void Exp_Truth (int nVars, Vec_Int_t *p, word *pRes)
 

Macro Definition Documentation

#define EXP_CONST0   -1

INCLUDES ///.

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

FileName [exp.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Boolean expression.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
exp.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

]PARAMETERS ///BASIC TYPES ///MACRO DEFINITIONS ///

Definition at line 43 of file exp.h.

#define EXP_CONST1   -2

Definition at line 44 of file exp.h.

Function Documentation

static Vec_Int_t* Exp_And ( int *  pMan,
int  nVars,
Vec_Int_t p0,
Vec_Int_t p1,
int  fCompl0,
int  fCompl1 
)
inlinestatic

Definition at line 135 of file exp.h.

136 {
137  int i, Len0 = Vec_IntSize(p0), Len1 = Vec_IntSize(p1);
138  Vec_Int_t * r = Vec_IntAlloc( Len0 + Len1 + 1 );
139  assert( (Len0 & 1) && (Len1 & 1) );
140  Vec_IntPush( r, 2 * (nVars + Len0/2 + Len1/2) );
141  Vec_IntPush( r, Exp_LitShift( nVars, Vec_IntEntry(p0, 0) ^ fCompl0, Len1/2 ) );
142  Vec_IntPush( r, Vec_IntEntry(p1, 0) ^ fCompl1 );
143  for ( i = 1; i < Len0; i++ )
144  Vec_IntPush( r, Exp_LitShift( nVars, Vec_IntEntry(p0, i), Len1/2 ) );
145  for ( i = 1; i < Len1; i++ )
146  Vec_IntPush( r, Vec_IntEntry(p1, i) );
147  assert( Vec_IntSize(r) == Len0 + Len1 + 1 );
148  return r;
149 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Exp_LitShift(int nVars, int Lit, int Shift)
Definition: exp.h:79
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
static Vec_Int_t* Exp_Const0 ( )
inlinestatic

Definition at line 46 of file exp.h.

47 {
48  Vec_Int_t * vExp;
49  vExp = Vec_IntAlloc( 1 );
50  Vec_IntPush( vExp, EXP_CONST0 );
51  return vExp;
52 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define EXP_CONST0
INCLUDES ///.
Definition: exp.h:43
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static Vec_Int_t* Exp_Const1 ( )
inlinestatic

Definition at line 53 of file exp.h.

54 {
55  Vec_Int_t * vExp;
56  vExp = Vec_IntAlloc( 1 );
57  Vec_IntPush( vExp, EXP_CONST1 );
58  return vExp;
59 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define EXP_CONST1
Definition: exp.h:44
static int Exp_IsConst ( Vec_Int_t p)
inlinestatic

Definition at line 60 of file exp.h.

61 {
62  return Vec_IntEntry(p,0) == EXP_CONST0 || Vec_IntEntry(p,0) == EXP_CONST1;
63 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define EXP_CONST0
INCLUDES ///.
Definition: exp.h:43
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define EXP_CONST1
Definition: exp.h:44
static int Exp_IsConst0 ( Vec_Int_t p)
inlinestatic

Definition at line 64 of file exp.h.

65 {
66  return Vec_IntEntry(p,0) == EXP_CONST0;
67 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define EXP_CONST0
INCLUDES ///.
Definition: exp.h:43
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Exp_IsConst1 ( Vec_Int_t p)
inlinestatic

Definition at line 68 of file exp.h.

69 {
70  return Vec_IntEntry(p,0) == EXP_CONST1;
71 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define EXP_CONST1
Definition: exp.h:44
static int Exp_IsLit ( Vec_Int_t p)
inlinestatic

Definition at line 85 of file exp.h.

86 {
87  return Vec_IntSize(p) == 1 && !Exp_IsConst(p);
88 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Exp_IsConst(Vec_Int_t *p)
Definition: exp.h:60
static int Exp_LitShift ( int  nVars,
int  Lit,
int  Shift 
)
inlinestatic

Definition at line 79 of file exp.h.

80 {
81  if ( Lit < 2 * nVars )
82  return Lit;
83  return Lit + 2 * Shift;
84 }
static int Exp_NodeNum ( Vec_Int_t p)
inlinestatic

Definition at line 89 of file exp.h.

90 {
91  return Vec_IntSize(p)/2;
92 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Vec_Int_t* Exp_Not ( Vec_Int_t p)
inlinestatic

Definition at line 93 of file exp.h.

94 {
95  Vec_IntWriteEntry( p, 0, Vec_IntEntry(p,0) ^ 1 );
96  return p;
97 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static Vec_Int_t* Exp_Or ( int *  pMan,
int  nVars,
Vec_Int_t p0,
Vec_Int_t p1 
)
inlinestatic

Definition at line 150 of file exp.h.

151 {
152  return Exp_Not( Exp_And(pMan, nVars, p0, p1, 1, 1) );
153 }
static Vec_Int_t * Exp_And(int *pMan, int nVars, Vec_Int_t *p0, Vec_Int_t *p1, int fCompl0, int fCompl1)
Definition: exp.h:135
static Vec_Int_t * Exp_Not(Vec_Int_t *p)
Definition: exp.h:93
static void Exp_Print ( int  nVars,
Vec_Int_t p 
)
inlinestatic

Definition at line 109 of file exp.h.

110 {
111  int i;
112  for ( i = 0; i < Exp_NodeNum(p); i++ )
113  {
114  Abc_Print( 1, "%2d = ", nVars + i );
115  Exp_PrintLit( nVars, Vec_IntEntry(p, 2*i+0) );
116  Abc_Print( 1, " & " );
117  Exp_PrintLit( nVars, Vec_IntEntry(p, 2*i+1) );
118  Abc_Print( 1, "\n" );
119  }
120  Abc_Print( 1, " F = " );
121  Exp_PrintLit( nVars, Vec_IntEntryLast(p) );
122  Abc_Print( 1, "\n" );
123 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Exp_PrintLit(int nVars, int Lit)
Definition: exp.h:98
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int Exp_NodeNum(Vec_Int_t *p)
Definition: exp.h:89
static int Vec_IntEntryLast(Vec_Int_t *p)
Definition: bblif.c:319
static void Exp_PrintLit ( int  nVars,
int  Lit 
)
inlinestatic

Definition at line 98 of file exp.h.

99 {
100  if ( Lit == EXP_CONST0 )
101  Abc_Print( 1, "Const0" );
102  else if ( Lit == EXP_CONST1 )
103  Abc_Print( 1, "Const1" );
104  else if ( Lit < 2 * nVars )
105  Abc_Print( 1, "%s%c", (Lit&1) ? "!" : " ", 'a' + Lit/2 );
106  else
107  Abc_Print( 1, "%s%d", (Lit&1) ? "!" : " ", Lit/2 );
108 }
#define EXP_CONST0
INCLUDES ///.
Definition: exp.h:43
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
#define EXP_CONST1
Definition: exp.h:44
static void Exp_PrintReverse ( int  nVars,
Vec_Int_t p 
)
inlinestatic

Definition at line 129 of file exp.h.

130 {
131  Exp_Reverse( p );
132  Exp_Print( nVars, p );
133  Exp_Reverse( p );
134 }
static void Exp_Print(int nVars, Vec_Int_t *p)
Definition: exp.h:109
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Vec_Int_t * Exp_Reverse(Vec_Int_t *p)
Definition: exp.h:124
static Vec_Int_t* Exp_Reverse ( Vec_Int_t p)
inlinestatic

Definition at line 124 of file exp.h.

125 {
127  return p;
128 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntReverseOrder(Vec_Int_t *p)
Definition: vecInt.h:1042
static void Exp_Truth ( int  nVars,
Vec_Int_t p,
word pRes 
)
inlinestatic

Definition at line 221 of file exp.h.

222 {
223  static word Truth6[6] = {
224  ABC_CONST(0xAAAAAAAAAAAAAAAA),
225  ABC_CONST(0xCCCCCCCCCCCCCCCC),
226  ABC_CONST(0xF0F0F0F0F0F0F0F0),
227  ABC_CONST(0xFF00FF00FF00FF00),
228  ABC_CONST(0xFFFF0000FFFF0000),
229  ABC_CONST(0xFFFFFFFF00000000)
230  };
231  word ** puFanins, ** puNodes, * pTemp0, * pTemp1;
232  int i, w, nWords = (nVars <= 6 ? 1 : 1 << (nVars-6));
233  // create elementary variables
234  puFanins = ABC_ALLOC( word *, nVars );
235  for ( i = 0; i < nVars; i++ )
236  puFanins[i] = ABC_ALLOC( word, nWords );
237  // assign elementary truth tables
238  for ( i = 0; i < nVars; i++ )
239  if ( i < 6 )
240  for ( w = 0; w < nWords; w++ )
241  puFanins[i][w] = Truth6[i];
242  else
243  for ( w = 0; w < nWords; w++ )
244  puFanins[i][w] = (w & (1 << (i-6))) ? ~(word)0 : 0;
245  // create intermediate nodes
246  puNodes = ABC_ALLOC( word *, Exp_NodeNum(p) );
247  for ( i = 0; i < Exp_NodeNum(p); i++ )
248  puNodes[i] = ABC_ALLOC( word, nWords );
249  // evaluate the expression
250  pTemp0 = ABC_ALLOC( word, nWords );
251  pTemp1 = ABC_ALLOC( word, nWords );
252  for ( i = 0; i < Exp_NodeNum(p); i++ )
253  {
254  Exp_TruthLit( nVars, Vec_IntEntry(p, 2*i+0), puFanins, puNodes, pTemp0, nWords );
255  Exp_TruthLit( nVars, Vec_IntEntry(p, 2*i+1), puFanins, puNodes, pTemp1, nWords );
256  for ( w = 0; w < nWords; w++ )
257  puNodes[i][w] = pTemp0[w] & pTemp1[w];
258  }
259  ABC_FREE( pTemp0 );
260  ABC_FREE( pTemp1 );
261  // copy the final result
262  Exp_TruthLit( nVars, Vec_IntEntryLast(p), puFanins, puNodes, pRes, nWords );
263  // cleanup
264  for ( i = 0; i < nVars; i++ )
265  ABC_FREE( puFanins[i] );
266  ABC_FREE( puFanins );
267  for ( i = 0; i < Exp_NodeNum(p); i++ )
268  ABC_FREE( puNodes[i] );
269  ABC_FREE( puNodes );
270 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void Exp_TruthLit(int nVars, int Lit, word **puFanins, word **puNodes, word *pRes, int nWords)
Definition: exp.h:205
int nWords
Definition: abcNpn.c:127
static word Truth6[6]
Definition: ifDec07.c:52
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static int Exp_NodeNum(Vec_Int_t *p)
Definition: exp.h:89
static int Vec_IntEntryLast(Vec_Int_t *p)
Definition: bblif.c:319
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
#define ABC_FREE(obj)
Definition: abc_global.h:232
static word Exp_Truth6 ( int  nVars,
Vec_Int_t p,
word puFanins 
)
inlinestatic

Definition at line 183 of file exp.h.

184 {
185  static word Truth6[6] = {
186  ABC_CONST(0xAAAAAAAAAAAAAAAA),
187  ABC_CONST(0xCCCCCCCCCCCCCCCC),
188  ABC_CONST(0xF0F0F0F0F0F0F0F0),
189  ABC_CONST(0xFF00FF00FF00FF00),
190  ABC_CONST(0xFFFF0000FFFF0000),
191  ABC_CONST(0xFFFFFFFF00000000)
192  };
193  word * puNodes, Res;
194  int i;
195  if ( puFanins == NULL )
196  puFanins = (word *)Truth6;
197  puNodes = ABC_CALLOC( word, Exp_NodeNum(p) );
198  for ( i = 0; i < Exp_NodeNum(p); i++ )
199  puNodes[i] = Exp_Truth6Lit( nVars, Vec_IntEntry(p, 2*i+0), puFanins, puNodes ) &
200  Exp_Truth6Lit( nVars, Vec_IntEntry(p, 2*i+1), puFanins, puNodes );
201  Res = Exp_Truth6Lit( nVars, Vec_IntEntryLast(p), puFanins, puNodes );
202  ABC_FREE( puNodes );
203  return Res;
204 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static word Truth6[6]
Definition: ifDec07.c:52
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static word Exp_Truth6Lit(int nVars, int Lit, word *puFanins, word *puNodes)
Definition: exp.h:173
static int Exp_NodeNum(Vec_Int_t *p)
Definition: exp.h:89
static int Vec_IntEntryLast(Vec_Int_t *p)
Definition: bblif.c:319
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static word Exp_Truth6Lit ( int  nVars,
int  Lit,
word puFanins,
word puNodes 
)
inlinestatic

Definition at line 173 of file exp.h.

174 {
175  if ( Lit == EXP_CONST0 )
176  return 0;
177  if ( Lit == EXP_CONST1 )
178  return ~(word)0;
179  if ( Lit < 2 * nVars )
180  return (Lit&1) ? ~puFanins[Lit/2] : puFanins[Lit/2];
181  return (Lit&1) ? ~puNodes[Lit/2-nVars] : puNodes[Lit/2-nVars];
182 }
#define EXP_CONST0
INCLUDES ///.
Definition: exp.h:43
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define EXP_CONST1
Definition: exp.h:44
static void Exp_TruthLit ( int  nVars,
int  Lit,
word **  puFanins,
word **  puNodes,
word pRes,
int  nWords 
)
inlinestatic

Definition at line 205 of file exp.h.

206 {
207  int w;
208  if ( Lit == EXP_CONST0 )
209  for ( w = 0; w < nWords; w++ )
210  pRes[w] = 0;
211  else if ( Lit == EXP_CONST1 )
212  for ( w = 0; w < nWords; w++ )
213  pRes[w] = ~(word)0;
214  else if ( Lit < 2 * nVars )
215  for ( w = 0; w < nWords; w++ )
216  pRes[w] = (Lit&1) ? ~puFanins[Lit/2][w] : puFanins[Lit/2][w];
217  else
218  for ( w = 0; w < nWords; w++ )
219  pRes[w] = (Lit&1) ? ~puNodes[Lit/2-nVars][w] : puNodes[Lit/2-nVars][w];
220 }
#define EXP_CONST0
INCLUDES ///.
Definition: exp.h:43
int nWords
Definition: abcNpn.c:127
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define EXP_CONST1
Definition: exp.h:44
static Vec_Int_t* Exp_Var ( int  iVar)
inlinestatic

Definition at line 72 of file exp.h.

73 {
74  Vec_Int_t * vExp;
75  vExp = Vec_IntAlloc( 1 );
76  Vec_IntPush( vExp, 2 * iVar );
77  return vExp;
78 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static Vec_Int_t* Exp_Xor ( int *  pMan,
int  nVars,
Vec_Int_t p0,
Vec_Int_t p1 
)
inlinestatic

Definition at line 154 of file exp.h.

155 {
156  int i, Len0 = Vec_IntSize(p0), Len1 = Vec_IntSize(p1);
157  Vec_Int_t * r = Vec_IntAlloc( Len0 + Len1 + 5 );
158  assert( (Len0 & 1) && (Len1 & 1) );
159  Vec_IntPush( r, 2 * (nVars + Len0/2 + Len1/2 + 2) );
160  Vec_IntPush( r, 2 * (nVars + Len0/2 + Len1/2 + 1) + 1 );
161  Vec_IntPush( r, 2 * (nVars + Len0/2 + Len1/2 + 0) + 1 );
162  Vec_IntPush( r, Exp_LitShift( nVars, Vec_IntEntry(p0, 0) ^ 1, Len1/2 ) );
163  Vec_IntPush( r, Vec_IntEntry(p1, 0) );
164  Vec_IntPush( r, Exp_LitShift( nVars, Vec_IntEntry(p0, 0), Len1/2 ) );
165  Vec_IntPush( r, Vec_IntEntry(p1, 0) ^ 1 );
166  for ( i = 1; i < Len0; i++ )
167  Vec_IntPush( r, Exp_LitShift( nVars, Vec_IntEntry(p0, i), Len1/2 ) );
168  for ( i = 1; i < Len1; i++ )
169  Vec_IntPush( r, Vec_IntEntry(p1, i) );
170  assert( Vec_IntSize(r) == Len0 + Len1 + 5 );
171  return Exp_Not( r );
172 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Exp_LitShift(int nVars, int Lit, int Shift)
Definition: exp.h:79
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
static Vec_Int_t * Exp_Not(Vec_Int_t *p)
Definition: exp.h:93