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

  FileName    [giaMan.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Scalable AIG package.]

  Synopsis    [Package manager.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

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

  Revision    [$Id: giaMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]

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

#include "gia.h"
22
#include "misc/tim/tim.h"
23
#include "proof/abs/abs.h"
24
#include "opt/dar/dar.h"
25 26 27

ABC_NAMESPACE_IMPL_START

Alan Mishchenko committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

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

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

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

  Synopsis    [Creates AIG.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
48 49
Gia_Man_t * Gia_ManStart( int nObjsMax )
{
Alan Mishchenko committed
50 51 52 53 54 55 56
    Gia_Man_t * p;
    assert( nObjsMax > 0 );
    p = ABC_CALLOC( Gia_Man_t, 1 );
    p->nObjsAlloc = nObjsMax;
    p->pObjs = ABC_CALLOC( Gia_Obj_t, nObjsMax );
    p->pObjs->iDiff0 = p->pObjs->iDiff1 = GIA_NONE;
    p->nObjs = 1;
57 58
    p->vCis  = Vec_IntAlloc( nObjsMax / 20 );
    p->vCos  = Vec_IntAlloc( nObjsMax / 20 );
Alan Mishchenko committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72
    return p;
}

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

  Synopsis    [Deletes AIG.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
73
void Gia_ManStop( Gia_Man_t * p )
Alan Mishchenko committed
74
{
75
    Gia_ManStaticFanoutStop( p );
76 77
    Tim_ManStopP( (Tim_Man_t **)&p->pManTime );
    assert( p->pManTime == NULL );
Alan Mishchenko committed
78 79
    Vec_PtrFreeFree( p->vNamesIn );
    Vec_PtrFreeFree( p->vNamesOut );
80 81
    Vec_IntFreeP( &p->vSuper );
    Vec_IntFreeP( &p->vStore );
82 83 84 85
    Vec_IntFreeP( &p->vClassNew );
    Vec_IntFreeP( &p->vClassOld );
    Vec_WrdFreeP( &p->vSims );
    Vec_WrdFreeP( &p->vSimsPi );
86 87 88
    Vec_FltFreeP( &p->vTiming );
    Vec_VecFreeP( &p->vClockDoms );
    Vec_IntFreeP( &p->vLutConfigs );
89 90 91
    Vec_IntFreeP( &p->vUserPiIds );
    Vec_IntFreeP( &p->vUserPoIds );
    Vec_IntFreeP( &p->vUserFfIds );
92
    Vec_IntFreeP( &p->vFlopClasses );
93
    Vec_IntFreeP( &p->vGateClasses );
94
    Vec_IntFreeP( &p->vObjClasses );
95
    Vec_IntFreeP( &p->vDoms );
96 97
    Vec_IntFreeP( &p->vLevels );
    Vec_IntFreeP( &p->vTruths );
98
    Vec_IntFreeP( &p->vTtNums );
99
    Vec_IntFreeP( &p->vTtNodes );
100
    Vec_WrdFreeP( &p->vTtMemory );
101
    Vec_PtrFreeP( &p->vTtInputs );
102
    Vec_IntFreeP( &p->vMapping );
103 104 105 106
    Vec_IntFreeP( &p->vPacking );
    Vec_FltFreeP( &p->vInArrs );
    Vec_FltFreeP( &p->vOutReqs );
    Gia_ManStopP( &p->pAigExtra );
Alan Mishchenko committed
107 108
    Vec_IntFree( p->vCis );
    Vec_IntFree( p->vCos );
109
    ABC_FREE( p->pData2 );
Alan Mishchenko committed
110
    ABC_FREE( p->pTravIds );
Alan Mishchenko committed
111 112
    ABC_FREE( p->pPlacement );
    ABC_FREE( p->pSwitching );
Alan Mishchenko committed
113
    ABC_FREE( p->pCexSeq );
Alan Mishchenko committed
114 115
    ABC_FREE( p->pCexComb );
    ABC_FREE( p->pIso );
116
//    ABC_FREE( p->pMapping );
Alan Mishchenko committed
117
    ABC_FREE( p->pFanData );
Alan Mishchenko committed
118
    ABC_FREE( p->pReprsOld );
Alan Mishchenko committed
119
    ABC_FREE( p->pReprs );
Alan Mishchenko committed
120
    ABC_FREE( p->pNexts );
121
    ABC_FREE( p->pSibls );
Alan Mishchenko committed
122
    ABC_FREE( p->pRefs );
123
//    ABC_FREE( p->pNodeRefs );
Alan Mishchenko committed
124
    ABC_FREE( p->pHTable );
125
    ABC_FREE( p->pMuxes );
Alan Mishchenko committed
126
    ABC_FREE( p->pObjs );
127 128
    ABC_FREE( p->pSpec );
    ABC_FREE( p->pName );
Alan Mishchenko committed
129 130 131 132 133
    ABC_FREE( p );
}

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

134 135 136 137 138 139 140 141 142
  Synopsis    [Returns memory used in megabytes.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
143
double Gia_ManMemory( Gia_Man_t * p )
144
{
145
    double Memory = sizeof(Gia_Man_t);
146 147 148 149
    Memory += sizeof(Gia_Obj_t) * Gia_ManObjNum(p);
    Memory += sizeof(int) * Gia_ManCiNum(p);
    Memory += sizeof(int) * Gia_ManCoNum(p);
    Memory += sizeof(int) * p->nHTable * (p->pHTable != NULL);
150
    return Memory;
151 152 153 154
}

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

155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
  Synopsis    [Stops the AIG manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Gia_ManStopP( Gia_Man_t ** p )
{
    if ( *p == NULL )
        return;
    Gia_ManStop( *p );
    *p = NULL;
}

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

Alan Mishchenko committed
174 175 176 177 178 179 180 181 182
  Synopsis    [Prints stats for the AIG.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
183
void Gia_ManPrintClasses_old( Gia_Man_t * p )
Alan Mishchenko committed
184 185 186 187 188 189
{
    Gia_Obj_t * pObj;
    int i;
    if ( p->vFlopClasses == NULL )
        return;
    Gia_ManForEachRo( p, pObj, i )
190 191
        Abc_Print( 1, "%d", Vec_IntEntry(p->vFlopClasses, i) );
    Abc_Print( 1, "\n" );
Alan Mishchenko committed
192 193 194 195

    {
        Gia_Man_t * pTemp;
        pTemp = Gia_ManDupFlopClass( p, 1 );
196
        Gia_AigerWrite( pTemp, "dom1.aig", 0, 0 );
Alan Mishchenko committed
197 198
        Gia_ManStop( pTemp );
        pTemp = Gia_ManDupFlopClass( p, 2 );
199
        Gia_AigerWrite( pTemp, "dom2.aig", 0, 0 );
Alan Mishchenko committed
200 201 202 203 204
        Gia_ManStop( pTemp );
    }
}

/**Function*************************************************************
205 206 207 208 209 210 211 212 213 214

  Synopsis    [Prints stats for the AIG.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
215 216 217 218 219 220 221 222 223 224
void Gia_ManPrintPlacement( Gia_Man_t * p )
{
    int i, nFixed = 0, nUndef = 0;
    if ( p->pPlacement == NULL )
        return;
    for ( i = 0; i < Gia_ManObjNum(p); i++ )
    {
        nFixed += p->pPlacement[i].fFixed;
        nUndef += p->pPlacement[i].fUndef;
    }
225
    Abc_Print( 1, "Placement:  Objects = %8d.  Fixed = %8d.  Undef = %8d.\n", Gia_ManObjNum(p), nFixed, nUndef );
Alan Mishchenko committed
226 227
}

228 229 230 231 232 233 234 235 236 237 238 239

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

  Synopsis    [Duplicates AIG for unrolling.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
240
void Gia_ManPrintTents_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vObjs )
241 242 243 244 245 246 247 248 249 250 251
{
    if ( Gia_ObjIsTravIdCurrent(p, pObj) )
        return;
    Gia_ObjSetTravIdCurrent(p, pObj);
    Vec_IntPush( vObjs, Gia_ObjId(p, pObj) );
    if ( Gia_ObjIsCi(pObj) )
        return;
    Gia_ManPrintTents_rec( p, Gia_ObjFanin0(pObj), vObjs );
    if ( Gia_ObjIsAnd(pObj) )
        Gia_ManPrintTents_rec( p, Gia_ObjFanin1(pObj), vObjs );
}
252
void Gia_ManPrintTents( Gia_Man_t * p )
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
{
    Vec_Int_t * vObjs;
    Gia_Obj_t * pObj;
    int t, i, iObjId, nSizePrev, nSizeCurr;
    assert( Gia_ManPoNum(p) > 0 );
    vObjs = Vec_IntAlloc( 100 );
    // save constant class
    Gia_ManIncrementTravId( p );
    Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
    Vec_IntPush( vObjs, 0 );
    // create starting root
    nSizePrev = Vec_IntSize(vObjs);
    Gia_ManForEachPo( p, pObj, i )
        Gia_ManPrintTents_rec( p, pObj, vObjs );
    // build tents
268
    Abc_Print( 1, "Tents:  " );
269 270
    for ( t = 1; nSizePrev < Vec_IntSize(vObjs); t++ )
    {
271
        int nPis = 0;
272 273
        nSizeCurr = Vec_IntSize(vObjs);
        Vec_IntForEachEntryStartStop( vObjs, iObjId, i, nSizePrev, nSizeCurr )
274 275
        {
            nPis += Gia_ObjIsPi(p, Gia_ManObj(p, iObjId));
276 277
            if ( Gia_ObjIsRo(p, Gia_ManObj(p, iObjId)) )
                Gia_ManPrintTents_rec( p, Gia_ObjRoToRi(p, Gia_ManObj(p, iObjId)), vObjs );
278
        }
279
        Abc_Print( 1, "%d=%d(%d)  ", t, nSizeCurr - nSizePrev, nPis );
280 281
        nSizePrev = nSizeCurr;
    }
282
    Abc_Print( 1, " Unused=%d\n", Gia_ManObjNum(p) - Vec_IntSize(vObjs) );
283 284 285 286 287 288 289
    Vec_IntFree( vObjs );
    // the remaining objects are PIs without fanout
//    Gia_ManForEachObj( p, pObj, i )
//        if ( !Gia_ObjIsTravIdCurrent(p, pObj) )
//            Gia_ObjPrint( p, pObj );
}

Alan Mishchenko committed
290 291 292 293 294 295 296 297 298 299 300
/**Function*************************************************************

  Synopsis    [Prints stats for the AIG.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
void Gia_ManPrintChoiceStats( Gia_Man_t * p )
{
    Gia_Obj_t * pObj;
    int i, nEquivs = 0, nChoices = 0;
    Gia_ManMarkFanoutDrivers( p );
    Gia_ManForEachAnd( p, pObj, i )
    {
        if ( !Gia_ObjSibl(p, i) )
            continue;
        nEquivs++;
        if ( pObj->fMark0 )
            nChoices++;
        assert( !Gia_ObjSiblObj(p, i)->fMark0 );
        assert( Gia_ObjIsAnd(Gia_ObjSiblObj(p, i)) );
    }
    Abc_Print( 1, "Choice stats: Equivs =%7d. Choices =%7d.\n", nEquivs, nChoices );
317
    Gia_ManCleanMark0( p );
318 319 320 321 322 323 324 325 326 327 328 329 330
}

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

  Synopsis    [Prints stats for the AIG.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
331
void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars )
Alan Mishchenko committed
332 333
{
    if ( p->pName )
334 335
        Abc_Print( 1, "%-8s : ", p->pName );
    Abc_Print( 1, "i/o =%7d/%7d", Gia_ManPiNum(p), Gia_ManPoNum(p) );
336
    if ( Gia_ManConstrNum(p) )
337
        Abc_Print( 1, "(c=%d)", Gia_ManConstrNum(p) );
Alan Mishchenko committed
338
    if ( Gia_ManRegNum(p) )
339
        Abc_Print( 1, "  ff =%7d", Gia_ManRegNum(p) );
340
    Abc_Print( 1, "  %s =%8d", p->pMuxes? "nod" : "and", Gia_ManAndNum(p) );
341
    Abc_Print( 1, "  lev =%5d", Gia_ManLevelNum(p) ); Vec_IntFreeP( &p->vLevels );
342
    if ( pPars && pPars->fCut )
343 344
        Abc_Print( 1, "  cut = %d(%d)", Gia_ManCrossCut(p, 0), Gia_ManCrossCut(p, 1) );
    Abc_Print( 1, "  mem =%5.2f MB", Gia_ManMemory(p)/(1<<20) );
345
    if ( Gia_ManHasDangling(p) )
346
        Abc_Print( 1, "  ch =%5d", Gia_ManEquivCountClasses(p) );
347 348 349 350 351 352
    if ( p->pMuxes )
    {
        Abc_Print( 1, "  and =%5d", Gia_ManAndNum(p)-Gia_ManXorNum(p)-Gia_ManMuxNum(p) );
        Abc_Print( 1, "  xor =%5d", Gia_ManXorNum(p) );
        Abc_Print( 1, "  mux =%5d", Gia_ManMuxNum(p) );
    }
353
    if ( pPars && pPars->fSwitch )
Alan Mishchenko committed
354 355
    {
        if ( p->pSwitching )
356
            Abc_Print( 1, "  power =%7.2f", Gia_ManEvaluateSwitching(p) );
Alan Mishchenko committed
357
        else
358
            Abc_Print( 1, "  power =%7.2f", Gia_ManComputeSwitching(p, 48, 16, 0) );
Alan Mishchenko committed
359
    }
360 361
//    Abc_Print( 1, "obj =%5d  ", Gia_ManObjNum(p) );
    Abc_Print( 1, "\n" );
Alan Mishchenko committed
362 363

//    Gia_ManSatExperiment( p );
Alan Mishchenko committed
364 365
    if ( p->pReprs && p->pNexts )
        Gia_ManEquivPrintClasses( p, 0, 0.0 );
366 367
    if ( p->pSibls )
        Gia_ManPrintChoiceStats( p );
368
    if ( Gia_ManHasMapping(p) )
369
        Gia_ManPrintMappingStats( p, pPars->fDumpFile );
370 371
    if ( pPars && pPars->fNpn && Gia_ManHasMapping(p) && Gia_ManLutSizeMax(p) <= 4 )
        Gia_ManPrintNpnClasses( p );
372 373
    if ( p->vPacking )
        Gia_ManPrintPackingStats( p );
374 375
    if ( pPars && pPars->fLutProf && Gia_ManHasMapping(p) )
        Gia_ManPrintLutStats( p );
Alan Mishchenko committed
376 377
    if ( p->pPlacement )
        Gia_ManPrintPlacement( p );
378
    if ( p->pManTime )
Alan Mishchenko committed
379
        Tim_ManPrintStats( (Tim_Man_t *)p->pManTime, p->nAnd2Delay );
Alan Mishchenko committed
380
    // print register classes
381 382
    Gia_ManPrintFlopClasses( p );
    Gia_ManPrintGateClasses( p );
383
    Gia_ManPrintObjClasses( p );
384
    if ( pPars && pPars->fTents )
385
    {
386
/*
387 388 389
        int k, Entry, Prev = 1;
        Vec_Int_t * vLimit = Vec_IntAlloc( 1000 );
        Gia_Man_t * pNew = Gia_ManUnrollDup( p, vLimit );
390
        Abc_Print( 1, "Tents:  " );
391
        Vec_IntForEachEntryStart( vLimit, Entry, k, 1 )
392 393 394
            Abc_Print( 1, "%d=%d  ", k, Entry-Prev ), Prev = Entry;
        Abc_Print( 1, " Unused=%d.", Gia_ManObjNum(p) - Gia_ManObjNum(pNew) );
        Abc_Print( 1, "\n" );
395 396
        Vec_IntFree( vLimit );
        Gia_ManStop( pNew );
397
*/
398
        Gia_ManPrintTents( p );
399
    }
Alan Mishchenko committed
400 401 402 403 404 405 406
}

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

  Synopsis    [Prints stats for the AIG.]

  Description []
407

Alan Mishchenko committed
408 409 410 411 412 413 414
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Gia_ManPrintStatsShort( Gia_Man_t * p )
{
415 416 417 418 419 420
    Abc_Print( 1, "i/o =%7d/%7d  ", Gia_ManPiNum(p), Gia_ManPoNum(p) );
    Abc_Print( 1, "ff =%7d  ", Gia_ManRegNum(p) );
    Abc_Print( 1, "and =%8d  ", Gia_ManAndNum(p) );
    Abc_Print( 1, "lev =%5d  ", Gia_ManLevelNum(p) );
//    Abc_Print( 1, "mem =%5.2f MB", 12.0*Gia_ManObjNum(p)/(1<<20) );
    Abc_Print( 1, "\n" );
Alan Mishchenko committed
421
}
422

Alan Mishchenko committed
423 424 425 426 427
/**Function*************************************************************

  Synopsis    [Prints stats for the AIG.]

  Description []
428

Alan Mishchenko committed
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Gia_ManPrintMiterStatus( Gia_Man_t * p )
{
    Gia_Obj_t * pObj, * pChild;
    int i, nSat = 0, nUnsat = 0, nUndec = 0, iOut = -1;
    Gia_ManForEachPo( p, pObj, i )
    {
        pChild = Gia_ObjChild0(pObj);
        // check if the output is constant 0
        if ( pChild == Gia_ManConst0(p) )
            nUnsat++;
        // check if the output is constant 1
        else if ( pChild == Gia_ManConst1(p) )
        {
            nSat++;
            if ( iOut == -1 )
                iOut = i;
        }
        // check if the output is a primary input
        else if ( Gia_ObjIsPi(p, Gia_Regular(pChild)) )
        {
            nSat++;
            if ( iOut == -1 )
                iOut = i;
        }
/*
        // check if the output is 1 for the 0000 pattern
        else if ( Gia_Regular(pChild)->fPhase != (unsigned)Gia_IsComplement(pChild) )
        {
            nSat++;
            if ( iOut == -1 )
                iOut = i;
        }
*/
        else
            nUndec++;
    }
470
    Abc_Print( 1, "Outputs = %7d.  Unsat = %7d.  Sat = %7d.  Undec = %7d.\n",
Alan Mishchenko committed
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
        Gia_ManPoNum(p), nUnsat, nSat, nUndec );
}

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

  Synopsis    [Prints stats for the AIG.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Gia_ManSetRegNum( Gia_Man_t * p, int nRegs )
{
    assert( p->nRegs == 0 );
    p->nRegs = nRegs;
}


Alan Mishchenko committed
492 493 494 495 496 497 498 499 500 501 502 503 504
/**Function*************************************************************

  Synopsis    [Reports the reduction of the AIG.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Gia_ManReportImprovement( Gia_Man_t * p, Gia_Man_t * pNew )
{
505 506
    Abc_Print( 1, "REG: Beg = %5d. End = %5d. (R =%5.1f %%)  ",
        Gia_ManRegNum(p), Gia_ManRegNum(pNew),
Alan Mishchenko committed
507
        Gia_ManRegNum(p)? 100.0*(Gia_ManRegNum(p)-Gia_ManRegNum(pNew))/Gia_ManRegNum(p) : 0.0 );
508 509
    Abc_Print( 1, "AND: Beg = %6d. End = %6d. (R =%5.1f %%)",
        Gia_ManAndNum(p), Gia_ManAndNum(pNew),
Alan Mishchenko committed
510
        Gia_ManAndNum(p)? 100.0*(Gia_ManAndNum(p)-Gia_ManAndNum(pNew))/Gia_ManAndNum(p) : 0.0 );
511
    Abc_Print( 1, "\n" );
Alan Mishchenko committed
512 513
}

514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
/**Function*************************************************************

  Synopsis    [Prints NPN class statistics.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Gia_ManPrintNpnClasses( Gia_Man_t * p )
{
    extern char ** Kit_DsdNpn4ClassNames();
    char ** pNames = Kit_DsdNpn4ClassNames();
    Vec_Int_t * vLeaves, * vTruth, * vVisited;
    int * pLutClass, ClassCounts[222] = {0};
    int i, k, iFan, Class, OtherClasses, OtherClasses2, nTotal, Counter, Counter2;
    unsigned * pTruth;
533
    assert( Gia_ManHasMapping(p) );
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566
    assert(  Gia_ManLutSizeMax( p ) <= 4 );
    vLeaves   = Vec_IntAlloc( 100 );
    vVisited  = Vec_IntAlloc( 100 );
    vTruth    = Vec_IntAlloc( (1<<16) );
    pLutClass = ABC_CALLOC( int, Gia_ManObjNum(p) );
    Gia_ManCleanTruth( p );
    Gia_ManForEachLut( p, i )
    {
        if ( Gia_ObjLutSize(p,i) > 4 )
            continue;
        Vec_IntClear( vLeaves );
        Gia_LutForEachFanin( p, i, iFan, k )
            Vec_IntPush( vLeaves, iFan );
        for ( ; k < 4; k++ )
            Vec_IntPush( vLeaves, 0 );
        pTruth = Gia_ManConvertAigToTruth( p, Gia_ManObj(p, i), vLeaves, vTruth, vVisited );
        Class = Dar_LibReturnClass( *pTruth );
        ClassCounts[ Class ]++;
        pLutClass[i] = Class;
    }
    Vec_IntFree( vLeaves );
    Vec_IntFree( vTruth );
    Vec_IntFree( vVisited );
    Vec_IntFreeP( &p->vTruths );
    nTotal = 0;
    for ( i = 0; i < 222; i++ )
        nTotal += ClassCounts[i];
    Abc_Print( 1, "NPN CLASS STATISTICS (for %d LUT4 present in the current mapping):\n", nTotal );
    OtherClasses = 0;
    for ( i = 0; i < 222; i++ )
    {
        if ( ClassCounts[i] == 0 )
            continue;
567 568
//        if ( 100.0 * ClassCounts[i] / (nTotal+1) < 0.1 ) // do not show anything below 0.1 percent
//            continue;
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603
        OtherClasses += ClassCounts[i];
        Abc_Print( 1, "Class %3d :  Count = %6d   (%7.2f %%)   %s\n", 
            i, ClassCounts[i], 100.0 * ClassCounts[i] / (nTotal+1), pNames[i] );
    }
    OtherClasses = nTotal - OtherClasses;
    Abc_Print( 1, "Other     :  Count = %6d   (%7.2f %%)\n", 
        OtherClasses, 100.0 * OtherClasses / (nTotal+1) );
    // count the number of LUTs that have MUX function and two fanins with MUX functions
    OtherClasses = OtherClasses2 = 0;
    ABC_FREE( p->pRefs );
    Gia_ManSetRefsMapped( p );
    Gia_ManForEachLut( p, i )
    {
        if ( pLutClass[i] != 109 )
            continue;
        Counter = Counter2 = 0;
        Gia_LutForEachFanin( p, i, iFan, k )
        {
            Counter  += (pLutClass[iFan] == 109);
            Counter2 += (pLutClass[iFan] == 109) && (Gia_ObjRefNumId(p, iFan) == 1);
        }
        OtherClasses  += (Counter > 1);
        OtherClasses2 += (Counter2 > 1);
//            Abc_Print( 1, "%d -- ", pLutClass[i] );
//            Gia_LutForEachFanin( p, i, iFan, k )
//                Abc_Print( 1, "%d ", pLutClass[iFan] );
//            Abc_Print( 1, "\n" );
    }
    ABC_FREE( p->pRefs );
    Abc_Print( 1, "Approximate number of 4:1 MUX structures: All = %6d  (%7.2f %%)  MFFC = %6d  (%7.2f %%)\n", 
        OtherClasses,  100.0 * OtherClasses  / (nTotal+1),
        OtherClasses2, 100.0 * OtherClasses2 / (nTotal+1) );
    ABC_FREE( pLutClass );
}

Alan Mishchenko committed
604 605 606 607 608
////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////


609
ABC_NAMESPACE_IMPL_END