30#define SUPER_MASK(n) ((~((unsigned)0)) >> (32-(n)))
31#define SUPER_FULL (~((unsigned)0))
32#define SUPER_NO_VAR (-9999.0)
33#define SUPER_EPSILON (0.001)
97#define Super_ManForEachGate( GateArray, Limit, Index, Gate ) \
99 Index < Limit && (Gate = GateArray[Index]); \
107static void Super_First(
Super_Man_t * pMan,
int nVarsMax );
110static int Super_CompareGates(
Super_Man_t * pMan,
unsigned uTruth[],
float Area,
float tPinDelaysRes[],
int nPins );
113static void Super_TranferGatesToArray(
Super_Man_t * pMan );
118static void Super_WriteFileHeader(
Super_Man_t * pMan, FILE * pFile );
120static void Super_WriteLibrary(
Super_Man_t * pMan );
122static void Super_WriteLibraryTreeFile(
Super_Man_t * pMan );
140void Super_Precompute(
Mio_Library_t * pLibGen,
int nVarsMax,
int nLevels,
int nGatesMax,
float tDelayMax,
float tAreaMax,
int TimeLimit,
int fSkipInv,
int fVerbose,
char * pFileName )
143 FILE * pFile = fopen( pFileName,
"wb" );
146 printf(
"Cannot open output file \"%s\".\n", pFileName );
149 vStr =
Super_PrecomputeStr( pLibGen, nVarsMax, nLevels, nGatesMax, tDelayMax, tAreaMax, TimeLimit, fSkipInv, fVerbose );
152 fwrite( Vec_StrArray(vStr), 1, Vec_StrSize(vStr), pFile );
159 printf(
"The supergates are written using new format \"%s\" ", pFileName );
160 printf(
"(%0.3f MB).\n", ((
double)
Extra_FileSize(pFileName))/(1<<20) );
184 if ( nGatesMax && nGatesMax < nVarsMax )
186 fprintf( stderr,
"Erro! The number of supergates requested (%d) in less than the number of variables (%d).\n", nGatesMax, nVarsMax );
187 fprintf( stderr,
"The library cannot be computed.\n" );
192 ppGates =
Mio_CollectRoots( pLibGen, nVarsMax, tDelayMax, 0, &nGates, fVerbose );
193 if ( nGatesMax && nGates >= nGatesMax )
195 fprintf( stdout,
"Warning! Genlib library contains more gates than can be computed.\n");
196 fprintf( stdout,
"Only one-gate supergates are included in the supergate library.\n" );
200 pMan = Super_ManStart();
207 pMan->
TimeStop = TimeLimit ? TimeLimit * CLOCKS_PER_SEC + Abc_Clock() : 0;
212 fprintf( stderr,
"Error: No genlib gates satisfy the limits criteria. Stop.\n");
213 fprintf( stderr,
"Limits: max delay = %.2f, max area = %.2f, time limit = %d sec.\n",
217 Super_ManStop( pMan );
224 Super_First( pMan, nVarsMax );
227 clockStart = Abc_Clock();
230 printf(
"Computing supergates with %d inputs, %d levels, and %d max gates.\n",
231 pMan->
nVarsMax, nLevels, nGatesMax );
232 printf(
"Limits: max delay = %.2f, max area = %.2f, time limit = %d sec.\n",
236 for ( Level = 1; Level <= nLevels; Level++ )
241 Super_Compute( pMan, ppGates, nGates, nGatesMax, fSkipInv );
245 printf(
"Lev %d: Try =%12d. Add =%6d. Rem =%5d. Save =%6d. Lookups =%12d. Aliases =%12d. ",
247ABC_PRT(
"Time", Abc_Clock() - clk );
251 pMan->
Time = Abc_Clock() - clockStart;
255printf(
"Writing the output file...\n" );
259 vStr = Super_Write( pMan );
262 Super_ManStop( pMan );
279void Super_First(
Super_Man_t * pMan,
int nVarsMax )
282 int nMintLimit, nVarLimit;
286 pMan->
nMints = (1 << nVarsMax);
292 for ( v = 0; v < nVarsMax; v++ )
300 for ( m = 0; m < nVarsMax; m++ )
305 Super_AddGateToTable( pMan, pSuper );
309 nVarLimit = (nVarsMax >= 5)? 5 : nVarsMax;
310 nMintLimit = (1 << nVarLimit);
311 for ( m = 0; m < nMintLimit; m++ )
312 for ( v = 0; v < nVarLimit; v++ )
318 for ( v = 0; v < 5; v++ )
325 for ( v = 0; v < nVarsMax; v++ )
348 Super_Gate_t * pSupers[6], * pGate0, * pGate1, * pGate2, * pGate3, * pGate4, * pGate5, * pGateNew;
349 float tPinDelaysRes[6], * ptPinDelays[6], tPinDelayMax, tDelayMio;
351 float Area0, Area1, Area2, Area3, Area4, AreaMio;
352 unsigned uTruth[2], uTruths[6][2];
353 int i0, i1, i2, i3, i4, i5;
355 int nFanins, nGatesLimit, k, s, t;
361 int iPruneLimitRoot = 4;
366 Super_TranferGatesToArray( pMan );
369 if ( pMan->
nGates > 10000 )
371 printf(
"Sorting array of %d supergates...\r", pMan->
nGates );
375 (int (*)(
const void *,
const void *)) Super_DelayCompare );
377 if ( pMan->
nGates > 10000 )
383 pMan->
TimePrint = Abc_Clock() + CLOCKS_PER_SEC;
388 for ( k = 0; k < nGates; k++ )
390 if ( fTimeOut )
break;
409 for ( s = 0, t = 0; s < pMan->
nGates; s++ )
414 ppGatesLimit[t] = pMan->
pGates[s];
415 if ( ppGatesLimit[t++]->tDelayMax + tDelayMio > pMan->
tDelayMax && pMan->
tDelayMax > 0.0 )
428 if ( nGatesLimit > 10000 )
429 printf(
"Sorting array of %d supergates...\r", nGatesLimit );
430 qsort( (
void *)ppGatesLimit, (
size_t)nGatesLimit,
sizeof(
Super_Gate_t *),
431 (
int (*)(
const void *,
const void *)) Super_AreaCompare );
432 assert( Super_AreaCompare( ppGatesLimit, ppGatesLimit + nGatesLimit - 1 ) <= 0 );
433 if ( nGatesLimit > 10000 )
447 if ( fTimeOut )
break;
448 fTimeOut = Super_CheckTimeout( pProgress, pMan );
452 if ( fSkipInv && pGate0->
tDelayMax == 0 )
455 Area = AreaMio + pGate0->
Area;
459 pSupers[0] = pGate0; uTruths[0][0] = pGate0->
uTruth[0]; uTruths[0][1] = pGate0->
uTruth[1]; ptPinDelays[0] = pGate0->
ptDelays;
462 if ( !Super_CompareGates( pMan, uTruth, Area, tPinDelaysRes, pMan->
nVarsMax ) )
465 pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->
nVarsMax );
466 Super_AddGateToTable( pMan, pGateNew );
467 if ( nGatesMax && pMan->
nClasses > nGatesMax )
474 Area0 = AreaMio + pGate0->
Area;
477 pSupers[0] = pGate0; uTruths[0][0] = pGate0->
uTruth[0]; uTruths[0][1] = pGate0->
uTruth[1]; ptPinDelays[0] = pGate0->
ptDelays;
481 if ( fTimeOut )
goto done;
482 fTimeOut = Super_CheckTimeout( pProgress, pMan );
484 Area = Area0 + pGate1->
Area;
488 pSupers[1] = pGate1; uTruths[1][0] = pGate1->
uTruth[0]; uTruths[1][1] = pGate1->
uTruth[1]; ptPinDelays[1] = pGate1->
ptDelays;
491 if ( !Super_CompareGates( pMan, uTruth, Area, tPinDelaysRes, pMan->
nVarsMax ) )
494 pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->
nVarsMax );
495 Super_AddGateToTable( pMan, pGateNew );
496 if ( nGatesMax && pMan->
nClasses > nGatesMax )
504 Area0 = AreaMio + pGate0->
Area;
507 pSupers[0] = pGate0; uTruths[0][0] = pGate0->
uTruth[0]; uTruths[0][1] = pGate0->
uTruth[1]; ptPinDelays[0] = pGate0->
ptDelays;
512 Area1 = Area0 + pGate1->
Area;
515 pSupers[1] = pGate1; uTruths[1][0] = pGate1->
uTruth[0]; uTruths[1][1] = pGate1->
uTruth[1]; ptPinDelays[1] = pGate1->
ptDelays;
518 if ( i2 != i0 && i2 != i1 )
520 if ( fTimeOut )
goto done;
521 fTimeOut = Super_CheckTimeout( pProgress, pMan );
523 Area = Area1 + pGate2->
Area;
526 pSupers[2] = pGate2; uTruths[2][0] = pGate2->
uTruth[0]; uTruths[2][1] = pGate2->
uTruth[1]; ptPinDelays[2] = pGate2->
ptDelays;
530 if ( !Super_CompareGates( pMan, uTruth, Area, tPinDelaysRes, pMan->
nVarsMax ) )
533 pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->
nVarsMax );
534 Super_AddGateToTable( pMan, pGateNew );
535 if ( nGatesMax && pMan->
nClasses > nGatesMax )
544 Area0 = AreaMio + pGate0->
Area;
547 pSupers[0] = pGate0; uTruths[0][0] = pGate0->
uTruth[0]; uTruths[0][1] = pGate0->
uTruth[1]; ptPinDelays[0] = pGate0->
ptDelays;
552 Area1 = Area0 + pGate1->
Area;
555 pSupers[1] = pGate1; uTruths[1][0] = pGate1->
uTruth[0]; uTruths[1][1] = pGate1->
uTruth[1]; ptPinDelays[1] = pGate1->
ptDelays;
558 if ( i2 != i0 && i2 != i1 )
560 Area2 = Area1 + pGate2->
Area;
563 pSupers[2] = pGate2; uTruths[2][0] = pGate2->
uTruth[0]; uTruths[2][1] = pGate2->
uTruth[1]; ptPinDelays[2] = pGate2->
ptDelays;
566 if ( i3 != i0 && i3 != i1 && i3 != i2 )
568 if ( fTimeOut )
goto done;
569 fTimeOut = Super_CheckTimeout( pProgress, pMan );
571 Area = Area2 + pGate3->
Area;
574 pSupers[3] = pGate3; uTruths[3][0] = pGate3->
uTruth[0]; uTruths[3][1] = pGate3->
uTruth[1]; ptPinDelays[3] = pGate3->
ptDelays;
578 if ( !Super_CompareGates( pMan, uTruth, Area, tPinDelaysRes, pMan->
nVarsMax ) )
581 pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->
nVarsMax );
582 Super_AddGateToTable( pMan, pGateNew );
583 if ( nGatesMax && pMan->
nClasses > nGatesMax )
593 Area0 = AreaMio + pGate0->
Area;
596 pSupers[0] = pGate0; uTruths[0][0] = pGate0->
uTruth[0]; uTruths[0][1] = pGate0->
uTruth[1]; ptPinDelays[0] = pGate0->
ptDelays;
601 Area1 = Area0 + pGate1->
Area;
604 pSupers[1] = pGate1; uTruths[1][0] = pGate1->
uTruth[0]; uTruths[1][1] = pGate1->
uTruth[1]; ptPinDelays[1] = pGate1->
ptDelays;
607 if ( i2 != i0 && i2 != i1 )
609 Area2 = Area1 + pGate2->
Area;
612 pSupers[2] = pGate2; uTruths[2][0] = pGate2->
uTruth[0]; uTruths[2][1] = pGate2->
uTruth[1]; ptPinDelays[2] = pGate2->
ptDelays;
615 if ( i3 != i0 && i3 != i1 && i3 != i2 )
617 Area3 = Area2 + pGate3->
Area;
620 pSupers[3] = pGate3; uTruths[3][0] = pGate3->
uTruth[0]; uTruths[3][1] = pGate3->
uTruth[1]; ptPinDelays[3] = pGate3->
ptDelays;
623 if ( i4 != i0 && i4 != i1 && i4 != i2 && i4 != i3 )
625 if ( fTimeOut )
goto done;
626 fTimeOut = Super_CheckTimeout( pProgress, pMan );
628 Area = Area3 + pGate4->
Area;
631 pSupers[4] = pGate4; uTruths[4][0] = pGate4->
uTruth[0]; uTruths[4][1] = pGate4->
uTruth[1]; ptPinDelays[4] = pGate4->
ptDelays;
635 if ( !Super_CompareGates( pMan, uTruth, Area, tPinDelaysRes, pMan->
nVarsMax ) )
638 pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->
nVarsMax );
639 Super_AddGateToTable( pMan, pGateNew );
640 if ( nGatesMax && pMan->
nClasses > nGatesMax )
651 Area0 = AreaMio + pGate0->
Area;
654 pSupers[0] = pGate0; uTruths[0][0] = pGate0->
uTruth[0]; uTruths[0][1] = pGate0->
uTruth[1]; ptPinDelays[0] = pGate0->
ptDelays;
659 Area1 = Area0 + pGate1->
Area;
662 pSupers[1] = pGate1; uTruths[1][0] = pGate1->
uTruth[0]; uTruths[1][1] = pGate1->
uTruth[1]; ptPinDelays[1] = pGate1->
ptDelays;
665 if ( i2 != i0 && i2 != i1 )
667 Area2 = Area1 + pGate2->
Area;
670 pSupers[2] = pGate2; uTruths[2][0] = pGate2->
uTruth[0]; uTruths[2][1] = pGate2->
uTruth[1]; ptPinDelays[2] = pGate2->
ptDelays;
673 if ( i3 != i0 && i3 != i1 && i3 != i2 )
675 Area3 = Area2 + pGate3->
Area;
678 pSupers[3] = pGate3; uTruths[3][0] = pGate3->
uTruth[0]; uTruths[3][1] = pGate3->
uTruth[1]; ptPinDelays[3] = pGate3->
ptDelays;
681 if ( i4 != i0 && i4 != i1 && i4 != i2 && i4 != i3 )
683 if ( fTimeOut )
break;
684 fTimeOut = Super_CheckTimeout( pProgress, pMan );
686 Area4 = Area3 + pGate4->
Area;
689 pSupers[4] = pGate4; uTruths[4][0] = pGate4->
uTruth[0]; uTruths[4][1] = pGate4->
uTruth[1]; ptPinDelays[4] = pGate4->
ptDelays;
692 if ( i5 != i0 && i5 != i1 && i5 != i2 && i5 != i3 && i5 != i4 )
694 if ( fTimeOut )
goto done;
695 fTimeOut = Super_CheckTimeout( pProgress, pMan );
697 Area = Area4 + pGate5->
Area;
700 pSupers[5] = pGate5; uTruths[5][0] = pGate5->
uTruth[0]; uTruths[5][1] = pGate5->
uTruth[1]; ptPinDelays[5] = pGate5->
ptDelays;
704 if ( !Super_CompareGates( pMan, uTruth, Area, tPinDelaysRes, pMan->
nVarsMax ) )
707 pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->
nVarsMax );
708 Super_AddGateToTable( pMan, pGateNew );
709 if ( nGatesMax && pMan->
nClasses > nGatesMax )
745 Extra_ProgressBarUpdate( pPro, ++pMan->
TimeSec, NULL );
746 pMan->
TimePrint = Abc_Clock() + CLOCKS_PER_SEC;
750 printf (
"Timeout!\n");
769void Super_TranferGatesToArray(
Super_Man_t * pMan )
781 for ( pGate = pList; pGate; pGate = pGate->
pNext )
809 pGate->
pNext = *ppList;
827int Super_CompareGates(
Super_Man_t * pMan,
unsigned uTruth[],
float Area,
float tPinDelaysRes[],
int nPins )
830 int i, fNewIsBetter, fGateIsBetter;
836 if ( uTruth[0] == 0 || ~uTruth[0] == 0 )
841 if ( ( uTruth[0] == 0 && uTruth[1] == 0 ) || ( ~uTruth[0] == 0 && ~uTruth[1] == 0 ) )
847 Key = uTruth[0] ^ uTruth[1];
852 for ( pGate = *ppList, pGate2 = pGate? pGate->
pNext: NULL; pGate;
853 pGate = pGate2, pGate2 = pGate? pGate->
pNext: NULL )
856 if ( pGate->
uTruth[0] != uTruth[0] || pGate->
uTruth[1] != uTruth[1] )
867 for ( i = 0; i < nPins; i++ )
875 if ( fGateIsBetter && fNewIsBetter )
879 if ( fGateIsBetter && fNewIsBetter )
881 else if ( fNewIsBetter )
884 *ppList = pGate->
pNext;
890 else if ( fGateIsBetter )
911 unsigned uTruth[],
float Area,
float tPinDelaysRes[],
float tDelayMax,
int nPins )
916 pSuper->
pRoot = pRoot;
917 pSuper->
uTruth[0] = uTruth[0];
918 pSuper->
uTruth[1] = uTruth[1];
923 pSuper->
pNext = NULL;
993 printf(
"The generated library is empty. No output file written.\n" );
1006 for ( pGate = pGateRoot; pGate; pGate = pGate->
pNext )
1009 if ( pGate->
pRoot == NULL )
1013 for ( v = 0; v < pMan->
nVarsMax; v++ )
1016 else if ( fZeroFound )
1018 if ( v < pMan->nVarsMax )
1028 (int (*)(
const void *,
const void *)) Super_WriteCompare );
1032ABC_PRT(
"Sorting", Abc_Clock() - clk );
1039 Super_WriteLibrary( pMan );
1042ABC_PRT(
"Writing old format", Abc_Clock() - clk );
1047 vStr = Super_WriteLibraryTreeStr( pMan );
1050ABC_PRT(
"Writing new format", Abc_Clock() - clk );
1067void Super_WriteFileHeader(
Super_Man_t * pMan, FILE * pFile )
1069 fprintf( pFile,
"#\n" );
1070 fprintf( pFile,
"# Supergate library derived for \"%s\" on %s.\n", pMan->
pName,
Extra_TimeStamp() );
1071 fprintf( pFile,
"#\n" );
1072 fprintf( pFile,
"# Command line: \"super -I %d -L %d -N %d -T %d -D %.2f -A %.2f %s %s\".\n",
1074 fprintf( pFile,
"#\n" );
1075 fprintf( pFile,
"# The number of inputs = %10d.\n", pMan->
nVarsMax );
1076 fprintf( pFile,
"# The number of levels = %10d.\n", pMan->
nLevels );
1077 fprintf( pFile,
"# The maximum delay = %10.2f.\n", pMan->
tDelayMax );
1078 fprintf( pFile,
"# The maximum area = %10.2f.\n", pMan->
tAreaMax );
1079 fprintf( pFile,
"# The maximum runtime (sec) = %10d.\n", pMan->
TimeLimit );
1080 fprintf( pFile,
"#\n" );
1081 fprintf( pFile,
"# The number of attempts = %10d.\n", pMan->
nTried );
1082 fprintf( pFile,
"# The number of supergates = %10d.\n", pMan->
nGates );
1083 fprintf( pFile,
"# The number of functions = %10d.\n", pMan->
nUnique );
1084 fprintf( pFile,
"# The total functions = %.0f (2^%d).\n", pow((
double)2,pMan->
nMints), pMan->
nMints );
1085 fprintf( pFile,
"#\n" );
1086 fprintf( pFile,
"# Generation time = %10.2f sec.\n", (
float)(pMan->
Time)/(
float)(CLOCKS_PER_SEC) );
1087 fprintf( pFile,
"#\n" );
1088 fprintf( pFile,
"%s\n", pMan->
pName );
1089 fprintf( pFile,
"%d\n", pMan->
nVarsMax );
1090 fprintf( pFile,
"%d\n", pMan->
nGates );
1096 Vec_StrPrintStr( vStr, pBuffer );
1098 Vec_StrPrintStr( vStr, pBuffer );
1100 Vec_StrPrintStr( vStr, pBuffer );
1101 sprintf( pBuffer,
"# Command line: \"super -I %d -L %d -N %d -T %d -D %.2f -A %.2f %s %s\".\n",
1103 Vec_StrPrintStr( vStr, pBuffer );
1105 Vec_StrPrintStr( vStr, pBuffer );
1106 sprintf( pBuffer,
"# The number of inputs = %10d.\n", pMan->
nVarsMax );
1107 Vec_StrPrintStr( vStr, pBuffer );
1108 sprintf( pBuffer,
"# The number of levels = %10d.\n", pMan->
nLevels );
1109 Vec_StrPrintStr( vStr, pBuffer );
1111 Vec_StrPrintStr( vStr, pBuffer );
1113 Vec_StrPrintStr( vStr, pBuffer );
1114 sprintf( pBuffer,
"# The maximum runtime (sec) = %10d.\n", pMan->
TimeLimit );
1115 Vec_StrPrintStr( vStr, pBuffer );
1117 Vec_StrPrintStr( vStr, pBuffer );
1118 sprintf( pBuffer,
"# The number of attempts = %10d.\n", pMan->
nTried );
1119 Vec_StrPrintStr( vStr, pBuffer );
1120 sprintf( pBuffer,
"# The number of supergates = %10d.\n", pMan->
nGates );
1121 Vec_StrPrintStr( vStr, pBuffer );
1122 sprintf( pBuffer,
"# The number of functions = %10d.\n", pMan->
nUnique );
1123 Vec_StrPrintStr( vStr, pBuffer );
1124 sprintf( pBuffer,
"# The total functions = %.0f (2^%d).\n", pow((
double)2,pMan->
nMints), pMan->
nMints );
1125 Vec_StrPrintStr( vStr, pBuffer );
1127 Vec_StrPrintStr( vStr, pBuffer );
1128 sprintf( pBuffer,
"# Generation time = %10.2f sec.\n", (
float)(pMan->
Time)/(
float)(CLOCKS_PER_SEC) );
1129 Vec_StrPrintStr( vStr, pBuffer );
1131 Vec_StrPrintStr( vStr, pBuffer );
1133 Vec_StrPrintStr( vStr, pBuffer );
1135 Vec_StrPrintStr( vStr, pBuffer );
1137 Vec_StrPrintStr( vStr, pBuffer );
1153 unsigned * pTruth1 = (*ppG1)->uTruth;
1154 unsigned * pTruth2 = (*ppG2)->uTruth;
1155 if ( pTruth1[1] < pTruth2[1] )
1157 if ( pTruth1[1] > pTruth2[1] )
1159 if ( pTruth1[0] < pTruth2[0] )
1161 if ( pTruth1[0] > pTruth2[0] )
1167 if ( (*ppG1)->tDelayMax < (*ppG2)->tDelayMax )
1169 if ( (*ppG1)->tDelayMax > (*ppG2)->tDelayMax )
1175 if ( (*ppG1)->Area < (*ppG2)->Area )
1177 if ( (*ppG1)->Area > (*ppG2)->Area )
1203 if ( pGate->
pRoot == NULL )
1206 strcat( pBuffer, Buffer );
1211 for ( i = 0; i < (int)pGate->
nFanins; i++ )
1221 static char Buffer[2000];
1229 fprintf( pFile,
"%04d ", Num );
1231 fprintf( pFile,
" %5.2f", pGate->
tDelayMax );
1232 fprintf( pFile,
" " );
1233 for ( i = 0; i < pMan->
nVarsMax; i++ )
1235 fprintf( pFile,
" %5.2f", pGate->
Area );
1236 fprintf( pFile,
" " );
1238 fprintf( pFile,
"\n" );
1245 char * pNameGeneric;
1252 sprintf( FileName,
"%s.super_old", pNameGeneric );
1259 if ( i == pMan->
nGates - 1 )
1262 pGateNext = pMan->
pGates[i+1];
1268 pFile = fopen( FileName,
"w" );
1269 Super_WriteFileHeader( pMan, pFile );
1276 if ( i == pMan->
nGates - 1 )
1279 pGateNext = pMan->
pGates[i+1];
1281 fprintf( pFile,
"\n" );
1288 printf(
"The supergates are written using old format \"%s\" ", FileName );
1289 printf(
"(%0.3f MB).\n", ((
double)
Extra_FileSize(FileName))/(1<<20) );
1317 for ( i = 0; i < nFanins; i++ )
1320 pSuper->
Number = (*pCounter)++;
1321 fprintf( pFile,
"%s", pSuper->
fSuper?
"* " :
"" );
1323 for ( i = 0; i < nFanins; i++ )
1330 fprintf( pFile,
"\n" );
1332void Super_WriteLibraryTreeFile(
Super_Man_t * pMan )
1337 char * pNameGeneric;
1345 sprintf( FileName,
"%s.super", pNameGeneric );
1349 pFile = fopen( FileName,
"wb" );
1350 Super_WriteFileHeader( pMan, pFile );
1352 posStart = ftell( pFile );
1353 fprintf( pFile,
" \n" );
1363 pFile = fopen( FileName,
"rb+" );
1364 fseek( pFile, posStart,
SEEK_SET );
1365 fprintf( pFile,
"%d", Counter );
1370 printf(
"The supergates are written using new format \"%s\" ", FileName );
1371 printf(
"(%0.3f MB).\n", ((
double)
Extra_FileSize(FileName))/(1<<20) );
1397 for ( i = 0; i < nFanins; i++ )
1400 pSuper->
Number = (*pCounter)++;
1405 Vec_StrPrintStr( vStr, pSuper->
fSuper?
"* " :
"" );
1407 for ( i = 0; i < nFanins; i++ )
1409 Vec_StrPrintStr( vStr,
" " );
1418 Vec_StrPrintStr( vStr,
"\n" );
1428 vStr = Vec_StrAlloc( 1000 );
1431 posStart = Vec_StrSize( vStr );
1432 for ( i = 0; i < 9; i++ )
1433 Vec_StrPush( vStr,
' ' );
1434 Vec_StrPush( vStr,
'\n' );
1442 Vec_StrPush( vStr, 0 );
1444 sprintf( pInsert,
"%d", Counter );
1445 for ( i = 0; i < (int)
strlen(pInsert); i++ )
1446 Vec_StrWriteEntry( vStr, posStart + i, pInsert[i] );
1453 FILE * pFile = fopen( pFileName,
"wb" );
1454 if ( pFile == NULL )
1456 printf(
"Cannot open output file \"%s\".\n", pFileName );
1459 vStr = Super_WriteLibraryTreeStr( pMan );
1460 fwrite( Vec_StrArray(vStr), 1, Vec_StrSize(vStr), pFile );
1462 Vec_StrFree( vStr );
1466 printf(
"The supergates are written using new format \"%s\" ", pFileName );
1467 printf(
"(%0.3f MB).\n", ((
double)
Extra_FileSize(pFileName))/(1<<20) );
#define ABC_ALLOC(type, num)
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
struct Vec_Str_t_ Vec_Str_t
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
int Mio_GateReadPinNum(Mio_Gate_t *pGate)
Mio_Gate_t ** Mio_CollectRoots(Mio_Library_t *pLib, int nInputs, float tDelay, int fSkipInv, int *pnGates, int fVerbose)
char * Mio_LibraryReadName(Mio_Library_t *pLib)
DECLARATIONS ///.
void Mio_DeriveTruthTable(Mio_Gate_t *pGate, unsigned uTruthsIn[][2], int nSigns, int nInputs, unsigned uTruthRes[])
double Mio_GateReadArea(Mio_Gate_t *pGate)
struct Mio_LibraryStruct_t_ Mio_Library_t
void Mio_DeriveGateDelays(Mio_Gate_t *pGate, float **ptPinDelays, int nPins, int nInputs, float tDelayZero, float *ptDelaysRes, float *ptPinDelayMax)
char * Mio_GateReadName(Mio_Gate_t *pGate)
struct Mio_GateStruct_t_ Mio_Gate_t
double Mio_GateReadDelayMax(Mio_Gate_t *pGate)
int st__ptrhash(const char *, int)
int st__ptrcmp(const char *, const char *)
int stmm_find_or_add(stmm_table *table, char *key, char ***slot)
void stmm_free_table(stmm_table *table)
int stmm_find(stmm_table *table, char *key, char ***slot)
stmm_table * stmm_init_table(stmm_compare_func_type compare, stmm_hash_func_type hash)
#define stmm_foreach_item(table, gen, key, value)
Super_Gate_t * pFanins[6]
Super_Gate_t * pInputs[10]
Extra_MmFlex_t * pMemFlex
void Super_WriteLibraryGate(FILE *pFile, Super_Man_t *pMan, Super_Gate_t *pGate, int Num)
char * Super_WriteLibraryGateName(Super_Gate_t *pGate)
void Super_WriteLibraryTreeFile_rec(FILE *pFile, Super_Man_t *pMan, Super_Gate_t *pSuper, int *pCounter)
struct Super_GateStruct_t_ Super_Gate_t
#define Super_ManForEachGate(GateArray, Limit, Index, Gate)
void Super_WriteLibraryGateName_rec(Super_Gate_t *pGate, char *pBuffer)
void Super_WriteLibraryTreeStr_rec(Vec_Str_t *vStr, Super_Man_t *pMan, Super_Gate_t *pSuper, int *pCounter)
void Super_WriteLibraryTree(Super_Man_t *pMan)
struct Super_ManStruct_t_ Super_Man_t
void Super_Precompute(Mio_Library_t *pLibGen, int nVarsMax, int nLevels, int nGatesMax, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fVerbose, char *pFileName)
FUNCTION DEFINITIONS ///.
void Super_WriteFileHeaderStr(Super_Man_t *pMan, Vec_Str_t *vStr)
Vec_Str_t * Super_PrecomputeStr(Mio_Library_t *pLibGen, int nVarsMax, int nLevels, int nGatesMax, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fVerbose)