ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcUtil.c
Go to the documentation of this file.
1
20
21#include "abc.h"
22#include "base/main/main.h"
23#include "map/mio/mio.h"
24#include "bool/dec/dec.h"
25#include "opt/fxu/fxu.h"
26#include "aig/miniaig/ndr.h"
27#include "misc/util/utilTruth.h"
28
29#ifdef ABC_USE_CUDD
30#include "bdd/extrab/extraBdd.h"
31#endif
32
34
35
39
43
55void * Abc_NtkAttrFree( Abc_Ntk_t * pNtk, int Attr, int fFreeMan )
56{
57 void * pUserMan;
58 Vec_Att_t * pAttrMan;
59 pAttrMan = (Vec_Att_t *)Vec_PtrEntry( pNtk->vAttrs, Attr );
60 Vec_PtrWriteEntry( pNtk->vAttrs, Attr, NULL );
61 pUserMan = Vec_AttFree( pAttrMan, fFreeMan );
62 return pUserMan;
63}
64
77{
78 Abc_Obj_t * pObj, * pTerm;
79 int i, k;
80 Vec_PtrClear( pNtk->vCis );
81 Vec_PtrClear( pNtk->vCos );
82 Abc_NtkForEachPi( pNtk, pObj, i )
83 Vec_PtrPush( pNtk->vCis, pObj );
84 Abc_NtkForEachPo( pNtk, pObj, i )
85 Vec_PtrPush( pNtk->vCos, pObj );
86 Abc_NtkForEachBox( pNtk, pObj, i )
87 {
88 if ( Abc_ObjIsLatch(pObj) )
89 continue;
90 Abc_ObjForEachFanin( pObj, pTerm, k )
91 Vec_PtrPush( pNtk->vCos, pTerm );
92 Abc_ObjForEachFanout( pObj, pTerm, k )
93 Vec_PtrPush( pNtk->vCis, pTerm );
94 }
95 Abc_NtkForEachBox( pNtk, pObj, i )
96 {
97 if ( !Abc_ObjIsLatch(pObj) )
98 continue;
99 Abc_ObjForEachFanin( pObj, pTerm, k )
100 Vec_PtrPush( pNtk->vCos, pTerm );
101 Abc_ObjForEachFanout( pObj, pTerm, k )
102 Vec_PtrPush( pNtk->vCis, pTerm );
103 }
104}
105
118{
119 Abc_Obj_t * pNode;
120 int i, nCubes = 0;
121 assert( Abc_NtkHasSop(pNtk) );
122 Abc_NtkForEachNode( pNtk, pNode, i )
123 {
124 if ( Abc_NodeIsConst(pNode) )
125 continue;
126 assert( pNode->pData );
127 nCubes += Abc_SopGetCubeNum( (char *)pNode->pData );
128 }
129 return nCubes;
130}
131
144{
145 Abc_Obj_t * pNode;
146 int i;
147 word nCubes, nCubePairs = 0;
148 assert( Abc_NtkHasSop(pNtk) );
149 Abc_NtkForEachNode( pNtk, pNode, i )
150 {
151 if ( Abc_NodeIsConst(pNode) )
152 continue;
153 assert( pNode->pData );
154 nCubes = (word)Abc_SopGetCubeNum( (char *)pNode->pData );
155 if ( nCubes > 1 )
156 nCubePairs += nCubes * (nCubes - 1) / 2;
157 }
158 return (int)(nCubePairs > (1<<30) ? (1<<30) : nCubePairs);
159}
160
173{
174 Abc_Obj_t * pNode;
175 int i, nLits = 0;
176 assert( Abc_NtkHasSop(pNtk) );
177 Abc_NtkForEachNode( pNtk, pNode, i )
178 {
179 assert( pNode->pData );
180 nLits += Abc_SopGetLitNum( (char *)pNode->pData );
181 }
182 return nLits;
183}
184
197{
198 Dec_Graph_t * pFactor;
199 Abc_Obj_t * pNode;
200 int nNodes, i;
201 assert( Abc_NtkHasSop(pNtk) );
202 nNodes = 0;
203 Abc_NtkForEachNode( pNtk, pNode, i )
204 {
205 if ( Abc_NodeIsConst(pNode) )
206 continue;
207 pFactor = Dec_Factor( (char *)pNode->pData );
208 nNodes += 1 + Dec_GraphNodeNum(pFactor);
209 Dec_GraphFree( pFactor );
210 }
211 return nNodes;
212}
213
226{
227 Abc_Obj_t * pNode;
228 int nNodes, i;
229 assert( Abc_NtkIsStrash(pNtk) );
230 nNodes = 0;
231 Abc_NtkForEachNode( pNtk, pNode, i )
232 nNodes += (int)(Abc_ObjFanoutNum(pNode) > 1);
233 return nNodes;
234}
235
248{
249 int nNodes = 0;
250#ifdef ABC_USE_CUDD
251 Abc_Obj_t * pNode;
252 int i;
253 assert( Abc_NtkIsBddLogic(pNtk) );
254 Abc_NtkForEachNode( pNtk, pNode, i )
255 {
256 assert( pNode->pData );
257 if ( Abc_ObjFaninNum(pNode) < 2 )
258 continue;
259 nNodes += pNode->pData? -1 + Cudd_DagSize( (DdNode *)pNode->pData ) : 0;
260 }
261#endif
262 return nNodes;
263}
264
277{
278 Abc_Obj_t * pNode;
279 int i, nNodes = 0;
280 assert( Abc_NtkIsAigLogic(pNtk) );
281 Abc_NtkForEachNode( pNtk, pNode, i )
282 {
283 assert( pNode->pData );
284 if ( Abc_ObjFaninNum(pNode) < 2 )
285 continue;
286//printf( "%d ", Hop_DagSize( pNode->pData ) );
287 nNodes += pNode->pData? Hop_DagSize( (Hop_Obj_t *)pNode->pData ) : 0;
288 }
289 return nNodes;
290}
291
304{
305 int nClauses = 0;
306#ifdef ABC_USE_CUDD
307 extern int Abc_CountZddCubes( DdManager * dd, DdNode * zCover );
308 Abc_Obj_t * pNode;
309 DdNode * bCover, * zCover, * bFunc;
310 DdManager * dd = (DdManager *)pNtk->pManFunc;
311 int i;
312 assert( Abc_NtkIsBddLogic(pNtk) );
313 Abc_NtkForEachNode( pNtk, pNode, i )
314 {
315 assert( pNode->pData );
316 bFunc = (DdNode *)pNode->pData;
317
318 bCover = Cudd_zddIsop( dd, bFunc, bFunc, &zCover );
319 Cudd_Ref( bCover );
320 Cudd_Ref( zCover );
321 nClauses += Abc_CountZddCubes( dd, zCover );
322 Cudd_RecursiveDeref( dd, bCover );
323 Cudd_RecursiveDerefZdd( dd, zCover );
324
325 bCover = Cudd_zddIsop( dd, Cudd_Not(bFunc), Cudd_Not(bFunc), &zCover );
326 Cudd_Ref( bCover );
327 Cudd_Ref( zCover );
328 nClauses += Abc_CountZddCubes( dd, zCover );
329 Cudd_RecursiveDeref( dd, bCover );
330 Cudd_RecursiveDerefZdd( dd, zCover );
331 }
332#endif
333 return nClauses;
334}
335
348{
349 Abc_Obj_t * pObj;
350 double TotalArea;
351 int i;
352 assert( Abc_NtkHasMapping(pNtk) );
353 TotalArea = 0.0;
354 Abc_NtkForEachNode( pNtk, pObj, i )
355 {
356 if ( Abc_ObjIsBarBuf(pObj) )
357 continue;
358// assert( pObj->pData );
359 if ( pObj->pData == NULL )
360 {
361 printf( "Node without mapping is encountered.\n" );
362 continue;
363 }
364 TotalArea += Mio_GateReadArea( (Mio_Gate_t *)pObj->pData );
365 // assuming that twin gates follow each other
366 if ( Abc_NtkFetchTwinNode(pObj) )
367 i++;
368 }
369 return TotalArea;
370}
371
384{
385 Abc_Obj_t * pNode;
386 int i, Counter = 0;
387 Abc_NtkForEachNode( pNtk, pNode, i )
388 Counter += pNode->fExor;
389 return Counter;
390}
391
404{
405 Abc_Obj_t * pNode;
406 int i, Counter = 0;
407 Abc_NtkForEachNode( pNtk, pNode, i )
408 Counter += Abc_NodeIsMuxType(pNode);
409 return Counter;
410}
411
424{
425 Abc_Obj_t * pNode;
426 int i, Counter = 0;
427 Abc_NtkForEachNode( pNtk, pNode, i )
428 Counter += (Abc_ObjFaninNum(pNode) == 1);
429 return Counter;
430}
431
444{
445 Abc_Obj_t * pNode;
446 int i, Counter = 0;
447 Abc_NtkForEachNode( pNtk, pNode, i )
448 Counter += (Abc_ObjFaninNum(pNode) > 1);
449 return Counter;
450}
451
464{
465 Abc_Obj_t * pNode;
466 int i, Counter;
467 if ( !Abc_NtkIsStrash(pNtk) )
468 return 0;
469 Counter = 0;
470 Abc_NtkForEachNode( pNtk, pNode, i )
471 Counter += Abc_AigNodeIsChoice( pNode );
472 return Counter;
473}
474
487{
488 Abc_Obj_t * pNode;
489 int i, nFaninsMax = 0;
490 Abc_NtkForEachNode( pNtk, pNode, i )
491 {
492 if ( nFaninsMax < Abc_ObjFaninNum(pNode) )
493 nFaninsMax = Abc_ObjFaninNum(pNode);
494 }
495 return nFaninsMax;
496}
498{
499 Abc_Obj_t * pNode;
500 int i, nFaninsMax = 0;
501 Abc_NtkForEachNode( pNtk, pNode, i )
502 {
503 if ( nFaninsMax < Abc_ObjFanoutNum(pNode) )
504 nFaninsMax = Abc_ObjFanoutNum(pNode);
505 }
506 return nFaninsMax;
507}
508
521{
522 Abc_Obj_t * pNode;
523 int i, nFanins = 0;
524 Abc_NtkForEachNode( pNtk, pNode, i )
525 nFanins += Abc_ObjFaninNum(pNode);
526 return nFanins;
527}
528
541{
542 Abc_Obj_t * pObj;
543 int i;
544 Abc_NtkForEachObj( pNtk, pObj, i )
545 pObj->pCopy = NULL;
546}
548{
549 Abc_Obj_t * pObj;
550 int i;
551 Abc_NtkCleanCopy( pNtk );
552 Abc_NtkForEachBox( pNtk, pObj, i )
553 Abc_NtkCleanCopy_rec( Abc_ObjModel(pObj) );
554}
555
568{
569 Abc_Obj_t * pObj;
570 int i;
571 Abc_NtkForEachObj( pNtk, pObj, i )
572 pObj->pData = NULL;
573}
574
587{
588 Abc_Obj_t * pObj;
589 int i;
590 Abc_NtkForEachObj( pNtk, pObj, i )
591 pObj->iTemp = -1;
592}
593
606{
607 Abc_Obj_t * pObj;
608 int i, Counter = 0;
609 Abc_NtkForEachObj( pNtk, pObj, i )
610 {
611 if ( Abc_ObjIsNode(pObj) )
612 Counter += (pObj->pCopy != NULL);
613 }
614 return Counter;
615}
616
629{
630 Vec_Ptr_t * vCopies;
631 Abc_Obj_t * pObj;
632 int i;
633 vCopies = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) );
634 Abc_NtkForEachObj( pNtk, pObj, i )
635 Vec_PtrWriteEntry( vCopies, i, pObj->pCopy );
636 return vCopies;
637}
638
650void Abc_NtkLoadCopy( Abc_Ntk_t * pNtk, Vec_Ptr_t * vCopies )
651{
652 Abc_Obj_t * pObj;
653 int i;
654 Abc_NtkForEachObj( pNtk, pObj, i )
655 pObj->pCopy = (Abc_Obj_t *)Vec_PtrEntry( vCopies, i );
656}
657
670{
671 Abc_Obj_t * pObj;
672 int i;
673 Abc_NtkForEachObj( pNtk, pObj, i )
674 pObj->pNext = NULL;
675}
677{
678 Abc_Obj_t * pObj;
679 int i;
680 Abc_NtkCleanNext( pNtk );
681 Abc_NtkForEachBox( pNtk, pObj, i )
682 Abc_NtkCleanNext_rec( Abc_ObjModel(pObj) );
683}
684
697{
698 Abc_Obj_t * pObj;
699 int i;
700 Abc_NtkForEachObj( pNtk, pObj, i )
701 pObj->fMarkA = 0;
702}
703
716{
717 Abc_Obj_t * pObj;
718 int i;
719 Abc_NtkForEachObj( pNtk, pObj, i )
720 pObj->fMarkB = 0;
721}
722
735{
736 Abc_Obj_t * pObj;
737 int i;
738 Abc_NtkForEachObj( pNtk, pObj, i )
739 pObj->fMarkC = 0;
740}
741
754{
755 Abc_Obj_t * pObj;
756 int i;
757 Abc_NtkForEachObj( pNtk, pObj, i )
758 pObj->fMarkA = pObj->fMarkB = 0;
759}
760
773{
774 Abc_Obj_t * pObj;
775 int i;
776 Abc_NtkForEachObj( pNtk, pObj, i )
777 pObj->fMarkA = pObj->fMarkB = pObj->fMarkC = 0;
778}
779
791int Abc_NodeFindFanin( Abc_Obj_t * pNode, Abc_Obj_t * pFanin )
792{
793 Abc_Obj_t * pThis;
794 int i;
795 Abc_ObjForEachFanin( pNode, pThis, i )
796 if ( pThis == pFanin )
797 return i;
798 return -1;
799}
800
813{
814 Abc_Obj_t * pFanout;
815 int i;
816 Abc_ObjForEachFanout( pNode, pFanout, i )
817 if ( Abc_ObjIsCo(pFanout) )
818 return pFanout;
819 return NULL;
820}
821
834{
835 Abc_Obj_t * pFanout;
836 int i;
837 Abc_ObjForEachFanout( pNode, pFanout, i )
838 if ( !Abc_ObjIsCo(pFanout) )
839 return pFanout;
840 return NULL;
841}
842
857{
858 Abc_Obj_t * pFanout, * pFanoutCo;
859 int i;
860 pFanoutCo = NULL;
861 Abc_ObjForEachFanout( pNode, pFanout, i )
862 {
863 if ( !Abc_ObjIsCo(pFanout) )
864 continue;
865 if ( Abc_ObjFaninC0(pFanout) )
866 continue;
867 if ( pFanoutCo == NULL )
868 {
869 assert( Abc_ObjFaninNum(pFanout) == 1 );
870 assert( Abc_ObjFanin0(pFanout) == pNode );
871 pFanoutCo = pFanout;
872 continue;
873 }
874 if ( strcmp( Abc_ObjName(pFanoutCo), Abc_ObjName(pFanout) ) ) // they have diff names
875 return NULL;
876 }
877 return pFanoutCo;
878}
879
891void Abc_NtkFixCoDriverProblem( Abc_Obj_t * pDriver, Abc_Obj_t * pNodeCo, int fDuplicate )
892{
893 Abc_Ntk_t * pNtk = pDriver->pNtk;
894 Abc_Obj_t * pDriverNew, * pFanin;
895 int k;
896 if ( fDuplicate && !Abc_ObjIsCi(pDriver) )
897 {
898 pDriverNew = Abc_NtkDupObj( pNtk, pDriver, 0 );
899 Abc_ObjForEachFanin( pDriver, pFanin, k )
900 Abc_ObjAddFanin( pDriverNew, pFanin );
901 if ( Abc_ObjFaninC0(pNodeCo) )
902 {
903 // change polarity of the duplicated driver
904 Abc_NodeComplement( pDriverNew );
905 Abc_ObjXorFaninC( pNodeCo, 0 );
906 }
907 }
908 else
909 {
910 // add inverters and buffers when necessary
911 if ( Abc_ObjFaninC0(pNodeCo) )
912 {
913 pDriverNew = Abc_NtkCreateNodeInv( pNtk, pDriver );
914 Abc_ObjXorFaninC( pNodeCo, 0 );
915 }
916 else
917 pDriverNew = Abc_NtkCreateNodeBuf( pNtk, pDriver );
918 }
919 // update the fanin of the PO node
920 Abc_ObjPatchFanin( pNodeCo, pDriver, pDriverNew );
921 assert( Abc_ObjFanoutNum(pDriverNew) == 1 );
922 // remove the old driver if it dangles
923 // (this happens when the duplicated driver had only one complemented fanout)
924 if ( Abc_ObjFanoutNum(pDriver) == 0 )
925 Abc_NtkDeleteObj( pDriver );
926}
927
943{
944 Abc_Obj_t * pNode, * pDriver;
945 int i;
946 assert( Abc_NtkIsLogic(pNtk) );
947 Abc_NtkIncrementTravId( pNtk );
948 Abc_NtkForEachCo( pNtk, pNode, i )
949 {
950 // if the driver is complemented, this is an error
951 pDriver = Abc_ObjFanin0(pNode);
952 if ( Abc_ObjFaninC0(pNode) )
953 return 0;
954 // if the driver is a CI and has different name, this is an error
955 if ( Abc_ObjIsCi(pDriver) && strcmp(Abc_ObjName(pDriver), Abc_ObjName(pNode)) )
956 return 0;
957 // if the driver is visited for the first time, remember the CO name
958 if ( !Abc_NodeIsTravIdCurrent(pDriver) )
959 {
960 pDriver->pNext = (Abc_Obj_t *)Abc_ObjName(pNode);
961 Abc_NodeSetTravIdCurrent(pDriver);
962 continue;
963 }
964 // the driver has second CO - if they have different name, this is an error
965 if ( strcmp((char *)pDriver->pNext, Abc_ObjName(pNode)) ) // diff names
966 return 0;
967 }
968 return 1;
969}
970
987int Abc_NtkLogicMakeSimpleCos2( Abc_Ntk_t * pNtk, int fDuplicate )
988{
989 Abc_Obj_t * pNode, * pDriver;
990 int i, nDupGates = 0;
991 assert( Abc_NtkIsLogic(pNtk) );
992 Abc_NtkIncrementTravId( pNtk );
993 Abc_NtkForEachCo( pNtk, pNode, i )
994 {
995 // if the driver is complemented, this is an error
996 pDriver = Abc_ObjFanin0(pNode);
997 if ( Abc_ObjFaninC0(pNode) )
998 {
999 Abc_NtkFixCoDriverProblem( pDriver, pNode, fDuplicate );
1000 nDupGates++;
1001 continue;
1002 }
1003 // if the driver is a CI and has different name, this is an error
1004 if ( Abc_ObjIsCi(pDriver) && strcmp(Abc_ObjName(pDriver), Abc_ObjName(pNode)) )
1005 {
1006 Abc_NtkFixCoDriverProblem( pDriver, pNode, fDuplicate );
1007 nDupGates++;
1008 continue;
1009 }
1010 // if the driver is visited for the first time, remember the CO name
1011 if ( !Abc_NodeIsTravIdCurrent(pDriver) )
1012 {
1013 pDriver->pNext = (Abc_Obj_t *)Abc_ObjName(pNode);
1014 Abc_NodeSetTravIdCurrent(pDriver);
1015 continue;
1016 }
1017 // the driver has second CO - if they have different name, this is an error
1018 if ( strcmp((char *)pDriver->pNext, Abc_ObjName(pNode)) ) // diff names
1019 {
1020 Abc_NtkFixCoDriverProblem( pDriver, pNode, fDuplicate );
1021 nDupGates++;
1022 continue;
1023 }
1024 }
1026 return nDupGates;
1027}
1028
1029
1041void Abc_NtkLogicMakeSimpleCosTest( Abc_Ntk_t * pNtk, int fDuplicate )
1042{
1043 int nObjs = Abc_NtkObjNumMax(pNtk);
1044 unsigned * pType = ABC_CALLOC( unsigned, nObjs );
1045 Abc_Obj_t * pNode;
1046 int i, Counts[4] = {0}, Consts[2] = {0}, Inputs[2] = {0};
1047 // collect info
1048 Abc_NtkForEachCo( pNtk, pNode, i )
1049 {
1050 if ( Abc_ObjFaninId0(pNode) == 0 )
1051 Consts[Abc_ObjFaninC0(pNode)]++;
1052 if ( Abc_ObjIsCi(Abc_ObjFanin0(pNode)) )
1053 Inputs[Abc_ObjFaninC0(pNode)]++;
1054 pType[Abc_ObjFaninId0(pNode)] |= (1 << Abc_ObjFaninC0(pNode));
1055 }
1056 // count the numbers
1057 for ( i = 0; i < nObjs; i++ )
1058 Counts[pType[i]]++;
1059 for ( i = 0; i < 4; i++ )
1060 printf( "%d = %d ", i, Counts[i] );
1061 for ( i = 0; i < 2; i++ )
1062 printf( "c%d = %d ", i, Consts[i] );
1063 for ( i = 0; i < 2; i++ )
1064 printf( "i%d = %d ", i, Inputs[i] );
1065 printf( "\n" );
1066 ABC_FREE( pType );
1067}
1068
1080int Abc_NtkLogicMakeSimpleCos( Abc_Ntk_t * pNtk, int fDuplicate )
1081{
1082 int fAddBuffers = 1;
1083 Vec_Ptr_t * vDrivers, * vCoTerms;
1084 Abc_Obj_t * pNode, * pDriver, * pDriverNew, * pFanin;
1085 int i, k, LevelMax, nTotal = 0;
1086 assert( Abc_NtkIsLogic(pNtk) );
1087 LevelMax = Abc_NtkLevel(pNtk);
1088// Abc_NtkLogicMakeSimpleCosTest( pNtk, fDuplicate );
1089
1090 // fix constant drivers
1091 Abc_NtkForEachCo( pNtk, pNode, i )
1092 {
1093 pDriver = Abc_ObjFanin0(pNode);
1094 if ( !Abc_NodeIsConst(pDriver) )
1095 continue;
1096 pDriverNew = (Abc_ObjFaninC0(pNode) == Abc_NodeIsConst0(pDriver)) ? Abc_NtkCreateNodeConst1(pNtk) : Abc_NtkCreateNodeConst0(pNtk);
1097 if ( Abc_ObjFaninC0(pNode) )
1098 Abc_ObjXorFaninC( pNode, 0 );
1099 Abc_ObjPatchFanin( pNode, pDriver, pDriverNew );
1100 if ( Abc_ObjFanoutNum(pDriver) == 0 )
1101 Abc_NtkDeleteObj( pDriver );
1102 }
1103
1104 // collect drivers pointed by complemented edges
1105 vDrivers = Vec_PtrAlloc( 100 );
1106 Abc_NtkIncrementTravId( pNtk );
1107 Abc_NtkForEachCo( pNtk, pNode, i )
1108 {
1109 if ( !Abc_ObjFaninC0(pNode) )
1110 continue;
1111 pDriver = Abc_ObjFanin0(pNode);
1112 if ( Abc_NodeIsTravIdCurrent(pDriver) )
1113 continue;
1114 Abc_NodeSetTravIdCurrent(pDriver);
1115 Vec_PtrPush( vDrivers, pDriver );
1116 }
1117 // fix complemented drivers
1118 if ( Vec_PtrSize(vDrivers) > 0 )
1119 {
1120 int nDupGates = 0, nDupInvs = 0, nDupChange = 0;
1121 Vec_Ptr_t * vFanouts = Vec_PtrAlloc( 100 );
1122 Vec_PtrForEachEntry( Abc_Obj_t *, vDrivers, pDriver, i )
1123 {
1124 int fHasDir = 0, fHasInv = 0, fHasOther = 0;
1125 Abc_ObjForEachFanout( pDriver, pNode, k )
1126 {
1127 if ( !Abc_ObjIsCo(pNode) )
1128 {
1129 assert( !Abc_ObjFaninC0(pNode) );
1130 fHasOther = 1;
1131 continue;
1132 }
1133 if ( Abc_ObjFaninC0(pNode) )
1134 fHasInv = 1;
1135 else //if ( Abc_ObjFaninC0(pNode) )
1136 fHasDir = 1;
1137 }
1138 assert( fHasInv );
1139 if ( Abc_ObjIsCi(pDriver) || fHasDir || (fHasOther && Abc_NtkHasMapping(pNtk)) ) // cannot change
1140 {
1141 // duplicate if critical
1142 if ( fDuplicate && Abc_ObjIsNode(pDriver) && Abc_ObjLevel(pDriver) == LevelMax )
1143 {
1144 pDriverNew = Abc_NtkDupObj( pNtk, pDriver, 0 );
1145 Abc_ObjForEachFanin( pDriver, pFanin, k )
1146 Abc_ObjAddFanin( pDriverNew, pFanin );
1147 Abc_NodeComplement( pDriverNew );
1148 nDupGates++;
1149 }
1150 else // add inverter
1151 {
1152 pDriverNew = Abc_NtkCreateNodeInv( pNtk, pDriver );
1153 nDupInvs++;
1154 }
1155 // collect CO fanouts to be redirected to the new node
1156 Vec_PtrClear( vFanouts );
1157 Abc_ObjForEachFanout( pDriver, pNode, k )
1158 if ( Abc_ObjIsCo(pNode) && Abc_ObjFaninC0(pNode) )
1159 Vec_PtrPush( vFanouts, pNode );
1160 assert( Vec_PtrSize(vFanouts) > 0 );
1161 Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pNode, k )
1162 {
1163 Abc_ObjXorFaninC( pNode, 0 );
1164 Abc_ObjPatchFanin( pNode, pDriver, pDriverNew );
1165 assert( Abc_ObjIsCi(pDriver) || Abc_ObjFanoutNum(pDriver) > 0 );
1166 }
1167 }
1168 else // can change
1169 {
1170 // change polarity of the driver
1171 assert( Abc_ObjIsNode(pDriver) );
1172 Abc_NodeComplement( pDriver );
1173 Abc_ObjForEachFanout( pDriver, pNode, k )
1174 {
1175 if ( Abc_ObjIsCo(pNode) )
1176 {
1177 assert( Abc_ObjFaninC0(pNode) );
1178 Abc_ObjXorFaninC( pNode, 0 );
1179 }
1180 else if ( Abc_ObjIsNode(pNode) )
1181 Abc_NodeComplementInput( pNode, pDriver );
1182 else assert( 0 );
1183 }
1184 nDupChange++;
1185 }
1186 }
1187 Vec_PtrFree( vFanouts );
1188// printf( "Resolving inverted CO drivers: Invs = %d. Dups = %d. Changes = %d.\n",
1189// nDupInvs, nDupGates, nDupChange );
1190 nTotal += nDupInvs + nDupGates;
1191 }
1192 Vec_PtrFree( vDrivers );
1193
1194 // collect COs that needs fixing by adding buffers or duplicating
1195 vCoTerms = Vec_PtrAlloc( 100 );
1196 Abc_NtkIncrementTravId( pNtk );
1197
1198 // The following cases should be addressed only if the network is written
1199 // into a BLIF file. Otherwise, it is possible to skip them:
1200 // (1) if a CO points to a CI with a different name
1201 // (2) if an internal node drives more than one CO
1202 if ( fAddBuffers )
1203 Abc_NtkForEachCo( pNtk, pNode, i )
1204 {
1205 // if the driver is a CI and has different name, this is an error
1206 pDriver = Abc_ObjFanin0(pNode);
1207 if ( Abc_ObjIsCi(pDriver) && strcmp(Abc_ObjName(pDriver), Abc_ObjName(pNode)) )
1208 {
1209 Vec_PtrPush( vCoTerms, pNode );
1210 continue;
1211 }
1212 // if the driver is visited for the first time, remember the CO name
1213 if ( !Abc_NodeIsTravIdCurrent(pDriver) )
1214 {
1215 pDriver->pNext = (Abc_Obj_t *)Abc_ObjName(pNode);
1216 Abc_NodeSetTravIdCurrent(pDriver);
1217 continue;
1218 }
1219 // the driver has second CO - if they have different name, this is an error
1220 if ( strcmp((char *)pDriver->pNext, Abc_ObjName(pNode)) ) // diff names
1221 {
1222 Vec_PtrPush( vCoTerms, pNode );
1223 continue;
1224 }
1225 }
1226 // fix duplication problem
1227 if ( Vec_PtrSize(vCoTerms) > 0 )
1228 {
1229 int nDupBufs = 0, nDupGates = 0;
1230 Vec_PtrForEachEntry( Abc_Obj_t *, vCoTerms, pNode, i )
1231 {
1232 pDriver = Abc_ObjFanin0(pNode);
1233 // duplicate if critical
1234 if ( fDuplicate && Abc_ObjIsNode(pDriver) && (Abc_NtkHasMapping(pNtk) || Abc_ObjLevel(pDriver) == LevelMax) )
1235 {
1236 pDriverNew = Abc_NtkDupObj( pNtk, pDriver, 0 );
1237 Abc_ObjForEachFanin( pDriver, pFanin, k )
1238 Abc_ObjAddFanin( pDriverNew, pFanin );
1239 nDupGates++;
1240 }
1241 else // add buffer
1242 {
1243 pDriverNew = Abc_NtkCreateNodeBuf( pNtk, pDriver );
1244 Abc_ObjAssignName( pDriverNew, Abc_ObjName(pDriver), "_buf" );
1245 nDupBufs++;
1246 }
1247 // swing the PO
1248 Abc_ObjPatchFanin( pNode, pDriver, pDriverNew );
1249 assert( Abc_ObjIsCi(pDriver) || Abc_ObjFanoutNum(pDriver) > 0 );
1250 }
1251// printf( "Resolving shared CO drivers: Bufs = %d. Dups = %d.\n", nDupBufs, nDupGates );
1252 nTotal += nDupBufs + nDupGates;
1253 }
1254 Vec_PtrFree( vCoTerms );
1255 return nTotal;
1256}
1257
1270{
1271 Abc_Obj_t * pNode1, * pNode2;
1272 int i;
1273 if ( Vec_PtrPushUnique(p, pNode) )
1274 return;
1275 // find the p of the node
1276 for ( i = p->nSize-1; i > 0; i-- )
1277 {
1278 pNode1 = (Abc_Obj_t *)p->pArray[i ];
1279 pNode2 = (Abc_Obj_t *)p->pArray[i-1];
1280 if ( Abc_ObjRegular(pNode1)->Level <= Abc_ObjRegular(pNode2)->Level )
1281 break;
1282 p->pArray[i ] = pNode2;
1283 p->pArray[i-1] = pNode1;
1284 }
1285}
1286
1287
1288
1301{
1302 Abc_Obj_t * pNode0, * pNode1;
1303 // check that the node is regular
1304 assert( !Abc_ObjIsComplement(pNode) );
1305 // if the node is not AND, this is not EXOR
1306 if ( !Abc_AigNodeIsAnd(pNode) )
1307 return 0;
1308 // if the children are not complemented, this is not EXOR
1309 if ( !Abc_ObjFaninC0(pNode) || !Abc_ObjFaninC1(pNode) )
1310 return 0;
1311 // get children
1312 pNode0 = Abc_ObjFanin0(pNode);
1313 pNode1 = Abc_ObjFanin1(pNode);
1314 // if the children are not ANDs, this is not EXOR
1315 if ( Abc_ObjFaninNum(pNode0) != 2 || Abc_ObjFaninNum(pNode1) != 2 )
1316 return 0;
1317 // this is AIG, which means the fanins should be ordered
1318 assert( Abc_ObjFaninId0(pNode0) != Abc_ObjFaninId1(pNode1) ||
1319 Abc_ObjFaninId0(pNode1) != Abc_ObjFaninId1(pNode0) );
1320 // if grand children are not the same, this is not EXOR
1321 if ( Abc_ObjFaninId0(pNode0) != Abc_ObjFaninId0(pNode1) ||
1322 Abc_ObjFaninId1(pNode0) != Abc_ObjFaninId1(pNode1) )
1323 return 0;
1324 // finally, if the complemented edges are matched, this is not EXOR
1325 if ( Abc_ObjFaninC0(pNode0) == Abc_ObjFaninC0(pNode1) ||
1326 Abc_ObjFaninC1(pNode0) == Abc_ObjFaninC1(pNode1) )
1327 return 0;
1328 return 1;
1329}
1330
1343{
1344 Abc_Obj_t * pNode0, * pNode1;
1345 // check that the node is regular
1346 assert( !Abc_ObjIsComplement(pNode) );
1347 // if the node is not AND, this is not MUX
1348 if ( !Abc_AigNodeIsAnd(pNode) )
1349 return 0;
1350 // if the children are not complemented, this is not MUX
1351 if ( !Abc_ObjFaninC0(pNode) || !Abc_ObjFaninC1(pNode) )
1352 return 0;
1353 // get children
1354 pNode0 = Abc_ObjFanin0(pNode);
1355 pNode1 = Abc_ObjFanin1(pNode);
1356 // if the children are not ANDs, this is not MUX
1357 if ( !Abc_AigNodeIsAnd(pNode0) || !Abc_AigNodeIsAnd(pNode1) )
1358 return 0;
1359 // otherwise the node is MUX iff it has a pair of equal grandchildren with opposite polarity
1360 return (Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC0(pNode1))) ||
1361 (Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC1(pNode1))) ||
1362 (Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC0(pNode1))) ||
1363 (Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC1(pNode1)));
1364}
1365
1378{
1379 Abc_Obj_t * pNode;
1380 int i;
1381 int Counter = 0;
1382 Abc_NtkForEachNode( pNtk, pNode, i )
1383 Counter += Abc_NodeIsMuxType( pNode );
1384 return Counter;
1385}
1386
1399{
1400 Abc_Obj_t * pNode0, * pNode1;
1401 // check that the node is regular
1402 assert( !Abc_ObjIsComplement(pNode) );
1403 // skip the node that do not have two fanouts
1404 if ( Abc_ObjFanoutNum(pNode) != 2 )
1405 return 0;
1406 // get the fanouts
1407 pNode0 = Abc_ObjFanout( pNode, 0 );
1408 pNode1 = Abc_ObjFanout( pNode, 1 );
1409 // if they have more than one fanout, we are not interested
1410 if ( Abc_ObjFanoutNum(pNode0) != 1 || Abc_ObjFanoutNum(pNode1) != 1 )
1411 return 0;
1412 // if the fanouts have the same fanout, this is MUX or EXOR (or a redundant gate (CA)(CB))
1413 return Abc_ObjFanout0(pNode0) == Abc_ObjFanout0(pNode1);
1414}
1415
1430Abc_Obj_t * Abc_NodeRecognizeMux( Abc_Obj_t * pNode, Abc_Obj_t ** ppNodeT, Abc_Obj_t ** ppNodeE )
1431{
1432 Abc_Obj_t * pNode0, * pNode1;
1433 assert( !Abc_ObjIsComplement(pNode) );
1434 assert( Abc_NodeIsMuxType(pNode) );
1435 // get children
1436 pNode0 = Abc_ObjFanin0(pNode);
1437 pNode1 = Abc_ObjFanin1(pNode);
1438 // find the control variable
1439// if ( pNode1->p1 == Fraig_Not(pNode2->p1) )
1440 if ( Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC0(pNode1)) )
1441 {
1442// if ( Fraig_IsComplement(pNode1->p1) )
1443 if ( Abc_ObjFaninC0(pNode0) )
1444 { // pNode2->p1 is positive phase of C
1445 *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode1));//pNode2->p2);
1446 *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode0));//pNode1->p2);
1447 return Abc_ObjChild0(pNode1);//pNode2->p1;
1448 }
1449 else
1450 { // pNode1->p1 is positive phase of C
1451 *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode0));//pNode1->p2);
1452 *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode1));//pNode2->p2);
1453 return Abc_ObjChild0(pNode0);//pNode1->p1;
1454 }
1455 }
1456// else if ( pNode1->p1 == Fraig_Not(pNode2->p2) )
1457 else if ( Abc_ObjFaninId0(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC0(pNode0) ^ Abc_ObjFaninC1(pNode1)) )
1458 {
1459// if ( Fraig_IsComplement(pNode1->p1) )
1460 if ( Abc_ObjFaninC0(pNode0) )
1461 { // pNode2->p2 is positive phase of C
1462 *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode1));//pNode2->p1);
1463 *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode0));//pNode1->p2);
1464 return Abc_ObjChild1(pNode1);//pNode2->p2;
1465 }
1466 else
1467 { // pNode1->p1 is positive phase of C
1468 *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode0));//pNode1->p2);
1469 *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode1));//pNode2->p1);
1470 return Abc_ObjChild0(pNode0);//pNode1->p1;
1471 }
1472 }
1473// else if ( pNode1->p2 == Fraig_Not(pNode2->p1) )
1474 else if ( Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId0(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC0(pNode1)) )
1475 {
1476// if ( Fraig_IsComplement(pNode1->p2) )
1477 if ( Abc_ObjFaninC1(pNode0) )
1478 { // pNode2->p1 is positive phase of C
1479 *ppNodeT = Abc_ObjNot(Abc_ObjChild1(pNode1));//pNode2->p2);
1480 *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode0));//pNode1->p1);
1481 return Abc_ObjChild0(pNode1);//pNode2->p1;
1482 }
1483 else
1484 { // pNode1->p2 is positive phase of C
1485 *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode0));//pNode1->p1);
1486 *ppNodeE = Abc_ObjNot(Abc_ObjChild1(pNode1));//pNode2->p2);
1487 return Abc_ObjChild1(pNode0);//pNode1->p2;
1488 }
1489 }
1490// else if ( pNode1->p2 == Fraig_Not(pNode2->p2) )
1491 else if ( Abc_ObjFaninId1(pNode0) == Abc_ObjFaninId1(pNode1) && (Abc_ObjFaninC1(pNode0) ^ Abc_ObjFaninC1(pNode1)) )
1492 {
1493// if ( Fraig_IsComplement(pNode1->p2) )
1494 if ( Abc_ObjFaninC1(pNode0) )
1495 { // pNode2->p2 is positive phase of C
1496 *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode1));//pNode2->p1);
1497 *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode0));//pNode1->p1);
1498 return Abc_ObjChild1(pNode1);//pNode2->p2;
1499 }
1500 else
1501 { // pNode1->p2 is positive phase of C
1502 *ppNodeT = Abc_ObjNot(Abc_ObjChild0(pNode0));//pNode1->p1);
1503 *ppNodeE = Abc_ObjNot(Abc_ObjChild0(pNode1));//pNode2->p1);
1504 return Abc_ObjChild1(pNode0);//pNode1->p2;
1505 }
1506 }
1507 assert( 0 ); // this is not MUX
1508 return NULL;
1509}
1510
1522int Abc_NtkPrepareTwoNtks( FILE * pErr, Abc_Ntk_t * pNtk, char ** argv, int argc,
1523 Abc_Ntk_t ** ppNtk1, Abc_Ntk_t ** ppNtk2, int * pfDelete1, int * pfDelete2, int fCheck )
1524{
1525 FILE * pFile;
1526 Abc_Ntk_t * pNtk1, * pNtk2, * pNtkTemp;
1527 int util_optind = 0;
1528
1529 *pfDelete1 = 0;
1530 *pfDelete2 = 0;
1531 if ( argc == util_optind )
1532 { // use the spec
1533 if ( pNtk == NULL )
1534 {
1535 fprintf( pErr, "Empty current network.\n" );
1536 return 0;
1537 }
1538 if ( pNtk->pSpec == NULL )
1539 {
1540 fprintf( pErr, "The external spec is not given.\n" );
1541 return 0;
1542 }
1543 pFile = fopen( pNtk->pSpec, "r" );
1544 if ( pFile == NULL )
1545 {
1546 fprintf( pErr, "Cannot open the external spec file \"%s\".\n", pNtk->pSpec );
1547 return 0;
1548 }
1549 else
1550 fclose( pFile );
1551 pNtk1 = Abc_NtkDup(pNtk);
1552 pNtk2 = Io_Read( pNtk->pSpec, Io_ReadFileType(pNtk->pSpec), fCheck, 0 );
1553 if ( pNtk2 == NULL )
1554 return 0;
1555 *pfDelete1 = 1;
1556 *pfDelete2 = 1;
1557 }
1558 else if ( argc == util_optind + 1 )
1559 {
1560 if ( pNtk == NULL )
1561 {
1562 fprintf( pErr, "Empty current network.\n" );
1563 return 0;
1564 }
1565 pNtk1 = Abc_NtkDup(pNtk);
1566 pNtk2 = Io_Read( argv[util_optind], Io_ReadFileType(argv[util_optind]), fCheck, 0 );
1567 if ( pNtk2 == NULL )
1568 return 0;
1569 *pfDelete1 = 1;
1570 *pfDelete2 = 1;
1571 }
1572 else if ( argc == util_optind + 2 )
1573 {
1574 pNtk1 = Io_Read( argv[util_optind], Io_ReadFileType(argv[util_optind]), fCheck, 0 );
1575 if ( pNtk1 == NULL )
1576 return 0;
1577 pNtk2 = Io_Read( argv[util_optind+1], Io_ReadFileType(argv[util_optind+1]), fCheck, 0 );
1578 if ( pNtk2 == NULL )
1579 {
1580 Abc_NtkDelete( pNtk1 );
1581 return 0;
1582 }
1583 *pfDelete1 = 1;
1584 *pfDelete2 = 1;
1585 }
1586 else
1587 {
1588 fprintf( pErr, "Wrong number of arguments.\n" );
1589 return 0;
1590 }
1591
1592 // make sure the networks are strashed
1593 if ( !Abc_NtkIsStrash(pNtk1) )
1594 {
1595 pNtkTemp = Abc_NtkStrash( pNtk1, 0, 1, 0 );
1596 if ( *pfDelete1 )
1597 Abc_NtkDelete( pNtk1 );
1598 pNtk1 = pNtkTemp;
1599 *pfDelete1 = 1;
1600 }
1601 if ( !Abc_NtkIsStrash(pNtk2) )
1602 {
1603 pNtkTemp = Abc_NtkStrash( pNtk2, 0, 1, 0 );
1604 if ( *pfDelete2 )
1605 Abc_NtkDelete( pNtk2 );
1606 pNtk2 = pNtkTemp;
1607 *pfDelete2 = 1;
1608 }
1609
1610 *ppNtk1 = pNtk1;
1611 *ppNtk2 = pNtk2;
1612 return 1;
1613}
1614
1615
1628{
1629 Abc_Obj_t * pFanin;
1630 int i;
1631 Vec_PtrClear(vNodes);
1632 Abc_ObjForEachFanin( pNode, pFanin, i )
1633 Vec_PtrPush( vNodes, pFanin );
1634}
1635
1648{
1649 Abc_Obj_t * pFanout;
1650 int i;
1651 Vec_PtrClear(vNodes);
1652 Abc_ObjForEachFanout( pNode, pFanout, i )
1653 Vec_PtrPush( vNodes, pFanout );
1654}
1655
1668{
1669 Vec_Ptr_t * vLatches;
1670 Abc_Obj_t * pObj;
1671 int i;
1672 vLatches = Vec_PtrAlloc( 10 );
1673 Abc_NtkForEachObj( pNtk, pObj, i )
1674 Vec_PtrPush( vLatches, pObj );
1675 return vLatches;
1676}
1677
1690{
1691 int Diff = Abc_ObjRegular(*pp1)->Level - Abc_ObjRegular(*pp2)->Level;
1692 if ( Diff < 0 )
1693 return -1;
1694 if ( Diff > 0 )
1695 return 1;
1696 Diff = Abc_ObjRegular(*pp1)->Id - Abc_ObjRegular(*pp2)->Id;
1697 if ( Diff < 0 )
1698 return -1;
1699 if ( Diff > 0 )
1700 return 1;
1701 return 0;
1702}
1703
1716{
1717 int Diff = Abc_ObjRegular(*pp1)->Level - Abc_ObjRegular(*pp2)->Level;
1718 if ( Diff > 0 )
1719 return -1;
1720 if ( Diff < 0 )
1721 return 1;
1722 Diff = Abc_ObjRegular(*pp1)->Id - Abc_ObjRegular(*pp2)->Id;
1723 if ( Diff > 0 )
1724 return -1;
1725 if ( Diff < 0 )
1726 return 1;
1727 return 0;
1728}
1729
1742{
1743 Vec_Int_t * vFanNums;
1744 Abc_Obj_t * pObj;
1745 int i;
1746 vFanNums = Vec_IntAlloc( 0 );
1747 Vec_IntFill( vFanNums, Abc_NtkObjNumMax(pNtk), -1 );
1748 Abc_NtkForEachObj( pNtk, pObj, i )
1749 if ( Abc_ObjIsCi(pObj) || Abc_ObjIsNode(pObj) )
1750 Vec_IntWriteEntry( vFanNums, i, Abc_ObjFanoutNum(pObj) );
1751 return vFanNums;
1752}
1753
1766{
1767 Vec_Ptr_t * vNodes;
1768 Abc_Obj_t * pNode;
1769 int i;
1770 vNodes = Vec_PtrAlloc( 100 );
1771 Abc_NtkForEachObj( pNtk, pNode, i )
1772 Vec_PtrPush( vNodes, pNode );
1773 return vNodes;
1774}
1775
1788{
1789 Vec_Int_t * vCiIds;
1790 Abc_Obj_t * pObj;
1791 int i;
1792 vCiIds = Vec_IntAlloc( Abc_NtkCiNum(pNtk) );
1793 Abc_NtkForEachCi( pNtk, pObj, i )
1794 Vec_IntPush( vCiIds, pObj->Id );
1795 return vCiIds;
1796}
1797
1810{
1811 Vec_Ptr_t * vNodes;
1812 Vec_Ptr_t * vObjsNew;
1813 Abc_Obj_t * pNode, * pTemp, * pConst1;
1814 int i, k;
1815 assert( Abc_NtkIsStrash(pNtk) );
1816//printf( "Total = %d. Current = %d.\n", Abc_NtkObjNumMax(pNtk), Abc_NtkObjNum(pNtk) );
1817 // start the array of objects with new IDs
1818 vObjsNew = Vec_PtrAlloc( pNtk->nObjs );
1819 // put constant node first
1820 pConst1 = Abc_AigConst1(pNtk);
1821 assert( pConst1->Id == 0 );
1822 Vec_PtrPush( vObjsNew, pConst1 );
1823 // put PI nodes next
1824 Abc_NtkForEachPi( pNtk, pNode, i )
1825 {
1826 pNode->Id = Vec_PtrSize( vObjsNew );
1827 Vec_PtrPush( vObjsNew, pNode );
1828 }
1829 // put PO nodes next
1830 Abc_NtkForEachPo( pNtk, pNode, i )
1831 {
1832 pNode->Id = Vec_PtrSize( vObjsNew );
1833 Vec_PtrPush( vObjsNew, pNode );
1834 }
1835 // put latches and their inputs/outputs next
1836 Abc_NtkForEachBox( pNtk, pNode, i )
1837 {
1838 pNode->Id = Vec_PtrSize( vObjsNew );
1839 Vec_PtrPush( vObjsNew, pNode );
1840 Abc_ObjForEachFanin( pNode, pTemp, k )
1841 {
1842 pTemp->Id = Vec_PtrSize( vObjsNew );
1843 Vec_PtrPush( vObjsNew, pTemp );
1844 }
1845 Abc_ObjForEachFanout( pNode, pTemp, k )
1846 {
1847 pTemp->Id = Vec_PtrSize( vObjsNew );
1848 Vec_PtrPush( vObjsNew, pTemp );
1849 }
1850 }
1851 // finally, internal nodes in the DFS order
1852 vNodes = Abc_AigDfs( pNtk, 1, 0 );
1853 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
1854 {
1855 if ( pNode == pConst1 )
1856 continue;
1857 pNode->Id = Vec_PtrSize( vObjsNew );
1858 Vec_PtrPush( vObjsNew, pNode );
1859 }
1860 Vec_PtrFree( vNodes );
1861 assert( Vec_PtrSize(vObjsNew) == pNtk->nObjs );
1862
1863 // update the fanin/fanout arrays
1864 Abc_NtkForEachObj( pNtk, pNode, i )
1865 {
1866 Abc_ObjForEachFanin( pNode, pTemp, k )
1867 pNode->vFanins.pArray[k] = pTemp->Id;
1868 Abc_ObjForEachFanout( pNode, pTemp, k )
1869 pNode->vFanouts.pArray[k] = pTemp->Id;
1870 }
1871
1872 // replace the array of objs
1873 Vec_PtrFree( pNtk->vObjs );
1874 pNtk->vObjs = vObjsNew;
1875
1876 // rehash the AIG
1877 Abc_AigRehash( (Abc_Aig_t *)pNtk->pManFunc );
1878
1879 // update the name manager!!!
1880}
1881
1894{
1895/*
1896 Abc_Obj_t * pLatch, * pFanin;
1897 int i, nTFFs, nJKFFs;
1898 nTFFs = nJKFFs = 0;
1899 Abc_NtkForEachLatch( pNtk, pLatch, i )
1900 {
1901 pFanin = Abc_ObjFanin0(pLatch);
1902 if ( Abc_ObjFaninNum(pFanin) != 2 )
1903 continue;
1904 if ( Abc_NodeIsExorType(pLatch) )
1905 {
1906 if ( Abc_ObjFanin0(Abc_ObjFanin0(pFanin)) == pLatch ||
1907 Abc_ObjFanin1(Abc_ObjFanin0(pFanin)) == pLatch )
1908 nTFFs++;
1909 }
1910 if ( Abc_ObjFaninNum( Abc_ObjFanin0(pFanin) ) != 2 ||
1911 Abc_ObjFaninNum( Abc_ObjFanin1(pFanin) ) != 2 )
1912 continue;
1913
1914 if ( (Abc_ObjFanin0(Abc_ObjFanin0(pFanin)) == pLatch ||
1915 Abc_ObjFanin1(Abc_ObjFanin0(pFanin)) == pLatch) &&
1916 (Abc_ObjFanin0(Abc_ObjFanin1(pFanin)) == pLatch ||
1917 Abc_ObjFanin1(Abc_ObjFanin1(pFanin)) == pLatch) )
1918 {
1919 nJKFFs++;
1920 }
1921 }
1922 printf( "D = %6d. T = %6d. JK = %6d. (%6.2f %%)\n",
1923 Abc_NtkLatchNum(pNtk), nTFFs, nJKFFs, 100.0 * nJKFFs / Abc_NtkLatchNum(pNtk) );
1924*/
1925}
1926
1927
1939int Abc_ObjPointerCompare( void ** pp1, void ** pp2 )
1940{
1941 if ( *pp1 < *pp2 )
1942 return -1;
1943 if ( *pp1 > *pp2 )
1944 return 1;
1945 return 0;
1946}
1947
1963{
1964 Abc_Obj_t * pObj;
1965 int i;
1966 Abc_NtkForEachObj( pNtk, pObj, i )
1967 if ( !Abc_ObjIsNet(pObj) )
1968 pObj->pCopy = pObj->pCopy? Abc_ObjCopyCond(pObj->pCopy) : NULL;
1969}
1970
1971
1983static inline int Abc_ObjCrossCutInc( Abc_Obj_t * pObj )
1984{
1985// pObj->pCopy = (void *)(((int)pObj->pCopy)++);
1986 int Value = (int)(ABC_PTRINT_T)pObj->pCopy;
1987 pObj->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)(Value + 1);
1988 return (int)(ABC_PTRINT_T)pObj->pCopy == Abc_ObjFanoutNum(pObj);
1989}
1990
2002int Abc_NtkCrossCut_rec( Abc_Obj_t * pObj, int * pnCutSize, int * pnCutSizeMax )
2003{
2004 Abc_Obj_t * pFanin;
2005 int i, nDecrem = 0;
2006 int fReverse = 0;
2007 if ( Abc_ObjIsCi(pObj) )
2008 return 0;
2009 // if visited, increment visit counter
2010 if ( Abc_NodeIsTravIdCurrent( pObj ) )
2011 return Abc_ObjCrossCutInc( pObj );
2012 Abc_NodeSetTravIdCurrent( pObj );
2013 // visit the fanins
2014 if ( !Abc_ObjIsCi(pObj) )
2015 {
2016 if ( fReverse )
2017 {
2018 Abc_ObjForEachFanin( pObj, pFanin, i )
2019 {
2020 pFanin = Abc_ObjFanin( pObj, Abc_ObjFaninNum(pObj) - 1 - i );
2021 nDecrem += Abc_NtkCrossCut_rec( pFanin, pnCutSize, pnCutSizeMax );
2022 }
2023 }
2024 else
2025 {
2026 Abc_ObjForEachFanin( pObj, pFanin, i )
2027 nDecrem += Abc_NtkCrossCut_rec( pFanin, pnCutSize, pnCutSizeMax );
2028 }
2029 }
2030 // count the node
2031 (*pnCutSize)++;
2032 if ( *pnCutSizeMax < *pnCutSize )
2033 *pnCutSizeMax = *pnCutSize;
2034 (*pnCutSize) -= nDecrem;
2035 return Abc_ObjCrossCutInc( pObj );
2036}
2037
2050{
2051 Abc_Obj_t * pObj;
2052 int nCutSize = 0, nCutSizeMax = 0;
2053 int i;
2054 Abc_NtkCleanCopy( pNtk );
2055 Abc_NtkIncrementTravId( pNtk );
2056 Abc_NtkForEachCo( pNtk, pObj, i )
2057 {
2058 Abc_NtkCrossCut_rec( pObj, &nCutSize, &nCutSizeMax );
2059 nCutSize--;
2060 }
2061 assert( nCutSize == 0 );
2062 printf( "Max cross cut size = %6d. Ratio = %6.2f %%\n", nCutSizeMax, 100.0 * nCutSizeMax/Abc_NtkObjNum(pNtk) );
2063 return nCutSizeMax;
2064}
2065
2066
2079{
2080 FILE * pFile;
2081 unsigned i;
2082 pFile = fopen( "4varfs.txt", "w" );
2083 for ( i = 1; i < (1<<16)-1; i++ )
2084 {
2085 fprintf( pFile, "read_truth " );
2086 Extra_PrintBinary( pFile, &i, 16 );
2087 fprintf( pFile, "; clp; st; w 1.blif; map; cec 1.blif\n" );
2088 }
2089 fclose( pFile );
2090}
2091
2092
2093static int * pSupps;
2094
2106int Abc_NtkCompareConesCompare( int * pNum1, int * pNum2 )
2107{
2108 if ( pSupps[*pNum1] > pSupps[*pNum2] )
2109 return -1;
2110 if ( pSupps[*pNum1] < pSupps[*pNum2] )
2111 return 1;
2112 return 0;
2113}
2114
2127{
2128 Vec_Ptr_t * vSupp, * vNodes, * vReverse;
2129 Abc_Obj_t * pObj, * pTemp;
2130 int Iter, i, k, Counter, CounterCos, CounterCosNew;
2131 int * pPerms;
2132
2133 // sort COs by support size
2134 pPerms = ABC_ALLOC( int, Abc_NtkCoNum(pNtk) );
2135 pSupps = ABC_ALLOC( int, Abc_NtkCoNum(pNtk) );
2136 Abc_NtkForEachCo( pNtk, pObj, i )
2137 {
2138 pPerms[i] = i;
2139 vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 );
2140 pSupps[i] = Vec_PtrSize(vSupp);
2141 Vec_PtrFree( vSupp );
2142 }
2143 qsort( (void *)pPerms, (size_t)Abc_NtkCoNum(pNtk), sizeof(int), (int (*)(const void *, const void *)) Abc_NtkCompareConesCompare );
2144
2145 // consider COs in this order
2146 Iter = 0;
2147 Abc_NtkForEachCo( pNtk, pObj, i )
2148 {
2149 pObj = Abc_NtkCo( pNtk, pPerms[i] );
2150 if ( pObj->fMarkA )
2151 continue;
2152 Iter++;
2153
2154 vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 );
2155 vNodes = Abc_NtkDfsNodes( pNtk, &pObj, 1 );
2156 vReverse = Abc_NtkDfsReverseNodesContained( pNtk, (Abc_Obj_t **)Vec_PtrArray(vSupp), Vec_PtrSize(vSupp) );
2157 // count the number of nodes in the reverse cone
2158 Counter = 0;
2159 for ( k = 1; k < Vec_PtrSize(vReverse) - 1; k++ )
2160 for ( pTemp = (Abc_Obj_t *)Vec_PtrEntry(vReverse, k); pTemp; pTemp = (Abc_Obj_t *)pTemp->pCopy )
2161 Counter++;
2162 CounterCos = CounterCosNew = 0;
2163 for ( pTemp = (Abc_Obj_t *)Vec_PtrEntryLast(vReverse); pTemp; pTemp = (Abc_Obj_t *)pTemp->pCopy )
2164 {
2165 assert( Abc_ObjIsCo(pTemp) );
2166 CounterCos++;
2167 if ( pTemp->fMarkA == 0 )
2168 CounterCosNew++;
2169 pTemp->fMarkA = 1;
2170 }
2171 // print statistics
2172 printf( "%4d CO %5d : Supp = %5d. Lev = %3d. Cone = %5d. Rev = %5d. COs = %3d (%3d).\n",
2173 Iter, pPerms[i], Vec_PtrSize(vSupp), Abc_ObjLevel(Abc_ObjFanin0(pObj)), Vec_PtrSize(vNodes), Counter, CounterCos, CounterCosNew );
2174
2175 if ( Vec_PtrSize(vSupp) < 10 )
2176 {
2177 // free arrays
2178 Vec_PtrFree( vSupp );
2179 Vec_PtrFree( vNodes );
2180 Vec_PtrFree( vReverse );
2181 break;
2182 }
2183
2184 // free arrays
2185 Vec_PtrFree( vSupp );
2186 Vec_PtrFree( vNodes );
2187 Vec_PtrFree( vReverse );
2188
2189 }
2190 Abc_NtkForEachCo( pNtk, pObj, i )
2191 pObj->fMarkA = 0;
2192
2193 ABC_FREE( pPerms );
2194 ABC_FREE( pSupps );
2195}
2196
2209{
2210 Vec_Ptr_t * vSupp;
2211 Abc_Obj_t * pObj, * pTemp;
2212 int i, nNodesOld;
2213 assert( Abc_NtkIsStrash(pNtk) );
2214 Abc_AigForEachAnd( pNtk, pObj, i )
2215 {
2216 if ( !Abc_AigNodeIsChoice(pObj) )
2217 continue;
2218
2219 vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 );
2220 nNodesOld = Vec_PtrSize(vSupp);
2221 Vec_PtrFree( vSupp );
2222
2223 for ( pTemp = (Abc_Obj_t *)pObj->pData; pTemp; pTemp = (Abc_Obj_t *)pTemp->pData )
2224 {
2225 vSupp = Abc_NtkNodeSupport( pNtk, &pTemp, 1 );
2226 if ( nNodesOld != Vec_PtrSize(vSupp) )
2227 printf( "Choice orig = %3d Choice new = %3d\n", nNodesOld, Vec_PtrSize(vSupp) );
2228 Vec_PtrFree( vSupp );
2229 }
2230 }
2231}
2232
2245{
2246 Abc_Obj_t * pObj;
2247 int i;
2248 if ( Abc_NtkConstrNum(pNtk) == 0 )
2249 return;
2250 Abc_NtkForEachPo( pNtk, pObj, i )
2251 {
2252 if ( i >= Abc_NtkPoNum(pNtk) - Abc_NtkConstrNum(pNtk) )
2253 Abc_ObjXorFaninC( pObj, 0 );
2254 }
2255}
2256
2269{
2270 Abc_Obj_t * pObj;
2271 int i;
2272 Abc_NtkForEachCi( pNtk, pObj, i )
2273 printf( "%c=%d ", 'a'+i, pObj->Level );
2274 printf( "\n" );
2275}
2276
2277
2290{
2291 Abc_Obj_t * pFanout;
2292 int i;
2293 Abc_ObjForEachFanout( pFanin, pFanout, i )
2294 if ( pFanout != pNode && pFanout->Level >= pNode->Level )
2295 return 0;
2296 return 1;
2297}
2298
2310{
2311 Abc_Obj_t * pFanout;
2312 int i;
2313 Abc_ObjForEachFanout( pFanin, pFanout, i )
2314 if ( pFanout != pNode && pFanout->Level > pNode->Level )
2315 return 1;
2316 return 0;
2317}
2318
2330Abc_Obj_t * Abc_NtkAddBuffsOne( Vec_Ptr_t * vBuffs, Abc_Obj_t * pFanin, int Level, int nLevelMax )
2331{
2332 Abc_Obj_t * pBuffer;
2333 assert( Level - 1 >= Abc_ObjLevel(pFanin) );
2334 pBuffer = (Abc_Obj_t *)Vec_PtrEntry( vBuffs, Abc_ObjId(pFanin) * nLevelMax + Level );
2335 if ( pBuffer == NULL )
2336 {
2337 if ( Level - 1 == Abc_ObjLevel(pFanin) )
2338 pBuffer = pFanin;
2339 else
2340 pBuffer = Abc_NtkAddBuffsOne( vBuffs, pFanin, Level - 1, nLevelMax );
2341 pBuffer = Abc_NtkCreateNodeBuf( Abc_ObjNtk(pFanin), pBuffer );
2342 Vec_PtrWriteEntry( vBuffs, Abc_ObjId(pFanin) * nLevelMax + Level, pBuffer );
2343 }
2344 return pBuffer;
2345}
2346Abc_Ntk_t * Abc_NtkAddBuffsInt( Abc_Ntk_t * pNtkInit, int fReverse, int nImprove, int fVerbose )
2347{
2348 Vec_Ptr_t * vBuffs;
2349 Abc_Ntk_t * pNtk = Abc_NtkDup( pNtkInit );
2350 Abc_Obj_t * pObj, * pFanin, * pBuffer;
2351 int i, k, Iter, nLevelMax = Abc_NtkLevel( pNtk );
2352 Abc_NtkForEachCo( pNtk, pObj, i )
2353 pObj->Level = nLevelMax + 1;
2354 if ( fReverse )
2355 {
2356 Vec_Ptr_t * vNodes = Abc_NtkDfs( pNtk, 1 );
2357 assert( nLevelMax < (1<<18) );
2358 Vec_PtrForEachEntryReverse( Abc_Obj_t *, vNodes, pObj, i )
2359 {
2360 pObj->Level = (1<<18);
2361 Abc_ObjForEachFanout( pObj, pFanin, k )
2362 pObj->Level = Abc_MinInt( pFanin->Level - 1, pObj->Level );
2363 assert( pObj->Level > 0 );
2364 }
2365 Abc_NtkForEachCi( pNtk, pObj, i )
2366 pObj->Level = 0;
2367
2368 // move the nodes down one step at a time
2369 for ( Iter = 0; Iter < nImprove; Iter++ )
2370 {
2371 int Counter = 0, TotalGain = 0;
2372 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
2373 {
2374 int CountGain = -1;
2375 assert( pObj->Level > 0 );
2376 Abc_ObjForEachFanin( pObj, pFanin, k )
2377 {
2378 assert( pFanin->Level < pObj->Level );
2379 if ( pFanin->Level + 1 == pObj->Level )
2380 break;
2381 }
2382 if ( k < Abc_ObjFaninNum(pObj) ) // cannot move
2383 continue;
2384 Abc_ObjForEachFanin( pObj, pFanin, k )
2385 CountGain += Abc_NtkAddBuffsEval( pObj, pFanin );
2386 if ( CountGain >= 0 ) // can move
2387 {
2388 pObj->Level--;
2389 Counter++;
2390 TotalGain += CountGain;
2391 }
2392 }
2393 if ( fVerbose )
2394 printf( "Shifted %5d nodes down with total gain %5d.\n", Counter, TotalGain );
2395 if ( Counter == 0 )
2396 break;
2397 }
2398 Vec_PtrFree( vNodes );
2399 }
2400 else
2401 {
2402 // move the nodes up one step at a time
2403 Vec_Ptr_t * vNodes = Abc_NtkDfs( pNtk, 1 );
2404 for ( Iter = 0; Iter < nImprove; Iter++ )
2405 {
2406 int Counter = 0, TotalGain = 0;
2407 Vec_PtrForEachEntryReverse( Abc_Obj_t *, vNodes, pObj, i )
2408 {
2409 int CountGain = 1;
2410 assert( pObj->Level <= (unsigned)nLevelMax );
2411 Abc_ObjForEachFanout( pObj, pFanin, k )
2412 {
2413 assert( pFanin->Level > pObj->Level );
2414 if ( pFanin->Level == pObj->Level + 1 )
2415 break;
2416 }
2417 if ( k < Abc_ObjFanoutNum(pObj) ) // cannot move
2418 continue;
2419 Abc_ObjForEachFanin( pObj, pFanin, k )
2420 CountGain -= !Abc_NtkAddBuffsEval2( pObj, pFanin );
2421 if ( CountGain >= 0 ) // can move
2422 {
2423 pObj->Level++;
2424 Counter++;
2425 TotalGain += CountGain;
2426 }
2427 }
2428 if ( fVerbose )
2429 printf( "Shifted %5d nodes up with total gain %5d.\n", Counter, TotalGain );
2430 if ( Counter == 0 )
2431 break;
2432 }
2433 Vec_PtrFree( vNodes );
2434 }
2435 vBuffs = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) * (nLevelMax + 1) );
2436 Abc_NtkForEachObj( pNtk, pObj, i )
2437 {
2438 if ( i == Vec_PtrSize(vBuffs) / (nLevelMax + 1) )
2439 break;
2440 if ( !Abc_ObjIsNode(pObj) && !Abc_ObjIsCo(pObj) )
2441 continue;
2442 Abc_ObjForEachFanin( pObj, pFanin, k )
2443 {
2444 assert( Abc_ObjLevel(pObj) - 1 >= Abc_ObjLevel(pFanin) );
2445 if ( Abc_ObjLevel(pObj) - 1 == Abc_ObjLevel(pFanin) )
2446 continue;
2447 pBuffer = Abc_NtkAddBuffsOne( vBuffs, pFanin, Abc_ObjLevel(pObj) - 1, nLevelMax );
2448 Abc_ObjPatchFanin( pObj, pFanin, pBuffer );
2449 }
2450 }
2451 Vec_PtrFree( vBuffs );
2452 Abc_NtkForEachCo( pNtk, pObj, i )
2453 pObj->Level = 0;
2454 return pNtk;
2455}
2456Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtkInit, int fDirect, int fReverse, int nImprove, int fVerbose )
2457{
2458 Abc_Ntk_t * pNtkD, * pNtkR;
2459 if ( fDirect )
2460 return Abc_NtkAddBuffsInt( pNtkInit, 0, nImprove, fVerbose );
2461 if ( fReverse )
2462 return Abc_NtkAddBuffsInt( pNtkInit, 1, nImprove, fVerbose );
2463 pNtkD = Abc_NtkAddBuffsInt( pNtkInit, 0, nImprove, fVerbose );
2464 pNtkR = Abc_NtkAddBuffsInt( pNtkInit, 1, nImprove, fVerbose );
2465 if ( Abc_NtkNodeNum(pNtkD) < Abc_NtkNodeNum(pNtkR) )
2466 {
2467 Abc_NtkDelete( pNtkR );
2468 return pNtkD;
2469 }
2470 else
2471 {
2472 Abc_NtkDelete( pNtkD );
2473 return pNtkR;
2474 }
2475}
2476
2489{
2490 static double GateDelays[20] = { 1.00, 1.00, 2.00, 2.58, 3.00, 3.32, 3.58, 3.81, 4.00, 4.17, 4.32, 4.46, 4.58, 4.70, 4.81, 4.91, 5.00, 5.09, 5.17, 5.25 };
2491 Vec_Ptr_t * vNodes;
2492 Abc_Obj_t * pObj, * pFanin;
2493 float DelayMax, Delays[15] = {0};
2494 int nFaninMax, i, k;
2495 // calculate relative gate delays
2496 nFaninMax = Abc_NtkGetFaninMax( pNtk );
2497 assert( nFaninMax > 1 && nFaninMax < 15 );
2498 for ( i = 0; i <= nFaninMax; i++ )
2499 Delays[i] = GateDelays[i]/GateDelays[nFaninMax];
2500 // set max CI delay
2501 Abc_NtkForEachCi( pNtk, pObj, i )
2502 pObj->dTemp = 0.0;
2503 // compute delays for each node
2504 vNodes = Abc_NtkDfs( pNtk, 1 );
2505 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
2506 {
2507 pObj->dTemp = 0.0;
2508 Abc_ObjForEachFanin( pObj, pFanin, k )
2509 pObj->dTemp = Abc_MaxFloat( pObj->dTemp, pFanin->dTemp );
2510 pObj->dTemp += Delays[Abc_ObjFaninNum(pObj)];
2511 }
2512 Vec_PtrFree( vNodes );
2513 DelayMax = 0.0;
2514 // find max CO delay
2515 Abc_NtkForEachCo( pNtk, pObj, i )
2516 DelayMax = Abc_MaxFloat( DelayMax, Abc_ObjFanin0(pObj)->dTemp );
2517 return DelayMax;
2518}
2519
2520
2532void Abc_NodeSopToCubes( Abc_Obj_t * pNodeOld, Abc_Ntk_t * pNtkNew, int fXor )
2533{
2534 Abc_Obj_t * pNodeOr, * pNodeNew, * pFanin;
2535 char * pCube, * pSop = (char *)pNodeOld->pData;
2536 int v, Value, nVars = Abc_ObjFaninNum(pNodeOld), nFanins;
2537 // create the root node
2538 if ( Abc_SopGetCubeNum(pSop) < 2 )
2539 {
2540 pNodeNew = Abc_NtkDupObj( pNtkNew, pNodeOld, 0 );
2541 Abc_ObjForEachFanin( pNodeOld, pFanin, v )
2542 Abc_ObjAddFanin( pNodeNew, pFanin->pCopy );
2543 assert( pNodeOld->pCopy == pNodeNew );
2544 return;
2545 }
2546 // add the OR gate
2547 pNodeOr = Abc_NtkCreateNode( pNtkNew );
2548 if ( fXor )
2549 pNodeOr->pData = Abc_SopCreateXorSpecial( (Mem_Flex_t *)pNtkNew->pManFunc, Abc_SopGetCubeNum(pSop) );
2550 else
2551 pNodeOr->pData = Abc_SopCreateOr( (Mem_Flex_t *)pNtkNew->pManFunc, Abc_SopGetCubeNum(pSop), NULL );
2552 // check the logic function of the node
2553 Abc_SopForEachCube( pSop, nVars, pCube )
2554 {
2555 nFanins = 0;
2556 Abc_CubeForEachVar( pCube, Value, v )
2557 if ( Value == '0' || Value == '1' )
2558 nFanins++;
2559 if ( nFanins == 0 ) // const1 cube in ESOP
2560 {
2561 pNodeNew = Abc_NtkCreateNodeConst1( pNtkNew );
2562 Abc_ObjAddFanin( pNodeOr, pNodeNew );
2563 continue;
2564 }
2565 assert( nFanins > 0 );
2566 // create node
2567 pNodeNew = Abc_NtkCreateNode( pNtkNew );
2568 pNodeNew->pData = Abc_SopCreateAnd( (Mem_Flex_t *)pNtkNew->pManFunc, nFanins, NULL );
2569 nFanins = 0;
2570 Abc_CubeForEachVar( pCube, Value, v )
2571 {
2572 if ( Value != '0' && Value != '1' )
2573 continue;
2574 Abc_ObjAddFanin( pNodeNew, Abc_ObjFanin(pNodeOld, v)->pCopy );
2575 if ( Value == '0' )
2576 Abc_SopComplementVar( (char *)pNodeNew->pData, nFanins );
2577 nFanins++;
2578 }
2579 Abc_ObjAddFanin( pNodeOr, pNodeNew );
2580 }
2581 // check the complement
2582 if ( Abc_SopIsComplement(pSop) )
2583 Abc_SopComplement( (char *)pNodeOr->pData );
2584 // mark the old node with the new one
2585 assert( pNodeOld->pCopy == NULL );
2586 pNodeOld->pCopy = pNodeOr;
2587}
2589{
2590 Abc_Ntk_t * pNtkNew;
2591 Abc_Obj_t * pNode;
2592 Vec_Ptr_t * vNodes;
2593 int i;
2594 assert( Abc_NtkIsSopLogic(pNtk) );
2595 Abc_NtkCleanCopy( pNtk );
2596 pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
2597 // perform conversion in the topological order
2598 vNodes = Abc_NtkDfs( pNtk, 0 );
2599 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
2600 Abc_NodeSopToCubes( pNode, pNtkNew, fXor );
2601 Vec_PtrFree( vNodes );
2602 // make sure everything is okay
2603 Abc_NtkFinalize( pNtk, pNtkNew );
2604 if ( !Abc_NtkCheck( pNtkNew ) )
2605 {
2606 printf( "Abc_NtkSopToCubes: The network check has failed.\n" );
2607 Abc_NtkDelete( pNtkNew );
2608 return NULL;
2609 }
2610 return pNtkNew;
2611}
2612
2624static inline int Abc_NtkTopoHasBeg( Abc_Obj_t * p ) { return Vec_IntEntry(p->pNtk->vTopo, 2*Abc_ObjId(p) ); }
2625static inline int Abc_NtkTopoHasEnd( Abc_Obj_t * p ) { return Vec_IntEntry(p->pNtk->vTopo, 2*Abc_ObjId(p)+1); }
2626
2627static inline void Abc_NtkTopoSetBeg( Abc_Obj_t * p ) { Vec_IntWriteEntry(p->pNtk->vTopo, 2*Abc_ObjId(p) , Vec_IntSize(p->pNtk->vTopo)); }
2628static inline void Abc_NtkTopoSetEnd( Abc_Obj_t * p ) { Vec_IntWriteEntry(p->pNtk->vTopo, 2*Abc_ObjId(p)+1, Vec_IntSize(p->pNtk->vTopo)); }
2629
2630void Abc_NtkReverseTopoOrder_rec( Abc_Obj_t * pObj, int fThisIsPivot )
2631{
2632 Abc_Obj_t * pNext, * pPivot = NULL;
2633 int i;
2634 if ( Abc_NodeIsTravIdCurrent( pObj ) )
2635 return;
2636 Abc_NodeSetTravIdCurrent( pObj );
2637 if ( Abc_ObjIsPo(pObj) )
2638 {
2639 Vec_IntPush( pObj->pNtk->vTopo, Abc_ObjId(pObj) );
2640 return;
2641 }
2642 assert( Abc_ObjIsNode(pObj) );
2643 // mark begining
2644 if ( fThisIsPivot )
2645 Abc_NtkTopoSetBeg( pObj );
2646 // find fanout without topo
2647 Abc_ObjForEachFanout( pObj, pNext, i )
2648 if ( !Abc_NtkTopoHasBeg(pNext) )
2649 {
2650 assert( !Abc_NtkTopoHasEnd(pNext) );
2651 Abc_NtkReverseTopoOrder_rec( pNext, 1 );
2652 pPivot = pNext;
2653 break;
2654 }
2655 Abc_ObjForEachFanout( pObj, pNext, i )
2656 if ( pNext != pPivot )
2657 Abc_NtkReverseTopoOrder_rec( pNext, 0 );
2658 // mark end
2659 if ( fThisIsPivot )
2660 Abc_NtkTopoSetEnd( pObj );
2661 // save current node
2662 Vec_IntPush( pObj->pNtk->vTopo, Abc_ObjId(pObj) );
2663}
2665{
2666 Abc_Obj_t * pObj;
2667 int i;
2668 assert( p->vTopo == NULL );
2669 p->vTopo = Vec_IntAlloc( 10 * Abc_NtkObjNumMax(p) );
2670 Vec_IntFill( p->vTopo, 2 * Abc_NtkObjNumMax(p), 0 );
2671 Abc_NtkForEachNode( p, pObj, i )
2672 {
2673 if ( Abc_NtkTopoHasBeg(pObj) )
2674 continue;
2675 Abc_NtkIncrementTravId( p );
2676 Abc_NtkReverseTopoOrder_rec( pObj, 1 );
2677 }
2678 printf( "Nodes = %d. Size = %d. Ratio = %f.\n",
2679 Abc_NtkNodeNum(p), Vec_IntSize(p->vTopo), 1.0*Vec_IntSize(p->vTopo)/Abc_NtkNodeNum(p) );
2680}
2681
2682void Abc_NtkReverse_rec( Abc_Obj_t * pObj, Vec_Int_t * vVisited )
2683{
2684 Abc_Obj_t * pNext;
2685 int i;
2686 if ( Abc_NodeIsTravIdCurrent( pObj ) )
2687 return;
2688 Abc_NodeSetTravIdCurrent( pObj );
2689 Abc_ObjForEachFanout( pObj, pNext, i )
2690 Abc_NtkReverse_rec( pNext, vVisited );
2691 Vec_IntPush( vVisited, Abc_ObjId(pObj) );
2692}
2694{
2695 Vec_Int_t * vVisited;
2696 Abc_Obj_t * pObj;
2697 int i;//, k, iBeg, iEnd;
2698 abctime clk = Abc_Clock();
2700/*
2701 printf( "Reverse topological order for nodes:\n" );
2702 Abc_NtkForEachNode( p, pObj, i )
2703 {
2704 iBeg = Abc_NtkTopoHasBeg( pObj );
2705 iEnd = Abc_NtkTopoHasEnd( pObj );
2706 printf( "Node %4d : ", Abc_ObjId(pObj) );
2707 for ( k = iEnd - 1; k >= iBeg; k-- )
2708 printf( "%d ", Vec_IntEntry(p->vTopo, k) );
2709 printf( "\n" );
2710 }
2711*/
2712 Vec_IntFreeP( &p->vTopo );
2713 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
2714 // compute regular fanout orders
2715 clk = Abc_Clock();
2716 vVisited = Vec_IntAlloc( 1000 );
2717 Abc_NtkForEachNode( p, pObj, i )
2718 {
2719 Vec_IntClear( vVisited );
2720 Abc_NtkIncrementTravId( p );
2721 Abc_NtkReverse_rec( pObj, vVisited );
2722 }
2723 Vec_IntFree( vVisited );
2724 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
2725}
2726
2757Abc_Ntk_t * Abc_NtkFromPla( char ** pPlas, int nInputs, int nOutputs )
2758{
2759 Fxu_Data_t Params, * p = &Params;
2760 Abc_Ntk_t * pNtkSop, * pNtkAig;
2761 Abc_Obj_t * pNode, * pFanin;
2762 int i, k;
2763 // allocate logic network with SOP local functions
2764 pNtkSop = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_SOP, 1 );
2765 pNtkSop->pName = Extra_FileNameGeneric("pla");
2766 // create primary inputs/outputs
2767 for ( i = 0; i < nInputs; i++ )
2768 Abc_NtkCreatePi( pNtkSop );
2769 for ( i = 0; i < nOutputs; i++ )
2770 Abc_NtkCreatePo( pNtkSop );
2771 Abc_NtkAddDummyPiNames( pNtkSop );
2772 Abc_NtkAddDummyPoNames( pNtkSop );
2773 // create internal nodes
2774 for ( i = 0; i < nOutputs; i++ )
2775 {
2776 pNode = Abc_NtkCreateNode( pNtkSop );
2777 Abc_NtkForEachPi( pNtkSop, pFanin, k )
2778 Abc_ObjAddFanin( pNode, pFanin );
2779 pNode->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkSop->pManFunc, pPlas[i] );
2780 Abc_ObjAddFanin( Abc_NtkPo(pNtkSop, i), pNode );
2781 // check that the number of inputs is the same
2782 assert( Abc_SopGetVarNum((char*)pNode->pData) == nInputs );
2783 }
2784 if ( !Abc_NtkCheck( pNtkSop ) )
2785 fprintf( stdout, "Abc_NtkFromPla(): Network check has failed.\n" );
2786 // perform fast_extract
2788 Abc_NtkFastExtract( pNtkSop, p );
2790 // convert to an AIG
2791 pNtkAig = Abc_NtkStrash( pNtkSop, 0, 1, 0 );
2792 Abc_NtkDelete( pNtkSop );
2793 return pNtkAig;
2794}
2796{
2797 char * pPlas[2] = { "1000 1\n", "0110 1\n0011 1\n" };
2798 Abc_Ntk_t * pNtkAig = Abc_NtkFromPla( pPlas, 4, 2 );
2799 Io_WriteBlifLogic( pNtkAig, "temp.blif", 0 );
2800 Abc_NtkDelete( pNtkAig );
2801}
2802
2814Abc_Ntk_t * Abc_NtkSplitSop( Abc_Ntk_t * pNtk, int nCubesMax, int fVerbose )
2815{
2816 Vec_Ptr_t * vNodes;
2817 Abc_Ntk_t * pNtkNew;
2818 Abc_Obj_t * pObj, * pFanin, * pObjNew, * pObjNewRoot;
2819 int i, k, j, nCubes, nCubesThis, nSplits;
2820 char * pSopStr, * pSopStr2, * pTempSop, Symb;
2821 if ( pNtk == NULL )
2822 return NULL;
2823 assert( !Abc_NtkIsStrash(pNtk) && !Abc_NtkIsNetlist(pNtk) );
2824 // start the network
2825 pNtkNew = Abc_NtkStartFrom( pNtk, pNtk->ntkType, pNtk->ntkFunc );
2826 // copy the internal nodes
2827 vNodes = Abc_NtkDfs( pNtk, 0 );
2828 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
2829 {
2830 assert( Abc_ObjIsNode(pObj) );
2831 pObjNewRoot = Abc_NtkDupObj( pNtkNew, pObj, 0 );
2832 nCubes = Abc_SopGetCubeNum( (char *)pObj->pData );
2833 if ( nCubes <= nCubesMax )
2834 {
2835 Abc_ObjForEachFanin( pObj, pFanin, k )
2836 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
2837 continue;
2838 }
2839 nSplits = (nCubes / nCubesMax) + (int)(nCubes % nCubesMax > 0);
2840 pSopStr = (char *)pObjNewRoot->pData;
2841 pObjNewRoot->pData = Abc_SopCreateOr((Mem_Flex_t *)pNtkNew->pManFunc, nSplits, NULL);
2842 if ( Abc_SopIsComplement(pSopStr) )
2843 {
2844 Abc_SopComplement( pSopStr );
2845 Abc_SopComplement( (char *)pObjNewRoot->pData );
2846 }
2847 pTempSop = (char *)pObj->pData; pObj->pData = (char *)"?";
2848 for ( j = 0; j < nSplits; j++ )
2849 {
2850 // clone the node
2851 pObjNew = Abc_NtkDupObj( pNtkNew, pObj, 0 );
2852 Abc_ObjAddFanin( pObjNewRoot, pObjNew );
2853 // get its cubes
2854 Abc_ObjForEachFanin( pObj, pFanin, k )
2855 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
2856 // create SOP for this node
2857 nCubesThis = (j < nCubes / nCubesMax) ? nCubesMax : nCubes % nCubesMax;
2858 pSopStr2 = pSopStr + (Abc_ObjFaninNum(pObj) + 3) * nCubesThis;
2859 Symb = *pSopStr2; *pSopStr2 = 0;
2860 pObjNew->pData = Abc_SopRegister( (Mem_Flex_t *)pNtkNew->pManFunc, pSopStr );
2861 *pSopStr2 = Symb;
2862 pSopStr = pSopStr2;
2863 }
2864 // update
2865 pObj->pData = pTempSop;
2866 pObj->pCopy = pObjNewRoot;
2867 }
2868 Vec_PtrFree( vNodes );
2869 Abc_NtkFinalize( pNtk, pNtkNew );
2870 // check correctness
2871 if ( !Abc_NtkCheck( pNtkNew ) )
2872 fprintf( stdout, "Abc_NtkDup(): Network check has failed.\n" );
2873 pNtk->pCopy = pNtkNew;
2874 return pNtkNew;
2875}
2876
2889{
2890 Abc_Obj_t * pObj, * pFanin;
2891 int i, k, Counter = 0;
2892 Abc_NtkIncrementTravId( pNtk );
2893 Abc_NtkForEachCi( pNtk, pObj, i )
2894 Abc_NodeSetTravIdCurrent(pObj);
2895 Abc_NtkForEachNode( pNtk, pObj, i )
2896 {
2897 // check if fanins are in the topo order
2898 Abc_ObjForEachFanin( pObj, pFanin, k )
2899 if ( !Abc_NodeIsTravIdCurrent(pFanin) )
2900 break;
2901 if ( k != Abc_ObjFaninNum(pObj) )
2902 {
2903 if ( Counter++ == 0 )
2904 printf( "Node %d is out of topo order.\n", Abc_ObjId(pObj) );
2905 }
2906 Abc_NodeSetTravIdCurrent(pObj);
2907 }
2908 if ( Counter )
2909 printf( "Topological order does not hold for %d internal nodes.\n", Counter );
2910 return (int)(Counter == 0);
2911}
2912
2925{
2926 Abc_Obj_t * pObj;
2927 int i;
2928 assert( pNtk->vPhases != NULL );
2929 assert( Vec_IntSize(pNtk->vPhases) == Abc_NtkObjNumMax(pNtk) );
2930 assert( pNtkNew->vPhases == NULL );
2931 pNtkNew->vPhases = Vec_IntStart( Abc_NtkObjNumMax(pNtkNew) );
2932 Abc_NtkForEachObj( pNtk, pObj, i )
2933 if ( pObj->pCopy && !Abc_ObjIsNone( (Abc_Obj_t *)pObj->pCopy ) )
2934 Vec_IntWriteEntry( pNtkNew->vPhases, Abc_ObjId( (Abc_Obj_t *)pObj->pCopy ), Vec_IntEntry(pNtk->vPhases, i) );
2935}
2936
2948Abc_Ntk_t * Abc_NtkDeriveWithOnePo( Abc_Ntk_t * pNtk, Vec_Int_t * vNodeIds, Vec_Int_t * vNodeValues )
2949{
2950 int fCopyNames = 1;
2951 Abc_Ntk_t * pNtkNew;
2952 Abc_Obj_t * pObj, * pFanin, * pObjNew, * pOutputNew;
2953 Vec_Ptr_t * vFanins = Vec_PtrAlloc( 100 );
2954 int i, k, Id, Value;
2955 // start the network
2956 pNtkNew = Abc_NtkAlloc( pNtk->ntkType, pNtk->ntkFunc, 1 );
2957 // duplicate the name and the spec
2958 pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
2959 pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
2960 // clean the node copy fields
2961 Abc_NtkCleanCopy( pNtk );
2962 // map the constant nodes
2963 if ( Abc_NtkIsStrash(pNtk) && Abc_NtkIsStrash(pNtkNew) )
2964 Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
2965 // clone CIs/CIs/boxes
2966 Abc_NtkForEachPi( pNtk, pObj, i )
2967 Abc_NtkDupObj( pNtkNew, pObj, fCopyNames );
2968 //Abc_NtkForEachPo( pNtk, pObj, i )
2969 // Abc_NtkDupObj( pNtkNew, pObj, fCopyNames );
2970 // create one PO
2971 pObjNew = Abc_NtkCreateObj( pNtkNew, ABC_OBJ_PO );
2972 Abc_ObjAssignName( pObjNew, "monitor", NULL );
2973 // create boxes
2974 Abc_NtkForEachBox( pNtk, pObj, i )
2975 Abc_NtkDupBox( pNtkNew, pObj, fCopyNames );
2976
2977 // duplicate nodes (CIs/COs/latches are already duplicated)
2978 Abc_NtkForEachObj( pNtk, pObj, i )
2979 if ( pObj->pCopy == NULL && !Abc_ObjIsPo(pObj) )
2980 Abc_NtkDupObj(pNtkNew, pObj, 0);
2981 // reconnect all objects except boxes (they are already connected) and POs (they will be connected later)
2982 Abc_NtkForEachObj( pNtk, pObj, i )
2983 if ( !Abc_ObjIsPo(pObj) && !Abc_ObjIsBox(pObj) && !Abc_ObjIsBo(pObj) )
2984 Abc_ObjForEachFanin( pObj, pFanin, k )
2985 Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
2986
2987 // AND nodes (with interters if needed)
2988 pOutputNew = NULL;
2989 Vec_IntForEachEntryTwo( vNodeIds, vNodeValues, Id, Value, i )
2990 {
2991 pObjNew = Abc_NtkObj( pNtk, Id )->pCopy;
2992 if ( Value == 0 ) // negative polarity - add inverter
2993 pObjNew = Abc_NtkCreateNodeInv( pNtkNew, pObjNew );
2994 if ( pOutputNew == NULL )
2995 pOutputNew = pObjNew;
2996 else
2997 {
2998 Vec_PtrFillTwo( vFanins, 2, pOutputNew, pObjNew );
2999 pOutputNew = Abc_NtkCreateNodeAnd( pNtkNew, vFanins );
3000 }
3001 }
3002 Vec_PtrFree( vFanins );
3003 // create the only POs, which is the AND of the corresponding nodes
3004 Abc_ObjAddFanin( Abc_NtkPo(pNtkNew, 0), pOutputNew );
3005
3006 // check that the CI/CO/latches are copied correctly
3007 assert( Abc_NtkPoNum(pNtkNew) == 1 );
3008 assert( Abc_NtkCiNum(pNtkNew) == Abc_NtkCiNum(pNtk) );
3009 assert( Abc_NtkLatchNum(pNtkNew) == Abc_NtkLatchNum(pNtk) );
3010 return pNtkNew;
3011}
3012
3030{
3031 Abc_Ntk_t * pMonitor, * pStrashed, * pResult;
3032 // sequential cleanup parameters
3033 int fLatchConst = 1;
3034 int fLatchEqual = 1;
3035 int fSaveNames = 1;
3036 int fUseMvSweep = 0;
3037 int nFramesSymb = 1;
3038 int nFramesSatur = 512;
3039 int fVerbose = 0;
3040 int fVeryVerbose = 0;
3041 // expecting sequential logic network
3042 assert( Abc_NtkIsLogic(p) );
3043 assert( Abc_NtkLatchNum(p) > 0 );
3044 assert( Vec_IntSize(vNodeIds) > 0 );
3045 assert( Vec_IntSize(vNodeIds) == Vec_IntSize(vNodeValues) );
3046 // derive ABC network whose only output is 1 iff the given nodes have the given values
3047 pMonitor = Abc_NtkDeriveWithOnePo( p, vNodeIds, vNodeValues );
3048 // perform structural hashing
3049 pStrashed = Abc_NtkStrash( pMonitor, 0, 1, 0 );
3050 Abc_NtkDelete( pMonitor );
3051 // it is a good idea to run sequential cleanup before giving the network to PDR
3052 pResult = Abc_NtkDarLatchSweep( pStrashed, fLatchConst, fLatchEqual, fSaveNames, fUseMvSweep, nFramesSymb, nFramesSatur, fVerbose, fVeryVerbose );
3053 Abc_NtkDelete( pStrashed );
3054 return pResult;
3055}
3056
3069{
3070 Abc_Ntk_t * pNtk;
3071 Vec_Int_t * vNodeIds = Vec_IntAlloc( 100 );
3072 Vec_Int_t * vNodeValues = Vec_IntAlloc( 100 );
3073
3074 // this test will only work for the network, which has nodes with internal IDs such as these
3075 Vec_IntPush( vNodeIds, 90 );
3076 Vec_IntPush( vNodeIds, 80 );
3077 Vec_IntPush( vNodeIds, 100 );
3078
3079 Vec_IntPush( vNodeValues, 1 );
3080 Vec_IntPush( vNodeValues, 0 );
3081 Vec_IntPush( vNodeValues, 1 );
3082
3083 pNtk = Abc_NtkCreatePropertyMonitor( p, vNodeIds, vNodeValues );
3084
3085 Vec_IntFree( vNodeIds );
3086 Vec_IntFree( vNodeValues );
3087
3088 return pNtk;
3089}
3090
3103{
3104 char * pGateName = Mio_GateReadName((Mio_Gate_t *)pObj->pData);
3105 if ( !strncmp(pGateName, "buf", 3) ) return ABC_OPER_BIT_BUF;
3106 if ( !strncmp(pGateName, "inv", 3) ) return ABC_OPER_BIT_INV;
3107 if ( !strncmp(pGateName, "and", 3) ) return ABC_OPER_BIT_AND;
3108 if ( !strncmp(pGateName, "nand", 4) ) return ABC_OPER_BIT_NAND;
3109 if ( !strncmp(pGateName, "or", 2) ) return ABC_OPER_BIT_OR;
3110 if ( !strncmp(pGateName, "nor", 3) ) return ABC_OPER_BIT_NOR;
3111 if ( !strncmp(pGateName, "xor", 3) ) return ABC_OPER_BIT_XOR;
3112 if ( !strncmp(pGateName, "xnor", 4) ) return ABC_OPER_BIT_NXOR;
3113 if ( !strncmp(pGateName, "zero", 4) ) return ABC_OPER_CONST_F;
3114 if ( !strncmp(pGateName, "one", 3) ) return ABC_OPER_CONST_T;
3115 assert( 0 );
3116 return -1;
3117}
3119{
3120 Vec_Wec_t * vRes = NULL;
3121 Abc_Ntk_t * pNtk = Abc_NtkCreateFromSops( "top", vSops );
3122 Abc_Ntk_t * pNtkNew;
3123 Abc_Obj_t * pObj, * pFanin;
3124 int i, k, iNode = 0;
3126 //Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "fx; strash; balance; dc2; map -a" );
3128 Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "st; collapse; sop; fx; strash; &get; &ps; &deepsyn -I 4 -J 50 -T 5 -S 111 -t; &ps; &put; map -a" );
3131 vRes = Vec_WecStart( Abc_NtkPiNum(pNtkNew) + Abc_NtkNodeNum(pNtkNew) + Abc_NtkPoNum(pNtkNew) );
3132 Abc_NtkForEachPi( pNtkNew, pObj, i )
3133 pObj->iTemp = iNode++;
3134 Abc_NtkForEachNode( pNtkNew, pObj, i )
3135 {
3136 Vec_Int_t * vNode = Vec_WecEntry(vRes, iNode);
3137 Vec_IntPush( vNode, Abc_GateToType(pObj) );
3138 Vec_IntPush( vNode, iNode );
3139 Abc_ObjForEachFanin( pObj, pFanin, k )
3140 Vec_IntPush( vNode, pFanin->iTemp );
3141 pObj->iTemp = iNode++;
3142 }
3143 Abc_NtkForEachPo( pNtkNew, pObj, i )
3144 Vec_IntPushTwo( Vec_WecEntry(vRes, iNode++), ABC_OPER_BIT_BUF, Abc_ObjFanin0(pObj)->iTemp );
3145 assert( Vec_WecSize(vRes) == iNode );
3146 return vRes;
3147}
3149{
3150 Vec_Wec_t * vRes = NULL;
3151 Abc_Ntk_t * pNtk = Abc_NtkCreateFromGias( "top", vGias, pMulti );
3152 Abc_Ntk_t * pNtkNew;
3153 Abc_Obj_t * pObj, * pFanin;
3154 int i, k, iNode = 0;
3157 Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "clp; sop; fx; strash; compress2rs; dch; map -a; strash; compress2rs; dch; map -a" );
3160 vRes = Vec_WecStart( Abc_NtkPiNum(pNtkNew) + Abc_NtkNodeNum(pNtkNew) + Abc_NtkPoNum(pNtkNew) );
3161 Abc_NtkForEachPi( pNtkNew, pObj, i )
3162 pObj->iTemp = iNode++;
3163 Abc_NtkForEachNode( pNtkNew, pObj, i )
3164 {
3165 Vec_Int_t * vNode = Vec_WecEntry(vRes, iNode);
3166 Vec_IntPush( vNode, Abc_GateToType(pObj) );
3167 Vec_IntPush( vNode, iNode );
3168 Abc_ObjForEachFanin( pObj, pFanin, k )
3169 Vec_IntPush( vNode, pFanin->iTemp );
3170 pObj->iTemp = iNode++;
3171 }
3172 Abc_NtkForEachPo( pNtkNew, pObj, i )
3173 Vec_IntPushTwo( Vec_WecEntry(vRes, iNode++), ABC_OPER_BIT_BUF, Abc_ObjFanin0(pObj)->iTemp );
3174 assert( Vec_WecSize(vRes) == iNode );
3175 return vRes;
3176}
3178{
3179 Abc_Ntk_t * pNtkNew, * pNtk;
3180 Vec_Ptr_t * vGias = Vec_PtrAlloc( 1 );
3181 Vec_PtrPush( vGias, p );
3182 pNtk = Abc_NtkCreateFromGias( "top", vGias, NULL );
3183 Vec_PtrFree( vGias );
3185 Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "balance; collapse; muxes; strash; dc2" );
3187 return Abc_NtkClpGia( pNtkNew );
3188}
3189
3202{
3203 int iLit0, iLit1;
3204 if ( Abc_NodeIsTravIdCurrent(pNode) || Abc_ObjFaninNum(pNode) == 0 || Abc_ObjIsCi(pNode) )
3205 return pNode->iTemp;
3206 assert( Abc_ObjIsNode( pNode ) );
3207 Abc_NodeSetTravIdCurrent( pNode );
3208 iLit0 = Abc_NtkClpOneGia_rec( pNew, Abc_ObjFanin0(pNode) );
3209 iLit1 = Abc_NtkClpOneGia_rec( pNew, Abc_ObjFanin1(pNode) );
3210 iLit0 = Abc_LitNotCond( iLit0, Abc_ObjFaninC0(pNode) );
3211 iLit1 = Abc_LitNotCond( iLit1, Abc_ObjFaninC1(pNode) );
3212 return (pNode->iTemp = Gia_ManHashAnd(pNew, iLit0, iLit1));
3213}
3215{
3216 int i, iLit;
3217 Abc_Obj_t * pNode;
3218 Gia_Man_t * pNew, * pTemp;
3219 assert( Abc_NtkIsStrash(pNtk) );
3220 Abc_NtkForEachObj( pNtk, pNode, i )
3221 pNode->iTemp = -1;
3222 // start new manager
3223 pNew = Gia_ManStart( Abc_NtkObjNum(pNtk) );
3224 pNew->pName = Abc_UtilStrsav( pNtk->pName );
3225 pNew->pSpec = Abc_UtilStrsav( pNtk->pSpec );
3226 Gia_ManHashStart( pNew );
3227 // primary inputs
3228 Abc_AigConst1(pNtk)->iTemp = 1;
3229 Abc_NtkForEachCi( pNtk, pNode, i )
3230 pNode->iTemp = Gia_ManAppendCi(pNew);
3231 // create the first cone
3232 Abc_NtkIncrementTravId( pNtk );
3233 Abc_NtkForEachCo( pNtk, pNode, i )
3234 {
3235 iLit = Abc_NtkClpOneGia_rec( pNew, Abc_ObjFanin0(pNode) );
3236 iLit = Abc_LitNotCond( iLit, Abc_ObjFaninC0(pNode) );
3237 Gia_ManAppendCo( pNew, iLit );
3238 }
3239 // perform cleanup
3240 pNew = Gia_ManCleanup( pTemp = pNew );
3241 Gia_ManStop( pTemp );
3242 return pNew;
3243}
3244Gia_Man_t * Abc_SopSynthesizeOne( char * pSop, int fClp )
3245{
3246 Abc_Ntk_t * pNtkNew, * pNtk;
3247 Vec_Ptr_t * vSops;
3248 if ( strlen(pSop) == 3 )
3249 {
3250 Gia_Man_t * pNew = Gia_ManStart( 1 );
3251 pNew->pName = Abc_UtilStrsav( "top" );
3252 //Gia_ManAppendCi( pNew );
3253 assert( pSop[1] == '0' || pSop[1] == '1' );
3254 Gia_ManAppendCo( pNew, pSop[1] == '1' );
3255 return pNew;
3256 }
3257 vSops = Vec_PtrAlloc( 1 );
3258 Vec_PtrPush( vSops, pSop );
3259 pNtk = Abc_NtkCreateFromSops( "top", vSops );
3260 Vec_PtrFree( vSops );
3263 if ( fClp )
3265 Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "fx; strash; balance; dc2" );
3268 return Abc_NtkStrashToGia( pNtkNew );
3269}
3270
3271
3283static int s_ArraySize = 145;
3284static int s_ArrayData[290] = {
3285 0, 0,
3286 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3287 10, 6, 14, 12, 10, 2, 22, 20, 2, 24, 16, 4, 28, 18, 16, 10, 8, 4, 34, 32, 30, 36, 38, 26, 16, 6, 36, 20, 44, 42, 46, 40, 42, 44, 14, 6, 52, 34, 32, 54, 56, 50, 58, 48, 32, 24, 20, 2, 12, 6, 66, 34, 68, 64, 62, 70, 28, 68, 74, 72, 76, 58, 70, 62, 80, 78, 68, 28, 84, 74, 4, 2, 88, 20, 64, 90, 92, 86, 66, 32, 18, 96, 98, 56, 100, 94, 52, 36, 104, 38, 90, 42, 36, 2, 108, 110, 112, 106, 114, 100, 102, 116, 118, 82, 116, 60, 120, 122, 124, 60, 118, 60, 102, 82, 128, 130, 132, 82, 134, 126, 82, 116, 122, 138, 122, 118, 142, 140, 60, 102, 130, 146, 130, 118, 150, 148, 152, 144, 154, 136, 18, 156, 144, 126, 68, 160, 32, 136, 164, 162, 166, 158, 28, 160, 70, 126, 90, 144, 174, 172, 176, 170, 152, 134, 36, 180, 2, 134, 184, 182, 186, 178, 188, 168, 64, 144, 164, 158, 194, 192, 96, 156, 44, 154, 200, 170, 202, 198, 204, 176, 206, 196, 204, 168, 62, 126, 212, 186, 24, 134, 108, 152, 218, 192, 220, 216, 222, 214, 224, 210, 220, 194, 110, 152, 30, 180, 232, 230, 184, 172, 236, 234, 238, 228, 234, 182, 242, 220, 244, 168, 42, 154, 248, 202, 54, 136, 252, 164, 254, 214, 256, 250, 218, 194, 252, 198, 262, 242, 264, 260, 232, 220, 268, 262, 270, 168,
3288 191, 191, 209, 209, 226, 226, 240, 240, 246, 246, 259, 259, 267, 267, 272, 272,
3289};
3291{
3292 int i;
3293 for ( i = 1; i < s_ArraySize; i++ )
3294 if ( s_ArrayData[2*i] || s_ArrayData[2*i+1] )
3295 break;
3296 for ( ; i < s_ArraySize; i++ )
3297 if ( s_ArrayData[2*i] < 2 && s_ArrayData[2*i+1] < 2 )
3298 return 1;
3299 return 0;
3300}
3302{
3303 Vec_Ptr_t * vNodes = Vec_PtrAlloc( s_ArraySize ); int i, nPos = 0;
3305 Abc_Obj_t * pObjNew = Abc_NtkHasConstNode() ? Abc_NtkCreateNode(pNtkNew) : NULL;
3306 if ( pObjNew ) pObjNew->pData = Abc_SopCreateConst0((Mem_Flex_t *)pNtkNew->pManFunc);
3307 Vec_PtrPush( vNodes, pObjNew );
3308 for ( i = 1; i < s_ArraySize; i++ )
3309 if ( !s_ArrayData[2*i] && !s_ArrayData[2*i+1] )
3310 Vec_PtrPush( vNodes, Abc_NtkCreatePi(pNtkNew) );
3311 else
3312 break;
3313 for ( ; i < s_ArraySize; i++ )
3314 {
3315 char * pSop = NULL;
3316 if ( s_ArrayData[2*i] > s_ArrayData[2*i+1] )
3317 pSop = Abc_SopCreateXor( (Mem_Flex_t *)pNtkNew->pManFunc, 2 );
3318 else if ( s_ArrayData[2*i] < s_ArrayData[2*i+1] )
3319 pSop = Abc_SopCreateAnd( (Mem_Flex_t *)pNtkNew->pManFunc, 2, NULL );
3320 else
3321 break;
3322 pObjNew = Abc_NtkCreateNode( pNtkNew );
3323 Abc_ObjAddFanin( pObjNew, (Abc_Obj_t *)Vec_PtrEntry(vNodes, Abc_Lit2Var(s_ArrayData[2*i])) );
3324 Abc_ObjAddFanin( pObjNew, (Abc_Obj_t *)Vec_PtrEntry(vNodes, Abc_Lit2Var(s_ArrayData[2*i+1])) );
3325 if ( Abc_LitIsCompl(s_ArrayData[2*i]) ) Abc_SopComplementVar( pSop, 0 );
3326 if ( Abc_LitIsCompl(s_ArrayData[2*i+1]) ) Abc_SopComplementVar( pSop, 1 );
3327 pObjNew->pData = pSop;
3328 Vec_PtrPush( vNodes, pObjNew );
3329 }
3330 for ( ; i < s_ArraySize; i++ )
3331 {
3332 char * pSop = NULL;
3333 assert( s_ArrayData[2*i] == s_ArrayData[2*i+1] );
3334 pObjNew = Abc_NtkCreateNode( pNtkNew );
3335 Abc_ObjAddFanin( pObjNew, (Abc_Obj_t *)Vec_PtrEntry(vNodes, Abc_Lit2Var(s_ArrayData[2*i])) );
3336 if ( Abc_LitIsCompl(s_ArrayData[2*i]) )
3337 pSop = Abc_SopCreateInv( (Mem_Flex_t *)pNtkNew->pManFunc );
3338 else
3339 pSop = Abc_SopCreateBuf( (Mem_Flex_t *)pNtkNew->pManFunc );
3340 pObjNew->pData = pSop;
3341 Vec_PtrPush( vNodes, pObjNew );
3342 nPos++;
3343 }
3344 for ( i = 0; i < nPos; i++ )
3345 Abc_ObjAddFanin( Abc_NtkCreatePo(pNtkNew), (Abc_Obj_t *)Vec_PtrEntry(vNodes, s_ArraySize-nPos+i) );
3346 Vec_PtrFree( vNodes );
3347 pNtkNew->pName = Extra_UtilStrsav("test");
3348 Abc_NtkAddDummyPiNames( pNtkNew );
3349 Abc_NtkAddDummyPoNames( pNtkNew );
3350 Abc_NtkAddDummyBoxNames( pNtkNew );
3351 if ( !Abc_NtkCheck( pNtkNew ) )
3352 Abc_Print( 1, "Abc_NtkFromArray(): Network check has failed.\n" );
3353 return pNtkNew;
3354}
3355
3367void Abc_PrintAT( Vec_Int_t * vRanks )
3368{
3369 int i, Entry;
3370 Vec_IntForEachEntryReverse( vRanks, Entry, i )
3371 if ( Entry == 0 )
3372 printf( " " );
3373 else
3374 printf( "%4d", Entry );
3375 //printf( "\n" );
3376}
3377int Abc_NtkMatchGpcPattern( Vec_Int_t * vRanks, int i, char * pGPC )
3378{
3379 int k, Cur, Min = ABC_INFINITY;
3380 for ( k = 0; pGPC[k] != ':' && i+k < Vec_IntSize(vRanks); k++ ) {
3381 if ( Abc_TtReadHexDigit(pGPC[k]) == 0 )
3382 continue;
3383 Cur = Vec_IntEntry(vRanks, i+k) / Abc_TtReadHexDigit(pGPC[k]);
3384 if ( Min > Cur )
3385 Min = Cur;
3386 }
3387 return Min;
3388}
3389void Abc_NtkUpdateGpcPattern( Vec_Int_t * vRank, int i, char * pGPC, int nGpcs, Vec_Int_t * vRank2, Vec_Int_t * vLevel )
3390{
3391 int k; char * pOut = strstr(pGPC, ":");
3392 assert( pOut && pOut[0] == ':' );
3393 pOut++;
3394 Vec_IntAddToEntry( vLevel, i, nGpcs );
3395 for ( k = 0; pGPC[k] != ':'; k++ )
3396 Vec_IntAddToEntry( vRank, i+k, -nGpcs * Abc_TtReadHexDigit(pGPC[k]) );
3397 for ( k = 0; pOut[k] != ':'; k++ )
3398 Vec_IntAddToEntry( vRank2, i+k, nGpcs * Abc_TtReadHexDigit(pOut[k]) );
3399}
3400int Abc_NtkGetGpcLutCount( char * pGPC )
3401{
3402 char * pOut = strstr(pGPC, ":");
3403 char * pLut = strstr(pOut+1, ":");
3404 return atoi(pLut+1);
3405}
3406static inline int Vec_WecSum( Vec_Wec_t * p )
3407{
3408 Vec_Int_t * vVec;
3409 int i, Counter = 0;
3410 Vec_WecForEachLevel( p, vVec, i )
3411 Counter += Vec_IntSum(vVec);
3412 return Counter;
3413}
3414char ** Abc_NtkTransformGPCs( char ** pGPCs, int nGPCs )
3415{
3416 char * pOut, * pLut, ** pRes = ABC_ALLOC( char *, nGPCs );
3417 int i, k, nLength;
3418 for ( i = 0; i < nGPCs; i++ ) {
3419 pRes[i] = Abc_UtilStrsav(pGPCs[i]);
3420 pOut = strstr(pRes[i], ":");
3421 nLength = (int)(pOut-pRes[i]);
3422 for ( k = 0; k < nLength/2; k++ )
3423 ABC_SWAP( char, pRes[i][k], pRes[i][nLength-1-k] )
3424 pLut = strstr(pOut+1, ":");
3425 nLength = (int)(pLut-pOut-1);
3426 for ( k = 0; k < nLength/2; k++ )
3427 ABC_SWAP( char, pOut[1+k], pOut[1+nLength-1-k] )
3428 }
3429 return pRes;
3430}
3431int Abc_NtkCheckGpc( char * pGPC, char * pGPC0 )
3432{
3433 int RetValue = 0, k, Sum[2] = {0};
3434 char * pOut = strstr(pGPC, ":");
3435 for ( k = 0; pGPC[k] != ':'; k++ )
3436 Sum[0] += (1 << k) * Abc_TtReadHexDigit(pGPC[k]);
3437 for ( k = 0; pOut[1+k] != ':'; k++ )
3438 Sum[1] += (1 << k) * Abc_TtReadHexDigit(pOut[1+k]);
3439 //printf( "GPC %s has input sum %d and output sum %d\n", pGPC0, Sum[0], Sum[1] );
3440 if ( Sum[0]+1 > (1 << Abc_Base2Log(Sum[1]+1)) )
3441 printf( "The largest value of GPC inputs (%d) exceeds the capacity of outputs (%d) for GPC %s.\n", Sum[0], Sum[1], pGPC0 );
3442 else if ( Sum[1]+1 > (1 << Abc_Base2Log(Sum[0]+1)) )
3443 printf( "The largest value of GPC outputs (%d) exceeds the capacity of inputs (%d) for GPC %s.\n", Sum[1], Sum[0], pGPC0 );
3444 else
3445 RetValue = 1;
3446 return RetValue;
3447}
3448void Abc_NtkATMap( int nXVars, int nYVars, int nAdder, char ** pGPCs0, int nGPCs, int fReturn, int fVerbose )
3449{
3450 abctime clkStart = Abc_Clock();
3451 char ** pGPCs = Abc_NtkTransformGPCs(pGPCs0, nGPCs);
3452 int i, nGPCluts[100] = {0};
3453 for ( i = 0; i < nGPCs; i++ )
3454 if ( !Abc_NtkCheckGpc(pGPCs[i], pGPCs0[i]) )
3455 return;
3456 for ( i = 0; i < nGPCs; i++ )
3457 nGPCluts[i] = Abc_NtkGetGpcLutCount(pGPCs[i]);
3458 int x, n, Entry, iLevel = 0, Sum = 0, nGpcs = 0, nBits, fFinished, nRcaLuts = 0, nLuts = 0;
3459 for ( x = 0; x < nXVars; x++ )
3460 Sum += (1 << x) * nYVars;
3461 nBits = Abc_Base2Log( Sum+1 );
3462 printf( "Rectangular adder tree (X=%d Y=%d Sum=%d Out=%d) mapped with", nXVars, nYVars, Sum, nBits );
3463 for ( i = 0; i < nGPCs; i++ )
3464 printf( " GPC%d=%s", i, pGPCs0[i] );
3465 printf( "\n" );
3466 Vec_Int_t * vLevel;
3467 Vec_Int_t * vRank[3] = { Vec_IntAlloc(100), Vec_IntAlloc(100), Vec_IntAlloc(100) };
3468 Vec_Wec_t ** vGPCs = ABC_ALLOC( Vec_Wec_t *, nGPCs );
3469 for ( i = 0; i < nGPCs; i++ )
3470 vGPCs[i] = Vec_WecAlloc(100);
3471 Vec_IntFill( vRank[0], nBits, 0 );
3472 for ( x = 0; x < nXVars; x++ )
3473 Vec_IntAddToEntry( vRank[0], x, nYVars );
3474 if ( fVerbose ) {
3475 printf( "Ranks: " );
3476 for ( i = nBits-1; i >= 0; i-- )
3477 printf( "%4d", i );
3478 printf( " : " );
3479 for ( i = nBits-1; i >= 0; i-- )
3480 printf( "%4d", i );
3481 printf( " LUT6\n" );
3482 }
3483 for ( n = 0; n < nGPCs; n++ )
3484 for ( i = 0, fFinished = 0; !fFinished; i++ )
3485 {
3486 int fAdded = 0;
3487 vLevel = Vec_WecPushLevel( vGPCs[n] );
3488 Vec_IntFill( vLevel, nBits, 0 );
3489 Vec_IntFill( vRank[1], nBits, 0 );
3490 Vec_IntClear( vRank[2] );
3491 Vec_IntAppend( vRank[2], vRank[0] );
3492 fFinished = 1;
3493 if ( Vec_IntFindMax(vRank[0]) > nAdder ) {
3494 for ( x = 0; x < nBits; x++ )
3495 if ( (nGpcs = Abc_NtkMatchGpcPattern(vRank[0], x, pGPCs[n])) )
3496 Abc_NtkUpdateGpcPattern(vRank[0], x, pGPCs[n], nGpcs, vRank[1], vLevel), fFinished = 0, fAdded = 1;
3497 nLuts += Vec_IntSum(vLevel) * nGPCluts[n];
3498 Vec_IntForEachEntry( vRank[1], Entry, x )
3499 Vec_IntAddToEntry( vRank[0], x, Entry );
3500 }
3501 if ( fVerbose && (fAdded || Vec_IntFindMax(vRank[2]) <= nAdder ) ) {
3502 printf( "Lev%02d: ", iLevel++ );
3503 Abc_PrintAT( vRank[2] );
3504 if ( fAdded ) {
3505 printf( " GPC%d: ", n );
3506 Abc_PrintAT( vLevel );
3507 printf( " %4d", Vec_IntSum(vLevel) * nGPCluts[n] );
3508 }
3509 else if ( Vec_IntFindMax(vRank[2]) <= nAdder ) {
3510 printf( " ADD%d: ", nAdder );
3511 for ( x = 0; x < nBits; x++ )
3512 if ( Vec_IntEntry(vRank[2], x) > 1 )
3513 break;
3514 for ( i = nBits-1; i >= x; i-- )
3515 printf( "%4d", 1 );
3516 for ( ; i >= 0; i-- )
3517 printf( " " );
3518 printf( " %4d", (nBits-x)*(nAdder == 4 ? 2 : 1) );
3519 }
3520 printf( "\n" );
3521 }
3522 if ( fAdded ) {
3523 if ( fReturn ) {
3524 fFinished = 1;
3525 n = -1;
3526 }
3527 }
3528 else if ( Vec_IntFindMax(vRank[2]) <= nAdder ) {
3529 fFinished = 1;
3530 n = nGPCs;
3531 }
3532 }
3533 if ( Vec_IntFindMax(vRank[0]) > nAdder )
3534 printf( "Synthesis of the adder tree is incomplete. Try using the full adder \"3:11:1\" as the last GPC.\n" );
3535 else if ( fVerbose && Vec_IntFindMax(vRank[0]) <= nAdder ) {
3536 printf( "Lev%02d: ", iLevel++ );
3537 for ( i = nBits-1; i >= 0; i-- )
3538 printf( "%4d", 1 );
3539 printf( "\n" );
3540 }
3541 printf( "Statistics: " );
3542 for ( n = 0; n < nGPCs; n++ )
3543 printf( "GPC%d = %d. ", n, Vec_WecSum(vGPCs[n]) );
3544 for ( x = 0; x < nBits; x++ )
3545 if ( Vec_IntEntry(vRank[0], x) > 1 )
3546 break;
3547 nRcaLuts = (nBits-x)*(nAdder == 4 ? 2 : 1);
3548 printf( "ADD%d = %d. ", nAdder, nRcaLuts );
3549 printf( "Total LUT count = %d. ", nLuts+nRcaLuts );
3550 for ( i = 0; i < 3; i++ )
3551 Vec_IntFree( vRank[i] );
3552 for ( i = 0; i < nGPCs; i++ )
3553 Vec_WecFree( vGPCs[i] );
3554 ABC_FREE( vGPCs );
3555 for ( i = 0; i < nGPCs; i++ )
3556 ABC_FREE( pGPCs[i] );
3557 ABC_FREE( pGPCs );
3558 Abc_PrintTime( 0, "Total time", Abc_Clock() - clkStart );
3559}
3560
3564
3565
3567
void Abc_NtkFxuFreeInfo(Fxu_Data_t *p)
Definition abcFxu.c:207
void Abc_NtkSetDefaultFxParams(Fxu_Data_t *p)
FUNCTION DEFINITIONS ///.
Definition abcFxu.c:52
int Abc_NtkFastExtract(Abc_Ntk_t *pNtk, Fxu_Data_t *p)
Definition abcFxu.c:83
@ ABC_OPER_CONST_F
Definition abcOper.h:50
@ ABC_OPER_BIT_NAND
Definition abcOper.h:58
@ ABC_OPER_BIT_XOR
Definition abcOper.h:61
@ ABC_OPER_CONST_T
Definition abcOper.h:51
@ ABC_OPER_BIT_INV
Definition abcOper.h:56
@ ABC_OPER_BIT_AND
Definition abcOper.h:57
@ ABC_OPER_BIT_NOR
Definition abcOper.h:60
@ ABC_OPER_BIT_OR
Definition abcOper.h:59
@ ABC_OPER_BIT_BUF
Definition abcOper.h:55
@ ABC_OPER_BIT_NXOR
Definition abcOper.h:62
void Abc_NtkCompareCones(Abc_Ntk_t *pNtk)
Definition abcUtil.c:2126
Abc_Ntk_t * Abc_NtkCreatePropertyMonitor(Abc_Ntk_t *p, Vec_Int_t *vNodeIds, Vec_Int_t *vNodeValues)
Definition abcUtil.c:3029
Abc_Obj_t * Abc_NodeHasUniqueCoFanout(Abc_Obj_t *pNode)
Definition abcUtil.c:856
int Abc_NtkGetBddNodeNum(Abc_Ntk_t *pNtk)
Definition abcUtil.c:247
Abc_Obj_t * Abc_NodeFindNonCoFanout(Abc_Obj_t *pNode)
Definition abcUtil.c:833
void Abc_NtkCompareSupports(Abc_Ntk_t *pNtk)
Definition abcUtil.c:2208
int Abc_NtkAddBuffsEval(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
Definition abcUtil.c:2289
int Abc_ObjPointerCompare(void **pp1, void **pp2)
Definition abcUtil.c:1939
int Abc_NodeCompareLevelsDecrease(Abc_Obj_t **pp1, Abc_Obj_t **pp2)
Definition abcUtil.c:1715
void Abc_NtkOrderCisCos(Abc_Ntk_t *pNtk)
Definition abcUtil.c:76
void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition abcUtil.c:540
Vec_Wec_t * Abc_SopSynthesize(Vec_Ptr_t *vSops)
Definition abcUtil.c:3118
Gia_Man_t * Abc_GiaSynthesizeInter(Gia_Man_t *p)
Definition abcUtil.c:3177
int Abc_NodeIsMuxType(Abc_Obj_t *pNode)
Definition abcUtil.c:1342
void Abc_NtkCleanMarkB(Abc_Ntk_t *pNtk)
Definition abcUtil.c:715
void Abc_NtkCleanNext_rec(Abc_Ntk_t *pNtk)
Definition abcUtil.c:676
void Abc_NtkATMap(int nXVars, int nYVars, int nAdder, char **pGPCs0, int nGPCs, int fReturn, int fVerbose)
Definition abcUtil.c:3448
void Abc_NtkFromPlaTest()
Definition abcUtil.c:2795
Abc_Ntk_t * Abc_NtkCreatePropertyMonitorTest(Abc_Ntk_t *p)
Definition abcUtil.c:3068
Abc_Ntk_t * Abc_NtkSopToCubes(Abc_Ntk_t *pNtk, int fXor)
Definition abcUtil.c:2588
void Abc_NtkTransferPhases(Abc_Ntk_t *pNtkNew, Abc_Ntk_t *pNtk)
Definition abcUtil.c:2924
void Abc_NtkReverse_rec(Abc_Obj_t *pObj, Vec_Int_t *vVisited)
Definition abcUtil.c:2682
Abc_Obj_t * Abc_NtkAddBuffsOne(Vec_Ptr_t *vBuffs, Abc_Obj_t *pFanin, int Level, int nLevelMax)
Definition abcUtil.c:2330
void Abc_NtkCleanMarkA(Abc_Ntk_t *pNtk)
Definition abcUtil.c:696
void Abc_NtkCleanNext(Abc_Ntk_t *pNtk)
Definition abcUtil.c:669
int Abc_NtkCompareConesCompare(int *pNum1, int *pNum2)
Definition abcUtil.c:2106
void Abc_PrintAT(Vec_Int_t *vRanks)
Definition abcUtil.c:3367
int Abc_NtkClpOneGia_rec(Gia_Man_t *pNew, Abc_Obj_t *pNode)
Definition abcUtil.c:3201
double Abc_NtkGetMappedArea(Abc_Ntk_t *pNtk)
Definition abcUtil.c:347
int Abc_NtkLogicHasSimpleCos(Abc_Ntk_t *pNtk)
Definition abcUtil.c:942
int Abc_NtkPrepareTwoNtks(FILE *pErr, Abc_Ntk_t *pNtk, char **argv, int argc, Abc_Ntk_t **ppNtk1, Abc_Ntk_t **ppNtk2, int *pfDelete1, int *pfDelete2, int fCheck)
Definition abcUtil.c:1522
Vec_Ptr_t * Abc_NtkCollectLatches(Abc_Ntk_t *pNtk)
Definition abcUtil.c:1667
Abc_Ntk_t * Abc_NtkFromPla(char **pPlas, int nInputs, int nOutputs)
Definition abcUtil.c:2757
void Abc_VecObjPushUniqueOrderByLevel(Vec_Ptr_t *p, Abc_Obj_t *pNode)
Definition abcUtil.c:1269
int Abc_NtkCrossCut_rec(Abc_Obj_t *pObj, int *pnCutSize, int *pnCutSizeMax)
Definition abcUtil.c:2002
int Abc_NtkGetLitFactNum(Abc_Ntk_t *pNtk)
Definition abcUtil.c:196
Abc_Ntk_t * Abc_NtkDeriveWithOnePo(Abc_Ntk_t *pNtk, Vec_Int_t *vNodeIds, Vec_Int_t *vNodeValues)
Definition abcUtil.c:2948
float Abc_NtkComputeDelay(Abc_Ntk_t *pNtk)
Definition abcUtil.c:2488
int Abc_NtkGetClauseNum(Abc_Ntk_t *pNtk)
Definition abcUtil.c:303
void Abc_NtkCleanMarkC(Abc_Ntk_t *pNtk)
Definition abcUtil.c:734
void Abc_NtkLoadCopy(Abc_Ntk_t *pNtk, Vec_Ptr_t *vCopies)
Definition abcUtil.c:650
int Abc_NtkGetLitNum(Abc_Ntk_t *pNtk)
Definition abcUtil.c:172
int Abc_NtkCountMuxes(Abc_Ntk_t *pNtk)
Definition abcUtil.c:1377
Vec_Ptr_t * Abc_NtkSaveCopy(Abc_Ntk_t *pNtk)
Definition abcUtil.c:628
int Abc_NtkLogicMakeSimpleCos2(Abc_Ntk_t *pNtk, int fDuplicate)
Definition abcUtil.c:987
Vec_Wec_t * Abc_GiaSynthesize(Vec_Ptr_t *vGias, Gia_Man_t *pMulti)
Definition abcUtil.c:3148
int Abc_NtkGetLargeNodeNum(Abc_Ntk_t *pNtk)
Definition abcUtil.c:443
int Abc_NtkGetChoiceNum(Abc_Ntk_t *pNtk)
Definition abcUtil.c:463
void Abc_NodeCollectFanins(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition abcUtil.c:1627
Abc_Ntk_t * Abc_NtkSplitSop(Abc_Ntk_t *pNtk, int nCubesMax, int fVerbose)
Definition abcUtil.c:2814
int Abc_NtkGetMultiRefNum(Abc_Ntk_t *pNtk)
Definition abcUtil.c:225
void Abc_NtkPrint256()
Definition abcUtil.c:2078
int Abc_NtkGetCubeNum(Abc_Ntk_t *pNtk)
Definition abcUtil.c:117
void Abc_NtkCleanData(Abc_Ntk_t *pNtk)
Definition abcUtil.c:567
int Abc_NtkIsTopo(Abc_Ntk_t *pNtk)
Definition abcUtil.c:2888
Gia_Man_t * Abc_SopSynthesizeOne(char *pSop, int fClp)
Definition abcUtil.c:3244
Abc_Obj_t * Abc_NodeFindCoFanout(Abc_Obj_t *pNode)
Definition abcUtil.c:812
int Abc_NodeIsMuxControlType(Abc_Obj_t *pNode)
Definition abcUtil.c:1398
int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition abcUtil.c:1080
int Abc_NtkCrossCut(Abc_Ntk_t *pNtk)
Definition abcUtil.c:2049
void Abc_NodeCollectFanouts(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition abcUtil.c:1647
int Abc_NtkGetAigNodeNum(Abc_Ntk_t *pNtk)
Definition abcUtil.c:276
int Abc_NtkGetFanoutMax(Abc_Ntk_t *pNtk)
Definition abcUtil.c:497
void Abc_NtkCleanCopy_rec(Abc_Ntk_t *pNtk)
Definition abcUtil.c:547
void Abc_NtkFixCoDriverProblem(Abc_Obj_t *pDriver, Abc_Obj_t *pNodeCo, int fDuplicate)
Definition abcUtil.c:891
void Abc_NtkReverseTopoOrderTest(Abc_Ntk_t *p)
Definition abcUtil.c:2693
void Abc_NtkUpdateGpcPattern(Vec_Int_t *vRank, int i, char *pGPC, int nGpcs, Vec_Int_t *vRank2, Vec_Int_t *vLevel)
Definition abcUtil.c:3389
Vec_Ptr_t * Abc_NtkCollectObjects(Abc_Ntk_t *pNtk)
Definition abcUtil.c:1765
int Abc_NtkGetGpcLutCount(char *pGPC)
Definition abcUtil.c:3400
void Abc_NtkReassignIds(Abc_Ntk_t *pNtk)
Definition abcUtil.c:1809
char ** Abc_NtkTransformGPCs(char **pGPCs, int nGPCs)
Definition abcUtil.c:3414
int Abc_NtkGetMuxNum(Abc_Ntk_t *pNtk)
Definition abcUtil.c:403
int Abc_NodeFindFanin(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
Definition abcUtil.c:791
int Abc_GateToType(Abc_Obj_t *pObj)
Definition abcUtil.c:3102
int Abc_NtkGetCubePairNum(Abc_Ntk_t *pNtk)
Definition abcUtil.c:143
void Abc_NtkDetectMatching(Abc_Ntk_t *pNtk)
Definition abcUtil.c:1893
void Abc_NtkReverseTopoOrder_rec(Abc_Obj_t *pObj, int fThisIsPivot)
Definition abcUtil.c:2630
Gia_Man_t * Abc_NtkStrashToGia(Abc_Ntk_t *pNtk)
Definition abcUtil.c:3214
void Abc_NtkLogicMakeSimpleCosTest(Abc_Ntk_t *pNtk, int fDuplicate)
Definition abcUtil.c:1041
int Abc_NtkAddBuffsEval2(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
Definition abcUtil.c:2309
void Abc_NodeSopToCubes(Abc_Obj_t *pNodeOld, Abc_Ntk_t *pNtkNew, int fXor)
Definition abcUtil.c:2532
int Abc_NodeIsExorType(Abc_Obj_t *pNode)
Definition abcUtil.c:1300
Vec_Int_t * Abc_NtkGetCiIds(Abc_Ntk_t *pNtk)
Definition abcUtil.c:1787
int Abc_NodeCompareLevelsIncrease(Abc_Obj_t **pp1, Abc_Obj_t **pp2)
Definition abcUtil.c:1689
ABC_NAMESPACE_IMPL_START void * Abc_NtkAttrFree(Abc_Ntk_t *pNtk, int Attr, int fFreeMan)
DECLARATIONS ///.
Definition abcUtil.c:55
Abc_Ntk_t * Abc_NtkAddBuffsInt(Abc_Ntk_t *pNtkInit, int fReverse, int nImprove, int fVerbose)
Definition abcUtil.c:2346
int Abc_NtkGetFaninMax(Abc_Ntk_t *pNtk)
Definition abcUtil.c:486
int Abc_NtkCheckGpc(char *pGPC, char *pGPC0)
Definition abcUtil.c:3431
void Abc_NtkReverseTopoOrder(Abc_Ntk_t *p)
Definition abcUtil.c:2664
Abc_Ntk_t * Abc_NtkFromArray()
Definition abcUtil.c:3301
void Abc_NtkTransferCopy(Abc_Ntk_t *pNtk)
Definition abcUtil.c:1962
int Abc_NtkGetExorNum(Abc_Ntk_t *pNtk)
Definition abcUtil.c:383
int Abc_NtkCountCopy(Abc_Ntk_t *pNtk)
Definition abcUtil.c:605
Abc_Obj_t * Abc_NodeRecognizeMux(Abc_Obj_t *pNode, Abc_Obj_t **ppNodeT, Abc_Obj_t **ppNodeE)
Definition abcUtil.c:1430
void Abc_NtkPrintCiLevels(Abc_Ntk_t *pNtk)
Definition abcUtil.c:2268
int Abc_NtkHasConstNode()
Definition abcUtil.c:3290
void Abc_NtkFillTemp(Abc_Ntk_t *pNtk)
Definition abcUtil.c:586
int Abc_NtkGetTotalFanins(Abc_Ntk_t *pNtk)
Definition abcUtil.c:520
void Abc_NtkInvertConstraints(Abc_Ntk_t *pNtk)
Definition abcUtil.c:2244
int Abc_NtkMatchGpcPattern(Vec_Int_t *vRanks, int i, char *pGPC)
Definition abcUtil.c:3377
void Abc_NtkCleanMarkAB(Abc_Ntk_t *pNtk)
Definition abcUtil.c:753
Vec_Int_t * Abc_NtkFanoutCounts(Abc_Ntk_t *pNtk)
Definition abcUtil.c:1741
int Abc_NtkGetBufNum(Abc_Ntk_t *pNtk)
Definition abcUtil.c:423
void Abc_NtkCleanMarkABC(Abc_Ntk_t *pNtk)
Definition abcUtil.c:772
Abc_Ntk_t * Abc_NtkAddBuffs(Abc_Ntk_t *pNtkInit, int fDirect, int fReverse, int nImprove, int fVerbose)
Definition abcUtil.c:2456
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
ABC_DLL Abc_Ntk_t * Abc_NtkCreateFromGias(char *pName, Vec_Ptr_t *vGias, Gia_Man_t *pMulti)
Definition abcNtk.c:2550
ABC_DLL Vec_Ptr_t * Abc_AigDfs(Abc_Ntk_t *pNtk, int fCollectAll, int fCollectCos)
Definition abcDfs.c:1198
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
Definition abcNtk.c:53
ABC_DLL void Abc_NodeComplementInput(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
Definition abcObj.c:1039
ABC_DLL char * Abc_SopCreateXorSpecial(Mem_Flex_t *pMan, int nVars)
Definition abcSop.c:297
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:84
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
Definition abcObj.c:170
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition abcObj.c:643
ABC_DLL void Abc_AigRehash(Abc_Aig_t *pMan)
Definition abcAig.c:628
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition abc.h:488
ABC_DLL Abc_Ntk_t * Abc_NtkDarLatchSweep(Abc_Ntk_t *pNtk, int fLatchConst, int fLatchEqual, int fSaveNames, int fUseMvSweep, int nFramesSymb, int nFramesSatur, int fVerbose, int fVeryVerbose)
Definition abcDar.c:3317
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
ABC_DLL Abc_Obj_t * Abc_NtkFetchTwinNode(Abc_Obj_t *pNode)
Definition abcMap.c:804
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition abcObj.c:342
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition abcObj.c:706
ABC_DLL void Abc_NtkAddDummyBoxNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:547
ABC_DLL Gia_Man_t * Abc_NtkClpGia(Abc_Ntk_t *pNtk)
ABC_DLL Vec_Ptr_t * Abc_NtkDfsReverseNodesContained(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition abcDfs.c:329
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition abcDfs.c:82
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition abcCheck.c:64
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition abc.h:449
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition abcObj.c:612
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
@ ABC_OBJ_PO
Definition abc.h:90
ABC_DLL char * Abc_SopCreateInv(Mem_Flex_t *pMan)
Definition abcSop.c:351
ABC_DLL char * Abc_SopCreateOr(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition abcSop.c:212
ABC_DLL void Abc_SopComplement(char *pSop)
Definition abcSop.c:648
ABC_DLL void Abc_NodeComplement(Abc_Obj_t *pNode)
Definition abcObj.c:1012
#define Abc_CubeForEachVar(pCube, Value, i)
Definition abc.h:536
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
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition abcNames.c:69
ABC_DLL void Abc_NtkFinalize(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Definition abcNtk.c:355
ABC_DLL int Abc_NodeIsConst0(Abc_Obj_t *pNode)
Definition abcObj.c:884
ABC_DLL Vec_Ptr_t * Abc_NtkNodeSupport(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition abcDfs.c:890
@ ABC_NTK_LOGIC
Definition abc.h:57
ABC_DLL char * Abc_SopCreateAnd(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition abcSop.c:168
ABC_DLL int Abc_SopGetLitNum(char *pSop)
Definition abcSop.c:559
ABC_DLL void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:521
ABC_DLL int Abc_NodeIsConst(Abc_Obj_t *pNode)
Definition abcObj.c:867
ABC_DLL Abc_Ntk_t * Abc_NtkCreateFromSops(char *pName, Vec_Ptr_t *vSops)
Definition abcNtk.c:2512
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition abcDfs.c:1449
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeAnd(Abc_Ntk_t *pNtk, Vec_Ptr_t *vFanins)
Definition abcObj.c:738
ABC_DLL void Abc_SopComplementVar(char *pSop, int iVar)
Definition abcSop.c:678
#define Abc_SopForEachCube(pSop, nFanins, pCube)
Definition abc.h:538
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition abcObj.c:674
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition abcStrash.c:265
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition abcSop.c:584
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
ABC_DLL Abc_Obj_t * Abc_NtkCreateObj(Abc_Ntk_t *pNtk, Abc_ObjType_t Type)
Definition abcObj.c:109
ABC_DLL Vec_Ptr_t * Abc_NtkDfsNodes(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition abcDfs.c:151
ABC_DLL int Abc_SopIsComplement(char *pSop)
Definition abcSop.c:703
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition abcFanio.c:172
ABC_DLL char * Abc_SopCreateXor(Mem_Flex_t *pMan, int nVars)
Definition abcSop.c:280
@ ABC_FUNC_SOP
Definition abc.h:65
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
Definition abcSop.c:537
ABC_DLL char * Abc_SopCreateConst0(Mem_Flex_t *pMan)
Definition abcSop.c:129
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, const char *pName)
DECLARATIONS ///.
Definition abcSop.c:62
#define Abc_NtkForEachBox(pNtk, pObj, i)
Definition abc.h:498
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition abcNtk.c:157
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition abcNtk.c:472
ABC_DLL char * Abc_SopCreateBuf(Mem_Flex_t *pMan)
Definition abcSop.c:367
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
ABC_DLL void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:495
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
ABC_DLL Abc_Obj_t * Abc_NtkDupBox(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pBox, int fCopyName)
Definition abcObj.c:415
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
Definition mainFrame.c:643
int nTotal
DECLARATIONS ///.
Definition cutTruth.c:37
ABC_DLL Abc_Frame_t * Abc_FrameReadGlobalFrame()
Definition mainFrame.c:666
ABC_DLL void Abc_FrameSetBatchMode(int Mode)
Definition mainFrame.c:111
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition mainFrame.c:327
ABC_DLL void Abc_FrameReplaceCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
Definition mainFrame.c:538
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
Definition cmdApi.c:193
Dec_Graph_t * Dec_Factor(char *pSop)
FUNCTION DECLARATIONS ///.
Definition decFactor.c:58
struct Dec_Graph_t_ Dec_Graph_t
Definition dec.h:68
Cube * p
Definition exorList.c:222
char * Extra_UtilStrsav(const char *s)
char * Extra_FileNameGeneric(char *FileName)
typedefABC_NAMESPACE_HEADER_START struct FxuDataStruct Fxu_Data_t
INCLUDES ///.
Definition fxu.h:42
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
void Gia_ManHashStart(Gia_Man_t *p)
Definition giaHash.c:125
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
int Hop_DagSize(Hop_Obj_t *pObj)
Definition hopDfs.c:279
struct Hop_Obj_t_ Hop_Obj_t
Definition hop.h:50
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
void Io_WriteBlifLogic(Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches)
FUNCTION DEFINITIONS ///.
Definition ioWriteBlif.c:59
Io_FileType_t Io_ReadFileType(char *pFileName)
DECLARATIONS ///.
Definition ioUtil.c:47
Abc_Ntk_t * Io_Read(char *pFileName, Io_FileType_t FileType, int fCheck, int fBarBufs)
Definition ioUtil.c:241
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
double Mio_GateReadArea(Mio_Gate_t *pGate)
Definition mioApi.c:171
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition mioApi.c:169
struct Mio_GateStruct_t_ Mio_Gate_t
Definition mio.h:43
struct Mem_Flex_t_ Mem_Flex_t
Definition mem.h:34
Abc_NtkType_t ntkType
Definition abc.h:156
Vec_Ptr_t * vAttrs
Definition abc.h:214
Vec_Ptr_t * vCis
Definition abc.h:165
char * pName
Definition abc.h:158
Vec_Ptr_t * vCos
Definition abc.h:166
int nObjs
Definition abc.h:172
Vec_Int_t * vTopo
Definition abc.h:213
void * pManFunc
Definition abc.h:191
Abc_Ntk_t * pCopy
Definition abc.h:204
char * pSpec
Definition abc.h:159
Vec_Ptr_t * vObjs
Definition abc.h:162
Vec_Int_t * vPhases
Definition abc.h:208
Abc_NtkFunc_t ntkFunc
Definition abc.h:157
void * pData
Definition abc.h:145
unsigned fMarkC
Definition abc.h:136
float dTemp
Definition abc.h:150
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
int iTemp
Definition abc.h:149
unsigned fExor
Definition abc.h:138
Vec_Int_t vFanouts
Definition abc.h:144
Abc_Obj_t * pCopy
Definition abc.h:148
unsigned fMarkA
Definition abc.h:134
Abc_Obj_t * pNext
Definition abc.h:131
unsigned Level
Definition abc.h:142
char * pSpec
Definition gia.h:100
char * pName
Definition gia.h:99
#define assert(ex)
Definition util_old.h:213
int strncmp()
int strlen()
int util_optind
int strcmp()
char * strstr()
struct Vec_Att_t_ Vec_Att_t
BASIC TYPES ///.
Definition vecAtt.h:62
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Vec_IntForEachEntryTwo(vVec1, vVec2, Entry1, Entry2, i)
Definition vecInt.h:66
#define Vec_IntForEachEntryReverse(vVec, pEntry, i)
Definition vecInt.h:62
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
Definition vecPtr.h:63
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_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42