abcMulti.c 20.2 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
/**CFile****************************************************************

  FileName    [abcMulti.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Network and node package.]

  Synopsis    [Procedures which transform an AIG into multi-input AND-graph.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

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

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

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

21 22
#include "base/abc/abc.h"
#include "misc/extra/extraBdd.h"
Alan Mishchenko committed
23

24 25 26
ABC_NAMESPACE_IMPL_START


Alan Mishchenko committed
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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

static void        Abc_NtkMultiInt( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew );
static Abc_Obj_t * Abc_NtkMulti_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld );

static DdNode *    Abc_NtkMultiDeriveBdd_rec( DdManager * dd, Abc_Obj_t * pNodeOld, Vec_Ptr_t * vFanins );
static DdNode *    Abc_NtkMultiDeriveBdd( DdManager * dd, Abc_Obj_t * pNodeOld, Vec_Ptr_t * vFaninsOld );

static void        Abc_NtkMultiSetBounds( Abc_Ntk_t * pNtk, int nThresh, int nFaninMax );
static void        Abc_NtkMultiSetBoundsCnf( Abc_Ntk_t * pNtk );
static void        Abc_NtkMultiSetBoundsMulti( Abc_Ntk_t * pNtk, int nThresh );
static void        Abc_NtkMultiSetBoundsSimple( Abc_Ntk_t * pNtk );
static void        Abc_NtkMultiSetBoundsFactor( Abc_Ntk_t * pNtk );
static void        Abc_NtkMultiCone( Abc_Obj_t * pNode, Vec_Ptr_t * vCone );

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

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

  Synopsis    [Transforms the AIG into nodes.]

  Description [Threhold is the max number of nodes duplicated at a node.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Abc_Ntk_t * Abc_NtkMulti( Abc_Ntk_t * pNtk, int nThresh, int nFaninMax, int fCnf, int fMulti, int fSimple, int fFactor )
{
    Abc_Ntk_t * pNtkNew;

    assert( Abc_NtkIsStrash(pNtk) );
    assert( nThresh >= 0 );
    assert( nFaninMax > 1 );

    // print a warning about choice nodes
    if ( Abc_NtkGetChoiceNum( pNtk ) )
        printf( "Warning: The choice nodes in the AIG are removed by renoding.\n" );

    // define the boundary
    if ( fCnf )
        Abc_NtkMultiSetBoundsCnf( pNtk );
    else if ( fMulti )
        Abc_NtkMultiSetBoundsMulti( pNtk, nThresh );
    else if ( fSimple )
        Abc_NtkMultiSetBoundsSimple( pNtk );
    else if ( fFactor )
        Abc_NtkMultiSetBoundsFactor( pNtk );
    else
        Abc_NtkMultiSetBounds( pNtk, nThresh, nFaninMax );

    // perform renoding for this boundary
    pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD );
    Abc_NtkMultiInt( pNtk, pNtkNew );
    Abc_NtkFinalize( pNtk, pNtkNew );

    // make the network minimum base
    Abc_NtkMinimumBase( pNtkNew );

    // fix the problem with complemented and duplicated CO edges
    Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );

    // report the number of CNF objects
    if ( fCnf )
    {
//        int nClauses = Abc_NtkGetClauseNum(pNtkNew) + 2*Abc_NtkPoNum(pNtkNew) + 2*Abc_NtkLatchNum(pNtkNew);
//        printf( "CNF variables = %d. CNF clauses = %d.\n",  Abc_NtkNodeNum(pNtkNew), nClauses );
    }
//printf( "Maximum fanin = %d.\n", Abc_NtkGetFaninMax(pNtkNew) );

    if ( pNtk->pExdc )
        pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
    // make sure everything is okay
    if ( !Abc_NtkCheck( pNtkNew ) )
    {
        printf( "Abc_NtkMulti: The network check has failed.\n" );
        Abc_NtkDelete( pNtkNew );
        return NULL;
    }
    return pNtkNew;
}

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

  Synopsis    [Transforms the AIG into nodes.]

  Description [Threhold is the max number of nodes duplicated at a node.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Abc_NtkMultiInt( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
{
    ProgressBar * pProgress;
    Abc_Obj_t * pNode, * pConst1, * pNodeNew;
    int i;

    // set the constant node
    pConst1 = Abc_AigConst1(pNtk);
    if ( Abc_ObjFanoutNum(pConst1) > 0 )
    {
        pNodeNew = Abc_NtkCreateNode( pNtkNew );  
136
        pNodeNew->pData = Cudd_ReadOne( (DdManager *)pNtkNew->pManFunc );   Cudd_Ref( (DdNode *)pNodeNew->pData );
Alan Mishchenko committed
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
        pConst1->pCopy = pNodeNew;
    }

    // perform renoding for POs
    pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
    Abc_NtkForEachCo( pNtk, pNode, i )
    {
        Extra_ProgressBarUpdate( pProgress, i, NULL );
        if ( Abc_ObjIsCi(Abc_ObjFanin0(pNode)) )
            continue;
        Abc_NtkMulti_rec( pNtkNew, Abc_ObjFanin0(pNode) );
    }
    Extra_ProgressBarStop( pProgress );

    // clean the boundaries and data field in the old network
    Abc_NtkForEachObj( pNtk, pNode, i )
    {
        pNode->fMarkA = 0;
        pNode->pData = NULL;
    }
}

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

  Synopsis    [Find the best multi-input node rooted at the given node.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Abc_Obj_t * Abc_NtkMulti_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld )
{
    Vec_Ptr_t * vCone;
    Abc_Obj_t * pNodeNew;
    int i;

    assert( !Abc_ObjIsComplement(pNodeOld) );
    // return if the result if known
    if ( pNodeOld->pCopy )
        return pNodeOld->pCopy;
    assert( Abc_ObjIsNode(pNodeOld) );
    assert( !Abc_AigNodeIsConst(pNodeOld) );
    assert( pNodeOld->fMarkA );

//printf( "%d ", Abc_NodeMffcSizeSupp(pNodeOld) );

    // collect the renoding cone
    vCone = Vec_PtrAlloc( 10 );
    Abc_NtkMultiCone( pNodeOld, vCone );

    // create a new node 
    pNodeNew = Abc_NtkCreateNode( pNtkNew ); 
    for ( i = 0; i < vCone->nSize; i++ )
193
        Abc_ObjAddFanin( pNodeNew, Abc_NtkMulti_rec(pNtkNew, (Abc_Obj_t *)vCone->pArray[i]) );
Alan Mishchenko committed
194 195

    // derive the function of this node
196 197
    pNodeNew->pData = Abc_NtkMultiDeriveBdd( (DdManager *)pNtkNew->pManFunc, pNodeOld, vCone );    
    Cudd_Ref( (DdNode *)pNodeNew->pData );
Alan Mishchenko committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
    Vec_PtrFree( vCone );

    // remember the node
    pNodeOld->pCopy = pNodeNew;
    return pNodeOld->pCopy;
}


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

  Synopsis    [Derives the local BDD of the node.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
DdNode * Abc_NtkMultiDeriveBdd( DdManager * dd, Abc_Obj_t * pNodeOld, Vec_Ptr_t * vFaninsOld )
{
    Abc_Obj_t * pFaninOld;
    DdNode * bFunc;
    int i;
    assert( !Abc_AigNodeIsConst(pNodeOld) );
    assert( Abc_ObjIsNode(pNodeOld) );
    // set the elementary BDD variables for the input nodes
    for ( i = 0; i < vFaninsOld->nSize; i++ )
    {
227 228
        pFaninOld = (Abc_Obj_t *)vFaninsOld->pArray[i];
        pFaninOld->pData = Cudd_bddIthVar( dd, i );    Cudd_Ref( (DdNode *)pFaninOld->pData );
Alan Mishchenko committed
229 230 231 232 233 234 235
        pFaninOld->fMarkC = 1;
    }
    // call the recursive BDD computation
    bFunc = Abc_NtkMultiDeriveBdd_rec( dd, pNodeOld, vFaninsOld );  Cudd_Ref( bFunc );
    // dereference the intermediate nodes
    for ( i = 0; i < vFaninsOld->nSize; i++ )
    {
236 237
        pFaninOld = (Abc_Obj_t *)vFaninsOld->pArray[i];
        Cudd_RecursiveDeref( dd, (DdNode *)pFaninOld->pData );
Alan Mishchenko committed
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
        pFaninOld->fMarkC = 0;
    }
    Cudd_Deref( bFunc );
    return bFunc;
}

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

  Synopsis    [Derives the local BDD of the node.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
DdNode * Abc_NtkMultiDeriveBdd_rec( DdManager * dd, Abc_Obj_t * pNode, Vec_Ptr_t * vFanins )
{
    DdNode * bFunc, * bFunc0, * bFunc1;
    assert( !Abc_ObjIsComplement(pNode) );
    // if the result is available return
    if ( pNode->fMarkC )
    {
        assert( pNode->pData ); // network has a cycle
263
        return (DdNode *)pNode->pData;
Alan Mishchenko committed
264 265 266 267 268 269 270
    }
    // mark the node as visited
    pNode->fMarkC = 1;
    Vec_PtrPush( vFanins, pNode );
    // compute the result for both branches
    bFunc0 = Abc_NtkMultiDeriveBdd_rec( dd, Abc_ObjFanin(pNode,0), vFanins ); Cudd_Ref( bFunc0 );
    bFunc1 = Abc_NtkMultiDeriveBdd_rec( dd, Abc_ObjFanin(pNode,1), vFanins ); Cudd_Ref( bFunc1 );
271 272
    bFunc0 = Cudd_NotCond( bFunc0, (long)Abc_ObjFaninC0(pNode) );
    bFunc1 = Cudd_NotCond( bFunc1, (long)Abc_ObjFaninC1(pNode) );
Alan Mishchenko committed
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 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 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 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 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 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 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 567 568 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 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 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
    // get the final result
    bFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 );   Cudd_Ref( bFunc );
    Cudd_RecursiveDeref( dd, bFunc0 );
    Cudd_RecursiveDeref( dd, bFunc1 );
    // set the result
    pNode->pData = bFunc;
    assert( pNode->pData );
    return bFunc;
}



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

  Synopsis    [Limits the cones to be no more than the given size.]

  Description [Returns 1 if the last cone was limited. Returns 0 if no changes.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int Abc_NtkMultiLimit_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vCone, int nFaninMax, int fCanStop, int fFirst )
{
    int nNodes0, nNodes1;
    assert( !Abc_ObjIsComplement(pNode) );
    // check if the node should be added to the fanins
    if ( !fFirst && (pNode->fMarkA || !Abc_ObjIsNode(pNode)) )
    {
        Vec_PtrPushUnique( vCone, pNode );
        return 0;
    }
    // if we cannot stop in this branch, collect all nodes
    if ( !fCanStop )
    {
        Abc_NtkMultiLimit_rec( Abc_ObjFanin(pNode,0), vCone, nFaninMax, 0, 0 );
        Abc_NtkMultiLimit_rec( Abc_ObjFanin(pNode,1), vCone, nFaninMax, 0, 0 );
        return 0;
    }
    // if we can stop, try the left branch first, and return if we stopped
    assert( vCone->nSize == 0 );
    if ( Abc_NtkMultiLimit_rec( Abc_ObjFanin(pNode,0), vCone, nFaninMax, 1, 0 ) )
        return 1;
    // save the number of nodes in the left branch and call for the right branch
    nNodes0 = vCone->nSize;
    assert( nNodes0 <= nFaninMax );
    Abc_NtkMultiLimit_rec( Abc_ObjFanin(pNode,1), vCone, nFaninMax, 0, 0 );
    // check the number of nodes
    if ( vCone->nSize <= nFaninMax )
        return 0;
    // the number of nodes exceeds the limit

    // get the number of nodes in the right branch
    vCone->nSize = 0;
    Abc_NtkMultiLimit_rec( Abc_ObjFanin(pNode,1), vCone, nFaninMax, 0, 0 );
    // if this number exceeds the limit, solve the problem for this branch
    if ( vCone->nSize > nFaninMax )
    {
        int RetValue;
        vCone->nSize = 0;
        RetValue = Abc_NtkMultiLimit_rec( Abc_ObjFanin(pNode,1), vCone, nFaninMax, 1, 0 );
        assert( RetValue == 1 );
        return 1;
    }

    nNodes1 = vCone->nSize; 
    assert( nNodes1 <= nFaninMax );
    if ( nNodes0 >= nNodes1 )
    { // the left branch is larger - cut it
        assert( Abc_ObjFanin(pNode,0)->fMarkA == 0 );
        Abc_ObjFanin(pNode,0)->fMarkA = 1;
    }
    else
    { // the right branch is larger - cut it
        assert( Abc_ObjFanin(pNode,1)->fMarkA == 0 );
        Abc_ObjFanin(pNode,1)->fMarkA = 1;
    }
    return 1;
}

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

  Synopsis    [Limits the cones to be no more than the given size.]

  Description [Returns 1 if the last cone was limited. Returns 0 if no changes.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int Abc_NtkMultiLimit( Abc_Obj_t * pNode, Vec_Ptr_t * vCone, int nFaninMax )
{
    vCone->nSize = 0;
    return Abc_NtkMultiLimit_rec( pNode, vCone, nFaninMax, 1, 1 );
}

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

  Synopsis    [Sets the expansion boundary for multi-input nodes.]

  Description [The boundary includes the set of PIs and all nodes such that 
  when expanding over the node we duplicate no more than nThresh nodes.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Abc_NtkMultiSetBounds( Abc_Ntk_t * pNtk, int nThresh, int nFaninMax )
{
    Vec_Ptr_t * vCone = Vec_PtrAlloc(10);
    Abc_Obj_t * pNode;
    int i, nFanouts, nConeSize;

    // make sure the mark is not set
    Abc_NtkForEachObj( pNtk, pNode, i )
        assert( pNode->fMarkA == 0 );

    // mark the nodes where expansion stops using pNode->fMarkA
    Abc_NtkForEachNode( pNtk, pNode, i )
    {
        // skip PI/PO nodes
//        if ( Abc_NodeIsConst(pNode) )
//            continue;
        // mark the nodes with multiple fanouts
        nFanouts = Abc_ObjFanoutNum(pNode);
        nConeSize = Abc_NodeMffcSize(pNode);
        if ( (nFanouts - 1) * nConeSize > nThresh )
            pNode->fMarkA = 1;
    }

    // mark the PO drivers
    Abc_NtkForEachCo( pNtk, pNode, i )
        Abc_ObjFanin0(pNode)->fMarkA = 1;

    // make sure the fanin limit is met
    Abc_NtkForEachNode( pNtk, pNode, i )
    {
        // skip PI/PO nodes
//        if ( Abc_NodeIsConst(pNode) )
//            continue;
        if ( pNode->fMarkA == 0 )
            continue;
        // continue cutting branches until it meets the fanin limit
        while ( Abc_NtkMultiLimit(pNode, vCone, nFaninMax) );
        assert( vCone->nSize <= nFaninMax );  
    }
    Vec_PtrFree(vCone);
/*
    // make sure the fanin limit is met
    Abc_NtkForEachNode( pNtk, pNode, i )
    {
        // skip PI/PO nodes
//        if ( Abc_NodeIsConst(pNode) )
//            continue;
        if ( pNode->fMarkA == 0 )
            continue;
        Abc_NtkMultiCone( pNode, vCone );
        assert( vCone->nSize <= nFaninMax );    
    }
*/
}

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

  Synopsis    [Sets the expansion boundary for conversion into CNF.]

  Description [The boundary includes the set of PIs, the roots of MUXes,
  the nodes with multiple fanouts and the nodes with complemented outputs.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Abc_NtkMultiSetBoundsCnf( Abc_Ntk_t * pNtk )
{
    Abc_Obj_t * pNode;
    int i, nMuxes;

    // make sure the mark is not set
    Abc_NtkForEachObj( pNtk, pNode, i )
        assert( pNode->fMarkA == 0 );

    // mark the nodes where expansion stops using pNode->fMarkA
    Abc_NtkForEachNode( pNtk, pNode, i )
    {
        // skip PI/PO nodes
//        if ( Abc_NodeIsConst(pNode) )
//            continue;
        // mark the nodes with multiple fanouts
        if ( Abc_ObjFanoutNum(pNode) > 1 )
            pNode->fMarkA = 1;
        // mark the nodes that are roots of MUXes
        if ( Abc_NodeIsMuxType( pNode ) )
        {
            pNode->fMarkA = 1;
            Abc_ObjFanin0( Abc_ObjFanin0(pNode) )->fMarkA = 1;
            Abc_ObjFanin0( Abc_ObjFanin1(pNode) )->fMarkA = 1;
            Abc_ObjFanin1( Abc_ObjFanin0(pNode) )->fMarkA = 1;
            Abc_ObjFanin1( Abc_ObjFanin1(pNode) )->fMarkA = 1;
        }
        else  // mark the complemented edges
        {
            if ( Abc_ObjFaninC0(pNode) )
                Abc_ObjFanin0(pNode)->fMarkA = 1;
            if ( Abc_ObjFaninC1(pNode) )
                Abc_ObjFanin1(pNode)->fMarkA = 1;
        }
    }

    // mark the PO drivers
    Abc_NtkForEachCo( pNtk, pNode, i )
        Abc_ObjFanin0(pNode)->fMarkA = 1;

    // count the number of MUXes
    nMuxes = 0;
    Abc_NtkForEachNode( pNtk, pNode, i )
    {
        // skip PI/PO nodes
//        if ( Abc_NodeIsConst(pNode) )
//            continue;
        if ( Abc_NodeIsMuxType(pNode) && 
            Abc_ObjFanin0(pNode)->fMarkA == 0 &&
            Abc_ObjFanin1(pNode)->fMarkA == 0 )
            nMuxes++;
    }
//    printf( "The number of MUXes detected = %d (%5.2f %% of logic).\n", nMuxes, 300.0*nMuxes/Abc_NtkNodeNum(pNtk) );
} 
 
/**Function*************************************************************

  Synopsis    [Sets the expansion boundary for conversion into multi-input AND graph.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Abc_NtkMultiSetBoundsMulti( Abc_Ntk_t * pNtk, int nThresh )
{
    Abc_Obj_t * pNode;
    int i, nFanouts, nConeSize;

    // make sure the mark is not set
    Abc_NtkForEachObj( pNtk, pNode, i )
        assert( pNode->fMarkA == 0 );

    // mark the nodes where expansion stops using pNode->fMarkA
    Abc_NtkForEachNode( pNtk, pNode, i )
    {
        // skip PI/PO nodes
//        if ( Abc_NodeIsConst(pNode) )
//            continue;
        // mark the nodes with multiple fanouts
//        if ( Abc_ObjFanoutNum(pNode) > 1 )
//            pNode->fMarkA = 1;
        // mark the nodes with multiple fanouts
        nFanouts = Abc_ObjFanoutNum(pNode);
        nConeSize = Abc_NodeMffcSizeStop(pNode);
        if ( (nFanouts - 1) * nConeSize > nThresh )
            pNode->fMarkA = 1;
        // mark the children if they are pointed by the complemented edges
        if ( Abc_ObjFaninC0(pNode) )
            Abc_ObjFanin0(pNode)->fMarkA = 1;
        if ( Abc_ObjFaninC1(pNode) )
            Abc_ObjFanin1(pNode)->fMarkA = 1;
    }

    // mark the PO drivers
    Abc_NtkForEachCo( pNtk, pNode, i )
        Abc_ObjFanin0(pNode)->fMarkA = 1;
}

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

  Synopsis    [Sets a simple boundary.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Abc_NtkMultiSetBoundsSimple( Abc_Ntk_t * pNtk )
{
    Abc_Obj_t * pNode;
    int i;
    // make sure the mark is not set
    Abc_NtkForEachObj( pNtk, pNode, i )
        assert( pNode->fMarkA == 0 );
    // mark the nodes where expansion stops using pNode->fMarkA
    Abc_NtkForEachNode( pNtk, pNode, i )
        pNode->fMarkA = 1;
}

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

  Synopsis    [Sets a factor-cut boundary.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Abc_NtkMultiSetBoundsFactor( Abc_Ntk_t * pNtk )
{
    Abc_Obj_t * pNode;
    int i;
    // make sure the mark is not set
    Abc_NtkForEachObj( pNtk, pNode, i )
        assert( pNode->fMarkA == 0 );
    // mark the nodes where expansion stops using pNode->fMarkA
    Abc_NtkForEachNode( pNtk, pNode, i )
        pNode->fMarkA = (pNode->vFanouts.nSize > 1 && !Abc_NodeIsMuxControlType(pNode));
    // mark the PO drivers
    Abc_NtkForEachCo( pNtk, pNode, i )
        Abc_ObjFanin0(pNode)->fMarkA = 1;
}

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

  Synopsis    [Collects the fanins of a large node.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Abc_NtkMultiCone_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vCone )
{
    assert( !Abc_ObjIsComplement(pNode) );
    if ( pNode->fMarkA || !Abc_ObjIsNode(pNode) )
    {
        Vec_PtrPushUnique( vCone, pNode );
        return;
    }
    Abc_NtkMultiCone_rec( Abc_ObjFanin(pNode,0), vCone );
    Abc_NtkMultiCone_rec( Abc_ObjFanin(pNode,1), vCone );
}

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

  Synopsis    [Collects the fanins of a large node.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Abc_NtkMultiCone( Abc_Obj_t * pNode, Vec_Ptr_t * vCone )
{
    assert( !Abc_ObjIsComplement(pNode) );
    assert( Abc_ObjIsNode(pNode) );
    vCone->nSize = 0;
    Abc_NtkMultiCone_rec( Abc_ObjFanin(pNode,0), vCone );
    Abc_NtkMultiCone_rec( Abc_ObjFanin(pNode,1), vCone );
}

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


648 649
ABC_NAMESPACE_IMPL_END