ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
rwtDec.c
Go to the documentation of this file.
1
20
21#include "rwt.h"
22#include "bool/deco/deco.h"
23
25
26
30
31static Dec_Graph_t * Rwt_NodePreprocess( Rwt_Man_t * p, Rwt_Node_t * pNode );
32static Dec_Edge_t Rwt_TravCollect_rec( Rwt_Man_t * p, Rwt_Node_t * pNode, Dec_Graph_t * pGraph );
33
37
50{
51 Dec_Graph_t * pGraph;
52 Rwt_Node_t * pNode;
53 int i, k;
54 // put the nodes into the structure
55 p->pMapInv = ABC_ALLOC( unsigned short, 222 );
56 memset( p->pMapInv, 0, sizeof(unsigned short) * 222 );
57 p->vClasses = Vec_VecStart( 222 );
58 for ( i = 0; i < p->nFuncs; i++ )
59 {
60 if ( p->pTable[i] == NULL )
61 continue;
62 // consider all implementations of this function
63 for ( pNode = p->pTable[i]; pNode; pNode = pNode->pNext )
64 {
65 assert( pNode->uTruth == p->pTable[i]->uTruth );
66 assert( p->pMap[pNode->uTruth] < 222 ); // Always >= 0 b/c unsigned.
67 Vec_VecPush( p->vClasses, p->pMap[pNode->uTruth], pNode );
68 p->pMapInv[ p->pMap[pNode->uTruth] ] = p->puCanons[pNode->uTruth];
69 }
70 }
71 // compute decomposition forms for each node and verify them
72 Vec_VecForEachEntry( Rwt_Node_t *, p->vClasses, pNode, i, k )
73 {
74 pGraph = Rwt_NodePreprocess( p, pNode );
75 pNode->pNext = (Rwt_Node_t *)pGraph;
76// assert( pNode->uTruth == (Dec_GraphDeriveTruth(pGraph) & 0xFFFF) );
77 }
78}
79
91Dec_Graph_t * Rwt_NodePreprocess( Rwt_Man_t * p, Rwt_Node_t * pNode )
92{
93 Dec_Graph_t * pGraph;
94 Dec_Edge_t eRoot;
95 assert( !Rwt_IsComplement(pNode) );
96 // consider constant
97 if ( pNode->uTruth == 0 )
98 return Dec_GraphCreateConst0();
99 // consider the case of elementary var
100 if ( pNode->uTruth == 0x00FF )
101 return Dec_GraphCreateLeaf( 3, 4, 1 );
102 // start the subgraphs
103 pGraph = Dec_GraphCreate( 4 );
104 // collect the nodes
106 eRoot = Rwt_TravCollect_rec( p, pNode, pGraph );
107 Dec_GraphSetRoot( pGraph, eRoot );
108 return pGraph;
109}
110
122Dec_Edge_t Rwt_TravCollect_rec( Rwt_Man_t * p, Rwt_Node_t * pNode, Dec_Graph_t * pGraph )
123{
124 Dec_Edge_t eNode0, eNode1, eNode;
125 // elementary variable
126 if ( pNode->fUsed )
127 return Dec_EdgeCreate( pNode->Id - 1, 0 );
128 // previously visited node
129 if ( pNode->TravId == p->nTravIds )
130 return Dec_IntToEdge( pNode->Volume );
131 pNode->TravId = p->nTravIds;
132 // solve for children
133 eNode0 = Rwt_TravCollect_rec( p, Rwt_Regular(pNode->p0), pGraph );
134 if ( Rwt_IsComplement(pNode->p0) )
135 eNode0.fCompl = !eNode0.fCompl;
136 eNode1 = Rwt_TravCollect_rec( p, Rwt_Regular(pNode->p1), pGraph );
137 if ( Rwt_IsComplement(pNode->p1) )
138 eNode1.fCompl = !eNode1.fCompl;
139 // create the decomposition node(s)
140 if ( pNode->fExor )
141 eNode = Dec_GraphAddNodeXor( pGraph, eNode0, eNode1, 0 );
142 else
143 eNode = Dec_GraphAddNodeAnd( pGraph, eNode0, eNode1 );
144 // save the result
145 pNode->Volume = Dec_EdgeToInt( eNode );
146 return eNode;
147}
148
152
153
155
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_HEADER_START struct Dec_Edge_t_ Dec_Edge_t
INCLUDES ///.
Definition dec.h:42
struct Dec_Graph_t_ Dec_Graph_t
Definition dec.h:68
Cube * p
Definition exorList.c:222
void Rwt_ManPreprocess(Rwt_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition rwtDec.c:49
struct Rwt_Man_t_ Rwt_Man_t
Definition rwt.h:55
struct Rwt_Node_t_ Rwt_Node_t
Definition rwt.h:56
void Rwt_ManIncTravId(Rwt_Man_t *p)
Definition rwtUtil.c:547
unsigned uTruth
Definition rwt.h:111
int TravId
Definition rwt.h:110
unsigned fUsed
Definition rwt.h:114
unsigned Volume
Definition rwt.h:112
unsigned fExor
Definition rwt.h:115
Rwt_Node_t * pNext
Definition rwt.h:118
Rwt_Node_t * p1
Definition rwt.h:117
Rwt_Node_t * p0
Definition rwt.h:116
int Id
Definition rwt.h:109
#define assert(ex)
Definition util_old.h:213
char * memset()
#define Vec_VecForEachEntry(Type, vGlob, pEntry, i, k)
Definition vecVec.h:87