132 pPinNew->
pNext = NULL;
153 if ( pPin1 == NULL || pPin2 == NULL )
195 char * pPhaseNames[10] = {
"UNKNOWN",
"INV",
"NONINV" };
197 fprintf( pFile,
"PIN * " );
199 fprintf( pFile,
"\n PIN %*s ", NameLen, pPin->
pName );
200 fprintf( pFile,
"%7s ", pPhaseNames[pPin->
Phase] );
201 fprintf( pFile,
"%3d ", (
int)pPin->
dLoadInput );
202 fprintf( pFile,
"%3d ", (
int)pPin->
dLoadMax );
224 assert( NameLen+FormLen+2 < 5000 );
226 fprintf( pFile,
"GATE %-*s ", GateLen, pGate->
pName );
227 fprintf( pFile,
"%8.2f ", pGate->
dArea );
228 fprintf( pFile,
"%-*s ",
Abc_MinInt(NameLen+FormLen+2, 30), Buffer );
231 fprintf( pFile,
"%s", pGate->
pSop? pGate->
pSop :
"unspecified\n" );
232 if ( fAllPins && pGate->
pPins )
237 fprintf( pFile,
"\n" );
255 int i, GateLen = 0, NameLen = 0, FormLen = 0;
265 fprintf( pFile,
"# The genlib library \"%s\" written by ABC on %s\n\n", pLib->
pName,
Extra_TimeStamp() );
266 for ( i = 0; i < pLib->
nGates; i++ )
283 if ( (*ppG1)->dDelayMax < (*ppG2)->dDelayMax )
285 if ( (*ppG1)->dDelayMax > (*ppG2)->dDelayMax )
306 int i, nGates, iGate;
314 if ( pGate->
nInputs > nInputs )
316 if ( tDelay > 0.0 && pGate->
dDelayMax > (
double)tDelay )
327 for ( i = 0; i < iGate; i++ )
328 if ( ppGates[i]->uTruth == pGate->
uTruth )
330 if ( ppGates[i]->dArea > pGate->
dArea ||
338 ppGates[ iGate++ ] = pGate;
340 printf(
"Selected gate %3d: %-20s A = %7.2f D = %7.2f %3s = %-s\n",
346 qsort( (
void *)ppGates, iGate,
sizeof(
Mio_Gate_t *),
369 if ( (pG1)->nFanins < (pG2)->nFanins )
371 if ( (pG1)->nFanins > (pG2)->nFanins )
373 if ( (pG1)->Area < (pG2)->Area )
375 if ( (pG1)->Area > (pG2)->Area )
400 for ( k = 0, pPin = pGate->
pPins; pPin; pPin = pPin->
pNext, k++ )
408 int i, nGates, iCell = 4;
418 for ( i = 0; i < iCell; i++ )
419 if ( ppCells[i].pName && ppCells[i].uTruth == pGate->
uTruth )
421 if ( ppCells[i].Area > pGate->
dArea ||
446 if ( ppCells[0].pName == NULL )
447 { printf(
"Error: Cannot find constant 0 gate in the library.\n" );
return NULL; }
448 if ( ppCells[1].pName == NULL )
449 { printf(
"Error: Cannot find constant 1 gate in the library.\n" );
return NULL; }
450 if ( ppCells[2].pName == NULL )
451 { printf(
"Error: Cannot find buffer gate in the library.\n" );
return NULL; }
452 if ( ppCells[3].pName == NULL )
453 { printf(
"Error: Cannot find inverter gate in the library.\n" );
return NULL; }
457 qsort( (
void *)(ppCells + 4), iCell - 4,
sizeof(
Mio_Cell_t),
462 for ( i = 0; i < iCell; i++ )
463 ppCells[i].Id = ppCells[i].pName ? i : -1;
469 int * pCounts =
ABC_CALLOC(
int, nGates + 4 );
474 for ( i = 0; i < iCell; i++ )
475 if ( ppCells[i].pName && ppCells[i].uTruth == pGate->
uTruth )
482 for ( i = 0; i < iCell; i++ )
485 printf(
"%4d : ", i );
486 if ( pCell->
pName == NULL )
489 printf(
"%-20s In = %d N = %3d A = %7.2f D = %7.2f\n",
516 static unsigned uTruths6[6][2] = {
517 { 0xAAAAAAAA, 0xAAAAAAAA },
518 { 0xCCCCCCCC, 0xCCCCCCCC },
519 { 0xF0F0F0F0, 0xF0F0F0F0 },
520 { 0xFF00FF00, 0xFF00FF00 },
521 { 0xFFFF0000, 0xFFFF0000 },
522 { 0x00000000, 0xFFFFFFFF }
546 void Mio_DeriveTruthTable_rec(
DdNode * bFunc,
unsigned uTruthsIn[][2],
unsigned uTruthRes[] )
548 unsigned uTruthsCof0[2];
549 unsigned uTruthsCof1[2];
554 Mio_DeriveTruthTable_rec(
Cudd_Not(bFunc), uTruthsIn, uTruthRes );
555 uTruthRes[0] = ~uTruthRes[0];
556 uTruthRes[1] = ~uTruthRes[1];
569 Mio_DeriveTruthTable_rec(
cuddE(bFunc), uTruthsIn, uTruthsCof0 );
570 Mio_DeriveTruthTable_rec(
cuddT(bFunc), uTruthsIn, uTruthsCof1 );
573 uTruthRes[0] = (uTruthsCof0[0] & ~uTruthsIn[bFunc->
index][0]) |
574 (uTruthsCof1[0] & uTruthsIn[bFunc->
index][0]);
575 uTruthRes[1] = (uTruthsCof0[1] & ~uTruthsIn[bFunc->
index][1]) |
576 (uTruthsCof1[1] & uTruthsIn[bFunc->
index][1]);
592 Mio_DeriveTruthTable_rec( pGate->bFunc, uTruthsIn, uTruthRes );
610 word uRes, uFanins[6];
613 for ( i = 0; i < nSigns; i++ )
614 uFanins[i] = (((
word)uTruthsIn[i][1]) << 32) | (
word)uTruthsIn[i][0];
616 uTruthRes[0] = uRes & 0xFFFFFFFF;
617 uTruthRes[1] = uRes >> 32;
634 for ( pCur = pSop; *pCur !=
'\n'; pCur++ )
637 return pCur - pSop - 2;
654 unsigned uSignCube[2];
663 assert( nFanins == nInputs );
671 for ( pCube = pGate->
pSop; *pCube; pCube += (nFanins) + 3 )
675 for ( i = 0; i < nFanins; i++ )
677 if ( pCube[i] ==
'0' )
678 uSignCube[0] &= ~uTruthsIn[i][0];
679 else if ( pCube[i] ==
'1' )
680 uSignCube[0] &= uTruthsIn[i][0];
684 uTruthRes[0] &=
MIO_MASK(1<<nInputs);
690 for ( pCube = pGate->
pSop; *pCube; pCube += (nFanins) + 3 )
694 for ( i = 0; i < nFanins; i++ )
696 if ( pCube[i] ==
'0' )
698 uSignCube[0] &= ~uTruthsIn[i][0];
699 uSignCube[1] &= ~uTruthsIn[i][1];
701 else if ( pCube[i] ==
'1' )
703 uSignCube[0] &= uTruthsIn[i][0];
704 uSignCube[1] &= uTruthsIn[i][1];
707 uTruthRes[0] |= uSignCube[0];
708 uTruthRes[1] |= uSignCube[1];
726 float ** ptPinDelays,
int nPins,
int nInputs,
float tDelayZero,
727 float * ptDelaysRes,
float * ptPinDelayMax )
730 float Delay, DelayMax;
734 for ( i = 0; i < nInputs; i++ )
735 ptDelaysRes[i] = tDelayZero;
738 for ( i = 0; i < nInputs; i++ )
740 for ( k = 0, pPin = pGate->
pPins; pPin; pPin = pPin->
pNext, k++ )
742 if ( ptPinDelays[k][i] < 0 )
745 if ( ptDelaysRes[i] < Delay )
746 ptDelaysRes[i] = Delay;
753 if ( DelayMax < ptDelaysRes[i] )
754 DelayMax = ptDelaysRes[i];
756 *ptPinDelayMax = DelayMax;
781 for ( i = 0; i < nInputs; i++ )
917 int nMints = (1 << nVars);
918 word tCur, tTemp1, tTemp2;
921 for ( i = 0; i < 2; i++ )
923 tCur = i ? ~uTruth : uTruth;
925 for ( p = 0; p < nPerms; p++ )
928 for ( c = 0; c < nMints; c++ )
942 int nMints = (1 << nVars);
943 char * pChar, * pChar2;
945 for ( i = 0; i < nVars; i++ )
946 Line[0][i] =
'A' + nVars - 1 - i;
947 Line[0][nVars] =
'+';
948 Line[0][nVars+1] = 0;
949 for ( i = 0; i < 2; i++ )
951 Line[n][nVars] = i ?
'-' :
'+';
952 for ( p = 0; p < nPerms; p++ )
954 for ( c = 0; c < nMints; c++ )
956 strcpy( Line[n+1], Line[n] ); n++;
957 pChar = &Line[n][pComp[c]];
958 if ( *pChar >=
'A' && *pChar <=
'Z' )
960 else if ( *pChar >=
'a' && *pChar <=
'z' )
963 pChar = &Line[n][pPerm[
p]];
968 assert( n == 2*nPerms*nMints );
970 for ( i = 0; i < 2; i++ )
971 for ( p = 0; p < nPerms; p++ )
972 for ( c = 0; c < nMints; c++ )
973 printf(
"%8d : %d %3d %2d : %s\n", n, i, p, c, Line[n]), n++;
986 int nGates, i, nClasses = 0,
nTotal;
989 for ( i = 2; i <= 6; i++ )
991 for ( i = 2; i <= 6; i++ )
999 for ( i = 0; i < nGates; i++ )
1002 assert( pSizes[i] > 1 && pSizes[i] <= 6 );
1005 Nf_ManPrepareGate( pSizes[i], pTruths[i], pComp[pSizes[i]], pPerm[pSizes[i]], vResult );
1010 printf(
"%6d : ", i );
1013 printf(
"Inputs = %2d ", pSizes[i] );
1014 printf(
"Total = %6d ",
nTotal );
1026 for ( i = 2; i <= 6; i++ )
1028 for ( i = 2; i <= 6; i++ )
1031 printf(
"Classes = %d. ", nClasses );
1041 printf(
"Standard cell library is not available.\n" );
static ABC_NAMESPACE_IMPL_START int pTruths[13719]
DECLARATIONS ///.
void Mio_WritePin(FILE *pFile, Mio_Pin_t *pPin, int NameLen, int fAllPins)
void st__free_table(st__table *table)
int Mio_DelayCompare(Mio_Gate_t **ppG1, Mio_Gate_t **ppG2)
void Mio_PinDelete(Mio_Pin_t *pPin)
ABC_DLL void * Abc_FrameReadLibGen()
Mio_Cell_t * Mio_CollectRootsNewDefault(int nInputs, int *pnGates, int fVerbose)
word Mio_DeriveTruthTable6(Mio_Gate_t *pGate)
void Mio_GateDelete(Mio_Gate_t *pGate)
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
#define Mio_GateForEachPin(Gate, Pin)
Mio_Cell_t * Mio_CollectRootsNew(Mio_Library_t *pLib, int nInputs, int *pnGates, int fVerbose)
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
void Mio_WriteGate(FILE *pFile, Mio_Gate_t *pGate, int GateLen, int NameLen, int FormLen, int fPrintSops, int fAllPins)
void Mio_DeriveTruthTable(Mio_Gate_t *pGate, unsigned uTruthsIn[][2], int nSigns, int nInputs, unsigned uTruthRes[])
void Nf_ManPrepareLibrary(Mio_Library_t *pLib)
void Mio_LibraryTransferDelays(Mio_Library_t *pLibD, Mio_Library_t *pLibS)
Mio_Gate_t * Mio_GateCreatePseudo(int nInputs)
void Mio_WriteLibrary(FILE *pFile, Mio_Library_t *pLib, int fPrintSops)
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
#define ABC_ALLOC(type, num)
int Mio_CheckGates(Mio_Library_t *pLib)
int Mio_SopGetVarNum(char *pSop)
word Mio_GateReadTruth(Mio_Gate_t *pGate)
static abctime Abc_Clock()
int Mio_DelayCompareNew(Mio_Cell_t *pG1, Mio_Cell_t *pG2)
static int Abc_MaxInt(int a, int b)
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
static int Vec_WrdSize(Vec_Wrd_t *p)
ABC_DLL void Abc_FrameUnmapAllNetworks(Abc_Frame_t *p)
for(p=first;p->value< newval;p=p->next)
#define ABC_SWAP(Type, a, b)
static void Vec_WrdUniqify(Vec_Wrd_t *p)
char * Mio_GateReadForm(Mio_Gate_t *pGate)
int Mio_GateReadPinNum(Mio_Gate_t *pGate)
static void Abc_PrintTime(int level, const char *pStr, abctime time)
void Mio_DeriveGateDelays(Mio_Gate_t *pGate, float **ptPinDelays, int nPins, int nInputs, float tDelayZero, float *ptDelaysRes, float *ptPinDelayMax)
static word Exp_Truth6(int nVars, Vec_Int_t *p, word *puFanins)
static int Abc_MinInt(int a, int b)
static word Abc_Tt6SwapAdjacent(word Truth, int iVar)
void Mio_LibraryMultiArea(Mio_Library_t *pLib, double Multi)
#define Cudd_IsComplement(node)
static void Vec_WrdClear(Vec_Wrd_t *p)
void Nf_ManPreparePrint(int nVars, int *pComp, int *pPerm, char Line[2 *720 *64][8])
void Mio_DeriveTruthTable2(Mio_Gate_t *pGate, unsigned uTruthsIn[][2], int nTruths, int nInputs, unsigned uTruthRes[])
static void Vec_StrFree(Vec_Str_t *p)
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
static void Vec_WrdFree(Vec_Wrd_t *p)
void * Abc_FrameGetGlobalFrame()
STRUCTURE DEFINITIONS ///.
static void Vec_IntFreeP(Vec_Int_t **p)
static word Abc_Tt6Flip(word Truth, int iVar)
void Nf_ManPrepareLibraryTest2()
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
static Vec_Wrd_t * Vec_WrdAlloc(int nCap)
FUNCTION DEFINITIONS ///.
#define ABC_NAMESPACE_IMPL_START
void Nf_ManPrepareGate(int nVars, word uTruth, int *pComp, int *pPerm, Vec_Wrd_t *vResult)
#define ABC_CONST(number)
PARAMETERS ///.
#define Mio_GateForEachPinSafe(Gate, Pin, Pin2)
Mio_Gate_t ** Mio_CollectRoots(Mio_Library_t *pLib, int nInputs, float tDelay, int fSkipInv, int *pnGates, int fVerbose)
void Mio_CollectCopy(Mio_Cell_t *pCell, Mio_Gate_t *pGate)
#define ABC_CALLOC(type, num)
int Mio_CheckPins(Mio_Pin_t *pPin1, Mio_Pin_t *pPin2)
Mio_Pin_t * Mio_PinDup(Mio_Pin_t *pPin)
void Mio_LibraryMultiDelay(Mio_Library_t *pLib, double Multi)
Mio_Gate_t ** ppGatesName
ABC_NAMESPACE_IMPL_START void Mio_LibraryDelete(Mio_Library_t *pLib)
DECLARATIONS ///.
void Mio_LibraryShiftDelay(Mio_Library_t *pLib, double Shift)
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
#define Mio_LibraryForEachGateSafe(Lib, Gate, Gate2)
char * Abc_UtilStrsav(char *s)
char * Mio_GateReadName(Mio_Gate_t *pGate)
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
int Mio_LibraryReadGateNum(Mio_Library_t *pLib)
int nTotal
DECLARATIONS ///.