ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
decUtil.c
Go to the documentation of this file.
1
18
19#include "base/abc/abc.h"
20#include "dec.h"
21
22#ifdef ABC_USE_CUDD
23#include "bdd/extrab/extraBdd.h"
24#endif
25
27
28
32
36
37#ifdef ABC_USE_CUDD
38
50DdNode * Dec_GraphDeriveBdd( DdManager * dd, Dec_Graph_t * pGraph )
51{
52 DdNode * bFunc, * bFunc0, * bFunc1;
53 Dec_Node_t * pNode = NULL; // Suppress "might be used uninitialized"
54 int i;
55
56 // sanity checks
57 assert( Dec_GraphLeaveNum(pGraph) >= 0 );
58 assert( Dec_GraphLeaveNum(pGraph) <= pGraph->nSize );
59
60 // check for constant function
61 if ( Dec_GraphIsConst(pGraph) )
62 return Cudd_NotCond( b1, Dec_GraphIsComplement(pGraph) );
63 // check for a literal
64 if ( Dec_GraphIsVar(pGraph) )
65 return Cudd_NotCond( Cudd_bddIthVar(dd, Dec_GraphVarInt(pGraph)), Dec_GraphIsComplement(pGraph) );
66
67 // assign the elementary variables
68 Dec_GraphForEachLeaf( pGraph, pNode, i )
69 pNode->pFunc = Cudd_bddIthVar( dd, i );
70
71 // compute the function for each internal node
72 Dec_GraphForEachNode( pGraph, pNode, i )
73 {
74 bFunc0 = Cudd_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
75 bFunc1 = Cudd_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
76 pNode->pFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( (DdNode *)pNode->pFunc );
77 }
78
79 // deref the intermediate results
80 bFunc = (DdNode *)pNode->pFunc; Cudd_Ref( bFunc );
81 Dec_GraphForEachNode( pGraph, pNode, i )
82 Cudd_RecursiveDeref( dd, (DdNode *)pNode->pFunc );
83 Cudd_Deref( bFunc );
84
85 // complement the result if necessary
86 return Cudd_NotCond( bFunc, Dec_GraphIsComplement(pGraph) );
87}
88
89#endif
90
103{
104 unsigned uTruths[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
105 unsigned uTruth = 0; // Suppress "might be used uninitialized"
106 unsigned uTruth0, uTruth1;
107 Dec_Node_t * pNode;
108 int i;
109
110 // sanity checks
111 assert( Dec_GraphLeaveNum(pGraph) >= 0 );
112 assert( Dec_GraphLeaveNum(pGraph) <= pGraph->nSize );
113 assert( Dec_GraphLeaveNum(pGraph) <= 5 );
114
115 // check for constant function
116 if ( Dec_GraphIsConst(pGraph) )
117 return Dec_GraphIsComplement(pGraph)? 0 : ~((unsigned)0);
118 // check for a literal
119 if ( Dec_GraphIsVar(pGraph) )
120 return Dec_GraphIsComplement(pGraph)? ~uTruths[Dec_GraphVarInt(pGraph)] : uTruths[Dec_GraphVarInt(pGraph)];
121
122 // assign the elementary variables
123 Dec_GraphForEachLeaf( pGraph, pNode, i )
124 pNode->pFunc = (void *)(ABC_PTRUINT_T)uTruths[i];
125
126 // compute the function for each internal node
127 Dec_GraphForEachNode( pGraph, pNode, i )
128 {
129 uTruth0 = (unsigned)(ABC_PTRUINT_T)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc;
130 uTruth1 = (unsigned)(ABC_PTRUINT_T)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc;
131 uTruth0 = pNode->eEdge0.fCompl? ~uTruth0 : uTruth0;
132 uTruth1 = pNode->eEdge1.fCompl? ~uTruth1 : uTruth1;
133 uTruth = uTruth0 & uTruth1;
134 pNode->pFunc = (void *)(ABC_PTRUINT_T)uTruth;
135 }
136
137 // complement the result if necessary
138 return Dec_GraphIsComplement(pGraph)? ~uTruth : uTruth;
139}
140
141
145
146
148
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define b1
Definition bbrImage.c:97
ABC_NAMESPACE_IMPL_START unsigned Dec_GraphDeriveTruth(Dec_Graph_t *pGraph)
DECLARATIONS ///.
Definition decUtil.c:102
struct Dec_Node_t_ Dec_Node_t
Definition dec.h:49
#define Dec_GraphForEachLeaf(pGraph, pLeaf, i)
ITERATORS ///.
Definition dec.h:98
#define Dec_GraphForEachNode(pGraph, pAnd, i)
Definition dec.h:101
struct Dec_Graph_t_ Dec_Graph_t
Definition dec.h:68
int nSize
Definition dec.h:73
Dec_Edge_t eEdge1
Definition dec.h:53
void * pFunc
Definition dec.h:56
Dec_Edge_t eEdge0
Definition dec.h:52
#define assert(ex)
Definition util_old.h:213