src/opt/cut/abcCut.c File Reference

#include "abc.h"
#include "cut.h"
Include dependency graph for abcCut.c:

Go to the source code of this file.

Functions

static void Abc_NtkPrintCuts (void *p, Abc_Ntk_t *pNtk, int fSeq)
static void Abc_NtkPrintCuts_ (void *p, Abc_Ntk_t *pNtk, int fSeq)
Vec_Int_tAbc_NtkGetNodeAttributes (Abc_Ntk_t *pNtk)
Cut_Man_tAbc_NtkCuts (Abc_Ntk_t *pNtk, Cut_Params_t *pParams)
void Abc_NtkCutsOracle (Abc_Ntk_t *pNtk, Cut_Oracle_t *p)
Cut_Man_tAbc_NtkSeqCuts (Abc_Ntk_t *pNtk, Cut_Params_t *pParams)
void * Abc_NodeGetCutsRecursive (void *p, Abc_Obj_t *pObj, int fDag, int fTree)
void * Abc_NodeGetCuts (void *p, Abc_Obj_t *pObj, int fDag, int fTree)
void Abc_NodeGetCutsSeq (void *p, Abc_Obj_t *pObj, int fTriv)
void * Abc_NodeReadCuts (void *p, Abc_Obj_t *pObj)
void Abc_NodeFreeCuts (void *p, Abc_Obj_t *pObj)

Variables

int nTotal
int nGood
int nEqual

Function Documentation

void Abc_NodeFreeCuts ( void *  p,
Abc_Obj_t pObj 
)

Function*************************************************************

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 435 of file abcCut.c.

00436 {
00437     Cut_NodeFreeCuts( p, pObj->Id );
00438 }

void* Abc_NodeGetCuts ( void *  p,
Abc_Obj_t pObj,
int  fDag,
int  fTree 
)

Function*************************************************************

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 341 of file abcCut.c.

00342 {
00343     Abc_Obj_t * pFanin;
00344     int fDagNode, fTriv, TreeCode = 0;
00345 //    assert( Abc_NtkIsStrash(pObj->pNtk) );
00346     assert( Abc_ObjFaninNum(pObj) == 2 );
00347 
00348 
00349     // check if the node is a DAG node
00350     fDagNode = (Abc_ObjFanoutNum(pObj) > 1 && !Abc_NodeIsMuxControlType(pObj));
00351     // increment the counter of DAG nodes
00352     if ( fDagNode ) Cut_ManIncrementDagNodes( p );
00353     // add the trivial cut if the node is a DAG node, or if we compute all cuts
00354     fTriv = fDagNode || !fDag;
00355     // check if fanins are DAG nodes
00356     if ( fTree )
00357     {
00358         pFanin = Abc_ObjFanin0(pObj);
00359         TreeCode |=  (Abc_ObjFanoutNum(pFanin) > 1 && !Abc_NodeIsMuxControlType(pFanin));
00360         pFanin = Abc_ObjFanin1(pObj);
00361         TreeCode |= ((Abc_ObjFanoutNum(pFanin) > 1 && !Abc_NodeIsMuxControlType(pFanin)) << 1);
00362     }
00363 
00364 
00365     // changes due to the global/local cut computation
00366     {
00367         Cut_Params_t * pParams = Cut_ManReadParams(p);
00368         if ( pParams->fLocal )
00369         {
00370             Vec_Int_t * vNodeAttrs = Cut_ManReadNodeAttrs(p);
00371             fDagNode = Vec_IntEntry( vNodeAttrs, pObj->Id );
00372             if ( fDagNode ) Cut_ManIncrementDagNodes( p );
00373 //            fTriv = fDagNode || !pParams->fGlobal;
00374             fTriv = !Vec_IntEntry( vNodeAttrs, pObj->Id );
00375             TreeCode = 0;
00376             pFanin = Abc_ObjFanin0(pObj);
00377             TreeCode |=  Vec_IntEntry( vNodeAttrs, pFanin->Id );
00378             pFanin = Abc_ObjFanin1(pObj);
00379             TreeCode |= (Vec_IntEntry( vNodeAttrs, pFanin->Id ) << 1);
00380         }
00381     }
00382     return Cut_NodeComputeCuts( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),  
00383         Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj), fTriv, TreeCode );  
00384 }

