From 73a997a8bd303b4398e64de2d3a0bfb3f85a3acf Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 17 Sep 2013 14:47:34 -0700 Subject: Adding commands to set and print timing constraints. --- src/base/main/main.h | 5 ++ src/base/main/mainFrame.c | 6 ++ src/base/main/mainInt.h | 3 + src/map/scl/scl.c | 173 ++++++++++++++++++++++++++++++++++++---------- src/map/scl/sclBuffer.c | 8 ++- src/map/scl/sclSize.c | 24 +++++++ src/map/scl/sclSize.h | 1 + src/map/scl/sclUtil.c | 35 ++++++++++ 8 files changed, 217 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/base/main/main.h b/src/base/main/main.h index 7d9b7292..a55ff06c 100644 --- a/src/base/main/main.h +++ b/src/base/main/main.h @@ -146,6 +146,11 @@ extern ABC_DLL void Abc_FrameReplaceCexVec( Abc_Frame_t * pAbc, Vec_P extern ABC_DLL void Abc_FrameReplacePoEquivs( Abc_Frame_t * pAbc, Vec_Ptr_t ** pvPoEquivs ); extern ABC_DLL void Abc_FrameReplacePoStatuses( Abc_Frame_t * pAbc, Vec_Int_t ** pvStatuses ); +extern ABC_DLL char * Abc_FrameReadDrivingCell(); +extern ABC_DLL float Abc_FrameReadMaxLoad(); +extern ABC_DLL void Abc_FrameSetDrivingCell( char * pName ); +extern ABC_DLL void Abc_FrameSetMaxLoad( float Load ); + ABC_NAMESPACE_HEADER_END #endif diff --git a/src/base/main/mainFrame.c b/src/base/main/mainFrame.c index ee4b665e..796c04de 100644 --- a/src/base/main/mainFrame.c +++ b/src/base/main/mainFrame.c @@ -91,6 +91,11 @@ int Abc_FrameIsBatchMode() { return s_GlobalFr int Abc_FrameIsBridgeMode() { return s_GlobalFrame ? s_GlobalFrame->fBridgeMode : 0; } void Abc_FrameSetBridgeMode() { if ( s_GlobalFrame ) s_GlobalFrame->fBridgeMode = 1; } +char * Abc_FrameReadDrivingCell() { return s_GlobalFrame->pDrivingCell; } +float Abc_FrameReadMaxLoad() { return s_GlobalFrame->MaxLoad; } +void Abc_FrameSetDrivingCell( char * pName ) { ABC_FREE(s_GlobalFrame->pDrivingCell); s_GlobalFrame->pDrivingCell = pName; } +void Abc_FrameSetMaxLoad( float Load ) { s_GlobalFrame->MaxLoad = Load; } + /**Function************************************************************* Synopsis [Returns 1 if the flag is enabled without value or with value 1.] @@ -199,6 +204,7 @@ void Abc_FrameDeallocate( Abc_Frame_t * p ) } Vec_PtrFreeP( &p->vLTLProperties_global ); Abc_FrameDeleteAllNetworks( p ); + ABC_FREE( p->pDrivingCell ); ABC_FREE( p->pCex2 ); ABC_FREE( p->pCex ); ABC_FREE( p ); diff --git a/src/base/main/mainInt.h b/src/base/main/mainInt.h index acd8bbd3..cf1a9376 100644 --- a/src/base/main/mainInt.h +++ b/src/base/main/mainInt.h @@ -93,6 +93,9 @@ struct Abc_Frame_t_ void * pLibSuper; // the current supergate library void * pLibVer; // the current Verilog library void * pLibScl; // the current Liberty library + // timing constraints + char * pDrivingCell; // name of the driving cell + float MaxLoad; // maximum output load // new code Gia_Man_t * pGia; // alternative current network as a light-weight AIG diff --git a/src/map/scl/scl.c b/src/map/scl/scl.c index 2957a325..82429a79 100644 --- a/src/map/scl/scl.c +++ b/src/map/scl/scl.c @@ -28,24 +28,26 @@ ABC_NAMESPACE_IMPL_START /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// -static int Scl_CommandReadLib ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandWriteLib( 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_CommandDumpGen ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandPrintGS ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandStime ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandTopo ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandBuffer ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandBufSize ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandUnBuffer( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandMinsize ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandMaxsize ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandUpsize ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandDnsize ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandBsize ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandPrintBuf( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandReadLib ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandWriteLib ( 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_CommandDumpGen ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandPrintGS ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandStime ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandTopo ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandBuffer ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandBufSize ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandUnBuffer ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandMinsize ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandMaxsize ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandUpsize ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandDnsize ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandBsize ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandPrintBuf ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandSetConstr ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandPrintConstr( Abc_Frame_t * pAbc, int argc, char **argv ); //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// @@ -87,24 +89,26 @@ void Abc_SclLoad( SC_Lib * pLib, SC_Lib ** ppScl ) ***********************************************************************/ void Scl_Init( Abc_Frame_t * pAbc ) { - Cmd_CommandAdd( pAbc, "SCL mapping", "read_lib", Scl_CommandReadLib, 0 ); - Cmd_CommandAdd( pAbc, "SCL mapping", "write_lib", Scl_CommandWriteLib, 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", "print_gs", Scl_CommandPrintGS, 0 ); - Cmd_CommandAdd( pAbc, "SCL mapping", "stime", Scl_CommandStime, 0 ); - Cmd_CommandAdd( pAbc, "SCL mapping", "topo", Scl_CommandTopo, 1 ); - Cmd_CommandAdd( pAbc, "SCL mapping", "buffer", Scl_CommandBuffer, 1 ); - Cmd_CommandAdd( pAbc, "SCL mapping", "bufsize", Scl_CommandBufSize, 1 ); - Cmd_CommandAdd( pAbc, "SCL mapping", "unbuffer", Scl_CommandUnBuffer, 1 ); - Cmd_CommandAdd( pAbc, "SCL mapping", "minsize", Scl_CommandMinsize, 1 ); - Cmd_CommandAdd( pAbc, "SCL mapping", "maxsize", Scl_CommandMaxsize, 1 ); - Cmd_CommandAdd( pAbc, "SCL mapping", "upsize", Scl_CommandUpsize, 1 ); - Cmd_CommandAdd( pAbc, "SCL mapping", "dnsize", Scl_CommandDnsize, 1 ); - Cmd_CommandAdd( pAbc, "SCL mapping", "bsize", Scl_CommandBsize, 1 ); - Cmd_CommandAdd( pAbc, "SCL mapping", "print_buf", Scl_CommandPrintBuf, 0 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "read_lib", Scl_CommandReadLib, 0 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "write_lib", Scl_CommandWriteLib, 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", "print_gs", Scl_CommandPrintGS, 0 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "stime", Scl_CommandStime, 0 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "topo", Scl_CommandTopo, 1 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "buffer", Scl_CommandBuffer, 1 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "bufsize", Scl_CommandBufSize, 1 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "unbuffer", Scl_CommandUnBuffer, 1 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "minsize", Scl_CommandMinsize, 1 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "maxsize", Scl_CommandMaxsize, 1 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "upsize", Scl_CommandUpsize, 1 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "dnsize", Scl_CommandDnsize, 1 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "bsize", Scl_CommandBsize, 1 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "print_buf", Scl_CommandPrintBuf, 0 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "set_constr", Scl_CommandSetConstr, 0 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "print_constr", Scl_CommandPrintConstr,0 ); } void Scl_End( Abc_Frame_t * pAbc ) { @@ -1770,6 +1774,103 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Scl_CommandSetConstr( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Abc_SclReadTimingConstr( Abc_Frame_t * pAbc, char * pFileName, int fVerbose ); + FILE * pFile; + char * pFileName; + int c, fVerbose = 0; + + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) + { + switch ( c ) + { + case 'v': + fVerbose ^= 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 ); + Abc_SclReadTimingConstr( pAbc, pFileName, fVerbose ); + return 0; + +usage: + fprintf( pAbc->Err, "usage: set_constr [-vh] \n" ); + fprintf( pAbc->Err, "\t sets timing constraints for standard-cell designs\n" ); + fprintf( pAbc->Err, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); + fprintf( pAbc->Err, "\t-h : prints the command summary\n" ); + fprintf( pAbc->Err, "\t : the name of a file to read\n" ); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Scl_CommandPrintConstr( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + int c, fVerbose = 0; + + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) + { + switch ( c ) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + printf( "Primary input driving cell = %s\n", Abc_FrameReadDrivingCell() ); + printf( "Primary output maximum load = %f\n", Abc_FrameReadMaxLoad() ); + return 0; + +usage: + fprintf( pAbc->Err, "usage: print_constr [-vh] \n" ); + fprintf( pAbc->Err, "\t prints current timing constraints\n" ); + fprintf( pAbc->Err, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); + fprintf( pAbc->Err, "\t-h : prints the command summary\n" ); + fprintf( pAbc->Err, "\t : the name of a file to read\n" ); + return 1; +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/map/scl/sclBuffer.c b/src/map/scl/sclBuffer.c index a90514a6..15a6bdce 100644 --- a/src/map/scl/sclBuffer.c +++ b/src/map/scl/sclBuffer.c @@ -511,6 +511,8 @@ float Abc_BufComputeArr( Buf_Man_t * p, Abc_Obj_t * pObj ) float DelayF, Delay = -ABC_INFINITY; Abc_ObjForEachFanin( pObj, pFanin, i ) { + if ( Vec_IntEntry(p->vOffsets, Abc_ObjId(pObj)) == -ABC_INFINITY ) + continue; DelayF = Abc_BufNodeArr(p, pFanin) + Abc_BufEdgeDelay(p, pObj, i); if ( Delay < DelayF ) Delay = DelayF; @@ -525,6 +527,8 @@ float Abc_BufComputeDep( Buf_Man_t * p, Abc_Obj_t * pObj ) float DelayF, Delay = -ABC_INFINITY; Abc_ObjForEachFanout( pObj, pFanout, i ) { + if ( Vec_IntEntry(p->vOffsets, Abc_ObjId(pFanout)) == -ABC_INFINITY ) + continue; DelayF = Abc_BufNodeDep(p, pFanout) + Abc_BufEdgeDelay(p, pFanout, Abc_NodeFindFanin(pFanout, pObj)); if ( Delay < DelayF ) Delay = DelayF; @@ -752,12 +756,12 @@ void Buf_ManStop( Buf_Man_t * p ) Vec_Int_t * Abc_BufSortByDelay( Buf_Man_t * p, int iPivot ) { Abc_Obj_t * pObj, * pFanout; - int i, * pOrder; + int i, Slack, * pOrder; Vec_IntClear( p->vDelays ); pObj = Abc_NtkObj( p->pNtk, iPivot ); Abc_ObjForEachFanout( pObj, pFanout, i ) { - int Slack = Abc_BufEdgeSlack(p, pObj, pFanout); + Slack = Abc_BufEdgeSlack(p, pObj, pFanout); assert( Slack >= 0 ); Vec_IntPush( p->vDelays, Abc_MaxInt(0, Slack) ); } diff --git a/src/map/scl/sclSize.c b/src/map/scl/sclSize.c index ec26d261..dce76988 100644 --- a/src/map/scl/sclSize.c +++ b/src/map/scl/sclSize.c @@ -21,6 +21,7 @@ #include "sclSize.h" #include "map/mio/mio.h" #include "misc/vec/vecWec.h" +#include "base/main/main.h" ABC_NAMESPACE_IMPL_START @@ -505,6 +506,29 @@ void Abc_SclManReadSlewAndLoad( SC_Man * p, Abc_Ntk_t * pNtk ) Abc_Time_t * pTime; Abc_Obj_t * pObj; int i; + if ( Abc_FrameReadMaxLoad() ) + { + float MaxLoad = Abc_FrameReadMaxLoad(); +// printf( "Default output load is specified (%f ff).\n", SC_LibCapFf(p->pLib, MaxLoad) ); + Abc_NtkForEachPo( pNtk, pObj, i ) + { + SC_Pair * pLoad = Abc_SclObjLoad( p, pObj ); + pLoad->rise = SC_LibCapFromFf( p->pLib, MaxLoad ); + pLoad->fall = SC_LibCapFromFf( p->pLib, MaxLoad ); + } + } + if ( Abc_FrameReadDrivingCell() ) + { + int iCell = Abc_SclCellFind( p->pLib, Abc_FrameReadDrivingCell() ); + if ( iCell == -1 ) + printf( "Cannot find the default PI driving cell (%s) in the library.\n", Abc_FrameReadDrivingCell() ); + else + { +// printf( "Default PI driving cell is specified (%s).\n", Abc_FrameReadDrivingCell() ); + p->pPiDrive = SC_LibCell( p->pLib, iCell ); + assert( p->pPiDrive != NULL ); + } + } if ( pNtk->pManTime == NULL ) return; /* diff --git a/src/map/scl/sclSize.h b/src/map/scl/sclSize.h index c2be1614..f4a937c2 100644 --- a/src/map/scl/sclSize.h +++ b/src/map/scl/sclSize.h @@ -61,6 +61,7 @@ struct SC_Man_ Vec_Flt_t * vInDrive; // maximum input drive strength Vec_Flt_t * vTimesOut; // output arrival times Vec_Que_t * vQue; // outputs by their time + SC_Cell * pPiDrive; // cell driving primary inputs // backup information Vec_Flt_t * vLoads2; // backup storage for loads Vec_Flt_t * vLoads3; // backup storage for loads diff --git a/src/map/scl/sclUtil.c b/src/map/scl/sclUtil.c index 45980b6f..2d73a375 100644 --- a/src/map/scl/sclUtil.c +++ b/src/map/scl/sclUtil.c @@ -218,6 +218,41 @@ char * Abc_SclFindGateFormula( char * pGateName, char * pOutName ) return Mio_GateReadForm(pGate); } +/**Function************************************************************* + + Synopsis [Reads timing constraints.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Abc_SclReadTimingConstr( Abc_Frame_t * pAbc, char * pFileName, int fVerbose ) +{ + char Buffer[1000], * pToken; + FILE * pFile = fopen( pFileName, "rb" ); + while ( fgets( Buffer, 1000, pFile ) ) + { + pToken = strtok( Buffer, " \t\r\n" ); + if ( !strcmp(pToken, "set_driving_cell") ) + { + Abc_FrameSetDrivingCell( Abc_UtilStrsav(strtok(NULL, " \t\r\n")) ); + if ( fVerbose ) + printf( "Setting driving cell to be \"%s\".\n", Abc_FrameReadDrivingCell() ); + } + else if ( !strcmp(pToken, "set_load") ) + { + Abc_FrameSetMaxLoad( atof(strtok(NULL, " \t\r\n")) ); + if ( fVerbose ) + printf( "Setting driving cell to be %f.\n", Abc_FrameReadMaxLoad() ); + } + else + printf( "Unrecognized token \"%s\".\n", pToken ); + } + fclose( pFile ); +} //////////////////////////////////////////////////////////////////////// /// END OF FILE /// -- cgit v1.2.3