abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sclLoad.c File Reference
#include "sclSize.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Vec_Flt_t
Abc_SclFindWireCaps (SC_WireLoad *pWL, int nFanoutMax)
 DECLARATIONS ///. More...
 
float Abc_SclFindWireLoad (Vec_Flt_t *vWireCaps, int nFans)
 
void Abc_SclAddWireLoad (SC_Man *p, Abc_Obj_t *pObj, int fSubtr)
 
void Abc_SclComputeLoad (SC_Man *p)
 
void Abc_SclUpdateLoad (SC_Man *p, Abc_Obj_t *pObj, SC_Cell *pOld, SC_Cell *pNew)
 
void Abc_SclUpdateLoadSplit (SC_Man *p, Abc_Obj_t *pBuffer, Abc_Obj_t *pFanout)
 

Function Documentation

void Abc_SclAddWireLoad ( SC_Man p,
Abc_Obj_t pObj,
int  fSubtr 
)

Definition at line 100 of file sclLoad.c.

101 {
102  float Load = Abc_SclFindWireLoad( p->vWireCaps, Abc_ObjFanoutNum(pObj) );
103  Abc_SclObjLoad(p, pObj)->rise += fSubtr ? -Load : Load;
104  Abc_SclObjLoad(p, pObj)->fall += fSubtr ? -Load : Load;
105 }
static SC_Pair * Abc_SclObjLoad(SC_Man *p, Abc_Obj_t *pObj)
Definition: sclSize.h:113
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
float Abc_SclFindWireLoad(Vec_Flt_t *vWireCaps, int nFans)
Definition: sclLoad.c:94
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
void Abc_SclComputeLoad ( SC_Man p)

Definition at line 106 of file sclLoad.c.

107 {
108  Abc_Obj_t * pObj, * pFanin;
109  int i, k;
110  // clear load storage
111  Abc_NtkForEachObj( p->pNtk, pObj, i )
112  {
113  SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
114  if ( !Abc_ObjIsPo(pObj) )
115  pLoad->rise = pLoad->fall = 0.0;
116  }
117  // add cell load
118  Abc_NtkForEachNode1( p->pNtk, pObj, i )
119  {
120  SC_Cell * pCell = Abc_SclObjCell( pObj );
121  Abc_ObjForEachFanin( pObj, pFanin, k )
122  {
123  SC_Pair * pLoad = Abc_SclObjLoad( p, pFanin );
124  SC_Pin * pPin = SC_CellPin( pCell, k );
125  pLoad->rise += pPin->rise_cap;
126  pLoad->fall += pPin->fall_cap;
127  }
128  }
129  // add PO load
130  Abc_NtkForEachCo( p->pNtk, pObj, i )
131  {
132  SC_Pair * pLoadPo = Abc_SclObjLoad( p, pObj );
133  SC_Pair * pLoad = Abc_SclObjLoad( p, Abc_ObjFanin0(pObj) );
134  pLoad->rise += pLoadPo->rise;
135  pLoad->fall += pLoadPo->fall;
136  }
137  // add wire load
138  if ( p->pWLoadUsed != NULL )
139  {
140  if ( p->vWireCaps == NULL )
141  p->vWireCaps = Abc_SclFindWireCaps( p->pWLoadUsed, Abc_NtkGetFanoutMax(p->pNtk) );
142  Abc_NtkForEachNode1( p->pNtk, pObj, i )
143  Abc_SclAddWireLoad( p, pObj, 0 );
144  Abc_NtkForEachPi( p->pNtk, pObj, i )
145  Abc_SclAddWireLoad( p, pObj, 0 );
146  }
147  // check input loads
148  if ( p->vInDrive != NULL )
149  {
150  Abc_NtkForEachPi( p->pNtk, pObj, i )
151  {
152  SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
153  if ( Abc_SclObjInDrive(p, pObj) != 0 && (pLoad->rise > Abc_SclObjInDrive(p, pObj) || pLoad->fall > Abc_SclObjInDrive(p, pObj)) )
154  printf( "Maximum input drive strength is exceeded at primary input %d.\n", i );
155  }
156  }
157 /*
158  // transfer load from barbufs
159  Abc_NtkForEachBarBuf( p->pNtk, pObj, i )
160  {
161  SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
162  SC_Pair * pLoadF = Abc_SclObjLoad( p, Abc_ObjFanin(pObj, 0) );
163  SC_PairAdd( pLoadF, pLoad );
164  }
165 */
166  // calculate average load
167 // if ( p->EstLoadMax )
168  {
169  double TotalLoad = 0;
170  int nObjs = 0;
171  Abc_NtkForEachNode1( p->pNtk, pObj, i )
172  {
173  SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
174  TotalLoad += 0.5 * pLoad->fall + 0.5 * pLoad->rise;
175  nObjs++;
176  }
177  Abc_NtkForEachPi( p->pNtk, pObj, i )
178  {
179  SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
180  TotalLoad += 0.5 * pLoad->fall + 0.5 * pLoad->rise;
181  nObjs++;
182  }
183  p->EstLoadAve = (float)(TotalLoad / nObjs);
184 // printf( "Average load = %.2f\n", p->EstLoadAve );
185  }
186 }
#define Abc_NtkForEachNode1(pNtk, pNode, i)
Definition: abc.h:467
static SC_Pair * Abc_SclObjLoad(SC_Man *p, Abc_Obj_t *pObj)
Definition: sclSize.h:113
static Llb_Mgr_t * p
Definition: llb3Image.c:950
float fall_cap
Definition: sclLib.h:173
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static float Abc_SclObjInDrive(SC_Man *p, Abc_Obj_t *pObj)
Definition: sclSize.h:128
ABC_NAMESPACE_IMPL_START Vec_Flt_t * Abc_SclFindWireCaps(SC_WireLoad *pWL, int nFanoutMax)
DECLARATIONS ///.
Definition: sclLoad.c:45
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
if(last==0)
Definition: sparse_int.h:34
static SC_Pin * SC_CellPin(SC_Cell *p, int i)
Definition: sclLib.h:241
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
void Abc_SclAddWireLoad(SC_Man *p, Abc_Obj_t *pObj, int fSubtr)
Definition: sclLoad.c:100
static int Abc_ObjIsPo(Abc_Obj_t *pObj)
Definition: abc.h:348
ABC_DLL int Abc_NtkGetFanoutMax(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:464
float rise_cap
Definition: sclLib.h:172
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
static SC_Cell * Abc_SclObjCell(Abc_Obj_t *p)
Definition: sclSize.h:110
ABC_NAMESPACE_IMPL_START Vec_Flt_t* Abc_SclFindWireCaps ( SC_WireLoad pWL,
int  nFanoutMax 
)

DECLARATIONS ///.

CFile****************************************************************

FileName [sclLoad.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Standard-cell library representation.]

Synopsis [Wire/gate load computations.]

Author [Alan Mishchenko, Niklas Een]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - August 24, 2012.]

