src/opt/dec/decAbc.c File Reference

#include "abc.h"
#include "dec.h"
#include "ivy.h"
Include dependency graph for decAbc.c:

Go to the source code of this file.

Functions

Abc_Obj_tDec_GraphToNetwork (Abc_Ntk_t *pNtk, Dec_Graph_t *pGraph)
Abc_Obj_tDec_GraphToNetworkNoStrash (Abc_Ntk_t *pNtk, Dec_Graph_t *pGraph)
int Dec_GraphToNetworkCount (Abc_Obj_t *pRoot, Dec_Graph_t *pGraph, int NodeMax, int LevelMax)
void Dec_GraphUpdateNetwork (Abc_Obj_t *pRoot, Dec_Graph_t *pGraph, bool fUpdateLevel, int nGain)
Hop_Obj_tDec_GraphToNetworkAig (Hop_Man_t *pMan, Dec_Graph_t *pGraph)
Hop_Obj_tDec_GraphFactorSop (Hop_Man_t *pMan, char *pSop)
Ivy_Obj_tDec_GraphToNetworkIvy (Ivy_Man_t *pMan, Dec_Graph_t *pGraph)

Function Documentation

Hop_Obj_t* Dec_GraphFactorSop ( Hop_Man_t pMan,
char *  pSop 
)

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

Synopsis [Strashes one logic node using its SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 250 of file decAbc.c.

00251 {
00252     Hop_Obj_t * pFunc;
00253     Dec_Graph_t * pFForm;
00254     Dec_Node_t * pNode;
00255     int i;
00256     // perform factoring
00257     pFForm = Dec_Factor( pSop );
00258     // collect the fanins
00259     Dec_GraphForEachLeaf( pFForm, pNode, i )
00260         pNode->pFunc = Hop_IthVar( pMan, i );
00261     // perform strashing
00262     pFunc = Dec_GraphToNetworkAig( pMan, pFForm );
00263     Dec_GraphFree( pFForm );
00264     return pFunc;
00265 }

Abc_Obj_t* Dec_GraphToNetwork ( Abc_Ntk_t pNtk,
Dec_Graph_t pGraph 
)

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

FileName [decAbc.c]

PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]

Synopsis [Interface between the decomposition package and ABC network.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - February 1, 2003.]

Revision [

Id
decAbc.c,v 1.1 2003/05/22 19:20:05 alanmi Exp

] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Transforms the decomposition graph into the AIG.]

Description [AIG nodes for the fanins should be assigned to pNode->pFunc of the leaves of the graph before calling this procedure.]

SideEffects []

SeeAlso []

Definition at line 43 of file decAbc.c.

00044 {
00045     Abc_Obj_t * pAnd0, * pAnd1;
00046     Dec_Node_t * pNode;
00047     int i;
00048     // check for constant function
00049     if ( Dec_GraphIsConst(pGraph) )
00050         return Abc_ObjNotCond( Abc_AigConst1(pNtk), Dec_GraphIsComplement(pGraph) );
00051     // check for a literal
00052     if ( Dec_GraphIsVar(pGraph) )
00053         return Abc_ObjNotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) );
00054     // build the AIG nodes corresponding to the AND gates of the graph
00055     Dec_GraphForEachNode( pGraph, pNode, i )
00056     {
00057         pAnd0 = Abc_ObjNotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); 
00058         pAnd1 = Abc_ObjNotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); 
00059         pNode->pFunc = Abc_AigAnd( pNtk->pManFunc, pAnd0, pAnd1 );
00060     }
00061     // complement the result if necessary
00062     return Abc_ObjNotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) );
00063 }

Hop_Obj_t* Dec_GraphToNetworkAig ( Hop_Man_t pMan,
Dec_Graph_t pGraph 
)

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

