58static inline char * Acb_Num2Name(
int i )
60 if ( i == 1 )
return "module";
61 if ( i == 2 )
return "endmodule";
62 if ( i == 3 )
return "input";
63 if ( i == 4 )
return "output";
64 if ( i == 5 )
return "wire";
65 if ( i == 6 )
return "buf";
66 if ( i == 7 )
return "not";
67 if ( i == 8 )
return "and";
68 if ( i == 9 )
return "nand";
69 if ( i == 10 )
return "or";
70 if ( i == 11 )
return "nor";
71 if ( i == 12 )
return "xor";
72 if ( i == 13 )
return "xnor";
73 if ( i == 14 )
return "_HMUX";
74 if ( i == 15 )
return "_DC";
78static inline int Acb_Type2Oper(
int i )
94static inline char * Acb_Oper2Name(
int i )
129 "GATE buf 1 O=a; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
130 "GATE inv 1 O=!a; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
131 "GATE and2 1 O=a*b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
132 "GATE and3 1 O=a*b*c; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
133 "GATE and4 1 O=a*b*c*d; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
134 "GATE or2 1 O=a+b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
135 "GATE or3 1 O=a+b+c; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
136 "GATE or4 1 O=a+b+c+d; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
137 "GATE nand2 1 O=!(a*b); PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
138 "GATE nand3 1 O=!(a*b*c); PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
139 "GATE nand4 1 O=!(a*b*c*d); PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
140 "GATE nor2 1 O=!(a+b); PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
141 "GATE nor3 1 O=!(a+b+c); PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
142 "GATE nor4 1 O=!(a+b+c+d); PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
143 "GATE xor 1 O=!a*b+a*!b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
144 "GATE xnor 1 O=a*b+!a*!b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
145 "GATE zero 0 O=CONST0;\n"
146 "GATE one 0 O=CONST1;\n"
149 "GATE buf 1 O=a; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
150 "GATE inv 1 O=!a; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
151 "GATE and2 1 O=a*b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
152 "GATE or2 1 O=a+b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
153 "GATE nand2 1 O=!(a*b); PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
154 "GATE nor2 1 O=!(a+b); PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
155 "GATE xor 1 O=!a*b+a*!b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
156 "GATE xnor 1 O=a*b+!a*!b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
157 "GATE zero 0 O=CONST0;\n"
158 "GATE one 0 O=CONST1;\n"
166 Vec_Str_t * vLibStr = Vec_StrAlloc( 1000 );
168 for ( i = 0; ppLibStr[i]; i++ )
169 Vec_StrAppend( vLibStr, ppLibStr[i] );
170 Vec_StrPush( vLibStr,
'\0' );
175 Vec_StrFree( vLibStr );
192 int i, NameId, fFound;
196 assert( i == NameId && !fFound );
203 for ( pTemp = pBuffer; *pTemp; pTemp++ )
204 if ( pTemp[0] ==
'/' && pTemp[1] ==
'/' )
205 while ( *pTemp && *pTemp !=
'\n' )
210 Vec_Int_t * vBuffer = Vec_IntAlloc( 1000 );
212 char * pToken, * pStart, * pLimit = pBuffer +
strlen(pBuffer);
213 int i, iToken, RLeft = -1, RRight = -1;
214 if ( pBuffer == NULL )
217 pToken =
strtok( pBuffer,
" \n\r\t(),;=" );
222 if ( !
strcmp(pToken,
"assign") )
225 int nToks = 0, pToks[4];
228 pToken =
strtok( NULL,
" \n\r\t(),=~&" );
229 if ( pToken[0] ==
';' )
231 if ( pToken[
strlen(pToken)-1] ==
';' )
233 pToken[
strlen(pToken)-1] = 0;
245 assert( nToks == 2 || nToks == 3 );
247 Vec_IntPush( vBuffer, pToks[0] );
248 Vec_IntPush( vBuffer, pToks[1] );
249 Vec_IntPush( vBuffer, nToks == 3 ? pToks[2] : pToks[1] );
250 pToken =
strtok( NULL,
" \n\r\t(),;=" );
255 if ( pToken[0] ==
'[' )
258 RLeft = atoi(pToken+1);
259 RRight = atoi(
strstr(pToken,
":")+1);
260 pToken =
strtok( NULL,
" \n\r\t(),;=" );
263 if ( pToken[0] ==
'\\' )
265 if ( !
strcmp(pToken,
"assign") )
271 else if ( RLeft != -1 )
275 for ( i = RRight; i <= RLeft; i++ )
277 sprintf( Buffer,
"%s[%d]", pToken, i );
279 Vec_IntPush( vBuffer, iToken );
281 pToken =
strtok( NULL,
" \n\r\t(),;=" );
284 Vec_IntPush( vBuffer, iToken );
287 for ( pStart = pToken; pStart < pLimit && *pStart !=
'\n'; pStart++ )
288 if ( *pStart ==
'(' )
290 if ( *pStart ==
'(' )
292 pToken =
strtok( pStart,
" \n\r\t(),;=" );
296 pToken =
strtok( NULL,
" \n\r\t(),;=" );
304 return pStr[0] ==
't' && pStr[1] ==
'_';
310 Vec_Int_t * vOutputs = Vec_IntAlloc(100);
315 int i, ModuleID, Token, Size, Count = 0;
331 Vec_IntPush( vTypes, Token );
332 Vec_IntPush( vTypes, Vec_IntSize(vFanins) );
336 Vec_IntPush( vCur, Token );
338 Vec_IntPush( vTypes, -1 );
339 Vec_IntPush( vTypes, Vec_IntSize(vFanins) );
341 pDesign = (
Ndr_Data_t *)Ndr_Create( Vec_IntEntry(vBuffer, 1) );
342 ModuleID = Ndr_AddModule( pDesign, Vec_IntEntry(vBuffer, 1) );
344 Ndr_DataResize( pDesign, Vec_IntSize(vInputs) );
346 Ndr_DataPush( pDesign,
NDR_INPUT, Token );
347 Ndr_DataAddTo( pDesign, ModuleID-256, Vec_IntSize(vInputs) );
348 Ndr_DataAddTo( pDesign, 0, Vec_IntSize(vInputs) );
350 Ndr_DataResize( pDesign, Vec_IntSize(vOutputs) );
353 Ndr_DataAddTo( pDesign, ModuleID-256, Vec_IntSize(vOutputs) );
354 Ndr_DataAddTo( pDesign, 0, Vec_IntSize(vOutputs) );
356 Ndr_DataResize( pDesign, Vec_IntSize(vWires) );
359 Ndr_DataPush( pDesign,
NDR_TARGET, Token ), Count++;
360 Ndr_DataAddTo( pDesign, ModuleID-256, Count );
361 Ndr_DataAddTo( pDesign, 0, Count );
364 Ndr_AddObject( pDesign, ModuleID,
ABC_OPER_CI, 0, 0, 0, 0, 0, NULL, 1, &Token, NULL );
366 Ndr_AddObject( pDesign, ModuleID,
ABC_OPER_CONST_F, 0, 0, 0, 0, 0, NULL, 1, &Token, NULL );
368 Ndr_AddObject( pDesign, ModuleID,
ABC_OPER_CONST_T, 0, 0, 0, 0, 0, NULL, 1, &Token, NULL );
370 Ndr_AddObject( pDesign, ModuleID,
ABC_OPER_CONST_X, 0, 0, 0, 0, 0, NULL, 1, &Token, NULL );
374 int Output = Vec_IntEntry(vFanins, Size);
375 int nFanins = Vec_IntEntry(vTypes, i+3) - Size - 1;
376 int * pFanins = Vec_IntEntryP(vFanins, Size+1);
377 Ndr_AddObject( pDesign, ModuleID, Acb_Type2Oper(Token), 0, 0, 0, 0, nFanins, pFanins, 1, &Output, NULL );
380 Ndr_AddObject( pDesign, ModuleID,
ABC_OPER_CO, 0, 0, 0, 0, 1, &Token, 1, &Token, NULL );
382 Vec_IntFree( vInputs );
383 Vec_IntFree( vOutputs );
384 Vec_IntFree( vWires );
385 Vec_IntFree( vTypes );
386 Vec_IntFree( vFanins );
403 int nFanins, * pFanins, pLits[16];
404 int i, Type, Size, Place = Vec_IntEntry( vMapType, Token );
405 int iLit = Vec_IntEntry( vMap, Token );
408 Place = Vec_IntEntry( vMapType, Token );
410 Type = Vec_IntEntry( vTypes, Place );
411 Size = Vec_IntEntry( vTypes, Place+1 );
412 nFanins = Vec_IntEntry(vTypes, Place+3) - Size - 1;
413 pFanins = Vec_IntEntryP(vFanins, Size+1);
414 assert( nFanins > 0 && nFanins < 16 );
415 for ( i = 0; i < nFanins; i++ )
417 for ( i = 0; i < nFanins; i++ )
418 pLits[i] = Vec_IntEntry( vMap, pFanins[i] );
422 iLit = Abc_LitNotCond( pLits[0], Type ==
ACB_NOT );
423 iLit = Gia_ManAppendAnd2( pNew, iLit, iLit );
429 for ( i = 1; i < nFanins; i++ )
430 iLit = Gia_ManAppendAnd2( pNew, iLit, pLits[i] );
432 for ( i = 1; i < nFanins; i++ )
433 iLit = Gia_ManAppendOr2( pNew, iLit, pLits[i] );
435 for ( i = 1; i < nFanins; i++ )
436 iLit = Gia_ManAppendXor2( pNew, iLit, pLits[i] );
440 Vec_IntWriteEntry( vMap, Token, iLit );
447 Vec_Int_t * vOutputs = Vec_IntAlloc(100);
454 int i, iLit, Token, Size;
471 Vec_IntPush( vTypes, Token );
472 Vec_IntPush( vTypes, Vec_IntSize(vFanins) );
475 else if ( pFileW && vCur == vWires &&
Abc_NamStr(pNames, Token)[0] ==
't' )
476 Vec_IntPush( vInputs, Token );
478 Vec_IntPush( vCur, Token );
480 Vec_IntPush( vTypes, -1 );
481 Vec_IntPush( vTypes, Vec_IntSize(vFanins) );
485 Vec_IntWriteEntry( vMapType, Vec_IntEntry(vFanins, Size), i );
488 pNew->
pName = Abc_UtilStrsav(
Abc_NamStr(pNames, Vec_IntEntry(vBuffer, 1)) );
491 Vec_IntWriteEntry( vMap, Token, 0 );
493 Vec_IntWriteEntry( vMap, Token, 1 );
495 Vec_IntWriteEntry( vMap, Token, 0 );
497 Vec_IntWriteEntry( vMap, Token, 0 );
499 Gia_ManAppendCi(pNew);
501 Vec_IntWriteEntry( vMap, Token, Gia_ManAppendAnd2(pNew, Gia_ManCiLit(pNew, i), Gia_ManCiLit(pNew, i)) );
505 Gia_ManAppendCo( pNew, Vec_IntEntry(vMap, Token) );
509 pNew->
vPolars = Vec_BitStart( Gia_ManObjNum(pNew) );
510 pNew->
vNamesNode = Vec_PtrStart( Gia_ManObjNum(pNew) );
513 if ( iLit == -1 || !Gia_ObjIsAnd(Gia_ManObj(pNew, Abc_Lit2Var(iLit))) )
515 sprintf( Buffer,
"%c_%s", Abc_LitIsCompl(iLit) ?
'c' :
'd',
Abc_NamStr(pNames, Token) );
517 Vec_PtrWriteEntry( pNew->
vNamesNode, Abc_Lit2Var(iLit), Abc_UtilStrsav(Buffer) );
518 Vec_BitWriteEntry( pNew->
vPolars, Abc_Lit2Var(iLit), Abc_LitIsCompl(iLit) );
527 pNew->
vNamesIn = Vec_PtrAlloc( Vec_IntSize(vInputs) );
530 pNew->
vNamesOut = Vec_PtrAlloc( Vec_IntSize(vOutputs) );
533 if ( pFileW && fNames )
538 pNew->
vWeights = Vec_IntStartFull( Gia_ManObjNum(pNew) );
540 if ( iLit != -1 && Vec_IntEntry(vT2W, Token) != -1 )
541 Vec_IntWriteEntry( pNew->
vWeights, Abc_Lit2Var(iLit), Vec_IntEntry(vT2W, Token) );
545 Vec_IntFree( vInputs );
546 Vec_IntFree( vOutputs );
547 Vec_IntFree( vWires );
548 Vec_IntFree( vTypes );
549 Vec_IntFree( vFanins );
551 Vec_IntFree( vMapType );
560 pNew->
pSpec = Abc_UtilStrsav( pFileName );
562 Vec_IntFree( vBuffer );
581 char * pToken, * pNum;
582 if ( pBuffer == NULL )
584 pToken =
strtok( pBuffer,
" \n\r()," );
585 pNum =
strtok( NULL,
" \n\r()," );
589 int Number = atoi(pNum);
592 printf(
"Cannot find name \"%s\" among node names of this network.\n", pToken );
595 Vec_IntWriteEntry( vWeights, NameId, Number );
596 pToken =
strtok( NULL,
" \n\r(),;" );
597 pNum =
strtok( NULL,
" \n\r(),;" );
630 if ( pFileName && pModule == NULL )
632 printf(
"Cannot read input file \"%s\".\n", pFileName );
635 if ( pFileNameW && vWeights == NULL )
637 printf(
"Cannot read weight file \"%s\".\n", pFileNameW );
647 Ndr_Delete( pModule );
648 Vec_IntFree( vBuffer );
649 Vec_IntFreeP( &vWeights );
672 int i, iObj, fFirst = 1;
673 FILE * pFile = fopen( pFileName,
"wb" );
674 if ( pFile == NULL ) { printf(
"Cannot open file \"%s\" for writing.\n", pFileName );
return; }
676 fprintf( pFile,
"\nmodule %s (\n ", Acb_NtkName(
p) );
679 fprintf( pFile,
"%s, ", Acb_ObjNameStr(
p, iObj) );
680 fprintf( pFile,
"\n " );
683 fprintf( pFile,
"%s%s", fFirst ?
"":
", ", Acb_ObjNameStr(
p, iObj) ), fFirst = 0;
684 fprintf( pFile,
"\n);\n\n" );
687 fprintf( pFile,
" input %s;\n", Acb_ObjNameStr(
p, iObj) );
688 fprintf( pFile,
"\n" );
691 fprintf( pFile,
" output %s;\n", Acb_ObjNameStr(
p, iObj) );
692 fprintf( pFile,
"\n" );
695 if ( Acb_ObjFaninNum(
p, iObj) > 0 )
696 fprintf( pFile,
" wire %s;\n", Acb_ObjNameStr(
p, iObj) );
697 fprintf( pFile,
"\n" );
700 if ( Acb_ObjFaninNum(
p, iObj) > 0 )
702 int * pFanin, iFanin, k, start = ftell(pFile)+55;
703 fprintf( pFile,
" %s (", Acb_Oper2Name( Acb_ObjType(
p, iObj) ) );
704 fprintf( pFile,
" %s", Acb_ObjNameStr(
p, iObj) );
707 fprintf( pFile,
", %s", Acb_ObjNameStr(
p, iFanin) );
708 fprintf( pFile,
" );" );
709 if ( Acb_NtkHasObjWeights(
p) && Acb_ObjWeight(
p, iObj) > 0 )
710 fprintf( pFile,
" %*s // weight = %d", (
int)(start-ftell(pFile)),
"", Acb_ObjWeight(
p, iObj) );
711 fprintf( pFile,
"\n" );
718 fprintf( pFile,
" 1\'bx" );
721 fprintf( pFile,
" );\n" );
724 fprintf( pFile,
"\nendmodule\n\n" );
747 int * pFanin, iFanin, i, Res = 0;
748 if ( Acb_ObjIsTravIdPrev(
p, iObj) )
750 if ( Acb_ObjSetTravIdCur(
p, iObj) )
752 assert( !Acb_ObjIsCi(
p, iObj) );
755 if ( Res ) Acb_ObjSetTravIdPrev(
p, iObj );
756 if ( Res ) Vec_BitWriteEntry( vBlock, iObj, 1 );
762 Vec_Int_t * vRoots = Vec_IntAlloc( 1000 );
763 Vec_Bit_t * vBlock = Vec_BitStart( Acb_NtkObjNum(
p) );
766 Acb_NtkIncTravId(
p );
767 assert( Vec_IntSize(vTargets) > 0 );
770 Acb_ObjSetTravIdCur(
p, iObj );
771 Vec_BitWriteEntry( vBlock, iObj, 1 );
774 Acb_NtkIncTravId(
p );
776 Acb_ObjSetTravIdCur(
p, iObj );
783 Vec_IntPush( vRoots, i );
801 int * pFanin, iFanin, i;
802 if ( Acb_ObjSetTravIdCur(
p, iObj) )
804 if ( Acb_ObjIsCi(
p, iObj) )
805 Vec_IntPush( vSupp, Acb_ObjCioId(
p, iObj) );
813 Vec_Int_t * vSupp = Vec_IntAlloc( 1000 );
814 Acb_NtkIncTravId(
p );
817 Vec_IntSort( vSupp, 0 );
835 int * pFanin, iFanin, i, Res = 1;
836 if ( Acb_ObjIsTravIdPrev(
p, iObj) )
838 if ( Acb_ObjSetTravIdCur(
p, iObj) )
840 if ( Acb_ObjIsCi(
p, iObj) )
844 if ( Res ) Acb_ObjSetTravIdPrev(
p, iObj );
850 Vec_Int_t * vDivs = Vec_IntAlloc( Vec_IntSize(vSupp) );
853 assert( Acb_ObjWeight(
p, iObj) > 0 );
854 Vec_IntPush( vDivs, iObj );
856 printf(
"Divisors are %d support variables (CIs in the TFO of the targets).\n", Vec_IntSize(vSupp) );
861 int fPrintWeights = 0;
862 int nDivLimit = 5000;
864 Vec_Int_t * vDivs = Vec_IntAlloc( 1000 );
868 if ( Acb_ObjWeight(
p, iObj) > 0 )
869 Vec_IntWriteEntry( &
p->vObjWeight, iObj, 1 );
872 Acb_NtkIncTravId(
p );
875 Acb_ObjSetTravIdCur(
p, iObj );
876 if ( Acb_ObjWeight(
p, iObj) > 0 )
877 Vec_IntPush( vDivs, iObj );
880 Acb_NtkIncTravId(
p );
883 Vec_IntPush( vDivs, iObj );
885 Vec_IntSelectSortCost( Vec_IntArray(vDivs), Vec_IntSize(vDivs), &
p->vObjWeight );
887 nDivLimit = Abc_MinInt( Vec_IntSize(vDivs), nDivLimit );
896 printf(
"%d", (Vec_IntEntry(&
p->vObjWeight, iObj) / 100) % 10 );
900 printf(
"%d", (Vec_IntEntry(&
p->vObjWeight, iObj) / 10) % 10 );
904 printf(
"%d", (Vec_IntEntry(&
p->vObjWeight, iObj) / 1) % 10 );
908 printf(
"Reducing divisor set from %d to ", Vec_IntSize(vDivs) );
909 Vec_IntShrink( vDivs, nDivLimit );
911 printf(
"%d.\n", Vec_IntSize(vDivs) );
928 int * pFanin, iFanin, i;
929 if ( Acb_ObjSetTravIdCur(
p, iObj) )
931 if ( Acb_ObjIsCi(
p, iObj) )
935 assert( !Acb_ObjIsCo(
p, iObj) );
936 Vec_IntPush( vNodes, iObj );
941 Vec_Int_t * vNodes = Vec_IntAlloc( 1000 );
942 Acb_NtkIncTravId(
p );
965 int * pFanin, iFanin, k, Type, Res;
966 assert( !Acb_ObjIsCio(
p, iObj) );
967 Vec_IntClear( vTemp );
970 assert( Acb_ObjCopy(
p, iFanin) >= 0 );
971 Vec_IntPush( vTemp, Acb_ObjCopy(
p, iFanin) );
973 Type = Acb_ObjType(
p, iObj );
979 return Vec_IntEntry(vTemp, 0);
981 return Abc_LitNot( Vec_IntEntry(vTemp, 0) );
1012 pNew->
pName = Abc_UtilStrsav(Acb_NtkName(
p));
1014 Acb_NtkCleanObjCopies(
p );
1017 Acb_ObjSetCopy(
p, iObj, Gia_ManAppendCi(pNew) );
1021 Acb_ObjSetCopy(
p, iObj, Gia_ManAppendCi(pNew) );
1023 vFanins = Vec_IntAlloc( 4 );
1025 if ( Acb_ObjCopy(
p, iObj) == -1 )
1027 Vec_IntFree( vFanins );
1030 Gia_ManAppendCo( pNew, Acb_ObjCopy(
p, iObj) );
1034 Gia_ManAppendCo( pNew, Acb_ObjCopy(
p, iObj) );
1045 pNew->
vNamesIn = Vec_PtrAlloc( Gia_ManCiNum(pNew) );
1047 Vec_PtrPush( pNew->
vNamesIn, Abc_UtilStrsav(Acb_ObjNameStr(
p, iObj)) );
1050 Vec_PtrPush( pNew->
vNamesIn, Abc_UtilStrsav(Acb_ObjNameStr(
p, iObj)) );
1052 pNew->
vNamesOut = Vec_PtrAlloc( Gia_ManCoNum(pNew) );
1054 Vec_PtrPush( pNew->
vNamesOut, Abc_UtilStrsav(Acb_ObjNameStr(
p, iObj)) );
1060 sprintf( Buffer,
"%s_%d", Acb_ObjNameStr(
p, iObj), Acb_ObjWeight(
p, iObj) );
1061 Vec_PtrPush( pNew->
vNamesOut, Abc_UtilStrsav(Buffer) );
1081 int i, iMiter = 0, iXor;
1084 pNew =
Gia_ManStart( Gia_ManObjNum(pF) + Gia_ManObjNum(pF) + 1000 );
1086 Gia_ManConst0(pF)->Value = 0;
1087 Gia_ManConst0(pG)->Value = 0;
1089 pObj->
Value = Gia_ManAppendCi( pNew );
1091 pObj->
Value = Gia_ManCi(pF, i)->Value;
1098 iXor =
Gia_ManHashXor( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin0Copy(Gia_ManCo(pF, i)) );
1101 Gia_ManAppendCo( pNew, iMiter );
1103 if ( i >= Gia_ManCoNum(pG) )
1104 Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1126 int i, nSize = Vec_IntSize(
p );
1127 int * pArray = Vec_IntArray(
p );
1128 srand( time(NULL) );
1129 for ( i = 0; i < nSize; i++ )
1131 int j = rand()%nSize;
1132 ABC_SWAP(
int, pArray[i], pArray[j] );
1138 int i, nSize = Vec_IntSize(
p );
1139 int * pArray = Vec_IntArray(
p );
1140 srand( time(NULL) );
1141 for ( i = 0; i < nSize-1; i++ )
1143 if ( rand() % 3 == 0 )
1145 printf(
"Permuting %d and %d\n", i, i+1 );
1146 ABC_SWAP(
int, pArray[i], pArray[i+1] );
1153 int i, k, Entry, nDivs = Vec_IntSize(vWeights);
1156 printf(
"%d", (Entry / 100) % 10 );
1160 printf(
"%d", (Entry / 10) % 10 );
1164 printf(
"%d", (Entry / 1) % 10 );
1169 for ( i = 0; i < nDivs; i++ )
1170 printf(
"%d", (i / 100) % 10 );
1173 for ( i = 0; i < nDivs; i++ )
1174 printf(
"%d", (i / 10) % 10 );
1177 for ( i = 0; i < nDivs; i++ )
1178 printf(
"%d", i % 10 );
1182 for ( k = 0; k < nPats; k++ )
1184 printf(
"%3d : ", k );
1185 for ( i = 0; i < nDivs; i++ )
1186 printf(
"%c", Abc_TtGetBit(Vec_WrdEntryP(vPats,
NWORDS*i), k) ?
'*' :
'|' );
1195 Vec_Int_t * vWeights = Vec_IntAlloc( Vec_IntSize(vDivs) );
1197 Vec_IntPush( vWeights, Vec_IntEntry(&pNtkF->
vObjWeight, iDiv) );
1202 int i, Entry, Cost = 0;
1204 Cost += Vec_IntEntry( vWeights, Abc_Lit2Var(Entry) - iFirstDiv );
1209 int i, status, nDivs = Vec_IntSize(vWeights);
1210 Vec_Int_t * vSupp = Vec_IntAlloc( 100 );
1217 status =
sat_solver_solve( pSat, Vec_IntArray(vSupp), Vec_IntLimit(vSupp), 0, 0, 0, 0 );
1222 for ( i = 0; i < nDivs; i++ )
1224 if ( sat_solver_var_value(pSat, iFirstDiv+i) == 0 )
1226 Abc_TtSetBit( Vec_WrdEntryP(vPats,
NWORDS*i), iPat );
1230 Vec_IntPush( vSupp, Abc_Var2Lit(iFirstDiv+i, 1) );
1250 Vec_IntSort( vSupp, 0 );
1255 int nDivs = Vec_WrdSize(vPats)/
NWORDS;
1256 int nWords = Abc_Bit6WordNum(nPats);
1258 int Cost, CostBest = -1;
1259 for ( i = 0; i < nDivs; i++ )
1261 word * pPat = Vec_WrdEntryP(vPats,
NWORDS*i);
1262 Cost = Abc_TtCountOnesVecMask(Mask, pPat,
nWords, 0);
1263 if ( CostBest < Cost )
1275 int nDivs = Vec_WrdSize(vPats)/
NWORDS;
1276 int i, b, iBest = -1;
1277 int Cost, CostBest = -1;
1279 Vec_Int_t * vCounts = Vec_IntStart(nPats);
1280 for ( i = 0; i < nDivs; i++ )
1282 word * pPat = Vec_WrdEntryP(vPats,
NWORDS*i);
1283 for ( b = 0; b < nPats; b++ )
1284 if ( Abc_TtGetBit(pPat, b) )
1285 Vec_IntAddToEntry( vCounts, b, 1 );
1287 for ( i = 0; i < nDivs; i++ )
1289 word * pPat = Vec_WrdEntryP(vPats,
NWORDS*i);
1292 for ( b = 0; b < nPats; b++ )
1293 if ( Abc_TtGetBit(pPat, b) && Abc_TtGetBit(Mask, b) )
1294 Cost += 1000000/Vec_IntEntry(vCounts, b);
1295 if ( CostBest < Cost )
1301 Vec_IntFree( vCounts );
1307 int i, status, nDivs = Vec_IntSize(vWeights);
1308 Vec_Int_t * vSupp = Vec_IntAlloc( 100 );
1313 Vec_IntPush( vSupp, Abc_Var2Lit(iFirstDiv+iDivBest, 1) );
1316 pMask = Vec_WrdEntryP( vPats,
NWORDS*iDivBest );
1317 Abc_TtAndSharp( Mask, Mask, pMask,
NWORDS, 1 );
1320 status =
sat_solver_solve( pSat, Vec_IntArray(vSupp), Vec_IntLimit(vSupp), 0, 0, 0, 0 );
1325 for ( i = 0; i < nDivs; i++ )
1327 if ( sat_solver_var_value(pSat, iFirstDiv+i) == 0 )
1329 Abc_TtSetBit( Vec_WrdEntryP(vPats,
NWORDS*i), *pnPats );
1332 if ( *pnPats ==
NWORDS*64 )
1334 printf(
"Exceeded %d words.\n",
NWORDS );
1335 Vec_IntFreeP( &vSupp );
1342 Vec_IntSort( vSupp, 0 );
1347 int i, iLit, status;
1348 int nDivs = Vec_WrdSize(vPats)/
NWORDS;
1349 Vec_Int_t * vLits = Vec_IntAlloc( Vec_IntSize(vSupp) );
1352 Vec_IntPush( vLits, iLit );
1354 status =
sat_solver_solve( pSat, Vec_IntArray(vLits), Vec_IntLimit(vLits), 0, 0, 0, 0 );
1357 Vec_IntFree( vLits );
1360 for ( i = 0; i < nDivs; i++ )
1362 if ( sat_solver_var_value(pSat, iFirstDiv+i) == 0 )
1364 Abc_TtSetBit( Vec_WrdEntryP(vPats,
NWORDS*i), *pnPats );
1367 if ( *pnPats ==
NWORDS*64 )
1373 Vec_Int_t * vTemp, * vSupp = Vec_IntDup( vSuppStart );
int i;
1374 for ( i = Vec_IntSize(vSupp)-1; i >= 0; i-- )
1377 if ( vTemp != vSupp )
1378 Vec_IntFree( vTemp );
1379 if ( vSupp == NULL )
1386 int i, k, iLit, iLit2, status,
nWords = Abc_Bit6WordNum(nPats);
1390 Abc_TtConst( Mask,
nWords, 0 );
1391 for ( i = 0; i < nPats; i++ )
1392 Abc_TtSetBit( Mask, i );
1396 int iDiv = Abc_Lit2Var(iLit) - iFirstDiv;
1398 Abc_TtConst( Covered,
nWords, 0 );
1401 if ( iLit2 == iLit )
1403 pMask = Vec_WrdEntryP( vPats,
NWORDS*(Abc_Lit2Var(iLit2) - iFirstDiv) );
1404 Abc_TtOr( Covered, Covered, pMask,
nWords );
1407 for ( k = 0; k < iDiv; k++ )
1409 if ( Vec_IntEntry(vWeights, k) == Vec_IntEntry(vWeights, iDiv) )
1411 assert( Vec_IntEntry(vWeights, k) < Vec_IntEntry(vWeights, iDiv) );
1412 pMask = Vec_WrdEntryP( vPats,
NWORDS*k );
1414 Abc_TtOr( Both, Covered, pMask,
nWords );
1415 if ( !Abc_TtEqual(Both, Mask,
nWords) )
1418 Vec_IntWriteEntry( vSupp, i, Abc_Var2Lit(iFirstDiv+k, 1) );
1419 status =
sat_solver_solve( pSat, Vec_IntArray(vSupp), Vec_IntLimit(vSupp), 0, 0, 0, 0 );
1427 Vec_IntWriteEntry( vSupp, i, iLit );
1434 abctime clkLimit = TimeOut * CLOCKS_PER_SEC + Abc_Clock();
1437 Vec_Int_t * vSuppBest, * vSupp, * vTemp;
1443 vSuppBest = Vec_IntDup( vSuppStart );
1444 printf(
"Starting cost = %d.\n", CostBest );
1447 for ( Iter = 0; Iter < 500; Iter++ )
1449 if ( Abc_Clock() > clkLimit )
1451 printf(
"Timeout after %d sec.\n", TimeOut );
1458 if ( vSupp == NULL )
1461 Vec_IntFree( vTemp );
1462 if ( vSupp == NULL )
1466 if ( CostBest > Cost )
1470 printf(
"Iter %4d: Next cost = %5d. ", Iter, Cost );
1471 printf(
"Updating best solution.\n" );
1473 Vec_IntFree( vSupp );
1476 Acb_FindReplace( pSat, iFirstDiv, vWeights, vPats, nPats, vSuppBest );
1478 Vec_WrdFreeP( &vPats );
1495 Vec_Int_t * vSupp = Vec_IntAlloc( 100 );
1498 int iCiVarBeg = pCnf->
nVars - nTargets;
1502 for ( i = 0; i < pCnf->
nClauses; i++ )
1506 Lit = Abc_Var2Lit( iCoVarBeg, 0 );
1512 for ( i = 0; i < pCnf->
nClauses; i++ )
1517 Lit = Abc_Var2Lit( iCoVarBeg+pCnf->
nVars, 0 );
1522 Lit = Abc_Var2Lit( iCiVarBeg + iTar, 1 );
1526 Lit = Abc_Var2Lit( iCiVarBeg+pCnf->
nVars + iTar, 0 );
1533 int fUseMinAssump = 1;
1534 int iLit, nSuppNew, status;
1535 int iDivVar = 2 * pCnf->
nVars;
1538 Vec_IntClear( vSupp );
1544 int iVar0 = iCoVarBeg+1+iDivOld;
1545 int iVar1 = iCoVarBeg+1+iDivOld+pCnf->
nVars;
1549 pLits[0] = Abc_Var2Lit( iVar0, 0 );
1550 pLits[1] = Abc_Var2Lit( iVar1, 1 );
1553 printf(
"Unsat is detected earlier.\n" );
1557 pLits[0] = Abc_Var2Lit( iVar0, 1 );
1558 pLits[1] = Abc_Var2Lit( iVar1, 0 );
1561 printf(
"Unsat is detected earlier.\n" );
1567 if ( vSuppOld == NULL || j == Vec_IntSize(vSuppOld) )
1569 for ( i = 0; i < nCoDivs; i++ )
1572 Vec_IntPush( vSupp, Abc_Var2Lit(iDivVar+i, 1) );
1575 if ( TimeOut ) sat_solver_set_runtime_limit( pSat, TimeOut * CLOCKS_PER_SEC + Abc_Clock() );
1576 status =
sat_solver_solve( pSat, Vec_IntArray(vSupp), Vec_IntLimit(vSupp), 0, 0, 0, 0 );
1577 if ( TimeOut ) sat_solver_set_runtime_limit( pSat, 0 );
1580 printf(
"ECO does not exist.\n" );
1582 Vec_IntFree( vSupp );
1587 printf(
"Support computation timed out after %d sec.\n", TimeOut );
1589 Vec_IntFree( vSupp );
1593 printf(
"Proved that the problem has a solution. " );
1594 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
1596 if ( fUseMinAssump )
1598 int fUseSuppMin = 1;
1602 Vec_IntShrink( vSupp, nSuppNew );
1603 Vec_IntSort( vSupp, 0 );
1604 printf(
"Found one feasible set of %d divisors. ", Vec_IntSize(vSupp) );
1605 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
1608 if ( fUseSuppMin && Vec_IntSize(vSupp) > 0 )
1611 Vec_Int_t * vSupp2 = Vec_IntDup( vSupp );
1613 vSupp =
Acb_FindSupport( pSat, iDivVar, vWeights, vTemp = vSupp, TimeOut );
1614 Vec_IntFree( vWeights );
1615 Vec_IntFree( vTemp );
1616 if ( vSupp == NULL )
1618 printf(
"Support minimization did not succeed. " );
1624 Vec_IntFree( vSupp2 );
1625 printf(
"Minimized support to %d supp vars. ", Vec_IntSize(vSupp) );
1627 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
1632 int * pFinal, nFinal = sat_solver_final( pSat, &pFinal );
1633 printf(
"AnalyzeFinal returned %d (out of %d).\n", nFinal, Vec_IntSize(vSupp) );
1634 Vec_IntClear( vSupp );
1635 for ( i = 0; i < nFinal; i++ )
1636 Vec_IntPush( vSupp, Abc_LitNot(pFinal[i]) );
1638 status =
sat_solver_solve( pSat, Vec_IntArray(vSupp), Vec_IntLimit(vSupp), 0, 0, 0, 0 );
1641 nFinal = sat_solver_final( pSat, &pFinal );
1642 printf(
"AnalyzeFinal returned %d (out of %d).\n", nFinal, Vec_IntSize(vSupp) );
1646 Vec_IntWriteEntry( vSupp, i, Abc_Lit2Var(iLit)-iDivVar );
1647 Vec_IntSort( vSupp, 0 );
1651 if ( vSupp ) Vec_IntSort( vSupp, 0 );
1655static inline int satoko_add_xor(
satoko_t * pSat,
int iVarA,
int iVarB,
int iVarC,
int fCompl )
1659 assert( iVarA >= 0 && iVarB >= 0 && iVarC >= 0 );
1661 Lits[0] = toLitCond( iVarA, !fCompl );
1662 Lits[1] = toLitCond( iVarB, 1 );
1663 Lits[2] = toLitCond( iVarC, 1 );
1667 Lits[0] = toLitCond( iVarA, !fCompl );
1668 Lits[1] = toLitCond( iVarB, 0 );
1669 Lits[2] = toLitCond( iVarC, 0 );
1673 Lits[0] = toLitCond( iVarA, fCompl );
1674 Lits[1] = toLitCond( iVarB, 1 );
1675 Lits[2] = toLitCond( iVarC, 0 );
1679 Lits[0] = toLitCond( iVarA, fCompl );
1680 Lits[1] = toLitCond( iVarB, 0 );
1681 Lits[2] = toLitCond( iVarC, 1 );
1688 Vec_Int_t * vSupp = Vec_IntAlloc( 100 );
1691 int iCiVarBeg = pCnf->
nVars - nCiTars;
1696 for ( i = 0; i < pCnf->
nClauses; i++ )
1700 Lit = Abc_Var2Lit( iCoVarBeg, 0 );
1706 for ( i = 0; i < pCnf->
nClauses; i++ )
1711 Lit = Abc_Var2Lit( iCoVarBeg+pCnf->
nVars, 0 );
1730 Lit = Abc_Var2Lit( iCiVarBeg, 1 );
1734 Lit = Abc_Var2Lit( iCiVarBeg+pCnf->
nVars, 0 );
1742 int fUseMinAssump = 1;
1743 int iLit, status, nSuppNew;
1744 int iDivVar = 2 * pCnf->
nVars + nCiTars;
1745 Vec_IntClear( vSupp );
1746 for ( i = 0; i < nCoDivs; i++ )
1748 satoko_add_xor( pSat, iDivVar+i, iCoVarBeg+1+i, iCoVarBeg+1+i+pCnf->
nVars, 0 );
1749 Vec_IntPush( vSupp, Abc_Var2Lit(iDivVar+i, 1) );
1771 printf(
"Demonstrated that the problem has NO solution. " );
1772 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
1774 Vec_IntFree( vSupp );
1778 printf(
"Proved that the problem has a solution. " );
1779 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
1782 if ( fUseMinAssump )
1786 Vec_IntShrink( vSupp, nSuppNew );
1787 printf(
"Solved the problem with %d supp vars. ", Vec_IntSize(vSupp) );
1788 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
1793 printf(
"AnalyzeFinal returned %d (out of %d).\n", nFinal, Vec_IntSize(vSupp) );
1794 Vec_IntClear( vSupp );
1795 for ( i = 0; i < nFinal; i++ )
1796 Vec_IntPush( vSupp, Abc_LitNot(pFinal[i]) );
1802 printf(
"AnalyzeFinal returned %d (out of %d).\n", nFinal, Vec_IntSize(vSupp) );
1807 Vec_IntWriteEntry( vSupp, i, Abc_Lit2Var(iLit)-iDivVar );
1808 Vec_IntSort( vSupp, 0 );
1812 Vec_IntSort( vSupp, 0 );
1830 int fCreatePrime = 1;
1831 int status, i, iMint, iVar, iLit, nFinal, * pFinal, pLits[2];
1834 pLits[0] = Abc_Var2Lit( PivotVar, 1 );
1835 pLits[1] = Abc_Var2Lit( FreeVar, 0 );
1836 Vec_StrClear( vTempSop );
1837 Vec_StrGrow( vTempSop, 8 * (Vec_IntSize(vDivVars) + 3) + 1 );
1842 Vec_StrPush( vTempSop,
' ' );
1843 Vec_StrPush( vTempSop,
'0' );
1844 Vec_StrPush( vTempSop,
'\n' );
1845 Vec_StrPush( vTempSop,
'\0' );
1846 return Vec_StrReleaseArray(vTempSop);
1849 pLits[0] = Abc_LitNot(pLits[0]);
1851 pLits[0] = Abc_LitNot(pLits[0]);
1852 if ( status ==
l_False || Vec_IntSize(vDivVars) == 0 )
1854 Vec_StrPush( vTempSop,
' ' );
1855 Vec_StrPush( vTempSop,
'1' );
1856 Vec_StrPush( vTempSop,
'\n' );
1857 Vec_StrPush( vTempSop,
'\0' );
1858 return Vec_StrReleaseArray(vTempSop);
1861 vTemp = Vec_IntAlloc( 100 );
1862 vLits = Vec_IntAlloc( 100 );
1863 for ( iMint = 0; ; iMint++ )
1865 if ( iMint == 1000 )
1867 if ( Vec_IntSize(vDivVars) == 0 )
1869 printf(
"Assuming constant 0 function.\n" );
1870 Vec_StrClear( vTempSop );
1871 Vec_StrPush( vTempSop,
' ' );
1872 Vec_StrPush( vTempSop,
'0' );
1873 Vec_StrPush( vTempSop,
'\n' );
1874 Vec_StrPush( vTempSop,
'\0' );
1875 return Vec_StrReleaseArray(vTempSop);
1878 printf(
"Reached the limit on the number of cubes (1000).\n" );
1879 Vec_IntFree( vTemp );
1880 Vec_IntFree( vLits );
1888 printf(
"Finished enumerating %d cubes.\n", iMint );
1889 Vec_IntFree( vTemp );
1890 Vec_IntFree( vLits );
1891 Vec_StrPush( vTempSop,
'\0' );
1892 return Vec_StrReleaseArray(vTempSop);
1896 Vec_IntClear( vTempLits );
1897 Vec_IntPush( vTempLits, Abc_LitNot(pLits[0]) );
1902 Vec_IntPush( vTempLits, sat_solver_var_literal(pSat, iVar) );
1907 for ( i = 0; i < Vec_IntSize(vDivVars); i++ )
1908 Vec_StrPush( vTempSop,
'-' );
1915 Vec_IntShrink( vTempLits, nFinal+1 );
1918 Vec_IntWriteEntry( vTempLits, 0, Abc_LitNot(pLits[1]) );
1921 Vec_IntWriteEntry( vTempLits, i, Abc_LitNot(iLit) );
1922 iVar = Vec_IntFind( vDivVars, Abc_Lit2Var(iLit) );
assert( iVar >= 0 );
1924 Vec_StrWriteEntry( vTempSop, Vec_StrSize(vTempSop) - Vec_IntSize(vDivVars) + iVar, (
char)(
'0' + !Abc_LitIsCompl(iLit)) );
1930 status =
sat_solver_solve( pSat, Vec_IntArray(vTempLits), Vec_IntLimit(vTempLits), 0, 0, 0, 0 );
1932 printf(
"Selected onset minterm number %d belongs to the offset (this is a bug).\n", iMint );
1936 nFinal = sat_solver_final( pSat, &pFinal );
1937 Vec_IntSelectSort( pFinal, nFinal );
1948 Vec_IntClear( vTemp );
1949 Vec_IntPush( vTemp, Abc_LitNot(pLits[0]) );
1950 for ( i = 0; i < nFinal; i++ )
1952 if ( pFinal[i] == pLits[0] )
1954 Vec_IntPush( vTemp, Abc_LitNot(pFinal[i]) );
1960 for ( i = nFinal - 1; i > 0; i-- )
1962 int iLit = Vec_IntEntry( vTemp, i );
1963 Vec_IntDrop( vTemp, i );
1965 status =
sat_solver_solve( pSat, Vec_IntArray(vTemp), Vec_IntLimit(vTemp), 0, 0, 0, 0 );
1975 Vec_IntInsert( vTemp, i, iLit );
1981 pFinal[i] = Abc_LitNot(iLit);
1982 nFinal = Vec_IntSize(vTemp);
1986 Vec_IntClear( vTempLits );
1987 Vec_IntPush( vTempLits, Abc_LitNot(pLits[1]) );
1988 for ( i = 0; i < nFinal; i++ )
1990 if ( pFinal[i] == pLits[0] )
1992 Vec_IntPush( vTempLits, pFinal[i] );
1993 iVar = Vec_IntFind( vDivVars, Abc_Lit2Var(pFinal[i]) );
assert( iVar >= 0 );
1995 Vec_StrWriteEntry( vTempSop, Vec_StrSize(vTempSop) - Vec_IntSize(vDivVars) + iVar, (
char)(
'0' + Abc_LitIsCompl(pFinal[i])) );
2000 Vec_StrAppend( vTempSop,
" 1\n" );
2014 Vec_Int_t * vTempLits = Vec_IntAlloc( Vec_IntSize(vUsed)+1 );
2017 int iCiVarBeg = pCnf->
nVars - nTargets - Vec_IntSize(vUsed);
2018 int iCoVarBeg = 1, Index;
2022 for ( i = 0; i < pCnf->
nClauses; i++ )
2026 Lit = Abc_Var2Lit( iCoVarBeg, 0 );
2033 Vec_IntWriteEntry( vUsed, i, iCiVarBeg + Index );
2038 Vec_IntWriteEntry( vUsed, i, iCoVarBeg + 1 + Index );
2042 Vec_IntFree( vTempLits );
2043 Vec_StrFree( vTempSop );
2052 Vec_IntWriteEntry( vUsed, i, Index - iCiVarBeg );
2057 Vec_IntWriteEntry( vUsed, i, Index - (iCoVarBeg + 1) );
2063 int iCoVarBeg = 1, i, Lit, status;
2067 for ( i = 0; i < pCnf->
nClauses; i++ )
2071 Lit = Abc_Var2Lit( iCoVarBeg, 0 );
2093 if ( Gia_ObjIsTravIdCurrent(
p, pObj) )
2095 Gia_ObjSetTravIdCurrent(
p, pObj);
2096 assert( Gia_ObjIsAnd(pObj) );
2099 Vec_IntPush( vNodes, Gia_ObjId(
p, pObj) );
2104 Vec_IntClear( vNodes0 );
2105 Vec_IntClear( vNodes1 );
2107 Gia_ObjSetTravIdCurrent(
p, Gia_ManConst0(
p) );
2109 Gia_ObjSetTravIdCurrent(
p, pObj );
2121 Vec_Int_t * vNodes0 = Vec_IntAlloc( Gia_ManAndNum(pM) );
2122 Vec_Int_t * vNodes1 = Vec_IntAlloc( Gia_ManAndNum(pM) );
2127 pRes =
Gia_ManStart( Gia_ManObjNum(pM) + Gia_ManObjNum(pOne) );
2129 Gia_ManConst0(pM)->Value = 0;
2130 Gia_ManConst0(pOne)->Value = 0;
2134 pObj->
Value = Gia_ManAppendCi( pRes );
2139 pObj->
Value = Gia_ObjFanin0Copy(pObj);
2142 assert( Gia_ManCoNum(pOne) == 1 );
2146 if ( i < Vec_IntSize(vUsed) )
2147 pObj->
Value = Gia_ManCi(pM, Vec_IntEntry(vUsed, i))->Value;
2152 pObj->
Value = Gia_ManCo(pM, 1+Vec_IntEntry(vUsed, i))->Value;
2157 pObj = Gia_ManCi( pM, Gia_ManCiNum(pM) - nTargets + iTar );
2158 pObj->
Value = Gia_ObjFanin0Copy( Gia_ManCo(pOne, 0) );
2162 Gia_ManAppendCo( pRes, Gia_ObjFanin0Copy(pObj) );
2164 Vec_IntFree( vNodes0 );
2165 Vec_IntFree( vNodes1 );
2169 assert( Gia_ManCiNum(pRes) == Gia_ManCiNum(pM) );
2170 assert( Gia_ManCoNum(pRes) == Gia_ManCoNum(pM) );
2189 Vec_StrAppend( vStr,
" patch p0 (" );
2191 Vec_StrPrintF( vStr,
"%s .%s(%s)", i ?
",":
"", Acb_ObjNameStr(
p, iObj), Acb_ObjNameStr(
p, iObj) );
2193 Vec_StrPrintF( vStr,
", .%s(%s)", Acb_ObjNameStr(
p, iObj), Acb_ObjNameStr(
p, iObj) );
2194 Vec_StrAppend( vStr,
" );\n\n" );
2195 Vec_StrPush( vStr,
'\0' );
2200 Vec_Ptr_t * vRes = Vec_PtrStart( Vec_IntSize(vUsed) + nNodes );
2201 Vec_Str_t * vStr = Vec_StrAlloc(1000);
int i, iObj, nWires = 1;
2204 Vec_PtrWriteEntry( vRes, i, Abc_UtilStrsav(Acb_ObjNameStr(
p, iObj)) );
2206 assert( Vec_WecSize(vGates) == Vec_IntSize(vUsed) + nNodes + Vec_IntSize(vTars) );
2209 Vec_Int_t * vGate = Vec_WecEntry( vGates, Vec_IntSize(vUsed) + nNodes + i );
2211 Vec_PtrWriteEntry( vRes, Vec_IntEntry(vGate, 1), Abc_UtilStrsav(Acb_ObjNameStr(
p, iObj)) );
2213 for ( i = Vec_IntSize(vUsed); i < Vec_IntSize(vUsed) + nNodes; i++ )
2214 if ( Vec_PtrEntry(vRes, i) == NULL )
2216 Vec_StrPrintF( vStr,
"ww%d", nWires++ );
2217 Vec_StrPush( vStr,
'\0' );
2218 Vec_PtrWriteEntry( vRes, i, Vec_StrReleaseArray(vStr) );
2220 Vec_StrFree( vStr );
2226 Vec_Int_t * vRes = Vec_IntAlloc( Vec_IntSize(vUsed) );
2228 Vec_IntPush( vRes, iObj );
2233 Vec_Ptr_t * vNames = Vec_PtrAlloc( Vec_IntSize(vObjs) );
2236 Vec_PtrPush( vNames, Acb_ObjNameStr(
p, iObj) );
2245 int nOuts = vGias ? Vec_PtrSize(vGias) : Vec_PtrSize(vSops);
2246 int i, k, iObj, nWires = Vec_WecSize(vGates) - Vec_IntSize(vUsed) - nOuts, fFirst = 1;
2247 int nGates1[5] = {0}, nGates0[5] = {0};
2257 Vec_PtrFree( vSpN );
2258 Vec_IntFree( vSup );
2261 if ( Vec_IntSize(vGate) > 2 )
2263 char * pName = Acb_Oper2Name(Vec_IntEntry(vGate, 0));
2264 if ( !
strcmp(pName,
"buf") )
2266 else if ( !
strcmp(pName,
"not") )
2269 nGates0[4] += Vec_IntSize(vGate) - 3;
2275 Vec_StrPrintF( vStr,
"// Patch : in = %d out = %d : pi_in = %d po_out = %d : tfi = %d tfo = %d\n", Vec_IntSize(vUsed), nOuts, nPiCount, nPoCount, Vec_IntSize(vTfi), Vec_IntSize(vTfo) );
2276 Vec_StrPrintF( vStr,
"// Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires, nGates0[0], nGates0[1], nGates0[2], nGates0[3], nGates0[4] );
2278 Vec_StrPrintF( vStr,
"// Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nMffc, nGates1[0], nGates1[1], nGates1[2], nGates1[3], nGates1[4] );
2280 Vec_StrPrintF( vStr,
"// TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires-nMffc, nGates0[0]-nGates1[0], nGates0[1]-nGates1[1], nGates0[2]-nGates1[2], nGates0[3]-nGates1[3], nGates0[4]-nGates1[4] );
2281 Vec_StrPrintF( vStr,
"\n" );
2283 Vec_StrAppend( vStr,
"module patch (" );
2285 assert( Vec_IntSize(vTars) == nOuts );
2287 Vec_StrPrintF( vStr,
"%s %s", i ?
",":
"", Acb_ObjNameStr(
p, iObj) );
2289 Vec_StrPrintF( vStr,
", %s", Acb_ObjNameStr(
p, iObj) );
2290 Vec_StrAppend( vStr,
" );\n\n" );
2292 Vec_StrAppend( vStr,
" output" );
2294 Vec_StrPrintF( vStr,
"%s %s", i ?
",":
"", Acb_ObjNameStr(
p, iObj) );
2295 Vec_StrAppend( vStr,
";\n" );
2297 Vec_StrAppend( vStr,
" input" );
2299 Vec_StrPrintF( vStr,
"%s %s", i ?
",":
"", Acb_ObjNameStr(
p, iObj) );
2300 Vec_StrAppend( vStr,
";\n" );
2302 if ( nWires > nOuts )
2304 Vec_StrAppend( vStr,
" wire" );
2305 for ( i = 0; i < nWires; i++ )
2307 char * pName = (
char *)Vec_PtrEntry( vNames, Vec_IntSize(vUsed)+i );
2308 if ( !
strncmp(pName,
"ww", 2) )
2309 Vec_StrPrintF( vStr,
"%s %s", fFirst ?
"":
",", pName ), fFirst = 0;
2311 Vec_StrAppend( vStr,
";\n\n" );
2317 if ( Vec_IntSize(vGate) > 2 )
2319 Vec_StrPrintF( vStr,
" %s (", Acb_Oper2Name(Vec_IntEntry(vGate, 0)) );
2321 Vec_StrPrintF( vStr,
"%s %s", k > 1 ?
",":
"", (
char *)Vec_PtrEntry(vNames, iObj) );
2322 Vec_StrAppend( vStr,
" );\n" );
2328 Vec_StrPrintF( vStr,
" %s, ", (
char *)Vec_PtrEntry(vNames, Vec_IntEntry(vGate, 1)) );
2329 Vec_StrPrintF( vStr,
" 1\'b%d", Vec_IntEntry(vGate, 0) ==
ABC_OPER_CONST_T );
2330 Vec_StrPrintF( vStr,
" );\n" );
2333 Vec_StrAppend( vStr,
"\nendmodule\n\n" );
2334 Vec_StrPush( vStr,
'\0' );
2335 Vec_PtrFreeFree( vNames );
2336 Vec_WecFree( vGates );
2342 printf(
"Patch : in = %d out = %d : pi_in = %d po_out = %d : tfi = %d tfo = %d\n", Vec_IntSize(vUsed), nOuts, nPiCount, nPoCount, Vec_IntSize(vTfi), Vec_IntSize(vTfo) );
2343 printf(
"Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires, nGates0[0], nGates0[1], nGates0[2], nGates0[3], nGates0[4] );
2345 printf(
"Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nMffc, nGates1[0], nGates1[1], nGates1[2], nGates1[3], nGates1[4] );
2347 printf(
"TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires-nMffc, nGates0[0]-nGates1[0], nGates0[1]-nGates1[1], nGates0[2]-nGates1[2], nGates0[3]-nGates1[3], nGates0[4]-nGates1[4] );
2365 char * pName;
int i;
2367 Vec_StrAppend( vStr,
" patch p0 (" );
2369 Vec_StrPrintF( vStr,
"%s .%s(t%d_%s)", i ?
",":
"", pName, i, pName );
2371 Vec_StrPrintF( vStr,
", .%s(%s)", pName, pName );
2372 Vec_StrAppend( vStr,
" );\n\n" );
2373 Vec_StrPush( vStr,
'\0' );
2378 int nIns = Vec_PtrSize(vIns), nOuts = Vec_PtrSize(vOuts);
2379 int nNodes = Vec_WecSize(vGates) - nIns - nOuts;
2380 Vec_Ptr_t * vRes = Vec_PtrStart( Vec_WecSize(vGates) );
char * pName;
2381 Vec_Str_t * vStr = Vec_StrAlloc(1000);
int i, nWires = 1;
2384 Vec_PtrWriteEntry( vRes, i, Abc_UtilStrsav(pName) );
2388 Vec_Int_t * vGate = Vec_WecEntry( vGates, nIns + nNodes + i );
2390 Vec_PtrWriteEntry( vRes, Vec_IntEntry(vGate, 1), Abc_UtilStrsav(pName) );
2392 for ( i = nIns; i < nIns + nNodes; i++ )
2393 if ( Vec_PtrEntry(vRes, i) == NULL )
2395 Vec_StrPrintF( vStr,
"ww%d", nWires++ );
2396 Vec_StrPush( vStr,
'\0' );
2397 Vec_PtrWriteEntry( vRes, i, Vec_StrReleaseArray(vStr) );
2399 Vec_StrFree( vStr );
2406 int nIns = Vec_PtrSize(vIns), nOuts = Vec_PtrSize(vOuts);
char * pName;
2407 int i, k, iObj, nWires = Vec_WecSize(vGates) - nIns - nOuts, nTwoIns = 0, fFirst = 1;
2411 Vec_StrAppend( vStr,
"module patch (" );
2414 Vec_StrPrintF( vStr,
"%s %s", i ?
",":
"", pName );
2416 Vec_StrPrintF( vStr,
", %s%s", i ?
"":
" ", pName );
2417 Vec_StrAppend( vStr,
" );\n\n" );
2419 Vec_StrAppend( vStr,
" output" );
2421 Vec_StrPrintF( vStr,
"%s %s", i ?
",":
"", pName );
2422 Vec_StrAppend( vStr,
";\n" );
2424 Vec_StrAppend( vStr,
" input" );
2426 Vec_StrPrintF( vStr,
"%s %s", i ?
",":
"", pName );
2427 Vec_StrAppend( vStr,
";\n" );
2429 if ( nWires > nOuts )
2431 Vec_StrAppend( vStr,
" wire" );
2432 for ( i = 0; i < nWires; i++ )
2434 char * pName = (
char *)Vec_PtrEntry( vNames, nIns+i );
2435 if ( !
strncmp(pName,
"ww", 2) )
2436 Vec_StrPrintF( vStr,
"%s %s", fFirst ?
"":
",", pName ), fFirst = 0;
2438 Vec_StrAppend( vStr,
";\n" );
2440 Vec_StrAppend( vStr,
"\n" );
2445 if ( Vec_IntSize(vGate) > 2 )
2447 Vec_StrPrintF( vStr,
" %s (", Acb_Oper2Name(Vec_IntEntry(vGate, 0)) );
2449 Vec_StrPrintF( vStr,
"%s %s", k > 1 ?
",":
"", (
char *)Vec_PtrEntry(vNames, iObj) );
2450 Vec_StrAppend( vStr,
" );\n" );
2451 nTwoIns += Vec_IntSize(vGate) - 3;
2457 Vec_StrPrintF( vStr,
" %s, ", (
char *)Vec_PtrEntry(vNames, Vec_IntEntry(vGate, 1)) );
2458 Vec_StrPrintF( vStr,
" 1\'b%d", Vec_IntEntry(vGate, 0) ==
ABC_OPER_CONST_T );
2459 Vec_StrPrintF( vStr,
" );\n" );
2462 Vec_StrAppend( vStr,
"\nendmodule\n\n" );
2463 Vec_StrPush( vStr,
'\0' );
2464 Vec_PtrFreeFree( vNames );
2465 Vec_WecFree( vGates );
2467 printf(
"Synthesized patch with %d inputs, %d outputs and %d gates (including %d two-input gates).\n", nIns, nOuts, nWires, nTwoIns );
2474 extern void Acb_NtkInsert(
char * pFileNameIn,
char * pFileNameOut,
Vec_Ptr_t * vNames,
int fNumber,
int fSkipMffc );
2481 printf(
"Finished dumping patch file \"%s\".\n",
"patch.v" );
2483 printf(
"Finished dumping intermediate file \"%s\".\n",
"temp.v" );
2485 printf(
"Finished dumping the resulting file \"%s\".\n", pFileNameOut );
2486 Vec_StrFree( vInst );
2487 Vec_StrFree( vPatch );
2503 FILE * pFile = fopen( pFileNamePatch,
"wb" );
2506 fprintf( pFile,
"%s", Vec_StrArray(
p) );
2513 if ( pBuffer == NULL )
2515 pFileOut = fopen( pFileNameOut,
"wb" );
2518 char * pTemp =
strstr( pBuffer,
"endmodule" );
2519 int nFirst = pTemp-pBuffer, nSecond =
strlen(pBuffer) - nFirst;
2520 int Value = fwrite( pBuffer, nFirst, 1, pFileOut );
2521 fprintf( pFileOut,
"\n%s", Vec_StrArray(vPatchLine) );
2522 Value = fwrite( pBuffer+nFirst, nSecond, 1, pFileOut );
2524 fprintf( pFileOut,
"\n%s\n", Vec_StrArray(vPatch) );
2543 int i, iObj, Weight = 0;
2544 printf(
"Patch has %d inputs: ", Vec_IntSize(vUsed) );
2547 printf(
"%d=%s(w=%d) ", Vec_IntEntry(vUsed, i), Acb_ObjNameStr(pNtkF, iObj), Acb_ObjWeight(pNtkF, iObj) );
2548 Weight += Acb_ObjWeight(pNtkF, iObj);
2550 printf(
"\nTotal weight = %d ", Weight );
2551 Abc_PrintTime( 1,
"Total runtime", Abc_Clock() - clk );
2568 int Iter, fVerbose = 0;
2571 if ( fVerbose ) printf(
"M_quo: " );
2577 if ( fVerbose ) printf(
"M_bal: " );
2580 for ( Iter = 0; Iter < 2; Iter++ )
2585 if ( fVerbose ) printf(
"M_dc2: " );
2592 if ( fVerbose ) printf(
"M_sn2: " );
2595 for ( Iter = 0; Iter < 2; Iter++ )
2600 if ( fVerbose ) printf(
"M_dc2: " );
2609 for ( v = 0; v < iTar; v++ )
2617 if ( Gia_ManAndNum(pCof) > 10000 )
2619 printf(
"Quantifying target %3d ", v );
2622 assert( Gia_ManCiNum(pCof) == Gia_ManCiNum(
p) );
2625 if ( fVerbose ) printf(
"M_quo: " );
2629 if ( fVerbose ) printf(
"M_syn: " );
2631 if ( 0 && iTar < nTars )
2643 printf(
"Dumped cof0 into file \"%s\".\n",
"eco_qbf0.aig" );
2644 printf(
"Dumped cof1 into file \"%s\".\n",
"eco_qbf1.aig" );
2657 Gia_Man_t * pCof[2][2] = {{0}}, * pTemp;
2660 int i, n, m, Count, CountBest = 0, iVarBest = -1;
2663 if ( Gia_ManAndNum(pCof1) == 0 || Gia_ManAndNum(pCof0) == 0 )
2665 vFanCount = Vec_IntStart( Gia_ManCiNum(pCof0) );
2666 for ( n = 0; n < 2; n++ )
2670 if ( Gia_ObjIsCi(Gia_ObjFanin0(pObj)) )
2671 Vec_IntAddToEntry( vFanCount, Gia_ObjCioId(Gia_ObjFanin0(pObj)), 1 );
2672 if ( Gia_ObjIsCi(Gia_ObjFanin1(pObj)) )
2673 Vec_IntAddToEntry( vFanCount, Gia_ObjCioId(Gia_ObjFanin1(pObj)), 1 );
2677 if ( CountBest < Count )
2682 Vec_IntFree( vFanCount );
2684 for ( n = 0; n < 2; n++ )
2685 for ( m = 0; m < 2; m++ )
2690 printf(
"%*sCof%d%d : ", 8-Depth,
"", n, m );
2693 for ( m = 0; m < 2; m++ )
2695 if ( Gia_ManAndNum(pCof[1][m]) == 0 || Gia_ManAndNum(pCof[0][m]) == 0 )
2697 else if ( Depth == 1 )
2701 printf(
"%*sInter%d : ", 8-Depth,
"", m );
2705 printf(
"%*sInter%d : ", 8-Depth,
"", m );
2708 for ( n = 0; n < 2; n++ )
2709 for ( m = 0; m < 2; m++ )
2712 for ( m = 0; m < 2; m++ )
2721 for ( v = 0; v < iTar; v++ )
2724 assert( Gia_ManCiNum(pCof) == Gia_ManCiNum(
p) );
2738 printf(
"Cof0 : " );
2740 printf(
"Cof1 : " );
2743 if ( Gia_ManAndNum(pCof1) == 0 || Gia_ManAndNum(pCof0) == 0 )
2760 for ( v = 0; v < iTar; v++ )
2763 assert( Gia_ManCiNum(pCof) == Gia_ManCiNum(
p) );
2793 Vec_Str_t * vTempSop = Vec_StrAlloc( 100 );
2794 char * pToken =
strtok( pStr,
"\n" );
int i;
2795 while ( pToken != NULL )
2797 for ( i = 0; i < nVars; i++ )
2798 Vec_StrPush( vTempSop,
'-' );
2799 for ( i = 0; pToken[i] !=
' '; i++ )
2800 if ( pToken[i] !=
'-' )
2802 int iVar = Vec_IntEntry( vMap, Vec_IntEntry(vSupp, i) );
2803 assert( iVar >= 0 && iVar < nVars );
2804 Vec_StrWriteEntry( vTempSop, Vec_StrSize(vTempSop) - nVars + iVar, pToken[i] );
2806 Vec_StrPrintF( vTempSop,
" %d\n", pToken[i+1] -
'0' );
2807 pToken =
strtok( NULL,
"\n" );
2809 Vec_StrPush( vTempSop,
'\0' );
2810 pToken = Vec_StrReleaseArray(vTempSop);
2811 Vec_StrFree( vTempSop );
2816 Vec_Ptr_t * vFuncs = Vec_PtrAlloc( Vec_PtrSize(vSops) );
2817 Vec_Int_t * vUsed = Vec_IntAlloc( 100 );
2818 Vec_Int_t * vMap = Vec_IntStartFull( nDivs );
2819 Vec_Int_t * vPres = Vec_IntStart( nDivs );
2825 char * pSop = (
char *)Vec_PtrEntry( vSops, i );
2826 char * pStrCopy = Abc_UtilStrsav( pSop );
2827 char * pToken =
strtok( pStrCopy,
"\n" );
2828 while ( pToken != NULL )
2830 for ( k = 0; pToken[k] !=
' '; k++ )
2831 if ( pToken[k] !=
'-' )
2832 Vec_IntWriteEntry( vPres, Vec_IntEntry(vLevel, k), 1 );
2833 pToken =
strtok( NULL,
"\n" );
2841 if ( !Vec_IntEntry(vPres, iVar) )
2843 if ( Vec_IntEntry(vMap, iVar) >= 0 )
2845 Vec_IntWriteEntry( vMap, iVar, Vec_IntSize(vUsed) );
2846 Vec_IntPush( vUsed, iVar );
2852 char * pSop = (
char *)Vec_PtrEntry( vSops, i );
2855 Vec_PtrPush( vFuncs, pSop );
2857 Vec_IntFree( vPres );
2858 Vec_IntFree( vMap );
2878 abctime clkStart = Abc_Clock();
2880 int nTargets = Vec_IntSize(&pNtkF->
vTargets);
2881 int TimeOut = fCisOnly ? 0 : 120;
2889 Vec_Int_t * vSupp = Vec_IntTwoMerge( vSuppF, vSuppG );
2901 Vec_Ptr_t * vSops = Vec_PtrAlloc( nTargets );
2902 Vec_Wec_t * vSupps = Vec_WecAlloc( nTargets );
2903 Vec_Int_t * vSuppOld = Vec_IntAlloc( 100 );
2907 Vec_Ptr_t * vGias = fCisOnly ? Vec_PtrAlloc(nTargets) : NULL;
2908 Vec_Str_t * vInst = NULL, * vPatch = NULL;
2919 printf(
"The number of targets = %d.\n", nTargets );
2925 printf(
"Miter: " );
2938 Lit = Abc_Var2Lit( 1, 0 );
2942 printf(
"The ECO problem has %s solution. ", status ==
l_False ?
"a" :
"NO" );
2943 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
2951 for ( i = nTargets-1; i >= 0; i-- )
2954 printf(
"\nConsidering target %d (out of %d)...\n", i, nTargets );
2958 vSupp = Vec_IntStartNatural( Vec_IntSize(vDivs) );
2959 printf(
"Target %d has support with %d variables.\n", i, Vec_IntSize(vSupp) );
2962 printf(
"Tar%02d: ", i );
2966 pGiaM =
Acb_UpdateMiter( pTemp = pGiaM, pOne, i, nTargets, vSupp, fCisOnly );
2970 Vec_PtrPush( vGias, pOne );
2976 vSupp =
Acb_DerivePatchSupport( pCnf, i, nTargets, Vec_IntSize(vDivs), vDivs, pNtkF, vSuppOld, TimeOut );
2977 if ( vSupp == NULL )
2983 Vec_IntAppend( vSuppOld, vSupp );
2984 Vec_IntClear( vSupp );
2985 Vec_IntAppend( vSupp, vSuppOld );
2996 if ( nTimeout && (Abc_Clock() - clkStart)/CLOCKS_PER_SEC >= nTimeout )
2998 Vec_IntFreeP( &vSupp );
3000 printf(
"The target computation timed out after %d seconds.\n", nTimeout );
3007 printf(
"Tar%02d: ", i );
3011 pGiaM =
Acb_UpdateMiter( pTemp = pGiaM, pOne, i, nTargets, vSupp, fCisOnly );
3016 Vec_PtrPush( vSops, pSop );
3018 printf(
"Function %d\n%s", i, pSop );
3021 Vec_IntAppend( Vec_WecPushLevel(vSupps), vSupp );
3022 Vec_IntFree( vSupp );
3035 printf(
"The ECO solution was verified successfully. " );
3037 printf(
"The ECO solution verification FAILED. " );
3038 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
3044 vUsed = Vec_IntStartNatural( Vec_IntSize(vDivs) );
3045 Vec_PtrReverseOrder( vGias );
3050 Vec_PtrReverseOrder( vFuncs );
3063 Acb_GenerateFileOut( vInst, pFileName[0], pFileName[3] ? pFileName[3] : (
char *)
"out.v", vPatch );
3064 printf(
"Finished dumping resulting file \"%s\".\n\n", pFileName[3] ? pFileName[3] :
"out.v" );
3083 Vec_PtrFree( vGias );
3085 Vec_StrFreeP( &vPatch );
3086 Vec_StrFreeP( &vInst );
3088 Vec_PtrFreeFree( vSops );
3089 Vec_WecFree( vSupps );
3090 Vec_IntFree( vSuppOld );
3091 Vec_IntFreeP( &vUsed );
3092 if ( vFuncs ) Vec_PtrFreeFree( vFuncs );
3098 Vec_IntFreeP( &vSuppF );
3099 Vec_IntFreeP( &vSuppG );
3100 Vec_IntFreeP( &vSupp );
3101 Vec_IntFreeP( &vNodesF );
3102 Vec_IntFreeP( &vNodesG );
3103 Vec_IntFreeP( &vRoots );
3104 Vec_IntFreeP( &vDivs );
3105 Vec_BitFreeP( &vBlock );
3140void Acb_NtkRunEco(
char * pFileNames[4],
int nTimeout,
int fCheck,
int fRandom,
int fInputs,
int fUnitW,
int fVerbose,
int fVeryVerbose )
3142 char Command[1000];
int Result = 1;
3145 if ( !pNtkF || !pNtkG )
3152 printf(
"Permuting targets as follows: " );
3157 assert( Acb_NtkCiNum(pNtkF) == Acb_NtkCiNum(pNtkG) );
3158 assert( Acb_NtkCoNum(pNtkF) == Acb_NtkCoNum(pNtkG) );
3162 if ( !
Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, nTimeout, 0, fInputs, fCheck, fUnitW, fVerbose, fVeryVerbose ) )
3167 printf(
"Computation did not succeed.\n" );
3171 Acb_ManFree( pNtkF->
pDesign );
3172 Acb_ManFree( pNtkG->
pDesign );
3175 sprintf( Command,
"read %s; strash; write temp1.aig; read %s; strash; write temp2.aig; &cec temp1.aig temp2.aig",
3176 pFileNames[1], pFileNames[3] ? pFileNames[3] :
"out.v" );
3178 fprintf( stdout,
"Cannot execute command \"%s\".\n", Command );
Gia_Man_t * Gia_ManInterOne(Gia_Man_t *pNtkOn, Gia_Man_t *pNtkOff, int fVerbose)
Vec_Wec_t * Abc_SopSynthesize(Vec_Ptr_t *vSops)
Gia_Man_t * Abc_GiaSynthesizeInter(Gia_Man_t *p)
Vec_Wec_t * Abc_GiaSynthesize(Vec_Ptr_t *vGias, Gia_Man_t *pMulti)
ABC_DLL Gia_Man_t * Abc_SopSynthesizeOne(char *pSop, int fClp)
#define ABC_SWAP(Type, a, b)
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
Acb_Ntk_t * Acb_NtkFromNdr(char *pFileName, void *pModule, Abc_Nam_t *pNames, Vec_Int_t *vWeights, int nNameIdMax)
Gia_Man_t * Gia_FileSimpleParse(Vec_Int_t *vBuffer, Abc_Nam_t *pNames, int fNames, char *pFileW)
Vec_Int_t * Acb_ReadWeightMap(char *pFileName, Abc_Nam_t *pNames)
Acb_KeyWords_t
DECLARATIONS ///.
Gia_Man_t * Gia_FileSimpleRead(char *pFileName, int fNames, char *pFileW)
Vec_Int_t * Acb_FindSupportMinOne(sat_solver *pSat, int iFirstDiv, Vec_Wrd_t *vPats, int *pnPats, Vec_Int_t *vSupp, int iVar)
void Acb_PrintPatch(Acb_Ntk_t *pNtkF, Vec_Int_t *vDivs, Vec_Int_t *vUsed, abctime clk)
Vec_Int_t * Acb_DerivePatchSupportS(Cnf_Dat_t *pCnf, int nCiTars, int nCoDivs, Vec_Int_t *vDivs, Acb_Ntk_t *pNtkF, Vec_Int_t *vSuppOld, int TimeOut)
Vec_Int_t * Acb_GetUsedDivs(Vec_Int_t *vDivs, Vec_Int_t *vUsed)
Acb_Ntk_t * Acb_VerilogSimpleRead(char *pFileName, char *pFileNameW)
char ** Acb_PrepareNames(Abc_Nam_t *p)
Vec_Ptr_t * Acb_GenerateSignalNames(Acb_Ntk_t *p, Vec_Int_t *vDivs, Vec_Int_t *vUsed, int nNodes, Vec_Int_t *vTars, Vec_Wec_t *vGates)
int Acb_NtkFindDivs_rec(Acb_Ntk_t *p, int iObj)
void Acb_VerilogSimpleReadTest(char *pFileName)
int Acb_NtkEcoPerform(Acb_Ntk_t *pNtkF, Acb_Ntk_t *pNtkG, char *pFileName[4], int nTimeout, int fCisOnly, int fInputs, int fCheck, int fUnitW, int fVerbose, int fVeryVerbose)
int Gia_FileSimpleParse_rec(Gia_Man_t *pNew, int Token, Vec_Int_t *vMapType, Vec_Int_t *vTypes, Vec_Int_t *vFanins, Vec_Int_t *vMap)
void Acb_CollectIntNodes_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vNodes)
Gia_Man_t * Acb_NtkDeriveMiterCnfInter2(Gia_Man_t *p, int iTar, int nTars)
int Acb_WireIsTarget(int Token, Abc_Nam_t *pNames)
Vec_Int_t * Acb_DerivePatchSupport(Cnf_Dat_t *pCnf, int iTar, int nTargets, int nCoDivs, Vec_Int_t *vDivs, Acb_Ntk_t *pNtkF, Vec_Int_t *vSuppOld, int TimeOut)
void * Acb_VerilogSimpleParse(Vec_Int_t *vBuffer, Abc_Nam_t *pNames)
void Acb_NtkRunEco(char *pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fUnitW, int fVerbose, int fVeryVerbose)
int Acb_FindArgMaxUnderMask(Vec_Wrd_t *vPats, word Mask[NWORDS], Vec_Int_t *vWeights, int nPats)
void Acb_NtkFindSupp_rec(Acb_Ntk_t *p, int iObj, Vec_Int_t *vSupp)
char * Acb_DeriveOnePatchFunction(Cnf_Dat_t *pCnf, int iTar, int nTargets, int nCoDivs, Vec_Int_t *vUsed, int fCisOnly)
int Acb_ObjToGia(Gia_Man_t *pNew, Acb_Ntk_t *p, int iObj, Vec_Int_t *vTemp)
char * Acb_RemapOneFunction(char *pStr, Vec_Int_t *vSupp, Vec_Int_t *vMap, int nVars)
Vec_Ptr_t * Acb_GenerateSignalNames2(Vec_Wec_t *vGates, Vec_Ptr_t *vIns, Vec_Ptr_t *vOuts)
Vec_Str_t * Acb_GeneratePatch(Acb_Ntk_t *p, Vec_Int_t *vDivs, Vec_Int_t *vUsed, Vec_Ptr_t *vSops, Vec_Ptr_t *vGias, Vec_Int_t *vTars)
Vec_Str_t * Acb_GenerateInstance(Acb_Ntk_t *p, Vec_Int_t *vDivs, Vec_Int_t *vUsed, Vec_Int_t *vTars)
Vec_Int_t * Acb_FindSupportStart(sat_solver *pSat, int iFirstDiv, Vec_Int_t *vWeights, Vec_Wrd_t **pvPats, int *piPats)
Vec_Int_t * Acb_DeriveWeights(Vec_Int_t *vDivs, Acb_Ntk_t *pNtkF)
Vec_Int_t * Acb_NtkFindNodes(Acb_Ntk_t *p, Vec_Int_t *vRoots, Vec_Int_t *vDivs)
Vec_Int_t * Acb_NtkFindDivsCis(Acb_Ntk_t *p, Vec_Int_t *vSupp)
int Acb_NtkSaveNames(Acb_Ntk_t *p, Vec_Int_t *vSupp, Vec_Int_t *vNodes, Vec_Int_t *vRoots, Vec_Int_t *vDivs, Vec_Int_t *vTargets, Gia_Man_t *pNew)
void Vec_IntPermute(Vec_Int_t *p)
void Acb_GenerateFilePatch(Vec_Str_t *p, char *pFileNamePatch)
void Acb_NtkTestRun2(char *pFileNames[3], int fVerbose)
char * Acb_EnumerateSatAssigns(sat_solver *pSat, int PivotVar, int FreeVar, Vec_Int_t *vDivVars, Vec_Int_t *vTempLits, Vec_Str_t *vTempSop)
Vec_Int_t * Acb_FindSupportMin(sat_solver *pSat, int iFirstDiv, Vec_Wrd_t *vPats, int *pnPats, Vec_Int_t *vSuppStart)
void Acb_NtkFindNodes_rec(Acb_Ntk_t *p, int iObj, Vec_Int_t *vNodes)
int Acb_FindArgMaxUnderMask2(Vec_Wrd_t *vPats, word Mask[NWORDS], Vec_Int_t *vWeights, int nPats)
Gia_Man_t * Acb_NtkToGia(Acb_Ntk_t *p, Vec_Int_t *vSupp, Vec_Int_t *vNodes, Vec_Int_t *vRoots, Vec_Int_t *vDivs, Vec_Int_t *vTargets)
int Acb_ComputeSuppCost(Vec_Int_t *vSupp, Vec_Int_t *vWeights, int iFirstDiv)
void Acb_FindReplace(sat_solver *pSat, int iFirstDiv, Vec_Int_t *vWeights, Vec_Wrd_t *vPats, int nPats, Vec_Int_t *vSupp)
Abc_Nam_t * Acb_VerilogStartNames()
Vec_Int_t * Acb_NtkFindDivs(Acb_Ntk_t *p, Vec_Int_t *vSupp, Vec_Bit_t *vBlock, int fUnitW, int fVerbose)
Gia_Man_t * Acb_NtkEcoSynthesize(Gia_Man_t *p)
void Acb_PrintPatterns(Vec_Wrd_t *vPats, int nPats, Vec_Int_t *vWeights)
Vec_Int_t * Acb_NtkFindRoots(Acb_Ntk_t *p, Vec_Int_t *vTargets, Vec_Bit_t **pvBlock)
Gia_Man_t * Acb_NtkDeriveMiterCnfInter(Gia_Man_t *p, int iTar, int nTars)
Vec_Int_t * Acb_FindSupport(sat_solver *pSat, int iFirstDiv, Vec_Int_t *vWeights, Vec_Int_t *vSuppStart, int TimeOut)
Vec_Str_t * Acb_GeneratePatch2(Gia_Man_t *pGia, Vec_Ptr_t *vIns, Vec_Ptr_t *vOuts)
Gia_Man_t * Acb_UpdateMiter(Gia_Man_t *pM, Gia_Man_t *pOne, int iTar, int nTargets, Vec_Int_t *vUsed, int fCisOnly)
void Acb_IntallLibrary(int f2Ins)
void Acb_GenerateFile2(Gia_Man_t *pGia, Vec_Ptr_t *vIns, Vec_Ptr_t *vOuts, char *pFileName, char *pFileNameOut, int fSkipMffc)
int Acb_NtkFindRoots_rec(Acb_Ntk_t *p, int iObj, Vec_Bit_t *vBlock)
void Acb_CollectIntNodes(Gia_Man_t *p, Vec_Int_t *vNodes0, Vec_Int_t *vNodes1)
Vec_Ptr_t * Acb_TransformPatchFunctions(Vec_Ptr_t *vSops, Vec_Wec_t *vSupps, Vec_Int_t **pvUsed, int nDivs)
Vec_Int_t * Acb_FindSupportNext(sat_solver *pSat, int iFirstDiv, Vec_Int_t *vWeights, Vec_Wrd_t *vPats, int *pnPats)
Vec_Str_t * Acb_GenerateInstance2(Vec_Ptr_t *vIns, Vec_Ptr_t *vOuts)
Vec_Int_t * Acb_VerilogSimpleLex(char *pFileName, Abc_Nam_t *pNames)
void Acb_VerilogRemoveComments(char *pBuffer)
Vec_Ptr_t * Acb_SignalNames(Acb_Ntk_t *p, Vec_Int_t *vObjs)
Gia_Man_t * Gia_ManInterOneInt(Gia_Man_t *pCof1, Gia_Man_t *pCof0, int Depth)
Gia_Man_t * Acb_CreateMiter(Gia_Man_t *pF, Gia_Man_t *pG)
int Acb_CheckMiter(Cnf_Dat_t *pCnf)
void Acb_VerilogSimpleWrite(Acb_Ntk_t *p, char *pFileName)
char * pLibStr[25]
FUNCTION DEFINITIONS ///.
Vec_Int_t * Acb_NtkFindSupp(Acb_Ntk_t *p, Vec_Int_t *vRoots)
Cnf_Dat_t * Acb_NtkDeriveMiterCnf(Gia_Man_t *p, int iTar, int nTars, int fVerbose)
void Vec_IntPermute2(Vec_Int_t *p)
void Acb_GenerateFileOut(Vec_Str_t *vPatchLine, char *pFileNameF, char *pFileNameOut, Vec_Str_t *vPatch)
int Acb_NtkCollectMfsGates(char *pFileName, Vec_Ptr_t *vNamesRefed, Vec_Ptr_t *vNamesDerefed, int nGates[5])
void Acb_NtkInsert(char *pFileNameIn, char *pFileNameOut, Vec_Ptr_t *vNames, int fNumber, int fSkipMffc)
#define Acb_NtkForEachCoDriver(p, iObj, i)
#define Acb_NtkForEachCi(p, iObj, i)
struct Acb_Ntk_t_ Acb_Ntk_t
int Acb_NtkCountPiBuffers(Acb_Ntk_t *p, Vec_Int_t *vObjs)
#define Acb_NtkForEachCiVec(vVec, p, iObj, i)
Vec_Int_t * Acb_ObjCollectTfoVec(Acb_Ntk_t *p, Vec_Int_t *vObjs)
int Acb_NtkCountPoDrivers(Acb_Ntk_t *p, Vec_Int_t *vObjs)
Vec_Int_t * Acb_ObjCollectTfiVec(Acb_Ntk_t *p, Vec_Int_t *vObjs)
#define Acb_NtkForEachCoDriverVec(vVec, p, iObj, i)
#define Acb_NtkForEachPo(p, iObj, i)
#define Acb_NtkForEachPi(p, iObj, i)
#define Acb_NtkForEachNode(p, i)
#define Acb_ObjForEachFaninFast(p, iObj, pFanins, iFanin, k)
ABC_DLL Vec_Ptr_t * Abc_FrameReadSignalNames()
ABC_DLL char * Abc_FrameReadSpecName()
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Vec_Str_t_ Vec_Str_t
#define sat_solver_addclause
#define sat_solver_add_xor
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
struct Cnf_Dat_t_ Cnf_Dat_t
void Cnf_DataFree(Cnf_Dat_t *p)
void Cnf_DataLift(Cnf_Dat_t *p, int nVarsPlus)
Gia_Man_t * Gia_ManCompress2(Gia_Man_t *p, int fUpdateLevel, int fVerbose)
void Gia_ManStop(Gia_Man_t *p)
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
#define Gia_ManForEachAnd(p, pObj, i)
Gia_Man_t * Gia_ManDupRemovePis(Gia_Man_t *p, int nRemPis)
Gia_Man_t * Gia_ManDupUniv(Gia_Man_t *p, int iVar)
Gia_Man_t * Gia_ManAreaBalance(Gia_Man_t *p, int fSimpleAnd, int nNewNodesMax, int fVerbose, int fVeryVerbose)
void Gia_ManHashAlloc(Gia_Man_t *p)
Gia_Man_t * Gia_ManDupCofactorVar(Gia_Man_t *p, int iVar, int Value)
Gia_Man_t * Gia_ManDupMux(int iVar, Gia_Man_t *pCof1, Gia_Man_t *pCof0)
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
struct Gia_Obj_t_ Gia_Obj_t
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
void Gia_ManFillValue(Gia_Man_t *p)
struct Gia_Man_t_ Gia_Man_t
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Gia_Man_t * Gia_ManAigSyn2(Gia_Man_t *p, int fOldAlgo, int fCoarsen, int fCutMin, int nRelaxRatio, int fDelayMin, int fVerbose, int fVeryVerbose)
void Gia_ManIncrementTravId(Gia_Man_t *p)
#define Gia_ManForEachCo(p, pObj, i)
#define Gia_ManForEachCi(p, pObj, i)
void Gia_ManHashStop(Gia_Man_t *p)
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
void * Mf_ManGenerateCnf(Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fMapping, int fVerbose)
void Gia_AigerWrite(Gia_Man_t *p, char *pFileName, int fWriteSymbols, int fCompact, int fWriteNewLine)
Gia_Man_t * Gia_ManDupDfsRehash(Gia_Man_t *p)
unsigned __int64 word
DECLARATIONS ///.
Mio_Library_t * Mio_LibraryReadBuffer(char *pBuffer, int fExtendedFormat, st__table *tExcludeGate, int nFaninLimit, int fVerbose)
void Mio_UpdateGenlib(Mio_Library_t *pLib)
FUNCTION DEFINITIONS ///.
struct Mio_LibraryStruct_t_ Mio_Library_t
void Mio_LibrarySetName(Mio_Library_t *pLib, char *pName)
struct Ndr_Data_t_ Ndr_Data_t
BASIC TYPES ///.
void * Cnf_DataWriteIntoSolver(Cnf_Dat_t *p, int nFrames, int fInit)
sat_solver * sat_solver_new(void)
void sat_solver_setnvars(sat_solver *s, int n)
int sat_solver_nvars(sat_solver *s)
int sat_solver_push(sat_solver *s, int p)
void sat_solver_pop(sat_solver *s)
void sat_solver_delete(sat_solver *s)
int sat_solver_minimize_assumptions(sat_solver *s, int *pLits, int nLits, int nConfLimit)
void satoko_setnvars(satoko_t *, int)
int satoko_solve_assumptions(satoko_t *s, int *plits, int nlits)
int satoko_final_conflict(satoko_t *, int **)
int satoko_minimize_assumptions(satoko_t *s, int *plits, int nlits, int nconflim)
int satoko_add_clause(satoko_t *, int *, int)
struct solver_t_ satoko_t
void satoko_destroy(satoko_t *)
satoko_t * satoko_create(void)
satoko_opts_t * satoko_options(satoko_t *)
int Abc_NamStrFind(Abc_Nam_t *p, char *pStr)
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
int Abc_NamObjNumMax(Abc_Nam_t *p)
Abc_Nam_t * Abc_NamStart(int nObjs, int nAveSize)
FUNCTION DEFINITIONS ///.
void Abc_NamDeref(Abc_Nam_t *p)
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
typedefABC_NAMESPACE_HEADER_START struct Abc_Nam_t_ Abc_Nam_t
INCLUDES ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_IntForEachEntryInVec(vVec2, vVec, Entry, i)
#define Vec_IntForEachEntryStop(vVec, Entry, i, Stop)
#define Vec_IntForEachEntryReverse(vVec, pEntry, i)
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
#define Vec_WecForEachLevelStartStop(vGlob, vVec, i, LevelStart, LevelStop)
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.