ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
mioUtils.c File Reference
#include <math.h>
#include "mioInt.h"
#include "base/main/main.h"
#include "exp.h"
#include "misc/util/utilTruth.h"
#include "opt/dau/dau.h"
#include "misc/util/utilNam.h"
#include "map/scl/sclLib.h"
#include "map/scl/sclCon.h"
Include dependency graph for mioUtils.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Mio_LibraryDelete (Mio_Library_t *pLib)
 DECLARATIONS ///.
 
void Mio_GateDelete (Mio_Gate_t *pGate)
 
void Mio_PinDelete (Mio_Pin_t *pPin)
 
Mio_Pin_tMio_PinDup (Mio_Pin_t *pPin)
 
int Mio_CheckPins (Mio_Pin_t *pPin1, Mio_Pin_t *pPin2)
 
int Mio_CheckGates (Mio_Library_t *pLib)
 
void Mio_WritePin (FILE *pFile, Mio_Pin_t *pPin, int NameLen, int fAllPins)
 
void Mio_WriteGate (FILE *pFile, Mio_Gate_t *pGate, int GateLen, int NameLen, int FormLen, int fPrintSops, int fAllPins)
 
void Mio_WriteLibrary (FILE *pFile, Mio_Library_t *pLib, int fPrintSops, int fShort, int fSelected)
 
void Exp_PrintNodeVerilog (FILE *pFile, int nVars, Vec_Int_t *p, Vec_Ptr_t *vNames, int Node, int fCompl)
 
void Exp_PrintLitVerilog (FILE *pFile, int nVars, Vec_Int_t *p, Vec_Ptr_t *vNames, int Lit)
 
void Exp_PrintVerilog (FILE *pFile, int nVars, Vec_Int_t *p, Vec_Ptr_t *vNames)
 
void Mio_WriteGateVerilog (FILE *pFile, Mio_Gate_t *pGate, Vec_Ptr_t *vNames)
 
void Mio_WriteLibraryVerilog (FILE *pFile, Mio_Library_t *pLib, int fPrintSops, int fShort, int fSelected)
 
int Mio_DelayCompare (Mio_Gate_t **ppG1, Mio_Gate_t **ppG2)
 
int Mio_AreaCompare (Mio_Cell_t *pG1, Mio_Cell_t *pG2)
 
int Mio_AreaCompare2 (Mio_Cell2_t *pG1, Mio_Cell2_t *pG2)
 
Mio_Gate_t ** Mio_CollectRoots (Mio_Library_t *pLib, int nInputs, float tDelay, int fSkipInv, int *pnGates, int fVerbose)
 
Mio_Cell_tMio_CollectRootsNew (Mio_Library_t *pLib, int nInputs, int *pnGates, int fVerbose)
 
Mio_Cell_tMio_CollectRootsNewDefault (int nInputs, int *pnGates, int fVerbose)
 
Mio_Cell2_tMio_CollectRootsNew2 (Mio_Library_t *pLib, int nInputs, int *pnGates, int fVerbose)
 
Mio_Cell2_tMio_CollectRootsNewDefault2 (int nInputs, int *pnGates, int fVerbose)
 
int Mio_CollectRootsNewDefault3 (int nInputs, Vec_Ptr_t **pvNames, Vec_Wrd_t **pvTruths)
 
word Mio_DeriveTruthTable6 (Mio_Gate_t *pGate)
 
void Mio_DeriveTruthTable (Mio_Gate_t *pGate, unsigned uTruthsIn[][2], int nSigns, int nInputs, unsigned uTruthRes[])
 
int Mio_SopGetVarNum (char *pSop)
 
void Mio_DeriveTruthTable2 (Mio_Gate_t *pGate, unsigned uTruthsIn[][2], int nTruths, int nInputs, unsigned uTruthRes[])
 
void Mio_DeriveGateDelays (Mio_Gate_t *pGate, float **ptPinDelays, int nPins, int nInputs, float tDelayZero, float *ptDelaysRes, float *ptPinDelayMax)
 
Mio_Gate_tMio_GateCreatePseudo (int nInputs)
 
void Mio_LibraryShiftDelay (Mio_Library_t *pLib, double Shift)
 
void Mio_LibraryMultiArea (Mio_Library_t *pLib, double Multi)
 
void Mio_LibraryMultiDelay (Mio_Library_t *pLib, double Multi)
 
void Mio_LibraryTransferDelays (Mio_Library_t *pLibD, Mio_Library_t *pLibS)
 
void Nf_ManPrepareGate (int nVars, word uTruth, int *pComp, int *pPerm, Vec_Wrd_t *vResult)
 
void Nf_ManPreparePrint (int nVars, int *pComp, int *pPerm, char Line[2 *720 *64][8])
 
void Nf_ManPrepareLibrary (Mio_Library_t *pLib)
 
void Nf_ManPrepareLibraryTest2 ()
 
void Mio_LibraryTransferCellIds ()
 
void Mio_LibraryReadProfile (FILE *pFile, Mio_Library_t *pLib)
 
void Mio_LibraryWriteProfile (FILE *pFile, Mio_Library_t *pLib)
 
int Mio_LibraryHasProfile (Mio_Library_t *pLib)
 
void Mio_LibraryTransferProfile (Mio_Library_t *pLibDst, Mio_Library_t *pLibSrc)
 
void Mio_LibraryTransferProfile2 (Mio_Library_t *pLibDst, Mio_Library_t *pLibSrc)
 
void Mio_LibraryCleanProfile2 (Mio_Library_t *pLib)
 
void Mio_LibraryHashGates (Mio_Library_t *pLib)
 
void Mio_LibraryShortFormula (Mio_Gate_t *pCell, char *pForm, char *pBuffer)
 
void Mio_LibraryShortNames (Mio_Library_t *pLib)
 
void Mio_LibraryMatchesStop (Mio_Library_t *pLib)
 
void Mio_LibraryMatchesStart (Mio_Library_t *pLib, int fPinFilter, int fPinPerm, int fPinQuick)
 
void Mio_LibraryMatchesFetch (Mio_Library_t *pLib, Vec_Mem_t **pvTtMem, Vec_Wec_t **pvTt2Match, Mio_Cell2_t **ppCells, int *pnCells, int fPinFilter, int fPinPerm, int fPinQuick)
 
void Mio_LibraryMatches2Stop (Mio_Library_t *pLib)
 
void Mio_LibraryMatches2Start (Mio_Library_t *pLib)
 
void Mio_LibraryMatches2Fetch (Mio_Library_t *pLib, Vec_Ptr_t **pvNames, Vec_Wrd_t **pvTruths, Vec_Int_t **pvTt2Match4, Vec_Int_t **pvConfigs, Vec_Mem_t *pvTtMem2[3], Vec_Int_t *pvTt2Match2[3])
 

Function Documentation

◆ Exp_PrintLitVerilog()

void Exp_PrintLitVerilog ( FILE * pFile,
int nVars,
Vec_Int_t * p,
Vec_Ptr_t * vNames,
int Lit )

Definition at line 321 of file mioUtils.c.

322{
323 if ( Lit == EXP_CONST0 )
324 fprintf( pFile, "1\'b0" );
325 else if ( Lit == EXP_CONST1 )
326 fprintf( pFile, "1\'b1" );
327 else if ( Lit < 2 * nVars )
328 fprintf( pFile, "%s%s", (Lit&1) ? "~" : "", (char *)Vec_PtrEntry(vNames, Lit/2) );
329 else
330 Exp_PrintNodeVerilog( pFile, nVars, p, vNames, Lit/2-nVars, Lit&1 );
331}
Cube * p
Definition exorList.c:222
#define EXP_CONST1
Definition exp.h:44
#define EXP_CONST0
INCLUDES ///.
Definition exp.h:43
void Exp_PrintNodeVerilog(FILE *pFile, int nVars, Vec_Int_t *p, Vec_Ptr_t *vNames, int Node, int fCompl)
Definition mioUtils.c:306
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Exp_PrintNodeVerilog()

void Exp_PrintNodeVerilog ( FILE * pFile,
int nVars,
Vec_Int_t * p,
Vec_Ptr_t * vNames,
int Node,
int fCompl )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 306 of file mioUtils.c.

307{
308 extern void Exp_PrintLitVerilog( FILE * pFile, int nVars, Vec_Int_t * p, Vec_Ptr_t * vNames, int Lit );
309 if ( Vec_IntEntry(p, 2*Node+1) >= 2*nVars )
310 fprintf( pFile, "(" );
311 Exp_PrintLitVerilog( pFile, nVars, p, vNames, Vec_IntEntry(p, 2*Node+1) ^ fCompl );
312 if ( Vec_IntEntry(p, 2*Node+1) >= 2*nVars )
313 fprintf( pFile, ")" );
314 fprintf( pFile, " %c ", fCompl ? '|' : '&' );
315 if ( Vec_IntEntry(p, 2*Node+0) >= 2*nVars )
316 fprintf( pFile, "(" );
317 Exp_PrintLitVerilog( pFile, nVars, p, vNames, Vec_IntEntry(p, 2*Node+0) ^ fCompl );
318 if ( Vec_IntEntry(p, 2*Node+0) >= 2*nVars )
319 fprintf( pFile, ")" );
320}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Exp_PrintLitVerilog(FILE *pFile, int nVars, Vec_Int_t *p, Vec_Ptr_t *vNames, int Lit)
Definition mioUtils.c:321
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Exp_PrintVerilog()

void Exp_PrintVerilog ( FILE * pFile,
int nVars,
Vec_Int_t * p,
Vec_Ptr_t * vNames )

Definition at line 332 of file mioUtils.c.

333{
334 Exp_PrintLitVerilog( pFile, nVars, p, vNames, Vec_IntEntryLast(p) );
335}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_AreaCompare()

int Mio_AreaCompare ( Mio_Cell_t * pG1,
Mio_Cell_t * pG2 )

Definition at line 416 of file mioUtils.c.

417{
418 int Comp;
419 float Eps = (float)0.0094636;
420 if ( pG1->nFanins < pG2->nFanins )
421 return -1;
422 if ( pG1->nFanins > pG2->nFanins )
423 return 1;
424 if ( pG1->Area < pG2->Area - Eps )
425 return -1;
426 if ( pG1->Area > pG2->Area + Eps )
427 return 1;
428 // compare names
429 Comp = strcmp( pG1->pName, pG2->pName );
430 if ( Comp < 0 )
431 return -1;
432 if ( Comp > 0 )
433 return 1;
434 assert( 0 );
435 return 0;
436}
unsigned nFanins
Definition mio.h:51
float Area
Definition mio.h:52
char * pName
Definition mio.h:49
#define assert(ex)
Definition util_old.h:213
int strcmp()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_AreaCompare2()

int Mio_AreaCompare2 ( Mio_Cell2_t * pG1,
Mio_Cell2_t * pG2 )

Definition at line 437 of file mioUtils.c.

438{
439 int Comp;
440 if ( pG1->nFanins < pG2->nFanins )
441 return -1;
442 if ( pG1->nFanins > pG2->nFanins )
443 return 1;
444 if ( pG1->AreaW < pG2->AreaW )
445 return -1;
446 if ( pG1->AreaW > pG2->AreaW )
447 return 1;
448 // compare names
449 Comp = strcmp( pG1->pName, pG2->pName );
450 if ( Comp < 0 )
451 return -1;
452 if ( Comp > 0 )
453 return 1;
454 assert( 0 );
455 return 0;
456}
word AreaW
Definition mio.h:66
char * pName
Definition mio.h:60
unsigned nFanins
Definition mio.h:64
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_CheckGates()

int Mio_CheckGates ( Mio_Library_t * pLib)

Definition at line 175 of file mioUtils.c.

176{
177 Mio_Gate_t * pGate;
178 Mio_Pin_t * pPin0 = NULL, * pPin = NULL;
179 Mio_LibraryForEachGate( pLib, pGate )
180 Mio_GateForEachPin( pGate, pPin )
181 if ( Mio_CheckPins( pPin0, pPin ) )
182 pPin0 = pPin;
183 else
184 return 0;
185 return 1;
186}
int Mio_CheckPins(Mio_Pin_t *pPin1, Mio_Pin_t *pPin2)
Definition mioUtils.c:157
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
Definition mio.h:81
struct Mio_PinStruct_t_ Mio_Pin_t
Definition mio.h:44
#define Mio_GateForEachPin(Gate, Pin)
Definition mio.h:92
struct Mio_GateStruct_t_ Mio_Gate_t
Definition mio.h:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_CheckPins()

int Mio_CheckPins ( Mio_Pin_t * pPin1,
Mio_Pin_t * pPin2 )

Function*************************************************************

Synopsis [Check if pin characteristics are the same.]

Description []

SideEffects []

SeeAlso []

Definition at line 157 of file mioUtils.c.

158{
159 if ( pPin1 == NULL || pPin2 == NULL )
160 return 1;
161 if ( pPin1->dLoadInput != pPin2->dLoadInput )
162 return 0;
163 if ( pPin1->dLoadMax != pPin2->dLoadMax )
164 return 0;
165 if ( pPin1->dDelayBlockRise != pPin2->dDelayBlockRise )
166 return 0;
167 if ( pPin1->dDelayFanoutRise != pPin2->dDelayFanoutRise )
168 return 0;
169 if ( pPin1->dDelayBlockFall != pPin2->dDelayBlockFall )
170 return 0;
171 if ( pPin1->dDelayFanoutFall != pPin2->dDelayFanoutFall )
172 return 0;
173 return 1;
174}
double dDelayBlockFall
Definition mioInt.h:131
double dDelayFanoutRise
Definition mioInt.h:130
double dLoadMax
Definition mioInt.h:128
double dDelayBlockRise
Definition mioInt.h:129
double dLoadInput
Definition mioInt.h:127
double dDelayFanoutFall
Definition mioInt.h:132
Here is the caller graph for this function:

◆ Mio_CollectRoots()

Mio_Gate_t ** Mio_CollectRoots ( Mio_Library_t * pLib,
int nInputs,
float tDelay,
int fSkipInv,
int * pnGates,
int fVerbose )

Definition at line 515 of file mioUtils.c.

516{
517 Mio_Gate_t * pGate;
518 Mio_Gate_t ** ppGates;
519 int i, nGates, iGate, fProfile;
520 nGates = Mio_LibraryReadGateNum( pLib );
521 ppGates = ABC_ALLOC( Mio_Gate_t *, nGates );
522 iGate = 0;
523 // check if profile is entered
524 fProfile = Mio_LibraryHasProfile( pLib );
525 if ( fProfile )
526 printf( "Mio_CollectRoots(): Using gate profile to select gates for mapping.\n" );
527 // for each functionality, select gate with the smallest area
528 // if equal areas, select gate with lexicographically smaller name
529 Mio_LibraryForEachGate( pLib, pGate )
530 {
531 if ( pGate->nInputs > nInputs )
532 continue;
533 if ( fProfile && Mio_GateReadProfile(pGate) == 0 && pGate->nInputs > 1 )
534 continue;
535 if ( tDelay > 0.0 && pGate->dDelayMax > (double)tDelay )
536 continue;
537 if ( pGate->uTruth == 0 || pGate->uTruth == ~(word)0 )
538 continue;
539 if ( pGate->uTruth == ABC_CONST(0xAAAAAAAAAAAAAAAA) )
540 continue;
541 if ( pGate->uTruth == ~ABC_CONST(0xAAAAAAAAAAAAAAAA) && fSkipInv )
542 continue;
543 if ( pGate->pTwin ) // skip multi-output gates for now
544 continue;
545 // check if the gate with this functionality already exists
546 for ( i = 0; i < iGate; i++ )
547 if ( ppGates[i]->uTruth == pGate->uTruth )
548 {
549 if ( Mio_CompareTwoGates(ppGates[i], pGate) )
550 ppGates[i] = pGate;
551 break;
552 }
553 if ( i < iGate )
554 continue;
555 assert( iGate < nGates );
556 ppGates[ iGate++ ] = pGate;
557 if ( fVerbose )
558 printf( "Selected gate %3d: %-20s A = %7.2f D = %7.2f %3s = %-s\n",
559 iGate+1, pGate->pName, pGate->dArea, pGate->dDelayMax, pGate->pOutName, pGate->pForm );
560 }
561 // sort by delay
562 if ( iGate > 0 )
563 {
564 qsort( (void *)ppGates, (size_t)iGate, sizeof(Mio_Gate_t *),
565 (int (*)(const void *, const void *)) Mio_DelayCompare );
566 assert( Mio_DelayCompare( ppGates, ppGates + iGate - 1 ) <= 0 );
567 }
568 if ( pnGates )
569 *pnGates = iGate;
570 return ppGates;
571}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_CONST(number)
PARAMETERS ///.
Definition abc_global.h:240
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
int Mio_LibraryHasProfile(Mio_Library_t *pLib)
Definition mioUtils.c:1555
int Mio_DelayCompare(Mio_Gate_t **ppG1, Mio_Gate_t **ppG2)
Definition mioUtils.c:399
int Mio_GateReadProfile(Mio_Gate_t *pGate)
Definition mioApi.c:185
int Mio_LibraryReadGateNum(Mio_Library_t *pLib)
Definition mioApi.c:45
char * pOutName
Definition mioInt.h:103
double dDelayMax
Definition mioInt.h:115
Mio_Gate_t * pTwin
Definition mioInt.h:108
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_CollectRootsNew()

Mio_Cell_t * Mio_CollectRootsNew ( Mio_Library_t * pLib,
int nInputs,
int * pnGates,
int fVerbose )

Definition at line 623 of file mioUtils.c.

624{
625 Mio_Gate_t * pGate;
626 Mio_Cell_t * ppCells;
627 int i, nGates, iCell = 4;
628 nGates = Mio_LibraryReadGateNum( pLib );
629 ppCells = ABC_CALLOC( Mio_Cell_t, nGates + 4 );
630 // for each functionality, select gate with the smallest area
631 // if equal areas, select gate with smaller average pin delay
632 // if these are also equal, select lexicographically smaller name
633 Mio_LibraryForEachGate( pLib, pGate )
634 {
635 if ( pGate->nInputs > nInputs || pGate->pTwin ) // skip large and multi-output
636 continue;
637 // check if the gate with this functionality already exists
638 for ( i = 0; i < iCell; i++ )
639 if ( ppCells[i].pName && ppCells[i].uTruth == pGate->uTruth )
640 {
641 if ( Mio_CompareTwo( ppCells + i, pGate ) )
642 Mio_CollectCopy( ppCells + i, pGate );
643 break;
644 }
645 if ( i < iCell )
646 continue;
647 if ( pGate->uTruth == 0 || pGate->uTruth == ~(word)0 )
648 {
649 int Idx = (int)(pGate->uTruth == ~(word)0);
650 assert( pGate->nInputs == 0 );
651 Mio_CollectCopy( ppCells + Idx, pGate );
652 continue;
653 }
654 if ( pGate->uTruth == ABC_CONST(0xAAAAAAAAAAAAAAAA) || pGate->uTruth == ~ABC_CONST(0xAAAAAAAAAAAAAAAA) )
655 {
656 int Idx = 2 + (int)(pGate->uTruth == ~ABC_CONST(0xAAAAAAAAAAAAAAAA));
657 assert( pGate->nInputs == 1 );
658 Mio_CollectCopy( ppCells + Idx, pGate );
659 continue;
660 }
661 Mio_CollectCopy( ppCells + iCell++, pGate );
662 }
663 if ( ppCells[0].pName == NULL )
664 { printf( "Error: Cannot find constant 0 gate in the library.\n" ); return NULL; }
665 if ( ppCells[1].pName == NULL )
666 { printf( "Error: Cannot find constant 1 gate in the library.\n" ); return NULL; }
667 if ( ppCells[2].pName == NULL )
668 { printf( "Error: Cannot find buffer gate in the library.\n" ); return NULL; }
669 if ( ppCells[3].pName == NULL )
670 { printf( "Error: Cannot find inverter gate in the library.\n" ); return NULL; }
671 // sort by delay
672 if ( iCell > 5 )
673 {
674 qsort( (void *)(ppCells + 4), (size_t)(iCell - 4), sizeof(Mio_Cell_t),
675 (int (*)(const void *, const void *)) Mio_AreaCompare );
676 assert( Mio_AreaCompare( ppCells + 4, ppCells + iCell - 1 ) <= 0 );
677 }
678 // assign IDs
679 for ( i = 0; i < iCell; i++ )
680 ppCells[i].Id = ppCells[i].pName ? i : -1;
681
682 // report
683 if ( fVerbose )
684 {
685 // count gates
686 int * pCounts = ABC_CALLOC( int, nGates + 4 );
687 Mio_LibraryForEachGate( pLib, pGate )
688 {
689 if ( pGate->nInputs > nInputs || pGate->pTwin ) // skip large and multi-output
690 continue;
691 for ( i = 0; i < iCell; i++ )
692 if ( ppCells[i].pName && ppCells[i].uTruth == pGate->uTruth )
693 {
694 pCounts[i]++;
695 break;
696 }
697 assert( i < iCell );
698 }
699 for ( i = 0; i < iCell; i++ )
700 {
701 Mio_Cell_t * pCell = ppCells + i;
702 printf( "%4d : ", i );
703 if ( pCell->pName == NULL )
704 printf( "None\n" );
705 else
706 printf( "%-20s In = %d N = %3d A = %12.6f D = %12.6f\n",
707 pCell->pName, pCell->nFanins, pCounts[i], pCell->Area, Mio_CellDelayAve(pCell) );
708 }
709 ABC_FREE( pCounts );
710 }
711 if ( pnGates )
712 *pnGates = iCell;
713 return ppCells;
714}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
int Mio_AreaCompare(Mio_Cell_t *pG1, Mio_Cell_t *pG2)
Definition mioUtils.c:416
struct Mio_Cell_t_ Mio_Cell_t
Definition mio.h:46
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_CollectRootsNew2()

