abc/src/base/abci/abcRefactor.c
/**Function*************************************************************

  Synopsis    [Performs incremental resynthesis of the AIG.]

  Description [Starting from each node, computes a reconvergence-driven cut, 
  derives BDD of the cut function, constructs ISOP, factors the ISOP, 
  and replaces the current implementation of the MFFC of the node by the 
  new factored form, if the number of AIG nodes is reduced and the total
  number of levels of the AIG network is not increated. Returns the
  number of AIG nodes saved.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Performs incremental resynthesis of the AIG.]

Description [Starting from each node, computes a reconvergence-driven cut,
derives BDD of the cut function, constructs ISOP, factors the ISOP,
and replaces the current implementation of the MFFC of the node by the
new factored form, if the number of AIG nodes is reduced and the total
number of levels of the AIG network is not increated. Returns the
number of AIG nodes saved.]




Function Synopsis [ Performs incremental resynthesis of the AIG . ] Description [ Starting from each node computes a reconvergence - driven cut derives BDD of the cut function constructs ISOP factors the ISOP and replaces the current implementation of the MFFC of the node by the new factored form if the number of AIG nodes is reduced and the total number of levels of the AIG network is not increated . Returns the number of AIG nodes saved . ]
int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose )
{
    extern void           Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int fUpdateLevel, int nGain );
    ProgressBar * pProgress;
    Abc_ManRef_t * pManRef;
    Abc_ManCut_t * pManCut;
    Dec_Graph_t * pFForm;
    Vec_Ptr_t * vFanins;
    Abc_Obj_t * pNode;
    abctime clk, clkStart = Abc_Clock();
    int i, nNodes;
    assert( Abc_NtkIsStrash(pNtk) );
    Abc_AigCleanup((Abc_Aig_t *)pNtk->pManFunc);
    pManCut = Abc_NtkManCutStart( nNodeSizeMax, nConeSizeMax, 2, 1000 );
    pManRef = Abc_NtkManRefStart( nNodeSizeMax, nConeSizeMax, fUseDcs, fVerbose );
    pManRef->vLeaves   = Abc_NtkManCutReadCutLarge( pManCut );
    if ( fUpdateLevel )
        Abc_NtkStartReverseLevels( pNtk, 0 );
    pManRef->nNodesBeg = Abc_NtkNodeNum(pNtk);
    nNodes = Abc_NtkObjNumMax(pNtk);
    pProgress = Extra_ProgressBarStart( stdout, nNodes );
    Abc_NtkForEachNode( pNtk, pNode, i )
    {
        Extra_ProgressBarUpdate( pProgress, i, NULL );
        if ( Abc_NodeIsPersistant(pNode) )
            continue;
        if ( Abc_ObjFanoutNum(pNode) > 1000 )
            continue;
        if ( i >= nNodes )
            break;
clk = Abc_Clock();
        vFanins = Abc_NodeFindCut( pManCut, pNode, fUseDcs );
pManRef->timeCut += Abc_Clock() - clk;
clk = Abc_Clock();
        pFForm = Abc_NodeRefactor( pManRef, pNode, vFanins, fUpdateLevel, fUseZeros, fUseDcs, fVerbose );
pManRef->timeRes += Abc_Clock() - clk;
        if ( pFForm == NULL )
            continue;
clk = Abc_Clock();
        Dec_GraphUpdateNetwork( pNode, pFForm, fUpdateLevel, pManRef->nLastGain );
pManRef->timeNtk += Abc_Clock() - clk;
        Dec_GraphFree( pFForm );
    }
    Extra_ProgressBarStop( pProgress );
pManRef->timeTotal = Abc_Clock() - clkStart;
    pManRef->nNodesEnd = Abc_NtkNodeNum(pNtk);
    if ( fVerbose )
        Abc_NtkManRefPrintStats( pManRef );
    Abc_NtkManCutStop( pManCut );
    Abc_NtkManRefStop( pManRef );
    Abc_NtkReassignIds( pNtk );
    if ( fUpdateLevel )
        Abc_NtkStopReverseLevels( pNtk );
    else
        Abc_NtkLevel( pNtk );
    if ( !Abc_NtkCheck( pNtk ) )
    {
        printf( "Abc_NtkRefactor: The network check has failed.\n" );
        return 0;
    }
    return 1;
}
int Abc_NtkRefactor ( Abc_Ntk_t * pNtk , int nNodeSizeMax , int nConeSizeMax , int fUpdateLevel , int fUseZeros , int fUseDcs , int fVerbose ) { extern void Dec_GraphUpdateNetwork ( Abc_Obj_t * pRoot , Dec_Graph_t * pGraph , int fUpdateLevel , int nGain ) ; ProgressBar * pProgress ; Abc_ManRef_t * pManRef ; Abc_ManCut_t * pManCut ; Dec_Graph_t * pFForm ; Vec_Ptr_t * vFanins ; Abc_Obj_t * pNode ; abctime clk , clkStart = Abc_Clock ( ) ; int i , nNodes ; assert ( Abc_NtkIsStrash ( pNtk ) ) ; Abc_AigCleanup ( ( Abc_Aig_t * ) pNtk -> pManFunc ) ; pManCut = Abc_NtkManCutStart ( nNodeSizeMax , nConeSizeMax , 2 , 1000 ) ; pManRef = Abc_NtkManRefStart ( nNodeSizeMax , nConeSizeMax , fUseDcs , fVerbose ) ; pManRef -> vLeaves = Abc_NtkManCutReadCutLarge ( pManCut ) ; if ( fUpdateLevel ) Abc_NtkStartReverseLevels ( pNtk , 0 ) ; pManRef -> nNodesBeg = Abc_NtkNodeNum ( pNtk ) ; nNodes = Abc_NtkObjNumMax ( pNtk ) ; pProgress = Extra_ProgressBarStart ( stdout , nNodes ) ; Abc_NtkForEachNode ( pNtk , pNode , i ) { Extra_ProgressBarUpdate ( pProgress , i , NULL ) ; if ( Abc_NodeIsPersistant ( pNode ) ) continue ; if ( Abc_ObjFanoutNum ( pNode ) > 1000 ) continue ; if ( i >= nNodes ) break ; clk = Abc_Clock ( ) ; vFanins = Abc_NodeFindCut ( pManCut , pNode , fUseDcs ) ; pManRef -> timeCut += Abc_Clock ( ) - clk ; clk = Abc_Clock ( ) ; pFForm = Abc_NodeRefactor ( pManRef , pNode , vFanins , fUpdateLevel , fUseZeros , fUseDcs , fVerbose ) ; pManRef -> timeRes += Abc_Clock ( ) - clk ; if ( pFForm == NULL ) continue ; clk = Abc_Clock ( ) ; Dec_GraphUpdateNetwork ( pNode , pFForm , fUpdateLevel , pManRef -> nLastGain ) ; pManRef -> timeNtk += Abc_Clock ( ) - clk ; Dec_GraphFree ( pFForm ) ; } Extra_ProgressBarStop ( pProgress ) ; pManRef -> timeTotal = Abc_Clock ( ) - clkStart ; pManRef -> nNodesEnd = Abc_NtkNodeNum ( pNtk ) ; if ( fVerbose ) Abc_NtkManRefPrintStats ( pManRef ) ; Abc_NtkManCutStop ( pManCut ) ; Abc_NtkManRefStop ( pManRef ) ; Abc_NtkReassignIds ( pNtk ) ; if ( fUpdateLevel ) Abc_NtkStopReverseLevels ( pNtk ) ; else Abc_NtkLevel ( pNtk ) ; if ( ! Abc_NtkCheck ( pNtk ) ) { printf ( " \n " ) ; return 0 ; } return 1 ; }
Function
Synopsis    [Performs incremental resynthesis of the AIG.]
Function Synopsis [ Performs incremental resynthesis of the AIG . ]
// cleanup the AIG // start the managers // compute the reverse levels if level update is requested // resynthesize each node once // skip the constant node //        if ( Abc_NodeIsConst(pNode) ) //            continue; // skip persistant nodes // skip the nodes with many fanouts // stop if all nodes have been tried once // compute a reconvergence-driven cut // evaluate this cut // acceptable replacement found, update the graph // print statistics of the manager // delete the managers // put the nodes into the DFS order and reassign their IDs //    Abc_AigCheckFaninOrder( pNtk->pManFunc ); // fix the levels // check