Commit 7d3976a7 by Alan Mishchenko

Unifying standard cell library representations.

parent 5df166fc
...@@ -66,13 +66,18 @@ Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, double AreaMulti, ...@@ -66,13 +66,18 @@ Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, double AreaMulti,
Vec_Int_t * vSwitching = NULL; Vec_Int_t * vSwitching = NULL;
float * pSwitching = NULL; float * pSwitching = NULL;
abctime clk, clkTotal = Abc_Clock(); abctime clk, clkTotal = Abc_Clock();
Mio_Library_t * pLib; Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen();
assert( Abc_NtkIsStrash(pNtk) ); assert( Abc_NtkIsStrash(pNtk) );
// derive library from SCL // derive library from SCL
// if the library is created here, it will be deleted when pSuperLib is deleted in Map_SuperLibFree()
if ( Abc_FrameReadLibScl() ) if ( Abc_FrameReadLibScl() )
Abc_SclDeriveGenlib( Abc_FrameReadLibScl(), Slew, Gain, nGatesMin ); {
pLib = Abc_SclDeriveGenlib( Abc_FrameReadLibScl(), Slew, Gain, nGatesMin );
if ( Abc_FrameReadLibGen() )
Mio_LibraryTransferDelays( (Mio_Library_t *)Abc_FrameReadLibGen(), pLib );
}
// quit if there is no library // quit if there is no library
pLib = (Mio_Library_t *)Abc_FrameReadLibGen();
if ( pLib == NULL ) if ( pLib == NULL )
{ {
printf( "The current library is not available.\n" ); printf( "The current library is not available.\n" );
...@@ -423,6 +428,7 @@ Abc_Obj_t * Abc_NodeFromMapPhase_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap ...@@ -423,6 +428,7 @@ Abc_Obj_t * Abc_NodeFromMapPhase_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap
***********************************************************************/ ***********************************************************************/
Abc_Obj_t * Abc_NodeFromMapSuper_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap, Map_Super_t * pSuper, Abc_Obj_t * pNodePis[], int nNodePis ) Abc_Obj_t * Abc_NodeFromMapSuper_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap, Map_Super_t * pSuper, Abc_Obj_t * pNodePis[], int nNodePis )
{ {
Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen();
Mio_Gate_t * pRoot; Mio_Gate_t * pRoot;
Map_Super_t ** ppFanins; Map_Super_t ** ppFanins;
Abc_Obj_t * pNodeNew, * pNodeFanin; Abc_Obj_t * pNodeNew, * pNodeFanin;
...@@ -449,6 +455,7 @@ Abc_Obj_t * Abc_NodeFromMapSuper_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap ...@@ -449,6 +455,7 @@ Abc_Obj_t * Abc_NodeFromMapSuper_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap
return Abc_NtkCreateNodeConst0(pNtkNew); return Abc_NtkCreateNodeConst0(pNtkNew);
} }
} }
pRoot = Mio_LibraryReadGateByName( pLib, Mio_GateReadName(pRoot), NULL );
// get information about the fanins of the supergate // get information about the fanins of the supergate
nFanins = Map_SuperReadFaninNum( pSuper ); nFanins = Map_SuperReadFaninNum( pSuper );
...@@ -685,6 +692,7 @@ void Abc_NodeFromMapCutPhase( Abc_Ntk_t * pNtkNew, Map_Cut_t * pCut, int fPhase ...@@ -685,6 +692,7 @@ void Abc_NodeFromMapCutPhase( Abc_Ntk_t * pNtkNew, Map_Cut_t * pCut, int fPhase
***********************************************************************/ ***********************************************************************/
Abc_Obj_t * Abc_NodeFromMapSuperChoice_rec( Abc_Ntk_t * pNtkNew, Map_Super_t * pSuper, Abc_Obj_t * pNodePis[], int nNodePis ) Abc_Obj_t * Abc_NodeFromMapSuperChoice_rec( Abc_Ntk_t * pNtkNew, Map_Super_t * pSuper, Abc_Obj_t * pNodePis[], int nNodePis )
{ {
Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen();
Mio_Gate_t * pRoot; Mio_Gate_t * pRoot;
Map_Super_t ** ppFanins; Map_Super_t ** ppFanins;
Abc_Obj_t * pNodeNew, * pNodeFanin; Abc_Obj_t * pNodeNew, * pNodeFanin;
...@@ -711,6 +719,7 @@ Abc_Obj_t * Abc_NodeFromMapSuperChoice_rec( Abc_Ntk_t * pNtkNew, Map_Super_t * p ...@@ -711,6 +719,7 @@ Abc_Obj_t * Abc_NodeFromMapSuperChoice_rec( Abc_Ntk_t * pNtkNew, Map_Super_t * p
return Abc_NtkCreateNodeConst0(pNtkNew); return Abc_NtkCreateNodeConst0(pNtkNew);
} }
} }
pRoot = Mio_LibraryReadGateByName( pLib, Mio_GateReadName(pRoot), NULL );
// get information about the fanins of the supergate // get information about the fanins of the supergate
nFanins = Map_SuperReadFaninNum( pSuper ); nFanins = Map_SuperReadFaninNum( pSuper );
......
...@@ -265,6 +265,7 @@ void Abc_NtkPrintStats( Abc_Ntk_t * pNtk, int fFactored, int fSaveBest, int fDum ...@@ -265,6 +265,7 @@ void Abc_NtkPrintStats( Abc_Ntk_t * pNtk, int fFactored, int fSaveBest, int fDum
Abc_Print( 1," bdd =%6d", Abc_NtkGetBddNodeNum(pNtk) - nSingles ); Abc_Print( 1," bdd =%6d", Abc_NtkGetBddNodeNum(pNtk) - nSingles );
else if ( Abc_NtkHasMapping(pNtk) ) else if ( Abc_NtkHasMapping(pNtk) )
{ {
assert( pNtk->pManFunc == Abc_FrameReadLibGen() );
Abc_Print( 1," area =%5.2f", Abc_NtkGetMappedArea(pNtk) ); Abc_Print( 1," area =%5.2f", Abc_NtkGetMappedArea(pNtk) );
Abc_Print( 1," delay =%5.2f", Abc_NtkDelayTrace(pNtk, NULL, NULL, 0) ); Abc_Print( 1," delay =%5.2f", Abc_NtkDelayTrace(pNtk, NULL, NULL, 0) );
} }
......
...@@ -205,7 +205,7 @@ int IoCommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -205,7 +205,7 @@ int IoCommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( !strcmp( Extra_FileNameExtension(pFileName), "genlib" ) ) if ( !strcmp( Extra_FileNameExtension(pFileName), "genlib" ) )
sprintf( Command, "read_genlib %s", pFileName ); sprintf( Command, "read_genlib %s", pFileName );
else if ( !strcmp( Extra_FileNameExtension(pFileName), "lib" ) ) else if ( !strcmp( Extra_FileNameExtension(pFileName), "lib" ) )
sprintf( Command, "read_liberty %s", pFileName ); sprintf( Command, "read_lib %s", pFileName );
else if ( !strcmp( Extra_FileNameExtension(pFileName), "scl" ) ) else if ( !strcmp( Extra_FileNameExtension(pFileName), "scl" ) )
sprintf( Command, "read_scl %s", pFileName ); sprintf( Command, "read_scl %s", pFileName );
else if ( !strcmp( Extra_FileNameExtension(pFileName), "super" ) ) else if ( !strcmp( Extra_FileNameExtension(pFileName), "super" ) )
......
...@@ -121,6 +121,9 @@ Ver_Man_t * Ver_ParseStart( char * pFileName, Abc_Lib_t * pGateLib ) ...@@ -121,6 +121,9 @@ Ver_Man_t * Ver_ParseStart( char * pFileName, Abc_Lib_t * pGateLib )
// create the design library and assign the technology library // create the design library and assign the technology library
p->pDesign = Abc_LibCreate( pFileName ); p->pDesign = Abc_LibCreate( pFileName );
p->pDesign->pLibrary = pGateLib; p->pDesign->pLibrary = pGateLib;
// derive library from SCL
// if ( Abc_FrameReadLibScl() )
// Abc_SclInstallGenlib( Abc_FrameReadLibScl(), 0, 0, 0 );
p->pDesign->pGenlib = Abc_FrameReadLibGen(); p->pDesign->pGenlib = Abc_FrameReadLibGen();
return p; return p;
} }
......
...@@ -169,9 +169,8 @@ void Map_SuperLibFree( Map_SuperLib_t * p ) ...@@ -169,9 +169,8 @@ void Map_SuperLibFree( Map_SuperLib_t * p )
if ( p == NULL ) return; if ( p == NULL ) return;
if ( p->pGenlib ) if ( p->pGenlib )
{ {
// assert( p->pGenlib == Abc_FrameReadLibGen() ); if ( p->pGenlib != Abc_FrameReadLibGen() )
// Mio_LibraryDelete( p->pGenlib ); Mio_LibraryDelete( p->pGenlib );
// Abc_FrameSetLibGen( NULL );
p->pGenlib = NULL; p->pGenlib = NULL;
} }
if ( p->tTableC ) if ( p->tTableC )
...@@ -204,14 +203,17 @@ int Map_SuperLibDeriveFromGenlib( Mio_Library_t * pLib, int fVerbose ) ...@@ -204,14 +203,17 @@ int Map_SuperLibDeriveFromGenlib( Mio_Library_t * pLib, int fVerbose )
char * pFileName; char * pFileName;
if ( pLib == NULL ) if ( pLib == NULL )
return 0; return 0;
// compute supergates // compute supergates
vStr = Super_PrecomputeStr( pLib, 5, 1, 100000000, 10000000, 10000000, 100, 1, 0 ); vStr = Super_PrecomputeStr( pLib, 5, 1, 100000000, 10000000, 10000000, 100, 1, 0 );
if ( vStr == NULL ) if ( vStr == NULL )
return 0; return 0;
// create supergate library // create supergate library
pFileName = Extra_FileNameGenericAppend( Mio_LibraryReadName(pLib), ".super" ); pFileName = Extra_FileNameGenericAppend( Mio_LibraryReadName(pLib), ".super" );
pLibSuper = Map_SuperLibCreate( pLib, vStr, pFileName, NULL, 1, 0 ); pLibSuper = Map_SuperLibCreate( pLib, vStr, pFileName, NULL, 1, 0 );
Vec_StrFree( vStr ); Vec_StrFree( vStr );
// replace the library // replace the library
Map_SuperLibFree( (Map_SuperLib_t *)Abc_FrameReadLibSuper() ); Map_SuperLibFree( (Map_SuperLib_t *)Abc_FrameReadLibSuper() );
Abc_FrameSetLibSuper( pLibSuper ); Abc_FrameSetLibSuper( pLibSuper );
......
...@@ -82,7 +82,7 @@ static char * pMcncGenlib[25] = { ...@@ -82,7 +82,7 @@ static char * pMcncGenlib[25] = {
***********************************************************************/ ***********************************************************************/
void Mio_Init( Abc_Frame_t * pAbc ) void Mio_Init( Abc_Frame_t * pAbc )
{ {
Cmd_CommandAdd( pAbc, "SC mapping", "read_liberty", Mio_CommandReadLiberty, 0 ); // Cmd_CommandAdd( pAbc, "SC mapping", "read_liberty", Mio_CommandReadLiberty, 0 );
Cmd_CommandAdd( pAbc, "SC mapping", "read_genlib", Mio_CommandReadGenlib, 0 ); Cmd_CommandAdd( pAbc, "SC mapping", "read_genlib", Mio_CommandReadGenlib, 0 );
Cmd_CommandAdd( pAbc, "SC mapping", "write_genlib", Mio_CommandWriteGenlib, 0 ); Cmd_CommandAdd( pAbc, "SC mapping", "write_genlib", Mio_CommandWriteGenlib, 0 );
......
...@@ -82,7 +82,6 @@ static inline char * Mio_UtilStrsav( char * s ) { return s ? strcpy(ABC_A ...@@ -82,7 +82,6 @@ static inline char * Mio_UtilStrsav( char * s ) { return s ? strcpy(ABC_A
/*=== mio.c =============================================================*/ /*=== mio.c =============================================================*/
extern void Mio_UpdateGenlib( Mio_Library_t * pLib ); extern void Mio_UpdateGenlib( Mio_Library_t * pLib );
extern int Mio_UpdateGenlib2( Vec_Str_t * vStr, Vec_Str_t * vStr2, char * pFileName, int fVerbose ); extern int Mio_UpdateGenlib2( Vec_Str_t * vStr, Vec_Str_t * vStr2, char * pFileName, int fVerbose );
extern void Abc_SclDeriveGenlib( void * pScl, float Slew, float Gain, int nGatesMin );
/*=== mioApi.c =============================================================*/ /*=== mioApi.c =============================================================*/
extern char * Mio_LibraryReadName ( Mio_Library_t * pLib ); extern char * Mio_LibraryReadName ( Mio_Library_t * pLib );
extern int Mio_LibraryReadGateNum ( Mio_Library_t * pLib ); extern int Mio_LibraryReadGateNum ( Mio_Library_t * pLib );
...@@ -161,10 +160,13 @@ extern Mio_Gate_t * Mio_GateCreatePseudo( int nInputs ); ...@@ -161,10 +160,13 @@ extern Mio_Gate_t * Mio_GateCreatePseudo( int nInputs );
extern void Mio_LibraryShiftDelay( Mio_Library_t * pLib, double Shift ); extern void Mio_LibraryShiftDelay( Mio_Library_t * pLib, double Shift );
extern void Mio_LibraryMultiArea( Mio_Library_t * pLib, double Multi ); extern void Mio_LibraryMultiArea( Mio_Library_t * pLib, double Multi );
extern void Mio_LibraryMultiDelay( Mio_Library_t * pLib, double Multi ); extern void Mio_LibraryMultiDelay( Mio_Library_t * pLib, double Multi );
extern void Mio_LibraryTransferDelays( Mio_Library_t * pLibD, Mio_Library_t * pLibS );
ABC_NAMESPACE_HEADER_END /*=== sclUtil.c =========================================================*/
extern Mio_Library_t * Abc_SclDeriveGenlibSimple( void * pScl );
extern Mio_Library_t * Abc_SclDeriveGenlib( void * pScl, float Slew, float Gain, int nGatesMin );
ABC_NAMESPACE_HEADER_END
#endif #endif
......
...@@ -260,7 +260,7 @@ void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops ) ...@@ -260,7 +260,7 @@ void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops )
Mio_GateForEachPin( pGate, pPin ) Mio_GateForEachPin( pGate, pPin )
NameLen = Abc_MaxInt( NameLen, strlen(pPin->pName) ); NameLen = Abc_MaxInt( NameLen, strlen(pPin->pName) );
} }
fprintf( pFile, "# The genlib library \"%s\".\n", pLib->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++ ) for ( i = 0; i < pLib->nGates; i++ )
Mio_WriteGate( pFile, pLib->ppGates0[i], GateLen, NameLen, FormLen, fPrintSops, fAllPins ); Mio_WriteGate( pFile, pLib->ppGates0[i], GateLen, NameLen, FormLen, fPrintSops, fAllPins );
} }
...@@ -705,6 +705,38 @@ void Mio_LibraryMultiDelay( Mio_Library_t * pLib, double Multi ) ...@@ -705,6 +705,38 @@ void Mio_LibraryMultiDelay( Mio_Library_t * pLib, double Multi )
} }
} }
/**Function*************************************************************
Synopsis [Transfers delays from the second to the first.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Mio_LibraryTransferDelays( Mio_Library_t * pLibD, Mio_Library_t * pLibS )
{
Mio_Gate_t * pGateD, * pGateS;
Mio_Pin_t * pPinD, * pPinS;
Mio_LibraryForEachGate( pLibS, pGateS )
{
Mio_LibraryForEachGate( pLibD, pGateD )
{
if ( pGateD->uTruth != pGateS->uTruth )
continue;
pPinS = Mio_GateReadPins( pGateS );
Mio_GateForEachPin( pGateD, pPinD )
{
pPinD->dDelayBlockRise = pPinS->dDelayBlockRise;
pPinD->dDelayBlockFall = pPinS->dDelayBlockFall;
pPinD->dDelayBlockMax = pPinS->dDelayBlockMax;
pPinS = Mio_PinReadNext(pPinS);
}
}
}
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -29,8 +29,9 @@ ABC_NAMESPACE_IMPL_START ...@@ -29,8 +29,9 @@ ABC_NAMESPACE_IMPL_START
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
static int Scl_CommandReadLib ( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandReadLib ( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandRead ( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandWriteLib( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandWrite ( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandReadScl ( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandWriteScl( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandPrintLib( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandPrintLib( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandDumpGen ( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandDumpGen ( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandPrintGS ( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandPrintGS ( Abc_Frame_t * pAbc, int argc, char **argv );
...@@ -87,9 +88,10 @@ void Abc_SclLoad( SC_Lib * pLib, SC_Lib ** ppScl ) ...@@ -87,9 +88,10 @@ void Abc_SclLoad( SC_Lib * pLib, SC_Lib ** ppScl )
void Scl_Init( Abc_Frame_t * pAbc ) void Scl_Init( Abc_Frame_t * pAbc )
{ {
Cmd_CommandAdd( pAbc, "SCL mapping", "read_lib", Scl_CommandReadLib, 0 ); Cmd_CommandAdd( pAbc, "SCL mapping", "read_lib", Scl_CommandReadLib, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "read_scl", Scl_CommandRead, 0 ); Cmd_CommandAdd( pAbc, "SCL mapping", "write_lib", Scl_CommandWriteLib, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "write_scl", Scl_CommandWrite, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "print_lib", Scl_CommandPrintLib, 0 ); Cmd_CommandAdd( pAbc, "SCL mapping", "print_lib", Scl_CommandPrintLib, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "read_scl", Scl_CommandReadScl, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "write_scl", Scl_CommandWriteScl, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "dump_genlib", Scl_CommandDumpGen, 0 ); Cmd_CommandAdd( pAbc, "SCL mapping", "dump_genlib", Scl_CommandDumpGen, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "print_gs", Scl_CommandPrintGS, 0 ); Cmd_CommandAdd( pAbc, "SCL mapping", "print_gs", Scl_CommandPrintGS, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "stime", Scl_CommandStime, 0 ); Cmd_CommandAdd( pAbc, "SCL mapping", "stime", Scl_CommandStime, 0 );
...@@ -128,9 +130,9 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -128,9 +130,9 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
FILE * pFile; FILE * pFile;
SC_Lib * pLib; SC_Lib * pLib;
int c, fDump = 0; int c, fDump = 0;
float Slew = 200; float Slew = 0;
float Gain = 100; float Gain = 0;
int nGatesMin = 4; int nGatesMin = 0;
int fVerbose = 1; int fVerbose = 1;
int fVeryVerbose = 0; int fVeryVerbose = 0;
...@@ -210,7 +212,7 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -210,7 +212,7 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_SclWriteLiberty( Extra_FileNameGenericAppend(pFileName, "_temp.lib"), (SC_Lib *)pAbc->pLibScl ); Abc_SclWriteLiberty( Extra_FileNameGenericAppend(pFileName, "_temp.lib"), (SC_Lib *)pAbc->pLibScl );
// extract genlib library // extract genlib library
if ( pAbc->pLibScl ) if ( pAbc->pLibScl )
Abc_SclDeriveGenlib( pAbc->pLibScl, Slew, Gain, nGatesMin ); Abc_SclInstallGenlib( pAbc->pLibScl, Slew, Gain, nGatesMin );
return 0; return 0;
usage: usage:
...@@ -227,72 +229,6 @@ usage: ...@@ -227,72 +229,6 @@ usage:
return 1; return 1;
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Scl_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pFile;
SC_Lib * pLib;
char * pFileName;
int c, fDump = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
{
switch ( c )
{
case 'd':
fDump ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( argc != globalUtilOptind + 1 )
goto usage;
// get the input file name
pFileName = argv[globalUtilOptind];
if ( (pFile = fopen( pFileName, "rb" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". \n", pFileName );
return 1;
}
fclose( pFile );
// read new library
pLib = Abc_SclReadFromFile( pFileName );
if ( pLib == NULL )
{
fprintf( pAbc->Err, "Reading SCL library from file \"%s\" has failed. \n", pFileName );
return 1;
}
Abc_SclLoad( pLib, (SC_Lib **)&pAbc->pLibScl );
if ( fDump )
Abc_SclWriteLiberty( Extra_FileNameGenericAppend(pFileName, "_temp.lib"), (SC_Lib *)pAbc->pLibScl );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_scl [-dh] <file>\n" );
fprintf( pAbc->Err, "\t reads extracted Liberty library from file\n" );
fprintf( pAbc->Err, "\t-d : toggle dumping the parsed library into file \"*_temp.lib\" [default = %s]\n", fDump? "yes": "no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\t<file> : the name of a file to read\n" );
return 1;
}
/**Function************************************************************* /**Function*************************************************************
Synopsis [] Synopsis []
...@@ -304,7 +240,7 @@ usage: ...@@ -304,7 +240,7 @@ usage:
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Scl_CommandWrite( Abc_Frame_t * pAbc, int argc, char **argv ) int Scl_CommandWriteLib( Abc_Frame_t * pAbc, int argc, char **argv )
{ {
FILE * pFile; FILE * pFile;
char * pFileName; char * pFileName;
...@@ -338,12 +274,12 @@ int Scl_CommandWrite( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -338,12 +274,12 @@ int Scl_CommandWrite( Abc_Frame_t * pAbc, int argc, char **argv )
fclose( pFile ); fclose( pFile );
// save current library // save current library
Abc_SclWriteScl( pFileName, (SC_Lib *)pAbc->pLibScl ); Abc_SclWriteLiberty( pFileName, (SC_Lib *)pAbc->pLibScl );
return 0; return 0;
usage: usage:
fprintf( pAbc->Err, "usage: write_scl [-h] <file>\n" ); fprintf( pAbc->Err, "usage: write_lib [-h] <file>\n" );
fprintf( pAbc->Err, "\t write extracted Liberty library into file\n" ); fprintf( pAbc->Err, "\t write current Liberty library into file\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" ); fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\t<file> : the name of the file to write\n" ); fprintf( pAbc->Err, "\t<file> : the name of the file to write\n" );
return 1; return 1;
...@@ -427,6 +363,128 @@ usage: ...@@ -427,6 +363,128 @@ usage:
return 1; return 1;
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Scl_CommandReadScl( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pFile;
SC_Lib * pLib;
char * pFileName;
int c, fDump = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
{
switch ( c )
{
case 'd':
fDump ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( argc != globalUtilOptind + 1 )
goto usage;
// get the input file name
pFileName = argv[globalUtilOptind];
if ( (pFile = fopen( pFileName, "rb" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". \n", pFileName );
return 1;
}
fclose( pFile );
// read new library
pLib = Abc_SclReadFromFile( pFileName );
if ( pLib == NULL )
{
fprintf( pAbc->Err, "Reading SCL library from file \"%s\" has failed. \n", pFileName );
return 1;
}
Abc_SclLoad( pLib, (SC_Lib **)&pAbc->pLibScl );
if ( fDump )
Abc_SclWriteLiberty( Extra_FileNameGenericAppend(pFileName, "_temp.lib"), (SC_Lib *)pAbc->pLibScl );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_scl [-dh] <file>\n" );
fprintf( pAbc->Err, "\t reads extracted Liberty library from file\n" );
fprintf( pAbc->Err, "\t-d : toggle dumping the parsed library into file \"*_temp.lib\" [default = %s]\n", fDump? "yes": "no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\t<file> : the name of a file to read\n" );
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Scl_CommandWriteScl( Abc_Frame_t * pAbc, int argc, char **argv )
{
FILE * pFile;
char * pFileName;
int c;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
}
if ( argc != globalUtilOptind + 1 )
goto usage;
if ( pAbc->pLibScl == NULL )
{
fprintf( pAbc->Err, "There is no Liberty library available.\n" );
return 1;
}
// get the input file name
pFileName = argv[globalUtilOptind];
if ( (pFile = fopen( pFileName, "wb" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open output file \"%s\". \n", pFileName );
return 1;
}
fclose( pFile );
// save current library
Abc_SclWriteScl( pFileName, (SC_Lib *)pAbc->pLibScl );
return 0;
usage:
fprintf( pAbc->Err, "usage: write_scl [-h] <file>\n" );
fprintf( pAbc->Err, "\t write extracted Liberty library into file\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\t<file> : the name of the file to write\n" );
return 1;
}
/**Function************************************************************* /**Function*************************************************************
Synopsis [] Synopsis []
......
...@@ -234,6 +234,7 @@ static inline void SC_PairMove( SC_Pair * d, SC_Pair * s ) { *d = *s; s ...@@ -234,6 +234,7 @@ static inline void SC_PairMove( SC_Pair * d, SC_Pair * s ) { *d = *s; s
static inline int SC_PairEqual( SC_Pair * d, SC_Pair * s ) { return d->rise == s->rise && d->fall == s->fall; } static inline int SC_PairEqual( SC_Pair * d, SC_Pair * s ) { return d->rise == s->rise && d->fall == s->fall; }
static inline int SC_PairEqualE( SC_Pair * d, SC_Pair * s, float E ) { return d->rise - s->rise < E && s->rise - d->rise < E && d->fall - s->fall < E && s->fall - d->fall < E; } static inline int SC_PairEqualE( SC_Pair * d, SC_Pair * s, float E ) { return d->rise - s->rise < E && s->rise - d->rise < E && d->fall - s->fall < E && s->fall - d->fall < E; }
static inline int SC_LibCellNum( SC_Lib * p ) { return Vec_PtrSize(p->vCells); }
static inline SC_Cell * SC_LibCell( SC_Lib * p, int i ) { return (SC_Cell *)Vec_PtrEntry(p->vCells, i); } static inline SC_Cell * SC_LibCell( SC_Lib * p, int i ) { return (SC_Cell *)Vec_PtrEntry(p->vCells, i); }
static inline SC_Pin * SC_CellPin( SC_Cell * p, int i ) { return (SC_Pin *)Vec_PtrEntry(p->vPins, i); } static inline SC_Pin * SC_CellPin( SC_Cell * p, int i ) { return (SC_Pin *)Vec_PtrEntry(p->vPins, i); }
static inline Vec_Wrd_t * SC_CellFunc( SC_Cell * p ) { return SC_CellPin(p, p->n_inputs)->vFunc; } static inline Vec_Wrd_t * SC_CellFunc( SC_Cell * p ) { return SC_CellPin(p, p->n_inputs)->vFunc; }
...@@ -598,8 +599,7 @@ extern SC_Cell * Abc_SclFindSmallestGate( SC_Cell * p, float CinMin ); ...@@ -598,8 +599,7 @@ extern SC_Cell * Abc_SclFindSmallestGate( SC_Cell * p, float CinMin );
extern SC_WireLoad * Abc_SclFindWireLoadModel( SC_Lib * p, float Area ); extern SC_WireLoad * Abc_SclFindWireLoadModel( SC_Lib * p, float Area );
extern SC_WireLoad * Abc_SclFetchWireLoadModel( SC_Lib * p, char * pName ); extern SC_WireLoad * Abc_SclFetchWireLoadModel( SC_Lib * p, char * pName );
extern void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float Slew, float Gain, int nGatesMin ); extern void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float Slew, float Gain, int nGatesMin );
extern void Abc_SclDeriveGenlib( void * pScl, float Slew, float Gain, int nGatesMin ); extern void Abc_SclInstallGenlib( void * pScl, float Slew, float Gain, int nGatesMin );
ABC_NAMESPACE_HEADER_END ABC_NAMESPACE_HEADER_END
......
...@@ -122,7 +122,7 @@ static void Abc_SclReadLibrary( Vec_Str_t * vOut, int * pPos, SC_Lib * p ) ...@@ -122,7 +122,7 @@ static void Abc_SclReadLibrary( Vec_Str_t * vOut, int * pPos, SC_Lib * p )
for ( i = Vec_StrGetI(vOut, pPos); i != 0; i-- ) for ( i = Vec_StrGetI(vOut, pPos); i != 0; i-- )
{ {
SC_Cell * pCell = Abc_SclCellAlloc(); SC_Cell * pCell = Abc_SclCellAlloc();
pCell->Id = Vec_PtrSize(p->vCells); pCell->Id = SC_LibCellNum(p);
Vec_PtrPush( p->vCells, pCell ); Vec_PtrPush( p->vCells, pCell );
pCell->pName = Vec_StrGetS(vOut, pPos); pCell->pName = Vec_StrGetS(vOut, pPos);
...@@ -530,7 +530,7 @@ static void Abc_SclWriteLibraryText( FILE * s, SC_Lib * p ) ...@@ -530,7 +530,7 @@ static void Abc_SclWriteLibraryText( FILE * s, SC_Lib * p )
SC_Pin * pPin; SC_Pin * pPin;
int n_valid_cells; int n_valid_cells;
int i, j, k; int i, j, k;
fprintf( s, "/* This Liberty file was generated by ABC on %s. */\n", Extra_TimeStamp() ); fprintf( s, "/* This Liberty file was generated by ABC on %s */\n", Extra_TimeStamp() );
fprintf( s, "/* The original unabridged library came from file \"%s\".*/\n\n", p->pFileName ); fprintf( s, "/* The original unabridged library came from file \"%s\".*/\n\n", p->pFileName );
// fprintf( s, "%d", ABC_SCL_CUR_VERSION ); // fprintf( s, "%d", ABC_SCL_CUR_VERSION );
...@@ -569,7 +569,7 @@ static void Abc_SclWriteLibraryText( FILE * s, SC_Lib * p ) ...@@ -569,7 +569,7 @@ static void Abc_SclWriteLibraryText( FILE * s, SC_Lib * p )
{ {
fprintf( s, " wire_load_selection(\"%s\") {\n", pWLS->pName ); fprintf( s, " wire_load_selection(\"%s\") {\n", pWLS->pName );
for ( j = 0; j < Vec_FltSize(pWLS->vAreaFrom); j++) for ( j = 0; j < Vec_FltSize(pWLS->vAreaFrom); j++)
fprintf( s, " wire_load_from_area( %f, %f, \"%s\" );\n", fprintf( s, " wire_load_from_area( %f, %f, %s );\n",
Vec_FltEntry(pWLS->vAreaFrom, j), Vec_FltEntry(pWLS->vAreaFrom, j),
Vec_FltEntry(pWLS->vAreaTo, j), Vec_FltEntry(pWLS->vAreaTo, j),
(char *)Vec_PtrEntry(pWLS->vWireLoadModel, j) ); (char *)Vec_PtrEntry(pWLS->vWireLoadModel, j) );
......
...@@ -67,7 +67,7 @@ void Abc_SclHashCells( SC_Lib * p ) ...@@ -67,7 +67,7 @@ void Abc_SclHashCells( SC_Lib * p )
SC_Cell * pCell; SC_Cell * pCell;
int i, * pPlace; int i, * pPlace;
assert( p->nBins == 0 ); assert( p->nBins == 0 );
p->nBins = Abc_PrimeCudd( 5 * Vec_PtrSize(p->vCells) ); p->nBins = Abc_PrimeCudd( 5 * SC_LibCellNum(p) );
p->pBins = ABC_FALLOC( int, p->nBins ); p->pBins = ABC_FALLOC( int, p->nBins );
SC_LibForEachCell( p, pCell, i ) SC_LibForEachCell( p, pCell, i )
{ {
...@@ -494,6 +494,78 @@ void Abc_SclPrintCells( SC_Lib * p, float Slew, float Gain, int fInvOnly, int fS ...@@ -494,6 +494,78 @@ void Abc_SclPrintCells( SC_Lib * p, float Slew, float Gain, int fInvOnly, int fS
/**Function************************************************************* /**Function*************************************************************
Synopsis [Derives simple GENLIB library.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Str_t * Abc_SclProduceGenlibStrSimple( SC_Lib * p )
{
char Buffer[200];
Vec_Str_t * vStr;
SC_Cell * pCell;
SC_Pin * pPin, * pPinOut;
int i, j, k, Count = 2;
// mark skipped cells
// Abc_SclMarkSkippedCells( p );
vStr = Vec_StrAlloc( 1000 );
Vec_StrPrintStr( vStr, "GATE _const0_ 0.00 z=CONST0;\n" );
Vec_StrPrintStr( vStr, "GATE _const1_ 0.00 z=CONST1;\n" );
SC_LibForEachCell( p, pCell, i )
{
if ( pCell->n_inputs == 0 )
continue;
assert( strlen(pCell->pName) < 200 );
SC_CellForEachPinOut( pCell, pPinOut, j )
{
Vec_StrPrintStr( vStr, "GATE " );
sprintf( Buffer, "%-16s", pCell->pName );
Vec_StrPrintStr( vStr, Buffer );
Vec_StrPrintStr( vStr, " " );
sprintf( Buffer, "%7.2f", pCell->area );
Vec_StrPrintStr( vStr, Buffer );
Vec_StrPrintStr( vStr, " " );
Vec_StrPrintStr( vStr, pPinOut->pName );
Vec_StrPrintStr( vStr, "=" );
Vec_StrPrintStr( vStr, pPinOut->func_text ? pPinOut->func_text : "?" );
Vec_StrPrintStr( vStr, ";\n" );
SC_CellForEachPinIn( pCell, pPin, k )
{
Vec_StrPrintStr( vStr, " PIN " );
sprintf( Buffer, "%-4s", pPin->pName );
Vec_StrPrintStr( vStr, Buffer );
sprintf( Buffer, " UNKNOWN 1 999 1.00 0.00 1.00 0.00\n" );
Vec_StrPrintStr( vStr, Buffer );
}
Count++;
}
}
Vec_StrPrintStr( vStr, "\n.end\n" );
Vec_StrPush( vStr, '\0' );
// printf( "GENLIB library with %d gates is produced:\n", Count );
// printf( "%s", Vec_StrArray(vStr) );
return vStr;
}
Mio_Library_t * Abc_SclDeriveGenlibSimple( void * pScl )
{
SC_Lib * p = (SC_Lib *)pScl;
Vec_Str_t * vStr = Abc_SclProduceGenlibStrSimple( p );
Mio_Library_t * pLib = Mio_LibraryRead( p->pFileName, Vec_StrArray(vStr), NULL, 0 );
Vec_StrFree( vStr );
if ( pLib )
printf( "Internally derived GENLIB library \"%s\" with %d gates.\n", p->pName, SC_LibCellNum(p) );
else
printf( "Reading library has filed.\n" );
return pLib;
}
/**Function*************************************************************
Synopsis [Derive GENLIB library.] Synopsis [Derive GENLIB library.]
Description [] Description []
...@@ -503,7 +575,7 @@ void Abc_SclPrintCells( SC_Lib * p, float Slew, float Gain, int fInvOnly, int fS ...@@ -503,7 +575,7 @@ void Abc_SclPrintCells( SC_Lib * p, float Slew, float Gain, int fInvOnly, int fS
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Vec_Str_t * Abc_SclDeriveGenlibStr( SC_Lib * p, float Slew, float Gain, int nGatesMin, int * pnCellCount ) Vec_Str_t * Abc_SclProduceGenlibStr( SC_Lib * p, float Slew, float Gain, int nGatesMin, int * pnCellCount )
{ {
char Buffer[200]; char Buffer[200];
Vec_Str_t * vStr; Vec_Str_t * vStr;
...@@ -565,8 +637,8 @@ Vec_Str_t * Abc_SclDeriveGenlibStr( SC_Lib * p, float Slew, float Gain, int nGat ...@@ -565,8 +637,8 @@ Vec_Str_t * Abc_SclDeriveGenlibStr( SC_Lib * p, float Slew, float Gain, int nGat
} }
void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float Slew, float Gain, int nGatesMin ) void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float Slew, float Gain, int nGatesMin )
{ {
char FileName[1000];
int nCellCount = 0; int nCellCount = 0;
char FileName[1000];
Vec_Str_t * vStr; Vec_Str_t * vStr;
FILE * pFile; FILE * pFile;
if ( pFileName == NULL ) if ( pFileName == NULL )
...@@ -579,22 +651,52 @@ void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float Slew, float Gain, in ...@@ -579,22 +651,52 @@ void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float Slew, float Gain, in
printf( "Cannot open file \"%s\" for writing.\n", FileName ); printf( "Cannot open file \"%s\" for writing.\n", FileName );
return; return;
} }
vStr = Abc_SclDeriveGenlibStr( p, Slew, Gain, nGatesMin, &nCellCount ); vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, &nCellCount );
fprintf( pFile, "%s", Vec_StrArray(vStr) ); fprintf( pFile, "%s", Vec_StrArray(vStr) );
Vec_StrFree( vStr ); Vec_StrFree( vStr );
fclose( pFile ); fclose( pFile );
printf( "Written GENLIB library with %d gates into file \"%s\".\n", nCellCount, FileName ); printf( "Written GENLIB library with %d gates into file \"%s\".\n", nCellCount, FileName );
} }
void Abc_SclDeriveGenlib( void * pScl, float Slew, float Gain, int nGatesMin ) Mio_Library_t * Abc_SclDeriveGenlib( void * pScl, float Slew, float Gain, int nGatesMin )
{ {
int nGateCount = 0; int nCellCount = 0;
Vec_Str_t * vStr = Abc_SclDeriveGenlibStr( (SC_Lib *)pScl, Slew, Gain, nGatesMin, &nGateCount ); SC_Lib * p = (SC_Lib *)pScl;
Vec_Str_t * vStr2 = Vec_StrDup( vStr ); Vec_Str_t * vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, &nCellCount );
int RetValue = Mio_UpdateGenlib2( vStr, vStr2, ((SC_Lib *)pScl)->pName, 0 ); Mio_Library_t * pLib = Mio_LibraryRead( p->pFileName, Vec_StrArray(vStr), NULL, 0 );
Vec_StrFree( vStr );
if ( pLib )
printf( "Internally derived GENLIB library \"%s\" with %d gates.\n", p->pName, nCellCount );
else
printf( "Reading library has filed.\n" );
return pLib;
}
/**Function*************************************************************
Synopsis [Install library.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_SclInstallGenlib( void * pScl, float Slew, float Gain, int nGatesMin )
{
SC_Lib * p = (SC_Lib *)pScl;
Vec_Str_t * vStr, * vStr2;
int RetValue, nGateCount = SC_LibCellNum(p);
if ( Gain == 0 )
vStr = Abc_SclProduceGenlibStrSimple(p);
else
vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, &nGateCount );
vStr2 = Vec_StrDup( vStr );
RetValue = Mio_UpdateGenlib2( vStr, vStr2, p->pName, 0 );
Vec_StrFree( vStr ); Vec_StrFree( vStr );
Vec_StrFree( vStr2 ); Vec_StrFree( vStr2 );
if ( RetValue ) if ( RetValue )
printf( "Internally derived GENLIB library \"%s\" with %d gates.\n", ((SC_Lib *)pScl)->pName, nGateCount ); printf( "Internally derived GENLIB library \"%s\" with %d gates.\n", p->pName, nGateCount );
else else
printf( "Reading library has filed.\n" ); printf( "Reading library has filed.\n" );
} }
......
...@@ -848,6 +848,8 @@ void Scl_LibertyReadWireLoadSelect( Scl_Tree_t * p, Vec_Str_t * vOut ) ...@@ -848,6 +848,8 @@ void Scl_LibertyReadWireLoadSelect( Scl_Tree_t * p, Vec_Str_t * vOut )
float First = atof( strtok(pHead, " ,") ); float First = atof( strtok(pHead, " ,") );
float Second = atof( strtok(NULL, " ,") ); float Second = atof( strtok(NULL, " ,") );
char * pThird = strtok(NULL, " "); char * pThird = strtok(NULL, " ");
if ( pThird[0] == '\"' )
assert(pThird[strlen(pThird)-1] == '\"'), pThird[strlen(pThird)-1] = 0, pThird++;
Vec_StrPutF_( vOut, First ); Vec_StrPutF_( vOut, First );
Vec_StrPutF_( vOut, Second ); Vec_StrPutF_( vOut, Second );
Vec_StrPutS_( vOut, pThird ); Vec_StrPutS_( vOut, pThird );
......
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