ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
fraigUtil.c
Go to the documentation of this file.
1
18
19#include "fraigInt.h"
20#include <limits.h>
21
23
24
28
29static int bit_count[256] = {
30 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
31 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
32 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
33 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
34 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
35 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
36 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
37 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
38};
39
40static void Fraig_Dfs_rec( Fraig_Man_t * pMan, Fraig_Node_t * pNode, Fraig_NodeVec_t * vNodes, int fEquiv );
41static int Fraig_CheckTfi_rec( Fraig_Man_t * pMan, Fraig_Node_t * pNode, Fraig_Node_t * pOld );
42
46
58Fraig_NodeVec_t * Fraig_Dfs( Fraig_Man_t * pMan, int fEquiv )
59{
60 Fraig_NodeVec_t * vNodes;
61 int i;
62 pMan->nTravIds++;
63 vNodes = Fraig_NodeVecAlloc( 100 );
64 for ( i = 0; i < pMan->vOutputs->nSize; i++ )
65 Fraig_Dfs_rec( pMan, Fraig_Regular(pMan->vOutputs->pArray[i]), vNodes, fEquiv );
66 return vNodes;
67}
68
80Fraig_NodeVec_t * Fraig_DfsOne( Fraig_Man_t * pMan, Fraig_Node_t * pNode, int fEquiv )
81{
82 Fraig_NodeVec_t * vNodes;
83 pMan->nTravIds++;
84 vNodes = Fraig_NodeVecAlloc( 100 );
85 Fraig_Dfs_rec( pMan, Fraig_Regular(pNode), vNodes, fEquiv );
86 return vNodes;
87}
88
100Fraig_NodeVec_t * Fraig_DfsNodes( Fraig_Man_t * pMan, Fraig_Node_t ** ppNodes, int nNodes, int fEquiv )
101{
102 Fraig_NodeVec_t * vNodes;
103 int i;
104 pMan->nTravIds++;
105 vNodes = Fraig_NodeVecAlloc( 100 );
106 for ( i = 0; i < nNodes; i++ )
107 Fraig_Dfs_rec( pMan, Fraig_Regular(ppNodes[i]), vNodes, fEquiv );
108 return vNodes;
109}
110
122void Fraig_Dfs_rec( Fraig_Man_t * pMan, Fraig_Node_t * pNode, Fraig_NodeVec_t * vNodes, int fEquiv )
123{
124 assert( !Fraig_IsComplement(pNode) );
125 // skip the visited node
126 if ( pNode->TravId == pMan->nTravIds )
127 return;
128 pNode->TravId = pMan->nTravIds;
129 // visit the transitive fanin
130 if ( Fraig_NodeIsAnd(pNode) )
131 {
132 Fraig_Dfs_rec( pMan, Fraig_Regular(pNode->p1), vNodes, fEquiv );
133 Fraig_Dfs_rec( pMan, Fraig_Regular(pNode->p2), vNodes, fEquiv );
134 }
135 if ( fEquiv && pNode->pNextE )
136 Fraig_Dfs_rec( pMan, pNode->pNextE, vNodes, fEquiv );
137 // save the node
138 Fraig_NodeVecPush( vNodes, pNode );
139}
140
152int Fraig_CountNodes( Fraig_Man_t * pMan, int fEquiv )
153{
154 Fraig_NodeVec_t * vNodes;
155 int RetValue;
156 vNodes = Fraig_Dfs( pMan, fEquiv );
157 RetValue = vNodes->nSize;
158 Fraig_NodeVecFree( vNodes );
159 return RetValue;
160}
161
174{
175 assert( !Fraig_IsComplement(pOld) );
176 assert( !Fraig_IsComplement(pNew) );
177 pMan->nTravIds++;
178 return Fraig_CheckTfi_rec( pMan, pNew, pOld );
179}
180
192int Fraig_CheckTfi_rec( Fraig_Man_t * pMan, Fraig_Node_t * pNode, Fraig_Node_t * pOld )
193{
194 // check the trivial cases
195 if ( pNode == NULL )
196 return 0;
197 if ( pNode->Num < pOld->Num && !pMan->fChoicing )
198 return 0;
199 if ( pNode == pOld )
200 return 1;
201 // skip the visited node
202 if ( pNode->TravId == pMan->nTravIds )
203 return 0;
204 pNode->TravId = pMan->nTravIds;
205 // check the children
206 if ( Fraig_CheckTfi_rec( pMan, Fraig_Regular(pNode->p1), pOld ) )
207 return 1;
208 if ( Fraig_CheckTfi_rec( pMan, Fraig_Regular(pNode->p2), pOld ) )
209 return 1;
210 // check equivalent nodes
211 return Fraig_CheckTfi_rec( pMan, pNode->pNextE, pOld );
212}
213
214
227{
228 Fraig_NodeVec_t * vNodes;
229 int RetValue;
230 vNodes = Fraig_DfsOne( pMan, pNew, 1 );
231 RetValue = (pOld->TravId == pMan->nTravIds);
232 Fraig_NodeVecFree( vNodes );
233 return RetValue;
234}
235
252{
253 Fraig_NodeVec_t * vNodes;
254 Fraig_Node_t * pNodeR;
255 int i;
256 // collect the nodes reachable
257 vNodes = Fraig_Dfs( p, 0 );
258 // clean the fanouts field
259 for ( i = 0; i < vNodes->nSize; i++ )
260 {
261 vNodes->pArray[i]->nFanouts = 0;
262 vNodes->pArray[i]->pData0 = NULL;
263 }
264 // mark reachable nodes by setting the two-bit counter pNode->nFans
265 for ( i = 0; i < vNodes->nSize; i++ )
266 {
267 pNodeR = Fraig_Regular(vNodes->pArray[i]->p1);
268 if ( pNodeR && ++pNodeR->nFanouts == 3 )
269 pNodeR->nFanouts = 2;
270 pNodeR = Fraig_Regular(vNodes->pArray[i]->p2);
271 if ( pNodeR && ++pNodeR->nFanouts == 3 )
272 pNodeR->nFanouts = 2;
273 }
274 Fraig_NodeVecFree( vNodes );
275}
276
288int Fraig_BitStringCountOnes( unsigned * pString, int nWords )
289{
290 unsigned char * pSuppBytes = (unsigned char *)pString;
291 int i, nOnes, nBytes = sizeof(unsigned) * nWords;
292 // count the number of ones in the simulation vector
293 for ( i = nOnes = 0; i < nBytes; i++ )
294 nOnes += bit_count[pSuppBytes[i]];
295 return nOnes;
296}
297
313{
314 Fraig_Node_t * pNode;
315 Fraig_NodeVec_t * pVec;
316 int i;
317 pVec = Fraig_Dfs( p, 0 );
318 for ( i = 0; i < pVec->nSize; i++ )
319 {
320 pNode = pVec->pArray[i];
321 if ( Fraig_NodeIsVar(pNode) )
322 {
323 if ( pNode->pRepr )
324 printf( "Primary input %d is a secondary node.\n", pNode->Num );
325 }
326 else if ( Fraig_NodeIsConst(pNode) )
327 {
328 if ( pNode->pRepr )
329 printf( "Constant 1 %d is a secondary node.\n", pNode->Num );
330 }
331 else
332 {
333 if ( pNode->pRepr )
334 printf( "Internal node %d is a secondary node.\n", pNode->Num );
335 if ( Fraig_Regular(pNode->p1)->pRepr )
336 printf( "Internal node %d has first fanin %d that is a secondary node.\n",
337 pNode->Num, Fraig_Regular(pNode->p1)->Num );
338 if ( Fraig_Regular(pNode->p2)->pRepr )
339 printf( "Internal node %d has second fanin %d that is a secondary node.\n",
340 pNode->Num, Fraig_Regular(pNode->p2)->Num );
341 }
342 }
343 Fraig_NodeVecFree( pVec );
344 return 1;
345}
346
359{
360 Fraig_NodeVec_t * vNodes;
361 Fraig_Node_t * pTemp;
362 int fCompl1, fCompl2, i;
363
364 vNodes = Fraig_DfsOne( p, pNode, 0 );
365 for ( i = 0; i < vNodes->nSize; i++ )
366 {
367 pTemp = vNodes->pArray[i];
368 if ( Fraig_NodeIsVar(pTemp) )
369 {
370 printf( "%3d : PI ", pTemp->Num );
371 Fraig_PrintBinary( stdout, (unsigned *)&pTemp->puSimR, 20 );
372 printf( " " );
373 Fraig_PrintBinary( stdout, (unsigned *)&pTemp->puSimD, 20 );
374 printf( " %d\n", pTemp->fInv );
375 continue;
376 }
377
378 fCompl1 = Fraig_IsComplement(pTemp->p1);
379 fCompl2 = Fraig_IsComplement(pTemp->p2);
380 printf( "%3d : %c%3d %c%3d ", pTemp->Num,
381 (fCompl1? '-':'+'), Fraig_Regular(pTemp->p1)->Num,
382 (fCompl2? '-':'+'), Fraig_Regular(pTemp->p2)->Num );
383 Fraig_PrintBinary( stdout, (unsigned *)&pTemp->puSimR, 20 );
384 printf( " " );
385 Fraig_PrintBinary( stdout, (unsigned *)&pTemp->puSimD, 20 );
386 printf( " %d\n", pTemp->fInv );
387 }
388 Fraig_NodeVecFree( vNodes );
389}
390
402void Fraig_PrintBinary( FILE * pFile, unsigned * pSign, int nBits )
403{
404 int Remainder, nWords;
405 int w, i;
406
407 Remainder = (nBits%(sizeof(unsigned)*8));
408 nWords = (nBits/(sizeof(unsigned)*8)) + (Remainder>0);
409
410 for ( w = nWords-1; w >= 0; w-- )
411 for ( i = ((w == nWords-1 && Remainder)? Remainder-1: 31); i >= 0; i-- )
412 fprintf( pFile, "%c", '0' + (int)((pSign[w] & (1<<i)) > 0) );
413
414// fprintf( pFile, "\n" );
415}
416
429{
430 int nLevelMax, i;
431 nLevelMax = 0;
432 for ( i = 0; i < pMan->vOutputs->nSize; i++ )
433 nLevelMax = nLevelMax > Fraig_Regular(pMan->vOutputs->pArray[i])->Level?
434 nLevelMax : Fraig_Regular(pMan->vOutputs->pArray[i])->Level;
435 return nLevelMax;
436}
437
449int Fraig_MappingUpdateLevel_rec( Fraig_Man_t * pMan, Fraig_Node_t * pNode, int fMaximum )
450{
451 Fraig_Node_t * pTemp;
452 int Level1, Level2, LevelE;
453 assert( !Fraig_IsComplement(pNode) );
454 if ( !Fraig_NodeIsAnd(pNode) )
455 return pNode->Level;
456 // skip the visited node
457 if ( pNode->TravId == pMan->nTravIds )
458 return pNode->Level;
459 pNode->TravId = pMan->nTravIds;
460 // compute levels of the children nodes
461 Level1 = Fraig_MappingUpdateLevel_rec( pMan, Fraig_Regular(pNode->p1), fMaximum );
462 Level2 = Fraig_MappingUpdateLevel_rec( pMan, Fraig_Regular(pNode->p2), fMaximum );
463 pNode->Level = 1 + Abc_MaxInt( Level1, Level2 );
464 if ( pNode->pNextE )
465 {
466 LevelE = Fraig_MappingUpdateLevel_rec( pMan, pNode->pNextE, fMaximum );
467 if ( fMaximum )
468 {
469 if ( pNode->Level < LevelE )
470 pNode->Level = LevelE;
471 }
472 else
473 {
474 if ( pNode->Level > LevelE )
475 pNode->Level = LevelE;
476 }
477 // set the level of all equivalent nodes to be the same minimum
478 if ( pNode->pRepr == NULL ) // the primary node
479 for ( pTemp = pNode->pNextE; pTemp; pTemp = pTemp->pNextE )
480 pTemp->Level = pNode->Level;
481 }
482 return pNode->Level;
483}
484
499void Fraig_MappingSetChoiceLevels( Fraig_Man_t * pMan, int fMaximum )
500{
501 int i;
502 pMan->nTravIds++;
503 for ( i = 0; i < pMan->vOutputs->nSize; i++ )
504 Fraig_MappingUpdateLevel_rec( pMan, Fraig_Regular(pMan->vOutputs->pArray[i]), fMaximum );
505}
506
521{
522 Fraig_Node_t * pNode, * pTemp;
523 int nChoiceNodes, nChoices;
524 int i, LevelMax1, LevelMax2;
525
526 // report the number of levels
527 LevelMax1 = Fraig_GetMaxLevel( pMan );
529 LevelMax2 = Fraig_GetMaxLevel( pMan );
530
531 // report statistics about choices
532 nChoiceNodes = nChoices = 0;
533 for ( i = 0; i < pMan->vNodes->nSize; i++ )
534 {
535 pNode = pMan->vNodes->pArray[i];
536 if ( pNode->pRepr == NULL && pNode->pNextE != NULL )
537 { // this is a choice node = the primary node that has equivalent nodes
538 nChoiceNodes++;
539 for ( pTemp = pNode; pTemp; pTemp = pTemp->pNextE )
540 nChoices++;
541 }
542 }
543 printf( "Maximum level: Original = %d. Reduced due to choices = %d.\n", LevelMax1, LevelMax2 );
544 printf( "Choice stats: Choice nodes = %d. Total choices = %d.\n", nChoiceNodes, nChoices );
545}
546
559{
560 Fraig_Node_t * pNode1, * pNode2;
561 // make the node regular (it does not matter for EXOR/NEXOR)
562 pNode = Fraig_Regular(pNode);
563 // if the node or its children are not ANDs or not compl, this cannot be EXOR type
564 if ( !Fraig_NodeIsAnd(pNode) )
565 return 0;
566 if ( !Fraig_NodeIsAnd(pNode->p1) || !Fraig_IsComplement(pNode->p1) )
567 return 0;
568 if ( !Fraig_NodeIsAnd(pNode->p2) || !Fraig_IsComplement(pNode->p2) )
569 return 0;
570
571 // get children
572 pNode1 = Fraig_Regular(pNode->p1);
573 pNode2 = Fraig_Regular(pNode->p2);
574 assert( pNode1->Num < pNode2->Num );
575
576 // compare grandchildren
577 return pNode1->p1 == Fraig_Not(pNode2->p1) && pNode1->p2 == Fraig_Not(pNode2->p2);
578}
579
592{
593 Fraig_Node_t * pNode1, * pNode2;
594
595 // make the node regular (it does not matter for EXOR/NEXOR)
596 pNode = Fraig_Regular(pNode);
597 // if the node or its children are not ANDs or not compl, this cannot be EXOR type
598 if ( !Fraig_NodeIsAnd(pNode) )
599 return 0;
600 if ( !Fraig_NodeIsAnd(pNode->p1) || !Fraig_IsComplement(pNode->p1) )
601 return 0;
602 if ( !Fraig_NodeIsAnd(pNode->p2) || !Fraig_IsComplement(pNode->p2) )
603 return 0;
604
605 // get children
606 pNode1 = Fraig_Regular(pNode->p1);
607 pNode2 = Fraig_Regular(pNode->p2);
608 assert( pNode1->Num < pNode2->Num );
609
610 // compare grandchildren
611 // node is an EXOR/NEXOR
612 if ( pNode1->p1 == Fraig_Not(pNode2->p1) && pNode1->p2 == Fraig_Not(pNode2->p2) )
613 return 1;
614
615 // otherwise the node is MUX iff it has a pair of equal grandchildren
616 return pNode1->p1 == Fraig_Not(pNode2->p1) ||
617 pNode1->p1 == Fraig_Not(pNode2->p2) ||
618 pNode1->p2 == Fraig_Not(pNode2->p1) ||
619 pNode1->p2 == Fraig_Not(pNode2->p2);
620}
621
634{
635 Fraig_Node_t * pNode1;
636 assert( !Fraig_IsComplement(pNode) );
638 assert( Fraig_IsComplement(pNode->p1) );
639 // get children
640 pNode1 = Fraig_Regular(pNode->p1);
641 return Fraig_IsComplement(pNode1->p1) == Fraig_IsComplement(pNode1->p2);
642}
643
659{
660 Fraig_Node_t * pNode1, * pNode2;
661 assert( !Fraig_IsComplement(pNode) );
662 assert( Fraig_NodeIsMuxType(pNode) );
663 // get children
664 pNode1 = Fraig_Regular(pNode->p1);
665 pNode2 = Fraig_Regular(pNode->p2);
666 // find the control variable
667 if ( pNode1->p1 == Fraig_Not(pNode2->p1) )
668 {
669 if ( Fraig_IsComplement(pNode1->p1) )
670 { // pNode2->p1 is positive phase of C
671 *ppNodeT = Fraig_Not(pNode2->p2);
672 *ppNodeE = Fraig_Not(pNode1->p2);
673 return pNode2->p1;
674 }
675 else
676 { // pNode1->p1 is positive phase of C
677 *ppNodeT = Fraig_Not(pNode1->p2);
678 *ppNodeE = Fraig_Not(pNode2->p2);
679 return pNode1->p1;
680 }
681 }
682 else if ( pNode1->p1 == Fraig_Not(pNode2->p2) )
683 {
684 if ( Fraig_IsComplement(pNode1->p1) )
685 { // pNode2->p2 is positive phase of C
686 *ppNodeT = Fraig_Not(pNode2->p1);
687 *ppNodeE = Fraig_Not(pNode1->p2);
688 return pNode2->p2;
689 }
690 else
691 { // pNode1->p1 is positive phase of C
692 *ppNodeT = Fraig_Not(pNode1->p2);
693 *ppNodeE = Fraig_Not(pNode2->p1);
694 return pNode1->p1;
695 }
696 }
697 else if ( pNode1->p2 == Fraig_Not(pNode2->p1) )
698 {
699 if ( Fraig_IsComplement(pNode1->p2) )
700 { // pNode2->p1 is positive phase of C
701 *ppNodeT = Fraig_Not(pNode2->p2);
702 *ppNodeE = Fraig_Not(pNode1->p1);
703 return pNode2->p1;
704 }
705 else
706 { // pNode1->p2 is positive phase of C
707 *ppNodeT = Fraig_Not(pNode1->p1);
708 *ppNodeE = Fraig_Not(pNode2->p2);
709 return pNode1->p2;
710 }
711 }
712 else if ( pNode1->p2 == Fraig_Not(pNode2->p2) )
713 {
714 if ( Fraig_IsComplement(pNode1->p2) )
715 { // pNode2->p2 is positive phase of C
716 *ppNodeT = Fraig_Not(pNode2->p1);
717 *ppNodeE = Fraig_Not(pNode1->p1);
718 return pNode2->p2;
719 }
720 else
721 { // pNode1->p2 is positive phase of C
722 *ppNodeT = Fraig_Not(pNode1->p1);
723 *ppNodeE = Fraig_Not(pNode2->p1);
724 return pNode1->p2;
725 }
726 }
727 assert( 0 ); // this is not MUX
728 return NULL;
729}
730
743{
744 int i, nExors;
745 nExors = 0;
746 for ( i = 0; i < pMan->vNodes->nSize; i++ )
747 nExors += Fraig_NodeIsExorType( pMan->vNodes->pArray[i] );
748 return nExors;
749
750}
751
764{
765 int i, nMuxes;
766 nMuxes = 0;
767 for ( i = 0; i < pMan->vNodes->nSize; i++ )
768 nMuxes += Fraig_NodeIsMuxType( pMan->vNodes->pArray[i] );
769 return nMuxes;
770
771}
772
785{
786 unsigned * pUnsigned1, * pUnsigned2;
787 int i;
788
789 // compare random siminfo
790 pUnsigned1 = pNode1->puSimR;
791 pUnsigned2 = pNode2->puSimR;
792 for ( i = 0; i < pMan->nWordsRand; i++ )
793 if ( pUnsigned1[i] & ~pUnsigned2[i] )
794 return 0;
795
796 // compare systematic siminfo
797 pUnsigned1 = pNode1->puSimD;
798 pUnsigned2 = pNode2->puSimD;
799 for ( i = 0; i < pMan->iWordStart; i++ )
800 if ( pUnsigned1[i] & ~pUnsigned2[i] )
801 return 0;
802
803 return 1;
804}
805
818{
819 int * pVars, nVars, i, Counter;
820
821 nVars = Msat_IntVecReadSize(vVarNums);
822 pVars = Msat_IntVecReadArray(vVarNums);
823 Counter = 0;
824 for ( i = 0; i < nVars; i++ )
825 Counter += Fraig_NodeIsVar( p->vNodes->pArray[pVars[i]] );
826 return Counter;
827}
828
829
830
843{
844 Fraig_NodeVec_t * vPivots;
845 Fraig_Node_t * pNode, * pNode2;
846 int i, k, Counter, nProved;
847 abctime clk;
848
849 vPivots = Fraig_NodeVecAlloc( 1000 );
850 for ( i = 0; i < pMan->vNodes->nSize; i++ )
851 {
852 pNode = pMan->vNodes->pArray[i];
853
854 if ( pNode->nOnes == 0 || pNode->nOnes == (unsigned)pMan->nWordsRand * 32 )
855 continue;
856
857 if ( pNode->nRefs > 5 )
858 {
859 Fraig_NodeVecPush( vPivots, pNode );
860// printf( "Node %6d : nRefs = %2d Level = %3d.\n", pNode->Num, pNode->nRefs, pNode->Level );
861 }
862 }
863 printf( "Total nodes = %d. Referenced nodes = %d.\n", pMan->vNodes->nSize, vPivots->nSize );
864
865clk = Abc_Clock();
866 // count implications
867 Counter = nProved = 0;
868 for ( i = 0; i < vPivots->nSize; i++ )
869 for ( k = i+1; k < vPivots->nSize; k++ )
870 {
871 pNode = vPivots->pArray[i];
872 pNode2 = vPivots->pArray[k];
873 if ( Fraig_NodeSimsContained( pMan, pNode, pNode2 ) )
874 {
875 if ( Fraig_NodeIsImplification( pMan, pNode, pNode2, -1 ) )
876 nProved++;
877 Counter++;
878 }
879 else if ( Fraig_NodeSimsContained( pMan, pNode2, pNode ) )
880 {
881 if ( Fraig_NodeIsImplification( pMan, pNode2, pNode, -1 ) )
882 nProved++;
883 Counter++;
884 }
885 }
886 printf( "Number of candidate pairs = %d. Proved = %d.\n", Counter, nProved );
887//ABC_PRT( "Time", Abc_Clock() - clk );
888 return 0;
889}
890
891
906{
907 int RetValue1, RetValue2;
908 if ( Fraig_Regular(pOld) == Fraig_Regular(pNew) )
909 return (pOld == pNew)? 1 : -1;
910 if ( Fraig_IsComplement(pOld) || Fraig_NodeIsVar(pOld) )
911 return 0;
912 RetValue1 = Fraig_NodeIsInSupergate( pOld->p1, pNew );
913 RetValue2 = Fraig_NodeIsInSupergate( pOld->p2, pNew );
914 if ( RetValue1 == -1 || RetValue2 == -1 )
915 return -1;
916 if ( RetValue1 == 1 || RetValue2 == 1 )
917 return 1;
918 return 0;
919}
920
921
933void Fraig_CollectSupergate_rec( Fraig_Node_t * pNode, Fraig_NodeVec_t * vSuper, int fFirst, int fStopAtMux )
934{
935 // if the new node is complemented or a PI, another gate begins
936// if ( Fraig_IsComplement(pNode) || Fraig_NodeIsVar(pNode) || Fraig_NodeIsMuxType(pNode) )
937 if ( (!fFirst && Fraig_Regular(pNode)->nRefs > 1) ||
938 Fraig_IsComplement(pNode) || Fraig_NodeIsVar(pNode) ||
939 (fStopAtMux && Fraig_NodeIsMuxType(pNode)) )
940 {
941 Fraig_NodeVecPushUnique( vSuper, pNode );
942 return;
943 }
944 // go through the branches
945 Fraig_CollectSupergate_rec( pNode->p1, vSuper, 0, fStopAtMux );
946 Fraig_CollectSupergate_rec( pNode->p2, vSuper, 0, fStopAtMux );
947}
948
961{
962 Fraig_NodeVec_t * vSuper;
963 vSuper = Fraig_NodeVecAlloc( 8 );
964 Fraig_CollectSupergate_rec( pNode, vSuper, 1, fStopAtMux );
965 return vSuper;
966}
967
968
981{
982 pMan->nTravIds2++;
983}
984
997{
998 pNode->TravId2 = pMan->nTravIds2;
999}
1000
1013{
1014 return pNode->TravId2 == pMan->nTravIds2;
1015}
1016
1029{
1030 return pNode->TravId2 == pMan->nTravIds2 - 1;
1031}
1032
1036
1037
1039
int nWords
Definition abcNpn.c:127
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Cube * p
Definition exorList.c:222
int Fraig_NodeIsImplification(Fraig_Man_t *p, Fraig_Node_t *pOld, Fraig_Node_t *pNew, int nBTLimit)
Definition fraigSat.c:551
int Fraig_ManCountExors(Fraig_Man_t *pMan)
Definition fraigUtil.c:742
int Fraig_NodeIsExorType(Fraig_Node_t *pNode)
Definition fraigUtil.c:558
int Fraig_BitStringCountOnes(unsigned *pString, int nWords)
Definition fraigUtil.c:288
Fraig_NodeVec_t * Fraig_CollectSupergate(Fraig_Node_t *pNode, int fStopAtMux)
Definition fraigUtil.c:960
int Fraig_NodeSimsContained(Fraig_Man_t *pMan, Fraig_Node_t *pNode1, Fraig_Node_t *pNode2)
Definition fraigUtil.c:784
void Fraig_PrintBinary(FILE *pFile, unsigned *pSign, int nBits)
Definition fraigUtil.c:402
void Fraig_ManMarkRealFanouts(Fraig_Man_t *p)
Definition fraigUtil.c:251
void Fraig_ManReportChoices(Fraig_Man_t *pMan)
Definition fraigUtil.c:520
void Fraig_NodeSetTravIdCurrent(Fraig_Man_t *pMan, Fraig_Node_t *pNode)
Definition fraigUtil.c:996
int Fraig_MappingUpdateLevel_rec(Fraig_Man_t *pMan, Fraig_Node_t *pNode, int fMaximum)
Definition fraigUtil.c:449
int Fraig_NodeIsExor(Fraig_Node_t *pNode)
Definition fraigUtil.c:633
void Fraig_PrintNode(Fraig_Man_t *p, Fraig_Node_t *pNode)
Definition fraigUtil.c:358
int Fraig_ManCheckConsistency(Fraig_Man_t *p)
Definition fraigUtil.c:312
int Fraig_NodeIsMuxType(Fraig_Node_t *pNode)
Definition fraigUtil.c:591
int Fraig_NodeIsInSupergate(Fraig_Node_t *pOld, Fraig_Node_t *pNew)
Definition fraigUtil.c:905
int Fraig_NodeIsTravIdPrevious(Fraig_Man_t *pMan, Fraig_Node_t *pNode)
Definition fraigUtil.c:1028
void Fraig_ManIncrementTravId(Fraig_Man_t *pMan)
Definition fraigUtil.c:980
int Fraig_GetMaxLevel(Fraig_Man_t *pMan)
Definition fraigUtil.c:428
int Fraig_NodeIsTravIdCurrent(Fraig_Man_t *pMan, Fraig_Node_t *pNode)
Definition fraigUtil.c:1012
void Fraig_CollectSupergate_rec(Fraig_Node_t *pNode, Fraig_NodeVec_t *vSuper, int fFirst, int fStopAtMux)
Definition fraigUtil.c:933
int Fraig_CountNodes(Fraig_Man_t *pMan, int fEquiv)
Definition fraigUtil.c:152
int Fraig_ManCountMuxes(Fraig_Man_t *pMan)
Definition fraigUtil.c:763
int Fraig_CheckTfi2(Fraig_Man_t *pMan, Fraig_Node_t *pOld, Fraig_Node_t *pNew)
Definition fraigUtil.c:226
Fraig_NodeVec_t * Fraig_DfsOne(Fraig_Man_t *pMan, Fraig_Node_t *pNode, int fEquiv)
Definition fraigUtil.c:80
Fraig_NodeVec_t * Fraig_DfsNodes(Fraig_Man_t *pMan, Fraig_Node_t **ppNodes, int nNodes, int fEquiv)
Definition fraigUtil.c:100
int Fraig_CheckTfi(Fraig_Man_t *pMan, Fraig_Node_t *pOld, Fraig_Node_t *pNew)
Definition fraigUtil.c:173
int Fraig_ManPrintRefs(Fraig_Man_t *pMan)
Definition fraigUtil.c:842
int Fraig_CountPis(Fraig_Man_t *p, Msat_IntVec_t *vVarNums)
Definition fraigUtil.c:817
void Fraig_MappingSetChoiceLevels(Fraig_Man_t *pMan, int fMaximum)
Definition fraigUtil.c:499
Fraig_Node_t * Fraig_NodeRecognizeMux(Fraig_Node_t *pNode, Fraig_Node_t **ppNodeT, Fraig_Node_t **ppNodeE)
Definition fraigUtil.c:658
Fraig_NodeVec_t * Fraig_Dfs(Fraig_Man_t *pMan, int fEquiv)
FUNCTION DEFINITIONS ///.
Definition fraigUtil.c:58
void Fraig_NodeVecFree(Fraig_NodeVec_t *p)
Definition fraigVec.c:66
#define Fraig_IsComplement(p)
GLOBAL VARIABLES ///.
Definition fraig.h:107
int Fraig_NodeIsConst(Fraig_Node_t *p)
Definition fraigApi.c:151
#define Fraig_Regular(p)
Definition fraig.h:108
#define Fraig_Not(p)
Definition fraig.h:109
int Fraig_NodeVecPushUnique(Fraig_NodeVec_t *p, Fraig_Node_t *Entry)
Definition fraigVec.c:212
struct Fraig_NodeVecStruct_t_ Fraig_NodeVec_t
Definition fraig.h:42
int Fraig_NodeIsAnd(Fraig_Node_t *p)
Definition fraigApi.c:153
typedefABC_NAMESPACE_HEADER_START struct Fraig_ManStruct_t_ Fraig_Man_t
INCLUDES ///.
Definition fraig.h:40
Fraig_NodeVec_t * Fraig_NodeVecAlloc(int nCap)
DECLARATIONS ///.
Definition fraigVec.c:43
struct Fraig_NodeStruct_t_ Fraig_Node_t
Definition fraig.h:41
void Fraig_NodeVecPush(Fraig_NodeVec_t *p, Fraig_Node_t *Entry)
Definition fraigVec.c:189
int Fraig_NodeIsVar(Fraig_Node_t *p)
Definition fraigApi.c:152
struct Msat_IntVec_t_ Msat_IntVec_t
Definition msat.h:45
int Msat_IntVecReadSize(Msat_IntVec_t *p)
Definition msatVec.c:233
int * Msat_IntVecReadArray(Msat_IntVec_t *p)
Definition msatVec.c:217
Fraig_Node_t * p2
Definition fraigInt.h:233
unsigned * puSimR
Definition fraigInt.h:247
Fraig_Node_t * pRepr
Definition fraigInt.h:242
Fraig_Node_t * p1
Definition fraigInt.h:232
Fraig_Node_t * pNextE
Definition fraigInt.h:241
unsigned * puSimD
Definition fraigInt.h:248
Fraig_Node_t * pData0
Definition fraigInt.h:251
Fraig_Node_t ** pArray
Definition fraigInt.h:267
#define assert(ex)
Definition util_old.h:213