summaryrefslogtreecommitdiffstats
path: root/src/map/scl/scl.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2013-10-13 21:05:35 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2013-10-13 21:05:35 -0700
commita4f80c1d36ee2ea986ac3fd637aa91f97537cdb6 (patch)
tree4ddb9e218d115f3c82c5fd2f823af3c2a120ec74 /src/map/scl/scl.c
parent89cab3adec5c92d45cbb49cf4b3c9d5ed8eee2f6 (diff)
downloadabc-a4f80c1d36ee2ea986ac3fd637aa91f97537cdb6.tar.gz
abc-a4f80c1d36ee2ea986ac3fd637aa91f97537cdb6.tar.bz2
abc-a4f80c1d36ee2ea986ac3fd637aa91f97537cdb6.zip
Cleaning up buffering code.
Diffstat (limited to 'src/map/scl/scl.c')
-rw-r--r--src/map/scl/scl.c304
1 files changed, 107 insertions, 197 deletions
diff --git a/src/map/scl/scl.c b/src/map/scl/scl.c
index e5eab4c7..1c5e3354 100644
--- a/src/map/scl/scl.c
+++ b/src/map/scl/scl.c
@@ -37,14 +37,13 @@ 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_CommandBuffer ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Scl_CommandBufferOld ( 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_CommandReadConstr ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Scl_CommandPrintConstr( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -99,14 +98,13 @@ void Scl_Init( Abc_Frame_t * pAbc )
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", "buffer", Scl_CommandBuffer, 1 );
+// Cmd_CommandAdd( pAbc, "SCL mapping", "_buffer", Scl_CommandBufferOld, 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_constr", Scl_CommandReadConstr, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "print_constr", Scl_CommandPrintConstr, 0 );
@@ -803,73 +801,17 @@ usage:
SeeAlso []
***********************************************************************/
-int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv )
+int Scl_CommandUnBuffer( Abc_Frame_t * pAbc, int argc, char **argv )
{
- Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
- Abc_Ntk_t * pNtkRes;
- int FanMin, FanMax, FanMaxR, fAddInvs, fUseInvs, fBufPis, fSkipDup;
- int c, fVerbose;
- int fOldAlgo = 0;
- FanMin = 6;
- FanMax = 14;
- FanMaxR = 0;
- fAddInvs = 0;
- fUseInvs = 0;
- fBufPis = 0;
- fSkipDup = 0;
- fVerbose = 0;
+ Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
+ int c, fRemInv = 0, fVerbose = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "NMRaixpdvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "ivh" ) ) != EOF )
{
switch ( c )
{
- case 'N':
- if ( globalUtilOptind >= argc )
- {
- Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
- goto usage;
- }
- FanMin = atoi(argv[globalUtilOptind]);
- globalUtilOptind++;
- if ( FanMin < 0 )
- goto usage;
- break;
- case 'M':
- if ( globalUtilOptind >= argc )
- {
- Abc_Print( -1, "Command line switch \"-M\" should be followed by a positive integer.\n" );
- goto usage;
- }
- FanMax = atoi(argv[globalUtilOptind]);
- globalUtilOptind++;
- if ( FanMax < 0 )
- goto usage;
- break;
- case 'R':
- if ( globalUtilOptind >= argc )
- {
- Abc_Print( -1, "Command line switch \"-R\" should be followed by a positive integer.\n" );
- goto usage;
- }
- FanMaxR = atoi(argv[globalUtilOptind]);
- globalUtilOptind++;
- if ( FanMaxR < 0 )
- goto usage;
- break;
- case 'a':
- fOldAlgo ^= 1;
- break;
case 'i':
- fAddInvs ^= 1;
- break;
- case 'x':
- fUseInvs ^= 1;
- break;
- case 'p':
- fBufPis ^= 1;
- break;
- case 'd':
- fSkipDup ^= 1;
+ fRemInv ^= 1;
break;
case 'v':
fVerbose ^= 1;
@@ -883,51 +825,34 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- Abc_Print( -1, "Empty network.\n" );
+ fprintf( pAbc->Err, "There is no current network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- Abc_Print( -1, "This command can only be applied to a logic network.\n" );
- return 1;
- }
- if ( fAddInvs && pNtk->vPhases == NULL )
- {
- Abc_Print( -1, "Fanin phase information is not avaiable.\n" );
+ fprintf( pAbc->Err, "The current network is not a logic network.\n" );
return 1;
}
-
- // modify the current network
- if ( fAddInvs )
- pNtkRes = Abc_SclBufferPhase( pNtk, fVerbose );
- else if ( fOldAlgo )
- pNtkRes = Abc_SclPerformBuffering( pNtk, FanMaxR, FanMax, fUseInvs, fVerbose );
+ if ( fRemInv )
+ pNtkRes = Abc_SclUnBufferPhase( pNtk, fVerbose );
else
- pNtkRes = Abc_SclBufPerform( pNtk, FanMin, FanMax, fBufPis, fSkipDup, fVerbose );
+ pNtkRes = Abc_SclUnBufferPerform( pNtk, fVerbose );
if ( pNtkRes == NULL )
{
Abc_Print( -1, "The command has failed.\n" );
return 1;
}
- // replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
usage:
- fprintf( pAbc->Err, "usage: buffer [-NMR num] [-aixpdvh]\n" );
- fprintf( pAbc->Err, "\t performs buffering of the mapped network\n" );
- fprintf( pAbc->Err, "\t-N <num> : the min fanout considered by the algorithm [default = %d]\n", FanMin );
- fprintf( pAbc->Err, "\t-M <num> : the max allowed fanout count of node/buffer [default = %d]\n", FanMax );
- fprintf( pAbc->Err, "\t-R <num> : the max allowed fanout count of root node [default = %d]\n", FanMaxR );
- fprintf( pAbc->Err, "\t-a : toggle using old algorithm [default = %s]\n", fOldAlgo? "yes": "no" );
- fprintf( pAbc->Err, "\t-i : toggle adding interters instead of buffering [default = %s]\n", fAddInvs? "yes": "no" );
- fprintf( pAbc->Err, "\t-x : toggle using interters instead of buffers [default = %s]\n", fUseInvs? "yes": "no" );
- fprintf( pAbc->Err, "\t-p : toggle buffering primary inputs [default = %s]\n", fBufPis? "yes": "no" );
- fprintf( pAbc->Err, "\t-d : toggle disabling gate duplication [default = %s]\n", fSkipDup? "yes": "no" );
+ fprintf( pAbc->Err, "usage: unbuffer [-ivh]\n" );
+ fprintf( pAbc->Err, "\t collapses buffer/inverter trees\n" );
+ fprintf( pAbc->Err, "\t-i : toggle removing interters [default = %s]\n", fRemInv? "yes": "no" );
fprintf( pAbc->Err, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pAbc->Err, "\t-h : print the command usage\n");
return 1;
-}
+}
/**Function*************************************************************
@@ -940,7 +865,7 @@ usage:
SeeAlso []
***********************************************************************/
-int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv )
+int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv )
{
SC_BusPars Pars, * pPars = &Pars;
Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
@@ -1045,7 +970,7 @@ int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pAbc->Err, "usage: bufsize [-GSD num] [-sbpcvwh]\n" );
+ fprintf( pAbc->Err, "usage: buffer [-GSD num] [-sbpcvwh]\n" );
fprintf( pAbc->Err, "\t performs buffering and sizing and mapped network\n" );
fprintf( pAbc->Err, "\t-G <num> : target gain percentage [default = %d]\n", pPars->GainRatio );
fprintf( pAbc->Err, "\t-S <num> : target slew in pisoseconds [default = %d]\n", pPars->Slew );
@@ -1071,17 +996,73 @@ usage:
SeeAlso []
***********************************************************************/
-int Scl_CommandUnBuffer( Abc_Frame_t * pAbc, int argc, char **argv )
+int Scl_CommandBufferOld( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
- int c, fRemInv = 0, fVerbose = 0;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+ Abc_Ntk_t * pNtkRes;
+ int FanMin, FanMax, FanMaxR, fAddInvs, fUseInvs, fBufPis, fSkipDup;
+ int c, fVerbose;
+ int fOldAlgo = 0;
+ FanMin = 6;
+ FanMax = 14;
+ FanMaxR = 0;
+ fAddInvs = 0;
+ fUseInvs = 0;
+ fBufPis = 0;
+ fSkipDup = 0;
+ fVerbose = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "ivh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "NMRaixpdvh" ) ) != EOF )
{
switch ( c )
{
+ case 'N':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
+ goto usage;
+ }
+ FanMin = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( FanMin < 0 )
+ goto usage;
+ break;
+ case 'M':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-M\" should be followed by a positive integer.\n" );
+ goto usage;
+ }
+ FanMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( FanMax < 0 )
+ goto usage;
+ break;
+ case 'R':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-R\" should be followed by a positive integer.\n" );
+ goto usage;
+ }
+ FanMaxR = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( FanMaxR < 0 )
+ goto usage;
+ break;
+ case 'a':
+ fOldAlgo ^= 1;
+ break;
case 'i':
- fRemInv ^= 1;
+ fAddInvs ^= 1;
+ break;
+ case 'x':
+ fUseInvs ^= 1;
+ break;
+ case 'p':
+ fBufPis ^= 1;
+ break;
+ case 'd':
+ fSkipDup ^= 1;
break;
case 'v':
fVerbose ^= 1;
@@ -1095,34 +1076,51 @@ int Scl_CommandUnBuffer( Abc_Frame_t * pAbc, int argc, char **argv )
if ( pNtk == NULL )
{
- fprintf( pAbc->Err, "There is no current network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pAbc->Err, "The current network is not a logic network.\n" );
+ Abc_Print( -1, "This command can only be applied to a logic network.\n" );
return 1;
}
- if ( fRemInv )
- pNtkRes = Abc_SclUnBufferPhase( pNtk, fVerbose );
+ if ( fAddInvs && pNtk->vPhases == NULL )
+ {
+ Abc_Print( -1, "Fanin phase information is not avaiable.\n" );
+ return 1;
+ }
+
+ // modify the current network
+ if ( fAddInvs )
+ pNtkRes = Abc_SclBufferPhase( pNtk, fVerbose );
+ else if ( fOldAlgo )
+ pNtkRes = Abc_SclPerformBuffering( pNtk, FanMaxR, FanMax, fUseInvs, fVerbose );
else
- pNtkRes = Abc_SclUnBufferPerform( pNtk, fVerbose );
+ pNtkRes = Abc_SclBufPerform( pNtk, FanMin, FanMax, fBufPis, fSkipDup, fVerbose );
if ( pNtkRes == NULL )
{
Abc_Print( -1, "The command has failed.\n" );
return 1;
}
+ // replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
usage:
- fprintf( pAbc->Err, "usage: unbuffer [-ivh]\n" );
- fprintf( pAbc->Err, "\t collapses buffer/inverter trees\n" );
- fprintf( pAbc->Err, "\t-i : toggle removing interters [default = %s]\n", fRemInv? "yes": "no" );
+ fprintf( pAbc->Err, "usage: _buffer [-NMR num] [-aixpdvh]\n" );
+ fprintf( pAbc->Err, "\t performs buffering of the mapped network\n" );
+ fprintf( pAbc->Err, "\t-N <num> : the min fanout considered by the algorithm [default = %d]\n", FanMin );
+ fprintf( pAbc->Err, "\t-M <num> : the max allowed fanout count of node/buffer [default = %d]\n", FanMax );
+ fprintf( pAbc->Err, "\t-R <num> : the max allowed fanout count of root node [default = %d]\n", FanMaxR );
+ fprintf( pAbc->Err, "\t-a : toggle using old algorithm [default = %s]\n", fOldAlgo? "yes": "no" );
+ fprintf( pAbc->Err, "\t-i : toggle adding interters instead of buffering [default = %s]\n", fAddInvs? "yes": "no" );
+ fprintf( pAbc->Err, "\t-x : toggle using interters instead of buffers [default = %s]\n", fUseInvs? "yes": "no" );
+ fprintf( pAbc->Err, "\t-p : toggle buffering primary inputs [default = %s]\n", fBufPis? "yes": "no" );
+ fprintf( pAbc->Err, "\t-d : toggle disabling gate duplication [default = %s]\n", fSkipDup? "yes": "no" );
fprintf( pAbc->Err, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pAbc->Err, "\t-h : print the command usage\n");
return 1;
-}
+}
/**Function*************************************************************
@@ -1646,94 +1644,6 @@ usage:
SeeAlso []
***********************************************************************/
-int Scl_CommandBsize( Abc_Frame_t * pAbc, int argc, char **argv )
-{
- extern Abc_Ntk_t * Abc_SclBuffSizeStep( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nTreeCRatio, int fUseWireLoads );
- Abc_Ntk_t * pNtkRes;
- int c;
- int fUseWireLoads = 1;
- int nTreeCRatio = 0;
-
- Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "Xch" ) ) != EOF )
- {
- switch ( c )
- {
- case 'X':
- if ( globalUtilOptind >= argc )
- {
- Abc_Print( -1, "Command line switch \"-X\" should be followed by a positive integer.\n" );
- goto usage;
- }
- nTreeCRatio = atoi(argv[globalUtilOptind]);
- globalUtilOptind++;
- if ( nTreeCRatio < 0 )
- goto usage;
- break;
- case 'c':
- fUseWireLoads ^= 1;
- break;
- case 'h':
- goto usage;
- default:
- goto usage;
- }
- }
-
- if ( Abc_FrameReadNtk(pAbc) == NULL )
- {
- fprintf( pAbc->Err, "There is no current network.\n" );
- return 1;
- }
- if ( !Abc_NtkHasMapping(Abc_FrameReadNtk(pAbc)) )
- {
- fprintf( pAbc->Err, "The current network is not mapped.\n" );
- return 1;
- }
- if ( !Abc_SclCheckNtk(Abc_FrameReadNtk(pAbc), 0) )
- {
- fprintf( pAbc->Err, "The current network is not in a topo order (run \"topo\").\n" );
- return 1;
- }
- if ( pAbc->pLibScl == NULL )
- {
- fprintf( pAbc->Err, "There is no Liberty library available.\n" );
- return 1;
- }
- if ( Abc_FrameReadNtk(pAbc)->vPhases == 0 )
- {
- fprintf( pAbc->Err, "There is no phases available.\n" );
- return 1;
- }
- pNtkRes = Abc_SclBuffSizeStep( (SC_Lib *)pAbc->pLibScl, Abc_FrameReadNtk(pAbc), nTreeCRatio, fUseWireLoads );
- if ( pNtkRes == NULL )
- {
- Abc_Print( -1, "The command has failed.\n" );
- return 1;
- }
- Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
- return 0;
-
-usage:
- fprintf( pAbc->Err, "usage: bsize [-X num] [-ch]\n" );
- fprintf( pAbc->Err, "\t performs STA using Liberty library\n" );
- fprintf( pAbc->Err, "\t-X : min Cout/Cave ratio for tree estimations [default = %d]\n", nTreeCRatio );
- fprintf( pAbc->Err, "\t-c : toggle using wire-loads if specified [default = %s]\n", fUseWireLoads? "yes": "no" );
- fprintf( pAbc->Err, "\t-h : print the help massage\n" );
- return 1;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
int Scl_CommandPrintBuf( Abc_Frame_t * pAbc, int argc, char **argv )
{
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);