abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kit.h
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [kit.h]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Computation kit.]
8 
9  Synopsis [External declarations.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - Dec 6, 2006.]
16 
17  Revision [$Id: kit.h,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #ifndef ABC__aig__kit__kit_h
22 #define ABC__aig__kit__kit_h
23 
24 
25 ////////////////////////////////////////////////////////////////////////
26 /// INCLUDES ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <assert.h>
33 
34 #include "misc/vec/vec.h"
35 #include "misc/extra/extraBdd.h"
36 #include "cloud.h"
37 
38 ////////////////////////////////////////////////////////////////////////
39 /// PARAMETERS ///
40 ////////////////////////////////////////////////////////////////////////
41 
42 
43 
45 
46 
47 ////////////////////////////////////////////////////////////////////////
48 /// BASIC TYPES ///
49 ////////////////////////////////////////////////////////////////////////
50 
51 typedef struct Kit_Sop_t_ Kit_Sop_t;
52 struct Kit_Sop_t_
53 {
54  int nLits; // the number of literals
55  int nCubes; // the number of cubes
56  unsigned * pCubes; // the storage for cubes
57 };
58 
59 typedef struct Kit_Edge_t_ Kit_Edge_t;
61 {
62  unsigned fCompl : 1; // the complemented bit
63  unsigned Node : 30; // the decomposition node pointed by the edge
64 };
65 
66 typedef struct Kit_Node_t_ Kit_Node_t;
68 {
69  Kit_Edge_t eEdge0; // the left child of the node
70  Kit_Edge_t eEdge1; // the right child of the node
71  // other info
72  union { int iFunc; // the function of the node (BDD or AIG)
73  void * pFunc; }; // the function of the node (BDD or AIG)
74  unsigned Level : 14; // the level of this node in the global AIG
75  // printing info
76  unsigned fNodeOr : 1; // marks the original OR node
77  unsigned fCompl0 : 1; // marks the original complemented edge
78  unsigned fCompl1 : 1; // marks the original complemented edge
79  // latch info
80  unsigned nLat0 : 5; // the number of latches on the first edge
81  unsigned nLat1 : 5; // the number of latches on the second edge
82  unsigned nLat2 : 5; // the number of latches on the output edge
83 };
84 
85 typedef struct Kit_Graph_t_ Kit_Graph_t;
87 {
88  int fConst; // marks the constant 1 graph
89  int nLeaves; // the number of leaves
90  int nSize; // the number of nodes (including the leaves)
91  int nCap; // the number of allocated nodes
92  Kit_Node_t * pNodes; // the array of leaves and internal nodes
93  Kit_Edge_t eRoot; // the pointer to the topmost node
94 };
95 
96 
97 // DSD node types
98 typedef enum {
99  KIT_DSD_NONE = 0, // 0: unknown
100  KIT_DSD_CONST1, // 1: constant 1
101  KIT_DSD_VAR, // 2: elementary variable
102  KIT_DSD_AND, // 3: multi-input AND
103  KIT_DSD_XOR, // 4: multi-input XOR
104  KIT_DSD_PRIME // 5: arbitrary function of 3+ variables
105 } Kit_Dsd_t;
106 
107 // DSD node
110 {
111  unsigned Id : 6; // the number of this node
112  unsigned Type : 3; // none, const, var, AND, XOR, MUX, PRIME
113  unsigned fMark : 1; // finished checking output
114  unsigned Offset : 8; // offset to the truth table
115  unsigned nRefs : 8; // offset to the truth table
116  unsigned nFans : 6; // the number of fanins of this node
117  unsigned short pFans[0]; // the fanin literals
118 };
119 
120 // DSD network
123 {
124  unsigned short nVars; // at most 16 (perhaps 18?)
125  unsigned short nNodesAlloc; // the number of allocated nodes (at most nVars)
126  unsigned short nNodes; // the number of nodes
127  unsigned short Root; // the root of the tree
128  unsigned * pMem; // memory for the truth tables (memory manager?)
129  unsigned * pSupps; // supports of the nodes
130  Kit_DsdObj_t** pNodes; // the nodes
131 };
132 
133 // DSD manager
136 {
137  int nVars; // the maximum number of variables
138  int nWords; // the number of words in TTs
139  Vec_Ptr_t * vTtElems; // elementary truth tables
140  Vec_Ptr_t * vTtNodes; // the node truth tables
141  // BDD representation
142  CloudManager * dd; // BDD package
143  Vec_Ptr_t * vTtBdds; // the node truth tables
144  Vec_Int_t * vNodes; // temporary array for BDD nodes
145 };
146 
147 static inline unsigned Kit_DsdObjOffset( int nFans ) { return (nFans >> 1) + ((nFans & 1) > 0); }
148 static inline unsigned * Kit_DsdObjTruth( Kit_DsdObj_t * pObj ) { return pObj->Type == KIT_DSD_PRIME ? (unsigned *)pObj->pFans + pObj->Offset: NULL; }
149 static inline int Kit_DsdNtkObjNum( Kit_DsdNtk_t * pNtk ){ return pNtk->nVars + pNtk->nNodes; }
150 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]; }
151 static inline Kit_DsdObj_t * Kit_DsdNtkRoot( Kit_DsdNtk_t * pNtk ) { return Kit_DsdNtkObj( pNtk, Abc_Lit2Var(pNtk->Root) ); }
152 static inline int Kit_DsdLitIsLeaf( Kit_DsdNtk_t * pNtk, int Lit ) { int Id = Abc_Lit2Var(Lit); assert( Id >= 0 && Id < pNtk->nVars + pNtk->nNodes ); return Id < pNtk->nVars; }
153 static inline unsigned Kit_DsdLitSupport( Kit_DsdNtk_t * pNtk, int Lit ) { int Id = Abc_Lit2Var(Lit); assert( Id >= 0 && Id < pNtk->nVars + pNtk->nNodes ); return pNtk->pSupps? (Id < pNtk->nVars? (1 << Id) : pNtk->pSupps[Id - pNtk->nVars]) : 0; }
154 
155 #define Kit_DsdNtkForEachObj( pNtk, pObj, i ) \
156  for ( i = 0; (i < (pNtk)->nNodes) && ((pObj) = (pNtk)->pNodes[i]); i++ )
157 #define Kit_DsdObjForEachFanin( pNtk, pObj, iLit, i ) \
158  for ( i = 0; (i < (int)(pObj)->nFans) && ((iLit) = (pObj)->pFans[i], 1); i++ )
159 #define Kit_DsdObjForEachFaninReverse( pNtk, pObj, iLit, i ) \
160  for ( i = (int)(pObj)->nFans - 1; (i >= 0) && ((iLit) = (pObj)->pFans[i], 1); i-- )
161 
162 #define Kit_PlaForEachCube( pSop, nFanins, pCube ) \
163  for ( pCube = (pSop); *pCube; pCube += (nFanins) + 3 )
164 #define Kit_PlaCubeForEachVar( pCube, Value, i ) \
165  for ( i = 0; (pCube[i] != ' ') && (Value = pCube[i]); i++ )
166 
167 ////////////////////////////////////////////////////////////////////////
168 /// MACRO DEFINITIONS ///
169 ////////////////////////////////////////////////////////////////////////
170 
171 #define KIT_MIN(a,b) (((a) < (b))? (a) : (b))
172 #define KIT_MAX(a,b) (((a) > (b))? (a) : (b))
173 #define KIT_INFINITY (100000000)
174 
175 static inline int Kit_CubeHasLit( unsigned uCube, int i ) { return(uCube & (unsigned)(1<<i)) > 0; }
176 static inline unsigned Kit_CubeSetLit( unsigned uCube, int i ) { return uCube | (unsigned)(1<<i); }
177 static inline unsigned Kit_CubeXorLit( unsigned uCube, int i ) { return uCube ^ (unsigned)(1<<i); }
178 static inline unsigned Kit_CubeRemLit( unsigned uCube, int i ) { return uCube & ~(unsigned)(1<<i); }
179 
180 static inline int Kit_CubeContains( unsigned uLarge, unsigned uSmall ) { return (uLarge & uSmall) == uSmall; }
181 static inline unsigned Kit_CubeSharp( unsigned uCube, unsigned uMask ) { return uCube & ~uMask; }
182 static inline unsigned Kit_CubeMask( int nVar ) { return (~(unsigned)0) >> (32-nVar); }
183 
184 static inline int Kit_CubeIsMarked( unsigned uCube ) { return Kit_CubeHasLit( uCube, 31 ); }
185 static inline unsigned Kit_CubeMark( unsigned uCube ) { return Kit_CubeSetLit( uCube, 31 ); }
186 static inline unsigned Kit_CubeUnmark( unsigned uCube ) { return Kit_CubeRemLit( uCube, 31 ); }
187 
188 static inline int Kit_SopCubeNum( Kit_Sop_t * cSop ) { return cSop->nCubes; }
189 static inline unsigned Kit_SopCube( Kit_Sop_t * cSop, int i ) { return cSop->pCubes[i]; }
190 static inline void Kit_SopShrink( Kit_Sop_t * cSop, int nCubesNew ) { cSop->nCubes = nCubesNew; }
191 static inline void Kit_SopPushCube( Kit_Sop_t * cSop, unsigned uCube ) { cSop->pCubes[cSop->nCubes++] = uCube; }
192 static inline void Kit_SopWriteCube( Kit_Sop_t * cSop, unsigned uCube, int i ) { cSop->pCubes[i] = uCube; }
193 
194 static inline Kit_Edge_t Kit_EdgeCreate( int Node, int fCompl ) { Kit_Edge_t eEdge = { fCompl, Node }; return eEdge; }
195 static inline unsigned Kit_EdgeToInt( Kit_Edge_t eEdge ) { return (eEdge.Node << 1) | eEdge.fCompl; }
196 static inline Kit_Edge_t Kit_IntToEdge( unsigned Edge ) { return Kit_EdgeCreate( Edge >> 1, Edge & 1 ); }
197 //static inline unsigned Kit_EdgeToInt_( Kit_Edge_t eEdge ) { return *(unsigned *)&eEdge; }
198 //static inline Kit_Edge_t Kit_IntToEdge_( unsigned Edge ) { return *(Kit_Edge_t *)&Edge; }
199 static inline unsigned Kit_EdgeToInt_( Kit_Edge_t m ) { union { Kit_Edge_t x; unsigned y; } v; v.x = m; return v.y; }
200 static inline Kit_Edge_t Kit_IntToEdge_( unsigned m ) { union { Kit_Edge_t x; unsigned y; } v; v.y = m; return v.x; }
201 
202 static inline int Kit_GraphIsConst( Kit_Graph_t * pGraph ) { return pGraph->fConst; }
203 static inline int Kit_GraphIsConst0( Kit_Graph_t * pGraph ) { return pGraph->fConst && pGraph->eRoot.fCompl; }
204 static inline int Kit_GraphIsConst1( Kit_Graph_t * pGraph ) { return pGraph->fConst && !pGraph->eRoot.fCompl; }
205 static inline int Kit_GraphIsComplement( Kit_Graph_t * pGraph ) { return pGraph->eRoot.fCompl; }
206 static inline int Kit_GraphIsVar( Kit_Graph_t * pGraph ) { return pGraph->eRoot.Node < (unsigned)pGraph->nLeaves; }
207 static inline void Kit_GraphComplement( Kit_Graph_t * pGraph ) { pGraph->eRoot.fCompl ^= 1; }
208 static inline void Kit_GraphSetRoot( Kit_Graph_t * pGraph, Kit_Edge_t eRoot ) { pGraph->eRoot = eRoot; }
209 static inline int Kit_GraphLeaveNum( Kit_Graph_t * pGraph ) { return pGraph->nLeaves; }
210 static inline int Kit_GraphNodeNum( Kit_Graph_t * pGraph ) { return pGraph->nSize - pGraph->nLeaves; }
211 static inline Kit_Node_t * Kit_GraphNode( Kit_Graph_t * pGraph, int i ) { return pGraph->pNodes + i; }
212 static inline Kit_Node_t * Kit_GraphNodeLast( Kit_Graph_t * pGraph ) { return pGraph->pNodes + pGraph->nSize - 1; }
213 static inline int Kit_GraphNodeInt( Kit_Graph_t * pGraph, Kit_Node_t * pNode ) { return pNode - pGraph->pNodes; }
214 static inline int Kit_GraphNodeIsVar( Kit_Graph_t * pGraph, Kit_Node_t * pNode ) { return Kit_GraphNodeInt(pGraph,pNode) < pGraph->nLeaves; }
215 static inline Kit_Node_t * Kit_GraphVar( Kit_Graph_t * pGraph ) { assert( Kit_GraphIsVar( pGraph ) ); return Kit_GraphNode( pGraph, pGraph->eRoot.Node ); }
216 static inline int Kit_GraphVarInt( Kit_Graph_t * pGraph ) { assert( Kit_GraphIsVar( pGraph ) ); return Kit_GraphNodeInt( pGraph, Kit_GraphVar(pGraph) ); }
217 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); }
218 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); }
219 static inline int Kit_GraphRootLevel( Kit_Graph_t * pGraph ) { return Kit_GraphNode(pGraph, pGraph->eRoot.Node)->Level; }
220 
221 static inline int Kit_SuppIsMinBase( int Supp ) { return (Supp & (Supp+1)) == 0; }
222 
223 static inline int Kit_BitWordNum( int nBits ) { return nBits/(8*sizeof(unsigned)) + ((nBits%(8*sizeof(unsigned))) > 0); }
224 static inline int Kit_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
225 static inline unsigned Kit_BitMask( int nBits ) { assert( nBits <= 32 ); return ~((~(unsigned)0) << nBits); }
226 
227 static inline void Kit_TruthSetBit( unsigned * p, int Bit ) { p[Bit>>5] |= (1<<(Bit & 31)); }
228 static inline void Kit_TruthXorBit( unsigned * p, int Bit ) { p[Bit>>5] ^= (1<<(Bit & 31)); }
229 static inline int Kit_TruthHasBit( unsigned * p, int Bit ) { return (p[Bit>>5] & (1<<(Bit & 31))) > 0; }
230 
231 static inline int Kit_WordFindFirstBit( unsigned uWord )
232 {
233  int i;
234  for ( i = 0; i < 32; i++ )
235  if ( uWord & (1 << i) )
236  return i;
237  return -1;
238 }
239 static inline int Kit_WordHasOneBit( unsigned uWord )
240 {
241  return (uWord & (uWord - 1)) == 0;
242 }
243 static inline int Kit_WordCountOnes( unsigned uWord )
244 {
245  uWord = (uWord & 0x55555555) + ((uWord>>1) & 0x55555555);
246  uWord = (uWord & 0x33333333) + ((uWord>>2) & 0x33333333);
247  uWord = (uWord & 0x0F0F0F0F) + ((uWord>>4) & 0x0F0F0F0F);
248  uWord = (uWord & 0x00FF00FF) + ((uWord>>8) & 0x00FF00FF);
249  return (uWord & 0x0000FFFF) + (uWord>>16);
250 }
251 static inline int Kit_TruthCountOnes( unsigned * pIn, int nVars )
252 {
253  int w, Counter = 0;
254  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
255  Counter += Kit_WordCountOnes(pIn[w]);
256  return Counter;
257 }
258 static inline int Kit_TruthFindFirstBit( unsigned * pIn, int nVars )
259 {
260  int w;
261  for ( w = 0; w < Kit_TruthWordNum(nVars); w++ )
262  if ( pIn[w] )
263  return 32*w + Kit_WordFindFirstBit(pIn[w]);
264  return -1;
265 }
266 static inline int Kit_TruthFindFirstZero( unsigned * pIn, int nVars )
267 {
268  int w;
269  for ( w = 0; w < Kit_TruthWordNum(nVars); w++ )
270  if ( ~pIn[w] )
271  return 32*w + Kit_WordFindFirstBit(~pIn[w]);
272  return -1;
273 }
274 static inline int Kit_TruthIsEqual( unsigned * pIn0, unsigned * pIn1, int nVars )
275 {
276  int w;
277  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
278  if ( pIn0[w] != pIn1[w] )
279  return 0;
280  return 1;
281 }
282 static inline int Kit_TruthIsEqualWithCare( unsigned * pIn0, unsigned * pIn1, unsigned * pCare, int nVars )
283 {
284  int w;
285  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
286  if ( (pIn0[w] & pCare[w]) != (pIn1[w] & pCare[w]) )
287  return 0;
288  return 1;
289 }
290 static inline int Kit_TruthIsOpposite( unsigned * pIn0, unsigned * pIn1, int nVars )
291 {
292  int w;
293  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
294  if ( pIn0[w] != ~pIn1[w] )
295  return 0;
296  return 1;
297 }
298 static inline int Kit_TruthIsEqualWithPhase( unsigned * pIn0, unsigned * pIn1, int nVars )
299 {
300  int w;
301  if ( (pIn0[0] & 1) == (pIn1[0] & 1) )
302  {
303  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
304  if ( pIn0[w] != pIn1[w] )
305  return 0;
306  }
307  else
308  {
309  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
310  if ( pIn0[w] != ~pIn1[w] )
311  return 0;
312  }
313  return 1;
314 }
315 static inline int Kit_TruthIsConst0( unsigned * pIn, int nVars )
316 {
317  int w;
318  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
319  if ( pIn[w] )
320  return 0;
321  return 1;
322 }
323 static inline int Kit_TruthIsConst1( unsigned * pIn, int nVars )
324 {
325  int w;
326  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
327  if ( pIn[w] != ~(unsigned)0 )
328  return 0;
329  return 1;
330 }
331 static inline int Kit_TruthIsImply( unsigned * pIn1, unsigned * pIn2, int nVars )
332 {
333  int w;
334  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
335  if ( pIn1[w] & ~pIn2[w] )
336  return 0;
337  return 1;
338 }
339 static inline int Kit_TruthIsDisjoint( unsigned * pIn1, unsigned * pIn2, int nVars )
340 {
341  int w;
342  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
343  if ( pIn1[w] & pIn2[w] )
344  return 0;
345  return 1;
346 }
347 static inline int Kit_TruthIsDisjoint3( unsigned * pIn1, unsigned * pIn2, unsigned * pIn3, int nVars )
348 {
349  int w;
350  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
351  if ( pIn1[w] & pIn2[w] & pIn3[w] )
352  return 0;
353  return 1;
354 }
355 static inline void Kit_TruthCopy( unsigned * pOut, unsigned * pIn, int nVars )
356 {
357  int w;
358  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
359  pOut[w] = pIn[w];
360 }
361 static inline void Kit_TruthClear( unsigned * pOut, int nVars )
362 {
363  int w;
364  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
365  pOut[w] = 0;
366 }
367 static inline void Kit_TruthFill( unsigned * pOut, int nVars )
368 {
369  int w;
370  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
371  pOut[w] = ~(unsigned)0;
372 }
373 static inline void Kit_TruthNot( unsigned * pOut, unsigned * pIn, int nVars )
374 {
375  int w;
376  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
377  pOut[w] = ~pIn[w];
378 }
379 static inline void Kit_TruthAnd( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars )
380 {
381  int w;
382  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
383  pOut[w] = pIn0[w] & pIn1[w];
384 }
385 static inline void Kit_TruthOr( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars )
386 {
387  int w;
388  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
389  pOut[w] = pIn0[w] | pIn1[w];
390 }
391 static inline void Kit_TruthXor( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars )
392 {
393  int w;
394  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
395  pOut[w] = pIn0[w] ^ pIn1[w];
396 }
397 static inline void Kit_TruthSharp( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars )
398 {
399  int w;
400  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
401  pOut[w] = pIn0[w] & ~pIn1[w];
402 }
403 static inline void Kit_TruthNand( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars )
404 {
405  int w;
406  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
407  pOut[w] = ~(pIn0[w] & pIn1[w]);
408 }
409 static inline void Kit_TruthAndPhase( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars, int fCompl0, int fCompl1 )
410 {
411  int w;
412  if ( fCompl0 && fCompl1 )
413  {
414  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
415  pOut[w] = ~(pIn0[w] | pIn1[w]);
416  }
417  else if ( fCompl0 && !fCompl1 )
418  {
419  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
420  pOut[w] = ~pIn0[w] & pIn1[w];
421  }
422  else if ( !fCompl0 && fCompl1 )
423  {
424  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
425  pOut[w] = pIn0[w] & ~pIn1[w];
426  }
427  else // if ( !fCompl0 && !fCompl1 )
428  {
429  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
430  pOut[w] = pIn0[w] & pIn1[w];
431  }
432 }
433 static inline void Kit_TruthOrPhase( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars, int fCompl0, int fCompl1 )
434 {
435  int w;
436  if ( fCompl0 && fCompl1 )
437  {
438  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
439  pOut[w] = ~(pIn0[w] & pIn1[w]);
440  }
441  else if ( fCompl0 && !fCompl1 )
442  {
443  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
444  pOut[w] = ~pIn0[w] | pIn1[w];
445  }
446  else if ( !fCompl0 && fCompl1 )
447  {
448  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
449  pOut[w] = pIn0[w] | ~pIn1[w];
450  }
451  else // if ( !fCompl0 && !fCompl1 )
452  {
453  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
454  pOut[w] = pIn0[w] | pIn1[w];
455  }
456 }
457 static inline void Kit_TruthMux( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, unsigned * pCtrl, int nVars )
458 {
459  int w;
460  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
461  pOut[w] = (pIn0[w] & ~pCtrl[w]) | (pIn1[w] & pCtrl[w]);
462 }
463 static inline void Kit_TruthMuxPhase( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, unsigned * pCtrl, int nVars, int fComp0 )
464 {
465  int w;
466  if ( fComp0 )
467  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
468  pOut[w] = (~pIn0[w] & ~pCtrl[w]) | (pIn1[w] & pCtrl[w]);
469  else
470  for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
471  pOut[w] = (pIn0[w] & ~pCtrl[w]) | (pIn1[w] & pCtrl[w]);
472 }
473 static inline void Kit_TruthIthVar( unsigned * pTruth, int nVars, int iVar )
474 {
475  unsigned Masks[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
476  int k, nWords = (nVars <= 5 ? 1 : (1 << (nVars - 5)));
477  if ( iVar < 5 )
478  {
479  for ( k = 0; k < nWords; k++ )
480  pTruth[k] = Masks[iVar];
481  }
482  else
483  {
484  for ( k = 0; k < nWords; k++ )
485  if ( k & (1 << (iVar-5)) )
486  pTruth[k] = ~(unsigned)0;
487  else
488  pTruth[k] = 0;
489  }
490 }
491 
492 
493 ////////////////////////////////////////////////////////////////////////
494 /// ITERATORS ///
495 ////////////////////////////////////////////////////////////////////////
496 
497 #define Kit_SopForEachCube( cSop, uCube, i ) \
498  for ( i = 0; (i < Kit_SopCubeNum(cSop)) && ((uCube) = Kit_SopCube(cSop, i)); i++ )
499 #define Kit_CubeForEachLiteral( uCube, Lit, nLits, i ) \
500  for ( i = 0; (i < (nLits)) && ((Lit) = Kit_CubeHasLit(uCube, i)); i++ )
501 
502 #define Kit_GraphForEachLeaf( pGraph, pLeaf, i ) \
503  for ( i = 0; (i < (pGraph)->nLeaves) && (((pLeaf) = Kit_GraphNode(pGraph, i)), 1); i++ )
504 #define Kit_GraphForEachNode( pGraph, pAnd, i ) \
505  for ( i = (pGraph)->nLeaves; (i < (pGraph)->nSize) && (((pAnd) = Kit_GraphNode(pGraph, i)), 1); i++ )
506 
507 ////////////////////////////////////////////////////////////////////////
508 /// FUNCTION DECLARATIONS ///
509 ////////////////////////////////////////////////////////////////////////
510 
511 /*=== kitBdd.c ==========================================================*/
512 extern DdNode * Kit_SopToBdd( DdManager * dd, Kit_Sop_t * cSop, int nVars );
513 extern DdNode * Kit_GraphToBdd( DdManager * dd, Kit_Graph_t * pGraph );
514 extern DdNode * Kit_TruthToBdd( DdManager * dd, unsigned * pTruth, int nVars, int fMSBonTop );
515 /*=== kitCloud.c ==========================================================*/
516 extern CloudNode * Kit_TruthToCloud( CloudManager * dd, unsigned * pTruth, int nVars );
517 extern unsigned * Kit_CloudToTruth( Vec_Int_t * vNodes, int nVars, Vec_Ptr_t * vStore, int fInv );
518 extern int Kit_CreateCloud( CloudManager * dd, CloudNode * pFunc, Vec_Int_t * vNodes );
519 extern int Kit_CreateCloudFromTruth( CloudManager * dd, unsigned * pTruth, int nVars, Vec_Int_t * vNodes );
520 extern unsigned * Kit_TruthCompose( CloudManager * dd, unsigned * pTruth, int nVars, unsigned ** pInputs, int nVarsAll, Vec_Ptr_t * vStore, Vec_Int_t * vNodes );
521 extern void Kit_TruthCofSupports( Vec_Int_t * vBddDir, Vec_Int_t * vBddInv, int nVars, Vec_Int_t * vMemory, unsigned * puSupps );
522 /*=== kitDsd.c ==========================================================*/
523 extern Kit_DsdMan_t * Kit_DsdManAlloc( int nVars, int nNodes );
524 extern void Kit_DsdManFree( Kit_DsdMan_t * p );
525 extern Kit_DsdNtk_t * Kit_DsdDeriveNtk( unsigned * pTruth, int nVars, int nLutSize );
526 extern unsigned * Kit_DsdTruthCompute( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk );
527 extern void Kit_DsdTruth( Kit_DsdNtk_t * pNtk, unsigned * pTruthRes );
528 extern void Kit_DsdTruthPartial( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, unsigned * pTruthRes, unsigned uSupp );
529 extern void Kit_DsdTruthPartialTwo( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, unsigned uSupp, int iVar, unsigned * pTruthCo, unsigned * pTruthDec );
530 extern void Kit_DsdPrint( FILE * pFile, Kit_DsdNtk_t * pNtk );
531 extern void Kit_DsdPrintExpanded( Kit_DsdNtk_t * pNtk );
532 extern void Kit_DsdPrintFromTruth( unsigned * pTruth, int nVars );
533 extern void Kit_DsdPrintFromTruth2( FILE * pFile, unsigned * pTruth, int nVars );
534 extern void Kit_DsdWriteFromTruth( char * pBuffer, unsigned * pTruth, int nVars );
535 extern Kit_DsdNtk_t * Kit_DsdDecompose( unsigned * pTruth, int nVars );
536 extern Kit_DsdNtk_t * Kit_DsdDecomposeExpand( unsigned * pTruth, int nVars );
537 extern Kit_DsdNtk_t * Kit_DsdDecomposeMux( unsigned * pTruth, int nVars, int nDecMux );
538 extern void Kit_DsdVerify( Kit_DsdNtk_t * pNtk, unsigned * pTruth, int nVars );
539 extern void Kit_DsdNtkFree( Kit_DsdNtk_t * pNtk );
540 extern int Kit_DsdNonDsdSizeMax( Kit_DsdNtk_t * pNtk );
542 extern unsigned Kit_DsdNonDsdSupports( Kit_DsdNtk_t * pNtk );
543 extern int Kit_DsdCountAigNodes( Kit_DsdNtk_t * pNtk );
544 extern unsigned Kit_DsdGetSupports( Kit_DsdNtk_t * p );
546 extern Kit_DsdNtk_t * Kit_DsdShrink( Kit_DsdNtk_t * p, int pPrios[] );
547 extern void Kit_DsdRotate( Kit_DsdNtk_t * p, int pFreqs[] );
548 extern int Kit_DsdCofactoring( unsigned * pTruth, int nVars, int * pCofVars, int nLimit, int fVerbose );
549 /*=== kitFactor.c ==========================================================*/
550 extern Kit_Graph_t * Kit_SopFactor( Vec_Int_t * vCover, int fCompl, int nVars, Vec_Int_t * vMemory );
551 /*=== kitGraph.c ==========================================================*/
552 extern Kit_Graph_t * Kit_GraphCreate( int nLeaves );
555 extern Kit_Graph_t * Kit_GraphCreateLeaf( int iLeaf, int nLeaves, int fCompl );
556 extern void Kit_GraphFree( Kit_Graph_t * pGraph );
557 extern Kit_Node_t * Kit_GraphAppendNode( Kit_Graph_t * pGraph );
558 extern Kit_Edge_t Kit_GraphAddNodeAnd( Kit_Graph_t * pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1 );
559 extern Kit_Edge_t Kit_GraphAddNodeOr( Kit_Graph_t * pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1 );
560 extern Kit_Edge_t Kit_GraphAddNodeXor( Kit_Graph_t * pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1, int Type );
561 extern Kit_Edge_t Kit_GraphAddNodeMux( Kit_Graph_t * pGraph, Kit_Edge_t eEdgeC, Kit_Edge_t eEdgeT, Kit_Edge_t eEdgeE, int Type );
562 extern unsigned Kit_GraphToTruth( Kit_Graph_t * pGraph );
563 extern Kit_Graph_t * Kit_TruthToGraph( unsigned * pTruth, int nVars, Vec_Int_t * vMemory );
564 extern int Kit_GraphLeafDepth_rec( Kit_Graph_t * pGraph, Kit_Node_t * pNode, Kit_Node_t * pLeaf );
565 /*=== kitHop.c ==========================================================*/
566 //extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
567 //extern Hop_Obj_t * Kit_GraphToHop( Hop_Man_t * pMan, Kit_Graph_t * pGraph );
568 //extern Hop_Obj_t * Kit_TruthToHop( Hop_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory );
569 //extern Hop_Obj_t * Kit_CoverToHop( Hop_Man_t * pMan, Vec_Int_t * vCover, int nVars, Vec_Int_t * vMemory );
570 /*=== kitIsop.c ==========================================================*/
571 extern int Kit_TruthIsop( unsigned * puTruth, int nVars, Vec_Int_t * vMemory, int fTryBoth );
572 extern void Kit_TruthIsopPrint( unsigned * puTruth, int nVars, Vec_Int_t * vMemory, int fTryBoth );
573 extern void Kit_TruthIsopPrintCover( Vec_Int_t * vCover, int nVars, int fCompl );
574 /*=== kitPla.c ==========================================================*/
575 extern int Kit_PlaIsConst0( char * pSop );
576 extern int Kit_PlaIsConst1( char * pSop );
577 extern int Kit_PlaIsBuf( char * pSop );
578 extern int Kit_PlaIsInv( char * pSop );
579 extern int Kit_PlaGetVarNum( char * pSop );
580 extern int Kit_PlaGetCubeNum( char * pSop );
581 extern int Kit_PlaIsComplement( char * pSop );
582 extern void Kit_PlaComplement( char * pSop );
583 extern char * Kit_PlaStart( void * p, int nCubes, int nVars );
584 extern char * Kit_PlaCreateFromIsop( void * p, int nVars, Vec_Int_t * vCover );
585 extern void Kit_PlaToIsop( char * pSop, Vec_Int_t * vCover );
586 extern char * Kit_PlaStoreSop( void * p, char * pSop );
587 extern char * Kit_PlaFromTruth( void * p, unsigned * pTruth, int nVars, Vec_Int_t * vCover );
588 extern char * Kit_PlaFromTruthNew( unsigned * pTruth, int nVars, Vec_Int_t * vCover, Vec_Str_t * vStr );
589 extern ABC_UINT64_T Kit_PlaToTruth6( char * pSop, int nVars );
590 extern void Kit_PlaToTruth( char * pSop, int nVars, Vec_Ptr_t * vVars, unsigned * pTemp, unsigned * pTruth );
591 /*=== kitSop.c ==========================================================*/
592 extern void Kit_SopCreate( Kit_Sop_t * cResult, Vec_Int_t * vInput, int nVars, Vec_Int_t * vMemory );
593 extern void Kit_SopCreateInverse( Kit_Sop_t * cResult, Vec_Int_t * vInput, int nVars, Vec_Int_t * vMemory );
594 extern void Kit_SopDup( Kit_Sop_t * cResult, Kit_Sop_t * cSop, Vec_Int_t * vMemory );
595 extern void Kit_SopDivideByLiteralQuo( Kit_Sop_t * cSop, int iLit );
596 extern void Kit_SopDivideByCube( Kit_Sop_t * cSop, Kit_Sop_t * cDiv, Kit_Sop_t * vQuo, Kit_Sop_t * vRem, Vec_Int_t * vMemory );
597 extern void Kit_SopDivideInternal( Kit_Sop_t * cSop, Kit_Sop_t * cDiv, Kit_Sop_t * vQuo, Kit_Sop_t * vRem, Vec_Int_t * vMemory );
598 extern void Kit_SopMakeCubeFree( Kit_Sop_t * cSop );
599 extern int Kit_SopIsCubeFree( Kit_Sop_t * cSop );
600 extern void Kit_SopCommonCubeCover( Kit_Sop_t * cResult, Kit_Sop_t * cSop, Vec_Int_t * vMemory );
601 extern int Kit_SopAnyLiteral( Kit_Sop_t * cSop, int nLits );
602 extern int Kit_SopDivisor( Kit_Sop_t * cResult, Kit_Sop_t * cSop, int nLits, Vec_Int_t * vMemory );
603 extern void Kit_SopBestLiteralCover( Kit_Sop_t * cResult, Kit_Sop_t * cSop, unsigned uCube, int nLits, Vec_Int_t * vMemory );
604 /*=== kitTruth.c ==========================================================*/
605 extern void Kit_TruthSwapAdjacentVars( unsigned * pOut, unsigned * pIn, int nVars, int Start );
606 extern void Kit_TruthStretch( unsigned * pOut, unsigned * pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn );
607 extern void Kit_TruthPermute( unsigned * pOut, unsigned * pIn, int nVars, char * pPerm, int fReturnIn );
608 extern void Kit_TruthShrink( unsigned * pOut, unsigned * pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn );
609 extern int Kit_TruthVarInSupport( unsigned * pTruth, int nVars, int iVar );
610 extern int Kit_TruthSupportSize( unsigned * pTruth, int nVars );
611 extern unsigned Kit_TruthSupport( unsigned * pTruth, int nVars );
612 extern void Kit_TruthCofactor0( unsigned * pTruth, int nVars, int iVar );
613 extern void Kit_TruthCofactor1( unsigned * pTruth, int nVars, int iVar );
614 extern void Kit_TruthCofactor0New( unsigned * pOut, unsigned * pIn, int nVars, int iVar );
615 extern void Kit_TruthCofactor1New( unsigned * pOut, unsigned * pIn, int nVars, int iVar );
616 extern int Kit_TruthVarIsVacuous( unsigned * pOnset, unsigned * pOffset, int nVars, int iVar );
617 extern void Kit_TruthExist( unsigned * pTruth, int nVars, int iVar );
618 extern void Kit_TruthExistNew( unsigned * pRes, unsigned * pTruth, int nVars, int iVar );
619 extern void Kit_TruthExistSet( unsigned * pRes, unsigned * pTruth, int nVars, unsigned uMask );
620 extern void Kit_TruthForall( unsigned * pTruth, int nVars, int iVar );
621 extern void Kit_TruthForallNew( unsigned * pRes, unsigned * pTruth, int nVars, int iVar );
622 extern void Kit_TruthForallSet( unsigned * pRes, unsigned * pTruth, int nVars, unsigned uMask );
623 extern void Kit_TruthUniqueNew( unsigned * pRes, unsigned * pTruth, int nVars, int iVar );
624 extern void Kit_TruthMuxVar( unsigned * pOut, unsigned * pCof0, unsigned * pCof1, int nVars, int iVar );
625 extern void Kit_TruthMuxVarPhase( unsigned * pOut, unsigned * pCof0, unsigned * pCof1, int nVars, int iVar, int fCompl0 );
626 extern void Kit_TruthChangePhase( unsigned * pTruth, int nVars, int iVar );
627 extern int Kit_TruthVarsSymm( unsigned * pTruth, int nVars, int iVar0, int iVar1, unsigned * pCof0, unsigned * pCof1 );
628 extern int Kit_TruthVarsAntiSymm( unsigned * pTruth, int nVars, int iVar0, int iVar1, unsigned * pCof0, unsigned * pCof1 );
629 extern int Kit_TruthMinCofSuppOverlap( unsigned * pTruth, int nVars, int * pVarMin );
630 extern int Kit_TruthBestCofVar( unsigned * pTruth, int nVars, unsigned * pCof0, unsigned * pCof1 );
631 extern void Kit_TruthCountOnesInCofs( unsigned * pTruth, int nVars, int * pStore );
632 extern void Kit_TruthCountOnesInCofs0( unsigned * pTruth, int nVars, int * pStore );
633 extern void Kit_TruthCountOnesInCofsSlow( unsigned * pTruth, int nVars, int * pStore, unsigned * pAux );
634 extern unsigned Kit_TruthHash( unsigned * pIn, int nWords );
635 extern unsigned Kit_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux, int nVars, char * pCanonPerm );
636 extern char * Kit_TruthDumpToFile( unsigned * pTruth, int nVars, int nFile );
637 extern void Kit_TruthPrintProfile( unsigned * pTruth, int nVars );
638 
639 
640 
642 
643 
644 
645 #endif
646 
647 ////////////////////////////////////////////////////////////////////////
648 /// END OF FILE ///
649 ////////////////////////////////////////////////////////////////////////
650 
static int Kit_TruthFindFirstZero(unsigned *pIn, int nVars)
Definition: kit.h:266
unsigned Type
Definition: kit.h:112
static Kit_Node_t * Kit_GraphNodeLast(Kit_Graph_t *pGraph)
Definition: kit.h:212
unsigned fMark
Definition: kit.h:113
int nCap
Definition: kit.h:91
void Kit_SopBestLiteralCover(Kit_Sop_t *cResult, Kit_Sop_t *cSop, unsigned uCube, int nLits, Vec_Int_t *vMemory)
Definition: kitSop.c:560
static void Kit_TruthAndPhase(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars, int fCompl0, int fCompl1)
Definition: kit.h:409
int Kit_PlaIsBuf(char *pSop)
Definition: kitPla.c:78
int Kit_TruthBestCofVar(unsigned *pTruth, int nVars, unsigned *pCof0, unsigned *pCof1)
Definition: kitTruth.c:1365
unsigned fCompl1
Definition: kit.h:78
static unsigned Kit_SopCube(Kit_Sop_t *cSop, int i)
Definition: kit.h:189
Kit_Edge_t eEdge0
Definition: kit.h:69
Kit_Node_t * Kit_GraphAppendNode(Kit_Graph_t *pGraph)
Definition: kitGraph.c:148
static int Kit_BitWordNum(int nBits)
Definition: kit.h:223
static int Kit_SuppIsMinBase(int Supp)
Definition: kit.h:221
static Kit_DsdObj_t * Kit_DsdNtkRoot(Kit_DsdNtk_t *pNtk)
Definition: kit.h:151
static int Kit_CubeContains(unsigned uLarge, unsigned uSmall)
Definition: kit.h:180
int Kit_CreateCloud(CloudManager *dd, CloudNode *pFunc, Vec_Int_t *vNodes)
Definition: kitCloud.c:167
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static unsigned Kit_DsdObjOffset(int nFans)
Definition: kit.h:147
static void Kit_TruthSetBit(unsigned *p, int Bit)
Definition: kit.h:227
DdNode * Kit_SopToBdd(DdManager *dd, Kit_Sop_t *cSop, int nVars)
FUNCTION DECLARATIONS ///.
Definition: kitBdd.c:46
int Kit_DsdNonDsdSizeMax(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:1211
void Kit_SopDivideByCube(Kit_Sop_t *cSop, Kit_Sop_t *cDiv, Kit_Sop_t *vQuo, Kit_Sop_t *vRem, Vec_Int_t *vMemory)
Definition: kitSop.c:145
unsigned nRefs
Definition: kit.h:115
unsigned fNodeOr
Definition: kit.h:76
void Kit_TruthPrintProfile(unsigned *pTruth, int nVars)
Definition: kitTruth.c:2203
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
Definition: kit.h:52
Kit_Edge_t eRoot
Definition: kit.h:93
typedefABC_NAMESPACE_HEADER_START struct cloudManager CloudManager
Definition: cloud.h:52
unsigned Offset
Definition: kit.h:114
Definition: cudd.h:278
static int pFreqs[13719]
Definition: rwrTemp.c:31
void Kit_PlaComplement(char *pSop)
Definition: kitPla.c:181
void Kit_TruthCofactor0(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:368
static unsigned Kit_CubeSharp(unsigned uCube, unsigned uMask)
Definition: kit.h:181
unsigned nLat2
Definition: kit.h:82
void Kit_TruthForall(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:813
int Kit_SopDivisor(Kit_Sop_t *cResult, Kit_Sop_t *cSop, int nLits, Vec_Int_t *vMemory)
Definition: kitSop.c:534
int nLits
Definition: kit.h:54
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Kit_TruthSwapAdjacentVars(unsigned *pOut, unsigned *pIn, int nVars, int Start)
DECLARATIONS ///.
Definition: kitTruth.c:46
static void Kit_TruthFill(unsigned *pOut, int nVars)
Definition: kit.h:367
unsigned Kit_DsdGetSupports(Kit_DsdNtk_t *p)
Definition: kitDsd.c:1762
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Kit_TruthIsEqualWithPhase(unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:298
void Kit_TruthExistSet(unsigned *pRes, unsigned *pTruth, int nVars, unsigned uMask)
Definition: kitTruth.c:793
static int Kit_WordHasOneBit(unsigned uWord)
Definition: kit.h:239
int Kit_PlaIsConst0(char *pSop)
DECLARATIONS ///.
Definition: kitPla.c:46
static Kit_Node_t * Kit_GraphNode(Kit_Graph_t *pGraph, int i)
Definition: kit.h:211
unsigned fCompl0
Definition: kit.h:77
unsigned nFans
Definition: kit.h:116
void Kit_TruthMuxVarPhase(unsigned *pOut, unsigned *pCof0, unsigned *pCof1, int nVars, int iVar, int fCompl0)
Definition: kitTruth.c:1125
static int Kit_TruthIsDisjoint3(unsigned *pIn1, unsigned *pIn2, unsigned *pIn3, int nVars)
Definition: kit.h:347
void Kit_TruthPermute(unsigned *pOut, unsigned *pIn, int nVars, char *pPerm, int fReturnIn)
Definition: kitTruth.c:233
char * Kit_PlaFromTruthNew(unsigned *pTruth, int nVars, Vec_Int_t *vCover, Vec_Str_t *vStr)
Definition: kitPla.c:406
void Kit_TruthCountOnesInCofs(unsigned *pTruth, int nVars, int *pStore)
Definition: kitTruth.c:1410
static int Kit_TruthIsImply(unsigned *pIn1, unsigned *pIn2, int nVars)
Definition: kit.h:331
Kit_Edge_t eEdge1
Definition: kit.h:70
char * Kit_PlaFromTruth(void *p, unsigned *pTruth, int nVars, Vec_Int_t *vCover)
Definition: kitPla.c:337
int Kit_CreateCloudFromTruth(CloudManager *dd, unsigned *pTruth, int nVars, Vec_Int_t *vNodes)
Definition: kitCloud.c:209
static int Kit_GraphIsComplement(Kit_Graph_t *pGraph)
Definition: kit.h:205
static Kit_Edge_t Kit_IntToEdge(unsigned Edge)
Definition: kit.h:196
Kit_DsdObj_t ** pNodes
Definition: kit.h:130
Kit_DsdNtk_t * Kit_DsdDecomposeExpand(unsigned *pTruth, int nVars)
Definition: kitDsd.c:2330
static int Kit_GraphLeaveNum(Kit_Graph_t *pGraph)
Definition: kit.h:209
static Kit_DsdObj_t * Kit_DsdNtkObj(Kit_DsdNtk_t *pNtk, int Id)
Definition: kit.h:150
Kit_DsdNtk_t * Kit_DsdDecomposeMux(unsigned *pTruth, int nVars, int nDecMux)
Definition: kitDsd.c:2350
int nVars
Definition: kit.h:137
unsigned Kit_DsdNonDsdSupports(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:1264
unsigned * Kit_TruthCompose(CloudManager *dd, unsigned *pTruth, int nVars, unsigned **pInputs, int nVarsAll, Vec_Ptr_t *vStore, Vec_Int_t *vNodes)
Definition: kitCloud.c:263
static Kit_Edge_t Kit_IntToEdge_(unsigned m)
Definition: kit.h:200
void Kit_DsdTruth(Kit_DsdNtk_t *pNtk, unsigned *pTruthRes)
Definition: kitDsd.c:1068
void Kit_TruthChangePhase(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:1259
int nSize
Definition: kit.h:90
DdNode * Kit_TruthToBdd(DdManager *dd, unsigned *pTruth, int nVars, int fMSBonTop)
Definition: kitBdd.c:182
int Kit_TruthVarIsVacuous(unsigned *pOnset, unsigned *pOffset, int nVars, int iVar)
Definition: kitTruth.c:625
void Kit_DsdPrintFromTruth2(FILE *pFile, unsigned *pTruth, int nVars)
Definition: kitDsd.c:514
int Kit_PlaIsInv(char *pSop)
Definition: kitPla.c:98
unsigned short Root
Definition: kit.h:127
static Kit_Edge_t Kit_EdgeCreate(int Node, int fCompl)
Definition: kit.h:194
static unsigned Kit_CubeMask(int nVar)
Definition: kit.h:182
static int Kit_GraphIsConst0(Kit_Graph_t *pGraph)
Definition: kit.h:203
int Kit_SopIsCubeFree(Kit_Sop_t *cSop)
Definition: kitSop.c:334
void Kit_SopDup(Kit_Sop_t *cResult, Kit_Sop_t *cSop, Vec_Int_t *vMemory)
Definition: kitSop.c:97
unsigned Id
Definition: kit.h:111
void Kit_TruthCountOnesInCofsSlow(unsigned *pTruth, int nVars, int *pStore, unsigned *pAux)
Definition: kitTruth.c:1537
void Kit_TruthMuxVar(unsigned *pOut, unsigned *pCof0, unsigned *pCof1, int nVars, int iVar)
Definition: kitTruth.c:1069
Kit_DsdMan_t * Kit_DsdManAlloc(int nVars, int nNodes)
DECLARATIONS ///.
Definition: kitDsd.c:45
static int Kit_TruthIsEqual(unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:274
static int Kit_TruthIsConst0(unsigned *pIn, int nVars)
Definition: kit.h:315
void Kit_SopDivideInternal(Kit_Sop_t *cSop, Kit_Sop_t *cDiv, Kit_Sop_t *vQuo, Kit_Sop_t *vRem, Vec_Int_t *vMemory)
Definition: kitSop.c:178
void Kit_DsdTruthPartial(Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk, unsigned *pTruthRes, unsigned uSupp)
Definition: kitDsd.c:1107
int Kit_PlaGetCubeNum(char *pSop)
Definition: kitPla.c:138
static int Kit_GraphIsVar(Kit_Graph_t *pGraph)
Definition: kit.h:206
unsigned * pMem
Definition: kit.h:128
int nCubes
Definition: kit.h:55
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition: kitDsd.c:490
void Kit_DsdTruthPartialTwo(Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk, unsigned uSupp, int iVar, unsigned *pTruthCo, unsigned *pTruthDec)
Definition: kitDsd.c:1089
static int Kit_CubeIsMarked(unsigned uCube)
Definition: kit.h:184
void Kit_TruthStretch(unsigned *pOut, unsigned *pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn)
Definition: kitTruth.c:166
char * Kit_PlaStoreSop(void *p, char *pSop)
Definition: kitPla.c:317
void Kit_TruthCofSupports(Vec_Int_t *vBddDir, Vec_Int_t *vBddInv, int nVars, Vec_Int_t *vMemory, unsigned *puSupps)
Definition: kitCloud.c:310
int Kit_DsdCountAigNodes(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:1895
void Kit_SopCommonCubeCover(Kit_Sop_t *cResult, Kit_Sop_t *cSop, Vec_Int_t *vMemory)
Definition: kitSop.c:350
void Kit_PlaToIsop(char *pSop, Vec_Int_t *vCover)
Definition: kitPla.c:282
Kit_DsdObj_t * Kit_DsdNonDsdPrimeMax(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:1236
int nWords
Definition: abcNpn.c:127
void * pFunc
Definition: kit.h:73
void Kit_TruthExist(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:684
void Kit_SopDivideByLiteralQuo(Kit_Sop_t *cSop, int iLit)
Definition: kitSop.c:121
static int Kit_TruthHasBit(unsigned *p, int Bit)
Definition: kit.h:229
void Kit_TruthCountOnesInCofs0(unsigned *pTruth, int nVars, int *pStore)
Definition: kitTruth.c:1486
Kit_DsdNtk_t * Kit_DsdDecompose(unsigned *pTruth, int nVars)
Definition: kitDsd.c:2314
static unsigned Kit_EdgeToInt(Kit_Edge_t eEdge)
Definition: kit.h:195
int Kit_GraphLeafDepth_rec(Kit_Graph_t *pGraph, Kit_Node_t *pNode, Kit_Node_t *pLeaf)
Definition: kitGraph.c:383
static int Kit_CubeHasLit(unsigned uCube, int i)
Definition: kit.h:175
static int Kit_GraphIsConst(Kit_Graph_t *pGraph)
Definition: kit.h:202
static void Kit_TruthMux(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, unsigned *pCtrl, int nVars)
Definition: kit.h:457
Kit_Node_t * pNodes
Definition: kit.h:92
static void Kit_TruthAnd(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:379
void Kit_TruthCofactor0New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:521
unsigned nLat0
Definition: kit.h:80
void Kit_SopMakeCubeFree(Kit_Sop_t *cSop)
Definition: kitSop.c:311
int nLeaves
Definition: kit.h:89
int Kit_PlaIsComplement(char *pSop)
Definition: kitPla.c:160
static int Kit_TruthIsConst1(unsigned *pIn, int nVars)
Definition: kit.h:323
void Kit_DsdPrint(FILE *pFile, Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:374
static void Kit_TruthXor(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:391
Kit_Edge_t Kit_GraphAddNodeAnd(Kit_Graph_t *pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1)
Definition: kitGraph.c:172
int Kit_TruthMinCofSuppOverlap(unsigned *pTruth, int nVars, int *pVarMin)
Definition: kitTruth.c:1315
Vec_Ptr_t * vTtBdds
Definition: kit.h:143
static Kit_Node_t * Kit_GraphNodeFanin0(Kit_Graph_t *pGraph, Kit_Node_t *pNode)
Definition: kit.h:217
unsigned fCompl
Definition: kit.h:62
void Kit_GraphFree(Kit_Graph_t *pGraph)
Definition: kitGraph.c:131
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
Definition: kitIsop.c:55
void Kit_TruthCofactor1(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:470
void Kit_TruthIsopPrint(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
Definition: kitIsop.c:128
void Kit_TruthIsopPrintCover(Vec_Int_t *vCover, int nVars, int fCompl)
Definition: kitIsop.c:104
Vec_Ptr_t * vTtElems
Definition: kit.h:139
Kit_Dsd_t
Definition: kit.h:98
static unsigned * Kit_DsdObjTruth(Kit_DsdObj_t *pObj)
Definition: kit.h:148
Kit_Graph_t * Kit_GraphCreateLeaf(int iLeaf, int nLeaves, int fCompl)
Definition: kitGraph.c:110
unsigned Node
Definition: kit.h:63
int Kit_SopAnyLiteral(Kit_Sop_t *cSop, int nLits)
Definition: kitSop.c:370
static int Kit_TruthCountOnes(unsigned *pIn, int nVars)
Definition: kit.h:251
void Kit_TruthCofactor1New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:573
char * Kit_PlaCreateFromIsop(void *p, int nVars, Vec_Int_t *vCover)
Definition: kitPla.c:243
unsigned nLat1
Definition: kit.h:81
CloudManager * dd
Definition: kit.h:142
unsigned * pSupps
Definition: kit.h:129
unsigned short nNodesAlloc
Definition: kit.h:125
static int Kit_GraphNodeIsVar(Kit_Graph_t *pGraph, Kit_Node_t *pNode)
Definition: kit.h:214
Kit_Graph_t * Kit_GraphCreate(int nLeaves)
DECLARATIONS ///.
Definition: kitGraph.c:45
static int Counter
void Kit_DsdWriteFromTruth(char *pBuffer, unsigned *pTruth, int nVars)
Definition: kitDsd.c:536
Kit_Graph_t * Kit_GraphCreateConst1()
Definition: kitGraph.c:90
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
void Kit_DsdRotate(Kit_DsdNtk_t *p, int pFreqs[])
Definition: kitDsd.c:1671
static void Kit_TruthOrPhase(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars, int fCompl0, int fCompl1)
Definition: kit.h:433
static unsigned Kit_CubeRemLit(unsigned uCube, int i)
Definition: kit.h:178
ABC_UINT64_T Kit_PlaToTruth6(char *pSop, int nVars)
Definition: kitPla.c:442
static int Kit_GraphNodeInt(Kit_Graph_t *pGraph, Kit_Node_t *pNode)
Definition: kit.h:213
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
unsigned Kit_TruthHash(unsigned *pIn, int nWords)
Definition: kitTruth.c:1560
unsigned short pFans[0]
Definition: kit.h:117
unsigned Kit_TruthSemiCanonicize(unsigned *pInOut, unsigned *pAux, int nVars, char *pCanonPerm)
Definition: kitTruth.c:1657
static unsigned Kit_CubeMark(unsigned uCube)
Definition: kit.h:185
static int pPerm[13719]
Definition: rwrTemp.c:32
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
static void Kit_TruthXorBit(unsigned *p, int Bit)
Definition: kit.h:228
static void Kit_TruthIthVar(unsigned *pTruth, int nVars, int iVar)
Definition: kit.h:473
unsigned Level
Definition: kit.h:74
Kit_Graph_t * Kit_GraphCreateConst0()
Definition: kitGraph.c:69
static void Kit_SopWriteCube(Kit_Sop_t *cSop, unsigned uCube, int i)
Definition: kit.h:192
static void Kit_TruthNand(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:403
static void Kit_TruthMuxPhase(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, unsigned *pCtrl, int nVars, int fComp0)
Definition: kit.h:463
static int Kit_TruthIsEqualWithCare(unsigned *pIn0, unsigned *pIn1, unsigned *pCare, int nVars)
Definition: kit.h:282
static int Kit_TruthIsDisjoint(unsigned *pIn1, unsigned *pIn2, int nVars)
Definition: kit.h:339
static void Kit_TruthSharp(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:397
Kit_Edge_t Kit_GraphAddNodeXor(Kit_Graph_t *pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1, int Type)
Definition: kitGraph.c:224
Kit_DsdNtk_t * Kit_DsdShrink(Kit_DsdNtk_t *p, int pPrios[])
Definition: kitDsd.c:1633
void Kit_TruthForallSet(unsigned *pRes, unsigned *pTruth, int nVars, unsigned uMask)
Definition: kitTruth.c:1048
void Kit_TruthShrink(unsigned *pOut, unsigned *pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn)
Definition: kitTruth.c:200
typedefABC_NAMESPACE_HEADER_START struct Kit_Sop_t_ Kit_Sop_t
INCLUDES ///.
Definition: kit.h:51
static void Kit_GraphSetRoot(Kit_Graph_t *pGraph, Kit_Edge_t eRoot)
Definition: kit.h:208
static int Kit_WordFindFirstBit(unsigned uWord)
Definition: kit.h:231
static int Kit_TruthIsOpposite(unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:290
void Kit_TruthUniqueNew(unsigned *pRes, unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:922
char * Kit_TruthDumpToFile(unsigned *pTruth, int nVars, int nFile)
Definition: kitTruth.c:2004
Kit_Edge_t Kit_GraphAddNodeOr(Kit_Graph_t *pGraph, Kit_Edge_t eEdge0, Kit_Edge_t eEdge1)
Definition: kitGraph.c:196
Vec_Int_t * vNodes
Definition: kit.h:144
void Kit_SopCreateInverse(Kit_Sop_t *cResult, Vec_Int_t *vInput, int nVars, Vec_Int_t *vMemory)
Definition: kitSop.c:68
static int Kit_TruthFindFirstBit(unsigned *pIn, int nVars)
Definition: kit.h:258
void Kit_TruthExistNew(unsigned *pRes, unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:738
unsigned Kit_TruthSupport(unsigned *pTruth, int nVars)
Definition: kitTruth.c:346
int Kit_DsdCofactoring(unsigned *pTruth, int nVars, int *pCofVars, int nLimit, int fVerbose)
Definition: kitDsd.c:2678
Kit_DsdNtk_t * Kit_DsdDeriveNtk(unsigned *pTruth, int nVars, int nLutSize)
unsigned short nNodes
Definition: kit.h:126
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
static int Kit_DsdLitIsLeaf(Kit_DsdNtk_t *pNtk, int Lit)
Definition: kit.h:152
static unsigned Kit_CubeXorLit(unsigned uCube, int i)
Definition: kit.h:177
static unsigned Kit_CubeUnmark(unsigned uCube)
Definition: kit.h:186
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int Kit_PlaIsConst1(char *pSop)
Definition: kitPla.c:62
int Kit_TruthVarInSupport(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:270
void Kit_TruthForallNew(unsigned *pRes, unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:867
void Kit_DsdManFree(Kit_DsdMan_t *p)
Definition: kitDsd.c:71
Vec_Ptr_t * vTtNodes
Definition: kit.h:140
static int Kit_DsdNtkObjNum(Kit_DsdNtk_t *pNtk)
Definition: kit.h:149
static Kit_Node_t * Kit_GraphVar(Kit_Graph_t *pGraph)
Definition: kit.h:215
static int Kit_GraphNodeNum(Kit_Graph_t *pGraph)
Definition: kit.h:210
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:163
#define assert(ex)
Definition: util_old.h:213
static int Kit_GraphIsConst1(Kit_Graph_t *pGraph)
Definition: kit.h:204
unsigned * pCubes
Definition: kit.h:56
static int Kit_WordCountOnes(unsigned uWord)
Definition: kit.h:243
unsigned Kit_GraphToTruth(Kit_Graph_t *pGraph)
Definition: kitGraph.c:306
static unsigned Kit_DsdLitSupport(Kit_DsdNtk_t *pNtk, int Lit)
Definition: kit.h:153
static void Kit_SopShrink(Kit_Sop_t *cSop, int nCubesNew)
Definition: kit.h:190
static int Kit_GraphVarInt(Kit_Graph_t *pGraph)
Definition: kit.h:216
static Kit_Node_t * Kit_GraphNodeFanin1(Kit_Graph_t *pGraph, Kit_Node_t *pNode)
Definition: kit.h:218
static void Kit_GraphComplement(Kit_Graph_t *pGraph)
Definition: kit.h:207
int Kit_TruthVarsAntiSymm(unsigned *pTruth, int nVars, int iVar0, int iVar1, unsigned *pCof0, unsigned *pCof1)
Definition: kitTruth.c:1223
int fConst
Definition: kit.h:88
int Kit_TruthVarsSymm(unsigned *pTruth, int nVars, int iVar0, int iVar1, unsigned *pCof0, unsigned *pCof1)
Definition: kitTruth.c:1187
Kit_Edge_t Kit_GraphAddNodeMux(Kit_Graph_t *pGraph, Kit_Edge_t eEdgeC, Kit_Edge_t eEdgeT, Kit_Edge_t eEdgeE, int Type)
Definition: kitGraph.c:265
static unsigned Kit_EdgeToInt_(Kit_Edge_t m)
Definition: kit.h:199
int iFunc
Definition: kit.h:72
CloudNode * Kit_TruthToCloud(CloudManager *dd, unsigned *pTruth, int nVars)
Definition: kitCloud.c:148
static int Kit_SopCubeNum(Kit_Sop_t *cSop)
Definition: kit.h:188
Kit_Graph_t * Kit_TruthToGraph(unsigned *pTruth, int nVars, Vec_Int_t *vMemory)
Definition: kitGraph.c:355
Kit_DsdNtk_t * Kit_DsdExpand(Kit_DsdNtk_t *p)
Definition: kitDsd.c:1451
DdNode * Kit_GraphToBdd(DdManager *dd, Kit_Graph_t *pGraph)
Definition: kitBdd.c:91
char * Kit_PlaStart(void *p, int nCubes, int nVars)
Definition: kitPla.c:211
static void Kit_TruthClear(unsigned *pOut, int nVars)
Definition: kit.h:361
int Kit_PlaGetVarNum(char *pSop)
Definition: kitPla.c:118
static unsigned Kit_CubeSetLit(unsigned uCube, int i)
Definition: kit.h:176
unsigned short nVars
Definition: kit.h:124
void Kit_DsdPrintExpanded(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:471
void Kit_DsdVerify(Kit_DsdNtk_t *pNtk, unsigned *pTruth, int nVars)
Definition: kitDsd.c:2492
int Kit_TruthSupportSize(unsigned *pTruth, int nVars)
Definition: kitTruth.c:327
unsigned * Kit_DsdTruthCompute(Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:663
void Kit_SopCreate(Kit_Sop_t *cResult, Vec_Int_t *vInput, int nVars, Vec_Int_t *vMemory)
DECLARATIONS ///.
Definition: kitSop.c:45
static void Kit_TruthOr(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:385
int nWords
Definition: kit.h:138
static unsigned Kit_BitMask(int nBits)
Definition: kit.h:225
unsigned * Kit_CloudToTruth(Vec_Int_t *vNodes, int nVars, Vec_Ptr_t *vStore, int fInv)
Definition: kitCloud.c:229
static void Kit_SopPushCube(Kit_Sop_t *cSop, unsigned uCube)
Definition: kit.h:191
Kit_Graph_t * Kit_SopFactor(Vec_Int_t *vCover, int fCompl, int nVars, Vec_Int_t *vMemory)
FUNCTION DEFINITIONS ///.
Definition: kitFactor.c:55
void Kit_PlaToTruth(char *pSop, int nVars, Vec_Ptr_t *vVars, unsigned *pTemp, unsigned *pTruth)
Definition: kitPla.c:496
static int Kit_GraphRootLevel(Kit_Graph_t *pGraph)
Definition: kit.h:219