Revision [

Id:
sclLoad.c,v 1.0 2012/08/24 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Returns estimated wire capacitances for each fanout count.]

Description []

SideEffects []`

SeeAlso []

Definition at line 45 of file sclLoad.c.

46 {
47  Vec_Flt_t * vCaps = NULL;
48  float EntryPrev, EntryCur, Slope;
49  int i, iPrev, k, Entry, EntryMax;
50  assert( pWL != NULL );
51  // find the biggest fanout count
52  EntryMax = 0;
53  Vec_IntForEachEntry( pWL->vFanout, Entry, i )
54  EntryMax = Abc_MaxInt( EntryMax, Entry );
55  // create the array
56  vCaps = Vec_FltStart( Abc_MaxInt(nFanoutMax, EntryMax) + 1 );
57  Vec_IntForEachEntry( pWL->vFanout, Entry, i )
58  Vec_FltWriteEntry( vCaps, Entry, Vec_FltEntry(pWL->vLen, i) * pWL->cap );
59  // interpolate between the values
60  assert( Vec_FltEntry(vCaps, 1) != 0 );
61  iPrev = 1;
62  EntryPrev = Vec_FltEntry(vCaps, 1);
63  Vec_FltForEachEntryStart( vCaps, EntryCur, i, 2 )
64  {
65  if ( EntryCur == 0 )
66  continue;
67  Slope = (EntryCur - EntryPrev) / (i - iPrev);
68  for ( k = iPrev + 1; k < i; k++ )
69  Vec_FltWriteEntry( vCaps, k, EntryPrev + Slope * (k - iPrev) );
70  EntryPrev = EntryCur;
71  iPrev = i;
72  }
73  // extrapolate after the largest value
74  Slope = pWL->cap * pWL->slope;
75  for ( k = iPrev + 1; k < i; k++ )
76  Vec_FltWriteEntry( vCaps, k, EntryPrev + Slope * (k - iPrev) );
77  // show
78 // Vec_FltForEachEntry( vCaps, EntryCur, i )
79 // printf( "%3d : %f\n", i, EntryCur );
80  return vCaps;
81 }
static void Vec_FltWriteEntry(Vec_Flt_t *p, int i, float Entry)
Definition: vecFlt.h:364
float slope
Definition: sclLib.h:121
#define Vec_FltForEachEntryStart(vVec, Entry, i, Start)
Definition: vecFlt.h:56
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static Vec_Flt_t * Vec_FltStart(int nSize)
Definition: vecFlt.h:101
float cap
Definition: sclLib.h:120
Vec_Int_t * vFanout
Definition: sclLib.h:122
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
Definition: vecFlt.h:42
#define assert(ex)
Definition: util_old.h:213
static float Vec_FltEntry(Vec_Flt_t *p, int i)
Definition: vecFlt.h:342
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
float Abc_SclFindWireLoad ( Vec_Flt_t vWireCaps,
int  nFans 
)

Function*************************************************************

Synopsis [Computes load for all nodes in the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 94 of file sclLoad.c.

95 {
96  if ( vWireCaps == NULL )
97  return 0;
98  return Vec_FltEntry( vWireCaps, Abc_MinInt(nFans, Vec_FltSize(vWireCaps)-1) );
99 }
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
static float Vec_FltEntry(Vec_Flt_t *p, int i)
Definition: vecFlt.h:342
static int Vec_FltSize(Vec_Flt_t *p)
Definition: vecFlt.h:294
void Abc_SclUpdateLoad ( SC_Man p,
Abc_Obj_t pObj,
SC_Cell pOld,
SC_Cell pNew 
)

Function*************************************************************

Synopsis [Updates load of the node's fanins.]

Description []

SideEffects []

SeeAlso []

Definition at line 199 of file sclLoad.c.

200 {
201  Abc_Obj_t * pFanin;
202  int k;
203  Abc_ObjForEachFanin( pObj, pFanin, k )
204  {
205  SC_Pair * pLoad = Abc_SclObjLoad( p, pFanin );
206  SC_Pin * pPinOld = SC_CellPin( pOld, k );
207  SC_Pin * pPinNew = SC_CellPin( pNew, k );
208  pLoad->rise += pPinNew->rise_cap - pPinOld->rise_cap;
209  pLoad->fall += pPinNew->fall_cap - pPinOld->fall_cap;
210  }
211 }
static SC_Pair * Abc_SclObjLoad(SC_Man *p, Abc_Obj_t *pObj)
Definition: sclSize.h:113
static Llb_Mgr_t * p
Definition: llb3Image.c:950
float fall_cap
Definition: sclLib.h:173
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
static SC_Pin * SC_CellPin(SC_Cell *p, int i)
Definition: sclLib.h:241
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
float rise_cap
Definition: sclLib.h:172
void Abc_SclUpdateLoadSplit ( SC_Man p,
Abc_Obj_t pBuffer,
Abc_Obj_t pFanout 
)

Definition at line 212 of file sclLoad.c.

213 {
214  SC_Pin * pPin;
215  SC_Pair * pLoad;
216  int iFanin = Abc_NodeFindFanin( pFanout, pBuffer );
217  assert( iFanin >= 0 );
218  assert( Abc_ObjFaninNum(pBuffer) == 1 );
219  pPin = SC_CellPin( Abc_SclObjCell(pFanout), iFanin );
220  // update load of the buffer
221  pLoad = Abc_SclObjLoad( p, pBuffer );
222  pLoad->rise -= pPin->rise_cap;
223  pLoad->fall -= pPin->fall_cap;
224  // update load of the fanin
225  pLoad = Abc_SclObjLoad( p, Abc_ObjFanin0(pBuffer) );
226  pLoad->rise += pPin->rise_cap;
227  pLoad->fall += pPin->fall_cap;
228 }
static SC_Pair * Abc_SclObjLoad(SC_Man *p, Abc_Obj_t *pObj)
Definition: sclSize.h:113
static Llb_Mgr_t * p
Definition: llb3Image.c:950
float fall_cap
Definition: sclLib.h:173
ABC_DLL int Abc_NodeFindFanin(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
Definition: abcUtil.c:758
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
static SC_Pin * SC_CellPin(SC_Cell *p, int i)
Definition: sclLib.h:241
#define assert(ex)
Definition: util_old.h:213
float rise_cap
Definition: sclLib.h:172
static SC_Cell * Abc_SclObjCell(Abc_Obj_t *p)
Definition: sclSize.h:110