Commit 3c9f7d2b by Alan Mishchenko

Extending and improving timing manager.

parent 81e1f9fe
......@@ -199,6 +199,7 @@ extern void Mio_LibraryShiftDelay( Mio_Library_t * pLib, double Shi
extern void Mio_LibraryMultiArea( Mio_Library_t * pLib, double Multi );
extern void Mio_LibraryMultiDelay( Mio_Library_t * pLib, double Multi );
extern void Mio_LibraryTransferDelays( Mio_Library_t * pLibD, Mio_Library_t * pLibS );
extern void Mio_LibraryTransferCellIds();
/*=== sclUtil.c =========================================================*/
extern Mio_Library_t * Abc_SclDeriveGenlibSimple( void * pScl );
......
......@@ -180,7 +180,7 @@ 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; }
void Mio_GateSetValue ( Mio_Gate_t * pGate, int Value ) { pGate->Value = Value; }
void Mio_GateSetCell ( Mio_Gate_t * pGate, int Cell ) { pGate->Value = Cell; }
void Mio_GateSetCell ( Mio_Gate_t * pGate, int Cell ) { pGate->Cell = Cell; }
int Mio_GateIsInv ( Mio_Gate_t * pGate ) { return pGate->uTruth == ABC_CONST(0x5555555555555555); }
/**Function*************************************************************
......
......@@ -347,6 +347,7 @@ Mio_Gate_t * Mio_LibraryReadGate( char ** ppToken, int fExtendedFormat )
// allocate the gate structure
pGate = ABC_CALLOC( Mio_Gate_t, 1 );
pGate->Cell = -1;
// read the name
pToken = strtok( NULL, " \t\r\n" );
......
......@@ -22,6 +22,7 @@
#include "exp.h"
#include "misc/util/utilTruth.h"
#include "opt/dau/dau.h"
#include "map/scl/sclLib.h"
ABC_NAMESPACE_IMPL_START
......@@ -1305,6 +1306,45 @@ void Nf_ManPrepareLibraryTest2()
}
/**Function*************************************************************
Synopsis [Install library.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Mio_LibraryTransferCellIds()
{
Mio_Gate_t * pGate;
Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen();
SC_Lib * pScl = (SC_Lib *)Abc_FrameReadLibScl();
int CellId;
if ( pScl == NULL )
{
printf( "SC library cannot be found.\n" );
return;
}
if ( pLib == NULL )
{
printf( "Genlib library cannot be found.\n" );
return;
}
Mio_LibraryForEachGate( pLib, pGate )
{
if ( Mio_GateReadPinNum(pGate) == 0 )
continue;
CellId = Abc_SclCellFind( pScl, Mio_GateReadName(pGate) );
if ( CellId < 0 )
printf( "Cannot find cell ID of gate %s.\n", Mio_GateReadName(pGate) );
else
Mio_GateSetCell( pGate, CellId );
}
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
......
......@@ -24,6 +24,8 @@
#include "misc/util/utilNam.h"
#include "sclCon.h"
#include "map/mio/mio.h"
ABC_NAMESPACE_IMPL_START
......@@ -242,7 +244,10 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_SclWriteLiberty( Extra_FileNameGenericAppend(pFileName, "_temp.lib"), (SC_Lib *)pAbc->pLibScl );
// extract genlib library
if ( pAbc->pLibScl )
{
Abc_SclInstallGenlib( pAbc->pLibScl, Slew, Gain, nGatesMin );
Mio_LibraryTransferCellIds();
}
return 0;
usage:
......@@ -522,7 +527,10 @@ int Scl_CommandReadScl( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_SclWriteLiberty( Extra_FileNameGenericAppend(pFileName, "_temp.lib"), (SC_Lib *)pAbc->pLibScl );
// extract genlib library
if ( pAbc->pLibScl )
{
Abc_SclInstallGenlib( pAbc->pLibScl, 0, 0, 0 );
Mio_LibraryTransferCellIds();
}
return 0;
usage:
......
......@@ -605,21 +605,34 @@ static inline int Scl_LibLookupI( SC_Surface * p, int slew, int load )
// return p0 + sfrac * (p1 - p0);
return p0 + (int)sFrac;
}
static inline void Scl_LibPinArrivalI( SC_Timing * pTime, SC_PairI * pArrIn, SC_PairI * pSlewIn, SC_PairI * pLoad, SC_PairI * pArrOut, SC_PairI * pSlewOut )
static inline void Scl_LibPinArrivalI( SC_Timing * pTime, SC_PairI * pArrIn, SC_PairI * pSlewIn, SC_PairI * pLoad, SC_PairI * pArrOut, SC_PairI * pSlewOut, int * pArray )
{
if (pTime->tsense == sc_ts_Pos || pTime->tsense == sc_ts_Non)
{
pArrOut->rise = Abc_MaxInt( pArrOut->rise, pArrIn->rise + Scl_LibLookupI(&pTime->pCellRise, pSlewIn->rise, pLoad->rise) );
pArrOut->fall = Abc_MaxInt( pArrOut->fall, pArrIn->fall + Scl_LibLookupI(&pTime->pCellFall, pSlewIn->fall, pLoad->fall) );
pSlewOut->rise = Abc_MaxInt( pSlewOut->rise, Scl_LibLookupI(&pTime->pRiseTrans, pSlewIn->rise, pLoad->rise) );
pSlewOut->fall = Abc_MaxInt( pSlewOut->fall, Scl_LibLookupI(&pTime->pFallTrans, pSlewIn->fall, pLoad->fall) );
pArrOut->rise = Abc_MaxInt( pArrOut->rise, pArrIn->rise + (pArray[0] = Scl_LibLookupI(&pTime->pCellRise, pSlewIn->rise, pLoad->rise)) );
pArrOut->fall = Abc_MaxInt( pArrOut->fall, pArrIn->fall + (pArray[1] = Scl_LibLookupI(&pTime->pCellFall, pSlewIn->fall, pLoad->fall)) );
pSlewOut->rise = Abc_MaxInt( pSlewOut->rise, Scl_LibLookupI(&pTime->pRiseTrans, pSlewIn->rise, pLoad->rise) );
pSlewOut->fall = Abc_MaxInt( pSlewOut->fall, Scl_LibLookupI(&pTime->pFallTrans, pSlewIn->fall, pLoad->fall) );
}
if (pTime->tsense == sc_ts_Neg || pTime->tsense == sc_ts_Non)
{
pArrOut->rise = Abc_MaxInt( pArrOut->rise, pArrIn->fall + Scl_LibLookupI(&pTime->pCellRise, pSlewIn->fall, pLoad->rise) );
pArrOut->fall = Abc_MaxInt( pArrOut->fall, pArrIn->rise + Scl_LibLookupI(&pTime->pCellFall, pSlewIn->rise, pLoad->fall) );
pSlewOut->rise = Abc_MaxInt( pSlewOut->rise, Scl_LibLookupI(&pTime->pRiseTrans, pSlewIn->fall, pLoad->rise) );
pSlewOut->fall = Abc_MaxInt( pSlewOut->fall, Scl_LibLookupI(&pTime->pFallTrans, pSlewIn->rise, pLoad->fall) );
pArrOut->rise = Abc_MaxInt( pArrOut->rise, pArrIn->fall + (pArray[2] = Scl_LibLookupI(&pTime->pCellRise, pSlewIn->fall, pLoad->rise)) );
pArrOut->fall = Abc_MaxInt( pArrOut->fall, pArrIn->rise + (pArray[3] = Scl_LibLookupI(&pTime->pCellFall, pSlewIn->rise, pLoad->fall)) );
pSlewOut->rise = Abc_MaxInt( pSlewOut->rise, Scl_LibLookupI(&pTime->pRiseTrans, pSlewIn->fall, pLoad->rise) );
pSlewOut->fall = Abc_MaxInt( pSlewOut->fall, Scl_LibLookupI(&pTime->pFallTrans, pSlewIn->rise, pLoad->fall) );
}
}
static inline void Scl_LibPinRequiredI( SC_Timing * pTime, SC_PairI * pReqIn, SC_PairI * pReqOut, int * pArray )
{
if (pTime->tsense == sc_ts_Pos || pTime->tsense == sc_ts_Non)
{
pReqIn->rise = Abc_MinInt( pReqIn->rise, pReqOut->rise - pArray[0] );
pReqIn->fall = Abc_MinInt( pReqIn->fall, pReqOut->fall - pArray[1] );
}
if (pTime->tsense == sc_ts_Neg || pTime->tsense == sc_ts_Non)
{
pReqIn->fall = Abc_MinInt( pReqIn->fall, pReqOut->rise - pArray[2] );
pReqIn->rise = Abc_MinInt( pReqIn->rise, pReqOut->fall - pArray[3] );
}
}
......@@ -689,6 +702,7 @@ static inline void Scl_LibHandleInputDriver( SC_Cell * pCell, SC_Pair * pLoadIn,
***********************************************************************/
static inline int Scl_LibPinArrivalEstimateI( SC_Cell * pCell, int iPin, int Slew, int Load )
{
int Arrray[4];
SC_PairI LoadIn = { Load, Load };
SC_PairI ArrIn = { 0, 0 };
SC_PairI ArrOut = { 0, 0 };
......@@ -697,11 +711,12 @@ static inline int Scl_LibPinArrivalEstimateI( SC_Cell * pCell, int iPin, int Sle
// Vec_Flt_t * vIndex0 = pTime->pCellRise->vIndex0; // slew
// SlewIn.fall = SlewIn.rise = Vec_FltEntry( vIndex0, Vec_FltSize(vIndex0)/2 );
SlewIn.fall = SlewIn.rise = Slew;
Scl_LibPinArrivalI( Scl_CellPinTime(pCell, iPin), &ArrIn, &SlewIn, &LoadIn, &ArrOut, &SlewOut );
Scl_LibPinArrivalI( Scl_CellPinTime(pCell, iPin), &ArrIn, &SlewIn, &LoadIn, &ArrOut, &SlewOut, Arrray );
return (ArrOut.fall + ArrOut.rise) >> 1;
}
static inline void Scl_LibHandleInputDriver2( SC_Cell * pCell, SC_PairI * pLoadIn, SC_PairI * pArrOut, SC_PairI * pSlewOut )
{
int Arrray[4];
SC_PairI LoadIn = { 0, 0 }; // zero input load
SC_PairI ArrIn = { 0, 0 }; // zero input time
SC_PairI SlewIn = { 0, 0 }; // zero input slew
......@@ -710,8 +725,8 @@ static inline void Scl_LibHandleInputDriver2( SC_Cell * pCell, SC_PairI * pLoadI
SC_PairI SlewOut = { 0, 0 }; // output slew under zero load
pSlewOut->fall = pSlewOut->rise = 0;
assert( pCell->n_inputs == 1 );
Scl_LibPinArrivalI( Scl_CellPinTime(pCell, 0), &ArrIn, &SlewIn, &LoadIn, &ArrOut0, &SlewOut );
Scl_LibPinArrivalI( Scl_CellPinTime(pCell, 0), &ArrIn, &SlewIn, pLoadIn, &ArrOut1, pSlewOut );
Scl_LibPinArrivalI( Scl_CellPinTime(pCell, 0), &ArrIn, &SlewIn, &LoadIn, &ArrOut0, &SlewOut, Arrray );
Scl_LibPinArrivalI( Scl_CellPinTime(pCell, 0), &ArrIn, &SlewIn, pLoadIn, &ArrOut1, pSlewOut, Arrray );
pArrOut->fall = ArrOut1.fall - ArrOut0.fall;
pArrOut->rise = ArrOut1.rise - ArrOut0.rise;
}
......
......@@ -685,18 +685,20 @@ int Sfm_MffcDeref_rec( Abc_Obj_t * pObj )
}
return Area;
}
int Sfm_MffcRef_rec( Abc_Obj_t * pObj )
int Sfm_MffcRef_rec( Abc_Obj_t * pObj, Vec_Int_t * vMffc )
{
Abc_Obj_t * pFanin;
int i, Area = (int)(MIO_NUM*Mio_GateReadArea((Mio_Gate_t *)pObj->pData));
Abc_ObjForEachFanin( pObj, pFanin, i )
{
if ( pFanin->vFanouts.nSize++ == 0 && !Abc_ObjIsCi(pFanin) )
Area += Sfm_MffcRef_rec( pFanin );
Area += Sfm_MffcRef_rec( pFanin, vMffc );
}
if ( vMffc )
Vec_IntPush( vMffc, Abc_ObjId(pObj) );
return Area;
}
int Sfm_DecMffcAreaReal( Abc_Obj_t * pPivot, Vec_Int_t * vCut )
int Sfm_DecMffcAreaReal( Abc_Obj_t * pPivot, Vec_Int_t * vCut, Vec_Int_t * vMffc )
{
Abc_Ntk_t * pNtk = pPivot->pNtk;
Abc_Obj_t * pObj;
......@@ -705,7 +707,7 @@ int Sfm_DecMffcAreaReal( Abc_Obj_t * pPivot, Vec_Int_t * vCut )
Abc_NtkForEachObjVec( vCut, pNtk, pObj, i )
pObj->vFanouts.nSize++;
Area1 = Sfm_MffcDeref_rec( pPivot );
Area2 = Sfm_MffcRef_rec( pPivot );
Area2 = Sfm_MffcRef_rec( pPivot, vMffc );
Abc_NtkForEachObjVec( vCut, pNtk, pObj, i )
pObj->vFanouts.nSize--;
assert( Area1 == Area2 );
......@@ -1149,7 +1151,7 @@ int Sfm_DecPeformDec2( Sfm_Dec_t * p, Abc_Obj_t * pObj )
// compute area savings
Sfm_DecPrepareVec( &p->vObjMap, pSupp[i], nSupp[i], &p->vTemp );
AreaThis = Sfm_DecMffcAreaReal(pObj, &p->vTemp);
AreaThis = Sfm_DecMffcAreaReal(pObj, &p->vTemp, NULL);
assert( p->AreaMffc <= AreaThis );
if ( p->pPars->fZeroCost ? (AreaNew > AreaThis) : (AreaNew >= AreaThis) )
continue;
......@@ -1243,6 +1245,13 @@ int Sfm_DecPeformDec3( Sfm_Dec_t * p, Abc_Obj_t * pObj )
return RetValue;
}
// get MFFC
if ( p->pMit )
{
Sfm_DecPrepareVec( &p->vObjMap, pSupp[i], nSupp[i], &p->vTemp );
Sfm_DecMffcAreaReal(pObj, &p->vTemp, &p->vTemp2 );
}
// try the delay
p->nSuppVars = nSupp[i];
Abc_TtCopy( p->Copy, uTruth[i], SFM_WORD_MAX, 0 );
......@@ -1256,17 +1265,31 @@ int Sfm_DecPeformDec3( Sfm_Dec_t * p, Abc_Obj_t * pObj )
Vec_Int_t vFanins = { nSupp[i], nSupp[i], pSupp[i] };
int Delay;
if ( p->pMit )
Delay = Sfm_MitEvalRemapping( p->pMit, &vFanins, &p->vObjMap, pGate1, pFans1, pGate2, pFans2 );
{
DelayMin = 0;
Delay = Sfm_MitEvalRemapping( p->pMit, &p->vTemp2, pObj, &vFanins, &p->vObjMap, pGate1, pFans1, pGate2, pFans2 );
if ( DelayMin < Delay )
{
DelayMin = Delay;
pGate1Best = pGate1;
pGate2Best = pGate2;
pFans1Best = pFans1;
pFans2Best = pFans2;
iBest = i;
}
}
else
Delay = Sfm_TimEvalRemapping( p->pTim, &vFanins, &p->vObjMap, pGate1, pFans1, pGate2, pFans2 );
if ( DelayMin > Delay )
{
DelayMin = Delay;
pGate1Best = pGate1;
pGate2Best = pGate2;
pFans1Best = pFans1;
pFans2Best = pFans2;
iBest = i;
Delay = Sfm_TimEvalRemapping( p->pTim, &vFanins, &p->vObjMap, pGate1, pFans1, pGate2, pFans2 );
if ( DelayMin > Delay )
{
DelayMin = Delay;
pGate1Best = pGate1;
pGate2Best = pGate2;
pFans1Best = pFans1;
pFans2Best = pFans2;
iBest = i;
}
}
}
}
......@@ -2004,7 +2027,11 @@ p->timeSat += Abc_Clock() - clk;
assert( Vec_IntSize(&p->vObjGates) - Limit <= 2 );
p->nNodesChanged++;
Abc_NtkCountStats( p, Limit );
// reduce load due to removed MFFC
if ( p->pMit ) Sfm_MitUpdateLoad( p->pMit, &p->vTemp2, 0 ); // assuming &p->vTemp2 contains MFFC
Sfm_DecInsert( pNtk, pObj, Limit, &p->vObjGates, &p->vObjFanins, &p->vObjMap, &p->vGateHands, p->GateBuffer, p->GateInvert, &p->vGateFuncs, &p->vTemp );
// increase load due to added new nodes
if ( p->pMit ) Sfm_MitUpdateLoad( p->pMit, &p->vTemp, 1 ); // assuming &p->vTemp contains new nodes
clk = Abc_Clock();
if ( p->pMit )
Sfm_MitUpdateTiming( p->pMit, &p->vTemp );
......
......@@ -231,11 +231,12 @@ extern Sfm_Mit_t * Sfm_MitStart( Mio_Library_t * pLib, SC_Lib * pScl, Scl_Con_t
extern void Sfm_MitStop( Sfm_Mit_t * p );
extern int Sfm_MitReadNtkDelay( Sfm_Mit_t * p );
extern int Sfm_MitReadObjDelay( Sfm_Mit_t * p, int iObj );
extern void Sfm_MitUpdateLoad( Sfm_Mit_t * p, Vec_Int_t * vTimeNodes, int fAdd );
extern void Sfm_MitUpdateTiming( Sfm_Mit_t * p, Vec_Int_t * vTimeNodes );
extern int Sfm_MitSortArrayByArrival( Sfm_Mit_t * p, Vec_Int_t * vNodes, int iPivot );
extern int Sfm_MitPriorityNodes( Sfm_Mit_t * p, Vec_Int_t * vCands, int Window );
extern int Sfm_MitNodeIsNonCritical( Sfm_Mit_t * p, Abc_Obj_t * pPivot, Abc_Obj_t * pNode );
extern int Sfm_MitEvalRemapping( Sfm_Mit_t * p, Vec_Int_t * vFanins, Vec_Int_t * vMap, Mio_Gate_t * pGate1, char * pFans1, Mio_Gate_t * pGate2, char * pFans2 );
extern int Sfm_MitEvalRemapping( Sfm_Mit_t * p, Vec_Int_t * vMffc, Abc_Obj_t * pObj, Vec_Int_t * vFanins, Vec_Int_t * vMap, Mio_Gate_t * pGate1, char * pFans1, Mio_Gate_t * pGate2, char * pFans2 );
/*=== sfmWin.c ==========================================================*/
extern int Sfm_ObjMffcSize( Sfm_Ntk_t * p, int iObj );
extern int Sfm_NtkCreateWindow( Sfm_Ntk_t * p, int iNode, int fVerbose );
......
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