src/opt/dec/decUtil.c File Reference

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

Go to the source code of this file.

Functions

DdNodeDec_GraphDeriveBdd (DdManager *dd, Dec_Graph_t *pGraph)
unsigned Dec_GraphDeriveTruth (Dec_Graph_t *pGraph)

Function Documentation

DdNode* Dec_GraphDeriveBdd ( DdManager dd,
Dec_Graph_t pGraph 
)

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

FileName [decUtil.c]

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

Synopsis [Decomposition unitilies.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Converts graph to BDD.]

Description []

SideEffects []

SeeAlso []

Definition at line 41 of file decUtil.c.

00042 {
00043     DdNode * bFunc, * bFunc0, * bFunc1;
00044     Dec_Node_t * pNode;
00045     int i;
00046 
00047     // sanity checks
00048     assert( Dec_GraphLeaveNum(pGraph) >= 0 );
00049     assert( Dec_GraphLeaveNum(pGraph) <= pGraph->nSize );
00050 
00051     // check for constant function
00052     if ( Dec_GraphIsConst(pGraph) )
00053         return Cudd_NotCond( b1, Dec_GraphIsComplement(pGraph) );
00054     // check for a literal
00055     if ( Dec_GraphIsVar(pGraph) )
00056         return Cudd_NotCond( Cudd_bddIthVar(dd, Dec_GraphVarInt(pGraph)), Dec_GraphIsComplement(pGraph) );
00057 
00058     // assign the elementary variables
00059     Dec_GraphForEachLeaf( pGraph, pNode, i )
00060         pNode->pFunc = Cudd_bddIthVar( dd, i );
00061 
00062     // compute the function for each internal node
00063     Dec_GraphForEachNode( pGraph, pNode, i )
00064     {
00065         bFunc0 = Cudd_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); 
00066         bFunc1 = Cudd_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); 
00067         pNode->pFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 );   Cudd_Ref( pNode->pFunc );
00068     }
00069 
00070     // deref the intermediate results
00071     bFunc = pNode->pFunc;   Cudd_Ref( bFunc );
00072     Dec_GraphForEachNode( pGraph, pNode, i )
00073         Cudd_RecursiveDeref( dd, pNode->pFunc );
00074     Cudd_Deref( bFunc );
00075 
00076     // complement the result if necessary
00077     return Cudd_NotCond( bFunc, Dec_GraphIsComplement(pGraph) );
00078 }

unsigned Dec_GraphDeriveTruth ( Dec_Graph_t pGraph  ) 

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

Synopsis [Derives the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 91 of file decUtil.c.

00092 {
00093     unsigned uTruths[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
00094     unsigned uTruth, uTruth0, uTruth1;
00095     Dec_Node_t * pNode;
00096     int i;
00097 
00098     // sanity checks
00099     assert( Dec_GraphLeaveNum(pGraph) >= 0 );
00100     assert( Dec_GraphLeaveNum(pGraph) <= pGraph->nSize );
00101     assert( Dec_GraphLeaveNum(pGraph) <= 5 );
00102 
00103     // check for constant function
00104     if ( Dec_GraphIsConst(pGraph) )
00105         return Dec_GraphIsComplement(pGraph)? 0 : ~((unsigned)0);
00106     // check for a literal
00107     if ( Dec_GraphIsVar(pGraph) )
00108         return Dec_GraphIsComplement(pGraph)? ~uTruths[Dec_GraphVarInt(pGraph)] : uTruths[Dec_GraphVarInt(pGraph)];
00109 
00110     // assign the elementary variables
00111     Dec_GraphForEachLeaf( pGraph, pNode, i )
00112         pNode->pFunc = (void *)uTruths[i];
00113 
00114     // compute the function for each internal node
00115     Dec_GraphForEachNode( pGraph, pNode, i )
00116     {
00117         uTruth0 = (unsigned)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc;
00118         uTruth1 = (unsigned)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc;
00119         uTruth0 = pNode->eEdge0.fCompl? ~uTruth0 : uTruth0;
00120         uTruth1 = pNode->eEdge1.fCompl? ~uTruth1 : uTruth1;
00121         uTruth = uTruth0 & uTruth1;
00122         pNode->pFunc = (void *)uTruth;
00123     }
00124 
00125     // complement the result if necessary
00126     return Dec_GraphIsComplement(pGraph)? ~uTruth : uTruth;
00127 }


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