Commit e9abb0f4 by Alan Mishchenko

Adding code to support gate profiles.

parent 0f29ba75
......@@ -74,7 +74,10 @@ Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, double AreaMulti,
{
pLib = Abc_SclDeriveGenlib( Abc_FrameReadLibScl(), Slew, Gain, nGatesMin, fVerbose );
if ( Abc_FrameReadLibGen() )
{
Mio_LibraryTransferDelays( (Mio_Library_t *)Abc_FrameReadLibGen(), pLib );
Mio_LibraryTransferProfile( pLib, (Mio_Library_t *)Abc_FrameReadLibGen() );
}
// remove supergate library
Map_SuperLibFree( (Map_SuperLib_t *)Abc_FrameReadLibSuper() );
Abc_FrameSetLibSuper( NULL );
......@@ -103,6 +106,8 @@ Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, double AreaMulti,
printf( "Converting \"%s\" into supergate library \"%s\".\n",
Mio_LibraryReadName(pLib), Extra_FileNameGenericAppend(Mio_LibraryReadName(pLib), ".super") );
// compute supergate library to be used for mapping
if ( Mio_LibraryHasProfile(pLib) )
printf( "Abc_NtkMap(): Genlib library has profile.\n" );
Map_SuperLibDeriveFromGenlib( pLib, fVerbose );
}
......
......@@ -1339,7 +1339,10 @@ void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary )
nGates = Mio_LibraryReadGateNum( (Mio_Library_t *)pNtk->pManFunc );
ppGates = Mio_LibraryReadGateArray( (Mio_Library_t *)pNtk->pManFunc );
for ( i = 0; i < nGates; i++ )
{
Mio_GateSetValue( ppGates[i], 0 );
Mio_GateSetProfile2( ppGates[i], 0 );
}
// count the gates by name
CounterTotal = 0;
......@@ -1347,6 +1350,7 @@ void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary )
{
if ( i == 0 ) continue;
Mio_GateSetValue( (Mio_Gate_t *)pObj->pData, 1 + Mio_GateReadValue((Mio_Gate_t *)pObj->pData) );
Mio_GateIncProfile2( (Mio_Gate_t *)pObj->pData );
CounterTotal++;
// assuming that twin gates follow each other
if ( Abc_NtkFetchTwinNode(pObj) )
......@@ -1371,10 +1375,12 @@ void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary )
if ( Counter == 0 )
continue;
Area = Counter * Mio_GateReadArea( ppGates[i] );
printf( "%-*s Fanin = %2d Instance = %8d Area = %10.2f %6.2f %% %s\n",
printf( "%-*s Fanin = %2d Instance = %8d Area = %10.2f %6.2f %% %8d %8d %s\n",
nGateNameLen, Mio_GateReadName( ppGates[i] ),
Mio_GateReadPinNum( ppGates[i] ),
Counter, Area, 100.0 * Area / AreaTotal,
Mio_GateReadProfile(ppGates[i]),
Mio_GateReadProfile2(ppGates[i]),
Mio_GateReadForm(ppGates[i]) );
}
printf( "%-*s Instance = %8d Area = %10.2f %6.2f %%\n",
......
......@@ -153,11 +153,15 @@ extern word Mio_GateReadTruth ( Mio_Gate_t * pGate );
extern int Mio_GateReadValue ( Mio_Gate_t * pGate );
extern int Mio_GateReadCell ( Mio_Gate_t * pGate );
extern int Mio_GateReadProfile ( Mio_Gate_t * pGate );
extern int Mio_GateReadProfile2 ( Mio_Gate_t * pGate );
extern char * Mio_GateReadPinName ( Mio_Gate_t * pGate, int iPin );
extern float Mio_GateReadPinDelay ( Mio_Gate_t * pGate, int iPin );
extern void Mio_GateSetValue ( Mio_Gate_t * pGate, int Value );
extern void Mio_GateSetCell ( Mio_Gate_t * pGate, int Cell );
extern void Mio_GateSetProfile ( Mio_Gate_t * pGate, int Prof );
extern void Mio_GateSetProfile2 ( Mio_Gate_t * pGate, int Prof );
extern void Mio_GateIncProfile2 ( Mio_Gate_t * pGate );
extern void Mio_GateDecProfile2 ( Mio_Gate_t * pGate );
extern int Mio_GateIsInv ( Mio_Gate_t * pGate );
extern char * Mio_PinReadName ( Mio_Pin_t * pPin );
extern Mio_PinPhase_t Mio_PinReadPhase ( Mio_Pin_t * pPin );
......@@ -204,6 +208,9 @@ extern void Mio_LibraryTransferDelays( Mio_Library_t * pLibD, Mio_L
extern void Mio_LibraryTransferCellIds();
extern void Mio_LibraryReadProfile( FILE * pFile, Mio_Library_t * pLib );
extern void Mio_LibraryWriteProfile( FILE * pFile, Mio_Library_t * pLib );
extern void Mio_LibraryTransferProfile( Mio_Library_t * pLibDst, Mio_Library_t * pLibSrc );
extern int Mio_LibraryHasProfile( Mio_Library_t * pLib );
extern void Mio_LibraryCleanProfile2( Mio_Library_t * pLib );
/*=== sclUtil.c =========================================================*/
extern Mio_Library_t * Abc_SclDeriveGenlibSimple( void * pScl );
......
......@@ -180,9 +180,13 @@ word * Mio_GateReadTruthP ( Mio_Gate_t * pGate ) { return
int Mio_GateReadValue ( Mio_Gate_t * pGate ) { return pGate->Value; }
int Mio_GateReadCell ( Mio_Gate_t * pGate ) { return pGate->Cell; }
int Mio_GateReadProfile ( Mio_Gate_t * pGate ) { return pGate->Profile; }
int Mio_GateReadProfile2( Mio_Gate_t * pGate ) { return pGate->Profile2; }
void Mio_GateSetValue ( Mio_Gate_t * pGate, int Value ) { pGate->Value = Value; }
void Mio_GateSetCell ( Mio_Gate_t * pGate, int Cell ) { pGate->Cell = Cell; }
void Mio_GateSetProfile ( Mio_Gate_t * pGate, int Prof ) { pGate->Profile = Prof; }
void Mio_GateSetProfile2 ( Mio_Gate_t * pGate, int Prof ) { pGate->Profile2 = Prof; }
void Mio_GateIncProfile2 ( Mio_Gate_t * pGate ) { pGate->Profile2++; }
void Mio_GateDecProfile2 ( Mio_Gate_t * pGate ) { pGate->Profile2--; }
int Mio_GateIsInv ( Mio_Gate_t * pGate ) { return pGate->uTruth == ABC_CONST(0x5555555555555555); }
/**Function*************************************************************
......
......@@ -96,6 +96,7 @@ struct Mio_GateStruct_t_
int Cell; // cell id
int nInputs; // the number of inputs
int Profile; // the number of occurrences
int Profile2; // the number of occurrences
double dDelayMax; // the maximum delay
char * pSop; // sum-of-products
Vec_Int_t * vExpr; // boolean expression
......
......@@ -413,16 +413,22 @@ Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay,
{
Mio_Gate_t * pGate;
Mio_Gate_t ** ppGates;
int i, nGates, iGate;
int i, nGates, iGate, fProfile;
nGates = Mio_LibraryReadGateNum( pLib );
ppGates = ABC_ALLOC( Mio_Gate_t *, nGates );
iGate = 0;
// check if profile is entered
fProfile = Mio_LibraryHasProfile( pLib );
if ( fProfile )
printf( "Mio_CollectRoots(): Using gate profile to select gates for mapping.\n" );
// for each functionality, select gate with the smallest area
// if equal areas, select gate with lexicographically smaller name
Mio_LibraryForEachGate( pLib, pGate )
{
if ( pGate->nInputs > nInputs )
continue;
if ( fProfile && Mio_GateReadProfile(pGate) == 0 && pGate->nInputs > 1 )
continue;
if ( tDelay > 0.0 && pGate->dDelayMax > (double)tDelay )
continue;
if ( pGate->uTruth == 0 || pGate->uTruth == ~(word)0 )
......@@ -1388,6 +1394,37 @@ void Mio_LibraryWriteProfile( FILE * pFile, Mio_Library_t * pLib )
fprintf( pFile, "%-24s %6d\n", Mio_GateReadName(pGate), Mio_GateReadProfile(pGate) );
}
int Mio_LibraryHasProfile( Mio_Library_t * pLib )
{
Mio_Gate_t * pGate;
Mio_LibraryForEachGate( pLib, pGate )
if ( Mio_GateReadProfile(pGate) > 0 )
return 1;
return 0;
}
void Mio_LibraryTransferProfile( Mio_Library_t * pLibDst, Mio_Library_t * pLibSrc )
{
Mio_Gate_t * pGateSrc, * pGateDst;
Mio_LibraryForEachGate( pLibSrc, pGateSrc )
if ( Mio_GateReadProfile(pGateSrc) > 0 )
{
pGateDst = Mio_LibraryReadGateByName( pLibDst, Mio_GateReadName(pGateSrc), NULL );
if ( pGateDst == NULL )
{
printf( "Cannot find gate \"%s\" in library \"%s\".\n", Mio_GateReadName(pGateSrc), Mio_LibraryReadName(pLibDst) );
continue;
}
Mio_GateSetProfile( pGateDst, Mio_GateReadProfile(pGateSrc) );
}
}
void Mio_LibraryCleanProfile2( Mio_Library_t * pLib )
{
Mio_Gate_t * pGate;
Mio_LibraryForEachGate( pLib, pGate )
Mio_GateSetProfile2( pGate, 0 );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
......
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