ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
hopTruth.c File Reference
#include "hop.h"
Include dependency graph for hopTruth.c:

Go to the source code of this file.

Functions

int Hop_ManConvertAigToTruth_rec1 (Hop_Obj_t *pObj)
 FUNCTION DEFINITIONS ///.
 
unsigned * Hop_ManConvertAigToTruth_rec2 (Hop_Obj_t *pObj, Vec_Int_t *vTruth, int nWords)
 
unsigned * Hop_ManConvertAigToTruth (Hop_Man_t *p, Hop_Obj_t *pRoot, int nVars, Vec_Int_t *vTruth, int fMsbFirst)
 
word Hop_ManComputeTruth6_rec (Hop_Man_t *p, Hop_Obj_t *pObj)
 
word Hop_ManComputeTruth6 (Hop_Man_t *p, Hop_Obj_t *pObj, int nVars)
 

Function Documentation

◆ Hop_ManComputeTruth6()

word Hop_ManComputeTruth6 ( Hop_Man_t * p,
Hop_Obj_t * pObj,
int nVars )

Definition at line 256 of file hopTruth.c.

257{
258 word Truth;
259 int i;
260 if ( Hop_ObjIsConst1( Hop_Regular(pObj) ) )
261 return Hop_IsComplement(pObj) ? 0 : ~(word)0;
262 for ( i = 0; i < nVars; i++ )
263 Hop_ManPi( p, i )->iData = i;
264 Truth = Hop_ManComputeTruth6_rec( p, Hop_Regular(pObj) );
265 return Hop_IsComplement(pObj) ? ~Truth : Truth;
266}
Cube * p
Definition exorList.c:222
word Hop_ManComputeTruth6_rec(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition hopTruth.c:244
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hop_ManComputeTruth6_rec()

word Hop_ManComputeTruth6_rec ( Hop_Man_t * p,
Hop_Obj_t * pObj )

Definition at line 244 of file hopTruth.c.

245{
246 word Truth0, Truth1;
247 if ( Hop_ObjIsPi(pObj) )
248 return Truth[pObj->iData];
249 assert( Hop_ObjIsNode(pObj) );
250 Truth0 = Hop_ManComputeTruth6_rec( p, Hop_ObjFanin0(pObj) );
251 Truth1 = Hop_ManComputeTruth6_rec( p, Hop_ObjFanin1(pObj) );
252 Truth0 = Hop_ObjFaninC0(pObj) ? ~Truth0 : Truth0;
253 Truth1 = Hop_ObjFaninC1(pObj) ? ~Truth1 : Truth1;
254 return Truth0 & Truth1;
255}
int iData
Definition hop.h:69
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hop_ManConvertAigToTruth()

unsigned * Hop_ManConvertAigToTruth ( Hop_Man_t * p,
Hop_Obj_t * pRoot,
int nVars,
Vec_Int_t * vTruth,
int fMsbFirst )

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

Synopsis [Computes truth table of the node.]

Description [Assumes that the structural support is no more than 8 inputs. Uses array vTruth to store temporary truth tables. The returned pointer should be used immediately.]

SideEffects []

SeeAlso []

Definition at line 143 of file hopTruth.c.

144{
145 static unsigned uTruths[8][8] = { // elementary truth tables
146 { 0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA },
147 { 0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC },
148 { 0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0 },
149 { 0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00 },
150 { 0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000 },
151 { 0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF },
152 { 0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF,0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF },
153 { 0x00000000,0x00000000,0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF }
154 };
155 Hop_Obj_t * pObj;
156 unsigned * pTruth, * pTruth2;
157 int i, nWords, nNodes;
158 Vec_Ptr_t * vTtElems;
159
160 // if the number of variables is more than 8, allocate truth tables
161 if ( nVars > 8 )
162 vTtElems = Vec_PtrAllocTruthTables( nVars );
163 else
164 vTtElems = NULL;
165
166 // clear the data fields and set marks
167 nNodes = Hop_ManConvertAigToTruth_rec1( Hop_Regular(pRoot) );
168 // prepare memory
169 nWords = Hop_TruthWordNum( nVars );
170 Vec_IntClear( vTruth );
171 Vec_IntGrow( vTruth, nWords * (nNodes+1) );
172 pTruth = Vec_IntFetch( vTruth, nWords );
173 // check the case of a constant
174 if ( Hop_ObjIsConst1( Hop_Regular(pRoot) ) )
175 {
176 assert( nNodes == 0 );
177 if ( Hop_IsComplement(pRoot) )
178 Hop_ManTruthClear( pTruth, nVars );
179 else
180 Hop_ManTruthFill( pTruth, nVars );
181 return pTruth;
182 }
183 // set elementary truth tables at the leaves
184 assert( nVars <= Hop_ManPiNum(p) );
185// assert( Hop_ManPiNum(p) <= 8 );
186 if ( fMsbFirst )
187 {
188// Hop_ManForEachPi( p, pObj, i )
189 for ( i = 0; i < nVars; i++ )
190 {
191 pObj = Hop_ManPi( p, i );
192 if ( vTtElems )
193 pObj->pData = Vec_PtrEntry(vTtElems, nVars-1-i);
194 else
195 pObj->pData = (void *)uTruths[nVars-1-i];
196 }
197 }
198 else
199 {
200// Hop_ManForEachPi( p, pObj, i )
201 for ( i = 0; i < nVars; i++ )
202 {
203 pObj = Hop_ManPi( p, i );
204 if ( vTtElems )
205 pObj->pData = Vec_PtrEntry(vTtElems, i);
206 else
207 pObj->pData = (void *)uTruths[i];
208 }
209 }
210 // clear the marks and compute the truth table
211 pTruth2 = Hop_ManConvertAigToTruth_rec2( Hop_Regular(pRoot), vTruth, nWords );
212 // copy the result
213 Hop_ManTruthCopy( pTruth, pTruth2, nVars );
214 if ( Hop_IsComplement(pRoot) )
215 Hop_ManTruthNot( pTruth, pTruth, nVars );
216 if ( vTtElems )
217 Vec_PtrFree( vTtElems );
218 return pTruth;
219}
int nWords
Definition abcNpn.c:127
unsigned * Hop_ManConvertAigToTruth_rec2(Hop_Obj_t *pObj, Vec_Int_t *vTruth, int nWords)
Definition hopTruth.c:97
int Hop_ManConvertAigToTruth_rec1(Hop_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition hopTruth.c:73
struct Hop_Obj_t_ Hop_Obj_t
Definition hop.h:50
void * pData
Definition hop.h:68
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hop_ManConvertAigToTruth_rec1()

int Hop_ManConvertAigToTruth_rec1 ( Hop_Obj_t * pObj)

FUNCTION DEFINITIONS ///.

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

Synopsis [Construct BDDs and mark AIG nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 73 of file hopTruth.c.

74{
75 int Counter = 0;
76 assert( !Hop_IsComplement(pObj) );
77 if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
78 return 0;
79 Counter += Hop_ManConvertAigToTruth_rec1( Hop_ObjFanin0(pObj) );
80 Counter += Hop_ManConvertAigToTruth_rec1( Hop_ObjFanin1(pObj) );
81 assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
82 Hop_ObjSetMarkA( pObj );
83 return Counter + 1;
84}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hop_ManConvertAigToTruth_rec2()

unsigned * Hop_ManConvertAigToTruth_rec2 ( Hop_Obj_t * pObj,
Vec_Int_t * vTruth,
int nWords )

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

Synopsis [Computes truth table of the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file hopTruth.c.

98{
99 unsigned * pTruth, * pTruth0, * pTruth1;
100 int i;
101 assert( !Hop_IsComplement(pObj) );
102 if ( !Hop_ObjIsNode(pObj) || !Hop_ObjIsMarkA(pObj) )
103 return (unsigned *)pObj->pData;
104 // compute the truth tables of the fanins
105 pTruth0 = Hop_ManConvertAigToTruth_rec2( Hop_ObjFanin0(pObj), vTruth, nWords );
106 pTruth1 = Hop_ManConvertAigToTruth_rec2( Hop_ObjFanin1(pObj), vTruth, nWords );
107 // creat the truth table of the node
108 pTruth = Vec_IntFetch( vTruth, nWords );
109 if ( Hop_ObjIsExor(pObj) )
110 for ( i = 0; i < nWords; i++ )
111 pTruth[i] = pTruth0[i] ^ pTruth1[i];
112 else if ( !Hop_ObjFaninC0(pObj) && !Hop_ObjFaninC1(pObj) )
113 for ( i = 0; i < nWords; i++ )
114 pTruth[i] = pTruth0[i] & pTruth1[i];
115 else if ( !Hop_ObjFaninC0(pObj) && Hop_ObjFaninC1(pObj) )
116 for ( i = 0; i < nWords; i++ )
117 pTruth[i] = pTruth0[i] & ~pTruth1[i];
118 else if ( Hop_ObjFaninC0(pObj) && !Hop_ObjFaninC1(pObj) )
119 for ( i = 0; i < nWords; i++ )
120 pTruth[i] = ~pTruth0[i] & pTruth1[i];
121 else // if ( Hop_ObjFaninC0(pObj) && Hop_ObjFaninC1(pObj) )
122 for ( i = 0; i < nWords; i++ )
123 pTruth[i] = ~pTruth0[i] & ~pTruth1[i];
124 assert( Hop_ObjIsMarkA(pObj) ); // loop detection
125 Hop_ObjClearMarkA( pObj );
126 pObj->pData = pTruth;
127 return pTruth;
128}
Here is the call graph for this function:
Here is the caller graph for this function: