mirror of
https://github.com/YosysHQ/abc.git
synced 2026-09-07 11:11:19 +02:00
Extending and improving timing manager.
This commit is contained in:
@@ -350,7 +350,7 @@ Abc_FlowRetime_MainLoop( ) {
|
||||
|
||||
// assert(!pManMR->fComputeInitState || 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;
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@ SRC += src/opt/sfm/sfmCnf.c \
|
||||
src/opt/sfm/sfmLib.c \
|
||||
src/opt/sfm/sfmNtk.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
|
||||
|
||||
+75
-19
@@ -40,6 +40,7 @@ struct Sfm_Dec_t_
|
||||
Sfm_Par_t * pPars; // parameters
|
||||
Sfm_Lib_t * pLib; // library
|
||||
Sfm_Tim_t * pTim; // timing
|
||||
Sfm_Mit_t * pMit; // timing
|
||||
Abc_Ntk_t * pNtk; // network
|
||||
// library
|
||||
Vec_Int_t vGateSizes; // fanin counts
|
||||
@@ -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_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 ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -208,7 +211,12 @@ p->timeLib = Abc_Clock();
|
||||
p->pLib = Sfm_LibPrepare( pPars->nVarMax, 1, !pPars->fArea, pPars->fVerbose, pPars->fLibVerbose );
|
||||
p->timeLib = Abc_Clock() - p->timeLib;
|
||||
if ( !pPars->fArea )
|
||||
p->pTim = Sfm_TimStart( pLib, NULL, pNtk, p->DeltaCrit );
|
||||
{
|
||||
if ( p->pMit )
|
||||
p->pMit = Sfm_MitStart( pLib, NULL, pNtk, p->DeltaCrit );
|
||||
else
|
||||
p->pTim = Sfm_TimStart( pLib, NULL, pNtk, p->DeltaCrit );
|
||||
}
|
||||
if ( pPars->fVeryVerbose )
|
||||
// if ( pPars->fVerbose )
|
||||
Sfm_LibPrint( p->pLib );
|
||||
@@ -236,6 +244,7 @@ void Sfm_DecStop( Sfm_Dec_t * p )
|
||||
printf( "Level count mismatch at node %d.\n", i );
|
||||
Sfm_LibStop( p->pLib );
|
||||
if ( p->pTim ) Sfm_TimStop( p->pTim );
|
||||
if ( p->pMit ) Sfm_MitStop( p->pMit );
|
||||
// divisors
|
||||
for ( i = 0; i < SFM_SUPP_MAX; i++ )
|
||||
ABC_FREE( p->pDivWords[i] );
|
||||
@@ -1195,7 +1204,7 @@ int Sfm_DecPeformDec3( Sfm_Dec_t * p, Abc_Obj_t * pObj )
|
||||
Vec_IntClear( &p->vObjDec );
|
||||
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
|
||||
if ( Vec_IntSize(&p->vObjDec) > Prev )
|
||||
Vec_IntShrink( &p->vObjDec, Prev );
|
||||
@@ -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] );
|
||||
if ( fVeryVerbose )
|
||||
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 )
|
||||
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 )
|
||||
char * pFans1 = (char *)Vec_PtrEntry( &p->vMatchFans, 2*k+0 );
|
||||
char * pFans2 = (char *)Vec_PtrEntry( &p->vMatchFans, 2*k+1 );
|
||||
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 )
|
||||
{
|
||||
DelayMin = Delay;
|
||||
@@ -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);
|
||||
}
|
||||
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;
|
||||
assert( nMffcMax > 0 );
|
||||
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_PIVOT;
|
||||
@@ -1408,14 +1444,14 @@ void Sfm_DecMarkMffc( Abc_Obj_t * pPivot, int nLevelMin, int nMffcMax, int fVery
|
||||
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 )
|
||||
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( "Node %d: ", pPivot->Id );
|
||||
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" );
|
||||
*/
|
||||
}
|
||||
@@ -1473,7 +1509,7 @@ void Sfm_DecMarkMffc( Abc_Obj_t * pPivot, int nLevelMin, int nMffcMax, int fVery
|
||||
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;
|
||||
Vec_Int_t * vLevel;
|
||||
@@ -1505,7 +1541,7 @@ printf( "\n\nTarget %d\n", Abc_ObjId(pPivot) );
|
||||
nTfiSize = Vec_IntSize(vTfi);
|
||||
Sfm_ObjFlipNode( pPivot );
|
||||
// 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 );
|
||||
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) );
|
||||
@@ -1534,7 +1570,22 @@ printf( "\nSides:\n" );
|
||||
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 );
|
||||
// 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);
|
||||
Vec_IntClear( vTfo );
|
||||
@@ -1757,7 +1808,7 @@ Abc_Obj_t * Abc_NtkAreaOptOne( Sfm_Dec_t * p, int i )
|
||||
pPars->fVeryVerbose = (int)(i == pPars->iNodeOne);
|
||||
p->nNodesTried++;
|
||||
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;
|
||||
if ( pPars->nWinSizeMax && pPars->nWinSizeMax < Vec_IntSize(&p->vObjGates) )
|
||||
return NULL;
|
||||
@@ -1877,18 +1928,20 @@ void Abc_NtkDelayOpt( Sfm_Dec_t * p )
|
||||
// collect nodes
|
||||
if ( 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;
|
||||
// try improving delay for the nodes according to the priority
|
||||
Abc_NtkForEachObjVec( &p->vCands, p->pNtk, pObj, i )
|
||||
{
|
||||
int OldId = Abc_ObjId(pObj);
|
||||
int DelayOld = Sfm_TimReadObjDelay(p->pTim, OldId);
|
||||
int DelayOld = Sfm_ManReadObjDelay(p, OldId);
|
||||
assert( pObj->fMarkA == 0 );
|
||||
|
||||
p->nNodesTried++;
|
||||
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;
|
||||
if ( p->nDivs < 2 || (pPars->nWinSizeMax && pPars->nWinSizeMax < Vec_IntSize(&p->vObjGates)) )
|
||||
{
|
||||
@@ -1951,15 +2004,18 @@ p->timeSat += Abc_Clock() - clk;
|
||||
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 );
|
||||
clk = Abc_Clock();
|
||||
Sfm_TimUpdateTiming( p->pTim, &p->vTemp );
|
||||
if ( p->pMit )
|
||||
Sfm_MitUpdateTiming( p->pMit, &p->vTemp );
|
||||
else
|
||||
Sfm_TimUpdateTiming( p->pTim, &p->vTemp );
|
||||
p->timeTime += Abc_Clock() - clk;
|
||||
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
|
||||
if ( pPars->fDelayVerbose )
|
||||
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),
|
||||
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) );
|
||||
break;
|
||||
}
|
||||
|
||||
+12
-1
@@ -63,6 +63,7 @@ ABC_NAMESPACE_HEADER_START
|
||||
typedef struct Sfm_Fun_t_ Sfm_Fun_t;
|
||||
typedef struct Sfm_Lib_t_ Sfm_Lib_t;
|
||||
typedef struct Sfm_Tim_t_ Sfm_Tim_t;
|
||||
typedef struct Sfm_Mit_t_ Sfm_Mit_t;
|
||||
|
||||
struct Sfm_Ntk_t_
|
||||
{
|
||||
@@ -214,7 +215,7 @@ extern void Sfm_NtkUpdate( Sfm_Ntk_t * p, int iNode, int f, int iFaninNe
|
||||
/*=== sfmSat.c ==========================================================*/
|
||||
extern int Sfm_NtkWindowToSolver( 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 void Sfm_TimStop( 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
|
||||
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_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 ==========================================================*/
|
||||
extern int Sfm_ObjMffcSize( Sfm_Ntk_t * p, int iObj );
|
||||
extern int Sfm_NtkCreateWindow( Sfm_Ntk_t * p, int iNode, int fVerbose );
|
||||
|
||||
@@ -0,0 +1,483 @@
|
||||
/**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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**CFile****************************************************************
|
||||
|
||||
FileName [sfmTime.c]
|
||||
FileName [sfmTim.c]
|
||||
|
||||
SystemName [ABC: Logic synthesis and verification system.]
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
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_
|
||||
// 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
|
||||
@@ -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_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_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]); }
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
// Abc_Obj_t * pObj; int i;
|
||||
Sfm_Tim_t * p = ABC_CALLOC( Sfm_Tim_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_TimTrace( p );
|
||||
assert( DeltaCrit > 0 && DeltaCrit < MIO_NUM*1000 );
|
||||
p->DeltaCrit = DeltaCrit;
|
||||
@@ -261,10 +243,6 @@ void Sfm_TimStop( Sfm_Tim_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 );
|
||||
@@ -409,17 +387,10 @@ int Sfm_TimPriorityNodes( Sfm_Tim_t * p, Vec_Int_t * vCands, int Window )
|
||||
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) );
|
||||
// printf( "Path = %5d Cand = %5d\n", Vec_IntSize(&p->vPath) );
|
||||
return Vec_IntSize(vCands) > 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user