Synopsis [Transforms the decomposition graph into the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 217 of file decAbc.c.

00218 {
00219     Dec_Node_t * pNode;
00220     Hop_Obj_t * pAnd0, * pAnd1;
00221     int i;
00222     // check for constant function
00223     if ( Dec_GraphIsConst(pGraph) )
00224         return Hop_NotCond( Hop_ManConst1(pMan), Dec_GraphIsComplement(pGraph) );
00225     // check for a literal
00226     if ( Dec_GraphIsVar(pGraph) )
00227         return Hop_NotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) );
00228     // build the AIG nodes corresponding to the AND gates of the graph
00229     Dec_GraphForEachNode( pGraph, pNode, i )
00230     {
00231         pAnd0 = Hop_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); 
00232         pAnd1 = Hop_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); 
00233         pNode->pFunc = Hop_And( pMan, pAnd0, pAnd1 );
00234     }
00235     // complement the result if necessary
00236     return Hop_NotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) );
00237 }

int Dec_GraphToNetworkCount ( Abc_Obj_t pRoot,
Dec_Graph_t pGraph,
int  NodeMax,
int  LevelMax 
)

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

Synopsis [Counts the number of new nodes added when using this graph.]

Description [AIG nodes for the fanins should be assigned to pNode->pFunc of the leaves of the graph before calling this procedure. Returns -1 if the number of nodes and levels exceeded the given limit or the number of levels exceeded the maximum allowed level.]

SideEffects []

SeeAlso []

Definition at line 117 of file decAbc.c.

00118 {
00119     Abc_Aig_t * pMan = pRoot->pNtk->pManFunc;
00120     Dec_Node_t * pNode, * pNode0, * pNode1;
00121     Abc_Obj_t * pAnd, * pAnd0, * pAnd1;
00122     int i, Counter, LevelNew, LevelOld;
00123     // check for constant function or a literal
00124     if ( Dec_GraphIsConst(pGraph) || Dec_GraphIsVar(pGraph) )
00125         return 0;
00126     // set the levels of the leaves
00127     Dec_GraphForEachLeaf( pGraph, pNode, i )
00128         pNode->Level = Abc_ObjRegular(pNode->pFunc)->Level;
00129     // compute the AIG size after adding the internal nodes
00130     Counter = 0;
00131     Dec_GraphForEachNode( pGraph, pNode, i )
00132     {
00133         // get the children of this node
00134         pNode0 = Dec_GraphNode( pGraph, pNode->eEdge0.Node );
00135         pNode1 = Dec_GraphNode( pGraph, pNode->eEdge1.Node );
00136         // get the AIG nodes corresponding to the children 
00137         pAnd0 = pNode0->pFunc; 
00138         pAnd1 = pNode1->pFunc; 
00139         if ( pAnd0 && pAnd1 )
00140         {
00141             // if they are both present, find the resulting node
00142             pAnd0 = Abc_ObjNotCond( pAnd0, pNode->eEdge0.fCompl );
00143             pAnd1 = Abc_ObjNotCond( pAnd1, pNode->eEdge1.fCompl );
00144             pAnd  = Abc_AigAndLookup( pMan, pAnd0, pAnd1 );
00145             // return -1 if the node is the same as the original root
00146             if ( Abc_ObjRegular(pAnd) == pRoot )
00147                 return -1;
00148         }
00149         else
00150             pAnd = NULL;
00151         // count the number of added nodes
00152         if ( pAnd == NULL || Abc_NodeIsTravIdCurrent(Abc_ObjRegular(pAnd)) )
00153         {
00154             if ( ++Counter > NodeMax )
00155                 return -1;
00156         }
00157         // count the number of new levels
00158         LevelNew = 1 + ABC_MAX( pNode0->Level, pNode1->Level );
00159         if ( pAnd )
00160         {
00161             if ( Abc_ObjRegular(pAnd) == Abc_AigConst1(pRoot->pNtk) )
00162                 LevelNew = 0;
00163             else if ( Abc_ObjRegular(pAnd) == Abc_ObjRegular(pAnd0) )
00164                 LevelNew = (int)Abc_ObjRegular(pAnd0)->Level;
00165             else if ( Abc_ObjRegular(pAnd) == Abc_ObjRegular(pAnd1) )
00166                 LevelNew = (int)Abc_ObjRegular(pAnd1)->Level;
00167             LevelOld = (int)Abc_ObjRegular(pAnd)->Level;
00168 //            assert( LevelNew == LevelOld );
00169         }
00170         if ( LevelNew > LevelMax )
00171             return -1;
00172         pNode->pFunc = pAnd;
00173         pNode->Level = LevelNew;
00174     }
00175     return Counter;
00176 }

