Commit 96d8f899 by Alan Mishchenko

Extending and improving timing manager.

parent e50fc467
...@@ -2535,6 +2535,10 @@ SOURCE=.\src\opt\sfm\sfmLib.c ...@@ -2535,6 +2535,10 @@ SOURCE=.\src\opt\sfm\sfmLib.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\opt\sfm\sfmMit.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\sfm\sfmNtk.c SOURCE=.\src\opt\sfm\sfmNtk.c
# End Source File # End Source File
# Begin Source File # Begin Source File
...@@ -2543,7 +2547,7 @@ SOURCE=.\src\opt\sfm\sfmSat.c ...@@ -2543,7 +2547,7 @@ SOURCE=.\src\opt\sfm\sfmSat.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\opt\sfm\sfmTime.c SOURCE=.\src\opt\sfm\sfmTim.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -178,7 +178,9 @@ Vec_Int_t * Mio_GateReadExpr ( Mio_Gate_t * pGate ) { return ...@@ -178,7 +178,9 @@ Vec_Int_t * Mio_GateReadExpr ( Mio_Gate_t * pGate ) { return
word Mio_GateReadTruth ( Mio_Gate_t * pGate ) { return pGate->nInputs <= 6 ? pGate->uTruth : 0; } word Mio_GateReadTruth ( Mio_Gate_t * pGate ) { return pGate->nInputs <= 6 ? pGate->uTruth : 0; }
word * Mio_GateReadTruthP ( Mio_Gate_t * pGate ) { return pGate->nInputs <= 6 ? NULL: pGate->pTruth; } word * Mio_GateReadTruthP ( Mio_Gate_t * pGate ) { return pGate->nInputs <= 6 ? NULL: pGate->pTruth; }
int Mio_GateReadValue ( Mio_Gate_t * pGate ) { return pGate->Value; } 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_GateSetValue ( Mio_Gate_t * pGate, int Value ) { pGate->Value = Value; }
void Mio_GateSetCell ( Mio_Gate_t * pGate, int Cell ) { pGate->Value = Cell; }
int Mio_GateIsInv ( Mio_Gate_t * pGate ) { return pGate->uTruth == ABC_CONST(0x5555555555555555); } int Mio_GateIsInv ( Mio_Gate_t * pGate ) { return pGate->uTruth == ABC_CONST(0x5555555555555555); }
/**Function************************************************************* /**Function*************************************************************
......
...@@ -93,6 +93,7 @@ struct Mio_GateStruct_t_ ...@@ -93,6 +93,7 @@ struct Mio_GateStruct_t_
Mio_Gate_t * pTwin; Mio_Gate_t * pTwin;
// the derived information // the derived information
int Cell; // cell id
int nInputs; // the number of inputs int nInputs; // the number of inputs
double dDelayMax; // the maximum delay double dDelayMax; // the maximum delay
char * pSop; // sum-of-products char * pSop; // sum-of-products
......
...@@ -65,6 +65,12 @@ struct SC_Pair_ ...@@ -65,6 +65,12 @@ struct SC_Pair_
float rise; float rise;
float fall; float fall;
}; };
typedef struct SC_PairI_ SC_PairI;
struct SC_PairI_
{
int rise;
int fall;
};
typedef struct SC_SizePars_ SC_SizePars; typedef struct SC_SizePars_ SC_SizePars;
struct SC_SizePars_ struct SC_SizePars_
...@@ -144,6 +150,9 @@ struct SC_Surface_ ...@@ -144,6 +150,9 @@ struct SC_Surface_
Vec_Flt_t vIndex0; // Vec<float> -- correspondes to "index_1" in the liberty file (for timing: slew) Vec_Flt_t vIndex0; // Vec<float> -- correspondes to "index_1" in the liberty file (for timing: slew)
Vec_Flt_t vIndex1; // Vec<float> -- correspondes to "index_2" in the liberty file (for timing: load) Vec_Flt_t vIndex1; // Vec<float> -- correspondes to "index_2" in the liberty file (for timing: load)
Vec_Ptr_t vData; // Vec<Vec<float> > -- 'data[i0][i1]' gives value at '(index0[i0], index1[i1])' Vec_Ptr_t vData; // Vec<Vec<float> > -- 'data[i0][i1]' gives value at '(index0[i0], index1[i1])'
Vec_Int_t vIndex0I; // Vec<float> -- correspondes to "index_1" in the liberty file (for timing: slew)
Vec_Int_t vIndex1I; // Vec<float> -- correspondes to "index_2" in the liberty file (for timing: load)
Vec_Ptr_t vDataI; // Vec<Vec<float> > -- 'data[i0][i1]' gives value at '(index0[i0], index1[i1])'
float approx[3][6]; float approx[3][6];
}; };
...@@ -171,6 +180,8 @@ struct SC_Pin_ ...@@ -171,6 +180,8 @@ struct SC_Pin_
float cap; // -- this value is used if 'rise_cap' and 'fall_cap' is missing (copied by 'postProcess()'). (not used) float cap; // -- this value is used if 'rise_cap' and 'fall_cap' is missing (copied by 'postProcess()'). (not used)
float rise_cap; // }- used for input pins ('cap' too). float rise_cap; // }- used for input pins ('cap' too).
float fall_cap; // } float fall_cap; // }
float rise_capI; // }- used for input pins ('cap' too).
float fall_capI; // }
float max_out_cap; // } (not used) float max_out_cap; // } (not used)
float max_out_slew; // }- used only for output pins (max values must not be exceeded or else mapping is illegal) (not used) float max_out_slew; // }- used only for output pins (max values must not be exceeded or else mapping is illegal) (not used)
char * func_text; // } char * func_text; // }
...@@ -188,6 +199,8 @@ struct SC_Cell_ ...@@ -188,6 +199,8 @@ struct SC_Cell_
int unsupp; // -- set to TRUE by parser if cell contains information we cannot handle int unsupp; // -- set to TRUE by parser if cell contains information we cannot handle
float area; float area;
float leakage; float leakage;
float areaI;
float leakageI;
int drive_strength; // -- some library files provide this field (currently unused, but may be a good hint for sizing) (not used) int drive_strength; // -- some library files provide this field (currently unused, but may be a good hint for sizing) (not used)
Vec_Ptr_t vPins; // NamedSet<SC_Pin> Vec_Ptr_t vPins; // NamedSet<SC_Pin>
int n_inputs; // -- 'pins[0 .. n_inputs-1]' are input pins int n_inputs; // -- 'pins[0 .. n_inputs-1]' are input pins
...@@ -372,7 +385,10 @@ static inline void Abc_SclSurfaceFree( SC_Surface * p ) ...@@ -372,7 +385,10 @@ static inline void Abc_SclSurfaceFree( SC_Surface * p )
{ {
Vec_FltErase( &p->vIndex0 ); Vec_FltErase( &p->vIndex0 );
Vec_FltErase( &p->vIndex1 ); Vec_FltErase( &p->vIndex1 );
Vec_IntErase( &p->vIndex0I );
Vec_IntErase( &p->vIndex1I );
Vec_VecErase( (Vec_Vec_t *)&p->vData ); Vec_VecErase( (Vec_Vec_t *)&p->vData );
Vec_VecErase( (Vec_Vec_t *)&p->vDataI );
ABC_FREE( p->pName ); ABC_FREE( p->pName );
// ABC_FREE( p ); // ABC_FREE( p );
} }
...@@ -531,6 +547,84 @@ static inline void Scl_LibPinDeparture( SC_Timing * pTime, SC_Pair * pDepIn, SC_ ...@@ -531,6 +547,84 @@ static inline void Scl_LibPinDeparture( SC_Timing * pTime, SC_Pair * pDepIn, SC_
/**Function************************************************************* /**Function*************************************************************
Synopsis [Lookup table delay computation.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Scl_LibLookupI( SC_Surface * p, int slew, int load )
{
int * pIndex0, * pIndex1, * pDataS, * pDataS1;
int p0, p1, s, l;
iword lFrac0, lFrac1, sFrac;
// handle constant table
if ( Vec_IntSize(&p->vIndex0I) == 1 && Vec_IntSize(&p->vIndex1I) == 1 )
{
Vec_Int_t * vTemp = (Vec_Int_t *)Vec_PtrEntry(&p->vDataI, 0);
assert( Vec_PtrSize(&p->vDataI) == 1 );
assert( Vec_IntSize(vTemp) == 1 );
return Vec_IntEntry(vTemp, 0);
}
// Find closest sample points in surface:
pIndex0 = Vec_IntArray(&p->vIndex0I);
for ( s = 1; s < Vec_IntSize(&p->vIndex0I)-1; s++ )
if ( pIndex0[s] > slew )
break;
s--;
pIndex1 = Vec_IntArray(&p->vIndex1I);
for ( l = 1; l < Vec_IntSize(&p->vIndex1I)-1; l++ )
if ( pIndex1[l] > load )
break;
l--;
pDataS = Vec_IntArray( (Vec_Int_t *)Vec_PtrEntry(&p->vDataI, s) );
pDataS1 = Vec_IntArray( (Vec_Int_t *)Vec_PtrEntry(&p->vDataI, s+1) );
// Interpolate (or extrapolate) function value from sample points:
// lfrac = (load - pIndex1[l]) / (pIndex1[l+1] - pIndex1[l]);
// sfrac = (slew - pIndex0[s]) / (pIndex0[s+1] - pIndex0[s]);
lFrac0 = (iword)(pDataS [l+1] - pDataS [l]) * (iword)(load - pIndex1[l]) / (iword)(pIndex1[l+1] - pIndex1[l]);
lFrac1 = (iword)(pDataS1[l+1] - pDataS1[l]) * (iword)(load - pIndex1[l]) / (iword)(pIndex1[l+1] - pIndex1[l]);
// p0 = pDataS [l] + lfrac * (pDataS [l+1] - pDataS [l]);
// p1 = pDataS1[l] + lfrac * (pDataS1[l+1] - pDataS1[l]);
p0 = pDataS [l] + (int)lFrac0;
p1 = pDataS1[l] + (int)lFrac1;
sFrac = (iword)(p1 - p0) * (iword)(slew - pIndex0[s]) / (iword)(pIndex0[s+1] - pIndex0[s]);
// 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 )
{
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) );
}
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) );
}
}
/**Function*************************************************************
Synopsis [Compute one timing edge.] Synopsis [Compute one timing edge.]
Description [] Description []
...@@ -582,6 +676,46 @@ static inline void Scl_LibHandleInputDriver( SC_Cell * pCell, SC_Pair * pLoadIn, ...@@ -582,6 +676,46 @@ static inline void Scl_LibHandleInputDriver( SC_Cell * pCell, SC_Pair * pLoadIn,
pArrOut->rise = ArrOut1.rise - ArrOut0.rise; pArrOut->rise = ArrOut1.rise - ArrOut0.rise;
} }
/**Function*************************************************************
Synopsis [Compute one timing edge.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Scl_LibPinArrivalEstimateI( SC_Cell * pCell, int iPin, int Slew, int Load )
{
SC_PairI LoadIn = { Load, Load };
SC_PairI ArrIn = { 0, 0 };
SC_PairI ArrOut = { 0, 0 };
SC_PairI SlewIn = { 0, 0 };
SC_PairI SlewOut = { 0, 0 };
// 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 );
return (ArrOut.fall + ArrOut.rise) >> 1;
}
static inline void Scl_LibHandleInputDriver2( SC_Cell * pCell, SC_PairI * pLoadIn, SC_PairI * pArrOut, SC_PairI * pSlewOut )
{
SC_PairI LoadIn = { 0, 0 }; // zero input load
SC_PairI ArrIn = { 0, 0 }; // zero input time
SC_PairI SlewIn = { 0, 0 }; // zero input slew
SC_PairI ArrOut0 = { 0, 0 }; // output time under zero load
SC_PairI ArrOut1 = { 0, 0 }; // output time under given load
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 );
pArrOut->fall = ArrOut1.fall - ArrOut0.fall;
pArrOut->rise = ArrOut1.rise - ArrOut0.rise;
}
/*=== sclLiberty.c ===============================================================*/ /*=== sclLiberty.c ===============================================================*/
extern SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose ); extern SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose );
/*=== sclLibScl.c ===============================================================*/ /*=== sclLibScl.c ===============================================================*/
......
...@@ -49,20 +49,35 @@ ABC_NAMESPACE_IMPL_START ...@@ -49,20 +49,35 @@ ABC_NAMESPACE_IMPL_START
static void Abc_SclReadSurface( Vec_Str_t * vOut, int * pPos, SC_Surface * p ) static void Abc_SclReadSurface( Vec_Str_t * vOut, int * pPos, SC_Surface * p )
{ {
Vec_Flt_t * vVec; Vec_Flt_t * vVec;
Vec_Int_t * vVecI;
int i, j; int i, j;
for ( i = Vec_StrGetI(vOut, pPos); i != 0; i-- ) for ( i = Vec_StrGetI(vOut, pPos); i != 0; i-- )
Vec_FltPush( &p->vIndex0, Vec_StrGetF(vOut, pPos) ); {
float Num = Vec_StrGetF(vOut, pPos);
Vec_FltPush( &p->vIndex0, Num );
Vec_IntPush( &p->vIndex0I, (int)(MIO_NUM*Num) );
}
for ( i = Vec_StrGetI(vOut, pPos); i != 0; i-- ) for ( i = Vec_StrGetI(vOut, pPos); i != 0; i-- )
Vec_FltPush( &p->vIndex1, Vec_StrGetF(vOut, pPos) ); {
float Num = Vec_StrGetF(vOut, pPos);
Vec_FltPush( &p->vIndex1, Num );
Vec_IntPush( &p->vIndex1I, (int)(MIO_NUM*Num) );
}
for ( i = 0; i < Vec_FltSize(&p->vIndex0); i++ ) for ( i = 0; i < Vec_FltSize(&p->vIndex0); i++ )
{ {
vVec = Vec_FltAlloc( Vec_FltSize(&p->vIndex1) ); vVec = Vec_FltAlloc( Vec_FltSize(&p->vIndex1) );
Vec_PtrPush( &p->vData, vVec ); Vec_PtrPush( &p->vData, vVec );
vVecI = Vec_IntAlloc( Vec_FltSize(&p->vIndex1) );
Vec_PtrPush( &p->vDataI, vVecI );
for ( j = 0; j < Vec_FltSize(&p->vIndex1); j++ ) for ( j = 0; j < Vec_FltSize(&p->vIndex1); j++ )
Vec_FltPush( vVec, Vec_StrGetF(vOut, pPos) ); {
float Num = Vec_StrGetF(vOut, pPos);
Vec_FltPush( vVec, Num );
Vec_IntPush( vVecI, (int)(MIO_NUM*Num) );
}
} }
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
...@@ -138,6 +153,9 @@ static int Abc_SclReadLibrary( Vec_Str_t * vOut, int * pPos, SC_Lib * p ) ...@@ -138,6 +153,9 @@ static int Abc_SclReadLibrary( Vec_Str_t * vOut, int * pPos, SC_Lib * p )
pCell->n_inputs = Vec_StrGetI(vOut, pPos); pCell->n_inputs = Vec_StrGetI(vOut, pPos);
pCell->n_outputs = Vec_StrGetI(vOut, pPos); pCell->n_outputs = Vec_StrGetI(vOut, pPos);
pCell->areaI = (int)(MIO_NUM*pCell->area);
pCell->leakageI = (int)(MIO_NUM*pCell->leakage);
/* /*
printf( "%s\n", pCell->pName ); printf( "%s\n", pCell->pName );
if ( !strcmp( "XOR3_X4M_A9TL", pCell->pName ) ) if ( !strcmp( "XOR3_X4M_A9TL", pCell->pName ) )
...@@ -154,6 +172,9 @@ static int Abc_SclReadLibrary( Vec_Str_t * vOut, int * pPos, SC_Lib * p ) ...@@ -154,6 +172,9 @@ static int Abc_SclReadLibrary( Vec_Str_t * vOut, int * pPos, SC_Lib * p )
pPin->pName = Vec_StrGetS(vOut, pPos); pPin->pName = Vec_StrGetS(vOut, pPos);
pPin->rise_cap = Vec_StrGetF(vOut, pPos); pPin->rise_cap = Vec_StrGetF(vOut, pPos);
pPin->fall_cap = Vec_StrGetF(vOut, pPos); pPin->fall_cap = Vec_StrGetF(vOut, pPos);
pPin->rise_capI = (int)(MIO_NUM*pPin->rise_capI);
pPin->fall_capI = (int)(MIO_NUM*pPin->fall_capI);
} }
for ( j = 0; j < pCell->n_outputs; j++ ) for ( j = 0; j < pCell->n_outputs; j++ )
......
...@@ -350,7 +350,7 @@ Abc_FlowRetime_MainLoop( ) { ...@@ -350,7 +350,7 @@ Abc_FlowRetime_MainLoop( ) {
// assert(!pManMR->fComputeInitState || pManMR->pInitNtk); // assert(!pManMR->fComputeInitState || pManMR->pInitNtk);
if (pManMR->fComputeInitState) Abc_NtkDelete(pManMR->pInitNtk); if (pManMR->fComputeInitState) Abc_NtkDelete(pManMR->pInitNtk);
if (pManMR->fGuaranteeInitState) ; /* Abc_NtkDelete(pNtkCopy); note: original ntk deleted later */ // if (pManMR->fGuaranteeInitState) ; /* Abc_NtkDelete(pNtkCopy); note: original ntk deleted later */
return pNtk; return pNtk;
} }
......
...@@ -4,5 +4,6 @@ SRC += src/opt/sfm/sfmCnf.c \ ...@@ -4,5 +4,6 @@ SRC += src/opt/sfm/sfmCnf.c \
src/opt/sfm/sfmLib.c \ src/opt/sfm/sfmLib.c \
src/opt/sfm/sfmNtk.c \ src/opt/sfm/sfmNtk.c \
src/opt/sfm/sfmSat.c \ src/opt/sfm/sfmSat.c \
src/opt/sfm/sfmTime.c \ src/opt/sfm/sfmTim.c \
src/opt/sfm/sfmMit.c \
src/opt/sfm/sfmWin.c src/opt/sfm/sfmWin.c
...@@ -40,6 +40,7 @@ struct Sfm_Dec_t_ ...@@ -40,6 +40,7 @@ struct Sfm_Dec_t_
Sfm_Par_t * pPars; // parameters Sfm_Par_t * pPars; // parameters
Sfm_Lib_t * pLib; // library Sfm_Lib_t * pLib; // library
Sfm_Tim_t * pTim; // timing Sfm_Tim_t * pTim; // timing
Sfm_Mit_t * pMit; // timing
Abc_Ntk_t * pNtk; // network Abc_Ntk_t * pNtk; // network
// library // library
Vec_Int_t vGateSizes; // fanin counts Vec_Int_t vGateSizes; // fanin counts
...@@ -142,6 +143,8 @@ static inline word Sfm_DecObjSim( Sfm_Dec_t * p, Abc_Obj_t * pObj ) { r ...@@ -142,6 +143,8 @@ static inline word Sfm_DecObjSim( Sfm_Dec_t * p, Abc_Obj_t * pObj ) { r
static inline word Sfm_DecObjSim2( Sfm_Dec_t * p, Abc_Obj_t * pObj ) { return Vec_WrdEntry(&p->vObjSims2, Abc_ObjId(pObj)); } static inline word Sfm_DecObjSim2( Sfm_Dec_t * p, Abc_Obj_t * pObj ) { return Vec_WrdEntry(&p->vObjSims2, Abc_ObjId(pObj)); }
static inline word * Sfm_DecDivPats( Sfm_Dec_t * p, int d, int c ) { return Vec_WrdEntryP(&p->vSets[c], d*SFM_SIM_WORDS); } static inline word * Sfm_DecDivPats( Sfm_Dec_t * p, int d, int c ) { return Vec_WrdEntryP(&p->vSets[c], d*SFM_SIM_WORDS); }
static inline int Sfm_ManReadObjDelay( Sfm_Dec_t * p, int Id ) { return p->pMit ? Sfm_MitReadObjDelay(p->pMit, Id) : Sfm_TimReadObjDelay(p->pTim, Id); }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -208,7 +211,12 @@ p->timeLib = Abc_Clock(); ...@@ -208,7 +211,12 @@ p->timeLib = Abc_Clock();
p->pLib = Sfm_LibPrepare( pPars->nVarMax, 1, !pPars->fArea, pPars->fVerbose, pPars->fLibVerbose ); p->pLib = Sfm_LibPrepare( pPars->nVarMax, 1, !pPars->fArea, pPars->fVerbose, pPars->fLibVerbose );
p->timeLib = Abc_Clock() - p->timeLib; p->timeLib = Abc_Clock() - p->timeLib;
if ( !pPars->fArea ) if ( !pPars->fArea )
{
if ( p->pMit )
p->pMit = Sfm_MitStart( pLib, NULL, pNtk, p->DeltaCrit );
else
p->pTim = Sfm_TimStart( pLib, NULL, pNtk, p->DeltaCrit ); p->pTim = Sfm_TimStart( pLib, NULL, pNtk, p->DeltaCrit );
}
if ( pPars->fVeryVerbose ) if ( pPars->fVeryVerbose )
// if ( pPars->fVerbose ) // if ( pPars->fVerbose )
Sfm_LibPrint( p->pLib ); Sfm_LibPrint( p->pLib );
...@@ -236,6 +244,7 @@ void Sfm_DecStop( Sfm_Dec_t * p ) ...@@ -236,6 +244,7 @@ void Sfm_DecStop( Sfm_Dec_t * p )
printf( "Level count mismatch at node %d.\n", i ); printf( "Level count mismatch at node %d.\n", i );
Sfm_LibStop( p->pLib ); Sfm_LibStop( p->pLib );
if ( p->pTim ) Sfm_TimStop( p->pTim ); if ( p->pTim ) Sfm_TimStop( p->pTim );
if ( p->pMit ) Sfm_MitStop( p->pMit );
// divisors // divisors
for ( i = 0; i < SFM_SUPP_MAX; i++ ) for ( i = 0; i < SFM_SUPP_MAX; i++ )
ABC_FREE( p->pDivWords[i] ); ABC_FREE( p->pDivWords[i] );
...@@ -1195,7 +1204,7 @@ int Sfm_DecPeformDec3( Sfm_Dec_t * p, Abc_Obj_t * pObj ) ...@@ -1195,7 +1204,7 @@ int Sfm_DecPeformDec3( Sfm_Dec_t * p, Abc_Obj_t * pObj )
Vec_IntClear( &p->vObjDec ); Vec_IntClear( &p->vObjDec );
for ( i = 0; i < nDecs; i++ ) for ( i = 0; i < nDecs; i++ )
{ {
DelayMin = DelayOrig = Sfm_TimReadObjDelay( p->pTim, Abc_ObjId(pObj) ); DelayMin = DelayOrig = Sfm_ManReadObjDelay( p, Abc_ObjId(pObj) );
// reduce the variable array // reduce the variable array
if ( Vec_IntSize(&p->vObjDec) > Prev ) if ( Vec_IntSize(&p->vObjDec) > Prev )
Vec_IntShrink( &p->vObjDec, Prev ); Vec_IntShrink( &p->vObjDec, Prev );
...@@ -1214,7 +1223,7 @@ int Sfm_DecPeformDec3( Sfm_Dec_t * p, Abc_Obj_t * pObj ) ...@@ -1214,7 +1223,7 @@ int Sfm_DecPeformDec3( Sfm_Dec_t * p, Abc_Obj_t * pObj )
printf( "Dec %d: Pat0 = %2d Pat1 = %2d Supp = %d ", i, p->nPats[0], p->nPats[1], nSupp[i] ); printf( "Dec %d: Pat0 = %2d Pat1 = %2d Supp = %d ", i, p->nPats[0], p->nPats[1], nSupp[i] );
if ( fVeryVerbose ) if ( fVeryVerbose )
Dau_DsdPrintFromTruth( uTruth[i], nSupp[i] ); Dau_DsdPrintFromTruth( uTruth[i], nSupp[i] );
if ( nSupp[i] == 1 && uTruth[i][0] == ABC_CONST(0x5555555555555555) && DelayMin <= p->DelayInv + Sfm_TimReadObjDelay(p->pTim, Vec_IntEntry(&p->vObjMap, pSupp[i][0])) ) if ( nSupp[i] == 1 && uTruth[i][0] == ABC_CONST(0x5555555555555555) && DelayMin <= p->DelayInv + Sfm_ManReadObjDelay(p, Vec_IntEntry(&p->vObjMap, pSupp[i][0])) )
{ {
if ( fVeryVerbose ) if ( fVeryVerbose )
printf( "Dec %d: Pat0 = %2d Pat1 = %2d NO DEC.\n", i, p->nPats[0], p->nPats[1] ); printf( "Dec %d: Pat0 = %2d Pat1 = %2d NO DEC.\n", i, p->nPats[0], p->nPats[1] );
...@@ -1243,7 +1252,11 @@ int Sfm_DecPeformDec3( Sfm_Dec_t * p, Abc_Obj_t * pObj ) ...@@ -1243,7 +1252,11 @@ int Sfm_DecPeformDec3( Sfm_Dec_t * p, Abc_Obj_t * pObj )
char * pFans1 = (char *)Vec_PtrEntry( &p->vMatchFans, 2*k+0 ); char * pFans1 = (char *)Vec_PtrEntry( &p->vMatchFans, 2*k+0 );
char * pFans2 = (char *)Vec_PtrEntry( &p->vMatchFans, 2*k+1 ); char * pFans2 = (char *)Vec_PtrEntry( &p->vMatchFans, 2*k+1 );
Vec_Int_t vFanins = { nSupp[i], nSupp[i], pSupp[i] }; Vec_Int_t vFanins = { nSupp[i], nSupp[i], pSupp[i] };
int Delay = Sfm_TimEvalRemapping( p->pTim, &vFanins, &p->vObjMap, pGate1, pFans1, pGate2, pFans2 ); int Delay;
if ( p->pMit )
Delay = Sfm_MitEvalRemapping( p->pMit, &vFanins, &p->vObjMap, pGate1, pFans1, pGate2, pFans2 );
else
Delay = Sfm_TimEvalRemapping( p->pTim, &vFanins, &p->vObjMap, pGate1, pFans1, pGate2, pFans2 );
if ( DelayMin > Delay ) if ( DelayMin > Delay )
{ {
DelayMin = Delay; DelayMin = Delay;
...@@ -1383,12 +1396,35 @@ static inline int Sfm_DecNodeIsMffcInput( Abc_Obj_t * p, int nLevelMin, Sfm_Tim_ ...@@ -1383,12 +1396,35 @@ static inline int Sfm_DecNodeIsMffcInput( Abc_Obj_t * p, int nLevelMin, Sfm_Tim_
{ {
return Abc_NodeIsTravIdCurrent(p) && Sfm_TimNodeIsNonCritical(pTim, pPivot, p); return Abc_NodeIsTravIdCurrent(p) && Sfm_TimNodeIsNonCritical(pTim, pPivot, p);
} }
void Sfm_DecMarkMffc( Abc_Obj_t * pPivot, int nLevelMin, int nMffcMax, int fVeryVerbose, Vec_Int_t * vMffc, Vec_Int_t * vInMffc, Sfm_Tim_t * pTim ) static inline int Sfm_DecNodeIsMffcInput2( Abc_Obj_t * p, int nLevelMin, Sfm_Mit_t * pMit, Abc_Obj_t * pPivot )
{
return Abc_NodeIsTravIdCurrent(p) && Sfm_MitNodeIsNonCritical(pMit, pPivot, p);
}
void Sfm_DecMarkMffc( Abc_Obj_t * pPivot, int nLevelMin, int nMffcMax, int fVeryVerbose, Vec_Int_t * vMffc, Vec_Int_t * vInMffc, Sfm_Tim_t * pTim, Sfm_Mit_t * pMit )
{ {
Abc_Obj_t * pFanin, * pFanin2, * pFanin3, * pObj; int i, k, n; Abc_Obj_t * pFanin, * pFanin2, * pFanin3, * pObj; int i, k, n;
assert( nMffcMax > 0 ); assert( nMffcMax > 0 );
Vec_IntFill( vMffc, 1, Abc_ObjId(pPivot) ); Vec_IntFill( vMffc, 1, Abc_ObjId(pPivot) );
if ( pTim != NULL ) if ( pMit != NULL )
{
pPivot->iTemp |= SFM_MASK_MFFC;
pPivot->iTemp |= SFM_MASK_PIVOT;
// collect MFFC inputs (these are low-delay nodes close to the pivot)
Vec_IntClear(vInMffc);
Abc_ObjForEachFanin( pPivot, pFanin, i )
if ( Sfm_DecNodeIsMffcInput2(pFanin, nLevelMin, pMit, pPivot) )
Vec_IntPushUnique( vInMffc, Abc_ObjId(pFanin) );
Abc_ObjForEachFanin( pPivot, pFanin, i )
Abc_ObjForEachFanin( pFanin, pFanin2, k )
if ( Sfm_DecNodeIsMffcInput2(pFanin2, nLevelMin, pMit, pPivot) )
Vec_IntPushUnique( vInMffc, Abc_ObjId(pFanin2) );
Abc_ObjForEachFanin( pPivot, pFanin, i )
Abc_ObjForEachFanin( pFanin, pFanin2, k )
Abc_ObjForEachFanin( pFanin2, pFanin3, n )
if ( Sfm_DecNodeIsMffcInput2(pFanin3, nLevelMin, pMit, pPivot) )
Vec_IntPushUnique( vInMffc, Abc_ObjId(pFanin3) );
}
else if ( pTim != NULL )
{ {
pPivot->iTemp |= SFM_MASK_MFFC; pPivot->iTemp |= SFM_MASK_MFFC;
pPivot->iTemp |= SFM_MASK_PIVOT; pPivot->iTemp |= SFM_MASK_PIVOT;
...@@ -1408,14 +1444,14 @@ void Sfm_DecMarkMffc( Abc_Obj_t * pPivot, int nLevelMin, int nMffcMax, int fVery ...@@ -1408,14 +1444,14 @@ void Sfm_DecMarkMffc( Abc_Obj_t * pPivot, int nLevelMin, int nMffcMax, int fVery
Vec_IntPushUnique( vInMffc, Abc_ObjId(pFanin3) ); Vec_IntPushUnique( vInMffc, Abc_ObjId(pFanin3) );
/* /*
printf( "Node %d: (%.2f) ", pPivot->Id, MIO_NUMINV*Sfm_TimReadObjDelay(pTim, Abc_ObjId(pPivot)) ); printf( "Node %d: (%.2f) ", pPivot->Id, MIO_NUMINV*Sfm_ManReadObjDelay(p, Abc_ObjId(pPivot)) );
Abc_ObjForEachFanin( pPivot, pFanin, i ) Abc_ObjForEachFanin( pPivot, pFanin, i )
printf( "%d: %.2f ", Abc_ObjLevel(pFanin), MIO_NUMINV*Sfm_TimReadObjDelay(pTim, Abc_ObjId(pFanin)) ); printf( "%d: %.2f ", Abc_ObjLevel(pFanin), MIO_NUMINV*Sfm_ManReadObjDelay(p, Abc_ObjId(pFanin)) );
printf( "\n" ); printf( "\n" );
printf( "Node %d: ", pPivot->Id ); printf( "Node %d: ", pPivot->Id );
Abc_NtkForEachObjVec( vInMffc, pPivot->pNtk, pObj, i ) Abc_NtkForEachObjVec( vInMffc, pPivot->pNtk, pObj, i )
printf( "%d: %.2f ", Abc_ObjLevel(pObj), MIO_NUMINV*Sfm_TimReadObjDelay(pTim, Abc_ObjId(pObj)) ); printf( "%d: %.2f ", Abc_ObjLevel(pObj), MIO_NUMINV*Sfm_ManReadObjDelay(p, Abc_ObjId(pObj)) );
printf( "\n" ); printf( "\n" );
*/ */
} }
...@@ -1473,7 +1509,7 @@ void Sfm_DecMarkMffc( Abc_Obj_t * pPivot, int nLevelMin, int nMffcMax, int fVery ...@@ -1473,7 +1509,7 @@ void Sfm_DecMarkMffc( Abc_Obj_t * pPivot, int nLevelMin, int nMffcMax, int fVery
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Sfm_DecExtract( Abc_Ntk_t * pNtk, Sfm_Par_t * pPars, Abc_Obj_t * pPivot, Vec_Int_t * vRoots, Vec_Int_t * vGates, Vec_Wec_t * vFanins, Vec_Int_t * vMap, Vec_Int_t * vTfi, Vec_Int_t * vTfo, Vec_Int_t * vMffc, Vec_Int_t * vInMffc, Sfm_Tim_t * pTim ) int Sfm_DecExtract( Abc_Ntk_t * pNtk, Sfm_Par_t * pPars, Abc_Obj_t * pPivot, Vec_Int_t * vRoots, Vec_Int_t * vGates, Vec_Wec_t * vFanins, Vec_Int_t * vMap, Vec_Int_t * vTfi, Vec_Int_t * vTfo, Vec_Int_t * vMffc, Vec_Int_t * vInMffc, Sfm_Tim_t * pTim, Sfm_Mit_t * pMit )
{ {
int fVeryVerbose = 0;//pPars->fVeryVerbose; int fVeryVerbose = 0;//pPars->fVeryVerbose;
Vec_Int_t * vLevel; Vec_Int_t * vLevel;
...@@ -1505,7 +1541,7 @@ printf( "\n\nTarget %d\n", Abc_ObjId(pPivot) ); ...@@ -1505,7 +1541,7 @@ printf( "\n\nTarget %d\n", Abc_ObjId(pPivot) );
nTfiSize = Vec_IntSize(vTfi); nTfiSize = Vec_IntSize(vTfi);
Sfm_ObjFlipNode( pPivot ); Sfm_ObjFlipNode( pPivot );
// additinally mark MFFC // additinally mark MFFC
Sfm_DecMarkMffc( pPivot, nLevelMin, pPars->nMffcMax, fVeryVerbose, vMffc, vInMffc, pTim ); Sfm_DecMarkMffc( pPivot, nLevelMin, pPars->nMffcMax, fVeryVerbose, vMffc, vInMffc, pTim, pMit );
assert( Vec_IntSize(vMffc) <= pPars->nMffcMax ); assert( Vec_IntSize(vMffc) <= pPars->nMffcMax );
if ( fVeryVerbose ) if ( fVeryVerbose )
printf( "Mffc size = %d. Mffc area = %.2f. InMffc size = %d.\n", Vec_IntSize(vMffc), Sfm_DecMffcArea(pNtk, vMffc)*MIO_NUMINV, Vec_IntSize(vInMffc) ); printf( "Mffc size = %d. Mffc area = %.2f. InMffc size = %d.\n", Vec_IntSize(vMffc), Sfm_DecMffcArea(pNtk, vMffc)*MIO_NUMINV, Vec_IntSize(vInMffc) );
...@@ -1534,7 +1570,22 @@ printf( "\nSides:\n" ); ...@@ -1534,7 +1570,22 @@ printf( "\nSides:\n" );
if ( pObj->iTemp == (SFM_MASK_PI | SFM_MASK_INPUT) || pObj->iTemp == SFM_MASK_FANIN ) if ( pObj->iTemp == (SFM_MASK_PI | SFM_MASK_INPUT) || pObj->iTemp == SFM_MASK_FANIN )
Sfm_DecAddNode( pObj, vMap, vGates, pObj->iTemp == SFM_MASK_FANIN, fVeryVerbose ); Sfm_DecAddNode( pObj, vMap, vGates, pObj->iTemp == SFM_MASK_FANIN, fVeryVerbose );
// reorder nodes acording to delay // reorder nodes acording to delay
if ( pTim ) if ( pMit )
{
int nDivsNew, nOldSize = Vec_IntSize(vMap);
Vec_IntClear( vTfo );
Vec_IntAppend( vTfo, vMap );
nDivsNew = Sfm_MitSortArrayByArrival( pMit, vTfo, Abc_ObjId(pPivot) );
// collect again
Vec_IntClear( vMap );
Vec_IntClear( vGates );
Abc_NtkForEachObjVec( vTfo, pNtk, pObj, i )
Sfm_DecAddNode( pObj, vMap, vGates, Abc_ObjIsCi(pObj) || (Abc_ObjLevel(pObj) < nLevelMin && Abc_ObjFaninNum(pObj) > 0) || pObj->iTemp == SFM_MASK_FANIN, 0 );
assert( nOldSize == Vec_IntSize(vMap) );
// update divisor count
nDivs = nDivsNew;
}
else if ( pTim )
{ {
int nDivsNew, nOldSize = Vec_IntSize(vMap); int nDivsNew, nOldSize = Vec_IntSize(vMap);
Vec_IntClear( vTfo ); Vec_IntClear( vTfo );
...@@ -1757,7 +1808,7 @@ Abc_Obj_t * Abc_NtkAreaOptOne( Sfm_Dec_t * p, int i ) ...@@ -1757,7 +1808,7 @@ Abc_Obj_t * Abc_NtkAreaOptOne( Sfm_Dec_t * p, int i )
pPars->fVeryVerbose = (int)(i == pPars->iNodeOne); pPars->fVeryVerbose = (int)(i == pPars->iNodeOne);
p->nNodesTried++; p->nNodesTried++;
clk = Abc_Clock(); clk = Abc_Clock();
p->nDivs = Sfm_DecExtract( pNtk, pPars, pObj, &p->vObjRoots, &p->vObjGates, &p->vObjFanins, &p->vObjMap, &p->vTemp, &p->vTemp2, &p->vObjMffc, &p->vObjInMffc, NULL ); p->nDivs = Sfm_DecExtract( pNtk, pPars, pObj, &p->vObjRoots, &p->vObjGates, &p->vObjFanins, &p->vObjMap, &p->vTemp, &p->vTemp2, &p->vObjMffc, &p->vObjInMffc, NULL, NULL );
p->timeWin += Abc_Clock() - clk; p->timeWin += Abc_Clock() - clk;
if ( pPars->nWinSizeMax && pPars->nWinSizeMax < Vec_IntSize(&p->vObjGates) ) if ( pPars->nWinSizeMax && pPars->nWinSizeMax < Vec_IntSize(&p->vObjGates) )
return NULL; return NULL;
...@@ -1877,18 +1928,20 @@ void Abc_NtkDelayOpt( Sfm_Dec_t * p ) ...@@ -1877,18 +1928,20 @@ void Abc_NtkDelayOpt( Sfm_Dec_t * p )
// collect nodes // collect nodes
if ( pPars->iNodeOne ) if ( pPars->iNodeOne )
Vec_IntFill( &p->vCands, 1, pPars->iNodeOne ); Vec_IntFill( &p->vCands, 1, pPars->iNodeOne );
else if ( !Sfm_TimPriorityNodes(p->pTim, &p->vCands, p->pPars->nTimeWin) ) else if ( p->pTim && !Sfm_TimPriorityNodes(p->pTim, &p->vCands, p->pPars->nTimeWin) )
break;
else if ( p->pMit && !Sfm_MitPriorityNodes(p->pMit, &p->vCands, p->pPars->nTimeWin) )
break; break;
// try improving delay for the nodes according to the priority // try improving delay for the nodes according to the priority
Abc_NtkForEachObjVec( &p->vCands, p->pNtk, pObj, i ) Abc_NtkForEachObjVec( &p->vCands, p->pNtk, pObj, i )
{ {
int OldId = Abc_ObjId(pObj); int OldId = Abc_ObjId(pObj);
int DelayOld = Sfm_TimReadObjDelay(p->pTim, OldId); int DelayOld = Sfm_ManReadObjDelay(p, OldId);
assert( pObj->fMarkA == 0 ); assert( pObj->fMarkA == 0 );
p->nNodesTried++; p->nNodesTried++;
clk = Abc_Clock(); clk = Abc_Clock();
p->nDivs = Sfm_DecExtract( pNtk, pPars, pObj, &p->vObjRoots, &p->vObjGates, &p->vObjFanins, &p->vObjMap, &p->vTemp, &p->vTemp2, &p->vObjMffc, &p->vObjInMffc, p->pTim ); p->nDivs = Sfm_DecExtract( pNtk, pPars, pObj, &p->vObjRoots, &p->vObjGates, &p->vObjFanins, &p->vObjMap, &p->vTemp, &p->vTemp2, &p->vObjMffc, &p->vObjInMffc, p->pTim, p->pMit );
p->timeWin += Abc_Clock() - clk; p->timeWin += Abc_Clock() - clk;
if ( p->nDivs < 2 || (pPars->nWinSizeMax && pPars->nWinSizeMax < Vec_IntSize(&p->vObjGates)) ) if ( p->nDivs < 2 || (pPars->nWinSizeMax && pPars->nWinSizeMax < Vec_IntSize(&p->vObjGates)) )
{ {
...@@ -1951,15 +2004,18 @@ p->timeSat += Abc_Clock() - clk; ...@@ -1951,15 +2004,18 @@ p->timeSat += Abc_Clock() - clk;
Abc_NtkCountStats( p, Limit ); Abc_NtkCountStats( p, Limit );
Sfm_DecInsert( pNtk, pObj, Limit, &p->vObjGates, &p->vObjFanins, &p->vObjMap, &p->vGateHands, p->GateBuffer, p->GateInvert, &p->vGateFuncs, &p->vTemp ); Sfm_DecInsert( pNtk, pObj, Limit, &p->vObjGates, &p->vObjFanins, &p->vObjMap, &p->vGateHands, p->GateBuffer, p->GateInvert, &p->vGateFuncs, &p->vTemp );
clk = Abc_Clock(); clk = Abc_Clock();
if ( p->pMit )
Sfm_MitUpdateTiming( p->pMit, &p->vTemp );
else
Sfm_TimUpdateTiming( p->pTim, &p->vTemp ); Sfm_TimUpdateTiming( p->pTim, &p->vTemp );
p->timeTime += Abc_Clock() - clk; p->timeTime += Abc_Clock() - clk;
pObjNew = Abc_NtkObj( pNtk, Abc_NtkObjNumMax(pNtk)-1 ); pObjNew = Abc_NtkObj( pNtk, Abc_NtkObjNumMax(pNtk)-1 );
assert( p->DelayMin == 0 || p->DelayMin == Sfm_TimReadObjDelay(p->pTim, Abc_ObjId(pObjNew)) ); assert( p->DelayMin == 0 || p->DelayMin == Sfm_ManReadObjDelay(p, Abc_ObjId(pObjNew)) );
// report // report
if ( pPars->fDelayVerbose ) if ( pPars->fDelayVerbose )
printf( "Node %5d : I =%3d. Cand = %5d (%6.2f %%) Old =%8.2f. New =%8.2f. Final =%8.2f\n", printf( "Node %5d : I =%3d. Cand = %5d (%6.2f %%) Old =%8.2f. New =%8.2f. Final =%8.2f\n",
OldId, i, Vec_IntSize(&p->vCands), 100.0 * Vec_IntSize(&p->vCands) / Abc_NtkNodeNum(p->pNtk), OldId, i, Vec_IntSize(&p->vCands), 100.0 * Vec_IntSize(&p->vCands) / Abc_NtkNodeNum(p->pNtk),
MIO_NUMINV*DelayOld, MIO_NUMINV*Sfm_TimReadObjDelay(p->pTim, Abc_ObjId(pObjNew)), MIO_NUMINV*DelayOld, MIO_NUMINV*Sfm_ManReadObjDelay(p, Abc_ObjId(pObjNew)),
MIO_NUMINV*Sfm_TimReadNtkDelay(p->pTim) ); MIO_NUMINV*Sfm_TimReadNtkDelay(p->pTim) );
break; break;
} }
......
...@@ -63,6 +63,7 @@ ABC_NAMESPACE_HEADER_START ...@@ -63,6 +63,7 @@ ABC_NAMESPACE_HEADER_START
typedef struct Sfm_Fun_t_ Sfm_Fun_t; typedef struct Sfm_Fun_t_ Sfm_Fun_t;
typedef struct Sfm_Lib_t_ Sfm_Lib_t; typedef struct Sfm_Lib_t_ Sfm_Lib_t;
typedef struct Sfm_Tim_t_ Sfm_Tim_t; typedef struct Sfm_Tim_t_ Sfm_Tim_t;
typedef struct Sfm_Mit_t_ Sfm_Mit_t;
struct Sfm_Ntk_t_ struct Sfm_Ntk_t_
{ {
...@@ -214,7 +215,7 @@ extern void Sfm_NtkUpdate( Sfm_Ntk_t * p, int iNode, int f, int iFaninNe ...@@ -214,7 +215,7 @@ extern void Sfm_NtkUpdate( Sfm_Ntk_t * p, int iNode, int f, int iFaninNe
/*=== sfmSat.c ==========================================================*/ /*=== sfmSat.c ==========================================================*/
extern int Sfm_NtkWindowToSolver( Sfm_Ntk_t * p ); extern int Sfm_NtkWindowToSolver( Sfm_Ntk_t * p );
extern word Sfm_ComputeInterpolant( Sfm_Ntk_t * p ); extern word Sfm_ComputeInterpolant( Sfm_Ntk_t * p );
/*=== sfmTime.c ==========================================================*/ /*=== sfmTim.c ==========================================================*/
extern Sfm_Tim_t * Sfm_TimStart( Mio_Library_t * pLib, Scl_Con_t * pExt, Abc_Ntk_t * pNtk, int DeltaCrit ); extern Sfm_Tim_t * Sfm_TimStart( Mio_Library_t * pLib, Scl_Con_t * pExt, Abc_Ntk_t * pNtk, int DeltaCrit );
extern void Sfm_TimStop( Sfm_Tim_t * p ); extern void Sfm_TimStop( Sfm_Tim_t * p );
extern int Sfm_TimReadNtkDelay( Sfm_Tim_t * p ); extern int Sfm_TimReadNtkDelay( Sfm_Tim_t * p );
...@@ -224,6 +225,16 @@ extern int Sfm_TimSortArrayByArrival( Sfm_Tim_t * p, Vec_Int_t * vNodes ...@@ -224,6 +225,16 @@ extern int Sfm_TimSortArrayByArrival( Sfm_Tim_t * p, Vec_Int_t * vNodes
extern int Sfm_TimPriorityNodes( Sfm_Tim_t * p, Vec_Int_t * vCands, int Window ); extern int Sfm_TimPriorityNodes( Sfm_Tim_t * p, Vec_Int_t * vCands, int Window );
extern int Sfm_TimNodeIsNonCritical( Sfm_Tim_t * p, Abc_Obj_t * pPivot, Abc_Obj_t * pNode ); extern int Sfm_TimNodeIsNonCritical( Sfm_Tim_t * p, Abc_Obj_t * pPivot, Abc_Obj_t * pNode );
extern int Sfm_TimEvalRemapping( Sfm_Tim_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_TimEvalRemapping( Sfm_Tim_t * p, Vec_Int_t * vFanins, Vec_Int_t * vMap, Mio_Gate_t * pGate1, char * pFans1, Mio_Gate_t * pGate2, char * pFans2 );
/*=== sfmMit.c ==========================================================*/
extern Sfm_Mit_t * Sfm_MitStart( Mio_Library_t * pLib, Scl_Con_t * pExt, Abc_Ntk_t * pNtk, int DeltaCrit );
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_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 );
/*=== sfmWin.c ==========================================================*/ /*=== sfmWin.c ==========================================================*/
extern int Sfm_ObjMffcSize( Sfm_Ntk_t * p, int iObj ); extern int Sfm_ObjMffcSize( Sfm_Ntk_t * p, int iObj );
extern int Sfm_NtkCreateWindow( Sfm_Ntk_t * p, int iNode, int fVerbose ); extern int Sfm_NtkCreateWindow( Sfm_Ntk_t * p, int iNode, int fVerbose );
......
/**CFile****************************************************************
FileName [sfmMit.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [SAT-based optimization using internal don't-cares.]
Synopsis [Timing manager.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: sfmMit.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "sfmInt.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
struct Sfm_Mit_t_
{
// external
Mio_Library_t * pLib; // library
Scl_Con_t * pExt; // external timing
Abc_Ntk_t * pNtk; // mapped network
int Delay; // the largest delay
int DeltaCrit; // critical delay delta
// timing info
Vec_Int_t vTimArrs; // arrivals (rise/fall)
Vec_Int_t vTimReqs; // required (rise/fall)
Vec_Int_t vTimSlews; // slews (rise/fall)
Vec_Int_t vTimLoads; // loads (rise/fall)
// timing edges
Vec_Int_t vObjOffs; // object offsets
Vec_Int_t vTimEdges; // edge timings (rise/fall)
// incremental timing
Vec_Wec_t vLevels; // levels
// critical path
Vec_Int_t vPath; // critical path
Vec_Wrd_t vSortData; // node priority order
};
static inline int * Sfm_MitArrId( Sfm_Mit_t * p, int Id ) { return Vec_IntEntryP( &p->vTimArrs, Abc_Var2Lit(Id, 0) ); }
static inline int * Sfm_MitReqId( Sfm_Mit_t * p, int Id ) { return Vec_IntEntryP( &p->vTimReqs, Abc_Var2Lit(Id, 0) ); }
static inline int * Sfm_MitSlewId( Sfm_Mit_t * p, int Id ) { return Vec_IntEntryP( &p->vTimSlews, Abc_Var2Lit(Id, 0) ); }
static inline int * Sfm_MitLoadId( Sfm_Mit_t * p, int Id ) { return Vec_IntEntryP( &p->vTimLoads, Abc_Var2Lit(Id, 0) ); }
static inline int * Sfm_MitArr( Sfm_Mit_t * p, Abc_Obj_t * pNode ) { return Vec_IntEntryP( &p->vTimArrs, Abc_Var2Lit(Abc_ObjId(pNode), 0) ); }
static inline int * Sfm_MitReq( Sfm_Mit_t * p, Abc_Obj_t * pNode ) { return Vec_IntEntryP( &p->vTimReqs, Abc_Var2Lit(Abc_ObjId(pNode), 0) ); }
static inline int * Sfm_MitSlew( Sfm_Mit_t * p, Abc_Obj_t * pNode ) { return Vec_IntEntryP( &p->vTimSlews, Abc_Var2Lit(Abc_ObjId(pNode), 0) ); }
static inline int * Sfm_MitLoad( Sfm_Mit_t * p, Abc_Obj_t * pNode ) { return Vec_IntEntryP( &p->vTimLoads, Abc_Var2Lit(Abc_ObjId(pNode), 0) ); }
static inline int Sfm_MitArrMaxId( Sfm_Mit_t * p, int Id ) { int * a = Sfm_MitArrId(p, Id); return Abc_MaxInt(a[0], a[1]); }
static inline int Sfm_MitArrMax( Sfm_Mit_t * p, Abc_Obj_t * pNode ) { int * a = Sfm_MitArr(p, pNode); return Abc_MaxInt(a[0], a[1]); }
static inline void Sfm_MitSetReq( Sfm_Mit_t * p, Abc_Obj_t * pNode, int t ) { int * r = Sfm_MitReq(p, pNode); r[0] = r[1] = t; }
static inline int Sfm_MitSlack( Sfm_Mit_t * p, Abc_Obj_t * pNode ) { int * r = Sfm_MitReq(p, pNode), * a = Sfm_MitArr(p, pNode); return Abc_MinInt(r[0]-a[0], r[1]-a[1]); }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Sfm_MitEdgeArrival( Sfm_Mit_t * p, Mio_Pin_t * pPin, int * pTimeIn, int * pTimeOut )
{
Mio_PinPhase_t PinPhase = Mio_PinReadPhase(pPin);
int tDelayBlockRise = (int)(MIO_NUM*Mio_PinReadDelayBlockRise(pPin));
int tDelayBlockFall = (int)(MIO_NUM*Mio_PinReadDelayBlockFall(pPin));
if ( PinPhase != MIO_PHASE_INV ) // NONINV phase is present
{
pTimeOut[0] = Abc_MaxInt( pTimeOut[0], pTimeIn[0] + tDelayBlockRise );
pTimeOut[1] = Abc_MaxInt( pTimeOut[1], pTimeIn[1] + tDelayBlockFall );
}
if ( PinPhase != MIO_PHASE_NONINV ) // INV phase is present
{
pTimeOut[0] = Abc_MaxInt( pTimeOut[0], pTimeIn[1] + tDelayBlockRise );
pTimeOut[1] = Abc_MaxInt( pTimeOut[1], pTimeIn[0] + tDelayBlockFall );
}
}
static inline void Sfm_MitGateArrival( Sfm_Mit_t * p, Mio_Gate_t * pGate, int ** pTimesIn, int * pTimeOut )
{
Mio_Pin_t * pPin; int i = 0;
pTimeOut[0] = pTimeOut[1] = 0;
Mio_GateForEachPin( pGate, pPin )
Sfm_MitEdgeArrival( p, pPin, pTimesIn[i++], pTimeOut );
assert( i == Mio_GateReadPinNum(pGate) );
}
static inline void Sfm_MitNodeArrival( Sfm_Mit_t * p, Abc_Obj_t * pNode )
{
int i, iFanin, * pTimesIn[6];
int * pTimeOut = Sfm_MitArr(p, pNode);
assert( Abc_ObjFaninNum(pNode) <= 6 );
Abc_ObjForEachFaninId( pNode, iFanin, i )
pTimesIn[i] = Sfm_MitArrId( p, iFanin );
Sfm_MitGateArrival( p, (Mio_Gate_t *)pNode->pData, pTimesIn, pTimeOut );
}
static inline void Sfm_MitEdgeRequired( Sfm_Mit_t * p, Mio_Pin_t * pPin, int * pTimeIn, int * pTimeOut )
{
Mio_PinPhase_t PinPhase = Mio_PinReadPhase(pPin);
int tDelayBlockRise = (int)(MIO_NUM*Mio_PinReadDelayBlockRise(pPin));
int tDelayBlockFall = (int)(MIO_NUM*Mio_PinReadDelayBlockFall(pPin));
if ( PinPhase != MIO_PHASE_INV ) // NONINV phase is present
{
pTimeIn[0] = Abc_MinInt( pTimeIn[0], pTimeOut[0] - tDelayBlockRise );
pTimeIn[1] = Abc_MinInt( pTimeIn[1], pTimeOut[1] - tDelayBlockFall );
}
if ( PinPhase != MIO_PHASE_NONINV ) // INV phase is present
{
pTimeIn[0] = Abc_MinInt( pTimeIn[0], pTimeOut[1] - tDelayBlockRise );
pTimeIn[1] = Abc_MinInt( pTimeIn[1], pTimeOut[0] - tDelayBlockFall );
}
}
static inline void Sfm_MitGateRequired( Sfm_Mit_t * p, Mio_Gate_t * pGate, int ** pTimesIn, int * pTimeOut )
{
Mio_Pin_t * pPin; int i = 0;
Mio_GateForEachPin( pGate, pPin )
Sfm_MitEdgeRequired( p, pPin, pTimesIn[i++], pTimeOut );
assert( i == Mio_GateReadPinNum(pGate) );
}
void Sfm_MitNodeRequired( Sfm_Mit_t * p, Abc_Obj_t * pNode )
{
int i, iFanin, * pTimesIn[6];
int * pTimeOut = Sfm_MitReq(p, pNode);
assert( Abc_ObjFaninNum(pNode) <= 6 );
Abc_ObjForEachFaninId( pNode, iFanin, i )
pTimesIn[i] = Sfm_MitReqId( p, iFanin );
Sfm_MitGateRequired( p, (Mio_Gate_t *)pNode->pData, pTimesIn, pTimeOut );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Sfm_MitCriticalPath_int( Sfm_Mit_t * p, Abc_Obj_t * pObj, Vec_Int_t * vPath, int SlackMax )
{
Abc_Obj_t * pNext; int i;
if ( Abc_NodeIsTravIdCurrent( pObj ) )
return;
Abc_NodeSetTravIdCurrent( pObj );
assert( Abc_ObjIsNode(pObj) );
Abc_ObjForEachFanin( pObj, pNext, i )
{
if ( Abc_ObjIsCi(pNext) || Abc_ObjFaninNum(pNext) == 0 )
continue;
assert( Abc_ObjIsNode(pNext) );
if ( Sfm_MitSlack(p, pNext) <= SlackMax )
Sfm_MitCriticalPath_int( p, pNext, vPath, SlackMax );
}
if ( Abc_ObjFaninNum(pObj) > 0 )
Vec_IntPush( vPath, Abc_ObjId(pObj) );
}
int Sfm_MitCriticalPath( Sfm_Mit_t * p, int Window )
{
int i, SlackMax = p->Delay * Window / 100;
Abc_Obj_t * pObj, * pNext;
Vec_IntClear( &p->vPath );
Abc_NtkIncrementTravId( p->pNtk );
Abc_NtkForEachCo( p->pNtk, pObj, i )
{
pNext = Abc_ObjFanin0(pObj);
if ( Abc_ObjIsCi(pNext) || Abc_ObjFaninNum(pNext) == 0 )
continue;
assert( Abc_ObjIsNode(pNext) );
if ( Sfm_MitSlack(p, pNext) <= SlackMax )
Sfm_MitCriticalPath_int( p, pNext, &p->vPath, SlackMax );
}
return Vec_IntSize(&p->vPath);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Sfm_MitTrace( Sfm_Mit_t * p )
{
Abc_Obj_t * pObj; int i, Delay = 0;
Vec_Ptr_t * vNodes = Abc_NtkDfs( p->pNtk, 1 );
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
Sfm_MitNodeArrival( p, pObj );
Abc_NtkForEachCo( p->pNtk, pObj, i )
Delay = Abc_MaxInt( Delay, Sfm_MitArrMax(p, Abc_ObjFanin0(pObj)) );
Vec_IntFill( &p->vTimReqs, 2*Abc_NtkObjNumMax(p->pNtk), ABC_INFINITY );
Abc_NtkForEachCo( p->pNtk, pObj, i )
Sfm_MitSetReq( p, Abc_ObjFanin0(pObj), Delay );
Vec_PtrForEachEntryReverse( Abc_Obj_t *, vNodes, pObj, i )
Sfm_MitNodeRequired( p, pObj );
Vec_PtrFree( vNodes );
return Delay;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Sfm_Mit_t * Sfm_MitStart( Mio_Library_t * pLib, Scl_Con_t * pExt, Abc_Ntk_t * pNtk, int DeltaCrit )
{
// Abc_Obj_t * pObj; int i;
Sfm_Mit_t * p = ABC_CALLOC( Sfm_Mit_t, 1 );
p->pLib = pLib;
p->pExt = pExt;
p->pNtk = pNtk;
Vec_IntFill( &p->vTimArrs, 3*Abc_NtkObjNumMax(pNtk), 0 );
Vec_IntFill( &p->vTimReqs, 3*Abc_NtkObjNumMax(pNtk), 0 );
// Vec_IntFill( &p->vTimSlews, 3*Abc_NtkObjNumMax(pNtk), 0 );
// Vec_IntFill( &p->vTimLoads, 3*Abc_NtkObjNumMax(pNtk), 0 );
// Vec_IntFill( &p->vObjOffs, 2*Abc_NtkObjNumMax(pNtk), 0 );
// Abc_NtkForEachNode( pNtk, pObj, i )
// {
// Vec_IntWriteEntry( &p->vObjOffs, i, Vec_IntSize(Vec_IntSize(&p->vTimEdges)) );
// Vec_IntFillExtra( &p->vTimEdges, Vec_IntSize(Vec_IntSize(&p->vTimEdges)) + Abc_ObjFaninNum(pObj), 0 );
// }
p->Delay = Sfm_MitTrace( p );
assert( DeltaCrit > 0 && DeltaCrit < MIO_NUM*1000 );
p->DeltaCrit = DeltaCrit;
return p;
}
void Sfm_MitStop( Sfm_Mit_t * p )
{
Vec_IntErase( &p->vTimArrs );
Vec_IntErase( &p->vTimReqs );
Vec_IntErase( &p->vTimSlews );
Vec_IntErase( &p->vTimLoads );
Vec_IntErase( &p->vObjOffs );
Vec_IntErase( &p->vTimEdges );
Vec_WecErase( &p->vLevels );
Vec_IntErase( &p->vPath );
Vec_WrdErase( &p->vSortData );
ABC_FREE( p );
}
int Sfm_MitReadNtkDelay( Sfm_Mit_t * p )
{
return p->Delay;
}
int Sfm_MitReadObjDelay( Sfm_Mit_t * p, int iObj )
{
return Sfm_MitArrMaxId(p, iObj);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Sfm_MitTest( Abc_Ntk_t * pNtk )
{
Mio_Library_t * pLib = (Mio_Library_t *)pNtk->pManFunc;
Sfm_Mit_t * p = Sfm_MitStart( pLib, NULL, pNtk, 100 );
printf( "Max delay = %.2f. Path = %d (%d).\n", MIO_NUMINV*p->Delay, Sfm_MitCriticalPath(p, 1), Abc_NtkNodeNum(p->pNtk) );
Sfm_MitStop( p );
}
/**Function*************************************************************
Synopsis [Levelized structure.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Sfm_MitUpdateClean( Sfm_Mit_t * p )
{
Vec_Int_t * vLevel;
Abc_Obj_t * pObj;
int i, k;
Vec_WecForEachLevel( &p->vLevels, vLevel, i )
{
Abc_NtkForEachObjVec( vLevel, p->pNtk, pObj, k )
{
assert( pObj->fMarkC == 1 );
pObj->fMarkC = 0;
}
Vec_IntClear( vLevel );
}
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Sfm_MitUpdateTiming( Sfm_Mit_t * p, Vec_Int_t * vTimeNodes )
{
assert( Vec_IntSize(vTimeNodes) > 0 && Vec_IntSize(vTimeNodes) <= 2 );
Vec_IntFillExtra( &p->vTimArrs, 2*Abc_NtkObjNumMax(p->pNtk), 0 );
Vec_IntFillExtra( &p->vTimReqs, 2*Abc_NtkObjNumMax(p->pNtk), 0 );
p->Delay = Sfm_MitTrace( p );
}
/**Function*************************************************************
Synopsis [Sort an array of nodes using their max arrival times.]
Description [Returns the number of new divisor nodes.]
SideEffects []
SeeAlso []
***********************************************************************/
int Sfm_MitSortArrayByArrival( Sfm_Mit_t * p, Vec_Int_t * vNodes, int iPivot )
{
word Entry;
int i, Id, nDivNew = -1;
int MaxDelay = Sfm_MitArrMaxId(p, iPivot);
assert( p->DeltaCrit > 0 );
// collect nodes
Vec_WrdClear( &p->vSortData );
Vec_IntForEachEntry( vNodes, Id, i )
Vec_WrdPush( &p->vSortData, ((word)Id << 32) | Sfm_MitArrMaxId(p, Id) );
// sort nodes by delay
Abc_QuickSort3( Vec_WrdArray(&p->vSortData), Vec_WrdSize(&p->vSortData), 0 );
// collect sorted nodes and find place where divisors end
Vec_IntClear( vNodes );
Vec_WrdForEachEntry( &p->vSortData, Entry, i )
{
Vec_IntPush( vNodes, (int)(Entry >> 32) );
if ( nDivNew == -1 && ((int)Entry) + p->DeltaCrit > MaxDelay )
nDivNew = i;
}
return nDivNew;
}
/**Function*************************************************************
Synopsis [Priority of nodes to try remapping for delay.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Sfm_MitPriorityNodes( Sfm_Mit_t * p, Vec_Int_t * vCands, int Window )
{
Vec_Int_t * vLevel;
Abc_Obj_t * pObj;
int i, k;
assert( Window >= 0 && Window <= 100 );
// collect critical path
Sfm_MitCriticalPath( p, Window );
// add nodes to the levelized structure
Sfm_MitUpdateClean( p );
Abc_NtkForEachObjVec( &p->vPath, p->pNtk, pObj, i )
{
assert( pObj->fMarkC == 0 );
pObj->fMarkC = 1;
Vec_WecPush( &p->vLevels, Abc_ObjLevel(pObj), Abc_ObjId(pObj) );
}
// prioritize nodes by expected gain
Vec_WecSort( &p->vLevels, 0 );
Vec_IntClear( vCands );
Vec_WecForEachLevel( &p->vLevels, vLevel, i )
{
// printf( "%d ", Vec_IntSize(vLevel) );
Abc_NtkForEachObjVec( vLevel, p->pNtk, pObj, k )
if ( !pObj->fMarkA )
Vec_IntPush( vCands, Abc_ObjId(pObj) );
// if ( Vec_IntSize(vCands) > 10 )
// break;
}
// printf( "\n" );
// printf( "Path = %5d ", Vec_IntSize(&p->vPath) );
// printf( "Cand = %5d ", Vec_IntSize(vCands) );
return Vec_IntSize(vCands) > 0;
}
/**Function*************************************************************
Synopsis [Returns 1 if node is relatively non-critical compared to the pivot.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Sfm_MitNodeIsNonCritical( Sfm_Mit_t * p, Abc_Obj_t * pPivot, Abc_Obj_t * pNode )
{
return Sfm_MitArrMax(p, pNode) + p->DeltaCrit <= Sfm_MitArrMax(p, pPivot);
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
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 )
{
int TimeOut[2][2];
int * pTimesIn1[6], * pTimesIn2[6];
int i, nFanins1, nFanins2;
// process the first gate
nFanins1 = Mio_GateReadPinNum( pGate1 );
for ( i = 0; i < nFanins1; i++ )
pTimesIn1[i] = Sfm_MitArrId( p, Vec_IntEntry(vMap, Vec_IntEntry(vFanins, (int)pFans1[i])) );
Sfm_MitGateArrival( p, pGate1, pTimesIn1, TimeOut[0] );
if ( pGate2 == NULL )
return Abc_MaxInt(TimeOut[0][0], TimeOut[0][1]);
// process the second gate
nFanins2 = Mio_GateReadPinNum( pGate2 );
for ( i = 0; i < nFanins2; i++ )
if ( (int)pFans2[i] == 16 )
pTimesIn2[i] = TimeOut[0];
else
pTimesIn2[i] = Sfm_MitArrId( p, Vec_IntEntry(vMap, Vec_IntEntry(vFanins, (int)pFans2[i])) );
Sfm_MitGateArrival( p, pGate2, pTimesIn2, TimeOut[1] );
return Abc_MaxInt(TimeOut[1][0], TimeOut[1][1]);
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
/**CFile**************************************************************** /**CFile****************************************************************
FileName [sfmTime.c] FileName [sfmTim.c]
SystemName [ABC: Logic synthesis and verification system.] SystemName [ABC: Logic synthesis and verification system.]
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
Date [Ver. 1.0. Started - June 20, 2005.] Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: sfmTime.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] Revision [$Id: sfmTim.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/ ***********************************************************************/
...@@ -38,11 +38,6 @@ struct Sfm_Tim_t_ ...@@ -38,11 +38,6 @@ struct Sfm_Tim_t_
// timing info // timing info
Vec_Int_t vTimArrs; // arrivals (rise/fall) Vec_Int_t vTimArrs; // arrivals (rise/fall)
Vec_Int_t vTimReqs; // required (rise/fall) Vec_Int_t vTimReqs; // required (rise/fall)
Vec_Int_t vTimSlews; // slews (rise/fall)
Vec_Int_t vTimLoads; // loads (rise/fall)
// timing edges
Vec_Int_t vObjOffs; // object offsets
Vec_Int_t vTimEdges; // edge timings (rise/fall)
// incremental timing // incremental timing
Vec_Wec_t vLevels; // levels Vec_Wec_t vLevels; // levels
// critical path // critical path
...@@ -52,13 +47,9 @@ struct Sfm_Tim_t_ ...@@ -52,13 +47,9 @@ struct Sfm_Tim_t_
static inline int * Sfm_TimArrId( Sfm_Tim_t * p, int Id ) { return Vec_IntEntryP( &p->vTimArrs, Abc_Var2Lit(Id, 0) ); } static inline int * Sfm_TimArrId( Sfm_Tim_t * p, int Id ) { return Vec_IntEntryP( &p->vTimArrs, Abc_Var2Lit(Id, 0) ); }
static inline int * Sfm_TimReqId( Sfm_Tim_t * p, int Id ) { return Vec_IntEntryP( &p->vTimReqs, Abc_Var2Lit(Id, 0) ); } static inline int * Sfm_TimReqId( Sfm_Tim_t * p, int Id ) { return Vec_IntEntryP( &p->vTimReqs, Abc_Var2Lit(Id, 0) ); }
static inline int * Sfm_TimSlewId( Sfm_Tim_t * p, int Id ) { return Vec_IntEntryP( &p->vTimSlews, Abc_Var2Lit(Id, 0) ); }
static inline int * Sfm_TimLoadId( Sfm_Tim_t * p, int Id ) { return Vec_IntEntryP( &p->vTimLoads, Abc_Var2Lit(Id, 0) ); }
static inline int * Sfm_TimArr( Sfm_Tim_t * p, Abc_Obj_t * pNode ) { return Vec_IntEntryP( &p->vTimArrs, Abc_Var2Lit(Abc_ObjId(pNode), 0) ); } static inline int * Sfm_TimArr( Sfm_Tim_t * p, Abc_Obj_t * pNode ) { return Vec_IntEntryP( &p->vTimArrs, Abc_Var2Lit(Abc_ObjId(pNode), 0) ); }
static inline int * Sfm_TimReq( Sfm_Tim_t * p, Abc_Obj_t * pNode ) { return Vec_IntEntryP( &p->vTimReqs, Abc_Var2Lit(Abc_ObjId(pNode), 0) ); } static inline int * Sfm_TimReq( Sfm_Tim_t * p, Abc_Obj_t * pNode ) { return Vec_IntEntryP( &p->vTimReqs, Abc_Var2Lit(Abc_ObjId(pNode), 0) ); }
static inline int * Sfm_TimSlew( Sfm_Tim_t * p, Abc_Obj_t * pNode ) { return Vec_IntEntryP( &p->vTimSlews, Abc_Var2Lit(Abc_ObjId(pNode), 0) ); }
static inline int * Sfm_TimLoad( Sfm_Tim_t * p, Abc_Obj_t * pNode ) { return Vec_IntEntryP( &p->vTimLoads, Abc_Var2Lit(Abc_ObjId(pNode), 0) ); }
static inline int Sfm_TimArrMaxId( Sfm_Tim_t * p, int Id ) { int * a = Sfm_TimArrId(p, Id); return Abc_MaxInt(a[0], a[1]); } static inline int Sfm_TimArrMaxId( Sfm_Tim_t * p, int Id ) { int * a = Sfm_TimArrId(p, Id); return Abc_MaxInt(a[0], a[1]); }
...@@ -237,21 +228,12 @@ int Sfm_TimTrace( Sfm_Tim_t * p ) ...@@ -237,21 +228,12 @@ int Sfm_TimTrace( Sfm_Tim_t * p )
***********************************************************************/ ***********************************************************************/
Sfm_Tim_t * Sfm_TimStart( Mio_Library_t * pLib, Scl_Con_t * pExt, Abc_Ntk_t * pNtk, int DeltaCrit ) Sfm_Tim_t * Sfm_TimStart( Mio_Library_t * pLib, Scl_Con_t * pExt, Abc_Ntk_t * pNtk, int DeltaCrit )
{ {
// Abc_Obj_t * pObj; int i;
Sfm_Tim_t * p = ABC_CALLOC( Sfm_Tim_t, 1 ); Sfm_Tim_t * p = ABC_CALLOC( Sfm_Tim_t, 1 );
p->pLib = pLib; p->pLib = pLib;
p->pExt = pExt; p->pExt = pExt;
p->pNtk = pNtk; p->pNtk = pNtk;
Vec_IntFill( &p->vTimArrs, 3*Abc_NtkObjNumMax(pNtk), 0 ); Vec_IntFill( &p->vTimArrs, 3*Abc_NtkObjNumMax(pNtk), 0 );
Vec_IntFill( &p->vTimReqs, 3*Abc_NtkObjNumMax(pNtk), 0 ); Vec_IntFill( &p->vTimReqs, 3*Abc_NtkObjNumMax(pNtk), 0 );
// Vec_IntFill( &p->vTimSlews, 3*Abc_NtkObjNumMax(pNtk), 0 );
// Vec_IntFill( &p->vTimLoads, 3*Abc_NtkObjNumMax(pNtk), 0 );
// Vec_IntFill( &p->vObjOffs, 2*Abc_NtkObjNumMax(pNtk), 0 );
// Abc_NtkForEachNode( pNtk, pObj, i )
// {
// Vec_IntWriteEntry( &p->vObjOffs, i, Vec_IntSize(Vec_IntSize(&p->vTimEdges)) );
// Vec_IntFillExtra( &p->vTimEdges, Vec_IntSize(Vec_IntSize(&p->vTimEdges)) + Abc_ObjFaninNum(pObj), 0 );
// }
p->Delay = Sfm_TimTrace( p ); p->Delay = Sfm_TimTrace( p );
assert( DeltaCrit > 0 && DeltaCrit < MIO_NUM*1000 ); assert( DeltaCrit > 0 && DeltaCrit < MIO_NUM*1000 );
p->DeltaCrit = DeltaCrit; p->DeltaCrit = DeltaCrit;
...@@ -261,10 +243,6 @@ void Sfm_TimStop( Sfm_Tim_t * p ) ...@@ -261,10 +243,6 @@ void Sfm_TimStop( Sfm_Tim_t * p )
{ {
Vec_IntErase( &p->vTimArrs ); Vec_IntErase( &p->vTimArrs );
Vec_IntErase( &p->vTimReqs ); Vec_IntErase( &p->vTimReqs );
Vec_IntErase( &p->vTimSlews );
Vec_IntErase( &p->vTimLoads );
Vec_IntErase( &p->vObjOffs );
Vec_IntErase( &p->vTimEdges );
Vec_WecErase( &p->vLevels ); Vec_WecErase( &p->vLevels );
Vec_IntErase( &p->vPath ); Vec_IntErase( &p->vPath );
Vec_WrdErase( &p->vSortData ); Vec_WrdErase( &p->vSortData );
...@@ -409,17 +387,10 @@ int Sfm_TimPriorityNodes( Sfm_Tim_t * p, Vec_Int_t * vCands, int Window ) ...@@ -409,17 +387,10 @@ int Sfm_TimPriorityNodes( Sfm_Tim_t * p, Vec_Int_t * vCands, int Window )
Vec_WecSort( &p->vLevels, 0 ); Vec_WecSort( &p->vLevels, 0 );
Vec_IntClear( vCands ); Vec_IntClear( vCands );
Vec_WecForEachLevel( &p->vLevels, vLevel, i ) Vec_WecForEachLevel( &p->vLevels, vLevel, i )
{
// printf( "%d ", Vec_IntSize(vLevel) );
Abc_NtkForEachObjVec( vLevel, p->pNtk, pObj, k ) Abc_NtkForEachObjVec( vLevel, p->pNtk, pObj, k )
if ( !pObj->fMarkA ) if ( !pObj->fMarkA )
Vec_IntPush( vCands, Abc_ObjId(pObj) ); Vec_IntPush( vCands, Abc_ObjId(pObj) );
// if ( Vec_IntSize(vCands) > 10 ) // printf( "Path = %5d Cand = %5d\n", Vec_IntSize(&p->vPath) );
// break;
}
// printf( "\n" );
// printf( "Path = %5d ", Vec_IntSize(&p->vPath) );
// printf( "Cand = %5d ", Vec_IntSize(vCands) );
return Vec_IntSize(vCands) > 0; return Vec_IntSize(vCands) > 0;
} }
......
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