timMan.c 20.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/**CFile****************************************************************

  FileName    [timMan.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Hierarchy/timing manager.]

  Synopsis    [Manipulation of manager data-structure.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - April 28, 2007.]

  Revision    [$Id: timMan.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]

***********************************************************************/

#include "timInt.h"
22
#include "map/if/if.h"
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92

ABC_NAMESPACE_IMPL_START

////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
///                     FUNCTION DEFINITIONS                         ///
////////////////////////////////////////////////////////////////////////

/**Function*************************************************************

  Synopsis    [Starts the timing manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Tim_Man_t * Tim_ManStart( int nCis, int nCos )
{
    Tim_Man_t * p;
    Tim_Obj_t * pObj;
    int i;
    p = ABC_ALLOC( Tim_Man_t, 1 );
    memset( p, 0, sizeof(Tim_Man_t) );
    p->pMemObj = Mem_FlexStart();
    p->nCis = nCis;
    p->nCos = nCos;
    p->pCis = ABC_ALLOC( Tim_Obj_t, nCis );
    memset( p->pCis, 0, sizeof(Tim_Obj_t) * nCis );
    p->pCos = ABC_ALLOC( Tim_Obj_t, nCos );
    memset( p->pCos, 0, sizeof(Tim_Obj_t) * nCos );
    Tim_ManForEachCi( p, pObj, i )
    {
        pObj->Id = i;
        pObj->iObj2Box = pObj->iObj2Num = -1;
        pObj->timeReq = TIM_ETERNITY;
    }
    Tim_ManForEachCo( p, pObj, i )
    {
        pObj->Id = i;
        pObj->iObj2Box = pObj->iObj2Num = -1;
        pObj->timeReq = TIM_ETERNITY;
    }
    p->fUseTravId = 1;
    return p;
}

/**Function*************************************************************

  Synopsis    [Duplicates the timing manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Tim_Man_t * Tim_ManDup( Tim_Man_t * p, int fUnitDelay )
{
    Tim_Man_t * pNew;
    Tim_Box_t * pBox;
    Tim_Obj_t * pObj;
    float * pDelayTable, * pDelayTableNew;
    int i, k, nInputs, nOutputs;
93 94 95 96 97
    // clear traversal IDs
    Tim_ManForEachCi( p, pObj, i ) 
        pObj->TravId = 0;          
    Tim_ManForEachCo( p, pObj, i ) 
        pObj->TravId = 0;          
98 99 100
    // create new manager
    pNew = Tim_ManStart( p->nCis, p->nCos );
    // copy box connectivity information
101 102
    memcpy( pNew->pCis, p->pCis, sizeof(Tim_Obj_t) * p->nCis ); 
    memcpy( pNew->pCos, p->pCos, sizeof(Tim_Obj_t) * p->nCos ); 
103 104 105 106 107 108 109 110 111 112 113 114 115
    if ( fUnitDelay )
    {
        // discretize PI arrival times
//        Tim_ManForEachPi( pNew, pObj, k )
//          pObj->timeArr = (int)pObj->timeArr;
        // discretize PO required times
//        Tim_ManForEachPo( pNew, pObj, k )
//          pObj->timeReq = 1 + (int)pObj->timeReq;
        // clear PI arrival and PO required
        Tim_ManInitPiArrivalAll( p, 0.0 );
        Tim_ManInitPoRequiredAll( p, (float)TIM_ETERNITY );
    }
    // duplicate delay tables
116
    if ( Tim_ManDelayTableNum(p) > 0 )
117
    {
118
        pNew->vDelayTables = Vec_PtrStart( Vec_PtrSize(p->vDelayTables) );
119 120
        Tim_ManForEachTable( p, pDelayTable, i )
        {
121 122
            if ( pDelayTable == NULL )
                continue;
123 124 125 126 127 128 129 130 131
            assert( i == (int)pDelayTable[0] );
            nInputs   = (int)pDelayTable[1];
            nOutputs  = (int)pDelayTable[2];
            pDelayTableNew = ABC_ALLOC( float, 3 + nInputs * nOutputs );
            pDelayTableNew[0] = (int)pDelayTable[0];
            pDelayTableNew[1] = (int)pDelayTable[1];
            pDelayTableNew[2] = (int)pDelayTable[2];
            for ( k = 0; k < nInputs * nOutputs; k++ )
                pDelayTableNew[3+k] = fUnitDelay ? 1.0 : pDelayTable[3+k];
132 133 134
//            assert( (int)pDelayTableNew[0] == Vec_PtrSize(pNew->vDelayTables) );
            assert( Vec_PtrEntry(pNew->vDelayTables, i) == NULL );
            Vec_PtrWriteEntry( pNew->vDelayTables, i, pDelayTableNew );
135
//printf( "Finished duplicating delay table %d.\n", i );
136
        }
137 138
    }
    // duplicate boxes
139 140 141 142 143 144 145
    if ( Tim_ManBoxNum(p) > 0 )
    {
        pNew->vBoxes = Vec_PtrAlloc( Tim_ManBoxNum(p) );
        Tim_ManForEachBox( p, pBox, i )
           Tim_ManCreateBox( pNew, pBox->Inouts[0], pBox->nInputs, 
                pBox->Inouts[pBox->nInputs], pBox->nOutputs, pBox->iDelayTable );
    }
146 147 148 149 150
    return pNew;
}

/**Function*************************************************************

151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
  Synopsis    [Trims the timing manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Tim_Man_t * Tim_ManTrim( Tim_Man_t * p, Vec_Int_t * vBoxPres )
{
    Tim_Man_t * pNew;
    Tim_Box_t * pBox;
    Tim_Obj_t * pObj;
    float * pDelayTable, * pDelayTableNew;
166
    int i, k, nNewCis, nNewCos, nInputs, nOutputs;
167
    assert( Vec_IntSize(vBoxPres) == Tim_ManBoxNum(p) );
168 169 170
    // count the number of CIs and COs in the trimmed manager
    nNewCis = Tim_ManPiNum(p);
    nNewCos = Tim_ManPoNum(p);
171 172 173 174 175 176 177
    if ( Tim_ManBoxNum(p) )
        Tim_ManForEachBox( p, pBox, i )
            if ( Vec_IntEntry(vBoxPres, i) )
            {
                nNewCis += pBox->nOutputs;
                nNewCos += pBox->nInputs;
            }
178
    if ( nNewCis == Tim_ManCiNum(p) && nNewCos == Tim_ManCoNum(p) )
179
        return Tim_ManDup( p, 0 );
180 181 182 183 184 185 186
    assert( nNewCis < Tim_ManCiNum(p) );
    assert( nNewCos < Tim_ManCoNum(p) );
    // clear traversal IDs
    Tim_ManForEachCi( p, pObj, i ) 
        pObj->TravId = 0;          
    Tim_ManForEachCo( p, pObj, i ) 
        pObj->TravId = 0;          
187
    // create new manager
188
    pNew = Tim_ManStart( nNewCis, nNewCos );
189
    // copy box connectivity information
190
    memcpy( pNew->pCis, p->pCis, sizeof(Tim_Obj_t) * Tim_ManPiNum(p) );
191 192 193
    memcpy( pNew->pCos + nNewCos - Tim_ManPoNum(p), 
            p->pCos + Tim_ManCoNum(p) - Tim_ManPoNum(p), 
            sizeof(Tim_Obj_t) * Tim_ManPoNum(p) );
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
    // duplicate delay tables
    if ( Tim_ManDelayTableNum(p) > 0 )
    {
        pNew->vDelayTables = Vec_PtrStart( Vec_PtrSize(p->vDelayTables) );
        Tim_ManForEachTable( p, pDelayTable, i )
        {
            if ( pDelayTable == NULL )
                continue;
            assert( i == (int)pDelayTable[0] );
            nInputs   = (int)pDelayTable[1];
            nOutputs  = (int)pDelayTable[2];
            pDelayTableNew = ABC_ALLOC( float, 3 + nInputs * nOutputs );
            pDelayTableNew[0] = (int)pDelayTable[0];
            pDelayTableNew[1] = (int)pDelayTable[1];
            pDelayTableNew[2] = (int)pDelayTable[2];
            for ( k = 0; k < nInputs * nOutputs; k++ )
                pDelayTableNew[3+k] = pDelayTable[3+k];
//            assert( (int)pDelayTableNew[0] == Vec_PtrSize(pNew->vDelayTables) );
            assert( Vec_PtrEntry(pNew->vDelayTables, i) == NULL );
            Vec_PtrWriteEntry( pNew->vDelayTables, i, pDelayTableNew );
        }
    }
    // duplicate boxes
    if ( Tim_ManBoxNum(p) > 0 )
    {
219 220
        int curPi = Tim_ManPiNum(p);
        int curPo = 0;
221 222 223
        pNew->vBoxes = Vec_PtrAlloc( Tim_ManBoxNum(p) );
        Tim_ManForEachBox( p, pBox, i )
            if ( Vec_IntEntry(vBoxPres, i) )
224 225
            {
                Tim_ManCreateBox( pNew, curPo, pBox->nInputs, curPi, pBox->nOutputs, pBox->iDelayTable );
226
                Tim_ManBoxSetCopy( pNew, Tim_ManBoxNum(pNew) - 1, i );
227 228 229 230 231 232
                curPi += pBox->nOutputs;
                curPo += pBox->nInputs;
            }
        curPo += Tim_ManPoNum(p);
        assert( curPi == Tim_ManCiNum(pNew) );
        assert( curPo == Tim_ManCoNum(pNew) );
233 234 235 236
    }
    return pNew;
}

237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
/**Function*************************************************************

  Synopsis    [Aligns two sets of boxes using the copy field.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Vec_Int_t * Tim_ManAlignTwo( Tim_Man_t * pSpec, Tim_Man_t * pImpl )
{
    Vec_Int_t * vBoxPres;
    Tim_Box_t * pBox;
    int i;
    assert( Tim_ManBoxNum(pSpec) > Tim_ManBoxNum(pImpl) );
    // check if boxes of pImpl can be aligned
    Tim_ManForEachBox( pImpl, pBox, i )
        if ( pBox->iCopy < 0 || pBox->iCopy >= Tim_ManBoxNum(pSpec) ) 
            return NULL;
    // map dropped boxes into 1, others into 0
    vBoxPres = Vec_IntStart( Tim_ManBoxNum(pSpec) );
    Tim_ManForEachBox( pImpl, pBox, i )
    {
        assert( !Vec_IntEntry(vBoxPres, pBox->iCopy) );
        Vec_IntWriteEntry( vBoxPres, pBox->iCopy, 1 );
    }
    return vBoxPres;
}
267 268 269

/**Function*************************************************************

270 271 272 273 274 275 276 277 278 279 280
  Synopsis    [Stops the timing manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Tim_ManStop( Tim_Man_t * p )
{
281 282
    Vec_PtrFreeFree( p->vDelayTables );
    Vec_PtrFreeP( &p->vBoxes );
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
    Mem_FlexStop( p->pMemObj, 0 );
    ABC_FREE( p->pCis );
    ABC_FREE( p->pCos );
    ABC_FREE( p );
}
void Tim_ManStopP( Tim_Man_t ** p )
{
    if ( *p == NULL )
        return;
    Tim_ManStop( *p );
    *p = NULL;
}

/**Function*************************************************************

298 299 300 301 302 303 304 305 306
  Synopsis    [Creates manager using hierarchy / box library / delay info.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
307
void Tim_ManCreate( Tim_Man_t * p, void * pLib, Vec_Flt_t * vInArrs, Vec_Flt_t * vOutReqs )
308 309 310
{
    If_LibBox_t * pLibBox = (If_LibBox_t *)pLib;
    If_Box_t * pIfBox;
311
    Tim_Box_t * pBox;
312 313
    Tim_Obj_t * pObj;
    float * pTable;
314
    int i, k;
315 316
    assert( p->vDelayTables == NULL );
    p->vDelayTables = Vec_PtrStart( Vec_PtrSize(pLibBox->vBoxes) );
317
    if ( p->vBoxes )
318 319 320 321 322
    Tim_ManForEachBox( p, pBox, i )
    {
        if ( pBox->iDelayTable == -1 )
        {
            // create table with constants
323 324 325 326
            pTable = ABC_ALLOC( float, 3 + pBox->nInputs * pBox->nOutputs );
            pTable[0] = pBox->iDelayTable;
            pTable[1] = pBox->nInputs;
            pTable[2] = pBox->nOutputs;
327
            for ( k = 0; k < pBox->nInputs * pBox->nOutputs; k++ )
328 329 330 331
                pTable[3 + k] = 1.0;
            // save table
            pBox->iDelayTable = Vec_PtrSize(p->vDelayTables);
            Vec_PtrPush( p->vDelayTables, pTable );
332 333 334 335 336 337 338
            continue;
        }
        assert( pBox->iDelayTable >= 0 && pBox->iDelayTable < Vec_PtrSize(pLibBox->vBoxes) );
        pIfBox = (If_Box_t *)Vec_PtrEntry( pLibBox->vBoxes, pBox->iDelayTable );
        assert( pIfBox != NULL );
        assert( pIfBox->nPis == pBox->nInputs );
        assert( pIfBox->nPos == pBox->nOutputs );
339
        pBox->fBlack = pIfBox->fBlack;
340 341 342
        if ( Vec_PtrEntry( p->vDelayTables, pBox->iDelayTable ) != NULL )
            continue;
        // create table of boxes
343 344 345 346
        pTable = ABC_ALLOC( float, 3 + pBox->nInputs * pBox->nOutputs );
        pTable[0] = pBox->iDelayTable;
        pTable[1] = pBox->nInputs;
        pTable[2] = pBox->nOutputs;
347
        for ( k = 0; k < pBox->nInputs * pBox->nOutputs; k++ )
348 349 350
            pTable[3 + k] = pIfBox->pDelays[k];
        // save table
        Vec_PtrWriteEntry( p->vDelayTables, pBox->iDelayTable, pTable );
351 352 353 354 355
    }
    // create arrival times
    if ( vInArrs )
    {
        assert( Vec_FltSize(vInArrs) == Tim_ManPiNum(p) );
356 357 358
        Tim_ManForEachPi( p, pObj, i )
            pObj->timeArr = Vec_FltEntry(vInArrs, i);

359 360 361 362
    }
    // create required times
    if ( vOutReqs )
    {
363
        k = 0;
364
        assert( Vec_FltSize(vOutReqs) == Tim_ManPoNum(p) );
365 366 367
        Tim_ManForEachPo( p, pObj, i )
            pObj->timeReq = Vec_FltEntry(vOutReqs, k++);
        assert( k == Tim_ManPoNum(p) );
368 369 370 371 372 373
    }
}


/**Function*************************************************************

374 375 376 377 378 379 380 381 382
  Synopsis    [Get arrival and required times if they are non-trivial.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
383
float * Tim_ManGetArrTimes( Tim_Man_t * p )
384
{
385
    float * pTimes;
386
    Tim_Obj_t * pObj;
387
    int i;
388 389 390
    Tim_ManForEachPi( p, pObj, i )
        if ( pObj->timeArr != 0.0 )
            break;
391 392 393 394 395 396 397 398 399 400 401 402
    if ( i == Tim_ManPiNum(p) )
        return NULL;
    pTimes  = ABC_ALLOC( float, Tim_ManPiNum(p) );
    Tim_ManForEachPi( p, pObj, i )
        pTimes[i] = pObj->timeArr;
    return pTimes;
}
float * Tim_ManGetReqTimes( Tim_Man_t * p )
{
    float * pTimes;
    Tim_Obj_t * pObj;
    int i, k = 0;
403 404 405
    Tim_ManForEachPo( p, pObj, i )
        if ( pObj->timeReq != TIM_ETERNITY )
            break;
406 407 408
    if ( i == Tim_ManPoNum(p) )
        return NULL;
    pTimes  = ABC_ALLOC( float, Tim_ManPoNum(p) );
409
    Tim_ManForEachPo( p, pObj, i )
410 411 412
        pTimes[k++] = pObj->timeArr;
    assert( k == Tim_ManPoNum(p) );
    return pTimes;
413 414 415 416 417
}


/**Function*************************************************************

418 419 420 421 422 423 424 425 426 427 428 429 430 431
  Synopsis    [Prints the timing manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Tim_ManPrint( Tim_Man_t * p )
{
    Tim_Box_t * pBox;
    Tim_Obj_t * pObj, * pPrev;
    float * pTable;
432
    int i, j, k, TableX, TableY;
433 434 435
    if ( p == NULL )
        return;
    printf( "TIMING MANAGER:\n" );
436 437
    printf( "PI = %d. CI = %d. PO = %d. CO = %d. Box = %d.\n", 
        Tim_ManPiNum(p), Tim_ManCiNum(p), Tim_ManPoNum(p), Tim_ManCoNum(p), Tim_ManBoxNum(p) );
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457

    // print CI info
    pPrev = p->pCis;
    Tim_ManForEachPi( p, pObj, i )
        if ( pPrev->timeArr != pObj->timeArr || pPrev->timeReq != pObj->timeReq )
            break;
    if ( i == Tim_ManCiNum(p) )
        printf( "All PIs :  arr = %5.3f  req = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
    else
        Tim_ManForEachPi( p, pObj, i )
            printf( "PI%5d :  arr = %5.3f  req = %5.3f\n", i, pObj->timeArr, pObj->timeReq );

    // print CO info
    pPrev = p->pCos;
    Tim_ManForEachPo( p, pObj, i )
        if ( pPrev->timeArr != pObj->timeArr || pPrev->timeReq != pObj->timeReq )
            break;
    if ( i == Tim_ManCoNum(p) )
        printf( "All POs :  arr = %5.3f  req = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
    else
458 459
    {
        int k = 0;
460
        Tim_ManForEachPo( p, pObj, i )
461 462
            printf( "PO%5d :  arr = %5.3f  req = %5.3f\n", k++, pObj->timeArr, pObj->timeReq );
    }
463 464

    // print box info
465
    if ( Tim_ManBoxNum(p) > 0 )
466 467
    Tim_ManForEachBox( p, pBox, i )
    {
468 469 470 471
        printf( "*** Box %5d :  I =%4d. O =%4d. I1 =%6d. O1 =%6d. Table =%4d\n", 
            i, pBox->nInputs, pBox->nOutputs, 
            Tim_ManBoxInputFirst(p, i), Tim_ManBoxOutputFirst(p, i), 
            pBox->iDelayTable );
472 473 474

        // print box inputs
        pPrev = Tim_ManBoxInput( p, pBox, 0 );
475
        Tim_ManBoxForEachInput( p, pBox, pObj, k )
476 477
            if ( pPrev->timeArr != pObj->timeArr || pPrev->timeReq != pObj->timeReq )
                break;
478
        if ( k == Tim_ManBoxInputNum(p, pBox->iBox) )
479 480
            printf( "Box inputs  :  arr = %5.3f  req = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
        else
481 482
            Tim_ManBoxForEachInput( p, pBox, pObj, k )
                printf( "box-in%4d :  arr = %5.3f  req = %5.3f\n", k, pObj->timeArr, pObj->timeReq );
483 484 485

        // print box outputs
        pPrev = Tim_ManBoxOutput( p, pBox, 0 );
486
        Tim_ManBoxForEachOutput( p, pBox, pObj, k )
487 488
            if ( pPrev->timeArr != pObj->timeArr || pPrev->timeReq != pObj->timeReq )
                break;
489
        if ( k == Tim_ManBoxOutputNum(p, pBox->iBox) )
490 491
            printf( "Box outputs :  arr = %5.3f  req = %5.3f\n", pPrev->timeArr, pPrev->timeReq );
        else
492 493
            Tim_ManBoxForEachOutput( p, pBox, pObj, k )
                printf( "box-out%3d :  arr = %5.3f  req = %5.3f\n", k, pObj->timeArr, pObj->timeReq );
494 495 496

        if ( i > 2 )
            break;
497 498 499 500 501 502
    }

    // print delay tables
    if ( Tim_ManDelayTableNum(p) > 0 )
    Tim_ManForEachTable( p, pTable, i )
    {
503 504
        if ( pTable == NULL )
            continue;
505 506 507 508 509 510 511 512 513 514
        printf( "Delay table %d:\n", i );
        assert( i == (int)pTable[0] );
        TableX = (int)pTable[1];
        TableY = (int)pTable[2];
        for ( j = 0; j < TableY; j++, printf( "\n" ) )
            for ( k = 0; k < TableX; k++ )
                if ( pTable[3+j*TableX+k] == -ABC_INFINITY )
                    printf( "%5s", "-" );
                else
                    printf( "%5.0f", pTable[3+j*TableX+k] );
515 516 517 518 519 520
    }
    printf( "\n" );
}

/**Function*************************************************************

521 522 523 524 525 526 527 528 529
  Synopsis    [Prints statistics of the timing manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
530
void Tim_ManPrintStats( Tim_Man_t * p, int nAnd2Delay )
531 532 533 534 535 536 537
{
    Tim_Box_t * pBox;
    Vec_Int_t * vCounts;
    Vec_Ptr_t * vBoxes;
    int i, Count, IdMax;
    if ( p == NULL )
        return;
538
    Abc_Print( 1, "Hierarchy      :  " );
539
    printf( "PI/CI = %d/%d   PO/CO = %d/%d   Box = %d   ", 
540 541 542
        Tim_ManPiNum(p), Tim_ManCiNum(p), 
        Tim_ManPoNum(p), Tim_ManCoNum(p), 
        Tim_ManBoxNum(p) );
543 544
    if ( nAnd2Delay )
        printf( "delay(AND2) = %d", nAnd2Delay );
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
    printf( "\n" );
    if ( Tim_ManBoxNum(p) == 0 )
        return;
    IdMax = 0;
    Tim_ManForEachBox( p, pBox, i )
        IdMax = Abc_MaxInt( IdMax, pBox->iDelayTable );
    vCounts = Vec_IntStart( IdMax+1 );
    vBoxes  = Vec_PtrStart( IdMax+1 );
    Tim_ManForEachBox( p, pBox, i )
    {
        Vec_IntAddToEntry( vCounts, pBox->iDelayTable, 1 );
        Vec_PtrWriteEntry( vBoxes, pBox->iDelayTable, pBox );
    }
    // print statistics about boxes
    Vec_IntForEachEntry( vCounts, Count, i )
    {
        if ( Count == 0 ) continue;
        pBox = (Tim_Box_t *)Vec_PtrEntry( vBoxes, i );
        printf( "    Box %4d      ", i );
        printf( "Num = %4d   ", Count );
        printf( "Ins = %4d   ", pBox->nInputs );
        printf( "Outs = %4d",   pBox->nOutputs );
        printf( "\n" );
    }
    Vec_IntFree( vCounts );
    Vec_PtrFree( vBoxes );
}

/**Function*************************************************************

575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
  Synopsis    [Read parameters.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int Tim_ManCiNum( Tim_Man_t * p )
{
    return p->nCis;
}
int Tim_ManCoNum( Tim_Man_t * p )
{
    return p->nCos;
}
int Tim_ManPiNum( Tim_Man_t * p )
{
594 595
    if ( Tim_ManBoxNum(p) == 0 )
        return Tim_ManCiNum(p);
596 597 598 599
    return Tim_ManBoxOutputFirst(p, 0);
}
int Tim_ManPoNum( Tim_Man_t * p )
{
600 601 602 603
    int iLastBoxId;
    if ( Tim_ManBoxNum(p) == 0 )
        return Tim_ManCoNum(p);
    iLastBoxId = Tim_ManBoxNum(p) - 1;
604 605 606 607
    return Tim_ManCoNum(p) - (Tim_ManBoxInputFirst(p, iLastBoxId) + Tim_ManBoxInputNum(p, iLastBoxId));
}
int Tim_ManBoxNum( Tim_Man_t * p )
{
608
    return p->vBoxes ? Vec_PtrSize(p->vBoxes) : 0;
609
}
610 611 612 613 614 615 616 617 618
int Tim_ManBlackBoxNum( Tim_Man_t * p )
{
    Tim_Box_t * pBox;
    int i, Counter = 0;
    if ( Tim_ManBoxNum(p) )
        Tim_ManForEachBox( p, pBox, i )
            Counter += pBox->fBlack;
    return Counter;
}
619 620
int Tim_ManDelayTableNum( Tim_Man_t * p )
{
621
    return p->vDelayTables ? Vec_PtrSize(p->vDelayTables) : 0;
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
}

/**Function*************************************************************

  Synopsis    [Sets the vector of timing tables associated with the manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Tim_ManSetDelayTables( Tim_Man_t * p, Vec_Ptr_t * vDelayTables )
{
    assert( p->vDelayTables == NULL );
    p->vDelayTables = vDelayTables;
}

/**Function*************************************************************

  Synopsis    [Disables the use of the traversal ID.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Tim_ManTravIdDisable( Tim_Man_t * p )
{
    p->fUseTravId = 0;
}

/**Function*************************************************************

  Synopsis    [Enables the use of the traversal ID.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Tim_ManTravIdEnable( Tim_Man_t * p )
{
    p->fUseTravId = 1;
}

////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////


ABC_NAMESPACE_IMPL_END