ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ifTime.c File Reference
#include "if.h"
Include dependency graph for ifTime.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void If_CutSortInputPins (If_Man_t *p, If_Cut_t *pCut, int *pPinPerm, float *pPinDelays)
 DECLARATIONS ///.
 
float If_CutDelay (If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut)
 
void If_CutPropagateRequired (If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut, float ObjRequired)
 
float If_ManDelayMax (If_Man_t *p, int fSeq)
 
void If_ManComputeRequired (If_Man_t *p)
 

Function Documentation

◆ If_CutDelay()

float If_CutDelay ( If_Man_t * p,
If_Obj_t * pObj,
If_Cut_t * pCut )

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

Synopsis [Computes delay.]

Description []

SideEffects []

SeeAlso []

Definition at line 91 of file ifTime.c.

92{
93 static int pPinPerm[IF_MAX_LUTSIZE];
94 static float pPinDelays[IF_MAX_LUTSIZE];
95 char * pPerm = If_CutPerm( pCut );
96 If_Obj_t * pLeaf;
97 float Delay, DelayCur;
98 float * pLutDelays;
99 int i, Shift, Pin2PinDelay;//, iLeaf;
100 Delay = -IF_FLOAT_LARGE;
101 if ( pCut->fAndCut )
102 {
103 If_CutForEachLeaf( p, pCut, pLeaf, i )
104 {
105 DelayCur = If_ObjCutBest(pLeaf)->Delay + p->pPars->nAndDelay;
106 Delay = IF_MAX( Delay, DelayCur );
107 }
108 }
109 else if ( p->pPars->pLutLib )
110 {
111 assert( !p->pPars->fLiftLeaves );
112 pLutDelays = p->pPars->pLutLib->pLutDelays[pCut->nLeaves];
113 if ( p->pPars->pLutLib->fVarPinDelays )
114 {
115 // compute the delay using sorted pins
116 If_CutSortInputPins( p, pCut, pPinPerm, pPinDelays );
117 for ( i = 0; i < (int)pCut->nLeaves; i++ )
118 {
119 DelayCur = pPinDelays[pPinPerm[i]] + pLutDelays[i];
120 Delay = IF_MAX( Delay, DelayCur );
121 }
122 }
123 else
124 {
125 If_CutForEachLeaf( p, pCut, pLeaf, i )
126 {
127 DelayCur = If_ObjCutBest(pLeaf)->Delay + pLutDelays[0];
128 Delay = IF_MAX( Delay, DelayCur );
129 }
130 }
131 }
132 else
133 {
134 if ( pCut->fUser )
135 {
136 assert( !p->pPars->fLiftLeaves );
137 If_CutForEachLeaf( p, pCut, pLeaf, i )
138 {
139 Pin2PinDelay = pPerm ? (pPerm[i] == IF_BIG_CHAR ? -IF_BIG_CHAR : pPerm[i]) : 1;
140 DelayCur = If_ObjCutBest(pLeaf)->Delay + (float)Pin2PinDelay;
141 Delay = IF_MAX( Delay, DelayCur );
142 }
143 }
144 else
145 {
146 if ( p->pPars->fLiftLeaves )
147 {
148 If_CutForEachLeafSeq( p, pCut, pLeaf, Shift, i )
149 {
150 DelayCur = If_ObjCutBest(pLeaf)->Delay - Shift * p->Period;
151 Delay = IF_MAX( Delay, DelayCur + 1.0 );
152 }
153 }
154 else
155 {
156 If_CutForEachLeaf( p, pCut, pLeaf, i )
157 {
158 DelayCur = If_ObjCutBest(pLeaf)->Delay + 1.0;
159 Delay = IF_MAX( Delay, DelayCur );
160 }
161 }
162 }
163 }
164 return Delay;
165}
Cube * p
Definition exorList.c:222
ABC_NAMESPACE_IMPL_START void If_CutSortInputPins(If_Man_t *p, If_Cut_t *pCut, int *pPinPerm, float *pPinDelays)
DECLARATIONS ///.
Definition ifTime.c:44
#define IF_BIG_CHAR
Definition if.h:61
#define IF_MAX_LUTSIZE
INCLUDES ///.
Definition if.h:53
#define IF_FLOAT_LARGE
Definition if.h:469
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
Definition if.h:503
#define If_CutForEachLeafSeq(p, pCut, pLeaf, Shift, i)
Definition if.h:510
#define IF_MAX(a, b)
Definition if.h:466
struct If_Obj_t_ If_Obj_t
Definition if.h:79
unsigned nLeaves
Definition if.h:316
unsigned fAndCut
Definition if.h:314
unsigned fUser
Definition if.h:312
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_CutPropagateRequired()

