Commit 61d46232 by Alan Mishchenko

Adding switch in 'print_genlib' and 'write_genlib' to print area-min gates only.

parent 701565eb
......@@ -401,23 +401,25 @@ int Mio_CommandWriteGenlib( Abc_Frame_t * pAbc, int argc, char **argv )
FILE * pOut, * pErr, * pFile;
Abc_Ntk_t * pNet;
char * pFileName;
int fVerbose;
int fSelected = 0;
int fVerbose = 0;
int c;
pNet = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
// set the defaults
fVerbose = 1;
Extra_UtilGetoptReset();
while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF )
while ( (c = Extra_UtilGetopt(argc, argv, "vah")) != EOF )
{
switch (c)
{
case 'v':
fVerbose ^= 1;
break;
case 'a':
fSelected ^= 1;
break;
case 'h':
goto usage;
break;
......@@ -443,15 +445,16 @@ int Mio_CommandWriteGenlib( Abc_Frame_t * pAbc, int argc, char **argv )
printf( "Error! Cannot open file \"%s\" for writing the library.\n", pFileName );
return 1;
}
Mio_WriteLibrary( pFile, (Mio_Library_t *)Abc_FrameReadLibGen(), 0, 0 );
Mio_WriteLibrary( pFile, (Mio_Library_t *)Abc_FrameReadLibGen(), 0, 0, fSelected );
fclose( pFile );
printf( "The current genlib library is written into file \"%s\".\n", pFileName );
return 0;
usage:
fprintf( pErr, "\nusage: write_genlib [-vh] <file>\n");
fprintf( pErr, "\nusage: write_genlib [-vah] <file>\n");
fprintf( pErr, "\t writes the current genlib library into a file\n" );
fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", fVerbose? "yes" : "no" );
fprintf( pErr, "\t-a : toggles writing min-area gates [default = %s]\n", fSelected? "yes" : "no" );
fprintf( pErr, "\t-h : print the command usage\n");
fprintf( pErr, "\t<file> : optional file name to write the library\n");
return 1;
......@@ -473,6 +476,7 @@ int Mio_CommandPrintGenlib( Abc_Frame_t * pAbc, int argc, char **argv )
FILE * pOut, * pErr;
Abc_Ntk_t * pNet;
int fShort = 0;
int fSelected = 0;
int fVerbose = 0;
int c;
......@@ -482,13 +486,16 @@ int Mio_CommandPrintGenlib( Abc_Frame_t * pAbc, int argc, char **argv )
// set the defaults
Extra_UtilGetoptReset();
while ( (c = Extra_UtilGetopt(argc, argv, "svh")) != EOF )
while ( (c = Extra_UtilGetopt(argc, argv, "savh")) != EOF )
{
switch (c)
{
case 's':
fShort ^= 1;
break;
case 'a':
fSelected ^= 1;
break;
case 'v':
fVerbose ^= 1;
break;
......@@ -504,13 +511,14 @@ int Mio_CommandPrintGenlib( Abc_Frame_t * pAbc, int argc, char **argv )
printf( "Library is not available.\n" );
return 1;
}
Mio_WriteLibrary( stdout, (Mio_Library_t *)Abc_FrameReadLibGen(), 0, fShort );
Mio_WriteLibrary( stdout, (Mio_Library_t *)Abc_FrameReadLibGen(), 0, fShort, fSelected );
return 0;
usage:
fprintf( pErr, "\nusage: print_genlib [-svh]\n");
fprintf( pErr, "\nusage: print_genlib [-savh]\n");
fprintf( pErr, "\t print the current genlib library\n" );
fprintf( pErr, "\t-s : toggles writing short form [default = %s]\n", fShort? "yes" : "no" );
fprintf( pErr, "\t-a : toggles writing min-area gates [default = %s]\n", fSelected? "yes" : "no" );
fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", fVerbose? "yes" : "no" );
fprintf( pErr, "\t-h : print the command usage\n");
return 1;
......
......@@ -180,7 +180,7 @@ extern void Mio_LibraryDelete( Mio_Library_t * pLib );
extern void Mio_GateDelete( Mio_Gate_t * pGate );
extern void Mio_PinDelete( Mio_Pin_t * pPin );
extern Mio_Pin_t * Mio_PinDup( Mio_Pin_t * pPin );
extern void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops, int fShort );
extern void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops, int fShort, int fSelected );
extern Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, int fSkipInv, int * pnGates, int fVerbose );
extern Mio_Cell_t * Mio_CollectRootsNew( Mio_Library_t * pLib, int nInputs, int * pnGates, int fVerbose );
extern Mio_Cell_t * Mio_CollectRootsNewDefault( int nInputs, int * pnGates, int fVerbose );
......
......@@ -248,13 +248,26 @@ void Mio_WriteGate( FILE * pFile, Mio_Gate_t * pGate, int GateLen, int NameLen,
SeeAlso []
***********************************************************************/
void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops, int fShort )
void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops, int fShort, int fSelected )
{
Mio_Gate_t * pGate;
Mio_Pin_t * pPin;
int i, GateLen = 0, NameLen = 0, FormLen = 0;
Vec_Ptr_t * vGates = Vec_PtrAlloc( 1000 );
int i, nCells, GateLen = 0, NameLen = 0, FormLen = 0;
int fAllPins = fShort || Mio_CheckGates( pLib );
Mio_LibraryForEachGate( pLib, pGate )
if ( fSelected )
{
Mio_Cell2_t * pCells = Mio_CollectRootsNewDefault2( 6, &nCells, 0 );
for ( i = 0; i < nCells; i++ )
Vec_PtrPush( vGates, pCells[i].pMioGate );
ABC_FREE( pCells );
}
else
{
for ( i = 0; i < pLib->nGates; i++ )
Vec_PtrPush( vGates, pLib->ppGates0[i] );
}
Vec_PtrForEachEntry( Mio_Gate_t *, vGates, pGate, i )
{
GateLen = Abc_MaxInt( GateLen, strlen(pGate->pName) );
NameLen = Abc_MaxInt( NameLen, strlen(pGate->pOutName) );
......@@ -262,9 +275,10 @@ void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops, int f
Mio_GateForEachPin( pGate, pPin )
NameLen = Abc_MaxInt( NameLen, strlen(pPin->pName) );
}
fprintf( pFile, "# The genlib library \"%s\" written by ABC on %s\n\n", pLib->pName, Extra_TimeStamp() );
for ( i = 0; i < pLib->nGates; i++ )
Mio_WriteGate( pFile, pLib->ppGates0[i], GateLen, NameLen, FormLen, fPrintSops, fAllPins );
fprintf( pFile, "# The genlib library \"%s\" with %d gates written by ABC on %s\n", pLib->pName, Vec_PtrSize(vGates), Extra_TimeStamp() );
Vec_PtrForEachEntry( Mio_Gate_t *, vGates, pGate, i )
Mio_WriteGate( pFile, pGate, GateLen, NameLen, FormLen, fPrintSops, fAllPins );
Vec_PtrFree( vGates );
}
/**Function*************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment