cswCut.c 17.3 KB
Newer Older
Alan Mishchenko committed
1 2
/**CFile****************************************************************

Alan Mishchenko committed
3
  FileName    [cswCut.c]
Alan Mishchenko committed
4 5 6

  SystemName  [ABC: Logic synthesis and verification system.]

Alan Mishchenko committed
7
  PackageName [Cut sweeping.]
Alan Mishchenko committed
8

Alan Mishchenko committed
9
  Synopsis    []
Alan Mishchenko committed
10 11 12 13 14

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

Alan Mishchenko committed
15
  Date        [Ver. 1.0. Started - July 11, 2007.]
Alan Mishchenko committed
16

Alan Mishchenko committed
17
  Revision    [$Id: cswCut.c,v 1.00 2007/07/11 00:00:00 alanmi Exp $]
Alan Mishchenko committed
18 19 20

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

Alan Mishchenko committed
21
#include "cswInt.h"
Alan Mishchenko committed
22

23 24 25
ABC_NAMESPACE_IMPL_START


Alan Mishchenko committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

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

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

  Synopsis    [Compute the cost of the cut.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
45
static inline int Csw_CutFindCost( Csw_Man_t * p, Csw_Cut_t * pCut )
Alan Mishchenko committed
46 47 48 49
{
    Aig_Obj_t * pLeaf;
    int i, Cost = 0;
    assert( pCut->nFanins > 0 );
Alan Mishchenko committed
50 51 52 53 54 55 56 57
    Csw_CutForEachLeaf( p->pManRes, pCut, pLeaf, i )
    {
//        Cost += pLeaf->nRefs;
        Cost += Csw_ObjRefs( p, pLeaf );
//        printf( "%d ", pLeaf->nRefs );
    }
//printf( "\n" );
    return Cost * 100 / pCut->nFanins;
Alan Mishchenko committed
58 59 60 61 62 63 64 65 66 67 68 69 70
}

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

  Synopsis    [Compute the cost of the cut.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
71
static inline float Csw_CutFindCost2( Csw_Man_t * p, Csw_Cut_t * pCut )
Alan Mishchenko committed
72 73 74 75 76
{
    Aig_Obj_t * pLeaf;
    float Cost = 0.0;
    int i;
    assert( pCut->nFanins > 0 );
Alan Mishchenko committed
77
    Csw_CutForEachLeaf( p->pManRes, pCut, pLeaf, i )
Alan Mishchenko committed
78 79 80 81 82 83
        Cost += (float)1.0/pLeaf->nRefs;
    return 1/Cost;
}

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

84
  Synopsis    [Returns the next free cut to use.]
Alan Mishchenko committed
85 86 87 88 89 90 91 92

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
93
static inline Csw_Cut_t * Csw_CutFindFree( Csw_Man_t * p, Aig_Obj_t * pObj )
Alan Mishchenko committed
94
{
Alan Mishchenko committed
95
    Csw_Cut_t * pCut, * pCutMax;
Alan Mishchenko committed
96 97
    int i;
    pCutMax = NULL;
Alan Mishchenko committed
98
    Csw_ObjForEachCut( p, pObj, pCut, i )
Alan Mishchenko committed
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
    {
        if ( pCut->nFanins == 0 )
            return pCut;
        if ( pCutMax == NULL || pCutMax->Cost < pCut->Cost )
            pCutMax = pCut;
    }
    assert( pCutMax != NULL );
    pCutMax->nFanins = 0;
    return pCutMax;
}

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

  Synopsis    [Computes the stretching phase of the cut w.r.t. the merged cut.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
121
static inline unsigned Cut_TruthPhase( Csw_Cut_t * pCut, Csw_Cut_t * pCut1 )
Alan Mishchenko committed
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
{
    unsigned uPhase = 0;
    int i, k;
    for ( i = k = 0; i < pCut->nFanins; i++ )
    {
        if ( k == pCut1->nFanins )
            break;
        if ( pCut->pFanins[i] < pCut1->pFanins[k] )
            continue;
        assert( pCut->pFanins[i] == pCut1->pFanins[k] );
        uPhase |= (1 << i);
        k++;
    }
    return uPhase;
}

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

  Synopsis    [Performs truth table computation.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
149
unsigned * Csw_CutComputeTruth( Csw_Man_t * p, Csw_Cut_t * pCut, Csw_Cut_t * pCut0, Csw_Cut_t * pCut1, int fCompl0, int fCompl1 )
Alan Mishchenko committed
150 151 152
{
    // permute the first table
    if ( fCompl0 ) 
Alan Mishchenko committed
153
        Kit_TruthNot( p->puTemp[0], Csw_CutTruth(pCut0), p->nLeafMax );
Alan Mishchenko committed
154
    else
Alan Mishchenko committed
155 156
        Kit_TruthCopy( p->puTemp[0], Csw_CutTruth(pCut0), p->nLeafMax );
    Kit_TruthStretch( p->puTemp[2], p->puTemp[0], pCut0->nFanins, p->nLeafMax, Cut_TruthPhase(pCut, pCut0), 0 );
Alan Mishchenko committed
157 158
    // permute the second table
    if ( fCompl1 ) 
Alan Mishchenko committed
159
        Kit_TruthNot( p->puTemp[1], Csw_CutTruth(pCut1), p->nLeafMax );
Alan Mishchenko committed
160
    else
Alan Mishchenko committed
161 162
        Kit_TruthCopy( p->puTemp[1], Csw_CutTruth(pCut1), p->nLeafMax );
    Kit_TruthStretch( p->puTemp[3], p->puTemp[1], pCut1->nFanins, p->nLeafMax, Cut_TruthPhase(pCut, pCut1), 0 );
Alan Mishchenko committed
163
    // produce the resulting table
Alan Mishchenko committed
164 165 166
    Kit_TruthAnd( Csw_CutTruth(pCut), p->puTemp[2], p->puTemp[3], p->nLeafMax );
//    assert( pCut->nFanins >= Kit_TruthSupportSize( Csw_CutTruth(pCut), p->nLeafMax ) );
    return Csw_CutTruth(pCut);
Alan Mishchenko committed
167 168 169 170 171 172 173 174 175 176 177 178 179
}

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

  Synopsis    [Performs support minimization for the truth table.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
180
int Csw_CutSupportMinimize( Csw_Man_t * p, Csw_Cut_t * pCut )
Alan Mishchenko committed
181 182 183 184
{
    unsigned * pTruth;
    int uSupp, nFansNew, i, k;
    // get truth table
Alan Mishchenko committed
185
    pTruth = Csw_CutTruth( pCut );
Alan Mishchenko committed
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
    // get support 
    uSupp = Kit_TruthSupport( pTruth, p->nLeafMax );
    // get the new support size
    nFansNew = Kit_WordCountOnes( uSupp );
    // check if there are redundant variables
    if ( nFansNew == pCut->nFanins )
        return nFansNew;
    assert( nFansNew < pCut->nFanins );
    // minimize support
    Kit_TruthShrink( p->puTemp[0], pTruth, nFansNew, p->nLeafMax, uSupp, 1 );
    for ( i = k = 0; i < pCut->nFanins; i++ )
        if ( uSupp & (1 << i) )
            pCut->pFanins[k++] = pCut->pFanins[i];
    assert( k == nFansNew );
    pCut->nFanins = nFansNew;
//    assert( nFansNew == Kit_TruthSupportSize( pTruth, p->nLeafMax ) );
//Extra_PrintBinary( stdout, pTruth, (1<<p->nLeafMax) ); printf( "\n" );
    return nFansNew;
}

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

  Synopsis    [Returns 1 if pDom is contained in pCut.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
217
static inline int Csw_CutCheckDominance( Csw_Cut_t * pDom, Csw_Cut_t * pCut )
Alan Mishchenko committed
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
{
    int i, k;
    for ( i = 0; i < (int)pDom->nFanins; i++ )
    {
        for ( k = 0; k < (int)pCut->nFanins; k++ )
            if ( pDom->pFanins[i] == pCut->pFanins[k] )
                break;
        if ( k == (int)pCut->nFanins ) // node i in pDom is not contained in pCut
            return 0;
    }
    // every node in pDom is contained in pCut
    return 1;
}

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

  Synopsis    [Returns 1 if the cut is contained.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
243
int Csw_CutFilter( Csw_Man_t * p, Aig_Obj_t * pObj, Csw_Cut_t * pCut )
Alan Mishchenko committed
244
{ 
Alan Mishchenko committed
245
    Csw_Cut_t * pTemp;
Alan Mishchenko committed
246 247
    int i;
    // go through the cuts of the node
Alan Mishchenko committed
248
    Csw_ObjForEachCut( p, pObj, pTemp, i )
Alan Mishchenko committed
249 250 251 252 253 254 255 256 257 258 259
    {
        if ( pTemp->nFanins < 2 )
            continue;
        if ( pTemp == pCut )
            continue;
        if ( pTemp->nFanins > pCut->nFanins )
        {
            // skip the non-contained cuts
            if ( (pTemp->uSign & pCut->uSign) != pCut->uSign )
                continue;
            // check containment seriously
Alan Mishchenko committed
260
            if ( Csw_CutCheckDominance( pCut, pTemp ) )
Alan Mishchenko committed
261 262 263 264 265 266 267 268 269 270 271
            {
                // remove contained cut
                pTemp->nFanins = 0;
            }
         }
        else
        {
            // skip the non-contained cuts
            if ( (pTemp->uSign & pCut->uSign) != pTemp->uSign )
                continue;
            // check containment seriously
Alan Mishchenko committed
272
            if ( Csw_CutCheckDominance( pTemp, pCut ) )
Alan Mishchenko committed
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
            {
                // remove the given
                pCut->nFanins = 0;
                return 1;
            }
        }
    }
    return 0;
}

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

  Synopsis    [Merges two cuts.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
294
static inline int Csw_CutMergeOrdered( Csw_Man_t * p, Csw_Cut_t * pC0, Csw_Cut_t * pC1, Csw_Cut_t * pC )
Alan Mishchenko committed
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
{ 
    int i, k, c;
    assert( pC0->nFanins >= pC1->nFanins );
    // the case of the largest cut sizes
    if ( pC0->nFanins == p->nLeafMax && pC1->nFanins == p->nLeafMax )
    {
        for ( i = 0; i < pC0->nFanins; i++ )
            if ( pC0->pFanins[i] != pC1->pFanins[i] )
                return 0;
        for ( i = 0; i < pC0->nFanins; i++ )
            pC->pFanins[i] = pC0->pFanins[i];
        pC->nFanins = pC0->nFanins;
        return 1;
    }
    // the case when one of the cuts is the largest
    if ( pC0->nFanins == p->nLeafMax )
    {
        for ( i = 0; i < pC1->nFanins; i++ )
        {
            for ( k = pC0->nFanins - 1; k >= 0; k-- )
                if ( pC0->pFanins[k] == pC1->pFanins[i] )
                    break;
            if ( k == -1 ) // did not find
                return 0;
        }
        for ( i = 0; i < pC0->nFanins; i++ )
            pC->pFanins[i] = pC0->pFanins[i];
        pC->nFanins = pC0->nFanins;
        return 1;
    }

    // compare two cuts with different numbers
    i = k = 0;
    for ( c = 0; c < p->nLeafMax; c++ )
    {
        if ( k == pC1->nFanins )
        {
            if ( i == pC0->nFanins )
            {
                pC->nFanins = c;
                return 1;
            }
            pC->pFanins[c] = pC0->pFanins[i++];
            continue;
        }
        if ( i == pC0->nFanins )
        {
            if ( k == pC1->nFanins )
            {
                pC->nFanins = c;
                return 1;
            }
            pC->pFanins[c] = pC1->pFanins[k++];
            continue;
        }
        if ( pC0->pFanins[i] < pC1->pFanins[k] )
        {
            pC->pFanins[c] = pC0->pFanins[i++];
            continue;
        }
        if ( pC0->pFanins[i] > pC1->pFanins[k] )
        {
            pC->pFanins[c] = pC1->pFanins[k++];
            continue;
        }
        pC->pFanins[c] = pC0->pFanins[i++]; 
        k++;
    }
    if ( i < pC0->nFanins || k < pC1->nFanins )
        return 0;
    pC->nFanins = c;
    return 1;
}

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

  Synopsis    [Prepares the object for FPGA mapping.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
380
int Csw_CutMerge( Csw_Man_t * p, Csw_Cut_t * pCut0, Csw_Cut_t * pCut1, Csw_Cut_t * pCut )
Alan Mishchenko committed
381 382 383 384 385
{ 
    assert( p->nLeafMax > 0 );
    // merge the nodes
    if ( pCut0->nFanins < pCut1->nFanins )
    {
Alan Mishchenko committed
386
        if ( !Csw_CutMergeOrdered( p, pCut1, pCut0, pCut ) )
Alan Mishchenko committed
387 388 389 390
            return 0;
    }
    else
    {
Alan Mishchenko committed
391
        if ( !Csw_CutMergeOrdered( p, pCut0, pCut1, pCut ) )
Alan Mishchenko committed
392 393 394 395 396 397 398 399
            return 0;
    }
    pCut->uSign = pCut0->uSign | pCut1->uSign;
    return 1;
}

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

Alan Mishchenko committed
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443
  Synopsis    [Consider cut with more than 2 fanins having 2 true variables.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Aig_Obj_t * Csw_ObjTwoVarCut( Csw_Man_t * p, Csw_Cut_t * pCut )
{
    Aig_Obj_t * pRes, * pIn0, * pIn1;
    int nVars, uTruth, fCompl = 0;
    assert( pCut->nFanins > 2 );
    // minimize support of this cut
    nVars = Csw_CutSupportMinimize( p, pCut );
    assert( nVars == 2 );
    // get the fanins
    pIn0 = Aig_ManObj( p->pManRes, pCut->pFanins[0] );
    pIn1 = Aig_ManObj( p->pManRes, pCut->pFanins[1] );
    // derive the truth table
    uTruth = 0xF & *Csw_CutTruth(pCut);
    if ( uTruth == 14 || uTruth == 13 || uTruth == 11 || uTruth == 7 )
    {
        uTruth = 0xF & ~uTruth;
        fCompl = 1;
    }
    // compute the result
    pRes = NULL;
    if ( uTruth == 1  )  // 0001  // 1110  14
        pRes = Aig_And( p->pManRes, Aig_Not(pIn0), Aig_Not(pIn1) );
    if ( uTruth == 2  )  // 0010  // 1101  13 
        pRes = Aig_And( p->pManRes,         pIn0 , Aig_Not(pIn1) );
    if ( uTruth == 4  )  // 0100  // 1011  11
        pRes = Aig_And( p->pManRes, Aig_Not(pIn0),         pIn1  );
    if ( uTruth == 8  )  // 1000  // 0111   7
        pRes = Aig_And( p->pManRes,         pIn0 ,         pIn1  );
    if ( pRes )
        pRes = Aig_NotCond( pRes, fCompl );
    return pRes;
}

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

Alan Mishchenko committed
444 445 446 447 448 449 450 451 452
  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
453
Csw_Cut_t * Csw_ObjPrepareCuts( Csw_Man_t * p, Aig_Obj_t * pObj, int fTriv )
Alan Mishchenko committed
454
{
Alan Mishchenko committed
455
    Csw_Cut_t * pCutSet, * pCut;
Alan Mishchenko committed
456 457
    int i;
    // create the cutset of the node
Alan Mishchenko committed
458 459 460
    pCutSet = (Csw_Cut_t *)Aig_MmFixedEntryFetch( p->pMemCuts );
    Csw_ObjSetCuts( p, pObj, pCutSet );
    Csw_ObjForEachCut( p, pObj, pCut, i )
Alan Mishchenko committed
461
    {
Alan Mishchenko committed
462 463
        pCut->nFanins = 0;
        pCut->iNode = pObj->Id;
Alan Mishchenko committed
464 465 466 467 468 469 470 471 472 473 474 475
        pCut->nCutSize = p->nCutSize;
        pCut->nLeafMax = p->nLeafMax;
    }
    // add unit cut if needed
    if ( fTriv )
    {
        pCut = pCutSet;
        pCut->Cost = 0;
        pCut->iNode = pObj->Id;
        pCut->nFanins = 1;
        pCut->pFanins[0] = pObj->Id;
        pCut->uSign = Aig_ObjCutSign( pObj->Id );
Alan Mishchenko committed
476
        memset( Csw_CutTruth(pCut), 0xAA, sizeof(unsigned) * p->nTruthWords );
Alan Mishchenko committed
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
    }
    return pCutSet;
}

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

  Synopsis    [Derives cuts for one node and sweeps this node.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
492
Aig_Obj_t * Csw_ObjSweep( Csw_Man_t * p, Aig_Obj_t * pObj, int fTriv )
Alan Mishchenko committed
493
{
Alan Mishchenko committed
494 495
    int fUseResub = 1;
    Csw_Cut_t * pCut0, * pCut1, * pCut, * pCutSet;
Alan Mishchenko committed
496 497
    Aig_Obj_t * pFanin0 = Aig_ObjFanin0(pObj);
    Aig_Obj_t * pFanin1 = Aig_ObjFanin1(pObj);
Alan Mishchenko committed
498 499
    Aig_Obj_t * pObjNew;
    unsigned * pTruth;
500
    int i, k, nVars, nFanins, iVar;
501
    abctime clk;
Alan Mishchenko committed
502 503 504 505 506 507

    assert( !Aig_IsComplement(pObj) );
    if ( !Aig_ObjIsNode(pObj) )
        return pObj;
    if ( Csw_ObjCuts(p, pObj) )
        return pObj;
Alan Mishchenko committed
508
    // the node is not processed yet
Alan Mishchenko committed
509
    assert( Csw_ObjCuts(p, pObj) == NULL );
Alan Mishchenko committed
510
    assert( Aig_ObjIsNode(pObj) );
Alan Mishchenko committed
511

Alan Mishchenko committed
512
    // set up the first cut
Alan Mishchenko committed
513 514
    pCutSet = Csw_ObjPrepareCuts( p, pObj, fTriv );

Alan Mishchenko committed
515
    // compute pair-wise cut combinations while checking table
Alan Mishchenko committed
516
    Csw_ObjForEachCut( p, pFanin0, pCut0, i )
Alan Mishchenko committed
517
    if ( pCut0->nFanins > 0 )
Alan Mishchenko committed
518
    Csw_ObjForEachCut( p, pFanin1, pCut1, k )
Alan Mishchenko committed
519 520 521 522 523 524
    if ( pCut1->nFanins > 0 )
    {
        // make sure K-feasible cut exists
        if ( Kit_WordCountOnes(pCut0->uSign | pCut1->uSign) > p->nLeafMax )
            continue;
        // get the next cut of this node
Alan Mishchenko committed
525
        pCut = Csw_CutFindFree( p, pObj );
526
clk = Abc_Clock();
Alan Mishchenko committed
527
        // assemble the new cut
Alan Mishchenko committed
528
        if ( !Csw_CutMerge( p, pCut0, pCut1, pCut ) )
Alan Mishchenko committed
529 530 531 532 533
        {
            assert( pCut->nFanins == 0 );
            continue;
        }
        // check containment
Alan Mishchenko committed
534
        if ( Csw_CutFilter( p, pObj, pCut ) )
Alan Mishchenko committed
535 536 537 538 539
        {
            assert( pCut->nFanins == 0 );
            continue;
        }
        // create its truth table
Alan Mishchenko committed
540 541 542 543 544
        pTruth = Csw_CutComputeTruth( p, pCut, pCut0, pCut1, Aig_ObjFaninC0(pObj), Aig_ObjFaninC1(pObj) );
        // support minimize the truth table
        nFanins = pCut->nFanins;
//        nVars = Csw_CutSupportMinimize( p, pCut ); // leads to quality degradation
        nVars = Kit_TruthSupportSize( pTruth, p->nLeafMax );
545
p->timeCuts += Abc_Clock() - clk;
Alan Mishchenko committed
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561

        // check for trivial truth tables
        if ( nVars == 0 )
        {
            p->nNodesTriv0++;
            return Aig_NotCond( Aig_ManConst1(p->pManRes), !(pTruth[0] & 1) );
        }
        if ( nVars == 1 )
        {
            p->nNodesTriv1++;
            iVar = Kit_WordFindFirstBit( Kit_TruthSupport(pTruth, p->nLeafMax) );
            assert( iVar < pCut->nFanins );
            return Aig_NotCond( Aig_ManObj(p->pManRes, pCut->pFanins[iVar]), (pTruth[0] & 1) );
        }
        if ( nVars == 2 && nFanins > 2 && fUseResub )
        {
Alan Mishchenko committed
562
            if ( (pObjNew = Csw_ObjTwoVarCut( p, pCut )) )
Alan Mishchenko committed
563 564 565 566 567 568 569
            {
                p->nNodesTriv2++;
                return pObjNew;
            }
        }

        // check if an equivalent node with the same cut exists
570
clk = Abc_Clock();
Alan Mishchenko committed
571
        pObjNew = pCut->nFanins > 2 ? Csw_TableCutLookup( p, pCut ) : NULL;
572
p->timeHash += Abc_Clock() - clk;
Alan Mishchenko committed
573 574 575 576 577 578
        if ( pObjNew )
        {
            p->nNodesCuts++;
            return pObjNew;
        }

Alan Mishchenko committed
579
        // assign the cost
Alan Mishchenko committed
580
        pCut->Cost = Csw_CutFindCost( p, pCut );
Alan Mishchenko committed
581 582 583
        assert( pCut->nFanins > 0 );
        assert( pCut->Cost > 0 );
    }
Alan Mishchenko committed
584
    p->nNodesTried++;
Alan Mishchenko committed
585

Alan Mishchenko committed
586
    // load the resulting cuts into the table
587
clk = Abc_Clock();
Alan Mishchenko committed
588
    Csw_ObjForEachCut( p, pObj, pCut, i )
Alan Mishchenko committed
589
    {
Alan Mishchenko committed
590 591 592 593 594
        if ( pCut->nFanins > 2 )
        {
            assert( pCut->Cost > 0 );
            Csw_TableCutInsert( p, pCut );
        }
Alan Mishchenko committed
595
    }
596
p->timeHash += Abc_Clock() - clk;
Alan Mishchenko committed
597 598 599

    // return the node if could not replace it
    return pObj;
Alan Mishchenko committed
600 601 602 603 604 605 606
}

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


607 608
ABC_NAMESPACE_IMPL_END