1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
/**CFile****************************************************************
FileName [fraigAccess.c]
PackageName [FRAIG: Functionally reduced AND-INV graphs.]
Synopsis [Access APIs for the FRAIG manager and node.]
Author [Alan Mishchenko <alanmi@eecs.berkeley.edu>]
Affiliation [UC Berkeley]
Date [Ver. 2.0. Started - October 1, 2004]
Revision [$Id: fraigApi.c,v 1.2 2005/07/08 01:01:30 alanmi Exp $]
***********************************************************************/
#include "fraigInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Access functions to read the data members of the manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Fraig_NodeVec_t * Fraig_ManReadVecInputs( Fraig_Man_t * p ) { return p->vInputs; }
Fraig_NodeVec_t * Fraig_ManReadVecOutputs( Fraig_Man_t * p ) { return p->vOutputs; }
Fraig_NodeVec_t * Fraig_ManReadVecNodes( Fraig_Man_t * p ) { return p->vNodes; }
Fraig_Node_t ** Fraig_ManReadInputs ( Fraig_Man_t * p ) { return p->vInputs->pArray; }
Fraig_Node_t ** Fraig_ManReadOutputs( Fraig_Man_t * p ) { return p->vOutputs->pArray; }
Fraig_Node_t ** Fraig_ManReadNodes( Fraig_Man_t * p ) { return p->vNodes->pArray; }
int Fraig_ManReadInputNum ( Fraig_Man_t * p ) { return p->vInputs->nSize; }
int Fraig_ManReadOutputNum( Fraig_Man_t * p ) { return p->vOutputs->nSize; }
int Fraig_ManReadNodeNum( Fraig_Man_t * p ) { return p->vNodes->nSize; }
Fraig_Node_t * Fraig_ManReadConst1 ( Fraig_Man_t * p ) { return p->pConst1; }
Fraig_Node_t * Fraig_ManReadIthNode( Fraig_Man_t * p, int i ) { assert ( i < p->vNodes->nSize ); return p->vNodes->pArray[i]; }
char ** Fraig_ManReadInputNames( Fraig_Man_t * p ) { return p->ppInputNames; }
char ** Fraig_ManReadOutputNames( Fraig_Man_t * p ) { return p->ppOutputNames; }
char * Fraig_ManReadVarsInt( Fraig_Man_t * p ) { return (char *)p->vVarsInt; }
char * Fraig_ManReadSat( Fraig_Man_t * p ) { return (char *)p->pSat; }
int Fraig_ManReadFuncRed( Fraig_Man_t * p ) { return p->fFuncRed; }
int Fraig_ManReadFeedBack( Fraig_Man_t * p ) { return p->fFeedBack; }
int Fraig_ManReadDoSparse( Fraig_Man_t * p ) { return p->fDoSparse; }
int Fraig_ManReadChoicing( Fraig_Man_t * p ) { return p->fChoicing; }
int Fraig_ManReadVerbose( Fraig_Man_t * p ) { return p->fVerbose; }
/**Function*************************************************************
Synopsis [Access functions to set the data members of the manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Fraig_ManSetFuncRed( Fraig_Man_t * p, int fFuncRed ) { p->fFuncRed = fFuncRed; }
void Fraig_ManSetFeedBack( Fraig_Man_t * p, int fFeedBack ) { p->fFeedBack = fFeedBack; }
void Fraig_ManSetDoSparse( Fraig_Man_t * p, int fDoSparse ) { p->fDoSparse = fDoSparse; }
void Fraig_ManSetChoicing( Fraig_Man_t * p, int fChoicing ) { p->fChoicing = fChoicing; }
void Fraig_ManSetTryProve( Fraig_Man_t * p, int fTryProve ) { p->fTryProve = fTryProve; }
void Fraig_ManSetVerbose( Fraig_Man_t * p, int fVerbose ) { p->fVerbose = fVerbose; }
void Fraig_ManSetTimeToGraph( Fraig_Man_t * p, int Time ) { p->timeToAig = Time; }
void Fraig_ManSetTimeToNet( Fraig_Man_t * p, int Time ) { p->timeToNet = Time; }
void Fraig_ManSetTimeTotal( Fraig_Man_t * p, int Time ) { p->timeTotal = Time; }
void Fraig_ManSetOutputNames( Fraig_Man_t * p, char ** ppNames ) { p->ppOutputNames = ppNames; }
void Fraig_ManSetInputNames( Fraig_Man_t * p, char ** ppNames ) { p->ppInputNames = ppNames; }
/**Function*************************************************************
Synopsis [Access functions to read the data members of the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Fraig_Node_t * Fraig_NodeReadData0( Fraig_Node_t * p ) { return p->pData0; }
Fraig_Node_t * Fraig_NodeReadData1( Fraig_Node_t * p ) { return p->pData1; }
int Fraig_NodeReadNum( Fraig_Node_t * p ) { return p->Num; }
Fraig_Node_t * Fraig_NodeReadOne( Fraig_Node_t * p ) { assert (!Fraig_IsComplement(p)); return p->p1; }
Fraig_Node_t * Fraig_NodeReadTwo( Fraig_Node_t * p ) { assert (!Fraig_IsComplement(p)); return p->p2; }
Fraig_Node_t * Fraig_NodeReadNextE( Fraig_Node_t * p ) { return p->pNextE; }
Fraig_Node_t * Fraig_NodeReadRepr( Fraig_Node_t * p ) { return p->pRepr; }
int Fraig_NodeReadNumRefs( Fraig_Node_t * p ) { return p->nRefs; }
int Fraig_NodeReadNumFanouts( Fraig_Node_t * p ) { return p->nFanouts; }
int Fraig_NodeReadSimInv( Fraig_Node_t * p ) { return p->fInv; }
int Fraig_NodeReadNumOnes( Fraig_Node_t * p ) { return p->nOnes; }
/**Function*************************************************************
Synopsis [Access functions to set the data members of the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Fraig_NodeSetData0( Fraig_Node_t * p, Fraig_Node_t * pData ) { p->pData0 = pData; }
void Fraig_NodeSetData1( Fraig_Node_t * p, Fraig_Node_t * pData ) { p->pData1 = pData; }
/**Function*************************************************************
Synopsis [Checks the type of the node.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Fraig_NodeIsConst( Fraig_Node_t * p ) { return (Fraig_Regular(p))->Num == 0; }
int Fraig_NodeIsVar( Fraig_Node_t * p ) { return (Fraig_Regular(p))->NumPi >= 0; }
int Fraig_NodeIsAnd( Fraig_Node_t * p ) { return (Fraig_Regular(p))->NumPi < 0 && (Fraig_Regular(p))->Num > 0; }
int Fraig_NodeComparePhase( Fraig_Node_t * p1, Fraig_Node_t * p2 ) { assert( !Fraig_IsComplement(p1) ); assert( !Fraig_IsComplement(p2) ); return p1->fInv ^ p2->fInv; }
/**Function*************************************************************
Synopsis [Returns a new primary input node.]
Description [If the node with this number does not exist,
create a new PI node with this number.]
SideEffects []
SeeAlso []
***********************************************************************/
Fraig_Node_t * Fraig_ManReadIthVar( Fraig_Man_t * p, int i )
{
int k;
if ( i < 0 )
{
printf( "Requesting a PI with a negative number\n" );
return NULL;
}
// create the PIs to fill in the interval
if ( i >= p->vInputs->nSize )
for ( k = p->vInputs->nSize; k <= i; k++ )
Fraig_NodeCreatePi( p );
return p->vInputs->pArray[i];
}
/**Function*************************************************************
Synopsis [Creates a new node.]
Description [This procedure should be called to create the constant
node and the PI nodes first.]
SideEffects []
SeeAlso []
***********************************************************************/
void Fraig_ManSetPo( Fraig_Man_t * p, Fraig_Node_t * pNode )
{
// assert( pNode->fNodePo == 0 );
// internal node may be a PO two times
pNode->fNodePo = 1;
Fraig_NodeVecPush( p->vOutputs, pNode );
}
/**Function*************************************************************
Synopsis [Perfoms the AND operation with functional hashing.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Fraig_Node_t * Fraig_NodeAnd( Fraig_Man_t * p, Fraig_Node_t * p1, Fraig_Node_t * p2 )
{
return Fraig_NodeAndCanon( p, p1, p2 );
}
/**Function*************************************************************
Synopsis [Perfoms the OR operation with functional hashing.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Fraig_Node_t * Fraig_NodeOr( Fraig_Man_t * p, Fraig_Node_t * p1, Fraig_Node_t * p2 )
{
return Fraig_Not( Fraig_NodeAndCanon( p, Fraig_Not(p1), Fraig_Not(p2) ) );
}
/**Function*************************************************************
Synopsis [Perfoms the EXOR operation with functional hashing.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Fraig_Node_t * Fraig_NodeExor( Fraig_Man_t * p, Fraig_Node_t * p1, Fraig_Node_t * p2 )
{
return Fraig_NodeMux( p, p1, Fraig_Not(p2), p2 );
}
/**Function*************************************************************
Synopsis [Perfoms the MUX operation with functional hashing.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Fraig_Node_t * Fraig_NodeMux( Fraig_Man_t * p, Fraig_Node_t * pC, Fraig_Node_t * pT, Fraig_Node_t * pE )
{
Fraig_Node_t * pAnd1, * pAnd2, * pRes;
pAnd1 = Fraig_NodeAndCanon( p, pC, pT ); Fraig_Ref( pAnd1 );
pAnd2 = Fraig_NodeAndCanon( p, Fraig_Not(pC), pE ); Fraig_Ref( pAnd2 );
pRes = Fraig_NodeOr( p, pAnd1, pAnd2 );
Fraig_RecursiveDeref( p, pAnd1 );
Fraig_RecursiveDeref( p, pAnd2 );
Fraig_Deref( pRes );
return pRes;
}
/**Function*************************************************************
Synopsis [Sets the node to be equivalent to the given one.]
Description [This procedure is a work-around for the equivalence check.
Does not verify the equivalence. Use at the user's risk.]
SideEffects []
SeeAlso []
***********************************************************************/
void Fraig_NodeSetChoice( Fraig_Man_t * pMan, Fraig_Node_t * pNodeOld, Fraig_Node_t * pNodeNew )
{
// assert( pMan->fChoicing );
pNodeNew->pNextE = pNodeOld->pNextE;
pNodeOld->pNextE = pNodeNew;
pNodeNew->pRepr = pNodeOld;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
|