abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
timMan.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [timMan.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Hierarchy/timing manager.]
8 
9  Synopsis [Manipulation of manager data-structure.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - April 28, 2007.]
16 
17  Revision [$Id: timMan.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "timInt.h"
22 #include "map/if/if.h"
23 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Starts the timing manager.]
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
45 Tim_Man_t * Tim_ManStart( int nCis, int nCos )
46 {
47  Tim_Man_t * p;
48  Tim_Obj_t * pObj;
49  int i;
50  p = ABC_ALLOC( Tim_Man_t, 1 );
51  memset( p, 0, sizeof(Tim_Man_t) );
52  p->pMemObj = Mem_FlexStart();
53  p->nCis = nCis;
54  p->nCos = nCos;
55  p->pCis = ABC_ALLOC( Tim_Obj_t, nCis );
56  memset( p->pCis, 0, sizeof(Tim_Obj_t) * nCis );
57  p->pCos = ABC_ALLOC( Tim_Obj_t, nCos );
58  memset( p->pCos, 0, sizeof(Tim_Obj_t) * nCos );
59  Tim_ManForEachCi( p, pObj, i )
60  {
61  pObj->Id = i;
62  pObj->iObj2Box = pObj->iObj2Num = -1;
63  pObj->timeReq = TIM_ETERNITY;
64  }
65  Tim_ManForEachCo( p, pObj, i )
66  {
67  pObj->Id = i;
68  pObj->iObj2Box = pObj->iObj2Num = -1;
69  pObj->timeReq = TIM_ETERNITY;
70  }
71  p->fUseTravId = 1;
72  return p;
73 }
74 
75 /**Function*************************************************************
76 
77  Synopsis [Duplicates the timing manager.]
78 
79  Description []
80 
81  SideEffects []
82 
83  SeeAlso []
84 
85 ***********************************************************************/
86 Tim_Man_t * Tim_ManDup( Tim_Man_t * p, int fUnitDelay )
87 {
88  Tim_Man_t * pNew;
89  Tim_Box_t * pBox;
90  Tim_Obj_t * pObj;
91  float * pDelayTable, * pDelayTableNew;
92  int i, k, nInputs, nOutputs;
93  // clear traversal IDs
94  Tim_ManForEachCi( p, pObj, i )
95  pObj->TravId = 0;
96  Tim_ManForEachCo( p, pObj, i )
97  pObj->TravId = 0;
98  // create new manager
99  pNew = Tim_ManStart( p->nCis, p->nCos );
100  // copy box connectivity information
101  memcpy( pNew->pCis, p->pCis, sizeof(Tim_Obj_t) * p->nCis );
102  memcpy( pNew->pCos, p->pCos, sizeof(Tim_Obj_t) * p->nCos );
103  if ( fUnitDelay )
104  {
105  // discretize PI arrival times
106 // Tim_ManForEachPi( pNew, pObj, k )
107 // pObj->timeArr = (int)pObj->timeArr;
108  // discretize PO required times
109 // Tim_ManForEachPo( pNew, pObj, k )
110 // pObj->timeReq = 1 + (int)pObj->timeReq;
111  // clear PI arrival and PO required
112  Tim_ManInitPiArrivalAll( p, 0.0 );
114  }
115  // duplicate delay tables
116  if ( Tim_ManDelayTableNum(p) > 0 )
117  {
118  pNew->vDelayTables = Vec_PtrStart( Vec_PtrSize(p->vDelayTables) );
119  Tim_ManForEachTable( p, pDelayTable, i )
120  {
121  if ( pDelayTable == NULL )
122  continue;
123  assert( i == (int)pDelayTable[0] );
124  nInputs = (int)pDelayTable[1];
125  nOutputs = (int)pDelayTable[2];
126  pDelayTableNew = ABC_ALLOC( float, 3 + nInputs * nOutputs );
127  pDelayTableNew[0] = (int)pDelayTable[0];
128  pDelayTableNew[1] = (int)pDelayTable[1];
129  pDelayTableNew[2] = (int)pDelayTable[2];
130  for ( k = 0; k < nInputs * nOutputs; k++ )
131  if ( pDelayTable[3+k] == -ABC_INFINITY )
132  pDelayTableNew[3+k] = -ABC_INFINITY;
133  else
134  pDelayTableNew[3+k] = fUnitDelay ? (float)fUnitDelay : pDelayTable[3+k];
135 // assert( (int)pDelayTableNew[0] == Vec_PtrSize(pNew->vDelayTables) );
136  assert( Vec_PtrEntry(pNew->vDelayTables, i) == NULL );
137  Vec_PtrWriteEntry( pNew->vDelayTables, i, pDelayTableNew );
138 //printf( "Finished duplicating delay table %d.\n", i );
139  }
140  }
141  // duplicate boxes
142  if ( Tim_ManBoxNum(p) > 0 )
143  {
144  pNew->vBoxes = Vec_PtrAlloc( Tim_ManBoxNum(p) );
145  Tim_ManForEachBox( p, pBox, i )
146  Tim_ManCreateBox( pNew, pBox->Inouts[0], pBox->nInputs,
147  pBox->Inouts[pBox->nInputs], pBox->nOutputs, pBox->iDelayTable );
148  }
149  return pNew;
150 }
151 
152 /**Function*************************************************************
153 
154  Synopsis [Trims the timing manager.]
155 
156  Description []
157 
158  SideEffects []
159 
160  SeeAlso []
161 
162 ***********************************************************************/
164 {
165  Tim_Man_t * pNew;
166  Tim_Box_t * pBox;
167  Tim_Obj_t * pObj;
168  float * pDelayTable, * pDelayTableNew;
169  int i, k, nNewCis, nNewCos, nInputs, nOutputs;
170  assert( Vec_IntSize(vBoxPres) == Tim_ManBoxNum(p) );
171  // count the number of CIs and COs in the trimmed manager
172  nNewCis = Tim_ManPiNum(p);
173  nNewCos = Tim_ManPoNum(p);
174  if ( Tim_ManBoxNum(p) )
175  Tim_ManForEachBox( p, pBox, i )
176  if ( Vec_IntEntry(vBoxPres, i) )
177  {
178  nNewCis += pBox->nOutputs;
179  nNewCos += pBox->nInputs;
180  }
181  if ( nNewCis == Tim_ManCiNum(p) && nNewCos == Tim_ManCoNum(p) )
182  return Tim_ManDup( p, 0 );
183  assert( nNewCis < Tim_ManCiNum(p) );
184  assert( nNewCos < Tim_ManCoNum(p) );
185  // clear traversal IDs
186  Tim_ManForEachCi( p, pObj, i )
187  pObj->TravId = 0;
188  Tim_ManForEachCo( p, pObj, i )
189  pObj->TravId = 0;
190  // create new manager
191  pNew = Tim_ManStart( nNewCis, nNewCos );
192  // copy box connectivity information
193  memcpy( pNew->pCis, p->pCis, sizeof(Tim_Obj_t) * Tim_ManPiNum(p) );
194  memcpy( pNew->pCos + nNewCos - Tim_ManPoNum(p),
195  p->pCos + Tim_ManCoNum(p) - Tim_ManPoNum(p),
196  sizeof(Tim_Obj_t) * Tim_ManPoNum(p) );
197  // duplicate delay tables
198  if ( Tim_ManDelayTableNum(p) > 0 )
199  {
200  pNew->vDelayTables = Vec_PtrStart( Vec_PtrSize(p->vDelayTables) );
201  Tim_ManForEachTable( p, pDelayTable, i )
202  {
203  if ( pDelayTable == NULL )
204  continue;
205  assert( i == (int)pDelayTable[0] );
206  nInputs = (int)pDelayTable[1];
207  nOutputs = (int)pDelayTable[2];
208  pDelayTableNew = ABC_ALLOC( float, 3 + nInputs * nOutputs );
209  pDelayTableNew[0] = (int)pDelayTable[0];
210  pDelayTableNew[1] = (int)pDelayTable[1];
211  pDelayTableNew[2] = (int)pDelayTable[2];
212  for ( k = 0; k < nInputs * nOutputs; k++ )
213  pDelayTableNew[3+k] = pDelayTable[3+k];
214 // assert( (int)pDelayTableNew[0] == Vec_PtrSize(pNew->vDelayTables) );
215  assert( Vec_PtrEntry(pNew->vDelayTables, i) == NULL );
216  Vec_PtrWriteEntry( pNew->vDelayTables, i, pDelayTableNew );
217  }
218  }
219  // duplicate boxes
220  if ( Tim_ManBoxNum(p) > 0 )
221  {
222  int curPi = Tim_ManPiNum(p);
223  int curPo = 0;
224  pNew->vBoxes = Vec_PtrAlloc( Tim_ManBoxNum(p) );
225  Tim_ManForEachBox( p, pBox, i )
226  if ( Vec_IntEntry(vBoxPres, i) )
227  {
228  Tim_ManCreateBox( pNew, curPo, pBox->nInputs, curPi, pBox->nOutputs, pBox->iDelayTable );
229  Tim_ManBoxSetCopy( pNew, Tim_ManBoxNum(pNew) - 1, i );
230  curPi += pBox->nOutputs;
231  curPo += pBox->nInputs;
232  }
233  curPo += Tim_ManPoNum(p);
234  assert( curPi == Tim_ManCiNum(pNew) );
235  assert( curPo == Tim_ManCoNum(pNew) );
236  }
237  return pNew;
238 }
239 
240 /**Function*************************************************************
241 
242  Synopsis [Reduces the timing manager.]
243 
244  Description []
245 
246  SideEffects []
247 
248  SeeAlso []
249 
250 ***********************************************************************/
251 Tim_Man_t * Tim_ManReduce( Tim_Man_t * p, Vec_Int_t * vBoxesLeft, int nTermsDiff )
252 {
253  Tim_Man_t * pNew;
254  Tim_Box_t * pBox;
255  Tim_Obj_t * pObj;
256  float * pDelayTable, * pDelayTableNew;
257  int i, k, iBox, nNewCis, nNewCos, nInputs, nOutputs;
258  int nNewPiNum = Tim_ManPiNum(p) - nTermsDiff;
259  int nNewPoNum = Tim_ManPoNum(p) - nTermsDiff;
260  assert( Vec_IntSize(vBoxesLeft) <= Tim_ManBoxNum(p) );
261  // count the number of CIs and COs in the trimmed manager
262  nNewCis = nNewPiNum;
263  nNewCos = nNewPoNum;
264  Vec_IntForEachEntry( vBoxesLeft, iBox, i )
265  {
266  pBox = Tim_ManBox( p, iBox );
267  nNewCis += pBox->nOutputs;
268  nNewCos += pBox->nInputs;
269  }
270  assert( nNewCis <= Tim_ManCiNum(p) - nTermsDiff );
271  assert( nNewCos <= Tim_ManCoNum(p) - nTermsDiff );
272  // clear traversal IDs
273  Tim_ManForEachCi( p, pObj, i )
274  pObj->TravId = 0;
275  Tim_ManForEachCo( p, pObj, i )
276  pObj->TravId = 0;
277  // create new manager
278  pNew = Tim_ManStart( nNewCis, nNewCos );
279  // copy box connectivity information
280  memcpy( pNew->pCis, p->pCis, sizeof(Tim_Obj_t) * nNewPiNum );
281  memcpy( pNew->pCos + nNewCos - nNewPoNum,
282  p->pCos + Tim_ManCoNum(p) - Tim_ManPoNum(p),
283  sizeof(Tim_Obj_t) * nNewPoNum );
284  // duplicate delay tables
285  if ( Tim_ManDelayTableNum(p) > 0 )
286  {
287  int fWarning = 0;
288  pNew->vDelayTables = Vec_PtrStart( Vec_PtrSize(p->vDelayTables) );
289  Tim_ManForEachTable( p, pDelayTable, i )
290  {
291  if ( pDelayTable == NULL )
292  continue;
293  if ( i != (int)pDelayTable[0] && fWarning == 0 )
294  {
295  printf( "Warning: Mismatch in delay-table number between the manager and the box.\n" );
296  fWarning = 1;
297  }
298  //assert( i == (int)pDelayTable[0] );
299  nInputs = (int)pDelayTable[1];
300  nOutputs = (int)pDelayTable[2];
301  pDelayTableNew = ABC_ALLOC( float, 3 + nInputs * nOutputs );
302  pDelayTableNew[0] = i;//(int)pDelayTable[0];
303  pDelayTableNew[1] = (int)pDelayTable[1];
304  pDelayTableNew[2] = (int)pDelayTable[2];
305  for ( k = 0; k < nInputs * nOutputs; k++ )
306  pDelayTableNew[3+k] = pDelayTable[3+k];
307 // assert( (int)pDelayTableNew[0] == Vec_PtrSize(pNew->vDelayTables) );
308  assert( Vec_PtrEntry(pNew->vDelayTables, i) == NULL );
309  Vec_PtrWriteEntry( pNew->vDelayTables, i, pDelayTableNew );
310  }
311  }
312  // duplicate boxes
313  if ( Tim_ManBoxNum(p) > 0 )
314  {
315  int curPi = nNewPiNum;
316  int curPo = 0;
317  pNew->vBoxes = Vec_PtrAlloc( Tim_ManBoxNum(p) );
318  Vec_IntForEachEntry( vBoxesLeft, iBox, i )
319  {
320  pBox = Tim_ManBox( p, iBox );
321  Tim_ManCreateBox( pNew, curPo, pBox->nInputs, curPi, pBox->nOutputs, pBox->iDelayTable );
322  Tim_ManBoxSetCopy( pNew, Tim_ManBoxNum(pNew) - 1, iBox );
323  curPi += pBox->nOutputs;
324  curPo += pBox->nInputs;
325  }
326  curPo += nNewPoNum;
327  assert( curPi == Tim_ManCiNum(pNew) );
328  assert( curPo == Tim_ManCoNum(pNew) );
329  }
330  return pNew;
331 }
332 
333 /**Function*************************************************************
334 
335  Synopsis [Aligns two sets of boxes using the copy field.]
336 
337  Description []
338 
339  SideEffects []
340 
341  SeeAlso []
342 
343 ***********************************************************************/
345 {
346  Vec_Int_t * vBoxPres;
347  Tim_Box_t * pBox;
348  int i;
349  assert( Tim_ManBoxNum(pSpec) > Tim_ManBoxNum(pImpl) );
350  // check if boxes of pImpl can be aligned
351  Tim_ManForEachBox( pImpl, pBox, i )
352  if ( pBox->iCopy < 0 || pBox->iCopy >= Tim_ManBoxNum(pSpec) )
353  return NULL;
354  // map dropped boxes into 1, others into 0
355  vBoxPres = Vec_IntStart( Tim_ManBoxNum(pSpec) );
356  Tim_ManForEachBox( pImpl, pBox, i )
357  {
358  assert( !Vec_IntEntry(vBoxPres, pBox->iCopy) );
359  Vec_IntWriteEntry( vBoxPres, pBox->iCopy, 1 );
360  }
361  return vBoxPres;
362 }
363 
364 /**Function*************************************************************
365 
366  Synopsis [Stops the timing manager.]
367 
368  Description []
369 
370  SideEffects []
371 
372  SeeAlso []
373 
374 ***********************************************************************/
376 {
377  Vec_PtrFreeFree( p->vDelayTables );
378  Vec_PtrFreeP( &p->vBoxes );
379  Mem_FlexStop( p->pMemObj, 0 );
380  ABC_FREE( p->pCis );
381  ABC_FREE( p->pCos );
382  ABC_FREE( p );
383 }
385 {
386  if ( *p == NULL )
387  return;
388  Tim_ManStop( *p );
389  *p = NULL;
390 }
391 
392 /**Function*************************************************************
393 
394  Synopsis [Creates manager using hierarchy / box library / delay info.]
395 
396  Description []
397 
398  SideEffects []
399 
400  SeeAlso []
401 
402 ***********************************************************************/
403 void Tim_ManCreate( Tim_Man_t * p, void * pLib, Vec_Flt_t * vInArrs, Vec_Flt_t * vOutReqs )
404 {
405  If_LibBox_t * pLibBox = (If_LibBox_t *)pLib;
406  If_Box_t * pIfBox;
407  Tim_Box_t * pBox;
408  Tim_Obj_t * pObj;
409  float * pTable;
410  int i, k;
411  assert( p->vDelayTables == NULL );
412  p->vDelayTables = pLibBox ? Vec_PtrStart( Vec_PtrSize(pLibBox->vBoxes) ) : Vec_PtrAlloc( 100 );
413  if ( p->vBoxes )
414  Tim_ManForEachBox( p, pBox, i )
415  {
416  if ( pBox->iDelayTable == -1 || pLibBox == NULL )
417  {
418  // create table with constants
419  pTable = ABC_ALLOC( float, 3 + pBox->nInputs * pBox->nOutputs );
420  pTable[0] = pBox->iDelayTable;
421  pTable[1] = pBox->nInputs;
422  pTable[2] = pBox->nOutputs;
423  for ( k = 0; k < pBox->nInputs * pBox->nOutputs; k++ )
424  pTable[3 + k] = 1.0;
425  // save table
426  pBox->iDelayTable = Vec_PtrSize(p->vDelayTables);
427  Vec_PtrPush( p->vDelayTables, pTable );
428  continue;
429  }
430  assert( pBox->iDelayTable >= 0 && pBox->iDelayTable < Vec_PtrSize(pLibBox->vBoxes) );
431  pIfBox = (If_Box_t *)Vec_PtrEntry( pLibBox->vBoxes, pBox->iDelayTable );
432  assert( pIfBox != NULL );
433  assert( pIfBox->nPis == pBox->nInputs );
434  assert( pIfBox->nPos == pBox->nOutputs );
435  pBox->fBlack = pIfBox->fBlack;
436  if ( Vec_PtrEntry( p->vDelayTables, pBox->iDelayTable ) != NULL )
437  continue;
438  // create table of boxes
439  pTable = ABC_ALLOC( float, 3 + pBox->nInputs * pBox->nOutputs );
440  pTable[0] = pBox->iDelayTable;
441  pTable[1] = pBox->nInputs;
442  pTable[2] = pBox->nOutputs;
443  for ( k = 0; k < pBox->nInputs * pBox->nOutputs; k++ )
444  pTable[3 + k] = pIfBox->pDelays[k];
445  // save table
446  Vec_PtrWriteEntry( p->vDelayTables, pBox->iDelayTable, pTable );
447  }
448  // create arrival times
449  if ( vInArrs )
450  {
451  assert( Vec_FltSize(vInArrs) == Tim_ManPiNum(p) );
452  Tim_ManForEachPi( p, pObj, i )
453  pObj->timeArr = Vec_FltEntry(vInArrs, i);
454 
455  }
456  // create required times
457  if ( vOutReqs )
458  {
459  k = 0;
460  assert( Vec_FltSize(vOutReqs) == Tim_ManPoNum(p) );
461  Tim_ManForEachPo( p, pObj, i )
462  pObj->timeReq = Vec_FltEntry(vOutReqs, k++);
463  assert( k == Tim_ManPoNum(p) );
464  }
465 }
466 
467 
468 /**Function*************************************************************
469 
470  Synopsis [Get arrival and required times if they are non-trivial.]
471 
472  Description []
473 
474  SideEffects []
475 
476  SeeAlso []
477 
478 ***********************************************************************/
480 {
481  float * pTimes;
482  Tim_Obj_t * pObj;
483  int i;
484  Tim_ManForEachPi( p, pObj, i )
485  if ( pObj->timeArr != 0.0 )
486  break;
487  if ( i == Tim_ManPiNum(p) )
488  return NULL;
489  pTimes = ABC_FALLOC( float, Tim_ManCiNum(p) );
490  Tim_ManForEachPi( p, pObj, i )
491  pTimes[i] = pObj->timeArr;
492  return pTimes;
493 }
495 {
496  float * pTimes;
497  Tim_Obj_t * pObj;
498  int i, k = 0;
499  Tim_ManForEachPo( p, pObj, i )
500  if ( pObj->timeReq != TIM_ETERNITY )
501  break;
502  if ( i == Tim_ManPoNum(p) )
503  return NULL;
504  pTimes = ABC_FALLOC( float, Tim_ManCoNum(p) );
505  Tim_ManForEachPo( p, pObj, i )
506  pTimes[k++] = pObj->timeArr;
507  assert( k == Tim_ManPoNum(p) );
508  return pTimes;
509 }
510 
511 
512 /**Function*************************************************************
513 
514  Synopsis [Prints the timing manager.]
515 
516  Description []
517 
518  SideEffects []
519 
520  SeeAlso []
521 
522 ***********************************************************************/
524 {
525  Tim_Box_t * pBox;
526  Tim_Obj_t * pObj, * pPrev;
527  float * pTable;
528  int i, j, k, TableX, TableY;
529  if ( p == NULL )
530  return;
531  printf( "TIMING MANAGER:\n" );
532  printf( "PI = %d. CI = %d. PO = %d. CO = %d. Box = %d.\n",
534 
535  // print CI info
536  pPrev = p->pCis;
537  Tim_ManForEachPi( p, pObj, i )
538  if ( pPrev->timeArr != pObj->timeArr || pPrev->timeReq != pObj->timeReq )
539  break;
540  if ( i == Tim_ManCiNum(p) )
541  printf( "All PIs : arrival = %5.3f required = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
542  else
543  Tim_ManForEachPi( p, pObj, i )
544  printf( "PI%5d : arrival = %5.3f required = %5.3f\n", i, pObj->timeArr, pObj->timeReq );
545 
546  // print CO info
547  pPrev = p->pCos;
548  Tim_ManForEachPo( p, pObj, i )
549  if ( pPrev->timeArr != pObj->timeArr || pPrev->timeReq != pObj->timeReq )
550  break;
551  if ( i == Tim_ManCoNum(p) )
552  printf( "All POs : arrival = %5.3f required = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
553  else
554  {
555  int k = 0;
556  Tim_ManForEachPo( p, pObj, i )
557  printf( "PO%5d : arrival = %5.3f required = %5.3f\n", k++, pObj->timeArr, pObj->timeReq );
558  }
559 
560  // print box info
561  if ( Tim_ManBoxNum(p) > 0 )
562  Tim_ManForEachBox( p, pBox, i )
563  {
564  printf( "*** Box %5d : I =%4d. O =%4d. I1 =%6d. O1 =%6d. Table =%4d\n",
565  i, pBox->nInputs, pBox->nOutputs,
567  pBox->iDelayTable );
568 
569  // print box inputs
570  pPrev = Tim_ManBoxInput( p, pBox, 0 );
571  Tim_ManBoxForEachInput( p, pBox, pObj, k )
572  if ( pPrev->timeArr != pObj->timeArr || pPrev->timeReq != pObj->timeReq )
573  break;
574  if ( k == Tim_ManBoxInputNum(p, pBox->iBox) )
575  printf( "Box inputs : arrival = %5.3f required = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
576  else
577  Tim_ManBoxForEachInput( p, pBox, pObj, k )
578  printf( "box-in%4d : arrival = %5.3f required = %5.3f\n", k, pObj->timeArr, pObj->timeReq );
579 
580  // print box outputs
581  pPrev = Tim_ManBoxOutput( p, pBox, 0 );
582  Tim_ManBoxForEachOutput( p, pBox, pObj, k )
583  if ( pPrev->timeArr != pObj->timeArr || pPrev->timeReq != pObj->timeReq )
584  break;
585  if ( k == Tim_ManBoxOutputNum(p, pBox->iBox) )
586  printf( "Box outputs : arrival = %5.3f required = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
587  else
588  Tim_ManBoxForEachOutput( p, pBox, pObj, k )
589  printf( "box-out%3d : arrival = %5.3f required = %5.3f\n", k, pObj->timeArr, pObj->timeReq );
590 
591  if ( i > 2 )
592  break;
593  }
594 
595  // print delay tables
596  if ( Tim_ManDelayTableNum(p) > 0 )
597  Tim_ManForEachTable( p, pTable, i )
598  {
599  if ( pTable == NULL )
600  continue;
601  printf( "Delay table %d:\n", i );
602  assert( i == (int)pTable[0] );
603  TableX = (int)pTable[1];
604  TableY = (int)pTable[2];
605  for ( j = 0; j < TableY; j++, printf( "\n" ) )
606  for ( k = 0; k < TableX; k++ )
607  if ( pTable[3+j*TableX+k] == -ABC_INFINITY )
608  printf( "%5s", "-" );
609  else
610  printf( "%5.0f", pTable[3+j*TableX+k] );
611  }
612  printf( "\n" );
613 }
614 
615 /**Function*************************************************************
616 
617  Synopsis [Prints statistics of the timing manager.]
618 
619  Description []
620 
621  SideEffects []
622 
623  SeeAlso []
624 
625 ***********************************************************************/
626 void Tim_ManPrintStats( Tim_Man_t * p, int nAnd2Delay )
627 {
628  Tim_Box_t * pBox;
629  Vec_Int_t * vCounts;
630  Vec_Ptr_t * vBoxes;
631  int i, Count, IdMax;
632  if ( p == NULL )
633  return;
634  Abc_Print( 1, "Hierarchy : " );
635  printf( "PI/CI = %d/%d PO/CO = %d/%d Box = %d ",
636  Tim_ManPiNum(p), Tim_ManCiNum(p),
637  Tim_ManPoNum(p), Tim_ManCoNum(p),
638  Tim_ManBoxNum(p) );
639  if ( nAnd2Delay )
640  printf( "delay(AND2) = %d", nAnd2Delay );
641  printf( "\n" );
642  if ( Tim_ManBoxNum(p) == 0 )
643  return;
644  IdMax = 0;
645  Tim_ManForEachBox( p, pBox, i )
646  IdMax = Abc_MaxInt( IdMax, pBox->iDelayTable );
647  vCounts = Vec_IntStart( IdMax+1 );
648  vBoxes = Vec_PtrStart( IdMax+1 );
649  Tim_ManForEachBox( p, pBox, i )
650  {
651  Vec_IntAddToEntry( vCounts, pBox->iDelayTable, 1 );
652  Vec_PtrWriteEntry( vBoxes, pBox->iDelayTable, pBox );
653  }
654  // print statistics about boxes
655  Vec_IntForEachEntry( vCounts, Count, i )
656  {
657  if ( Count == 0 ) continue;
658  pBox = (Tim_Box_t *)Vec_PtrEntry( vBoxes, i );
659  printf( " Box %4d ", i );
660  printf( "Num = %4d ", Count );
661  printf( "Ins = %4d ", pBox->nInputs );
662  printf( "Outs = %4d", pBox->nOutputs );
663  printf( "\n" );
664  }
665  Vec_IntFree( vCounts );
666  Vec_PtrFree( vBoxes );
667 }
668 
669 /**Function*************************************************************
670 
671  Synopsis [Read parameters.]
672 
673  Description []
674 
675  SideEffects []
676 
677  SeeAlso []
678 
679 ***********************************************************************/
681 {
682  return p->nCis;
683 }
685 {
686  return p->nCos;
687 }
689 {
690  if ( Tim_ManBoxNum(p) == 0 )
691  return Tim_ManCiNum(p);
692  return Tim_ManBoxOutputFirst(p, 0);
693 }
695 {
696  int iLastBoxId;
697  if ( Tim_ManBoxNum(p) == 0 )
698  return Tim_ManCoNum(p);
699  iLastBoxId = Tim_ManBoxNum(p) - 1;
700  return Tim_ManCoNum(p) - (Tim_ManBoxInputFirst(p, iLastBoxId) + Tim_ManBoxInputNum(p, iLastBoxId));
701 }
703 {
704  return p->vBoxes ? Vec_PtrSize(p->vBoxes) : 0;
705 }
707 {
708  Tim_Box_t * pBox;
709  int i, Counter = 0;
710  if ( Tim_ManBoxNum(p) )
711  Tim_ManForEachBox( p, pBox, i )
712  Counter += pBox->fBlack;
713  return Counter;
714 }
716 {
717  return p->vDelayTables ? Vec_PtrSize(p->vDelayTables) : 0;
718 }
719 
720 /**Function*************************************************************
721 
722  Synopsis [Sets the vector of timing tables associated with the manager.]
723 
724  Description []
725 
726  SideEffects []
727 
728  SeeAlso []
729 
730 ***********************************************************************/
731 void Tim_ManSetDelayTables( Tim_Man_t * p, Vec_Ptr_t * vDelayTables )
732 {
733  assert( p->vDelayTables == NULL );
734  p->vDelayTables = vDelayTables;
735 }
736 
737 /**Function*************************************************************
738 
739  Synopsis [Disables the use of the traversal ID.]
740 
741  Description []
742 
743  SideEffects []
744 
745  SeeAlso []
746 
747 ***********************************************************************/
749 {
750  p->fUseTravId = 0;
751 }
752 
753 /**Function*************************************************************
754 
755  Synopsis [Enables the use of the traversal ID.]
756 
757  Description []
758 
759  SideEffects []
760 
761  SeeAlso []
762 
763 ***********************************************************************/
765 {
766  p->fUseTravId = 1;
767 }
768 
769 ////////////////////////////////////////////////////////////////////////
770 /// END OF FILE ///
771 ////////////////////////////////////////////////////////////////////////
772 
773 
775 
char * memset()
char fBlack
Definition: if.h:341
int Tim_ManBoxOutputFirst(Tim_Man_t *p, int iBox)
Definition: timBox.c:154
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
Tim_Man_t * Tim_ManDup(Tim_Man_t *p, int fUnitDelay)
Definition: timMan.c:86
float timeArr
Definition: timInt.h:85
#define Tim_ManForEachTable(p, pTable, i)
Definition: timInt.h:125
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Tim_ManSetDelayTables(Tim_Man_t *p, Vec_Ptr_t *vDelayTables)
Definition: timMan.c:731
Tim_Man_t * Tim_ManTrim(Tim_Man_t *p, Vec_Int_t *vBoxPres)
Definition: timMan.c:163
int * pDelays
Definition: if.h:347
#define Tim_ManBoxForEachOutput(p, pBox, pObj, i)
Definition: timInt.h:122
float * Tim_ManGetReqTimes(Tim_Man_t *p)
Definition: timMan.c:494
void Tim_ManPrint(Tim_Man_t *p)
Definition: timMan.c:523
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Tim_ManStopP(Tim_Man_t **p)
Definition: timMan.c:384
#define Tim_ManForEachBox(p, pBox, i)
Definition: timInt.h:117
static void Vec_PtrFreeFree(Vec_Ptr_t *p)
Definition: vecPtr.h:569
int Tim_ManPiNum(Tim_Man_t *p)
Definition: timMan.c:688
char * memcpy()
#define Tim_ManForEachPo(p, pObj, i)
Definition: timInt.h:114
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int Tim_ManBoxOutputNum(Tim_Man_t *p, int iBox)
Definition: timBox.c:202
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int Tim_ManDelayTableNum(Tim_Man_t *p)
Definition: timMan.c:715
static Tim_Obj_t * Tim_ManBoxOutput(Tim_Man_t *p, Tim_Box_t *pBox, int i)
Definition: timInt.h:101
void Tim_ManTravIdDisable(Tim_Man_t *p)
Definition: timMan.c:748
void Tim_ManCreateBox(Tim_Man_t *p, int firstIn, int nIns, int firstOut, int nOuts, int iDelayTable)
ITERATORS ///.
Definition: timBox.c:44
void Tim_ManPrintStats(Tim_Man_t *p, int nAnd2Delay)
Definition: timMan.c:626
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
Mem_Flex_t * Mem_FlexStart()
Definition: mem.c:311
float timeReq
Definition: timInt.h:86
int Tim_ManPoNum(Tim_Man_t *p)
Definition: timMan.c:694
int Tim_ManBoxNum(Tim_Man_t *p)
Definition: timMan.c:702
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
ABC_NAMESPACE_IMPL_START Tim_Man_t * Tim_ManStart(int nCis, int nCos)
DECLARATIONS ///.
Definition: timMan.c:45
Vec_Int_t * Tim_ManAlignTwo(Tim_Man_t *pSpec, Tim_Man_t *pImpl)
Definition: timMan.c:344
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
#define Tim_ManForEachCo(p, pObj, i)
Definition: timInt.h:109
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
#define Tim_ManBoxForEachInput(p, pBox, pObj, i)
Definition: timInt.h:120
int iObj2Num
Definition: timInt.h:84
int nPis
Definition: if.h:345
static int Counter
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static Tim_Box_t * Tim_ManBox(Tim_Man_t *p, int i)
Definition: timInt.h:95
float * Tim_ManGetArrTimes(Tim_Man_t *p)
Definition: timMan.c:479
Vec_Ptr_t * vBoxes
Definition: if.h:352
int Tim_ManBoxInputNum(Tim_Man_t *p, int iBox)
Definition: timBox.c:186
int TravId
Definition: timInt.h:82
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
Definition: mem.c:343
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
void Tim_ManInitPiArrivalAll(Tim_Man_t *p, float Delay)
Definition: timTime.c:78
Definition: if.h:337
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Tim_ManForEachPi(p, pObj, i)
Definition: timInt.h:112
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Id
Definition: timInt.h:81
#define TIM_ETERNITY
MACRO DEFINITIONS ///.
Definition: tim.h:98
#define Tim_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: timInt.h:107
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
Definition: vecFlt.h:42
static void Vec_PtrFreeP(Vec_Ptr_t **p)
Definition: vecPtr.h:240
int Tim_ManCoNum(Tim_Man_t *p)
Definition: timMan.c:684
int iObj2Box
Definition: timInt.h:83
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
Tim_Man_t * Tim_ManReduce(Tim_Man_t *p, Vec_Int_t *vBoxesLeft, int nTermsDiff)
Definition: timMan.c:251
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition: tim.h:92
static Tim_Obj_t * Tim_ManBoxInput(Tim_Man_t *p, Tim_Box_t *pBox, int i)
Definition: timInt.h:100
static float Vec_FltEntry(Vec_Flt_t *p, int i)
Definition: vecFlt.h:342
void Tim_ManCreate(Tim_Man_t *p, void *pLib, Vec_Flt_t *vInArrs, Vec_Flt_t *vOutReqs)
Definition: timMan.c:403
void Tim_ManTravIdEnable(Tim_Man_t *p)
Definition: timMan.c:764
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
int Tim_ManBoxInputFirst(Tim_Man_t *p, int iBox)
Definition: timBox.c:122
void Tim_ManStop(Tim_Man_t *p)
Definition: timMan.c:375
static int Vec_FltSize(Vec_Flt_t *p)
Definition: vecFlt.h:294
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Tim_ManBlackBoxNum(Tim_Man_t *p)
Definition: timMan.c:706
typedefABC_NAMESPACE_HEADER_START struct Tim_Box_t_ Tim_Box_t
INCLUDES ///.
Definition: timInt.h:48
void Tim_ManBoxSetCopy(Tim_Man_t *p, int iBox, int iCopy)
Definition: timBox.c:290
int Tim_ManCiNum(Tim_Man_t *p)
Definition: timMan.c:680
void Tim_ManInitPoRequiredAll(Tim_Man_t *p, float Delay)
Definition: timTime.c:97
#define ABC_FALLOC(type, num)
Definition: abc_global.h:231
int nPos
Definition: if.h:346
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223