void* Abc_NodeGetCutsRecursive ( void *  p,
Abc_Obj_t pObj,
int  fDag,
int  fTree 
)

Function*************************************************************

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 320 of file abcCut.c.

00321 {
00322     void * pList;
00323     if ( pList = Abc_NodeReadCuts( p, pObj ) )
00324         return pList;
00325     Abc_NodeGetCutsRecursive( p, Abc_ObjFanin0(pObj), fDag, fTree );
00326     Abc_NodeGetCutsRecursive( p, Abc_ObjFanin1(pObj), fDag, fTree );
00327     return Abc_NodeGetCuts( p, pObj, fDag, fTree );
00328 }

void Abc_NodeGetCutsSeq ( void *  p,
Abc_Obj_t pObj,
int  fTriv 
)

Function*************************************************************

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 397 of file abcCut.c.

00398 {
00399     int CutSetNum;
00400     assert( Abc_NtkIsSeq(pObj->pNtk) );
00401     assert( Abc_ObjFaninNum(pObj) == 2 );
00402     fTriv     = pObj->fMarkC ? 0 : fTriv;
00403     CutSetNum = pObj->fMarkC ? (int)pObj->pCopy : -1;
00404     Cut_NodeComputeCutsSeq( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),  
00405         Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj), Seq_ObjFaninL0(pObj), Seq_ObjFaninL1(pObj), fTriv, CutSetNum );  
00406 }

void* Abc_NodeReadCuts ( void *  p,
Abc_Obj_t pObj 
)

Function*************************************************************

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 419 of file abcCut.c.

00420 {
00421     return Cut_NodeReadCutsNew( p, pObj->Id );  
00422 }

Cut_Man_t* Abc_NtkCuts ( Abc_Ntk_t pNtk,
Cut_Params_t pParams 
)

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 69 of file abcCut.c.

00070 {
00071     ProgressBar * pProgress;
00072     Cut_Man_t *  p;
00073     Abc_Obj_t * pObj, * pNode;
00074     Vec_Ptr_t * vNodes;
00075     Vec_Int_t * vChoices;
00076     int i;
00077     int clk = clock();
00078 
00079     extern void Abc_NtkBalanceAttach( Abc_Ntk_t * pNtk );
00080     extern void Abc_NtkBalanceDetach( Abc_Ntk_t * pNtk );
00081 
00082     nTotal = nGood = nEqual = 0;
00083 
00084     assert( Abc_NtkIsStrash(pNtk) );
00085     // start the manager
00086     pParams->nIdsMax = Abc_NtkObjNumMax( pNtk );
00087     p = Cut_ManStart( pParams );
00088     // compute node attributes if local or global cuts are requested
00089     if ( pParams->fGlobal || pParams->fLocal )
00090     {
00091         extern Vec_Int_t * Abc_NtkGetNodeAttributes( Abc_Ntk_t * pNtk );
00092         Cut_ManSetNodeAttrs( p, Abc_NtkGetNodeAttributes(pNtk) );
00093     }
00094     // prepare for cut dropping
00095     if ( pParams->fDrop )
00096         Cut_ManSetFanoutCounts( p, Abc_NtkFanoutCounts(pNtk) );
00097     // set cuts for PIs
00098     Abc_NtkForEachCi( pNtk, pObj, i )
00099         if ( Abc_ObjFanoutNum(pObj) > 0 )
00100             Cut_NodeSetTriv( p, pObj->Id );
00101     // compute cuts for internal nodes
00102     vNodes = Abc_AigDfs( pNtk, 0, 1 ); // collects POs
00103     vChoices = Vec_IntAlloc( 100 );
00104     pProgress = Extra_ProgressBarStart( stdout, Vec_PtrSize(vNodes) );
00105     Vec_PtrForEachEntry( vNodes, pObj, i )
00106     {
00107         // when we reached a CO, it is time to deallocate the cuts
00108         if ( Abc_ObjIsCo(pObj) )
00109         {
00110             if ( pParams->fDrop )
00111                 Cut_NodeTryDroppingCuts( p, Abc_ObjFaninId0(pObj) );
00112             continue;
00113         }
00114         // skip constant node, it has no cuts
00115 //        if ( Abc_NodeIsConst(pObj) )
00116 //            continue;
00117         Extra_ProgressBarUpdate( pProgress, i, NULL );
00118         // compute the cuts to the internal node
00119         Abc_NodeGetCuts( p, pObj, pParams->fDag, pParams->fTree );  
00120         // consider dropping the fanins cuts
00121         if ( pParams->fDrop )
00122         {
00123             Cut_NodeTryDroppingCuts( p, Abc_ObjFaninId0(pObj) );
00124             Cut_NodeTryDroppingCuts( p, Abc_ObjFaninId1(pObj) );
00125         }
00126         // add cuts due to choices
00127         if ( Abc_AigNodeIsChoice(pObj) )
00128         {
00129             Vec_IntClear( vChoices );
00130             for ( pNode = pObj; pNode; pNode = pNode->pData )
00131                 Vec_IntPush( vChoices, pNode->Id );
00132             Cut_NodeUnionCuts( p, vChoices );
00133         }
00134     }
00135     Extra_ProgressBarStop( pProgress );
00136     Vec_PtrFree( vNodes );
00137     Vec_IntFree( vChoices );
00138 PRT( "Total", clock() - clk );
00139 //Abc_NtkPrintCuts( p, pNtk, 0 );
00140 //    Cut_ManPrintStatsToFile( p, pNtk->pSpec, clock() - clk );
00141 
00142     // temporary printout of stats
00143     if ( nTotal )
00144     printf( "Total cuts = %d. Good cuts = %d.  Ratio = %5.2f\n", nTotal, nGood, ((double)nGood)/nTotal );
00145     return p;
00146 }

void Abc_NtkCutsOracle ( Abc_Ntk_t pNtk,
Cut_Oracle_t p 
)

Function*************************************************************

Synopsis [Cut computation using the oracle.]

Description []

SideEffects []

SeeAlso []

Definition at line 159 of file abcCut.c.

00160 {
00161     Abc_Obj_t * pObj;
00162     Vec_Ptr_t * vNodes;
00163     int i, clk = clock();
00164     int fDrop = Cut_OracleReadDrop(p);
00165 
00166     assert( Abc_NtkIsStrash(pNtk) );
00167 
00168     // prepare cut droppping
00169     if ( fDrop )
00170         Cut_OracleSetFanoutCounts( p, Abc_NtkFanoutCounts(pNtk) );
00171 
00172     // set cuts for PIs
00173     Abc_NtkForEachCi( pNtk, pObj, i )
00174         if ( Abc_ObjFanoutNum(pObj) > 0 )
00175             Cut_OracleNodeSetTriv( p, pObj->Id );
00176 
00177     // compute cuts for internal nodes
00178     vNodes = Abc_AigDfs( pNtk, 0, 1 ); // collects POs
00179     Vec_PtrForEachEntry( vNodes, pObj, i )
00180     {
00181         // when we reached a CO, it is time to deallocate the cuts
00182         if ( Abc_ObjIsCo(pObj) )
00183         {
00184             if ( fDrop )
00185                 Cut_OracleTryDroppingCuts( p, Abc_ObjFaninId0(pObj) );
00186             continue;
00187         }
00188         // skip constant node, it has no cuts
00189 //        if ( Abc_NodeIsConst(pObj) )
00190 //            continue;
00191         // compute the cuts to the internal node
00192         Cut_OracleComputeCuts( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),  
00193                 Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
00194         // consider dropping the fanins cuts
00195         if ( fDrop )
00196         {
00197             Cut_OracleTryDroppingCuts( p, Abc_ObjFaninId0(pObj) );
00198             Cut_OracleTryDroppingCuts( p, Abc_ObjFaninId1(pObj) );
00199         }
00200     }
00201     Vec_PtrFree( vNodes );
00202 //PRT( "Total", clock() - clk );
00203 //Abc_NtkPrintCuts_( p, pNtk, 0 );
00204 }

