summaryrefslogtreecommitdiffstats
path: root/src/map/scl/scl.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2015-09-08 19:53:49 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2015-09-08 19:53:49 -0700
commit97751e43b71792ded1947d98945e1e832325be6d (patch)
tree2b88dea48591c73d70bc4172f449de9a6b77bd5b /src/map/scl/scl.c
parentf623b04da47aaa2810c06b880f85354becef288e (diff)
downloadabc-97751e43b71792ded1947d98945e1e832325be6d.tar.gz
abc-97751e43b71792ded1947d98945e1e832325be6d.tar.bz2
abc-97751e43b71792ded1947d98945e1e832325be6d.zip
New constraint manager and memory reporting 'ps'.
Diffstat (limited to 'src/map/scl/scl.c')
-rw-r--r--src/map/scl/scl.c92
1 files changed, 90 insertions, 2 deletions
diff --git a/src/map/scl/scl.c b/src/map/scl/scl.c
index bd917ca3..8f788628 100644
--- a/src/map/scl/scl.c
+++ b/src/map/scl/scl.c
@@ -21,6 +21,9 @@
#include "sclSize.h"
#include "base/main/mainInt.h"
+#include "misc/util/utilNam.h"
+#include "sclCon.h"
+
ABC_NAMESPACE_IMPL_START
@@ -47,9 +50,15 @@ 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_CommandPrintBuf ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Scl_CommandReadConstr ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Scl_CommandWriteConstr( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Scl_CommandPrintConstr( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Scl_CommandResetConstr( Abc_Frame_t * pAbc, int argc, char ** argv );
+static inline Scl_Con_t * Scl_ConGetMan( Abc_Frame_t * pAbc ) { return (Scl_Con_t *)pAbc->pAbcCon; }
+static inline void Scl_ConFreeMan( Abc_Frame_t * pAbc ) { if ( pAbc->pAbcCon ) Scl_ConFree(Scl_ConGetMan(pAbc)); }
+static inline void Scl_ConUpdateMan( Abc_Frame_t * pAbc, Scl_Con_t * p ) { Scl_ConFreeMan(pAbc); pAbc->pAbcCon = p; }
+ Scl_Con_t * Scl_ConReadMan() { return Scl_ConGetMan( Abc_FrameGetGlobalFrame() ); }
+
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -109,12 +118,14 @@ void Scl_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "SCL mapping", "dnsize", Scl_CommandDnsize, 1 );
Cmd_CommandAdd( pAbc, "SCL mapping", "print_buf", Scl_CommandPrintBuf, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "read_constr", Scl_CommandReadConstr, 0 );
+ Cmd_CommandAdd( pAbc, "SCL mapping", "write_constr", Scl_CommandWriteConstr, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "print_constr", Scl_CommandPrintConstr, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "reset_constr", Scl_CommandResetConstr, 0 );
}
void Scl_End( Abc_Frame_t * pAbc )
{
Abc_SclLoad( NULL, (SC_Lib **)&pAbc->pLibScl );
+ Scl_ConUpdateMan( pAbc, NULL );
}
@@ -1799,7 +1810,9 @@ usage:
***********************************************************************/
int Scl_CommandReadConstr( Abc_Frame_t * pAbc, int argc, char ** argv )
{
+ extern Abc_Nam_t * Abc_NtkNameMan( Abc_Ntk_t * p, int fOuts );
extern void Abc_SclReadTimingConstr( Abc_Frame_t * pAbc, char * pFileName, int fVerbose );
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
FILE * pFile;
char * pFileName;
int c, fVerbose = 0;
@@ -1830,6 +1843,13 @@ int Scl_CommandReadConstr( Abc_Frame_t * pAbc, int argc, char ** argv )
}
fclose( pFile );
Abc_SclReadTimingConstr( pAbc, pFileName, fVerbose );
+
+ // input constraint manager
+ if ( pNtk )
+ {
+ Scl_Con_t * pCon = Scl_ConRead( pFileName, Abc_NtkNameMan(pNtk, 0), Abc_NtkNameMan(pNtk, 1) );
+ if ( pCon ) Scl_ConUpdateMan( pAbc, pCon );
+ }
return 0;
usage:
@@ -1852,8 +1872,72 @@ usage:
SeeAlso []
***********************************************************************/
+int Scl_CommandWriteConstr( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Scl_Con_t * pCon = Scl_ConGetMan( pAbc );
+ char * pFileName = NULL;
+ 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 ( pCon == NULL )
+ {
+ Abc_Print( 1, "Scl_CommandWriteConstr(): There is no constraint manager.\n" );
+ return 0;
+ }
+ if ( argc == globalUtilOptind + 1 )
+ pFileName = argv[globalUtilOptind];
+ else if ( argc == globalUtilOptind && pCon )
+ pFileName = Extra_FileNameGenericAppend( pCon->pFileName, "_out.constr" );
+ else
+ {
+ printf( "Output file name should be given on the command line.\n" );
+ return 0;
+ }
+ // perform writing
+ if ( !strcmp( Extra_FileNameExtension(pFileName), "constr" ) )
+ Scl_ConWrite( pCon, pFileName );
+ else
+ {
+ printf( "Scl_CommandWriteConstr(): Unrecognized output file extension.\n" );
+ return 0;
+ }
+ return 0;
+
+usage:
+ fprintf( pAbc->Err, "usage: write_constr [-vh] <file>\n" );
+ fprintf( pAbc->Err, "\t writes current timing constraints into a file\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<file> : 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 )
{
+ Scl_Con_t * pCon = Scl_ConGetMan( pAbc );
int c, fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
@@ -1869,8 +1953,10 @@ int Scl_CommandPrintConstr( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- printf( "Primary input driving cell = %s\n", Abc_FrameReadDrivingCell() );
- printf( "Primary output maximum load = %f\n", Abc_FrameReadMaxLoad() );
+ //printf( "Primary input driving cell = %s\n", Abc_FrameReadDrivingCell() );
+ //printf( "Primary output maximum load = %f\n", Abc_FrameReadMaxLoad() );
+
+ if ( pCon ) Scl_ConWrite( pCon, NULL );
return 0;
usage:
@@ -1912,6 +1998,8 @@ int Scl_CommandResetConstr( Abc_Frame_t * pAbc, int argc, char ** argv )
}
Abc_FrameSetDrivingCell( NULL );
Abc_FrameSetMaxLoad( 0 );
+
+ Scl_ConUpdateMan( pAbc, NULL );
return 0;
usage: