mirror of https://github.com/YosysHQ/abc.git
Improvements to buffering and sizing.
This commit is contained in:
parent
2c7f39026a
commit
f8410b532b
|
|
@ -442,6 +442,9 @@ static inline void Abc_ObjSetMvVar( Abc_Obj_t * pObj, void * pV) { Vec_At
|
|||
#define Abc_NtkForEachObj( pNtk, pObj, i ) \
|
||||
for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pObj) = Abc_NtkObj(pNtk, i)), 1); i++ ) \
|
||||
if ( (pObj) == NULL ) {} else
|
||||
#define Abc_NtkForEachObjReverse( pNtk, pNode, i ) \
|
||||
for ( i = Vec_PtrSize((pNtk)->vObjs) - 1; (i >= 0) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i-- ) \
|
||||
if ( (pNode) == NULL ) {} else
|
||||
#define Abc_NtkForEachObjVec( vIds, pNtk, pObj, i ) \
|
||||
for ( i = 0; i < Vec_IntSize(vIds) && (((pObj) = Abc_NtkObj(pNtk, Vec_IntEntry(vIds,i))), 1); i++ ) \
|
||||
if ( (pObj) == NULL ) {} else
|
||||
|
|
@ -460,7 +463,7 @@ static inline void Abc_ObjSetMvVar( Abc_Obj_t * pObj, void * pV) { Vec_At
|
|||
#define Abc_NtkForEachNodeReverse( pNtk, pNode, i ) \
|
||||
for ( i = Vec_PtrSize((pNtk)->vObjs) - 1; (i >= 0) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i-- ) \
|
||||
if ( (pNode) == NULL || !Abc_ObjIsNode(pNode) ) {} else
|
||||
#define Abc_NtkForEachNodeReverse1( pNtk, pNode, i ) \
|
||||
#define Abc_NtkForEachNodeReverse1( pNtk, pNode, i ) \
|
||||
for ( i = Vec_PtrSize((pNtk)->vObjs) - 1; (i >= 0) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i-- ) \
|
||||
if ( (pNode) == NULL || !Abc_ObjIsNode(pNode) || !Abc_ObjFaninNum(pNode) ) {} else
|
||||
#define Abc_NtkForEachGate( pNtk, pNode, i ) \
|
||||
|
|
|
|||
|
|
@ -988,12 +988,12 @@ void Abc_Init( Abc_Frame_t * pAbc )
|
|||
Dar_LibStart();
|
||||
}
|
||||
{
|
||||
extern void Dau_DsdTest();
|
||||
Dau_DsdTest();
|
||||
// extern void Dau_DsdTest();
|
||||
// Dau_DsdTest();
|
||||
}
|
||||
|
||||
if ( Sdm_ManCanRead() )
|
||||
Sdm_ManRead();
|
||||
// if ( Sdm_ManCanRead() )
|
||||
// Sdm_ManRead();
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
|
|
|||
|
|
@ -946,11 +946,11 @@ int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
|
||||
int c;
|
||||
memset( pPars, 0, sizeof(SC_BusPars) );
|
||||
pPars->GainRatio = 200;
|
||||
pPars->GainRatio = 1000;
|
||||
pPars->Slew = 100;
|
||||
pPars->nDegree = 8;
|
||||
pPars->nDegree = 10;
|
||||
pPars->fSizeOnly = 0;
|
||||
pPars->fAddBufs = 0;
|
||||
pPars->fAddBufs = 1;
|
||||
pPars->fBufPis = 0;
|
||||
pPars->fUseWireLoads = 1;
|
||||
pPars->fVerbose = 0;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "sclSize.h"
|
||||
#include "map/mio/mio.h"
|
||||
#include "base/main/main.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
|
@ -34,6 +35,7 @@ struct Bus_Man_t_
|
|||
// user data
|
||||
SC_BusPars * pPars; // parameters
|
||||
Abc_Ntk_t * pNtk; // user's network
|
||||
SC_Cell * pPiDrive; // PI driver
|
||||
// library
|
||||
SC_Lib * pLib; // cell library
|
||||
SC_Cell * pInv; // base interter (largest/average/???)
|
||||
|
|
@ -93,10 +95,10 @@ Bus_Man_t * Bus_ManStart( Abc_Ntk_t * pNtk, SC_Lib * pLib, SC_BusPars * pPars )
|
|||
}
|
||||
if ( p->pWLoadUsed )
|
||||
p->vWireCaps = Abc_SclFindWireCaps( p->pWLoadUsed );
|
||||
p->vCins = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 1000 );
|
||||
p->vETimes = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 1000 );
|
||||
p->vLoads = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 1000 );
|
||||
p->vDepts = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 1000 );
|
||||
p->vCins = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 10000 );
|
||||
p->vETimes = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 10000 );
|
||||
p->vLoads = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 10000 );
|
||||
p->vDepts = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 10000 );
|
||||
p->vFanouts = Vec_PtrAlloc( 100 );
|
||||
pNtk->pBSMan = p;
|
||||
return p;
|
||||
|
|
@ -125,46 +127,28 @@ void Bus_ManStop( Bus_Man_t * p )
|
|||
***********************************************************************/
|
||||
void Bus_ManReadInOutLoads( Bus_Man_t * p )
|
||||
{
|
||||
Abc_Time_t * pTime;
|
||||
Abc_Obj_t * pObj;
|
||||
int i;
|
||||
if ( p->pNtk->pManTime == NULL )
|
||||
return;
|
||||
// read input load
|
||||
pTime = Abc_NtkReadDefaultInputDrive( p->pNtk );
|
||||
if ( Abc_MaxFloat(pTime->Rise, pTime->Fall) != 0 )
|
||||
if ( Abc_FrameReadMaxLoad() )
|
||||
{
|
||||
printf( "Default input drive strength is specified (%.2f ff; %.2f ff).\n", pTime->Rise, pTime->Fall );
|
||||
Abc_NtkForEachPi( p->pNtk, pObj, i )
|
||||
Bus_SclObjSetCin( pObj, SC_LibCapFromFf(p->pLib, 0.5 * pTime->Rise + 0.5 * pTime->Fall) );
|
||||
Abc_Obj_t * pObj; int i;
|
||||
float MaxLoad = Abc_FrameReadMaxLoad();
|
||||
Abc_NtkForEachPo( p->pNtk, pObj, i )
|
||||
Bus_SclObjSetCin( pObj, MaxLoad );
|
||||
printf( "Default output load is specified (%f ff).\n", SC_LibCapFf(p->pLib, MaxLoad) );
|
||||
}
|
||||
if ( Abc_NodeReadInputDrive(p->pNtk, 0) != NULL )
|
||||
if ( Abc_FrameReadDrivingCell() )
|
||||
{
|
||||
printf( "Input drive strengths for some primary inputs are specified.\n" );
|
||||
Abc_NtkForEachPi( p->pNtk, pObj, i )
|
||||
int iCell = Abc_SclCellFind( p->pLib, Abc_FrameReadDrivingCell() );
|
||||
if ( iCell == -1 )
|
||||
printf( "Cannot find the default PI driving cell (%s) in the library.\n", Abc_FrameReadDrivingCell() );
|
||||
else
|
||||
{
|
||||
pTime = Abc_NodeReadInputDrive(p->pNtk, i);
|
||||
Bus_SclObjSetCin( pObj, SC_LibCapFromFf(p->pLib, 0.5 * pTime->Rise + 0.5 * pTime->Fall) );
|
||||
// printf( "Default PI driving cell is specified (%s).\n", Abc_FrameReadDrivingCell() );
|
||||
p->pPiDrive = SC_LibCell( p->pLib, iCell );
|
||||
assert( p->pPiDrive != NULL );
|
||||
assert( p->pPiDrive->n_inputs == 1 );
|
||||
printf( "Default input driving cell is specified (%s).\n", p->pPiDrive->pName );
|
||||
}
|
||||
}
|
||||
// read output load
|
||||
pTime = Abc_NtkReadDefaultOutputLoad( p->pNtk );
|
||||
if ( Abc_MaxFloat(pTime->Rise, pTime->Fall) != 0 )
|
||||
{
|
||||
printf( "Default output load is specified (%.2f ff; %.2f ff).\n", pTime->Rise, pTime->Fall );
|
||||
Abc_NtkForEachPo( p->pNtk, pObj, i )
|
||||
Bus_SclObjSetCin( pObj, SC_LibCapFromFf(p->pLib, 0.5 * pTime->Rise + 0.5 * pTime->Fall) );
|
||||
}
|
||||
if ( Abc_NodeReadOutputLoad(p->pNtk, 0) != NULL )
|
||||
{
|
||||
printf( "Output loads for some primary outputs are specified.\n" );
|
||||
Abc_NtkForEachPo( p->pNtk, pObj, i )
|
||||
{
|
||||
pTime = Abc_NodeReadOutputLoad(p->pNtk, i);
|
||||
Bus_SclObjSetCin( pObj, SC_LibCapFromFf(p->pLib, 0.5 * pTime->Rise + 0.5 * pTime->Fall) );
|
||||
}
|
||||
}
|
||||
// read arrival/required times
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
|
@ -205,7 +189,7 @@ void Abc_NtkComputeFanoutInfo( Abc_Obj_t * pObj, float Slew )
|
|||
Abc_ObjForEachFanout( pObj, pFanout, i )
|
||||
if ( !Abc_ObjIsCo(pFanout) )
|
||||
{
|
||||
int iFanin = Abc_NodeFindFanin(pFanout, pObj);;
|
||||
int iFanin = Abc_NodeFindFanin(pFanout, pObj);
|
||||
Bus_SclObjSetETime( pFanout, Abc_NtkComputeEdgeDept(pFanout, iFanin, Slew) );
|
||||
Bus_SclObjSetCin( pFanout, SC_CellPinCap( Abc_SclObjCell(pFanout), iFanin ) );
|
||||
}
|
||||
|
|
@ -252,7 +236,9 @@ void Abc_NtkPrintFanoutProfileVec( Abc_Obj_t * pObj, Vec_Ptr_t * vFanouts )
|
|||
Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pFanout, i )
|
||||
{
|
||||
printf( "%3d : time = %7.2f ps load = %7.2f ff ", i, Bus_SclObjETime(pFanout), Bus_SclObjCin(pFanout) );
|
||||
printf( "%s\n", (pObj && Abc_ObjFanoutNum(pObj) == Vec_PtrSize(vFanouts) && Abc_ObjFaninPhase( pFanout, Abc_NodeFindFanin(pFanout, pObj) )) ? "*" : " " );
|
||||
if ( pObj->pNtk->vPhases )
|
||||
printf( "%s", (pObj && Abc_ObjFanoutNum(pObj) == Vec_PtrSize(vFanouts) && Abc_ObjFaninPhase( pFanout, Abc_NodeFindFanin(pFanout, pObj) )) ? "*" : " " );
|
||||
printf( "\n" );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
|
|
@ -400,15 +386,25 @@ void Abc_SclBufSize( Bus_Man_t * p )
|
|||
float Load, LoadNew, Cin, DeptMax = 0;
|
||||
int i, k, nObjOld = Abc_NtkObjNumMax(p->pNtk);
|
||||
Abc_SclMioGates2SclGates( p->pLib, p->pNtk );
|
||||
Abc_NtkForEachNodeReverse1( p->pNtk, pObj, i )
|
||||
Abc_NtkForEachObjReverse( p->pNtk, pObj, i )
|
||||
{
|
||||
if ( !((Abc_ObjIsNode(pObj) && Abc_ObjFaninNum(pObj) > 0) || (Abc_ObjIsCi(pObj) && p->pPiDrive)) )
|
||||
continue;
|
||||
// compute load
|
||||
Abc_NtkComputeFanoutInfo( pObj, p->pPars->Slew );
|
||||
Load = Abc_NtkComputeNodeLoad( p, pObj );
|
||||
// consider the gate
|
||||
pCell = Abc_SclObjCell( pObj );
|
||||
Cin = SC_CellPinCapAve( pCell->pAve );
|
||||
if ( Abc_ObjIsCi(pObj) )
|
||||
{
|
||||
pCell = p->pPiDrive;
|
||||
Cin = SC_CellPinCapAve( pCell );
|
||||
}
|
||||
else
|
||||
{
|
||||
pCell = Abc_SclObjCell( pObj );
|
||||
Cin = SC_CellPinCapAve( pCell->pAve );
|
||||
// Cin = SC_CellPinCapAve( pCell->pRepr->pNext );
|
||||
}
|
||||
// consider upsizing the gate
|
||||
if ( !p->pPars->fSizeOnly && (Abc_ObjFanoutNum(pObj) > p->pPars->nDegree || Load > GainGate * Cin) )
|
||||
{
|
||||
|
|
@ -427,7 +423,7 @@ void Abc_SclBufSize( Bus_Man_t * p )
|
|||
Bus_SclInsertFanout( p->vFanouts, pInv );
|
||||
Load = Abc_NtkComputeFanoutLoad( p, p->vFanouts );
|
||||
}
|
||||
while ( Vec_PtrSize(p->vFanouts) > p->pPars->nDegree || Load > GainGate * Cin );
|
||||
while ( Vec_PtrSize(p->vFanouts) > p->pPars->nDegree || (Vec_PtrSize(p->vFanouts) > 1 && Load > GainGate * Cin) );
|
||||
// update node fanouts
|
||||
Vec_PtrForEachEntry( Abc_Obj_t *, p->vFanouts, pFanout, k )
|
||||
if ( Abc_ObjFaninNum(pFanout) == 0 )
|
||||
|
|
@ -436,6 +432,8 @@ void Abc_SclBufSize( Bus_Man_t * p )
|
|||
LoadNew = Abc_NtkComputeNodeLoad( p, pObj );
|
||||
assert( LoadNew - Load < 1 && Load - LoadNew < 1 );
|
||||
}
|
||||
if ( Abc_ObjIsCi(pObj) )
|
||||
continue;
|
||||
Abc_NtkComputeNodeDeparture( pObj, p->pPars->Slew );
|
||||
// create cell
|
||||
pCellNew = Abc_SclFindSmallestGate( pCell, Load / GainGate );
|
||||
|
|
@ -444,12 +442,23 @@ void Abc_SclBufSize( Bus_Man_t * p )
|
|||
Abc_SclOneNodePrint( p, pObj );
|
||||
assert( p->pPars->fSizeOnly || Abc_ObjFanoutNum(pObj) <= p->pPars->nDegree );
|
||||
}
|
||||
// compute departure time of the PI
|
||||
Abc_NtkForEachCi( p->pNtk, pObj, i )
|
||||
DeptMax = Abc_MaxFloat( DeptMax, Abc_NtkComputeNodeDeparture(pObj, p->pPars->Slew) );
|
||||
{
|
||||
float DeptCur = Abc_NtkComputeNodeDeparture(pObj, p->pPars->Slew);
|
||||
if ( p->pPiDrive )
|
||||
{
|
||||
float Load = Bus_SclObjLoad( pObj );
|
||||
SC_Pair ArrOut, SlewOut, LoadIn = { Load, Load };
|
||||
Scl_LibHandleInputDriver( p->pPiDrive, &LoadIn, &ArrOut, &SlewOut );
|
||||
DeptCur += 0.5 * ArrOut.fall + 0.5 * ArrOut.rise;
|
||||
}
|
||||
DeptMax = Abc_MaxFloat( DeptMax, DeptCur );
|
||||
}
|
||||
Abc_SclSclGates2MioGates( p->pLib, p->pNtk );
|
||||
if ( p->pPars->fVerbose )
|
||||
{
|
||||
printf( "WireLoads = %d. Degree = %d. Target gain =%5d Slew =%5d Inv = %6d Delay =%7.0f ps ",
|
||||
printf( "WireLoads = %d. Degree = %d. Target gain =%5d Slew =%5d Buf = %6d Delay =%7.0f ps ",
|
||||
p->pPars->fUseWireLoads, p->pPars->nDegree, p->pPars->GainRatio, p->pPars->Slew,
|
||||
Abc_NtkObjNumMax(p->pNtk) - nObjOld, SC_LibTimePs(p->pLib, DeptMax) );
|
||||
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ static inline void Abc_SclTimeNodePrint( SC_Man * p, Abc_Obj_t * pObj, int fRise
|
|||
printf( "Cout =%6.1f ff ", Abc_SclObjLoadFf(p, pObj, fRise >= 0 ? fRise : 0) );
|
||||
printf( "Cmax =%6.1f ff ", pCell ? SC_LibCapFf(p->pLib, SC_CellPin(pCell, pCell->n_inputs)->max_out_cap) : 0.0 );
|
||||
printf( "G =%5d ", pCell ? (int)(100.0 * Abc_SclObjLoadAve(p, pObj) / SC_CellPinCapAve(pCell)) : 0 );
|
||||
printf( "SL =%6.1f ps", Abc_SclObjSlackPs(p, pObj, p->MaxDelay0) );
|
||||
// printf( "SL =%6.1f ps", Abc_SclObjSlackPs(p, pObj, p->MaxDelay0) );
|
||||
printf( "\n" );
|
||||
}
|
||||
void Abc_SclTimeNtkPrint( SC_Man * p, int fShowAll, int fPrintPath )
|
||||
|
|
@ -142,7 +142,7 @@ void Abc_SclTimeNtkPrint( SC_Man * p, int fShowAll, int fPrintPath )
|
|||
printf( "(%5.1f %%) ", 100.0 * Abc_SclCountMinSize(p->pLib, p->pNtk, 0) / Abc_NtkNodeNum(p->pNtk) );
|
||||
printf( "Delay =%9.2f ps ", maxDelay );
|
||||
printf( "(%5.1f %%) ", 100.0 * Abc_SclCountNearCriticalNodes(p) / Abc_NtkNodeNum(p->pNtk) );
|
||||
printf( " \n" );
|
||||
printf( " \n" );
|
||||
if ( fShowAll )
|
||||
{
|
||||
// printf( "Timing information for all nodes: \n" );
|
||||
|
|
|
|||
Loading…
Reference in New Issue