mirror of https://github.com/YosysHQ/abc.git
Added features 'map -M <float>' to control the use of large gates.
This commit is contained in:
parent
9abe8b66c9
commit
da6838463f
|
|
@ -13256,25 +13256,27 @@ int Abc_CommandMap( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
Abc_Ntk_t * pNtk, * pNtkRes;
|
||||
char Buffer[100];
|
||||
double DelayTarget;
|
||||
double AreaMulti;
|
||||
int fAreaOnly;
|
||||
int fRecovery;
|
||||
int fSweep;
|
||||
int fSwitching;
|
||||
int fVerbose;
|
||||
int c;
|
||||
extern Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, int fRecovery, int fSwitching, int fVerbose );
|
||||
extern Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, double AreaMulti, int fRecovery, int fSwitching, int fVerbose );
|
||||
extern int Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
|
||||
|
||||
pNtk = Abc_FrameReadNtk(pAbc);
|
||||
// set defaults
|
||||
DelayTarget =-1;
|
||||
AreaMulti = 0;
|
||||
fAreaOnly = 0;
|
||||
fRecovery = 1;
|
||||
fSweep = 1;
|
||||
fSwitching = 0;
|
||||
fVerbose = 0;
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "Darspvh" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "DMarspvh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
|
|
@ -13289,6 +13291,17 @@ int Abc_CommandMap( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
if ( DelayTarget <= 0.0 )
|
||||
goto usage;
|
||||
break;
|
||||
case 'M':
|
||||
if ( globalUtilOptind >= argc )
|
||||
{
|
||||
Abc_Print( -1, "Command line switch \"-M\" should be followed by a floating point number.\n" );
|
||||
goto usage;
|
||||
}
|
||||
AreaMulti = (float)atof(argv[globalUtilOptind]);
|
||||
globalUtilOptind++;
|
||||
if ( AreaMulti < 0.0 )
|
||||
goto usage;
|
||||
break;
|
||||
case 'a':
|
||||
fAreaOnly ^= 1;
|
||||
break;
|
||||
|
|
@ -13337,7 +13350,7 @@ int Abc_CommandMap( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
}
|
||||
Abc_Print( 0, "The network was strashed and balanced before mapping.\n" );
|
||||
// get the new network
|
||||
pNtkRes = Abc_NtkMap( pNtk, DelayTarget, fRecovery, fSwitching, fVerbose );
|
||||
pNtkRes = Abc_NtkMap( pNtk, DelayTarget, AreaMulti, fRecovery, fSwitching, fVerbose );
|
||||
if ( pNtkRes == NULL )
|
||||
{
|
||||
Abc_NtkDelete( pNtk );
|
||||
|
|
@ -13349,7 +13362,7 @@ int Abc_CommandMap( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
else
|
||||
{
|
||||
// get the new network
|
||||
pNtkRes = Abc_NtkMap( pNtk, DelayTarget, fRecovery, fSwitching, fVerbose );
|
||||
pNtkRes = Abc_NtkMap( pNtk, DelayTarget, AreaMulti, fRecovery, fSwitching, fVerbose );
|
||||
if ( pNtkRes == NULL )
|
||||
{
|
||||
Abc_Print( -1, "Mapping has failed.\n" );
|
||||
|
|
@ -13369,9 +13382,10 @@ usage:
|
|||
sprintf( Buffer, "not used" );
|
||||
else
|
||||
sprintf( Buffer, "%.3f", DelayTarget );
|
||||
Abc_Print( -2, "usage: map [-D float] [-arspvh]\n" );
|
||||
Abc_Print( -2, "usage: map [-DM float] [-arspvh]\n" );
|
||||
Abc_Print( -2, "\t performs standard cell mapping of the current network\n" );
|
||||
Abc_Print( -2, "\t-D float : sets the global required times [default = %s]\n", Buffer );
|
||||
Abc_Print( -2, "\t-M float : \"area multiplier\" to discourage large gates [default = %.2f]\n", AreaMulti );
|
||||
Abc_Print( -2, "\t-a : toggles area-only mapping [default = %s]\n", fAreaOnly? "yes": "no" );
|
||||
Abc_Print( -2, "\t-r : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
|
||||
Abc_Print( -2, "\t-s : toggles sweep after mapping [default = %s]\n", fSweep? "yes": "no" );
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ static Abc_Obj_t * Abc_NodeFromMapSuperChoice_rec( Abc_Ntk_t * pNtkNew, Map_Sup
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, int fRecovery, int fSwitching, int fVerbose )
|
||||
Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, double AreaMulti, int fRecovery, int fSwitching, int fVerbose )
|
||||
{
|
||||
int fShowSwitching = 1;
|
||||
Abc_Ntk_t * pNtkNew;
|
||||
|
|
@ -65,22 +65,31 @@ Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, int fRecovery, int
|
|||
Vec_Int_t * vSwitching = NULL;
|
||||
float * pSwitching = NULL;
|
||||
clock_t clk, clkTotal = clock();
|
||||
Mio_Library_t * pLib = Abc_FrameReadLibGen();
|
||||
|
||||
assert( Abc_NtkIsStrash(pNtk) );
|
||||
|
||||
// check that the library is available
|
||||
if ( Abc_FrameReadLibGen() == NULL )
|
||||
if ( pLib == NULL )
|
||||
{
|
||||
printf( "The current library is not available.\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// derive the supergate library
|
||||
if ( Abc_FrameReadLibSuper() == NULL && Abc_FrameReadLibGen() )
|
||||
if ( Abc_FrameReadLibSuper() == NULL && pLib )
|
||||
{
|
||||
// printf( "A simple supergate library is derived from gate library \"%s\".\n",
|
||||
// Mio_LibraryReadName((Mio_Library_t *)Abc_FrameReadLibGen()) );
|
||||
Map_SuperLibDeriveFromGenlib( (Mio_Library_t *)Abc_FrameReadLibGen() );
|
||||
|
||||
// penalize large gates by increasing their area
|
||||
Mio_LibraryShiftArea( pLib, AreaMulti );
|
||||
// compute supergate library to be used for mapping
|
||||
Map_SuperLibDeriveFromGenlib( pLib );
|
||||
// return the library to normal
|
||||
Mio_LibraryShiftArea( Abc_FrameReadLibGen(), -AreaMulti );
|
||||
if ( AreaMulti != 0.0 )
|
||||
printf( "The cell areas are multiplied by the factor: <num_fanins> ^ (%.2f).\n", AreaMulti );
|
||||
}
|
||||
|
||||
// print a warning about choice nodes
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ char * Amap_LibertyGetStringFormula( Amap_Tree_t * p, Amap_Pair_t Pair )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Amap_LibertyPrintGenlib( Amap_Tree_t * p, char * pFileName )
|
||||
int Amap_LibertyPrintGenlib( Amap_Tree_t * p, char * pFileName, int fVerbose )
|
||||
{
|
||||
FILE * pFile;
|
||||
Amap_Item_t * pCell, * pArea, * pFunc, * pPin, * pOutput;
|
||||
|
|
@ -390,24 +390,28 @@ int Amap_LibertyPrintGenlib( Amap_Tree_t * p, char * pFileName )
|
|||
continue;
|
||||
if ( Amap_LibertyCellIsFlop(p, pCell) )
|
||||
{
|
||||
printf( "Amap_LibertyPrintGenlib() skipped sequential cell \"%s\".\n", Amap_LibertyGetString(p, pCell->Head) );
|
||||
if ( fVerbose )
|
||||
printf( "Amap_LibertyPrintGenlib() skipped sequential cell \"%s\".\n", Amap_LibertyGetString(p, pCell->Head) );
|
||||
continue;
|
||||
}
|
||||
Counter = Amap_LibertyCellCountOutputs( p, pCell );
|
||||
if ( Counter == 0 )
|
||||
{
|
||||
printf( "Amap_LibertyPrintGenlib() skipped cell \"%s\" without logic function.\n", Amap_LibertyGetString(p, pCell->Head) );
|
||||
if ( fVerbose )
|
||||
printf( "Amap_LibertyPrintGenlib() skipped cell \"%s\" without logic function.\n", Amap_LibertyGetString(p, pCell->Head) );
|
||||
continue;
|
||||
}
|
||||
if ( Counter > 1 )
|
||||
{
|
||||
printf( "Amap_LibertyPrintGenlib() skipped multi-output cell \"%s\".\n", Amap_LibertyGetString(p, pCell->Head) );
|
||||
if ( fVerbose )
|
||||
printf( "Amap_LibertyPrintGenlib() skipped multi-output cell \"%s\".\n", Amap_LibertyGetString(p, pCell->Head) );
|
||||
continue;
|
||||
}
|
||||
pArea = Amap_LibertyCellArea( p, pCell );
|
||||
if ( pArea == NULL )
|
||||
{
|
||||
printf( "Amap_LibertyPrintGenlib() skipped cell \"%s\" with unspecified area.\n", Amap_LibertyGetString(p, pCell->Head) );
|
||||
if ( fVerbose )
|
||||
printf( "Amap_LibertyPrintGenlib() skipped cell \"%s\" with unspecified area.\n", Amap_LibertyGetString(p, pCell->Head) );
|
||||
continue;
|
||||
}
|
||||
pOutput = Amap_LibertyCellOutput( p, pCell );
|
||||
|
|
@ -415,7 +419,8 @@ int Amap_LibertyPrintGenlib( Amap_Tree_t * p, char * pFileName )
|
|||
pForm = Amap_LibertyGetStringFormula( p, pFunc->Head );
|
||||
if ( !strcmp(pForm, "0") || !strcmp(pForm, "1") )
|
||||
{
|
||||
printf( "Amap_LibertyPrintGenlib() skipped cell \"%s\" with constant formula \"%s\".\n", Amap_LibertyGetString(p, pCell->Head), pForm );
|
||||
if ( fVerbose )
|
||||
printf( "Amap_LibertyPrintGenlib() skipped cell \"%s\" with constant formula \"%s\".\n", Amap_LibertyGetString(p, pCell->Head), pForm );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -900,7 +905,7 @@ int Amap_LibertyParse( char * pFileName, char * pFileGenlib, int fVerbose )
|
|||
if ( fVerbose )
|
||||
printf( "Parsing finished successfully.\n" );
|
||||
// Amap_LibertyPrintLiberty( p, "temp_.lib" );
|
||||
Amap_LibertyPrintGenlib( p, "temp.genlib" );
|
||||
Amap_LibertyPrintGenlib( p, "temp.genlib", fVerbose );
|
||||
RetValue = 1;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -434,7 +434,8 @@ int Amap_LibParseEquations( Amap_Lib_t * p, int fVerbose )
|
|||
pTruth = Hop_ManConvertAigToTruth( pMan, pObj, pGate->nPins, vTruth, 0 );
|
||||
if ( Kit_TruthSupportSize(pTruth, pGate->nPins) < (int)pGate->nPins )
|
||||
{
|
||||
printf( "Skipping gate \"%s\" because its output \"%s\" does not depend on all input variables.\n", pGate->pName, pGate->pForm );
|
||||
if ( fVerbose )
|
||||
printf( "Skipping gate \"%s\" because its output \"%s\" does not depend on all input variables.\n", pGate->pName, pGate->pForm );
|
||||
continue;
|
||||
}
|
||||
pGate->pFunc = (unsigned *)Aig_MmFlexEntryFetch( p->pMemGates, sizeof(unsigned)*Abc_TruthWordNum(pGate->nPins) );
|
||||
|
|
@ -459,7 +460,7 @@ int Amap_LibParseEquations( Amap_Lib_t * p, int fVerbose )
|
|||
***********************************************************************/
|
||||
void Amap_LibParseTest( char * pFileName )
|
||||
{
|
||||
int fVerbose = 1;
|
||||
int fVerbose = 0;
|
||||
Amap_Lib_t * p;
|
||||
clock_t clk = clock();
|
||||
p = Amap_LibReadFile( pFileName, fVerbose );
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ int Mio_CommandReadLiberty( Abc_Frame_t * pAbc, int argc, char **argv )
|
|||
pErr = Abc_FrameReadErr(pAbc);
|
||||
|
||||
// set the defaults
|
||||
fVerbose = 1;
|
||||
fVerbose = 0;
|
||||
Extra_UtilGetoptReset();
|
||||
while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF )
|
||||
{
|
||||
|
|
@ -295,7 +295,7 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
|
|||
}
|
||||
// add the fixed number (wire delay) to all delays in the library
|
||||
if ( WireDelay != 0.0 )
|
||||
Mio_LibraryShift( pLib, WireDelay );
|
||||
Mio_LibraryShiftDelay( pLib, WireDelay );
|
||||
|
||||
// free the current superlib because it depends on the old Mio library
|
||||
if ( Abc_FrameReadLibSuper() )
|
||||
|
|
@ -309,7 +309,7 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
|
|||
Abc_FrameSetLibGen( pLib );
|
||||
|
||||
// set the new network
|
||||
pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( FileName, 1, 0 );
|
||||
pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( FileName, 0, 0 );
|
||||
if ( pLib == NULL )
|
||||
{
|
||||
fprintf( pErr, "Reading GENLIB library has failed.\n" );
|
||||
|
|
|
|||
|
|
@ -149,7 +149,8 @@ extern void Mio_DeriveGateDelays( Mio_Gate_t * pGate,
|
|||
float ** ptPinDelays, int nPins, int nInputs, float tDelayZero,
|
||||
float * ptDelaysRes, float * ptPinDelayMax );
|
||||
extern Mio_Gate_t * Mio_GateCreatePseudo( int nInputs );
|
||||
extern void Mio_LibraryShift( Mio_Library_t * pLib, double Shift );
|
||||
extern void Mio_LibraryShiftDelay( Mio_Library_t * pLib, double Shift );
|
||||
extern void Mio_LibraryShiftArea( Mio_Library_t * pLib, double Shift );
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
***********************************************************************/
|
||||
|
||||
#include <math.h>
|
||||
#include "mioInt.h"
|
||||
#include "base/main/main.h"
|
||||
#include "exp.h"
|
||||
|
|
@ -591,7 +592,7 @@ Mio_Gate_t * Mio_GateCreatePseudo( int nInputs )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Mio_LibraryShift( Mio_Library_t * pLib, double Shift )
|
||||
void Mio_LibraryShiftDelay( Mio_Library_t * pLib, double Shift )
|
||||
{
|
||||
Mio_Gate_t * pGate;
|
||||
Mio_Pin_t * pPin;
|
||||
|
|
@ -607,6 +608,28 @@ void Mio_LibraryShift( Mio_Library_t * pLib, double Shift )
|
|||
}
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Multiply areas of all gates by values proportional to fanin count.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Mio_LibraryShiftArea( Mio_Library_t * pLib, double Shift )
|
||||
{
|
||||
Mio_Gate_t * pGate;
|
||||
Mio_LibraryForEachGate( pLib, pGate )
|
||||
{
|
||||
// printf( "Before %8.3f ", pGate->dArea );
|
||||
pGate->dArea *= pow( pGate->nInputs, Shift );
|
||||
// printf( "After %8.3f Inputs = %d. Factor = %8.3f\n", pGate->dArea, pGate->nInputs, pow( pGate->nInputs, Shift ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
|
|
|
|||
Loading…
Reference in New Issue