void If_CutPropagateRequired ( If_Man_t * p,
If_Obj_t * pObj,
If_Cut_t * pCut,
float ObjRequired )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 178 of file ifTime.c.

179{
180 static int pPinPerm[IF_MAX_LUTSIZE];
181 static float pPinDelays[IF_MAX_LUTSIZE];
182 If_Obj_t * pLeaf;
183 float * pLutDelays;
184 float Required;
185 int i, Pin2PinDelay;//, iLeaf;
186 assert( !p->pPars->fLiftLeaves );
187 // compute the pins
188 if ( pCut->fAndCut )
189 {
190 If_CutForEachLeaf( p, pCut, pLeaf, i )
191 pLeaf->Required = IF_MIN( pLeaf->Required, ObjRequired - p->pPars->nAndDelay );
192 }
193 else if ( p->pPars->pLutLib )
194 {
195 pLutDelays = p->pPars->pLutLib->pLutDelays[pCut->nLeaves];
196 if ( p->pPars->pLutLib->fVarPinDelays )
197 {
198 // compute the delay using sorted pins
199 If_CutSortInputPins( p, pCut, pPinPerm, pPinDelays );
200 for ( i = 0; i < (int)pCut->nLeaves; i++ )
201 {
202 Required = ObjRequired - pLutDelays[i];
203 pLeaf = If_ManObj( p, pCut->pLeaves[pPinPerm[i]] );
204 pLeaf->Required = IF_MIN( pLeaf->Required, Required );
205 }
206 }
207 else
208 {
209 Required = ObjRequired;
210 If_CutForEachLeaf( p, pCut, pLeaf, i )
211 pLeaf->Required = IF_MIN( pLeaf->Required, Required - pLutDelays[0] );
212 }
213 }
214 else if ( p->pPars->fUserLutDec || p->pPars->fUserLut2D )
215 {
216 Required = ObjRequired;
217 If_CutForEachLeaf( p, pCut, pLeaf, i )
218 pLeaf->Required = IF_MIN( pLeaf->Required, Required - If_LutDecPinRequired( p, pCut, i, ObjRequired ) );
219 }
220 else
221 {
222 if ( pCut->fUser )
223 {
224 char Perm[IF_MAX_FUNC_LUTSIZE], * pPerm = Perm;
225 if ( p->pPars->fDelayOpt )
226 {
227 int Delay = If_CutSopBalancePinDelays( p, pCut, pPerm );
228 assert( Delay == (int)pCut->Delay );
229 }
230 else if ( p->pPars->fDelayOptLut )
231 {
232 int Delay = If_CutLutBalancePinDelays( p, pCut, pPerm );
233 assert( Delay == (int)pCut->Delay );
234 }
235 else if ( p->pPars->fDsdBalance )
236 {
237 int Delay = If_CutDsdBalancePinDelays( p, pCut, pPerm );
238 assert( Delay == (int)pCut->Delay );
239 }
240 else
241 pPerm = If_CutPerm(pCut);
242 If_CutForEachLeaf( p, pCut, pLeaf, i )
243 {
244 Pin2PinDelay = pPerm ? (pPerm[i] == IF_BIG_CHAR ? -IF_BIG_CHAR : pPerm[i]) : 1;
245 Required = ObjRequired - (float)Pin2PinDelay;
246 pLeaf->Required = IF_MIN( pLeaf->Required, Required );
247 }
248 }
249 else
250 {
251 Required = ObjRequired;
252 If_CutForEachLeaf( p, pCut, pLeaf, i )
253 pLeaf->Required = IF_MIN( pLeaf->Required, Required - (float)1.0 );
254 }
255 }
256}
float If_LutDecPinRequired(If_Man_t *p, If_Cut_t *pCut, int i, float required)
Definition ifDelay.c:625
int If_CutLutBalancePinDelays(If_Man_t *p, If_Cut_t *pCut, char *pPerm)
Definition ifDelay.c:327
#define IF_MIN(a, b)
MACRO DEFINITIONS ///.
Definition if.h:465
#define IF_MAX_FUNC_LUTSIZE
Definition if.h:55
int If_CutSopBalancePinDelays(If_Man_t *p, If_Cut_t *pCut, char *pPerm)
Definition ifDelay.c:159
int If_CutDsdBalancePinDelays(If_Man_t *p, If_Cut_t *pCut, char *pPerm)
Definition ifDsd.c:2183
int pLeaves[0]
Definition if.h:318
float Delay
Definition if.h:306
float Required
Definition if.h:353
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_CutSortInputPins()

ABC_NAMESPACE_IMPL_START void If_CutSortInputPins ( If_Man_t * p,
If_Cut_t * pCut,
int * pPinPerm,
float * pPinDelays )

DECLARATIONS ///.

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

FileName [ifTime.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [FPGA mapping based on priority cuts.]

Synopsis [Computation of delay paramters depending on the library.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - November 21, 2006.]

Revision [

Id
ifTime.c,v 1.00 2006/11/21 00:00:00 alanmi Exp

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

Synopsis [Sorts the pins in the decreasing order of delays.]

Description []

SideEffects []

SeeAlso []

Definition at line 44 of file ifTime.c.

45{
46 If_Obj_t * pLeaf;
47 int i, j, best_i, temp;
48 // start the trivial permutation and collect pin delays
49 If_CutForEachLeaf( p, pCut, pLeaf, i )
50 {
51 pPinPerm[i] = i;
52 pPinDelays[i] = If_ObjCutBest(pLeaf)->Delay;
53 }
54 // selection sort the pins in the decreasible order of delays
55 // this order will match the increasing order of LUT input pins
56 for ( i = 0; i < (int)pCut->nLeaves-1; i++ )
57 {
58 best_i = i;
59 for ( j = i+1; j < (int)pCut->nLeaves; j++ )
60 if ( pPinDelays[pPinPerm[j]] > pPinDelays[pPinPerm[best_i]] )
61 best_i = j;
62 if ( best_i == i )
63 continue;
64 temp = pPinPerm[i];
65 pPinPerm[i] = pPinPerm[best_i];
66 pPinPerm[best_i] = temp;
67 }
68/*
69 // verify
70 assert( pPinPerm[0] < (int)pCut->nLeaves );
71 for ( i = 1; i < (int)pCut->nLeaves; i++ )
72 {
73 assert( pPinPerm[i] < (int)pCut->nLeaves );
74 assert( pPinDelays[pPinPerm[i-1]] >= pPinDelays[pPinPerm[i]] );
75 }
76*/
77}
Here is the caller graph for this function:

◆ If_ManComputeRequired()

void If_ManComputeRequired ( If_Man_t * p)

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

Synopsis [Computes the required times of all nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 313 of file ifTime.c.

314{
315 If_Obj_t * pObj;
316 int i, Counter;
317 float reqTime;
318
319 // compute area, clean required times, collect nodes used in the mapping
320// p->AreaGlo = If_ManScanMapping( p );
322 if ( p->pManTim == NULL )
323 {
324 // get the global required times
325 p->RequiredGlo = If_ManDelayMax( p, 0 );
326
327 // consider the case when the required times are given
328 if ( p->pPars->pTimesReq && !p->pPars->fAreaOnly )
329 {
330 // make sure that the required time hold
331 Counter = 0;
332 If_ManForEachCo( p, pObj, i )
333 {
334 if ( If_ObjArrTime(If_ObjFanin0(pObj)) > p->pPars->pTimesReq[i] + p->fEpsilon )
335 {
336 If_ObjFanin0(pObj)->Required = If_ObjArrTime(If_ObjFanin0(pObj));
337 Counter++;
338 // Abc_Print( 0, "Required times are violated for output %d (arr = %d; req = %d).\n",
339 // i, (int)If_ObjArrTime(If_ObjFanin0(pObj)), (int)p->pPars->pTimesReq[i] );
340 }
341 else
342 If_ObjFanin0(pObj)->Required = p->pPars->pTimesReq[i];
343 }
344 if ( Counter && !p->fReqTimeWarn )
345 {
346 Abc_Print( 0, "Required times are exceeded at %d output%s. The earliest arrival times are used.\n", Counter, Counter > 1 ? "s":"" );
347 p->fReqTimeWarn = 1;
348 }
349 }
350 else
351 {
352 // find new delay target
353 if ( p->pPars->nRelaxRatio && p->pPars->DelayTargetNew == 0 )
354 p->pPars->DelayTargetNew = p->RequiredGlo * (100.0 + p->pPars->nRelaxRatio) / 100.0;
355
356 // update the required times according to the target
357 if ( p->pPars->DelayTarget != -1 )
358 {
359 if ( p->RequiredGlo > p->pPars->DelayTarget + p->fEpsilon )
360 {
361 if ( p->fNextRound == 0 )
362 {
363 p->fNextRound = 1;
364 Abc_Print( 0, "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->pPars->DelayTarget );
365 }
366 }
367 else if ( p->RequiredGlo < p->pPars->DelayTarget - p->fEpsilon )
368 {
369 if ( p->fNextRound == 0 )
370 {
371 p->fNextRound = 1;
372// Abc_Print( 0, "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
373 }
374 p->RequiredGlo = p->pPars->DelayTarget;
375 }
376 }
377 else if ( p->pPars->DelayTargetNew > 0 ) // relax the required times
378 p->RequiredGlo = p->pPars->DelayTargetNew;
379 // do not propagate required times if area minimization is requested
380 if ( p->pPars->fAreaOnly )
381 return;
382 // set the required times for the POs
383 if ( p->pPars->fDoAverage )
384 {
385 if ( p->pPars->nRelaxRatio )
386 {
387 If_ManForEachCo( p, pObj, i )
388 If_ObjFanin0(pObj)->Required = If_ObjArrTime(If_ObjFanin0(pObj)) * (100.0 + p->pPars->nRelaxRatio) / 100.0;
389 }
390 else
391 {
392 If_ManForEachCo( p, pObj, i )
393 If_ObjFanin0(pObj)->Required = If_ObjArrTime(If_ObjFanin0(pObj));
394 }
395 }
396 else if ( p->pPars->fLatchPaths )
397 {
398 If_ManForEachLatchInput( p, pObj, i )
399 If_ObjFanin0(pObj)->Required = p->RequiredGlo;
400 }
401 else
402 {
403 If_ManForEachCo( p, pObj, i )
404 If_ObjFanin0(pObj)->Required = p->RequiredGlo;
405 }
406 }
407 // go through the nodes in the reverse topological order
408 // Vec_PtrForEachEntry( If_Obj_t *, p->vMapped, pObj, i )
409 // If_CutPropagateRequired( p, pObj, If_ObjCutBest(pObj), pObj->Required );
410 If_ManForEachObjReverse( p, pObj, i )
411 {
412 if ( pObj->nRefs == 0 )
413 continue;
414 If_CutPropagateRequired( p, pObj, If_ObjCutBest(pObj), pObj->Required );
415 }
416 }
417 else
418 {
419 // get the global required times
420 p->RequiredGlo = If_ManDelayMax( p, 0 );
421
422 // find new delay target
423 if ( p->pPars->nRelaxRatio && p->pPars->DelayTargetNew == 0 )
424 p->pPars->DelayTargetNew = p->RequiredGlo * (100.0 + p->pPars->nRelaxRatio) / 100.0;
425
426 // update the required times according to the target
427 if ( p->pPars->DelayTarget != -1 )
428 {
429 if ( p->RequiredGlo > p->pPars->DelayTarget + p->fEpsilon )
430 {
431 if ( p->fNextRound == 0 )
432 {
433 p->fNextRound = 1;
434 Abc_Print( 0, "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->pPars->DelayTarget );
435 }
436 }
437 else if ( p->RequiredGlo < p->pPars->DelayTarget - p->fEpsilon )
438 {
439 if ( p->fNextRound == 0 )
440 {
441 p->fNextRound = 1;
442// Abc_Print( 0, "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
443 }
444 p->RequiredGlo = p->pPars->DelayTarget;
445 }
446 }
447 else if ( p->pPars->DelayTargetNew > 0 ) // relax the required times
448 p->RequiredGlo = p->pPars->DelayTargetNew;
449
450 // do not propagate required times if area minimization is requested
451 if ( p->pPars->fAreaOnly )
452 return;
453 // set the required times for the POs
454 Tim_ManIncrementTravId( p->pManTim );
455 if ( p->vCoAttrs )
456 {
457 assert( If_ManCoNum(p) == Vec_IntSize(p->vCoAttrs) );
458 If_ManForEachCo( p, pObj, i )
459 {
460 if ( Vec_IntEntry(p->vCoAttrs, i) == -1 ) // -1=internal
461 continue;
462 if ( Vec_IntEntry(p->vCoAttrs, i) == 0 ) // 0=optimize
463 Tim_ManSetCoRequired( p->pManTim, i, p->RequiredGlo );
464 else if ( Vec_IntEntry(p->vCoAttrs, i) == 1 ) // 1=keep
465 Tim_ManSetCoRequired( p->pManTim, i, If_ObjArrTime(If_ObjFanin0(pObj)) );
466 else if ( Vec_IntEntry(p->vCoAttrs, i) == 2 ) // 2=relax
467 Tim_ManSetCoRequired( p->pManTim, i, IF_FLOAT_LARGE );
468 else assert( 0 );
469 }
470 }
471 else if ( p->pPars->fDoAverage )
472 {
473 if ( p->pPars->nRelaxRatio )
474 {
475 If_ManForEachCo( p, pObj, i )
476 Tim_ManSetCoRequired( p->pManTim, i, If_ObjArrTime(If_ObjFanin0(pObj)) * (100.0 + p->pPars->nRelaxRatio) / 100.0 );
477 }
478 else
479 {
480 If_ManForEachCo( p, pObj, i )
481 Tim_ManSetCoRequired( p->pManTim, i, If_ObjArrTime(If_ObjFanin0(pObj)) );
482 }
483 }
484 else if ( p->pPars->fLatchPaths )
485 {
486 If_ManForEachPo( p, pObj, i )
487 Tim_ManSetCoRequired( p->pManTim, i, IF_FLOAT_LARGE );
488 If_ManForEachLatchInput( p, pObj, i )
489 Tim_ManSetCoRequired( p->pManTim, i, p->RequiredGlo );
490 }
491 else
492 {
493 Tim_ManInitPoRequiredAll( p->pManTim, p->RequiredGlo );
494// If_ManForEachCo( p, pObj, i )
495// Tim_ManSetCoRequired( p->pManTim, pObj->IdPio, p->RequiredGlo );
496 }
497 // go through the nodes in the reverse topological order
498 If_ManForEachObjReverse( p, pObj, i )
499 {
500 if ( If_ObjIsAnd(pObj) )
501 {
502 if ( pObj->nRefs == 0 )
503 continue;
504 If_CutPropagateRequired( p, pObj, If_ObjCutBest(pObj), pObj->Required );
505 }
506 else if ( If_ObjIsCi(pObj) )
507 {
508 reqTime = pObj->Required;
509 Tim_ManSetCiRequired( p->pManTim, pObj->IdPio, reqTime );
510 }
511 else if ( If_ObjIsCo(pObj) )
512 {
513 reqTime = Tim_ManGetCoRequired( p->pManTim, pObj->IdPio );
514 If_ObjFanin0(pObj)->Required = IF_MIN( reqTime, If_ObjFanin0(pObj)->Required );
515 }
516 else if ( If_ObjIsConst1(pObj) )
517 {
518 }
519 else // add the node to the mapper
520 assert( 0 );
521 }
522 }
523}
float If_ManDelayMax(If_Man_t *p, int fSeq)
Definition ifTime.c:269
void If_CutPropagateRequired(If_Man_t *p, If_Obj_t *pObj, If_Cut_t *pCut, float ObjRequired)
Definition ifTime.c:178
#define If_ManForEachCo(p, pObj, i)
Definition if.h:477
void If_ManMarkMapping(If_Man_t *p)
Definition ifUtil.c:434
#define If_ManForEachObjReverse(p, pObj, i)
Definition if.h:494
#define If_ManForEachLatchInput(p, pObj, i)
Definition if.h:486
#define If_ManForEachPo(p, pObj, i)
Definition if.h:483
int nRefs
Definition if.h:346
int IdPio
Definition if.h:345
void Tim_ManIncrementTravId(Tim_Man_t *p)
DECLARATIONS ///.
Definition timTrav.c:44
void Tim_ManSetCiRequired(Tim_Man_t *p, int iCi, float Delay)
Definition timTime.c:135
void Tim_ManInitPoRequiredAll(Tim_Man_t *p, float Delay)
Definition timTime.c:97
void Tim_ManSetCoRequired(Tim_Man_t *p, int iCo, float Delay)
Definition timTime.c:154
float Tim_ManGetCoRequired(Tim_Man_t *p, int iCo)
Definition timTime.c:222
Here is the call graph for this function:
Here is the caller graph for this function:

◆ If_ManDelayMax()

float If_ManDelayMax ( If_Man_t * p,
int fSeq )

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

Synopsis [Returns the max delay of the POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 269 of file ifTime.c.

270{
271 If_Obj_t * pObj;
272 float DelayBest;
273 int i;
274 if ( p->pPars->fLatchPaths && (p->pPars->nLatchesCi == 0 || p->pPars->nLatchesCo == 0) )
275 {
276 Abc_Print( 0, "Delay optimization of latch path is not performed because there is no latches.\n" );
277 p->pPars->fLatchPaths = 0;
278 }
279 DelayBest = -IF_FLOAT_LARGE;
280 if ( fSeq )
281 {
282 assert( p->pPars->nLatchesCi > 0 );
283 If_ManForEachPo( p, pObj, i )
284 if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
285 DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
286 }
287 else if ( p->pPars->fLatchPaths )
288 {
289 If_ManForEachLatchInput( p, pObj, i )
290 if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
291 DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
292 }
293 else
294 {
295 If_ManForEachCo( p, pObj, i )
296 if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
297 DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
298 }
299 return DelayBest;
300}
Here is the caller graph for this function: