abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcIfif.c File Reference
#include "base/abc/abc.h"
#include "map/if/if.h"

Go to the source code of this file.

Data Structures

struct  Abc_IffObj_t_
 
struct  Abc_IffMan_t_
 

Macros

#define IFIF_MAX_LEAVES   6
 DECLARATIONS ///. More...
 

Typedefs

typedef struct Abc_IffObj_t_ Abc_IffObj_t
 
typedef struct Abc_IffMan_t_ Abc_IffMan_t
 

Functions

static Abc_IffObj_tAbc_IffObj (Abc_IffMan_t *p, int i)
 
static float Abc_IffDelay (Abc_IffMan_t *p, Abc_Obj_t *pObj, int fDelay1)
 
Abc_IffMan_tAbc_NtkIfifStart (Abc_Ntk_t *pNtk, Ifif_Par_t *pPars)
 FUNCTION DEFINITIONS ///. More...
 
void Abc_NtkIfifStop (Abc_IffMan_t *p)
 
void Abc_ObjSortByDelay (Abc_IffMan_t *p, Abc_Obj_t *pObj, int fDelay1, Abc_Obj_t **ppNodes)
 
float Abc_ObjDelay0 (Abc_IffMan_t *p, Abc_Obj_t *pObj)
 
float Abc_ObjDelay1 (Abc_IffMan_t *p, Abc_Obj_t *pObj)
 
float Abc_ObjDelayDegree (Abc_IffMan_t *p, Abc_Obj_t *pObj, int d)
 
void Abc_NtkPerformIfif (Abc_Ntk_t *pNtk, Ifif_Par_t *pPars)
 

Macro Definition Documentation

#define IFIF_MAX_LEAVES   6

DECLARATIONS ///.

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

FileName [abcIfif.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Experiment with technology mapping.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
abcIfif.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 30 of file abcIfif.c.

Typedef Documentation

typedef struct Abc_IffMan_t_ Abc_IffMan_t

Definition at line 41 of file abcIfif.c.

typedef struct Abc_IffObj_t_ Abc_IffObj_t

Definition at line 33 of file abcIfif.c.

Function Documentation

static float Abc_IffDelay ( Abc_IffMan_t p,
Abc_Obj_t pObj,
int  fDelay1 
)
inlinestatic

Definition at line 52 of file abcIfif.c.

52 { return Abc_IffObj(p, Abc_ObjId(pObj))->Delay[fDelay1]; }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
float Delay[IFIF_MAX_LEAVES+1]
Definition: abcIfif.c:36
static Abc_IffObj_t * Abc_IffObj(Abc_IffMan_t *p, int i)
Definition: abcIfif.c:51
static Abc_IffObj_t* Abc_IffObj ( Abc_IffMan_t p,
int  i 
)
inlinestatic

Definition at line 51 of file abcIfif.c.

51 { assert( i >= 0 && i < p->nObjs ); return p->pObjs + i; }
Abc_IffObj_t * pObjs
Definition: abcIfif.c:48
#define assert(ex)
Definition: util_old.h:213
Abc_IffMan_t* Abc_NtkIfifStart ( Abc_Ntk_t pNtk,
Ifif_Par_t pPars 
)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 69 of file abcIfif.c.

70 {
71  Abc_IffMan_t * p;
72  p = ABC_CALLOC( Abc_IffMan_t, 1 );
73  p->pNtk = pNtk;
74  p->pPars = pPars;
75  // internal data
76  p->nObjs = Abc_NtkObjNumMax( pNtk );
77  p->pObjs = ABC_CALLOC( Abc_IffObj_t, p->nObjs );
78  return p;
79 }
Abc_IffObj_t * pObjs
Definition: abcIfif.c:48
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Abc_Ntk_t * pNtk
Definition: abcIfif.c:44
Ifif_Par_t * pPars
Definition: abcIfif.c:45
void Abc_NtkIfifStop ( Abc_IffMan_t p)

Definition at line 80 of file abcIfif.c.

81 {
82  // internal data
83  ABC_FREE( p->pObjs );
84  ABC_FREE( p );
85 }
Abc_IffObj_t * pObjs
Definition: abcIfif.c:48
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Abc_NtkPerformIfif ( Abc_Ntk_t pNtk,
Ifif_Par_t pPars 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 255 of file abcIfif.c.

256 {
257  Abc_IffMan_t * p;
258  Abc_IffObj_t * pIffObj;
259  Vec_Ptr_t * vNodes;
260  Abc_Obj_t * pObj;
261  float Delay, Delay10, DegreeFinal;
262  int i, d, Count10;
263  assert( pPars->pLutLib->LutMax >= 0 && pPars->pLutLib->LutMax <= IFIF_MAX_LEAVES );
264  assert( pPars->nLutSize >= 0 && pPars->nLutSize <= IFIF_MAX_LEAVES );
265  assert( pPars->nDegree >= 0 && pPars->nDegree <= IFIF_MAX_LEAVES );
266  // convert to AIGs
267  Abc_NtkToAig( pNtk );
268  Abc_NtkLevel( pNtk );
269 
270  // print parameters
271  if ( pPars->fVerbose )
272  {
273  printf( "Running mapper into LUT structures with the following parameters:\n" );
274  printf( "Pin+Wire: {" );
275  for ( i = 0; i < pPars->pLutLib->LutMax; i++ )
276  printf( " %3.2f", pPars->pLutDelays[i] );
277  printf( " } " );
278  printf( "Wire %3.2f Degree %d Type: %s\n",
279  pPars->DelayWire, pPars->nDegree, pPars->fCascade? "Cascade" : "Cluster" );
280  }
281 
282  // start manager
283  p = Abc_NtkIfifStart( pNtk, pPars );
284 // printf( "Running experiment with LUT delay %d and degree %d (LUT size is %d).\n", DelayWire, nDegree, nLutSize );
285 
286  // compute the delay
287  vNodes = Abc_NtkDfs( pNtk, 0 );
288  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
289  {
290  assert( Abc_ObjIsNode(pObj) );
291  pIffObj = Abc_IffObj( p, Abc_ObjId(pObj) );
292 
293  if ( pPars->fCascade )
294  {
295  for ( d = 0; d <= pPars->nDegree; d++ )
296  pIffObj->Delay[d] = Abc_ObjDelayDegree( p, pObj, d );
297  }
298  else
299  {
300  pIffObj->Delay[0] = Abc_ObjDelay0( p, pObj );
301  pIffObj->Delay[1] = Abc_ObjDelay1( p, pObj );
302  }
303  }
304 
305  // get final degree number
306  if ( pPars->fCascade )
307  DegreeFinal = pPars->nDegree;
308  else
309  DegreeFinal = 1;
310 
311  if ( p->pPars->fVeryVerbose )
312  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
313  {
314  printf( "Node %3d : Lev =%3d ", Abc_ObjId(pObj), Abc_ObjLevel(pObj) );
315  for ( d = 0; d <= DegreeFinal; d++ )
316  printf( "Del%d =%4.2f ", d, Abc_IffDelay(p, pObj, d) );
317  printf( "\n" );
318  }
319  Vec_PtrFree( vNodes );
320 
321 
322  // consider delay at the outputs
323  Delay = 0;
324  Abc_NtkForEachCo( pNtk, pObj, i )
325  Delay = Abc_MaxFloat( Delay, Abc_IffDelay(p, Abc_ObjFanin0(pObj), DegreeFinal) );
326  Delay10 = 0.9 * Delay;
327 
328  // consider delay at the outputs
329  Count10 = 0;
330  Abc_NtkForEachCo( pNtk, pObj, i )
331  if ( Abc_IffDelay(p, Abc_ObjFanin0(pObj), DegreeFinal) >= Delay10 )
332  Count10++;
333 
334  printf( "Critical delay %5.2f. Critical outputs %5.2f %%\n", Delay, 100.0 * Count10 / Abc_NtkCoNum(pNtk) );
335 // printf( "%.2f %.2f\n", Delay, 100.0 * Count10 / Abc_NtkCoNum(pNtk) );
336 
337  // derive a new network
338 
339  // stop manager
340  Abc_NtkIfifStop( p );
341 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int nLutSize
Definition: if.h:89
Abc_IffMan_t * Abc_NtkIfifStart(Abc_Ntk_t *pNtk, Ifif_Par_t *pPars)
FUNCTION DEFINITIONS ///.
Definition: abcIfif.c:69
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int fVerbose
Definition: if.h:95
If_LibLut_t * pLutLib
Definition: if.h:90
float Abc_ObjDelay0(Abc_IffMan_t *p, Abc_Obj_t *pObj)
Definition: abcIfif.c:134
int LutMax
Definition: if.h:173
int fVeryVerbose
Definition: if.h:96
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
#define IFIF_MAX_LEAVES
DECLARATIONS ///.
Definition: abcIfif.c:30
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
void Abc_NtkIfifStop(Abc_IffMan_t *p)
Definition: abcIfif.c:80
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
float Abc_ObjDelayDegree(Abc_IffMan_t *p, Abc_Obj_t *pObj, int d)
Definition: abcIfif.c:227
float Delay[IFIF_MAX_LEAVES+1]
Definition: abcIfif.c:36
static int Abc_ObjLevel(Abc_Obj_t *pObj)
Definition: abc.h:330
float Abc_ObjDelay1(Abc_IffMan_t *p, Abc_Obj_t *pObj)
Definition: abcIfif.c:156
if(last==0)
Definition: sparse_int.h:34
float DelayWire
Definition: if.h:92
int fCascade
Definition: if.h:94
static Abc_IffObj_t * Abc_IffObj(Abc_IffMan_t *p, int i)
Definition: abcIfif.c:51
int nDegree
Definition: if.h:93
ABC_DLL int Abc_NtkToAig(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:1192
float pLutDelays[IF_MAX_LUTSIZE]
Definition: if.h:91
#define assert(ex)
Definition: util_old.h:213
Ifif_Par_t * pPars
Definition: abcIfif.c:45
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1265
static float Abc_IffDelay(Abc_IffMan_t *p, Abc_Obj_t *pObj, int fDelay1)
Definition: abcIfif.c:52
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
float Abc_ObjDelay0 ( Abc_IffMan_t p,
Abc_Obj_t pObj 
)

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

Synopsis [This is the delay which object has all by itself.]

Description [This delay is stored in Delay0.]

SideEffects []

SeeAlso []

Definition at line 134 of file abcIfif.c.

135 {
136  int i;
137  float Delay0 = 0;
138  Abc_Obj_t * ppNodes[6];
139  Abc_ObjSortByDelay( p, pObj, 1, ppNodes );
140  for ( i = 0; i < Abc_ObjFaninNum(pObj); i++ )
141  Delay0 = Abc_MaxFloat( Delay0, Abc_IffDelay(p, ppNodes[i], 1) + p->pPars->pLutDelays[i] );
142  return Delay0;
143 }
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
void Abc_ObjSortByDelay(Abc_IffMan_t *p, Abc_Obj_t *pObj, int fDelay1, Abc_Obj_t **ppNodes)
Definition: abcIfif.c:98
float pLutDelays[IF_MAX_LUTSIZE]
Definition: if.h:91
Ifif_Par_t * pPars
Definition: abcIfif.c:45
static float Abc_IffDelay(Abc_IffMan_t *p, Abc_Obj_t *pObj, int fDelay1)
Definition: abcIfif.c:52
float Abc_ObjDelay1 ( Abc_IffMan_t p,
Abc_Obj_t pObj 
)

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

Synopsis [This is the delay object has in the structure.]

Description [This delay is stored in Delay1.]

SideEffects []

SeeAlso []

Definition at line 156 of file abcIfif.c.

157 {
158  int i, fVeryVerbose = 0;
159 // Abc_IffObj_t * pIfif = Abc_IffObj( p, Abc_ObjId(pObj) );
160  Abc_Obj_t * ppNodes[6];
161  float Delay1, DelayNew;
162 
163  if ( Abc_ObjFaninNum(pObj) == 0 )
164  return 0;
165 
166  // sort fanins by delay1+LutDelay
167  Abc_ObjSortByDelay( p, pObj, 1, ppNodes );
168 
169  // print verbose results
170  if ( fVeryVerbose )
171  {
172  printf( "Object %d Level %d\n", Abc_ObjId(pObj), Abc_ObjLevel(pObj) );
173  for ( i = 0; i < Abc_ObjFaninNum(pObj); i++ )
174  {
175  printf( "Fanin %d : ", i );
176  printf( "D0 %3.2f ", Abc_IffDelay(p, ppNodes[i], 0) );
177  printf( "D0* %3.2f ", Abc_IffDelay(p, ppNodes[i], 0) + p->pPars->pLutDelays[i] - p->pPars->DelayWire );
178  printf( "D1 %3.2f", Abc_IffDelay(p, ppNodes[i], 1) + p->pPars->pLutDelays[i] );
179  printf( "\n" );
180  }
181  printf( "\n" );
182  }
183 /*
184  // for the first nDegree delays, sort them by the minimum Delay1+LutDelay and Delay0-Wire+LutDelay
185  Delay1 = 0;
186  pIfif->nLeaves = 0;
187  for ( i = 0; i < Abc_ObjFaninNum(pObj); i++ )
188  {
189  if ( Abc_ObjIsNode(ppNodes[i]) && pIfif->nLeaves < p->pPars->nDegree )
190  {
191  DelayNew = Abc_MinFloat( Abc_IffDelay(p, ppNodes[i], 1) + p->pPars->pLutDelays[i],
192  Abc_IffDelay(p, ppNodes[i], 0) + p->pPars->pLutDelays[i] - p->pPars->DelayWire );
193  pIfif->pLeaves[pIfif->nLeaves++] = Abc_ObjId(ppNodes[i]);
194  }
195  else
196  DelayNew = Abc_IffDelay(p, ppNodes[i], 1) + p->pPars->pLutDelays[i];
197  Delay1 = Abc_MaxFloat( Delay1, DelayNew );
198  }
199 */
200  // for the first nDegree delays, sort them by the minimum Delay1+LutDelay and Delay0-Wire+LutDelay
201  Delay1 = 0;
202  for ( i = 0; i < Abc_ObjFaninNum(pObj); i++ )
203  {
204  if ( i < p->pPars->nDegree )
205  DelayNew = Abc_MinFloat( Abc_IffDelay(p, ppNodes[i], 1) + p->pPars->pLutDelays[i],
206  Abc_IffDelay(p, ppNodes[i], 0) + p->pPars->pLutDelays[i] - p->pPars->DelayWire );
207  else
208  DelayNew = Abc_IffDelay(p, ppNodes[i], 1) + p->pPars->pLutDelays[i];
209  Delay1 = Abc_MaxFloat( Delay1, DelayNew );
210  }
211  assert( Delay1 > 0 );
212  return Delay1;
213 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
static float Abc_MinFloat(float a, float b)
Definition: abc_global.h:244
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
static int Abc_ObjLevel(Abc_Obj_t *pObj)
Definition: abc.h:330
void Abc_ObjSortByDelay(Abc_IffMan_t *p, Abc_Obj_t *pObj, int fDelay1, Abc_Obj_t **ppNodes)
Definition: abcIfif.c:98
float DelayWire
Definition: if.h:92
float pLutDelays[IF_MAX_LUTSIZE]
Definition: if.h:91
#define assert(ex)
Definition: util_old.h:213
Ifif_Par_t * pPars
Definition: abcIfif.c:45
static float Abc_IffDelay(Abc_IffMan_t *p, Abc_Obj_t *pObj, int fDelay1)
Definition: abcIfif.c:52
float Abc_ObjDelayDegree ( Abc_IffMan_t p,
Abc_Obj_t pObj,
int  d 
)

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

Synopsis [This is the delay which object has all by itself.]

Description [This delay is stored in Delay0.]

SideEffects []

SeeAlso []

Definition at line 227 of file abcIfif.c.

228 {
229  int i;
230  float Delay0 = 0, DelayNew;
231  Abc_Obj_t * ppNodes[6];
232  assert( d >= 0 && d <= p->pPars->nDegree );
233  Abc_ObjSortByDelay( p, pObj, p->pPars->nDegree, ppNodes );
234  for ( i = 0; i < Abc_ObjFaninNum(pObj); i++ )
235  {
236  DelayNew = Abc_IffDelay(p, ppNodes[i], p->pPars->nDegree) + p->pPars->pLutDelays[i];
237  if ( i == 0 && d > 0 )
238  DelayNew = Abc_MinFloat(DelayNew, Abc_IffDelay(p, ppNodes[i], d-1) + p->pPars->pLutDelays[i] - p->pPars->DelayWire );
239  Delay0 = Abc_MaxFloat( Delay0, DelayNew );
240  }
241  return Delay0;
242 }
static float Abc_MinFloat(float a, float b)
Definition: abc_global.h:244
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
void Abc_ObjSortByDelay(Abc_IffMan_t *p, Abc_Obj_t *pObj, int fDelay1, Abc_Obj_t **ppNodes)
Definition: abcIfif.c:98
float DelayWire
Definition: if.h:92
int nDegree
Definition: if.h:93
float pLutDelays[IF_MAX_LUTSIZE]
Definition: if.h:91
#define assert(ex)
Definition: util_old.h:213
Ifif_Par_t * pPars
Definition: abcIfif.c:45
static float Abc_IffDelay(Abc_IffMan_t *p, Abc_Obj_t *pObj, int fDelay1)
Definition: abcIfif.c:52
void Abc_ObjSortByDelay ( Abc_IffMan_t p,
Abc_Obj_t pObj,
int  fDelay1,
Abc_Obj_t **  ppNodes 
)

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

Synopsis [Collects fanins into ppNodes in decreasing order.]

Description []

SideEffects []

SeeAlso []

Definition at line 98 of file abcIfif.c.

99 {
100  Abc_Obj_t * pFanin;
101  int i, a, k = 0;
102  Abc_ObjForEachFanin( pObj, pFanin, i )
103  {
104  ppNodes[k++] = pFanin;
105  if ( Abc_ObjIsCi(pFanin) )
106  continue;
107  for ( a = k-1; a > 0; a-- )
108  if ( Abc_IffDelay(p, ppNodes[a-1], fDelay1) + p->pPars->pLutDelays[a-1] < Abc_IffDelay(p, ppNodes[a], fDelay1) + p->pPars->pLutDelays[a] )
109  ABC_SWAP( Abc_Obj_t *, ppNodes[a-1], ppNodes[a] );
110  }
111 /*
112  for ( a = 1; a < k; a++ )
113  {
114  float D1 = Abc_IffDelay(p, ppNodes[a-1], fDelay1);
115  float D2 = Abc_IffDelay(p, ppNodes[a], fDelay1);
116  if ( Abc_ObjIsCi(ppNodes[a-1]) || Abc_ObjIsCi(ppNodes[a]) )
117  continue;
118  assert( Abc_IffDelay(p, ppNodes[a-1], fDelay1) + p->pPars->pLutDelays[a-1] >= Abc_IffDelay(p, ppNodes[a], fDelay1) + p->pPars->pLutDelays[a] - 0.01 );
119  }
120 */
121 }
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
float pLutDelays[IF_MAX_LUTSIZE]
Definition: if.h:91
Ifif_Par_t * pPars
Definition: abcIfif.c:45
static float Abc_IffDelay(Abc_IffMan_t *p, Abc_Obj_t *pObj, int fDelay1)
Definition: abcIfif.c:52