Vec_Int_t* Abc_NtkGetNodeAttributes ( Abc_Ntk_t pNtk  ) 

Definition at line 36 of file abcCut.c.

00037 {
00038     Vec_Int_t * vAttrs = Vec_IntStart( Abc_NtkObjNumMax(pNtk) + 1 );
00039     int i;
00040     Abc_Obj_t * pObj;
00041 
00042 //    Abc_NtkForEachCi( pNtk, pObj, i )
00043 //        Vec_IntWriteEntry( vAttrs, pObj->Id, 1 );
00044 
00045     Abc_NtkForEachObj( pNtk, pObj, i )
00046     {
00047 //        if ( Abc_ObjIsNode(pObj) && (rand() % 4 == 0) )
00048         if ( Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) > 1 && !Abc_NodeIsMuxControlType(pObj) && (rand() % 3 == 0) )
00049             Vec_IntWriteEntry( vAttrs, pObj->Id, 1 );
00050     }
00051     return vAttrs; 
00052 }

void Abc_NtkPrintCuts ( void *  p,
Abc_Ntk_t pNtk,
int  fSeq 
) [static]

CFile****************************************************************

FileName [abcCut.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Interface to cut computation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id
abcCut.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] DECLARATIONS ///

Function*************************************************************

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 451 of file abcCut.c.

00452 {
00453     Cut_Man_t * pMan = p;
00454     Cut_Cut_t * pList;
00455     Abc_Obj_t * pObj;
00456     int i;
00457     printf( "Cuts of the network:\n" );
00458     Abc_NtkForEachObj( pNtk, pObj, i )
00459     {
00460         pList = Abc_NodeReadCuts( p, pObj );
00461         printf( "Node %s:\n", Abc_ObjName(pObj) );
00462         Cut_CutPrintList( pList, fSeq );
00463     }
00464 }

void Abc_NtkPrintCuts_ ( void *  p,
Abc_Ntk_t pNtk,
int  fSeq 
) [static]

Function*************************************************************

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 477 of file abcCut.c.

00478 {
00479     Cut_Man_t * pMan = p;
00480     Cut_Cut_t * pList;
00481     Abc_Obj_t * pObj;
00482     pObj = Abc_NtkObj( pNtk, 2 * Abc_NtkObjNum(pNtk) / 3 );
00483     pList = Abc_NodeReadCuts( p, pObj );
00484     printf( "Node %s:\n", Abc_ObjName(pObj) );
00485     Cut_CutPrintList( pList, fSeq );
00486 }

Cut_Man_t* Abc_NtkSeqCuts ( Abc_Ntk_t pNtk,
Cut_Params_t pParams 
)

Function*************************************************************

