ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcAig.c
Go to the documentation of this file.
1
20
21#include "abc.h"
22
24
25/*
26 AIG is an And-Inv Graph with structural hashing.
27 It is always structurally hashed. It means that at any time:
28 - for each AND gate, there are no other AND gates with the same children
29 - the constants are propagated
30 - there is no single-input nodes (inverters/buffers)
31 Additionally the following invariants are satisfied:
32 - there are no dangling nodes (the nodes without fanout)
33 - the level of each AND gate reflects the levels of this fanins
34 - the EXOR-status of each node is up-to-date
35 - the AND nodes are in the topological order
36 - the constant 1 node has always number 0 in the object list
37 The operations that are performed on AIGs:
38 - building new nodes (Abc_AigAnd)
39 - performing elementary Boolean operations (Abc_AigOr, Abc_AigXor, etc)
40 - replacing one node by another (Abc_AigReplace)
41 - propagating constants (Abc_AigReplace)
42 When AIG is duplicated, the new graph is structurally hashed too.
43 If this repeated hashing leads to fewer nodes, it means the original
44 AIG was not strictly hashed (one of the conditions above is violated).
45*/
46
50
51// the simple AIG manager
53{
54 Abc_Ntk_t * pNtkAig; // the AIG network
55 Abc_Obj_t * pConst1; // the constant 1 object (not a node!)
56 Abc_Obj_t ** pBins; // the table bins
57 int nBins; // the size of the table
58 int nEntries; // the total number of entries in the table
59 Vec_Ptr_t * vNodes; // the temporary array of nodes
60 Vec_Ptr_t * vStackReplaceOld; // the nodes to be replaced
61 Vec_Ptr_t * vStackReplaceNew; // the nodes to be used for replacement
62 Vec_Vec_t * vLevels; // the nodes to be updated
63 Vec_Vec_t * vLevelsR; // the nodes to be updated
64 Vec_Ptr_t * vAddedCells; // the added nodes
65 Vec_Ptr_t * vUpdatedNets; // the nodes whose fanouts have changed
66
71};
72
73// iterators through the entries in the linked lists of nodes
74#define Abc_AigBinForEachEntry( pBin, pEnt ) \
75 for ( pEnt = pBin; \
76 pEnt; \
77 pEnt = pEnt->pNext )
78#define Abc_AigBinForEachEntrySafe( pBin, pEnt, pEnt2 ) \
79 for ( pEnt = pBin, \
80 pEnt2 = pEnt? pEnt->pNext: NULL; \
81 pEnt; \
82 pEnt = pEnt2, \
83 pEnt2 = pEnt? pEnt->pNext: NULL )
84
85// hash key for the structural hash table
86//static inline unsigned Abc_HashKey2( Abc_Obj_t * p0, Abc_Obj_t * p1, int TableSize ) { return ((unsigned)(p0) + (unsigned)(p1) * 12582917) % TableSize; }
87//static inline unsigned Abc_HashKey2( Abc_Obj_t * p0, Abc_Obj_t * p1, int TableSize ) { return ((unsigned)((a)->Id + (b)->Id) * ((a)->Id + (b)->Id + 1) / 2) % TableSize; }
88
89// hashing the node
90static unsigned Abc_HashKey2( Abc_Obj_t * p0, Abc_Obj_t * p1, int TableSize )
91{
92 unsigned Key = 0;
93 Key ^= Abc_ObjRegular(p0)->Id * 7937;
94 Key ^= Abc_ObjRegular(p1)->Id * 2971;
95 Key ^= Abc_ObjIsComplement(p0) * 911;
96 Key ^= Abc_ObjIsComplement(p1) * 353;
97 return Key % TableSize;
98}
99
100// structural hash table procedures
101static Abc_Obj_t * Abc_AigAndCreate( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1 );
102static Abc_Obj_t * Abc_AigAndCreateFrom( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1, Abc_Obj_t * pAnd );
103static void Abc_AigAndDelete( Abc_Aig_t * pMan, Abc_Obj_t * pThis );
104static void Abc_AigResize( Abc_Aig_t * pMan );
105// incremental AIG procedures
106static void Abc_AigReplace_int( Abc_Aig_t * pMan, Abc_Obj_t * pOld, Abc_Obj_t * pNew, int fUpdateLevel );
107static void Abc_AigUpdateLevel_int( Abc_Aig_t * pMan );
108static void Abc_AigUpdateLevelR_int( Abc_Aig_t * pMan );
109static void Abc_AigRemoveFromLevelStructure( Vec_Vec_t * vStruct, Abc_Obj_t * pNode );
110static void Abc_AigRemoveFromLevelStructureR( Vec_Vec_t * vStruct, Abc_Obj_t * pNode );
111
112
116
129{
130 Abc_Aig_t * pMan;
131 // start the manager
132 pMan = ABC_ALLOC( Abc_Aig_t, 1 );
133 memset( pMan, 0, sizeof(Abc_Aig_t) );
134 // allocate the table
135 pMan->nBins = Abc_PrimeCudd( 10000 );
136 pMan->pBins = ABC_ALLOC( Abc_Obj_t *, pMan->nBins );
137 memset( pMan->pBins, 0, sizeof(Abc_Obj_t *) * pMan->nBins );
138 pMan->vNodes = Vec_PtrAlloc( 100 );
139 pMan->vLevels = Vec_VecAlloc( 100 );
140 pMan->vLevelsR = Vec_VecAlloc( 100 );
141 pMan->vStackReplaceOld = Vec_PtrAlloc( 100 );
142 pMan->vStackReplaceNew = Vec_PtrAlloc( 100 );
143 // create the constant node
144 assert( pNtkAig->vObjs->nSize == 0 );
145 pMan->pConst1 = Abc_NtkCreateObj( pNtkAig, ABC_OBJ_NODE );
146 pMan->pConst1->Type = ABC_OBJ_CONST1;
147 pMan->pConst1->fPhase = 1;
148 pNtkAig->nObjCounts[ABC_OBJ_NODE]--;
149 // save the current network
150 pMan->pNtkAig = pNtkAig;
151 return pMan;
152}
153
165void Abc_AigFree( Abc_Aig_t * pMan )
166{
167 assert( Vec_PtrSize( pMan->vStackReplaceOld ) == 0 );
168 assert( Vec_PtrSize( pMan->vStackReplaceNew ) == 0 );
169 // free the table
170 if ( pMan->vAddedCells )
171 Vec_PtrFree( pMan->vAddedCells );
172 if ( pMan->vUpdatedNets )
173 Vec_PtrFree( pMan->vUpdatedNets );
174 Vec_VecFree( pMan->vLevels );
175 Vec_VecFree( pMan->vLevelsR );
176 Vec_PtrFree( pMan->vStackReplaceOld );
177 Vec_PtrFree( pMan->vStackReplaceNew );
178 Vec_PtrFree( pMan->vNodes );
179 ABC_FREE( pMan->pBins );
180 ABC_FREE( pMan );
181}
182
195{
196 Vec_Ptr_t * vDangles;
197 Abc_Obj_t * pAnd;
198 int i, nNodesOld;
199// printf( "Strash0 = %d. Strash1 = %d. Strash100 = %d. StrashM = %d.\n",
200// pMan->nStrash0, pMan->nStrash1, pMan->nStrash5, pMan->nStrash2 );
201 nNodesOld = pMan->nEntries;
202 // collect the AND nodes that do not fanout
203 vDangles = Vec_PtrAlloc( 100 );
204 for ( i = 0; i < pMan->nBins; i++ )
205 Abc_AigBinForEachEntry( pMan->pBins[i], pAnd )
206 if ( Abc_ObjFanoutNum(pAnd) == 0 )
207 Vec_PtrPush( vDangles, pAnd );
208 // process the dangling nodes and their MFFCs
209 Vec_PtrForEachEntry( Abc_Obj_t *, vDangles, pAnd, i )
210 Abc_AigDeleteNode( pMan, pAnd );
211 Vec_PtrFree( vDangles );
212 return nNodesOld - pMan->nEntries;
213}
214
227{
228 Abc_Obj_t * pObj, * pAnd;
229 int i, nFanins, Counter;
230 Abc_NtkForEachNode( pMan->pNtkAig, pObj, i )
231 {
232 nFanins = Abc_ObjFaninNum(pObj);
233 if ( nFanins == 0 )
234 {
235 if ( !Abc_AigNodeIsConst(pObj) )
236 {
237 printf( "Abc_AigCheck: The AIG has non-standard constant nodes.\n" );
238 return 0;
239 }
240 continue;
241 }
242 if ( nFanins == 1 )
243 {
244 printf( "Abc_AigCheck: The AIG has single input nodes.\n" );
245 return 0;
246 }
247 if ( nFanins > 2 )
248 {
249 printf( "Abc_AigCheck: The AIG has non-standard nodes.\n" );
250 return 0;
251 }
252 if ( pObj->Level != 1 + (unsigned)Abc_MaxInt( Abc_ObjFanin0(pObj)->Level, Abc_ObjFanin1(pObj)->Level ) )
253 printf( "Abc_AigCheck: Node \"%s\" has level that does not agree with the fanin levels.\n", Abc_ObjName(pObj) );
254 pAnd = Abc_AigAndLookup( pMan, Abc_ObjChild0(pObj), Abc_ObjChild1(pObj) );
255 if ( pAnd != pObj )
256 printf( "Abc_AigCheck: Node \"%s\" is not in the structural hashing table.\n", Abc_ObjName(pObj) );
257 }
258 // count the number of nodes in the table
259 Counter = 0;
260 for ( i = 0; i < pMan->nBins; i++ )
261 Abc_AigBinForEachEntry( pMan->pBins[i], pAnd )
262 Counter++;
263 if ( Counter != Abc_NtkNodeNum(pMan->pNtkAig) )
264 {
265 printf( "Abc_AigCheck: The number of nodes in the structural hashing table is wrong.\n" );
266 return 0;
267 }
268 // if the node is a choice node, nodes in its class should not have fanouts
269 Abc_NtkForEachNode( pMan->pNtkAig, pObj, i )
270 if ( Abc_AigNodeIsChoice(pObj) )
271 for ( pAnd = (Abc_Obj_t *)pObj->pData; pAnd; pAnd = (Abc_Obj_t *)pAnd->pData )
272 if ( Abc_ObjFanoutNum(pAnd) > 0 )
273 {
274 printf( "Abc_AigCheck: Representative %s", Abc_ObjName(pAnd) );
275 printf( " of choice node %s has %d fanouts.\n", Abc_ObjName(pObj), Abc_ObjFanoutNum(pAnd) );
276 return 0;
277 }
278 return 1;
279}
280
293{
294 Abc_Obj_t * pNode;
295 int i, LevelsMax;
296 assert( Abc_NtkIsStrash(pNtk) );
297 if ( pNtk->nBarBufs )
298 return Abc_NtkLevel( pNtk );
299 // perform the traversal
300 LevelsMax = 0;
301 Abc_NtkForEachCo( pNtk, pNode, i )
302 if ( LevelsMax < (int)Abc_ObjFanin0(pNode)->Level )
303 LevelsMax = (int)Abc_ObjFanin0(pNode)->Level;
304 return LevelsMax;
305}
306
307
319Abc_Obj_t * Abc_AigAndCreate( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1 )
320{
321 Abc_Obj_t * pAnd;
322 unsigned Key;
323 // check if it is a good time for table resizing
324 if ( pMan->nEntries > 2 * pMan->nBins )
325 Abc_AigResize( pMan );
326 // order the arguments
327 if ( Abc_ObjRegular(p0)->Id > Abc_ObjRegular(p1)->Id )
328 pAnd = p0, p0 = p1, p1 = pAnd;
329 // create the new node
330 pAnd = Abc_NtkCreateNode( pMan->pNtkAig );
331 Abc_ObjAddFanin( pAnd, p0 );
332 Abc_ObjAddFanin( pAnd, p1 );
333 // set the level of the new node
334 pAnd->Level = 1 + Abc_MaxInt( Abc_ObjRegular(p0)->Level, Abc_ObjRegular(p1)->Level );
335 pAnd->fExor = Abc_NodeIsExorType(pAnd);
336 pAnd->fPhase = (Abc_ObjIsComplement(p0) ^ Abc_ObjRegular(p0)->fPhase) & (Abc_ObjIsComplement(p1) ^ Abc_ObjRegular(p1)->fPhase);
337 // add the node to the corresponding linked list in the table
338 Key = Abc_HashKey2( p0, p1, pMan->nBins );
339 pAnd->pNext = pMan->pBins[Key];
340 pMan->pBins[Key] = pAnd;
341 pMan->nEntries++;
342 // create the cuts if defined
343// if ( pAnd->pNtk->pManCut )
344// Abc_NodeGetCuts( pAnd->pNtk->pManCut, pAnd );
345 pAnd->pCopy = NULL;
346 // add the node to the list of updated nodes
347 if ( pMan->vAddedCells )
348 Vec_PtrPush( pMan->vAddedCells, pAnd );
349 return pAnd;
350}
351
363Abc_Obj_t * Abc_AigAndCreateFrom( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1, Abc_Obj_t * pAnd )
364{
365 Abc_Obj_t * pTemp;
366 unsigned Key;
367 assert( !Abc_ObjIsComplement(pAnd) );
368 // order the arguments
369 if ( Abc_ObjRegular(p0)->Id > Abc_ObjRegular(p1)->Id )
370 pTemp = p0, p0 = p1, p1 = pTemp;
371 // create the new node
372 Abc_ObjAddFanin( pAnd, p0 );
373 Abc_ObjAddFanin( pAnd, p1 );
374 // set the level of the new node
375 pAnd->Level = 1 + Abc_MaxInt( Abc_ObjRegular(p0)->Level, Abc_ObjRegular(p1)->Level );
376 pAnd->fExor = Abc_NodeIsExorType(pAnd);
377 // add the node to the corresponding linked list in the table
378 Key = Abc_HashKey2( p0, p1, pMan->nBins );
379 pAnd->pNext = pMan->pBins[Key];
380 pMan->pBins[Key] = pAnd;
381 pMan->nEntries++;
382 // create the cuts if defined
383// if ( pAnd->pNtk->pManCut )
384// Abc_NodeGetCuts( pAnd->pNtk->pManCut, pAnd );
385 pAnd->pCopy = NULL;
386 // add the node to the list of updated nodes
387// if ( pMan->vAddedCells )
388// Vec_PtrPush( pMan->vAddedCells, pAnd );
389 return pAnd;
390}
391
404{
405 Abc_Obj_t * pAnd, * pConst1;
406 unsigned Key;
407 assert( Abc_ObjRegular(p0)->pNtk->pManFunc == pMan );
408 assert( Abc_ObjRegular(p1)->pNtk->pManFunc == pMan );
409 // check for trivial cases
410 pConst1 = Abc_AigConst1(pMan->pNtkAig);
411 if ( p0 == p1 )
412 return p0;
413 if ( p0 == Abc_ObjNot(p1) )
414 return Abc_ObjNot(pConst1);
415 if ( Abc_ObjRegular(p0) == pConst1 )
416 {
417 if ( p0 == pConst1 )
418 return p1;
419 return Abc_ObjNot(pConst1);
420 }
421 if ( Abc_ObjRegular(p1) == pConst1 )
422 {
423 if ( p1 == pConst1 )
424 return p0;
425 return Abc_ObjNot(pConst1);
426 }
427/*
428 {
429 int nFans0 = Abc_ObjFanoutNum( Abc_ObjRegular(p0) );
430 int nFans1 = Abc_ObjFanoutNum( Abc_ObjRegular(p1) );
431 if ( nFans0 == 0 || nFans1 == 0 )
432 pMan->nStrash0++;
433 else if ( nFans0 == 1 || nFans1 == 1 )
434 pMan->nStrash1++;
435 else if ( nFans0 <= 100 && nFans1 <= 100 )
436 pMan->nStrash5++;
437 else
438 pMan->nStrash2++;
439 }
440*/
441 {
442 int nFans0 = Abc_ObjFanoutNum( Abc_ObjRegular(p0) );
443 int nFans1 = Abc_ObjFanoutNum( Abc_ObjRegular(p1) );
444 if ( nFans0 == 0 || nFans1 == 0 )
445 return NULL;
446 }
447
448 // order the arguments
449 if ( Abc_ObjRegular(p0)->Id > Abc_ObjRegular(p1)->Id )
450 pAnd = p0, p0 = p1, p1 = pAnd;
451 // get the hash key for these two nodes
452 Key = Abc_HashKey2( p0, p1, pMan->nBins );
453 // find the matching node in the table
454 Abc_AigBinForEachEntry( pMan->pBins[Key], pAnd )
455 if ( p0 == Abc_ObjChild0(pAnd) && p1 == Abc_ObjChild1(pAnd) )
456 {
457// assert( Abc_ObjFanoutNum(Abc_ObjRegular(p0)) && Abc_ObjFanoutNum(p1) );
458 return pAnd;
459 }
460 return NULL;
461}
462
474Abc_Obj_t * Abc_AigXorLookup( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1, int * pType )
475{
476 Abc_Obj_t * pNode1, * pNode2, * pNode;
477 // set the flag to zero
478 if ( pType ) *pType = 0;
479 // check the case of XOR(a,b) = OR(ab, a'b')'
480 if ( (pNode1 = Abc_AigAndLookup(pMan, Abc_ObjNot(p0), Abc_ObjNot(p1))) &&
481 (pNode2 = Abc_AigAndLookup(pMan, p0, p1)) )
482 {
483 pNode = Abc_AigAndLookup( pMan, Abc_ObjNot(pNode1), Abc_ObjNot(pNode2) );
484 if ( pNode && pType ) *pType = 1;
485 return pNode;
486 }
487 // check the case of XOR(a,b) = OR(a'b, ab')
488 if ( (pNode1 = Abc_AigAndLookup(pMan, p0, Abc_ObjNot(p1))) &&
489 (pNode2 = Abc_AigAndLookup(pMan, Abc_ObjNot(p0), p1)) )
490 {
491 pNode = Abc_AigAndLookup( pMan, Abc_ObjNot(pNode1), Abc_ObjNot(pNode2) );
492 return pNode? Abc_ObjNot(pNode) : NULL;
493 }
494 return NULL;
495}
496
508Abc_Obj_t * Abc_AigMuxLookup( Abc_Aig_t * pMan, Abc_Obj_t * pC, Abc_Obj_t * pT, Abc_Obj_t * pE, int * pType )
509{
510 Abc_Obj_t * pNode1, * pNode2, * pNode;
511 // set the flag to zero
512 if ( pType ) *pType = 0;
513 // check the case of MUX(c,t,e) = OR(ct', c'e')'
514 if ( (pNode1 = Abc_AigAndLookup(pMan, pC, Abc_ObjNot(pT))) &&
515 (pNode2 = Abc_AigAndLookup(pMan, Abc_ObjNot(pC), Abc_ObjNot(pE))) )
516 {
517 pNode = Abc_AigAndLookup( pMan, Abc_ObjNot(pNode1), Abc_ObjNot(pNode2) );
518 if ( pNode && pType ) *pType = 1;
519 return pNode;
520 }
521 // check the case of MUX(c,t,e) = OR(ct, c'e)
522 if ( (pNode1 = Abc_AigAndLookup(pMan, pC, pT)) &&
523 (pNode2 = Abc_AigAndLookup(pMan, Abc_ObjNot(pC), pE)) )
524 {
525 pNode = Abc_AigAndLookup( pMan, Abc_ObjNot(pNode1), Abc_ObjNot(pNode2) );
526 return pNode? Abc_ObjNot(pNode) : NULL;
527 }
528 return NULL;
529}
530
542void Abc_AigAndDelete( Abc_Aig_t * pMan, Abc_Obj_t * pThis )
543{
544 Abc_Obj_t * pAnd, * pAnd0, * pAnd1, ** ppPlace;
545 unsigned Key;
546 assert( !Abc_ObjIsComplement(pThis) );
547 assert( Abc_ObjIsNode(pThis) );
548 assert( Abc_ObjFaninNum(pThis) == 2 );
549 assert( pMan->pNtkAig == pThis->pNtk );
550 // get the hash key for these two nodes
551 pAnd0 = Abc_ObjRegular( Abc_ObjChild0(pThis) );
552 pAnd1 = Abc_ObjRegular( Abc_ObjChild1(pThis) );
553 Key = Abc_HashKey2( Abc_ObjChild0(pThis), Abc_ObjChild1(pThis), pMan->nBins );
554 // find the matching node in the table
555 ppPlace = pMan->pBins + Key;
556 Abc_AigBinForEachEntry( pMan->pBins[Key], pAnd )
557 {
558 if ( pAnd != pThis )
559 {
560 ppPlace = &pAnd->pNext;
561 continue;
562 }
563 *ppPlace = pAnd->pNext;
564 break;
565 }
566 assert( pAnd == pThis );
567 pMan->nEntries--;
568 // delete the cuts if defined
569 if ( pThis->pNtk->pManCut )
570 Abc_NodeFreeCuts( pThis->pNtk->pManCut, pThis );
571}
572
584void Abc_AigResize( Abc_Aig_t * pMan )
585{
586 Abc_Obj_t ** pBinsNew;
587 Abc_Obj_t * pEnt, * pEnt2;
588 int nBinsNew, Counter, i;
589 abctime clk;
590 unsigned Key;
591
592clk = Abc_Clock();
593 // get the new table size
594 nBinsNew = Abc_PrimeCudd( 3 * pMan->nBins );
595 // allocate a new array
596 pBinsNew = ABC_ALLOC( Abc_Obj_t *, nBinsNew );
597 memset( pBinsNew, 0, sizeof(Abc_Obj_t *) * nBinsNew );
598 // rehash the entries from the old table
599 Counter = 0;
600 for ( i = 0; i < pMan->nBins; i++ )
601 Abc_AigBinForEachEntrySafe( pMan->pBins[i], pEnt, pEnt2 )
602 {
603 Key = Abc_HashKey2( Abc_ObjChild0(pEnt), Abc_ObjChild1(pEnt), nBinsNew );
604 pEnt->pNext = pBinsNew[Key];
605 pBinsNew[Key] = pEnt;
606 Counter++;
607 }
608 assert( Counter == pMan->nEntries );
609// printf( "Increasing the structural table size from %6d to %6d. ", pMan->nBins, nBinsNew );
610// ABC_PRT( "Time", Abc_Clock() - clk );
611 // replace the table and the parameters
612 ABC_FREE( pMan->pBins );
613 pMan->pBins = pBinsNew;
614 pMan->nBins = nBinsNew;
615}
616
629{
630 Abc_Obj_t ** pBinsNew;
631 Abc_Obj_t * pEnt, * pEnt2;
632 int * pArray;
633 unsigned Key;
634 int Counter, Temp, i;
635
636 // allocate a new array
637 pBinsNew = ABC_ALLOC( Abc_Obj_t *, pMan->nBins );
638 memset( pBinsNew, 0, sizeof(Abc_Obj_t *) * pMan->nBins );
639 // rehash the entries from the old table
640 Counter = 0;
641 for ( i = 0; i < pMan->nBins; i++ )
642 Abc_AigBinForEachEntrySafe( pMan->pBins[i], pEnt, pEnt2 )
643 {
644 // swap the fanins if needed
645 pArray = pEnt->vFanins.pArray;
646 if ( pArray[0] > pArray[1] )
647 {
648 Temp = pArray[0];
649 pArray[0] = pArray[1];
650 pArray[1] = Temp;
651 Temp = pEnt->fCompl0;
652 pEnt->fCompl0 = pEnt->fCompl1;
653 pEnt->fCompl1 = Temp;
654 }
655 // rehash the node
656 Key = Abc_HashKey2( Abc_ObjChild0(pEnt), Abc_ObjChild1(pEnt), pMan->nBins );
657 pEnt->pNext = pBinsNew[Key];
658 pBinsNew[Key] = pEnt;
659 Counter++;
660 }
661 assert( Counter == pMan->nEntries );
662 // replace the table and the parameters
663 ABC_FREE( pMan->pBins );
664 pMan->pBins = pBinsNew;
665}
666
667
668
669
670
671
684{
685 assert( Abc_NtkIsStrash(pNtk) );
686 return ((Abc_Aig_t *)pNtk->pManFunc)->pConst1;
687}
688
701{
702 Abc_Obj_t * pAnd;
703 if ( (pAnd = Abc_AigAndLookup( pMan, p0, p1 )) )
704 return pAnd;
705 return Abc_AigAndCreate( pMan, p0, p1 );
706}
707
720{
721 return Abc_ObjNot( Abc_AigAnd( pMan, Abc_ObjNot(p0), Abc_ObjNot(p1) ) );
722}
723
736{
737 return Abc_AigOr( pMan, Abc_AigAnd(pMan, p0, Abc_ObjNot(p1)),
738 Abc_AigAnd(pMan, p1, Abc_ObjNot(p0)) );
739}
740
753{
754 return Abc_AigOr( pMan, Abc_AigAnd(pMan, pC, p1), Abc_AigAnd(pMan, Abc_ObjNot(pC), p0) );
755}
756
768Abc_Obj_t * Abc_AigMiter_rec( Abc_Aig_t * pMan, Abc_Obj_t ** ppObjs, int nObjs )
769{
770 Abc_Obj_t * pObj1, * pObj2;
771 if ( nObjs == 1 )
772 return ppObjs[0];
773 pObj1 = Abc_AigMiter_rec( pMan, ppObjs, nObjs/2 );
774 pObj2 = Abc_AigMiter_rec( pMan, ppObjs + nObjs/2, nObjs - nObjs/2 );
775 return Abc_AigOr( pMan, pObj1, pObj2 );
776}
777
789Abc_Obj_t * Abc_AigMiter( Abc_Aig_t * pMan, Vec_Ptr_t * vPairs, int fImplic )
790{
791 int i;
792 if ( vPairs->nSize == 0 )
793 return Abc_ObjNot( Abc_AigConst1(pMan->pNtkAig) );
794 assert( vPairs->nSize % 2 == 0 );
795 // go through the cubes of the node's SOP
796 if ( fImplic )
797 {
798 for ( i = 0; i < vPairs->nSize; i += 2 )
799 vPairs->pArray[i/2] = Abc_AigAnd( pMan, (Abc_Obj_t *)vPairs->pArray[i], Abc_ObjNot((Abc_Obj_t *)vPairs->pArray[i+1]) );
800 }
801 else
802 {
803 for ( i = 0; i < vPairs->nSize; i += 2 )
804 vPairs->pArray[i/2] = Abc_AigXor( pMan, (Abc_Obj_t *)vPairs->pArray[i], (Abc_Obj_t *)vPairs->pArray[i+1] );
805 }
806 vPairs->nSize = vPairs->nSize/2;
807 return Abc_AigMiter_rec( pMan, (Abc_Obj_t **)vPairs->pArray, vPairs->nSize );
808}
809
822{
823 Abc_Obj_t * pMiter, * pXor;
824 int i;
825 assert( vPairs->nSize % 2 == 0 );
826 // go through the cubes of the node's SOP
827 pMiter = Abc_ObjNot( Abc_AigConst1(pMan->pNtkAig) );
828 for ( i = 0; i < vPairs->nSize; i += 2 )
829 {
830 pXor = Abc_AigXor( pMan, (Abc_Obj_t *)vPairs->pArray[i], (Abc_Obj_t *)vPairs->pArray[i+1] );
831 pMiter = Abc_AigOr( pMan, pMiter, pXor );
832 }
833 return pMiter;
834}
835
836
837
838
850int Abc_AigReplace( Abc_Aig_t * pMan, Abc_Obj_t * pOld, Abc_Obj_t * pNew, int fUpdateLevel )
851{
852 assert( Vec_PtrSize(pMan->vStackReplaceOld) == 0 );
853 assert( Vec_PtrSize(pMan->vStackReplaceNew) == 0 );
854 Vec_PtrPush( pMan->vStackReplaceOld, pOld );
855 Vec_PtrPush( pMan->vStackReplaceNew, pNew );
856 assert( !Abc_ObjIsComplement(pOld) );
857 // process the replacements
858 while ( Vec_PtrSize(pMan->vStackReplaceOld) )
859 {
860 pOld = (Abc_Obj_t *)Vec_PtrPop( pMan->vStackReplaceOld );
861 pNew = (Abc_Obj_t *)Vec_PtrPop( pMan->vStackReplaceNew );
862 if ( Abc_ObjFanoutNum(pOld) == 0 )
863 //return 0;
864 continue;
865 Abc_AigReplace_int( pMan, pOld, pNew, fUpdateLevel );
866 }
867 if ( fUpdateLevel )
868 {
869 Abc_AigUpdateLevel_int( pMan );
870 if ( pMan->pNtkAig->vLevelsR )
871 Abc_AigUpdateLevelR_int( pMan );
872 }
873 return 1;
874}
875
887void Abc_AigReplace_int( Abc_Aig_t * pMan, Abc_Obj_t * pOld, Abc_Obj_t * pNew, int fUpdateLevel )
888{
889 Abc_Obj_t * pFanin1, * pFanin2, * pFanout, * pFanoutNew, * pFanoutFanout;
890 int k, v, iFanin;
891 // make sure the old node is regular and has fanouts
892 // (the new node can be complemented and can have fanouts)
893 assert( !Abc_ObjIsComplement(pOld) );
894 assert( Abc_ObjFanoutNum(pOld) > 0 );
895 // look at the fanouts of old node
896 Abc_NodeCollectFanouts( pOld, pMan->vNodes );
897 Vec_PtrForEachEntry( Abc_Obj_t *, pMan->vNodes, pFanout, k )
898 {
899 if ( Abc_ObjIsCo(pFanout) )
900 {
901 pFanin1 = Abc_ObjRegular( pNew );
902 if ( pFanin1->fMarkB )
903 Abc_AigRemoveFromLevelStructureR( pMan->vLevelsR, pFanin1 );
904 if ( fUpdateLevel && pMan->pNtkAig->vLevelsR )
905 {
907 assert( pFanin1->fMarkB == 0 );
908 if ( !Abc_ObjIsCi(pFanin1) )
909 {
910 pFanin1->fMarkB = 1;
911 Vec_VecPush( pMan->vLevelsR, Abc_ObjReverseLevel(pFanin1), pFanin1 );
912 }
913 }
914 Abc_ObjPatchFanin( pFanout, pOld, pNew );
915 continue;
916 }
917 // find the old node as a fanin of this fanout
918 iFanin = Vec_IntFind( &pFanout->vFanins, pOld->Id );
919 assert( iFanin == 0 || iFanin == 1 );
920 // get the new fanin
921 pFanin1 = Abc_ObjNotCond( pNew, Abc_ObjFaninC(pFanout, iFanin) );
922 assert( Abc_ObjRegular(pFanin1) != pFanout );
923 // get another fanin
924 pFanin2 = Abc_ObjChild( pFanout, iFanin ^ 1 );
925 assert( Abc_ObjRegular(pFanin2) != pFanout );
926 // check if the node with these fanins exists
927 if ( (pFanoutNew = Abc_AigAndLookup( pMan, pFanin1, pFanin2 )) )
928 { // such node exists (it may be a constant)
929 // schedule replacement of the old fanout by the new fanout
930 Vec_PtrPush( pMan->vStackReplaceOld, pFanout );
931 Vec_PtrPush( pMan->vStackReplaceNew, pFanoutNew );
932 continue;
933 }
934 // such node does not exist - modify the old fanout node
935 // (this way the change will not propagate all the way to the COs)
936 assert( Abc_ObjRegular(pFanin1) != Abc_ObjRegular(pFanin2) );
937
938 // if the node is in the level structure, remove it
939 if ( pFanout->fMarkA )
940 Abc_AigRemoveFromLevelStructure( pMan->vLevels, pFanout );
941 // if the node is in the level structure, remove it
942 if ( pFanout->fMarkB )
943 Abc_AigRemoveFromLevelStructureR( pMan->vLevelsR, pFanout );
944
945 // remove the old fanout node from the structural hashing table
946 Abc_AigAndDelete( pMan, pFanout );
947 // remove the fanins of the old fanout
948 Abc_ObjRemoveFanins( pFanout );
949 // recreate the old fanout with new fanins and add it to the table
950 Abc_AigAndCreateFrom( pMan, pFanin1, pFanin2, pFanout );
951 assert( Abc_AigNodeIsAcyclic(pFanout, pFanout) );
952
953 if ( fUpdateLevel )
954 {
955 // schedule the updated fanout for updating direct level
956 assert( pFanout->fMarkA == 0 );
957 pFanout->fMarkA = 1;
958 Vec_VecPush( pMan->vLevels, pFanout->Level, pFanout );
959 // schedule the updated fanout for updating reverse level
960 if ( pMan->pNtkAig->vLevelsR )
961 {
962 assert( pFanout->fMarkB == 0 );
963 pFanout->fMarkB = 1;
964 Vec_VecPush( pMan->vLevelsR, Abc_ObjReverseLevel(pFanout), pFanout );
965 }
966 }
967
968 // the fanout has changed, update EXOR status of its fanouts
969 Abc_ObjForEachFanout( pFanout, pFanoutFanout, v )
970 if ( Abc_AigNodeIsAnd(pFanoutFanout) )
971 pFanoutFanout->fExor = Abc_NodeIsExorType(pFanoutFanout);
972 }
973 // if the node has no fanouts left, remove its MFFC
974 if ( Abc_ObjFanoutNum(pOld) == 0 )
975 Abc_AigDeleteNode( pMan, pOld );
976}
977
989void Abc_AigDeleteNode( Abc_Aig_t * pMan, Abc_Obj_t * pNode )
990{
991 Abc_Obj_t * pNode0, * pNode1, * pTemp;
992 int i, k;
993
994 // make sure the node is regular and dangling
995 assert( !Abc_ObjIsComplement(pNode) );
996 assert( Abc_ObjIsNode(pNode) );
997 assert( Abc_ObjFaninNum(pNode) == 2 );
998 assert( Abc_ObjFanoutNum(pNode) == 0 );
999
1000 // when deleting an old node that is scheduled for replacement, remove it from the replacement queue
1001 Vec_PtrForEachEntry( Abc_Obj_t *, pMan->vStackReplaceOld, pTemp, i )
1002 if ( pNode == pTemp )
1003 {
1004 // remove the entry from the replacement array
1005 for ( k = i; k < pMan->vStackReplaceOld->nSize - 1; k++ )
1006 {
1007 pMan->vStackReplaceOld->pArray[k] = pMan->vStackReplaceOld->pArray[k+1];
1008 pMan->vStackReplaceNew->pArray[k] = pMan->vStackReplaceNew->pArray[k+1];
1009 }
1010 pMan->vStackReplaceOld->nSize--;
1011 pMan->vStackReplaceNew->nSize--;
1012 }
1013
1014 // when deleting a new node that should replace another node, do not delete
1015 Vec_PtrForEachEntry( Abc_Obj_t *, pMan->vStackReplaceNew, pTemp, i )
1016 if ( pNode == Abc_ObjRegular(pTemp) )
1017 return;
1018
1019 // remember the node's fanins
1020 pNode0 = Abc_ObjFanin0( pNode );
1021 pNode1 = Abc_ObjFanin1( pNode );
1022
1023 // add the node to the list of updated nodes
1024 if ( pMan->vUpdatedNets )
1025 {
1026 Vec_PtrPushUnique( pMan->vUpdatedNets, pNode0 );
1027 Vec_PtrPushUnique( pMan->vUpdatedNets, pNode1 );
1028 }
1029
1030 // remove the node from the table
1031 Abc_AigAndDelete( pMan, pNode );
1032 // if the node is in the level structure, remove it
1033 if ( pNode->fMarkA )
1034 Abc_AigRemoveFromLevelStructure( pMan->vLevels, pNode );
1035 if ( pNode->fMarkB )
1036 Abc_AigRemoveFromLevelStructureR( pMan->vLevelsR, pNode );
1037 // remove the node from the network
1038 Abc_NtkDeleteObj( pNode );
1039
1040 // call recursively for the fanins
1041 if ( Abc_ObjIsNode(pNode0) && pNode0->vFanouts.nSize == 0 )
1042 Abc_AigDeleteNode( pMan, pNode0 );
1043 if ( Abc_ObjIsNode(pNode1) && pNode1->vFanouts.nSize == 0 )
1044 Abc_AigDeleteNode( pMan, pNode1 );
1045}
1046
1047
1063void Abc_AigUpdateLevel_int( Abc_Aig_t * pMan )
1064{
1065 Abc_Obj_t * pNode, * pFanout;
1066 Vec_Ptr_t * vVec;
1067 int LevelNew, i, k, v;
1068
1069 // go through the nodes and update the level of their fanouts
1070 Vec_VecForEachLevel( pMan->vLevels, vVec, i )
1071 {
1072 if ( Vec_PtrSize(vVec) == 0 )
1073 continue;
1074 Vec_PtrForEachEntry( Abc_Obj_t *, vVec, pNode, k )
1075 {
1076 if ( pNode == NULL )
1077 continue;
1078 assert( Abc_ObjIsNode(pNode) );
1079 assert( (int)pNode->Level == i );
1080 // clean the mark
1081 assert( pNode->fMarkA == 1 );
1082 pNode->fMarkA = 0;
1083 // iterate through the fanouts
1084 Abc_ObjForEachFanout( pNode, pFanout, v )
1085 {
1086 if ( Abc_ObjIsCo(pFanout) )
1087 continue;
1088 // get the new level of this fanout
1089 LevelNew = 1 + Abc_MaxInt( Abc_ObjFanin0(pFanout)->Level, Abc_ObjFanin1(pFanout)->Level );
1090 assert( LevelNew > i );
1091 if ( (int)pFanout->Level == LevelNew ) // no change
1092 continue;
1093 // if the fanout is present in the data structure, pull it out
1094 if ( pFanout->fMarkA )
1095 Abc_AigRemoveFromLevelStructure( pMan->vLevels, pFanout );
1096 // update the fanout level
1097 pFanout->Level = LevelNew;
1098 // add the fanout to the data structure to update its fanouts
1099 assert( pFanout->fMarkA == 0 );
1100 pFanout->fMarkA = 1;
1101 Vec_VecPush( pMan->vLevels, pFanout->Level, pFanout );
1102 }
1103 }
1104 Vec_PtrClear( vVec );
1105 }
1106}
1107
1119void Abc_AigUpdateLevelR_int( Abc_Aig_t * pMan )
1120{
1121 Abc_Obj_t * pNode, * pFanin, * pFanout;
1122 Vec_Ptr_t * vVec;
1123 int LevelNew, i, k, v, j;
1124
1125 // go through the nodes and update the level of their fanouts
1126 Vec_VecForEachLevel( pMan->vLevelsR, vVec, i )
1127 {
1128 if ( Vec_PtrSize(vVec) == 0 )
1129 continue;
1130 Vec_PtrForEachEntry( Abc_Obj_t *, vVec, pNode, k )
1131 {
1132 if ( pNode == NULL )
1133 continue;
1134 assert( Abc_ObjIsNode(pNode) );
1135 assert( Abc_ObjReverseLevel(pNode) == i );
1136 // clean the mark
1137 assert( pNode->fMarkB == 1 );
1138 pNode->fMarkB = 0;
1139 // iterate through the fanins
1140 Abc_ObjForEachFanin( pNode, pFanin, v )
1141 {
1142 if ( Abc_ObjIsCi(pFanin) )
1143 continue;
1144 // get the new reverse level of this fanin
1145 LevelNew = 0;
1146 Abc_ObjForEachFanout( pFanin, pFanout, j )
1147 if ( LevelNew < Abc_ObjReverseLevel(pFanout) )
1148 LevelNew = Abc_ObjReverseLevel(pFanout);
1149 LevelNew += 1;
1150 assert( LevelNew > i );
1151 if ( Abc_ObjReverseLevel(pFanin) == LevelNew ) // no change
1152 continue;
1153 // if the fanin is present in the data structure, pull it out
1154 if ( pFanin->fMarkB )
1155 Abc_AigRemoveFromLevelStructureR( pMan->vLevelsR, pFanin );
1156 // update the reverse level
1157 Abc_ObjSetReverseLevel( pFanin, LevelNew );
1158 // add the fanin to the data structure to update its fanins
1159 assert( pFanin->fMarkB == 0 );
1160 pFanin->fMarkB = 1;
1161 Vec_VecPush( pMan->vLevelsR, LevelNew, pFanin );
1162 }
1163 }
1164 Vec_PtrClear( vVec );
1165 }
1166}
1167
1179void Abc_AigRemoveFromLevelStructure( Vec_Vec_t * vStruct, Abc_Obj_t * pNode )
1180{
1181 Vec_Ptr_t * vVecTemp;
1182 Abc_Obj_t * pTemp;
1183 int m;
1184 assert( pNode->fMarkA );
1185 vVecTemp = Vec_VecEntry( vStruct, pNode->Level );
1186 Vec_PtrForEachEntry( Abc_Obj_t *, vVecTemp, pTemp, m )
1187 {
1188 if ( pTemp != pNode )
1189 continue;
1190 Vec_PtrWriteEntry( vVecTemp, m, NULL );
1191 break;
1192 }
1193 assert( m < Vec_PtrSize(vVecTemp) ); // found
1194 pNode->fMarkA = 0;
1195}
1196
1208void Abc_AigRemoveFromLevelStructureR( Vec_Vec_t * vStruct, Abc_Obj_t * pNode )
1209{
1210 Vec_Ptr_t * vVecTemp;
1211 Abc_Obj_t * pTemp;
1212 int m;
1213 assert( pNode->fMarkB );
1214 vVecTemp = Vec_VecEntry( vStruct, Abc_ObjReverseLevel(pNode) );
1215 Vec_PtrForEachEntry( Abc_Obj_t *, vVecTemp, pTemp, m )
1216 {
1217 if ( pTemp != pNode )
1218 continue;
1219 Vec_PtrWriteEntry( vVecTemp, m, NULL );
1220 break;
1221 }
1222 assert( m < Vec_PtrSize(vVecTemp) ); // found
1223 pNode->fMarkB = 0;
1224}
1225
1226
1227
1228
1242{
1243 Abc_Obj_t * pFanout;
1244 int i, iFanin;
1245 Abc_ObjForEachFanout( pNode, pFanout, i )
1246 {
1247 iFanin = Vec_IntFind( &pFanout->vFanins, pNode->Id );
1248 assert( iFanin >= 0 );
1249 if ( Abc_ObjFaninC( pFanout, iFanin ) )
1250 return 1;
1251 }
1252 return 0;
1253}
1254
1269{
1270 Abc_Obj_t * pFanout;
1271 int i, iFanin;
1272 Abc_ObjForEachFanout( pNode, pFanout, i )
1273 {
1274 if ( !Abc_NodeIsTravIdCurrent(pFanout) )
1275 continue;
1276 iFanin = Vec_IntFind( &pFanout->vFanins, pNode->Id );
1277 assert( iFanin >= 0 );
1278 if ( Abc_ObjFaninC( pFanout, iFanin ) )
1279 return 1;
1280 }
1281 return 0;
1282}
1283
1284
1297{
1298 Abc_Obj_t * pNodeR = Abc_ObjRegular(pNode);
1299 if ( Abc_ObjIsCi(pNodeR) )
1300 {
1301 printf( "CI %4s%s.\n", Abc_ObjName(pNodeR), Abc_ObjIsComplement(pNode)? "\'" : "" );
1302 return;
1303 }
1304 if ( Abc_AigNodeIsConst(pNodeR) )
1305 {
1306 printf( "Constant 1 %s.\n", Abc_ObjIsComplement(pNode)? "(complemented)" : "" );
1307 return;
1308 }
1309 // print the node's function
1310 printf( "%7s%s", Abc_ObjName(pNodeR), Abc_ObjIsComplement(pNode)? "\'" : "" );
1311 printf( " = " );
1312 printf( "%7s%s", Abc_ObjName(Abc_ObjFanin0(pNodeR)), Abc_ObjFaninC0(pNodeR)? "\'" : "" );
1313 printf( " * " );
1314 printf( "%7s%s", Abc_ObjName(Abc_ObjFanin1(pNodeR)), Abc_ObjFaninC1(pNodeR)? "\'" : "" );
1315 printf( "\n" );
1316}
1317
1318
1331{
1332 Abc_Obj_t * pFanin0, * pFanin1;
1333 Abc_Obj_t * pChild00, * pChild01;
1334 Abc_Obj_t * pChild10, * pChild11;
1335 if ( !Abc_AigNodeIsAnd(pNode) )
1336 return 1;
1337 pFanin0 = Abc_ObjFanin0(pNode);
1338 pFanin1 = Abc_ObjFanin1(pNode);
1339 if ( pRoot == pFanin0 || pRoot == pFanin1 )
1340 return 0;
1341 if ( Abc_ObjIsCi(pFanin0) )
1342 {
1343 pChild00 = NULL;
1344 pChild01 = NULL;
1345 }
1346 else
1347 {
1348 pChild00 = Abc_ObjFanin0(pFanin0);
1349 pChild01 = Abc_ObjFanin1(pFanin0);
1350 if ( pRoot == pChild00 || pRoot == pChild01 )
1351 return 0;
1352 }
1353 if ( Abc_ObjIsCi(pFanin1) )
1354 {
1355 pChild10 = NULL;
1356 pChild11 = NULL;
1357 }
1358 else
1359 {
1360 pChild10 = Abc_ObjFanin0(pFanin1);
1361 pChild11 = Abc_ObjFanin1(pFanin1);
1362 if ( pRoot == pChild10 || pRoot == pChild11 )
1363 return 0;
1364 }
1365 return 1;
1366}
1367
1380{
1381 Abc_Obj_t * pEnt;
1382 int i;
1383 for ( i = 0; i < pMan->nBins; i++ )
1384 Abc_AigBinForEachEntry( pMan->pBins[i], pEnt )
1385 {
1386 if ( Abc_ObjRegular(Abc_ObjChild0(pEnt))->Id > Abc_ObjRegular(Abc_ObjChild1(pEnt))->Id )
1387 {
1388// int i0 = Abc_ObjRegular(Abc_ObjChild0(pEnt))->Id;
1389// int i1 = Abc_ObjRegular(Abc_ObjChild1(pEnt))->Id;
1390 printf( "Node %d has incorrect ordering of fanins.\n", pEnt->Id );
1391 }
1392 }
1393}
1394
1407{
1408 Abc_Obj_t * pObj;
1409 int i;
1410 assert( Abc_NtkIsDfsOrdered(pNtk) );
1411 Abc_AigConst1(pNtk)->fPhase = 1;
1412 Abc_NtkForEachPi( pNtk, pObj, i )
1413 pObj->fPhase = 0;
1414 Abc_NtkForEachLatchOutput( pNtk, pObj, i )
1415 pObj->fPhase = Abc_LatchIsInit1(pObj);
1416 Abc_AigForEachAnd( pNtk, pObj, i )
1417 pObj->fPhase = (Abc_ObjFanin0(pObj)->fPhase ^ Abc_ObjFaninC0(pObj)) & (Abc_ObjFanin1(pObj)->fPhase ^ Abc_ObjFaninC1(pObj));
1418 Abc_NtkForEachPo( pNtk, pObj, i )
1419 pObj->fPhase = (Abc_ObjFanin0(pObj)->fPhase ^ Abc_ObjFaninC0(pObj));
1420 Abc_NtkForEachLatchInput( pNtk, pObj, i )
1421 pObj->fPhase = (Abc_ObjFanin0(pObj)->fPhase ^ Abc_ObjFaninC0(pObj));
1422}
1423
1424
1425
1438{
1439 assert( pMan->vAddedCells == NULL );
1440 pMan->vAddedCells = Vec_PtrAlloc( 1000 );
1441 pMan->vUpdatedNets = Vec_PtrAlloc( 1000 );
1442 *pvUpdatedNets = pMan->vUpdatedNets;
1443 return pMan->vAddedCells;
1444}
1445
1458{
1459 assert( pMan->vAddedCells != NULL );
1460 Vec_PtrFree( pMan->vAddedCells );
1461 Vec_PtrFree( pMan->vUpdatedNets );
1462 pMan->vAddedCells = NULL;
1463 pMan->vUpdatedNets = NULL;
1464}
1465
1478{
1479 assert( pMan->vAddedCells != NULL );
1480 Vec_PtrClear( pMan->vAddedCells );
1481 Vec_PtrClear( pMan->vUpdatedNets );
1482}
1483
1496{
1497 Abc_Obj_t * pAnd;
1498 int i, Counter = 0, CounterTotal = 0;
1499 // count how many nodes have pNext set
1500 for ( i = 0; i < pMan->nBins; i++ )
1501 Abc_AigBinForEachEntry( pMan->pBins[i], pAnd )
1502 {
1503 Counter += (pAnd->pNext != NULL);
1504 CounterTotal++;
1505 }
1506 printf( "Counter = %d. Nodes = %d. Ave = %6.2f\n", Counter, CounterTotal, 1.0 * CounterTotal/pMan->nBins );
1507 return Counter;
1508}
1509
1513
1514
1516{
1517 printf( "Hello, World!\n" );
1518}
1519
1520
1522
Abc_Obj_t * Abc_AigMiter2(Abc_Aig_t *pMan, Vec_Ptr_t *vPairs)
Definition abcAig.c:821
int Abc_AigCheck(Abc_Aig_t *pMan)
Definition abcAig.c:226
Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
#define Abc_AigBinForEachEntry(pBin, pEnt)
Definition abcAig.c:74
Abc_Aig_t * Abc_AigAlloc(Abc_Ntk_t *pNtkAig)
FUNCTION DEFINITIONS ///.
Definition abcAig.c:128
void Abc_AigRehash(Abc_Aig_t *pMan)
Definition abcAig.c:628
void Abc_AigUpdateReset(Abc_Aig_t *pMan)
Definition abcAig.c:1477
Vec_Ptr_t * Abc_AigUpdateStart(Abc_Aig_t *pMan, Vec_Ptr_t **pvUpdatedNets)
Definition abcAig.c:1437
Abc_Obj_t * Abc_AigAndLookup(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:403
#define Abc_AigBinForEachEntrySafe(pBin, pEnt, pEnt2)
Definition abcAig.c:78
void Abc_AigPrintNode(Abc_Obj_t *pNode)
Definition abcAig.c:1296
int Abc_AigLevel(Abc_Ntk_t *pNtk)
Definition abcAig.c:292
void Abc_AigUpdateStop(Abc_Aig_t *pMan)
Definition abcAig.c:1457
void Abc_AigSetNodePhases(Abc_Ntk_t *pNtk)
Definition abcAig.c:1406
void Abc_AigCheckFaninOrder(Abc_Aig_t *pMan)
Definition abcAig.c:1379
Abc_Obj_t * Abc_AigMiter(Abc_Aig_t *pMan, Vec_Ptr_t *vPairs, int fImplic)
Definition abcAig.c:789
int Abc_AigNodeIsAcyclic(Abc_Obj_t *pNode, Abc_Obj_t *pRoot)
Definition abcAig.c:1330
int Abc_AigNodeHasComplFanoutEdge(Abc_Obj_t *pNode)
Definition abcAig.c:1241
Abc_Obj_t * Abc_AigOr(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:719
Abc_Obj_t * Abc_AigMuxLookup(Abc_Aig_t *pMan, Abc_Obj_t *pC, Abc_Obj_t *pT, Abc_Obj_t *pE, int *pType)
Definition abcAig.c:508
int Abc_AigReplace(Abc_Aig_t *pMan, Abc_Obj_t *pOld, Abc_Obj_t *pNew, int fUpdateLevel)
Definition abcAig.c:850
void Abc_NtkHelloWorld(Abc_Ntk_t *pNtk)
END OF FILE ///.
Definition abcAig.c:1515
Abc_Obj_t * Abc_AigXor(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:735
int Abc_AigCleanup(Abc_Aig_t *pMan)
Definition abcAig.c:194
int Abc_AigNodeHasComplFanoutEdgeTrav(Abc_Obj_t *pNode)
Definition abcAig.c:1268
void Abc_AigDeleteNode(Abc_Aig_t *pMan, Abc_Obj_t *pNode)
Definition abcAig.c:989
Abc_Obj_t * Abc_AigMiter_rec(Abc_Aig_t *pMan, Abc_Obj_t **ppObjs, int nObjs)
Definition abcAig.c:768
Abc_Obj_t * Abc_AigMux(Abc_Aig_t *pMan, Abc_Obj_t *pC, Abc_Obj_t *p1, Abc_Obj_t *p0)
Definition abcAig.c:752
Abc_Obj_t * Abc_AigXorLookup(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1, int *pType)
Definition abcAig.c:474
Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:700
int Abc_AigCountNext(Abc_Aig_t *pMan)
Definition abcAig.c:1495
void Abc_AigFree(Abc_Aig_t *pMan)
Definition abcAig.c:165
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
ABC_DLL int Abc_NtkIsDfsOrdered(Abc_Ntk_t *pNtk)
Definition abcDfs.c:698
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL Abc_Obj_t * Abc_AigXor(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:735
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
Definition abcObj.c:170
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition abc.h:488
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
@ ABC_OBJ_NODE
Definition abc.h:94
@ ABC_OBJ_CONST1
Definition abc.h:88
struct Abc_Aig_t_ Abc_Aig_t
Definition abc.h:117
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
ABC_DLL void Abc_NodeCollectFanouts(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition abcUtil.c:1647
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition abcDfs.c:1449
#define Abc_NtkForEachLatchOutput(pNtk, pObj, i)
Definition abc.h:506
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition abcAig.c:700
#define Abc_NtkForEachLatchInput(pNtk, pObj, i)
Definition abc.h:503
ABC_DLL void Abc_ObjSetReverseLevel(Abc_Obj_t *pObj, int LevelR)
Definition abcTiming.c:1253
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
ABC_DLL void Abc_ObjRemoveFanins(Abc_Obj_t *pObj)
Definition abcFanio.c:141
ABC_DLL Abc_Obj_t * Abc_NtkCreateObj(Abc_Ntk_t *pNtk, Abc_ObjType_t Type)
Definition abcObj.c:109
ABC_DLL void Abc_NodeFreeCuts(void *p, Abc_Obj_t *pObj)
Definition abcCut.c:527
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition abcFanio.c:172
ABC_DLL int Abc_ObjReverseLevel(Abc_Obj_t *pObj)
Definition abcTiming.c:1233
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
ABC_DLL int Abc_NodeIsExorType(Abc_Obj_t *pNode)
Definition abcUtil.c:1300
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
DECLARATIONS ///.
Definition abcAig.c:53
int nEntries
Definition abcAig.c:58
Vec_Vec_t * vLevels
Definition abcAig.c:62
Abc_Ntk_t * pNtkAig
Definition abcAig.c:54
int nStrash1
Definition abcAig.c:68
Vec_Ptr_t * vStackReplaceOld
Definition abcAig.c:60
int nStrash2
Definition abcAig.c:70
Vec_Ptr_t * vUpdatedNets
Definition abcAig.c:65
int nBins
Definition abcAig.c:57
Vec_Vec_t * vLevelsR
Definition abcAig.c:63
int nStrash0
Definition abcAig.c:67
Vec_Ptr_t * vNodes
Definition abcAig.c:59
int nStrash5
Definition abcAig.c:69
Abc_Obj_t ** pBins
Definition abcAig.c:56
Abc_Obj_t * pConst1
Definition abcAig.c:55
Vec_Ptr_t * vAddedCells
Definition abcAig.c:64
Vec_Ptr_t * vStackReplaceNew
Definition abcAig.c:61
Vec_Int_t * vLevelsR
Definition abc.h:196
int nBarBufs
Definition abc.h:174
int nObjCounts[ABC_OBJ_NUMBER]
Definition abc.h:171
void * pManFunc
Definition abc.h:191
void * pManCut
Definition abc.h:193
Vec_Ptr_t * vObjs
Definition abc.h:162
void * pData
Definition abc.h:145
Vec_Int_t vFanins
Definition abc.h:143
Abc_Ntk_t * pNtk
Definition abc.h:130
int Id
Definition abc.h:132
unsigned fMarkB
Definition abc.h:135
unsigned fExor
Definition abc.h:138
Vec_Int_t vFanouts
Definition abc.h:144
unsigned fCompl1
Definition abc.h:141
Abc_Obj_t * pCopy
Definition abc.h:148
unsigned fMarkA
Definition abc.h:134
unsigned Type
Definition abc.h:133
unsigned fPhase
Definition abc.h:137
Abc_Obj_t * pNext
Definition abc.h:131
unsigned Level
Definition abc.h:142
unsigned fCompl0
Definition abc.h:140
#define assert(ex)
Definition util_old.h:213
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
#define Vec_VecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecVec.h:55
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition vecVec.h:42