Mio_Cell2_t * Mio_CollectRootsNew2 ( Mio_Library_t * pLib,
int nInputs,
int * pnGates,
int fVerbose )

Definition at line 774 of file mioUtils.c.

775{
776 Mio_Gate_t * pGate0;
777 Mio_Cell2_t * ppCells0, * ppCells, * pCell;
778 int i, nGates, iCell0 = 0, iCell = 4;
779 // create space for new cells
780 nGates = Mio_LibraryReadGateNum( pLib );
781 ppCells = ABC_CALLOC( Mio_Cell2_t, nGates + 4 );
782 // copy all gates first
783 ppCells0 = ABC_CALLOC( Mio_Cell2_t, nGates );
784 Mio_LibraryForEachGate( pLib, pGate0 )
785 if ( !(pGate0->nInputs > nInputs || pGate0->pTwin) ) // skip large and multi-output
786 Mio_CollectCopy2( ppCells0 + iCell0++, pGate0 );
787 assert( iCell0 <= nGates );
788 // for each functionality, select gate with the smallest area
789 // if equal areas, select gate with smaller average pin delay
790 // if these are also equal, select lexicographically smaller name
791 for ( pCell = ppCells0; pCell < ppCells0 + iCell0; pCell++ )
792 {
793 // check if the gate with this functionality already exists
794 for ( i = 0; i < iCell; i++ )
795 if ( ppCells[i].pName && ppCells[i].uTruth == pCell->uTruth )
796 {
797 if ( Mio_CompareTwo2( ppCells + i, pCell ) )
798 ppCells[i] = *pCell;
799 break;
800 }
801 if ( i < iCell )
802 continue;
803 if ( pCell->uTruth == 0 || pCell->uTruth == ~(word)0 )
804 {
805 int Idx = (int)(pCell->uTruth == ~(word)0);
806 assert( pCell->nFanins == 0 );
807 ppCells[Idx] = *pCell;
808 continue;
809 }
810 if ( pCell->uTruth == ABC_CONST(0xAAAAAAAAAAAAAAAA) || pCell->uTruth == ~ABC_CONST(0xAAAAAAAAAAAAAAAA) )
811 {
812 int Idx = 2 + (int)(pCell->uTruth == ~ABC_CONST(0xAAAAAAAAAAAAAAAA));
813 assert( pCell->nFanins == 1 );
814 ppCells[Idx] = *pCell;
815 continue;
816 }
817 ppCells[iCell++] = *pCell;
818 }
819 ABC_FREE( ppCells0 );
820 if ( ppCells[0].pName == NULL )
821 { printf( "Error: Cannot find constant 0 gate in the library.\n" ); return NULL; }
822 if ( ppCells[1].pName == NULL )
823 { printf( "Error: Cannot find constant 1 gate in the library.\n" ); return NULL; }
824 if ( ppCells[2].pName == NULL )
825 { printf( "Error: Cannot find buffer gate in the library.\n" ); return NULL; }
826 if ( ppCells[3].pName == NULL )
827 { printf( "Error: Cannot find inverter gate in the library.\n" ); return NULL; }
828 // sort by delay
829 if ( iCell > 5 )
830 {
831 qsort( (void *)(ppCells + 4), (size_t)(iCell - 4), sizeof(Mio_Cell2_t),
832 (int (*)(const void *, const void *)) Mio_AreaCompare2 );
833 assert( Mio_AreaCompare2( ppCells + 4, ppCells + iCell - 1 ) <= 0 );
834 }
835 // assign IDs
836 Mio_LibraryForEachGate( pLib, pGate0 )
837 Mio_GateSetCell( pGate0, -1 );
838 for ( i = 0; i < iCell; i++ )
839 {
840 ppCells[i].Id = ppCells[i].pName ? i : -1;
841 Mio_GateSetCell( (Mio_Gate_t *)ppCells[i].pMioGate, i );
842 }
843
844 // report
845 if ( fVerbose )
846 {
847 // count gates
848 int * pCounts = ABC_CALLOC( int, nGates + 4 );
849 Mio_LibraryForEachGate( pLib, pGate0 )
850 {
851 if ( pGate0->nInputs > nInputs || pGate0->pTwin ) // skip large and multi-output
852 continue;
853 for ( i = 0; i < iCell; i++ )
854 if ( ppCells[i].pName && ppCells[i].uTruth == pGate0->uTruth )
855 {
856 pCounts[i]++;
857 break;
858 }
859 assert( i < iCell );
860 }
861 for ( i = 0; i < iCell; i++ )
862 {
863 Mio_Cell2_t * pCell = ppCells + i;
864 printf( "%4d : ", i );
865 if ( pCell->pName == NULL )
866 printf( "None\n" );
867 else
868 printf( "%-20s In = %d N = %3d A = %12.6f D = %12.6f\n",
869 pCell->pName, pCell->nFanins, pCounts[i], pCell->AreaF, Scl_Int2Flt(pCell->iDelayAve) );
870 }
871 ABC_FREE( pCounts );
872 }
873 if ( pnGates )
874 *pnGates = iCell;
875 return ppCells;
876}
int Mio_AreaCompare2(Mio_Cell2_t *pG1, Mio_Cell2_t *pG2)
Definition mioUtils.c:437
struct Mio_Cell2_t_ Mio_Cell2_t
Definition mio.h:57
void Mio_GateSetCell(Mio_Gate_t *pGate, int Cell)
Definition mioApi.c:188
float AreaF
Definition mio.h:65
word uTruth
Definition mio.h:67
int iDelayAve
Definition mio.h:68
unsigned Id
Definition mio.h:62
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_CollectRootsNewDefault()

Mio_Cell_t * Mio_CollectRootsNewDefault ( int nInputs,
int * pnGates,
int fVerbose )

Definition at line 715 of file mioUtils.c.

716{
717 return Mio_CollectRootsNew( (Mio_Library_t *)Abc_FrameReadLibGen(), nInputs, pnGates, fVerbose );
718}
ABC_DLL void * Abc_FrameReadLibGen()
Definition mainFrame.c:59
Mio_Cell_t * Mio_CollectRootsNew(Mio_Library_t *pLib, int nInputs, int *pnGates, int fVerbose)
Definition mioUtils.c:623
struct Mio_LibraryStruct_t_ Mio_Library_t
Definition mio.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_CollectRootsNewDefault2()

Mio_Cell2_t * Mio_CollectRootsNewDefault2 ( int nInputs,
int * pnGates,
int fVerbose )

Definition at line 877 of file mioUtils.c.

878{
879 return Mio_CollectRootsNew2( (Mio_Library_t *)Abc_FrameReadLibGen(), nInputs, pnGates, fVerbose );
880}
Mio_Cell2_t * Mio_CollectRootsNew2(Mio_Library_t *pLib, int nInputs, int *pnGates, int fVerbose)
Definition mioUtils.c:774
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_CollectRootsNewDefault3()

int Mio_CollectRootsNewDefault3 ( int nInputs,
Vec_Ptr_t ** pvNames,
Vec_Wrd_t ** pvTruths )

Function*************************************************************