Synopsis [Computes the cuts for the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 218 of file abcCut.c.

00219 {
00220 /*
00221     Cut_Man_t *  p;
00222     Abc_Obj_t * pObj, * pNode;
00223     int i, nIters, fStatus;
00224     Vec_Int_t * vChoices;
00225     int clk = clock();
00226 
00227     assert( Abc_NtkIsSeq(pNtk) );
00228     assert( pParams->fSeq );
00229 //    assert( Abc_NtkIsDfsOrdered(pNtk) );
00230 
00231     // start the manager
00232     pParams->nIdsMax = Abc_NtkObjNumMax( pNtk );
00233     pParams->nCutSet = Abc_NtkCutSetNodeNum( pNtk );
00234     p = Cut_ManStart( pParams );
00235 
00236     // set cuts for the constant node and the PIs
00237     pObj = Abc_AigConst1(pNtk);
00238     if ( Abc_ObjFanoutNum(pObj) > 0 )
00239         Cut_NodeSetTriv( p, pObj->Id );
00240     Abc_NtkForEachPi( pNtk, pObj, i )
00241     {
00242 //printf( "Setting trivial cut %d.\n", pObj->Id );
00243         Cut_NodeSetTriv( p, pObj->Id );
00244     }
00245     // label the cutset nodes and set their number in the array
00246     // assign the elementary cuts to the cutset nodes
00247     Abc_SeqForEachCutsetNode( pNtk, pObj, i )
00248     {
00249         assert( pObj->fMarkC == 0 );
00250         pObj->fMarkC = 1;
00251         pObj->pCopy = (Abc_Obj_t *)i;
00252         Cut_NodeSetTriv( p, pObj->Id );
00253 //printf( "Setting trivial cut %d.\n", pObj->Id );
00254     }
00255 
00256     // process the nodes
00257     vChoices = Vec_IntAlloc( 100 );
00258     for ( nIters = 0; nIters < 10; nIters++ )
00259     {
00260 //printf( "ITERATION %d:\n", nIters );
00261         // compute the cuts for the internal nodes
00262         Abc_AigForEachAnd( pNtk, pObj, i )
00263         {
00264             Abc_NodeGetCutsSeq( p, pObj, nIters==0 );
00265             // add cuts due to choices
00266             if ( Abc_AigNodeIsChoice(pObj) )
00267             {
00268                 Vec_IntClear( vChoices );
00269                 for ( pNode = pObj; pNode; pNode = pNode->pData )
00270                     Vec_IntPush( vChoices, pNode->Id );
00271                 Cut_NodeUnionCutsSeq( p, vChoices, (pObj->fMarkC ? (int)pObj->pCopy : -1), nIters==0 );
00272             }
00273         }
00274         // merge the new cuts with the old cuts
00275         Abc_NtkForEachPi( pNtk, pObj, i )
00276             Cut_NodeNewMergeWithOld( p, pObj->Id );
00277         Abc_AigForEachAnd( pNtk, pObj, i )
00278             Cut_NodeNewMergeWithOld( p, pObj->Id );
00279         // for the cutset, transfer temp cuts to new cuts
00280         fStatus = 0;
00281         Abc_SeqForEachCutsetNode( pNtk, pObj, i )
00282             fStatus |= Cut_NodeTempTransferToNew( p, pObj->Id, i );
00283         if ( fStatus == 0 )
00284             break;
00285     }
00286     Vec_IntFree( vChoices );
00287 
00288     // if the status is not finished, transfer new to old for the cutset
00289     Abc_SeqForEachCutsetNode( pNtk, pObj, i )
00290         Cut_NodeNewMergeWithOld( p, pObj->Id );
00291 
00292     // transfer the old cuts to the new positions
00293     Abc_NtkForEachObj( pNtk, pObj, i )
00294         Cut_NodeOldTransferToNew( p, pObj->Id );
00295 
00296     // unlabel the cutset nodes
00297     Abc_SeqForEachCutsetNode( pNtk, pObj, i )
00298         pObj->fMarkC = 0;
00299 if ( pParams->fVerbose )
00300 {
00301 PRT( "Total", clock() - clk );
00302 printf( "Converged after %d iterations.\n", nIters );
00303 }
00304 //Abc_NtkPrintCuts( p, pNtk, 1 );
00305     return p;
00306 */
00307 }


Variable Documentation

int nEqual
int nGood
int nTotal

Generated on Tue Jan 5 12:18:35 2010 for abc70930 by  doxygen 1.6.1