Ivy_Obj_t* Dec_GraphToNetworkIvy ( Ivy_Man_t pMan,
Dec_Graph_t pGraph 
)

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

Synopsis [Transforms the decomposition graph into the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 278 of file decAbc.c.

00279 {
00280     Dec_Node_t * pNode;
00281     Ivy_Obj_t * pAnd0, * pAnd1;
00282     int i;
00283     // check for constant function
00284     if ( Dec_GraphIsConst(pGraph) )
00285         return Ivy_NotCond( Ivy_ManConst1(pMan), Dec_GraphIsComplement(pGraph) );
00286     // check for a literal
00287     if ( Dec_GraphIsVar(pGraph) )
00288         return Ivy_NotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) );
00289     // build the AIG nodes corresponding to the AND gates of the graph
00290     Dec_GraphForEachNode( pGraph, pNode, i )
00291     {
00292         pAnd0 = Ivy_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); 
00293         pAnd1 = Ivy_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); 
00294         pNode->pFunc = Ivy_And( pMan, pAnd0, pAnd1 );
00295     }
00296     // complement the result if necessary
00297     return Ivy_NotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) );
00298 }

Abc_Obj_t* Dec_GraphToNetworkNoStrash ( Abc_Ntk_t pNtk,
Dec_Graph_t pGraph 
)

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

Synopsis [Transforms the decomposition graph into the AIG.]

Description [AIG nodes for the fanins should be assigned to pNode->pFunc of the leaves of the graph before calling this procedure.]

SideEffects []

SeeAlso []

Definition at line 77 of file decAbc.c.

00078 {
00079     Abc_Obj_t * pAnd, * pAnd0, * pAnd1;
00080     Dec_Node_t * pNode;
00081     int i;
00082     // check for constant function
00083     if ( Dec_GraphIsConst(pGraph) )
00084         return Abc_ObjNotCond( Abc_AigConst1(pNtk), Dec_GraphIsComplement(pGraph) );
00085     // check for a literal
00086     if ( Dec_GraphIsVar(pGraph) )
00087         return Abc_ObjNotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) );
00088     // build the AIG nodes corresponding to the AND gates of the graph
00089     Dec_GraphForEachNode( pGraph, pNode, i )
00090     {
00091         pAnd0 = Abc_ObjNotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); 
00092         pAnd1 = Abc_ObjNotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); 
00093 //        pNode->pFunc = Abc_AigAnd( pNtk->pManFunc, pAnd0, pAnd1 );
00094         pAnd = Abc_NtkCreateNode( pNtk );
00095         Abc_ObjAddFanin( pAnd, pAnd0 );
00096         Abc_ObjAddFanin( pAnd, pAnd1 );
00097         pNode->pFunc = pAnd;
00098     }
00099     // complement the result if necessary
00100     return Abc_ObjNotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) );
00101 }

void Dec_GraphUpdateNetwork ( Abc_Obj_t pRoot,
Dec_Graph_t pGraph,
bool  fUpdateLevel,
int  nGain 
)

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

Synopsis [Replaces MFFC of the node by the new factored form.]

Description []

SideEffects []

SeeAlso []

Definition at line 190 of file decAbc.c.

00191 {
00192     Abc_Obj_t * pRootNew;
00193     Abc_Ntk_t * pNtk = pRoot->pNtk;
00194     int nNodesNew, nNodesOld;
00195     nNodesOld = Abc_NtkNodeNum(pNtk);
00196     // create the new structure of nodes
00197     pRootNew = Dec_GraphToNetwork( pNtk, pGraph );
00198     // remove the old nodes
00199     Abc_AigReplace( pNtk->pManFunc, pRoot, pRootNew, fUpdateLevel );
00200     // compare the gains
00201     nNodesNew = Abc_NtkNodeNum(pNtk);
00202     assert( nGain <= nNodesOld - nNodesNew );
00203 }


Generated on Tue Jan 5 12:19:24 2010 for abc70930 by  doxygen 1.6.1