Synopsis [Derives the truth table of the gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 893 of file mioUtils.c.

894{
896 int i, iGate = 0, nGates = pLib ? Mio_LibraryReadGateNum( pLib ) : 0;
897 Mio_Gate_t * pGate0, ** ppGates; word * pTruth;
898 if ( pLib == NULL )
899 return 0;
900 ppGates = ABC_CALLOC( Mio_Gate_t *, nGates );
901 Mio_LibraryForEachGate( pLib, pGate0 )
902 ppGates[pGate0->Cell] = pGate0;
903 *pvNames = Vec_PtrAlloc( nGates );
904 *pvTruths = Vec_WrdStart( nGates * 4 );
905 for ( i = 0; i < nGates; i++ )
906 {
907 pGate0 = ppGates[i];
908 if ( pGate0->nInputs > nInputs || pGate0->pTwin ) // skip large and multi-output
909 continue;
910 Vec_PtrPush( *pvNames, pGate0->pName );
911 pTruth = Vec_WrdEntryP( *pvTruths, iGate++*4 );
912 if ( pGate0->nInputs <= 6 )
913 pTruth[0] = pTruth[1] = pTruth[2] = pTruth[3] = pGate0->uTruth;
914 else if ( pGate0->nInputs == 7 )
915 {
916 pTruth[0] = pTruth[2] = pGate0->pTruth[0];
917 pTruth[1] = pTruth[3] = pGate0->pTruth[1];
918 }
919 else if ( pGate0->nInputs == 8 )
920 memcpy( pTruth, pGate0->pTruth, (size_t)(4*sizeof(word)) );
921 }
922 assert( iGate == nGates );
923 assert( Vec_WrdEntry(*pvTruths, 0) == 0 );
924 assert( Vec_WrdEntry(*pvTruths, 4) == ~(word)0 );
925 assert( Vec_WrdEntry(*pvTruths, 8) == s_Truths6[0] );
926 assert( Vec_WrdEntry(*pvTruths, 12) == ~s_Truths6[0] );
927 ABC_FREE( ppGates );
928 return nGates;
929}
char * memcpy()
Here is the call graph for this function:

◆ Mio_DelayCompare()

int Mio_DelayCompare ( Mio_Gate_t ** ppG1,
Mio_Gate_t ** ppG2 )

Function*************************************************************

Synopsis [Compares the max delay of two gates.]

Description []

SideEffects []

SeeAlso []

Definition at line 399 of file mioUtils.c.

400{
401 int Comp;
402 float Eps = (float)0.0094636;
403 if ( (*ppG1)->dDelayMax < (*ppG2)->dDelayMax - Eps )
404 return -1;
405 if ( (*ppG1)->dDelayMax > (*ppG2)->dDelayMax + Eps )
406 return 1;
407 // compare names
408 Comp = strcmp( (*ppG1)->pName, (*ppG2)->pName );
409 if ( Comp < 0 )
410 return -1;
411 if ( Comp > 0 )
412 return 1;
413 assert( 0 );
414 return 0;
415}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_DeriveGateDelays()

void Mio_DeriveGateDelays ( Mio_Gate_t * pGate,
float ** ptPinDelays,
int nPins,
int nInputs,
float tDelayZero,
float * ptDelaysRes,
float * ptPinDelayMax )

Function*************************************************************

Synopsis [Derives the area and delay of the root of the gate.]

Description [Array of the resulting delays should be initialized to the (negative) SUPER_NO_VAR value.]

SideEffects []

SeeAlso []

Definition at line 1153 of file mioUtils.c.

1156{
1157 Mio_Pin_t * pPin;
1158 float Delay, DelayMax;
1159 int i, k;
1160 assert( pGate->nInputs == nPins );
1161 // set all the delays to the unused delay
1162 for ( i = 0; i < nInputs; i++ )
1163 ptDelaysRes[i] = tDelayZero;
1164 // compute the delays for each input and the max delay at the same time
1165 DelayMax = 0;
1166 for ( i = 0; i < nInputs; i++ )
1167 {
1168 for ( k = 0, pPin = pGate->pPins; pPin; pPin = pPin->pNext, k++ )
1169 {
1170 if ( ptPinDelays[k][i] < 0 )
1171 continue;
1172 Delay = ptPinDelays[k][i] + (float)pPin->dDelayBlockMax;
1173 if ( ptDelaysRes[i] < Delay )
1174 ptDelaysRes[i] = Delay;
1175 }
1176 if ( k != nPins )
1177 {
1178 printf ("DEBUG: problem gate is %s\n", Mio_GateReadName( pGate ));
1179 }
1180 assert( k == nPins );
1181 if ( DelayMax < ptDelaysRes[i] )
1182 DelayMax = ptDelaysRes[i];
1183 }
1184 *ptPinDelayMax = DelayMax;
1185}
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition mioApi.c:169
Mio_Pin_t * pPins
Definition mioInt.h:102
double dDelayBlockMax
Definition mioInt.h:133
Mio_Pin_t * pNext
Definition mioInt.h:134
Here is the call graph for this function:

◆ Mio_DeriveTruthTable()

void Mio_DeriveTruthTable ( Mio_Gate_t * pGate,
unsigned uTruthsIn[][2],
int nSigns,
int nInputs,
unsigned uTruthRes[] )

Function*************************************************************

Synopsis [Derives the truth table of the gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 1036 of file mioUtils.c.

1037{
1038 word uRes, uFanins[6];
1039 int i;
1040 assert( pGate->nInputs == nSigns );
1041 for ( i = 0; i < nSigns; i++ )
1042 uFanins[i] = (((word)uTruthsIn[i][1]) << 32) | (word)uTruthsIn[i][0];
1043 uRes = Exp_Truth6( nSigns, pGate->vExpr, (word *)uFanins );
1044 uTruthRes[0] = uRes & 0xFFFFFFFF;
1045 uTruthRes[1] = uRes >> 32;
1046}
Vec_Int_t * vExpr
Definition mioInt.h:117
Here is the caller graph for this function:

◆ Mio_DeriveTruthTable2()

void Mio_DeriveTruthTable2 ( Mio_Gate_t * pGate,
unsigned uTruthsIn[][2],
int nTruths,
int nInputs,
unsigned uTruthRes[] )

Function*************************************************************

Synopsis [Derives the truth table of the root of the gate.]

Description [Given the truth tables of the leaves of the gate, this procedure derives the truth table of the root.]

SideEffects []

SeeAlso []

Definition at line 1080 of file mioUtils.c.

1081{
1082 unsigned uSignCube[2];
1083 int i, nFanins;
1084 char * pCube;
1085
1086 // make sure that the number of input truth tables in equal to the number of gate inputs
1087 assert( pGate->nInputs == nTruths );
1088 assert( nInputs < 7 );
1089
1090 nFanins = Mio_SopGetVarNum( pGate->pSop );
1091 assert( nFanins == nInputs );
1092
1093 // clean the resulting truth table
1094 uTruthRes[0] = 0;
1095 uTruthRes[1] = 0;
1096 if ( nInputs < 6 )
1097 {
1098// Abc_SopForEachCube( pGate->pSop, nFanins, pCube )
1099 for ( pCube = pGate->pSop; *pCube; pCube += (nFanins) + 3 )
1100 {
1101 // add the clause
1102 uSignCube[0] = MIO_FULL;
1103 for ( i = 0; i < nFanins; i++ )
1104 {
1105 if ( pCube[i] == '0' )
1106 uSignCube[0] &= ~uTruthsIn[i][0];
1107 else if ( pCube[i] == '1' )
1108 uSignCube[0] &= uTruthsIn[i][0];
1109 }
1110 }
1111 if ( nInputs < 5 )
1112 uTruthRes[0] &= MIO_MASK(1<<nInputs);
1113 }
1114 else
1115 {
1116 // consider the case when two unsigneds should be used
1117// Abc_SopForEachCube( pGate->pSop, nFanins, pCube )
1118 for ( pCube = pGate->pSop; *pCube; pCube += (nFanins) + 3 )
1119 {
1120 uSignCube[0] = MIO_FULL;
1121 uSignCube[1] = MIO_FULL;
1122 for ( i = 0; i < nFanins; i++ )
1123 {
1124 if ( pCube[i] == '0' )
1125 {
1126 uSignCube[0] &= ~uTruthsIn[i][0];
1127 uSignCube[1] &= ~uTruthsIn[i][1];
1128 }
1129 else if ( pCube[i] == '1' )
1130 {
1131 uSignCube[0] &= uTruthsIn[i][0];
1132 uSignCube[1] &= uTruthsIn[i][1];
1133 }
1134 }
1135 uTruthRes[0] |= uSignCube[0];
1136 uTruthRes[1] |= uSignCube[1];
1137 }
1138 }
1139}
#define MIO_FULL
Definition mioInt.h:55
#define MIO_MASK(n)
Definition mioInt.h:54
int Mio_SopGetVarNum(char *pSop)
Definition mioUtils.c:1059
Here is the call graph for this function:

◆ Mio_DeriveTruthTable6()

word Mio_DeriveTruthTable6 ( Mio_Gate_t * pGate)

Function*************************************************************

Synopsis [Derives the truth table of the gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 942 of file mioUtils.c.

943{
944 static unsigned uTruths6[6][2] = {
945 { 0xAAAAAAAA, 0xAAAAAAAA },
946 { 0xCCCCCCCC, 0xCCCCCCCC },
947 { 0xF0F0F0F0, 0xF0F0F0F0 },
948 { 0xFF00FF00, 0xFF00FF00 },
949 { 0xFFFF0000, 0xFFFF0000 },
950 { 0x00000000, 0xFFFFFFFF }
951 };
952 union {
953 unsigned u[2];
954 word w;
955 } uTruthRes;
956 assert( pGate->nInputs <= 6 );
957 Mio_DeriveTruthTable( pGate, uTruths6, pGate->nInputs, 6, uTruthRes.u );
958 return uTruthRes.w;
959}
void Mio_DeriveTruthTable(Mio_Gate_t *pGate, unsigned uTruthsIn[][2], int nSigns, int nInputs, unsigned uTruthRes[])
Definition mioUtils.c:1036
Here is the call graph for this function:

◆ Mio_GateCreatePseudo()

Mio_Gate_t * Mio_GateCreatePseudo ( int nInputs)

Function*************************************************************

Synopsis [Creates a pseudo-gate.]

Description [The pseudo-gate is a N-input gate with all info set to 0.]

SideEffects []

SeeAlso []

Definition at line 1199 of file mioUtils.c.

1200{
1201 Mio_Gate_t * pGate;
1202 Mio_Pin_t * pPin;
1203 int i;
1204 // allocate the gate structure
1205 pGate = ABC_ALLOC( Mio_Gate_t, 1 );
1206 memset( pGate, 0, sizeof(Mio_Gate_t) );
1207 pGate->nInputs = nInputs;
1208 // create pins
1209 for ( i = 0; i < nInputs; i++ )
1210 {
1211 pPin = ABC_ALLOC( Mio_Pin_t, 1 );
1212 memset( pPin, 0, sizeof(Mio_Pin_t) );
1213 pPin->pNext = pGate->pPins;
1214 pGate->pPins = pPin;
1215 }
1216 return pGate;
1217}
char * memset()
Here is the call graph for this function:

◆ Mio_GateDelete()

void Mio_GateDelete ( Mio_Gate_t * pGate)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 87 of file mioUtils.c.

88{
89 Mio_Pin_t * pPin, * pPin2;
90 if ( pGate->nInputs > 6 )
91 ABC_FREE( pGate->pTruth );
92 Vec_IntFreeP( &pGate->vExpr );
93 ABC_FREE( pGate->pOutName );
94 ABC_FREE( pGate->pName );
95 ABC_FREE( pGate->pForm );
96// if ( pGate->bFunc )
97// Cudd_RecursiveDeref( pGate->pLib->dd, pGate->bFunc );
98 Mio_GateForEachPinSafe( pGate, pPin, pPin2 )
99 Mio_PinDelete( pPin );
100 ABC_FREE( pGate );
101}
void Mio_PinDelete(Mio_Pin_t *pPin)
Definition mioUtils.c:114
#define Mio_GateForEachPinSafe(Gate, Pin, Pin2)
Definition mio.h:96
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_LibraryCleanProfile2()

void Mio_LibraryCleanProfile2 ( Mio_Library_t * pLib)

Definition at line 1616 of file mioUtils.c.

1617{
1618 Mio_Gate_t * pGate;
1619 Mio_LibraryForEachGate( pLib, pGate )
1620 Mio_GateSetProfile2( pGate, 0 );
1621}
void Mio_GateSetProfile2(Mio_Gate_t *pGate, int Prof)
Definition mioApi.c:190
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_LibraryDelete()

ABC_NAMESPACE_IMPL_START void Mio_LibraryDelete ( Mio_Library_t * pLib)

DECLARATIONS ///.

CFile****************************************************************

FileName [mioUtils.c]

PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]

Synopsis [File reading/writing for technology mapping.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - September 8, 2003.]

Revision [

Id
mioUtils.c,v 1.6 2004/09/03 18:02:20 satrajit Exp

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 51 of file mioUtils.c.

52{
53 Mio_Gate_t * pGate, * pGate2;
54 if ( pLib == NULL )
55 return;
58 // free the bindings of nodes to gates from this library for all networks
60 // free the library
61 ABC_FREE( pLib->pName );
62 Mio_LibraryForEachGateSafe( pLib, pGate, pGate2 )
63 Mio_GateDelete( pGate );
64 Mem_FlexStop( pLib->pMmFlex, 0 );
65 Vec_StrFree( pLib->vCube );
66 if ( pLib->tName2Gate )
68// if ( pLib->dd )
69// Cudd_Quit( pLib->dd );
70 ABC_FREE( pLib->ppGates0 );
71 ABC_FREE( pLib->ppGatesName );
72 ABC_FREE( pLib->pFileName );
73 ABC_FREE( pLib );
74}
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
Definition mainFrame.c:643
ABC_DLL void Abc_FrameUnmapAllNetworks(Abc_Frame_t *p)
Definition mainFrame.c:577
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
Definition mem.c:359
void Mio_LibraryMatchesStop(Mio_Library_t *pLib)
Definition mioUtils.c:1759
void Mio_LibraryMatches2Stop(Mio_Library_t *pLib)
Definition mioUtils.c:1805
void Mio_GateDelete(Mio_Gate_t *pGate)
Definition mioUtils.c:87
#define Mio_LibraryForEachGateSafe(Lib, Gate, Gate2)
Definition mio.h:85
void st__free_table(st__table *table)
Definition st.c:81
Mio_Gate_t ** ppGates0
Definition mioInt.h:66
Mio_Gate_t ** ppGatesName
Definition mioInt.h:67
st__table * tName2Gate
Definition mioInt.h:77
Vec_Str_t * vCube
Definition mioInt.h:79
Mem_Flex_t * pMmFlex
Definition mioInt.h:78
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_LibraryHashGates()

void Mio_LibraryHashGates ( Mio_Library_t * pLib)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1634 of file mioUtils.c.

1635{
1636 Mio_Gate_t * pGate;
1637 Mio_LibraryForEachGate( pLib, pGate )
1638 if ( pGate->pTwin )
1639 {
1640 printf( "Gates with multiple outputs are not supported.\n" );
1641 return;
1642 }
1643 if ( pLib->tName2Gate )
1644 st__free_table( pLib->tName2Gate );
1646 Mio_LibraryForEachGate( pLib, pGate )
1647 st__insert( pLib->tName2Gate, pGate->pName, (char *)pGate );
1648}
int st__strhash(const char *string, int modulus)
Definition st.c:449
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition st.c:72
int st__insert(st__table *table, const char *key, char *value)
Definition st.c:171
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_LibraryHasProfile()

int Mio_LibraryHasProfile ( Mio_Library_t * pLib)

Definition at line 1555 of file mioUtils.c.

1556{
1557 Mio_Gate_t * pGate;
1558 Mio_LibraryForEachGate( pLib, pGate )
1559 if ( Mio_GateReadProfile(pGate) > 0 )
1560 return 1;
1561 return 0;
1562}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_LibraryMatches2Fetch()

void Mio_LibraryMatches2Fetch ( Mio_Library_t * pLib,
Vec_Ptr_t ** pvNames,
Vec_Wrd_t ** pvTruths,
Vec_Int_t ** pvTt2Match4,
Vec_Int_t ** pvConfigs,
Vec_Mem_t * pvTtMem2[3],
Vec_Int_t * pvTt2Match2[3] )

Definition at line 1830 of file mioUtils.c.

1831{
1832 int i;
1834 *pvNames = pLib->vNames;
1835 *pvTruths = pLib->vTruths;
1836 *pvTt2Match4 = pLib->vTt2Match4;
1837 *pvConfigs = pLib->vConfigs;
1838 for ( i = 0; i < 3; i++ )
1839 {
1840 pvTtMem2[i] = pLib->vTtMem2[i];
1841 pvTt2Match2[i] = pLib->vTt2Match2[i];
1842 }
1843}
void Mio_LibraryMatches2Start(Mio_Library_t *pLib)
Definition mioUtils.c:1821
Vec_Mem_t * vTtMem2[3]
Definition mioInt.h:92
Vec_Int_t * vConfigs
Definition mioInt.h:91
Vec_Int_t * vTt2Match4
Definition mioInt.h:90
Vec_Wrd_t * vTruths
Definition mioInt.h:89
Vec_Int_t * vTt2Match2[3]
Definition mioInt.h:93
Vec_Ptr_t * vNames
Definition mioInt.h:88
Here is the call graph for this function:

◆ Mio_LibraryMatches2Start()

void Mio_LibraryMatches2Start ( Mio_Library_t * pLib)

Definition at line 1821 of file mioUtils.c.

1822{
1823 extern int Gia_ManDeriveMatches( Vec_Ptr_t ** pvNames, Vec_Wrd_t ** pvTruths, Vec_Int_t ** pvTt2Match4, Vec_Int_t ** pvConfigs, Vec_Mem_t * pvTtMem2[3], Vec_Int_t * pvTt2Match2[3] );
1824 if ( pLib->vNames )
1825 return;
1826 if ( pLib->vTtMem )
1828 Gia_ManDeriveMatches( &pLib->vNames, &pLib->vTruths, &pLib->vTt2Match4, &pLib->vConfigs, pLib->vTtMem2, pLib->vTt2Match2 );
1829}
ABC_NAMESPACE_IMPL_START int Gia_ManDeriveMatches(Vec_Ptr_t **pvNames, Vec_Wrd_t **pvTruths, Vec_Int_t **pvTt2Match4, Vec_Int_t **pvConfigs, Vec_Mem_t *pvTtMem2[3], Vec_Int_t *pvTt2Match2[3])
DECLARATIONS ///.
Definition giaIiff.c:47
Vec_Mem_t * vTtMem
Definition mioInt.h:84
typedefABC_NAMESPACE_IMPL_START struct Vec_Mem_t_ Vec_Mem_t
DECLARATIONS ///.
Definition utilMem.c:35
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition vecWrd.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_LibraryMatches2Stop()

void Mio_LibraryMatches2Stop ( Mio_Library_t * pLib)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1805 of file mioUtils.c.

1806{
1807 int i;
1808 if ( !pLib->vNames )
1809 return;
1810 Vec_PtrFree( pLib->vNames );
1811 Vec_WrdFree( pLib->vTruths );
1812 Vec_IntFree( pLib->vTt2Match4 );
1813 Vec_IntFree( pLib->vConfigs );
1814 for ( i = 0; i < 3; i++ )
1815 {
1816 Vec_MemHashFree( pLib->vTtMem2[i] );
1817 Vec_MemFree( pLib->vTtMem2[i] );
1818 Vec_IntFree( pLib->vTt2Match2[i] );
1819 }
1820}
Here is the caller graph for this function:

◆ Mio_LibraryMatchesFetch()

void Mio_LibraryMatchesFetch ( Mio_Library_t * pLib,
Vec_Mem_t ** pvTtMem,
Vec_Wec_t ** pvTt2Match,
Mio_Cell2_t ** ppCells,
int * pnCells,
int fPinFilter,
int fPinPerm,
int fPinQuick )

Definition at line 1785 of file mioUtils.c.

1786{
1787 Mio_LibraryMatchesStart( pLib, fPinFilter, fPinPerm, fPinQuick );
1788 *pvTtMem = pLib->vTtMem; // truth tables
1789 *pvTt2Match = pLib->vTt2Match; // matches for truth tables
1790 *ppCells = pLib->pCells; // library gates
1791 *pnCells = pLib->nCells; // library gate count
1792}
void Mio_LibraryMatchesStart(Mio_Library_t *pLib, int fPinFilter, int fPinPerm, int fPinQuick)
Definition mioUtils.c:1768
Mio_Cell2_t * pCells
Definition mioInt.h:86
Vec_Wec_t * vTt2Match
Definition mioInt.h:85
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_LibraryMatchesStart()

void Mio_LibraryMatchesStart ( Mio_Library_t * pLib,
int fPinFilter,
int fPinPerm,
int fPinQuick )

Definition at line 1768 of file mioUtils.c.

1769{
1770 extern Mio_Cell2_t * Nf_StoDeriveMatches( Vec_Mem_t * vTtMem, Vec_Wec_t * vTt2Match, int * pnCells, int fPinFilter, int fPinPerm, int fPinQuick );
1771 if ( pLib->vTtMem && pLib->fPinFilter == fPinFilter && pLib->fPinPerm == fPinPerm && pLib->fPinQuick == fPinQuick )
1772 return;
1773 if ( pLib->vTtMem )
1774 Mio_LibraryMatchesStop( pLib );
1775 pLib->fPinFilter = fPinFilter; // pin filtering
1776 pLib->fPinPerm = fPinPerm; // pin permutation
1777 pLib->fPinQuick = fPinQuick; // pin permutation
1778 pLib->vTtMem = Vec_MemAllocForTT( 6, 0 );
1779 pLib->vTt2Match = Vec_WecAlloc( 1000 );
1780 Vec_WecPushLevel( pLib->vTt2Match );
1781 Vec_WecPushLevel( pLib->vTt2Match );
1782 assert( Vec_WecSize(pLib->vTt2Match) == Vec_MemEntryNum(pLib->vTtMem) );
1783 pLib->pCells = Nf_StoDeriveMatches( pLib->vTtMem, pLib->vTt2Match, &pLib->nCells, fPinFilter, fPinPerm, fPinQuick );
1784}
Mio_Cell2_t * Nf_StoDeriveMatches(Vec_Mem_t *vTtMem, Vec_Wec_t *vTt2Match, int *pnCells, int fPinFilter, int fPinPerm, int fPinQuick)
Definition giaNf.c:288
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_LibraryMatchesStop()

void Mio_LibraryMatchesStop ( Mio_Library_t * pLib)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1759 of file mioUtils.c.

1760{
1761 if ( !pLib->vTtMem )
1762 return;
1763 Vec_WecFree( pLib->vTt2Match );
1764 Vec_MemHashFree( pLib->vTtMem );
1765 Vec_MemFree( pLib->vTtMem );
1766 ABC_FREE( pLib->pCells );
1767}
Here is the caller graph for this function:

◆ Mio_LibraryMultiArea()

void Mio_LibraryMultiArea ( Mio_Library_t * pLib,
double Multi )

Function*************************************************************

Synopsis [Multiply areas/delays by values proportional to fanin count.]

Description []

SideEffects []

SeeAlso []

Definition at line 1257 of file mioUtils.c.

1258{
1259 Mio_Gate_t * pGate;
1260 Mio_LibraryForEachGate( pLib, pGate )
1261 {
1262 if ( pGate->nInputs < 2 )
1263 continue;
1264// printf( "Before %8.3f ", pGate->dArea );
1265 pGate->dArea *= pow( pGate->nInputs, Multi );
1266// printf( "After %8.3f Inputs = %d. Factor = %8.3f\n", pGate->dArea, pGate->nInputs, pow( pGate->nInputs, Multi ) );
1267 }
1268}
Here is the caller graph for this function:

◆ Mio_LibraryMultiDelay()

void Mio_LibraryMultiDelay ( Mio_Library_t * pLib,
double Multi )

Definition at line 1269 of file mioUtils.c.

1270{
1271 Mio_Gate_t * pGate;
1272 Mio_Pin_t * pPin;
1273 Mio_LibraryForEachGate( pLib, pGate )
1274 {
1275 if ( pGate->nInputs < 2 )
1276 continue;
1277// printf( "Before %8.3f ", pGate->dDelayMax );
1278 pGate->dDelayMax *= pow( pGate->nInputs, Multi );
1279// printf( "After %8.3f Inputs = %d. Factor = %8.3f\n", pGate->dDelayMax, pGate->nInputs, pow( pGate->nInputs, Multi ) );
1280 Mio_GateForEachPin( pGate, pPin )
1281 {
1282 pPin->dDelayBlockRise *= pow( pGate->nInputs, Multi );
1283 pPin->dDelayBlockFall *= pow( pGate->nInputs, Multi );
1284 pPin->dDelayBlockMax *= pow( pGate->nInputs, Multi );
1285 }
1286 }
1287}
Here is the caller graph for this function:

◆ Mio_LibraryReadProfile()

void Mio_LibraryReadProfile ( FILE * pFile,
Mio_Library_t * pLib )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1523 of file mioUtils.c.

1524{
1525 Mio_Gate_t * pGate;
1526 char pBuffer[1000];
1527 while ( fgets( pBuffer, 1000, pFile ) != NULL )
1528 {
1529 char * pToken = strtok( pBuffer, " \t\n" );
1530 if ( pToken == NULL )
1531 continue;
1532 if ( pToken[0] == '#' )
1533 continue;
1534 // read gate
1535 pGate = Mio_LibraryReadGateByName( pLib, pToken, NULL );
1536 if ( pGate == NULL )
1537 {
1538 printf( "Cannot find gate \"%s\" in library \"%s\".\n", pToken, Mio_LibraryReadName(pLib) );
1539 continue;
1540 }
1541 // read profile
1542 pToken = strtok( NULL, " \t\n" );
1543 Mio_GateSetProfile( pGate, atoi(pToken) );
1544 }
1545}
void Mio_GateSetProfile(Mio_Gate_t *pGate, int Prof)
Definition mioApi.c:189
char * Mio_LibraryReadName(Mio_Library_t *pLib)
DECLARATIONS ///.
Definition mioApi.c:43
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
Definition mioApi.c:105
char * strtok()
Here is the call graph for this function:

◆ Mio_LibraryShiftDelay()

void Mio_LibraryShiftDelay ( Mio_Library_t * pLib,
double Shift )

Function*************************************************************

Synopsis [Adds constant value to all delay values.]

Description [The pseudo-gate is a N-input gate with all info set to 0.]

SideEffects []

SeeAlso []

Definition at line 1230 of file mioUtils.c.

1231{
1232 Mio_Gate_t * pGate;
1233 Mio_Pin_t * pPin;
1234 Mio_LibraryForEachGate( pLib, pGate )
1235 {
1236 pGate->dDelayMax += Shift;
1237 Mio_GateForEachPin( pGate, pPin )
1238 {
1239 pPin->dDelayBlockRise += Shift;
1240 pPin->dDelayBlockFall += Shift;
1241 pPin->dDelayBlockMax += Shift;
1242 }
1243 }
1244}

◆ Mio_LibraryShortFormula()

void Mio_LibraryShortFormula ( Mio_Gate_t * pCell,
char * pForm,
char * pBuffer )

Definition at line 1680 of file mioUtils.c.

1681{
1682 Mio_Pin_t * pPin;
1683 char * pTemp, * pLimit; int i;
1684 if ( !strncmp(pForm, "CONST", 5) )
1685 {
1686 sprintf( pBuffer, "%s", pForm );
1687 return;
1688 }
1689 for ( pTemp = pForm; *pTemp; )
1690 {
1691 if ( !Abc_SclIsChar(*pTemp) )
1692 {
1693 *pBuffer++ = *pTemp++;
1694 continue;
1695 }
1696 pLimit = Abc_SclFindLimit( pTemp );
1697 i = 0;
1698 Mio_GateForEachPin( pCell, pPin )
1699 {
1700 if ( Abc_SclAreEqual( pPin->pName, pTemp, pLimit ) )
1701 {
1702 *pBuffer++ = 'a' + i;
1703 break;
1704 }
1705 i++;
1706 }
1707 pTemp = pLimit;
1708 }
1709 *pBuffer++ = 0;
1710}
int strncmp()
char * sprintf()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_LibraryShortNames()

void Mio_LibraryShortNames ( Mio_Library_t * pLib)

Definition at line 1711 of file mioUtils.c.

1712{
1713 char Buffer[10000];
1714 Mio_Gate_t * pGate; Mio_Pin_t * pPin;
1715 int c = 0, i; unsigned char nDigits = (unsigned char)Abc_Base10Log( Mio_LibraryReadGateNum(pLib) );
1716 // itereate through classes
1717 Mio_LibraryForEachGate( pLib, pGate )
1718 {
1719 ABC_FREE( pGate->pName );
1720 sprintf( Buffer, "g%0*d", nDigits, ++c );
1721 pGate->pName = Abc_UtilStrsav( Buffer );
1722 // update formula
1723 Mio_LibraryShortFormula( pGate, pGate->pForm, Buffer );
1724 ABC_FREE( pGate->pForm );
1725 pGate->pForm = Abc_UtilStrsav( Buffer );
1726 // pin names
1727 i = 0;
1728 Mio_GateForEachPin( pGate, pPin )
1729 {
1730 ABC_FREE( pPin->pName );
1731 sprintf( Buffer, "%c", 'a'+i );
1732 pPin->pName = Abc_UtilStrsav( Buffer );
1733 i++;
1734 }
1735 // output pin
1736 ABC_FREE( pGate->pOutName );
1737 sprintf( Buffer, "z" );
1738 pGate->pOutName = Abc_UtilStrsav( Buffer );
1739 }
1740 Mio_LibraryHashGates( pLib );
1741 // update library name
1742 printf( "Renaming library \"%s\" into \"%s%d\".\n", pLib->pName, "lib", Mio_LibraryReadGateNum(pLib) );
1743 ABC_FREE( pLib->pName );
1744 sprintf( Buffer, "lib%d", Mio_LibraryReadGateNum(pLib) );
1745 pLib->pName = Abc_UtilStrsav( Buffer );
1746}
void Mio_LibraryShortFormula(Mio_Gate_t *pCell, char *pForm, char *pBuffer)
Definition mioUtils.c:1680
void Mio_LibraryHashGates(Mio_Library_t *pLib)
Definition mioUtils.c:1634
Here is the call graph for this function:

◆ Mio_LibraryTransferCellIds()

void Mio_LibraryTransferCellIds ( )

Function*************************************************************

Synopsis [Install library.]

Description []

SideEffects []

SeeAlso []

Definition at line 1484 of file mioUtils.c.

1485{
1486 Mio_Gate_t * pGate;
1488 SC_Lib * pScl = (SC_Lib *)Abc_FrameReadLibScl();
1489 int CellId;
1490 if ( pScl == NULL )
1491 {
1492 printf( "SC library cannot be found.\n" );
1493 return;
1494 }
1495 if ( pLib == NULL )
1496 {
1497 printf( "Genlib library cannot be found.\n" );
1498 return;
1499 }
1500 Mio_LibraryForEachGate( pLib, pGate )
1501 {
1502 if ( Mio_GateReadPinNum(pGate) == 0 )
1503 continue;
1504 CellId = Abc_SclCellFind( pScl, Mio_GateReadName(pGate) );
1505 if ( CellId < 0 )
1506 printf( "Cannot find cell ID of gate %s.\n", Mio_GateReadName(pGate) );
1507 else
1508 Mio_GateSetCell( pGate, CellId );
1509 }
1510}
ABC_DLL void * Abc_FrameReadLibScl()
Definition mainFrame.c:62
int Mio_GateReadPinNum(Mio_Gate_t *pGate)
Definition mioApi.c:177
struct SC_Lib_ SC_Lib
Definition sclLib.h:128
int Abc_SclCellFind(SC_Lib *p, char *pName)
Definition sclLibUtil.c:81
Here is the call graph for this function:

◆ Mio_LibraryTransferDelays()

void Mio_LibraryTransferDelays ( Mio_Library_t * pLibD,
Mio_Library_t * pLibS )

Function*************************************************************

Synopsis [Transfers delays from the second to the first.]

Description []

SideEffects []

SeeAlso []

Definition at line 1300 of file mioUtils.c.

1301{
1302 Mio_Gate_t * pGateD, * pGateS;
1303 Mio_Pin_t * pPinD, * pPinS;
1304 Mio_LibraryForEachGate( pLibS, pGateS )
1305 {
1306 Mio_LibraryForEachGate( pLibD, pGateD )
1307 {
1308 if ( pGateD->uTruth != pGateS->uTruth )
1309 continue;
1310 pPinS = Mio_GateReadPins( pGateS );
1311 Mio_GateForEachPin( pGateD, pPinD )
1312 {
1313 if (pPinS)
1314 {
1315 pPinD->dDelayBlockRise = pPinS->dDelayBlockRise;
1316 pPinD->dDelayBlockFall = pPinS->dDelayBlockFall;
1317 pPinD->dDelayBlockMax = pPinS->dDelayBlockMax;
1318 pPinS = Mio_PinReadNext(pPinS);
1319 }
1320 else
1321 {
1322 pPinD->dDelayBlockRise = 0;
1323 pPinD->dDelayBlockFall = 0;
1324 pPinD->dDelayBlockMax = 0;
1325 }
1326 }
1327 }
1328 }
1329}
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
Definition mioApi.c:173
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
Definition mioApi.c:217
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_LibraryTransferProfile()

void Mio_LibraryTransferProfile ( Mio_Library_t * pLibDst,
Mio_Library_t * pLibSrc )

Definition at line 1565 of file mioUtils.c.

1566{
1567 Mio_Gate_t * pGateSrc, * pGateDst;
1568 Mio_LibraryForEachGate( pLibDst, pGateDst )
1569 Mio_GateSetProfile( pGateDst, 0 );
1570 Mio_LibraryForEachGate( pLibSrc, pGateSrc )
1571 if ( Mio_GateReadProfile(pGateSrc) > 0 )
1572 {
1573 // find gate by name
1574 pGateDst = Mio_LibraryReadGateByName( pLibDst, Mio_GateReadName(pGateSrc), NULL );
1575 if ( pGateDst == NULL )
1576 {
1577 // find gate by function
1578 Mio_LibraryForEachGate( pLibDst, pGateDst )
1579 if ( pGateDst->uTruth == pGateSrc->uTruth )
1580 break;
1581 if ( pGateDst == NULL )
1582 {
1583 printf( "Cannot find gate \"%s\" in library \"%s\".\n", Mio_GateReadName(pGateSrc), Mio_LibraryReadName(pLibDst) );
1584 continue;
1585 }
1586 }
1587 Mio_GateAddToProfile( pGateDst, Mio_GateReadProfile(pGateSrc) );
1588 }
1589}
void Mio_GateAddToProfile(Mio_Gate_t *pGate, int Prof)
Definition mioApi.c:193
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_LibraryTransferProfile2()

void Mio_LibraryTransferProfile2 ( Mio_Library_t * pLibDst,
Mio_Library_t * pLibSrc )

Definition at line 1590 of file mioUtils.c.

1591{
1592 Mio_Gate_t * pGateSrc, * pGateDst;
1593 Mio_LibraryForEachGate( pLibDst, pGateDst )
1594 Mio_GateSetProfile2( pGateDst, 0 );
1595 Mio_LibraryForEachGate( pLibSrc, pGateSrc )
1596 if ( Mio_GateReadProfile2(pGateSrc) > 0 )
1597 {
1598 // find gate by name
1599 pGateDst = Mio_LibraryReadGateByName( pLibDst, Mio_GateReadName(pGateSrc), NULL );
1600 if ( pGateDst == NULL )
1601 {
1602 // find gate by function
1603 Mio_LibraryForEachGate( pLibDst, pGateDst )
1604 if ( pGateDst->uTruth == pGateSrc->uTruth )
1605 break;
1606 if ( pGateDst == NULL )
1607 {
1608 printf( "Cannot find gate \"%s\" in library \"%s\".\n", Mio_GateReadName(pGateSrc), Mio_LibraryReadName(pLibDst) );
1609 continue;
1610 }
1611 }
1612 Mio_GateAddToProfile2( pGateDst, Mio_GateReadProfile2(pGateSrc) );
1613 }
1614}
void Mio_GateAddToProfile2(Mio_Gate_t *pGate, int Prof)
Definition mioApi.c:194
int Mio_GateReadProfile2(Mio_Gate_t *pGate)
Definition mioApi.c:186
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_LibraryWriteProfile()

void Mio_LibraryWriteProfile ( FILE * pFile,
Mio_Library_t * pLib )

Definition at line 1547 of file mioUtils.c.

1548{
1549 Mio_Gate_t * pGate;
1550 Mio_LibraryForEachGate( pLib, pGate )
1551 if ( Mio_GateReadProfile(pGate) > 0 )
1552 fprintf( pFile, "%-24s %6d\n", Mio_GateReadName(pGate), Mio_GateReadProfile(pGate) );
1553}
Here is the call graph for this function:

◆ Mio_PinDelete()

void Mio_PinDelete ( Mio_Pin_t * pPin)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 114 of file mioUtils.c.

115{
116 ABC_FREE( pPin->pName );
117 ABC_FREE( pPin );
118}
Here is the caller graph for this function:

◆ Mio_PinDup()

Mio_Pin_t * Mio_PinDup ( Mio_Pin_t * pPin)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 131 of file mioUtils.c.

132{
133 Mio_Pin_t * pPinNew;
134
135 pPinNew = ABC_ALLOC( Mio_Pin_t, 1 );
136 *pPinNew = *pPin;
137 pPinNew->pName = (pPinNew->pName ? Abc_UtilStrsav(pPinNew->pName) : NULL);
138 pPinNew->pNext = NULL;
139
140 return pPinNew;
141}
Here is the caller graph for this function:

◆ Mio_SopGetVarNum()

int Mio_SopGetVarNum ( char * pSop)

Function*************************************************************

Synopsis [Reads the number of variables in the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 1059 of file mioUtils.c.

1060{
1061 char * pCur;
1062 for ( pCur = pSop; *pCur != '\n'; pCur++ )
1063 if ( *pCur == 0 )
1064 return -1;
1065 return pCur - pSop - 2;
1066}
Here is the caller graph for this function:

◆ Mio_WriteGate()

void Mio_WriteGate ( FILE * pFile,
Mio_Gate_t * pGate,
int GateLen,
int NameLen,
int FormLen,
int fPrintSops,
int fAllPins )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 226 of file mioUtils.c.

227{
228 //Vec_Int_t * vCover = Vec_IntAlloc( 1 << 10 ); int nLits;
229 char Buffer[5000];
230 Mio_Pin_t * pPin;
231 assert( NameLen+FormLen+2 < 5000 );
232 sprintf( Buffer, "%s=%s;", pGate->pOutName, pGate->pForm );
233 fprintf( pFile, "GATE %-*s ", GateLen, pGate->pName );
234 fprintf( pFile, "%8.2f ", pGate->dArea );
235 fprintf( pFile, "%-*s ", Abc_MinInt(NameLen+FormLen+2, 60), Buffer );
236 // print the pins
237 if ( fPrintSops )
238 fprintf( pFile, "%s", pGate->pSop? pGate->pSop : "unspecified\n" );
239 if ( fAllPins && pGate->pPins ) // equal pins
240 Mio_WritePin( pFile, pGate->pPins, NameLen, 1 );
241 else // different pins
242 Mio_GateForEachPin( pGate, pPin )
243 Mio_WritePin( pFile, pPin, NameLen, 0 );
244 //nLits = 2*Kit_TruthLitNum((unsigned*)&pGate->uTruth, Mio_GateReadPinNum(pGate), vCover);
245 //if ( nLits != Mio_GateReadArea(pGate) )
246 // printf( " # %d ", nLits );
247 fprintf( pFile, "\n" );
248 //Vec_IntFree( vCover );
249}
void Mio_WritePin(FILE *pFile, Mio_Pin_t *pPin, int NameLen, int fAllPins)
Definition mioUtils.c:199
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_WriteGateVerilog()

void Mio_WriteGateVerilog ( FILE * pFile,
Mio_Gate_t * pGate,
Vec_Ptr_t * vNames )

Definition at line 336 of file mioUtils.c.

337{
338 char * pName; int i;
339 fprintf( pFile, "module %s ( ", pGate->pName );
340 fprintf( pFile, "%s", pGate->pOutName );
341 Vec_PtrForEachEntry( char *, vNames, pName, i )
342 fprintf( pFile, ", %s", pName );
343 fprintf( pFile, " );\n" );
344 fprintf( pFile, " output %s;\n", pGate->pOutName );
345 if ( Vec_PtrSize(vNames) > 0 )
346 {
347 fprintf( pFile, " input %s", (char *)Vec_PtrEntry(vNames, 0) );
348 Vec_PtrForEachEntryStart( char *, vNames, pName, i, 1 )
349 fprintf( pFile, ", %s", pName );
350 fprintf( pFile, ";\n" );
351 }
352 fprintf( pFile, " assign %s = ", pGate->pOutName );
353 Exp_PrintVerilog( pFile, Vec_PtrSize(vNames), pGate->vExpr, vNames );
354 fprintf( pFile, ";\n" );
355 fprintf( pFile, "endmodule\n\n" );
356}
void Exp_PrintVerilog(FILE *pFile, int nVars, Vec_Int_t *p, Vec_Ptr_t *vNames)
Definition mioUtils.c:332
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mio_WriteLibrary()

void Mio_WriteLibrary ( FILE * pFile,
Mio_Library_t * pLib,
int fPrintSops,
int fShort,
int fSelected )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 262 of file mioUtils.c.

263{
264 Mio_Gate_t * pGate;
265 Mio_Pin_t * pPin;
266 Vec_Ptr_t * vGates = Vec_PtrAlloc( 1000 );
267 int i, nCells, GateLen = 0, NameLen = 0, FormLen = 0;
268 int fAllPins = fShort || Mio_CheckGates( pLib );
269 if ( fSelected )
270 {
271 Mio_Cell2_t * pCells = Mio_CollectRootsNewDefault2( 6, &nCells, 0 );
272 for ( i = 0; i < nCells; i++ )
273 Vec_PtrPush( vGates, pCells[i].pMioGate );
274 ABC_FREE( pCells );
275 }
276 else
277 {
278 for ( i = 0; i < pLib->nGates; i++ )
279 Vec_PtrPush( vGates, pLib->ppGates0[i] );
280 }
281 Vec_PtrForEachEntry( Mio_Gate_t *, vGates, pGate, i )
282 {
283 GateLen = Abc_MaxInt( GateLen, strlen(pGate->pName) );
284 NameLen = Abc_MaxInt( NameLen, strlen(pGate->pOutName) );
285 FormLen = Abc_MaxInt( FormLen, strlen(pGate->pForm) );
286 Mio_GateForEachPin( pGate, pPin )
287 NameLen = Abc_MaxInt( NameLen, strlen(pPin->pName) );
288 }
289 fprintf( pFile, "# The genlib library \"%s\" with %d gates written by ABC on %s\n", pLib->pName, Vec_PtrSize(vGates), Extra_TimeStamp() );
290 Vec_PtrForEachEntry( Mio_Gate_t *, vGates, pGate, i )
291 Mio_WriteGate( pFile, pGate, GateLen, NameLen, FormLen, fPrintSops, fAllPins );
292 Vec_PtrFree( vGates );
293}
char * Extra_TimeStamp()
void Mio_WriteGate(FILE *pFile, Mio_Gate_t *pGate, int GateLen, int NameLen, int FormLen, int fPrintSops, int fAllPins)
Definition mioUtils.c:226
Mio_Cell2_t * Mio_CollectRootsNewDefault2(int nInputs, int *pnGates, int fVerbose)
Definition mioUtils.c:877
int Mio_CheckGates(Mio_Library_t *pLib)
Definition mioUtils.c:175
int strlen()
Here is the call graph for this function:

◆ Mio_WriteLibraryVerilog()

void Mio_WriteLibraryVerilog ( FILE * pFile,
Mio_Library_t * pLib,
int fPrintSops,
int fShort,
int fSelected )

Definition at line 357 of file mioUtils.c.

358{
359 Mio_Gate_t * pGate;
360 Mio_Pin_t * pPin;
361 Vec_Ptr_t * vGates = Vec_PtrAlloc( 1000 );
362 Vec_Ptr_t * vNames = Vec_PtrAlloc( 100 );
363 int i, nCells;
364 if ( fSelected )
365 {
366 Mio_Cell2_t * pCells = Mio_CollectRootsNewDefault2( 6, &nCells, 0 );
367 for ( i = 0; i < nCells; i++ )
368 Vec_PtrPush( vGates, pCells[i].pMioGate );
369 ABC_FREE( pCells );
370 }
371 else
372 {
373 for ( i = 0; i < pLib->nGates; i++ )
374 Vec_PtrPush( vGates, pLib->ppGates0[i] );
375 }
376 fprintf( pFile, "// Verilog for genlib library \"%s\" with %d gates written by ABC on %s\n\n", pLib->pName, Vec_PtrSize(vGates), Extra_TimeStamp() );
377 Vec_PtrForEachEntry( Mio_Gate_t *, vGates, pGate, i )
378 {
379 Vec_PtrClear( vNames );
380 Mio_GateForEachPin( pGate, pPin )
381 Vec_PtrPush( vNames, pPin->pName );
382 Mio_WriteGateVerilog( pFile, pGate, vNames );
383 }
384 Vec_PtrFree( vNames );
385 Vec_PtrFree( vGates );
386}
void Mio_WriteGateVerilog(FILE *pFile, Mio_Gate_t *pGate, Vec_Ptr_t *vNames)
Definition mioUtils.c:336
Here is the call graph for this function:

◆ Mio_WritePin()

void Mio_WritePin ( FILE * pFile,
Mio_Pin_t * pPin,
int NameLen,
int fAllPins )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 199 of file mioUtils.c.

200{
201 char * pPhaseNames[10] = { "UNKNOWN", "INV", "NONINV" };
202 if ( fAllPins )
203 fprintf( pFile, "PIN * " );
204 else
205 fprintf( pFile, "\n PIN %*s ", NameLen, pPin->pName );
206 fprintf( pFile, "%7s ", pPhaseNames[pPin->Phase] );
207 fprintf( pFile, "%3d ", (int)pPin->dLoadInput );
208 fprintf( pFile, "%3d ", (int)pPin->dLoadMax );
209 fprintf( pFile, "%8.2f ", pPin->dDelayBlockRise );
210 fprintf( pFile, "%8.2f ", pPin->dDelayFanoutRise );
211 fprintf( pFile, "%8.2f ", pPin->dDelayBlockFall );
212 fprintf( pFile, "%8.2f", pPin->dDelayFanoutFall );
213}
Mio_PinPhase_t Phase
Definition mioInt.h:126
Here is the caller graph for this function:

◆ Nf_ManPrepareGate()

void Nf_ManPrepareGate ( int nVars,
word uTruth,
int * pComp,
int * pPerm,
Vec_Wrd_t * vResult )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1342 of file mioUtils.c.

1343{
1344 int nPerms = Extra_Factorial( nVars );
1345 int nMints = (1 << nVars);
1346 word tCur, tTemp1, tTemp2;
1347 int i, p, c;
1348 Vec_WrdClear( vResult );
1349 for ( i = 0; i < 2; i++ )
1350 {
1351 tCur = i ? ~uTruth : uTruth;
1352 tTemp1 = tCur;
1353 for ( p = 0; p < nPerms; p++ )
1354 {
1355 tTemp2 = tCur;
1356 for ( c = 0; c < nMints; c++ )
1357 {
1358 Vec_WrdPush( vResult, tCur );
1359 tCur = Abc_Tt6Flip( tCur, pComp[c] );
1360 }
1361 assert( tTemp2 == tCur );
1362 tCur = Abc_Tt6SwapAdjacent( tCur, pPerm[p] );
1363 }
1364 assert( tTemp1 == tCur );
1365 }
1366}
int Extra_Factorial(int n)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Nf_ManPrepareLibrary()

void Nf_ManPrepareLibrary ( Mio_Library_t * pLib)

Definition at line 1404 of file mioUtils.c.

1405{
1406// char Lines[2*720*64][8];
1407// Nf_ManPreparePrint( 6, pComp, pPerm, Lines );
1408 int * pComp[7];
1409 int * pPerm[7];
1410 Mio_Gate_t ** ppGates;
1411 Vec_Wrd_t * vResult;
1412 word * pTruths;
1413 int * pSizes;
1414 int nGates, i, nClasses = 0, nTotal;
1415 abctime clk = Abc_Clock();
1416
1417 for ( i = 2; i <= 6; i++ )
1418 pComp[i] = Extra_GreyCodeSchedule( i );
1419 for ( i = 2; i <= 6; i++ )
1420 pPerm[i] = Extra_PermSchedule( i );
1421
1422 // collect truth tables
1423 ppGates = Mio_CollectRoots( pLib, 6, (float)1.0e+20, 1, &nGates, 0 );
1424 pSizes = ABC_CALLOC( int, nGates );
1425 pTruths = ABC_CALLOC( word, nGates );
1426 vResult = Vec_WrdAlloc( 2 * 720 * 64 );
1427 for ( i = 0; i < nGates; i++ )
1428 {
1429 pSizes[i] = Mio_GateReadPinNum( ppGates[i] );
1430 assert( pSizes[i] > 1 && pSizes[i] <= 6 );
1431 pTruths[i] = Mio_GateReadTruth( ppGates[i] );
1432
1433 Nf_ManPrepareGate( pSizes[i], pTruths[i], pComp[pSizes[i]], pPerm[pSizes[i]], vResult );
1434 Vec_WrdUniqify(vResult);
1435 nClasses += Vec_WrdSize(vResult);
1436 nTotal = (1 << (pSizes[i]+1)) * Extra_Factorial(pSizes[i]);
1437
1438 printf( "%6d : ", i );
1439 printf( "%16s : ", Mio_GateReadName( ppGates[i] ) );
1440 printf( "%48s : ", Mio_GateReadForm( ppGates[i] ) );
1441 printf( "Inputs = %2d ", pSizes[i] );
1442 printf( "Total = %6d ", nTotal );
1443 printf( "Classes = %6d ", Vec_WrdSize(vResult) );
1444 printf( "Configs = %8.2f ", 1.0*nTotal/Vec_WrdSize(vResult) );
1445 printf( "%6.2f %% ", 100.0*Vec_WrdSize(vResult)/nTotal );
1446 Dau_DsdPrintFromTruth( &pTruths[i], pSizes[i] );
1447// printf( "\n" );
1448 }
1449 Vec_WrdFree( vResult );
1450 ABC_FREE( ppGates );
1451 ABC_FREE( pSizes );
1452 ABC_FREE( pTruths );
1453
1454 for ( i = 2; i <= 6; i++ )
1455 ABC_FREE( pComp[i] );
1456 for ( i = 2; i <= 6; i++ )
1457 ABC_FREE( pPerm[i] );
1458
1459 printf( "Classes = %d. ", nClasses );
1460 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1461}
ABC_INT64_T abctime
Definition abc_global.h:332
int nTotal
DECLARATIONS ///.
Definition cutTruth.c:37
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
Definition dauDsd.c:1968
int * Extra_PermSchedule(int n)
int * Extra_GreyCodeSchedule(int n)
Mio_Gate_t ** Mio_CollectRoots(Mio_Library_t *pLib, int nInputs, float tDelay, int fSkipInv, int *pnGates, int fVerbose)
Definition mioUtils.c:515
void Nf_ManPrepareGate(int nVars, word uTruth, int *pComp, int *pPerm, Vec_Wrd_t *vResult)
Definition mioUtils.c:1342
word Mio_GateReadTruth(Mio_Gate_t *pGate)
Definition mioApi.c:181
char * Mio_GateReadForm(Mio_Gate_t *pGate)
Definition mioApi.c:172
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Nf_ManPrepareLibraryTest2()

void Nf_ManPrepareLibraryTest2 ( )

Definition at line 1463 of file mioUtils.c.

1464{
1466 if ( pLib != NULL )
1467 Nf_ManPrepareLibrary( pLib );
1468 else
1469 printf( "Standard cell library is not available.\n" );
1470
1471}
void Nf_ManPrepareLibrary(Mio_Library_t *pLib)
Definition mioUtils.c:1404
Here is the call graph for this function:

◆ Nf_ManPreparePrint()

void Nf_ManPreparePrint ( int nVars,
int * pComp,
int * pPerm,
char Line[2 *720 *64][8] )

Definition at line 1367 of file mioUtils.c.

1368{
1369 int nPerms = Extra_Factorial( nVars );
1370 int nMints = (1 << nVars);
1371 char * pChar, * pChar2;
1372 int i, p, c, n = 0;
1373 for ( i = 0; i < nVars; i++ )
1374 Line[0][i] = 'A' + nVars - 1 - i;
1375 Line[0][nVars] = '+';
1376 Line[0][nVars+1] = 0;
1377 for ( i = 0; i < 2; i++ )
1378 {
1379 Line[n][nVars] = i ? '-' : '+';
1380 for ( p = 0; p < nPerms; p++ )
1381 {
1382 for ( c = 0; c < nMints; c++ )
1383 {
1384 strcpy( Line[n+1], Line[n] ); n++;
1385 pChar = &Line[n][pComp[c]];
1386 if ( *pChar >= 'A' && *pChar <= 'Z' )
1387 *pChar += 'a' - 'A';
1388 else if ( *pChar >= 'a' && *pChar <= 'z' )
1389 *pChar -= 'a' - 'A';
1390 }
1391 pChar = &Line[n][pPerm[p]];
1392 pChar2 = pChar + 1;
1393 ABC_SWAP( char, *pChar, *pChar2 );
1394 }
1395 }
1396 assert( n == 2*nPerms*nMints );
1397 n = 0;
1398 for ( i = 0; i < 2; i++ )
1399 for ( p = 0; p < nPerms; p++ )
1400 for ( c = 0; c < nMints; c++ )
1401 printf("%8d : %d %3d %2d : %s\n", n, i, p, c, Line[n]), n++;
1402}
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
char * strcpy()
Here is the call graph for this function: