abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaTruth.c File Reference
#include "gia.h"

Go to the source code of this file.

Functions

static wordGla_ObjTruthElem (Gia_Man_t *p, int i)
 
static wordGla_ObjTruthNodeId (Gia_Man_t *p, int Id)
 
static wordGla_ObjTruthNode (Gia_Man_t *p, Gia_Obj_t *pObj)
 
static wordGla_ObjTruthFree1 (Gia_Man_t *p)
 
static wordGla_ObjTruthFree2 (Gia_Man_t *p)
 
static wordGla_ObjTruthConst0 (Gia_Man_t *p, word *pDst)
 
static wordGla_ObjTruthDup (Gia_Man_t *p, word *pDst, word *pSrc, int c)
 
void Gia_ObjComputeTruthTable6Lut_rec (Gia_Man_t *p, int iObj, Vec_Wrd_t *vTemp)
 FUNCTION DEFINITIONS ///. More...
 
word Gia_ObjComputeTruthTable6Lut (Gia_Man_t *p, int iObj, Vec_Wrd_t *vTemp)
 
void Gia_ObjComputeTruthTable6_rec (Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Wrd_t *vTruths)
 
word Gia_ObjComputeTruthTable6 (Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSupp, Vec_Wrd_t *vTruths)
 
void Gia_ObjCollectInternal_rec (Gia_Man_t *p, Gia_Obj_t *pObj)
 
void Gia_ObjCollectInternal (Gia_Man_t *p, Gia_Obj_t *pObj)
 
wordGia_ObjComputeTruthTable (Gia_Man_t *p, Gia_Obj_t *pObj)
 
void Gia_ObjComputeTruthTableTest (Gia_Man_t *p)
 
void Gia_ObjComputeTruthTableStart (Gia_Man_t *p, int nVarsMax)
 
void Gia_ObjComputeTruthTableStop (Gia_Man_t *p)
 
void Gia_ObjCollectInternalCut_rec (Gia_Man_t *p, int iObj)
 
void Gia_ObjCollectInternalCut (Gia_Man_t *p, int iRoot, Vec_Int_t *vLeaves)
 
wordGia_ObjComputeTruthTableCut (Gia_Man_t *p, Gia_Obj_t *pRoot, Vec_Int_t *vLeaves)
 

Variables

static
ABC_NAMESPACE_IMPL_START word 
s_Truth6 [6]
 DECLARATIONS ///. More...
 

Function Documentation

void Gia_ObjCollectInternal ( Gia_Man_t p,
Gia_Obj_t pObj 
)

Definition at line 159 of file giaTruth.c.

160 {
161  Vec_IntClear( p->vTtNodes );
162  Gia_ObjCollectInternal_rec( p, pObj );
163 }
void Gia_ObjCollectInternal_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaTruth.c:147
Vec_Int_t * vTtNodes
Definition: gia.h:185
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
void Gia_ObjCollectInternal_rec ( Gia_Man_t p,
Gia_Obj_t pObj 
)

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

Synopsis [Collects internal nodes reachable from the given node.]

Description []

SideEffects []

SeeAlso []

Definition at line 147 of file giaTruth.c.

148 {
149  if ( !Gia_ObjIsAnd(pObj) )
150  return;
151  if ( pObj->fMark0 )
152  return;
153  pObj->fMark0 = 1;
156  Gia_ObjSetNum( p, pObj, Vec_IntSize(p->vTtNodes) );
157  Vec_IntPush( p->vTtNodes, Gia_ObjId(p, pObj) );
158 }
void Gia_ObjCollectInternal_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaTruth.c:147
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
unsigned fMark0
Definition: gia.h:79
Vec_Int_t * vTtNodes
Definition: gia.h:185
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
static void Gia_ObjSetNum(Gia_Man_t *p, Gia_Obj_t *pObj, int n)
Definition: gia.h:515
void Gia_ObjCollectInternalCut ( Gia_Man_t p,
int  iRoot,
Vec_Int_t vLeaves 
)

Definition at line 324 of file giaTruth.c.

325 {
326  int i, iObj;
327  assert( !Gia_ObjHasNumId(p, iRoot) );
328  assert( Gia_ObjIsAnd(Gia_ManObj(p, iRoot)) );
329  Vec_IntForEachEntry( vLeaves, iObj, i )
330  {
331  assert( !Gia_ObjHasNumId(p, iObj) );
332  Gia_ObjSetNumId( p, iObj, -i );
333  }
334  assert( !Gia_ObjHasNumId(p, iRoot) ); // the root cannot be one of the leaves
335  Vec_IntClear( p->vTtNodes );
336  Vec_IntPush( p->vTtNodes, -1 );
337  Gia_ObjCollectInternalCut_rec( p, iRoot );
338 }
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static int Gia_ObjHasNumId(Gia_Man_t *p, int Id)
Definition: gia.h:511
void Gia_ObjCollectInternalCut_rec(Gia_Man_t *p, int iObj)
Definition: giaTruth.c:314
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static void Gia_ObjSetNumId(Gia_Man_t *p, int Id, int n)
Definition: gia.h:514
Vec_Int_t * vTtNodes
Definition: gia.h:185
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
void Gia_ObjCollectInternalCut_rec ( Gia_Man_t p,
int  iObj 
)

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

Synopsis [Collects internal nodes reachable from the given node.]

Description []

SideEffects []

SeeAlso []

Definition at line 314 of file giaTruth.c.

315 {
316  if ( Gia_ObjHasNumId(p, iObj) )
317  return;
318  assert( Gia_ObjIsAnd(Gia_ManObj(p, iObj)) );
321  Gia_ObjSetNumId( p, iObj, Vec_IntSize(p->vTtNodes) );
322  Vec_IntPush( p->vTtNodes, iObj );
323 }
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static int Gia_ObjHasNumId(Gia_Man_t *p, int Id)
Definition: gia.h:511
void Gia_ObjCollectInternalCut_rec(Gia_Man_t *p, int iObj)
Definition: giaTruth.c:314
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static void Gia_ObjSetNumId(Gia_Man_t *p, int Id, int n)
Definition: gia.h:514
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Vec_Int_t * vTtNodes
Definition: gia.h:185
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
word* Gia_ObjComputeTruthTable ( Gia_Man_t p,
Gia_Obj_t pObj 
)

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

Synopsis [Computing the truth table for GIA object.]

Description [The truth table should be used by the calling application (or saved into the user's storage) before this procedure is called again.]

SideEffects []

SeeAlso []

Definition at line 177 of file giaTruth.c.

178 {
179  Gia_Obj_t * pTemp, * pRoot;
180  word * pTruth, * pTruthL, * pTruth0, * pTruth1;
181  int i;
182  if ( p->vTtMemory == NULL )
183  {
184  p->nTtVars = Gia_ManPiNum( p );
186  p->vTtNums = Vec_IntStart( Gia_ManObjNum(p) + 1000 );
187  p->vTtNodes = Vec_IntAlloc( 256 );
189  p->vTtMemory = Vec_WrdStart( p->nTtWords * 256 );
190  }
191  else
192  {
193  // make sure the number of primary inputs did not change
194  // since the truth table computation storage was prepared
195  assert( p->nTtVars == Gia_ManPiNum(p) );
196  }
197  // extend ID numbers
198  if ( Vec_IntSize(p->vTtNums) < Gia_ManObjNum(p) )
200  // collect internal nodes
201  pRoot = Gia_ObjIsCo(pObj) ? Gia_ObjFanin0(pObj) : pObj;
202  Gia_ObjCollectInternal( p, pRoot );
203  // extend TT storage
204  if ( Vec_WrdSize(p->vTtMemory) < p->nTtWords * (Vec_IntSize(p->vTtNodes) + 2) )
205  Vec_WrdFillExtra( p->vTtMemory, p->nTtWords * (Vec_IntSize(p->vTtNodes) + 2), 0 );
206  // compute the truth table for internal nodes
207  Gia_ManForEachObjVec( p->vTtNodes, p, pTemp, i )
208  {
209  pTemp->fMark0 = 0; // unmark nodes marked by Gia_ObjCollectInternal()
210  pTruth = Gla_ObjTruthNode(p, pTemp);
211  pTruthL = pTruth + p->nTtWords;
214  if ( Gia_ObjFaninC0(pTemp) )
215  {
216  if ( Gia_ObjFaninC1(pTemp) )
217  while ( pTruth < pTruthL )
218  *pTruth++ = ~*pTruth0++ & ~*pTruth1++;
219  else
220  while ( pTruth < pTruthL )
221  *pTruth++ = ~*pTruth0++ & *pTruth1++;
222  }
223  else
224  {
225  if ( Gia_ObjFaninC1(pTemp) )
226  while ( pTruth < pTruthL )
227  *pTruth++ = *pTruth0++ & ~*pTruth1++;
228  else
229  while ( pTruth < pTruthL )
230  *pTruth++ = *pTruth0++ & *pTruth1++;
231  }
232  }
233  // compute the final table
234  if ( Gia_ObjIsConst0(pRoot) )
235  pTruth = Gla_ObjTruthConst0( p, Gla_ObjTruthFree1(p) );
236  else if ( Gia_ObjIsPi(p, pRoot) )
237  pTruth = Gla_ObjTruthElem( p, Gia_ObjCioId(pRoot) );
238  else if ( Gia_ObjIsAnd(pRoot) )
239  pTruth = Gla_ObjTruthNode( p, pRoot );
240  else
241  pTruth = NULL;
242  return Gla_ObjTruthDup( p, Gla_ObjTruthFree2(p), pTruth, Gia_ObjIsCo(pObj) && Gia_ObjFaninC0(pObj) );
243 }
void Gia_ObjCollectInternal(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaTruth.c:159
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static void Vec_IntFillExtra(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:376
static word * Gla_ObjTruthFree1(Gia_Man_t *p)
Definition: giaTruth.c:42
static int Abc_Truth6WordNum(int nVars)
Definition: abc_global.h:257
static int Gia_ObjIsConst0(Gia_Obj_t *pObj)
Definition: gia.h:430
static word * Gla_ObjTruthFree2(Gia_Man_t *p)
Definition: giaTruth.c:43
int nTtWords
Definition: gia.h:183
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
Definition: gia.h:75
static word * Gla_ObjTruthDup(Gia_Man_t *p, word *pDst, word *pSrc, int c)
Definition: giaTruth.c:45
static Vec_Ptr_t * Vec_PtrAllocTruthTables(int nVars)
Definition: vecPtr.h:1065
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static word * Gla_ObjTruthConst0(Gia_Man_t *p, word *pDst)
Definition: giaTruth.c:44
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Vec_Ptr_t * vTtInputs
Definition: gia.h:186
static word * Gla_ObjTruthElem(Gia_Man_t *p, int i)
Definition: giaTruth.c:39
int nTtVars
Definition: gia.h:182
static word * Gla_ObjTruthNode(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaTruth.c:41
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
static Vec_Wrd_t * Vec_WrdStart(int nSize)
Definition: vecWrd.h:103
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
unsigned fMark0
Definition: gia.h:79
Vec_Int_t * vTtNodes
Definition: gia.h:185
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
Vec_Wrd_t * vTtMemory
Definition: gia.h:187
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
static void Vec_WrdFillExtra(Vec_Wrd_t *p, int nSize, word Fill)
Definition: vecWrd.h:509
static int Gia_ObjCioId(Gia_Obj_t *pObj)
Definition: gia.h:411
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ObjIsPi(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:441
Vec_Int_t * vTtNums
Definition: gia.h:184
word Gia_ObjComputeTruthTable6 ( Gia_Man_t p,
Gia_Obj_t pObj,
Vec_Int_t vSupp,
Vec_Wrd_t vTruths 
)

Definition at line 116 of file giaTruth.c.

117 {
118  Gia_Obj_t * pLeaf;
119  int i;
120  assert( Vec_IntSize(vSupp) <= 6 );
121  assert( Gia_ObjIsAnd(pObj) );
122  assert( !pObj->fMark0 );
123  Vec_WrdClear( vTruths );
125  Gia_ManForEachObjVec( vSupp, p, pLeaf, i )
126  {
127  assert( pLeaf->fMark0 || Gia_ObjIsRo(p, pLeaf) );
128  pLeaf->Value = Vec_WrdSize(vTruths);
129  Vec_WrdPush( vTruths, s_Truth6[i] );
130  Gia_ObjSetTravIdCurrent(p, pLeaf);
131  }
132  Gia_ObjComputeTruthTable6_rec( p, pObj, vTruths );
133  return Vec_WrdEntryLast( vTruths );
134 }
void Gia_ObjComputeTruthTable6_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Wrd_t *vTruths)
Definition: giaTruth.c:99
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
Definition: vecWrd.h:618
static word Vec_WrdEntryLast(Vec_Wrd_t *p)
Definition: vecWrd.h:452
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
Definition: gia.h:75
static ABC_NAMESPACE_IMPL_START word s_Truth6[6]
DECLARATIONS ///.
Definition: giaTruth.c:30
static void Vec_WrdClear(Vec_Wrd_t *p)
Definition: vecWrd.h:602
static int Gia_ObjIsRo(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:443
static void Gia_ObjSetTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:531
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
unsigned fMark0
Definition: gia.h:79
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
void Gia_ObjComputeTruthTable6_rec ( Gia_Man_t p,
Gia_Obj_t pObj,
Vec_Wrd_t vTruths 
)

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

Synopsis [Computes truth table up to 6 inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file giaTruth.c.

100 {
101  word uTruth0, uTruth1;
102  if ( Gia_ObjIsTravIdCurrent(p, pObj) )
103  return;
104  Gia_ObjSetTravIdCurrent(p, pObj);
105  assert( !pObj->fMark0 );
106  assert( Gia_ObjIsAnd(pObj) );
107  Gia_ObjComputeTruthTable6_rec( p, Gia_ObjFanin0(pObj), vTruths );
108  Gia_ObjComputeTruthTable6_rec( p, Gia_ObjFanin1(pObj), vTruths );
109  uTruth0 = Vec_WrdEntry( vTruths, Gia_ObjFanin0(pObj)->Value );
110  uTruth0 = Gia_ObjFaninC0(pObj) ? ~uTruth0 : uTruth0;
111  uTruth1 = Vec_WrdEntry( vTruths, Gia_ObjFanin1(pObj)->Value );
112  uTruth1 = Gia_ObjFaninC1(pObj) ? ~uTruth1 : uTruth1;
113  pObj->Value = Vec_WrdSize(vTruths);
114  Vec_WrdPush( vTruths, uTruth0 & uTruth1 );
115 }
void Gia_ObjComputeTruthTable6_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Wrd_t *vTruths)
Definition: giaTruth.c:99
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static int Gia_ObjIsTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:533
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
Definition: vecWrd.h:618
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Gia_ObjSetTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:531
unsigned fMark0
Definition: gia.h:79
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
word Gia_ObjComputeTruthTable6Lut ( Gia_Man_t p,
int  iObj,
Vec_Wrd_t vTemp 
)

Definition at line 76 of file giaTruth.c.

77 {
78  int i, Fanin;
79  assert( Vec_WrdSize(vTemp) == Gia_ManObjNum(p) );
80  assert( Gia_ObjIsLut(p, iObj) );
81  Gia_LutForEachFanin( p, iObj, Fanin, i )
82  Vec_WrdWriteEntry( vTemp, Fanin, s_Truth6[i] );
83  assert( i <= 6 );
84  Gia_ObjComputeTruthTable6Lut_rec( p, iObj, vTemp );
85  return Vec_WrdEntry( vTemp, iObj );
86 }
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
static ABC_NAMESPACE_IMPL_START word s_Truth6[6]
DECLARATIONS ///.
Definition: giaTruth.c:30
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
Definition: vecWrd.h:418
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjIsLut(Gia_Man_t *p, int Id)
Definition: gia.h:952
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition: gia.h:970
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Gia_ObjComputeTruthTable6Lut_rec(Gia_Man_t *p, int iObj, Vec_Wrd_t *vTemp)
FUNCTION DEFINITIONS ///.
Definition: giaTruth.c:62
void Gia_ObjComputeTruthTable6Lut_rec ( Gia_Man_t p,
int  iObj,
Vec_Wrd_t vTemp 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Computes truth table of a 6-LUT.]

Description []

SideEffects []

SeeAlso []

Definition at line 62 of file giaTruth.c.

63 {
64  word uTruth0, uTruth1;
65  Gia_Obj_t * pObj = Gia_ManObj( p, iObj );
66  if ( !Gia_ObjIsAnd(pObj) )
67  return;
70  uTruth0 = Vec_WrdEntry( vTemp, Gia_ObjFanin0(pObj)->Value );
71  uTruth0 = Gia_ObjFaninC0(pObj) ? ~uTruth0 : uTruth0;
72  uTruth1 = Vec_WrdEntry( vTemp, Gia_ObjFanin1(pObj)->Value );
73  uTruth1 = Gia_ObjFaninC1(pObj) ? ~uTruth1 : uTruth1;
74  Vec_WrdWriteEntry( vTemp, iObj, uTruth0 & uTruth1 );
75 }
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static int Gia_ObjFaninId1p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:464
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
Definition: vecWrd.h:418
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
void Gia_ObjComputeTruthTable6Lut_rec(Gia_Man_t *p, int iObj, Vec_Wrd_t *vTemp)
FUNCTION DEFINITIONS ///.
Definition: giaTruth.c:62
word* Gia_ObjComputeTruthTableCut ( Gia_Man_t p,
Gia_Obj_t pRoot,
Vec_Int_t vLeaves 
)

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

Synopsis [Computes the truth table of pRoot in terms of leaves.]

Description [The root cannot be one of the leaves.]

SideEffects []

SeeAlso []

Definition at line 351 of file giaTruth.c.

352 {
353  Gia_Obj_t * pTemp;
354  word * pTruth, * pTruthL, * pTruth0, * pTruth1;
355  int i, iObj, Id0, Id1;
356  assert( p->vTtMemory != NULL );
357  assert( Vec_IntSize(vLeaves) <= p->nTtVars );
358  // extend ID numbers
359  if ( Vec_IntSize(p->vTtNums) < Gia_ManObjNum(p) )
361  // collect internal nodes
362  Gia_ObjCollectInternalCut( p, Gia_ObjId(p, pRoot), vLeaves );
363  // extend TT storage
364  if ( Vec_WrdSize(p->vTtMemory) < p->nTtWords * (Vec_IntSize(p->vTtNodes) + 2) )
365  Vec_WrdFillExtra( p->vTtMemory, p->nTtWords * (Vec_IntSize(p->vTtNodes) + 2), 0 );
366  // compute the truth table for internal nodes
367  Vec_IntForEachEntryStart( p->vTtNodes, iObj, i, 1 )
368  {
369  assert( i == Gia_ObjNumId(p, iObj) );
370  pTemp = Gia_ManObj( p, iObj );
371  pTruth = Gla_ObjTruthNodeId( p, i );
372  pTruthL = pTruth + p->nTtWords;
373  Id0 = Gia_ObjNumId( p, Gia_ObjFaninId0(pTemp, iObj) );
374  Id1 = Gia_ObjNumId( p, Gia_ObjFaninId1(pTemp, iObj) );
375  pTruth0 = (Id0 > 0) ? Gla_ObjTruthNodeId(p, Id0) : Gla_ObjTruthElem(p, -Id0);
376  pTruth1 = (Id1 > 0) ? Gla_ObjTruthNodeId(p, Id1) : Gla_ObjTruthElem(p, -Id1);
377  if ( Gia_ObjFaninC0(pTemp) )
378  {
379  if ( Gia_ObjFaninC1(pTemp) )
380  while ( pTruth < pTruthL )
381  *pTruth++ = ~*pTruth0++ & ~*pTruth1++;
382  else
383  while ( pTruth < pTruthL )
384  *pTruth++ = ~*pTruth0++ & *pTruth1++;
385  }
386  else
387  {
388  if ( Gia_ObjFaninC1(pTemp) )
389  while ( pTruth < pTruthL )
390  *pTruth++ = *pTruth0++ & ~*pTruth1++;
391  else
392  while ( pTruth < pTruthL )
393  *pTruth++ = *pTruth0++ & *pTruth1++;
394  }
395  }
396  pTruth = Gla_ObjTruthNode( p, pRoot );
397  // unmark leaves marked by Gia_ObjCollectInternal()
398  Vec_IntForEachEntry( vLeaves, iObj, i )
399  Gia_ObjResetNumId( p, iObj );
400  Vec_IntForEachEntryStart( p->vTtNodes, iObj, i, 1 )
401  Gia_ObjResetNumId( p, iObj );
402  return pTruth;
403 }
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static void Vec_IntFillExtra(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:376
int nTtWords
Definition: gia.h:183
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static word * Gla_ObjTruthElem(Gia_Man_t *p, int i)
Definition: giaTruth.c:39
static word * Gla_ObjTruthNodeId(Gia_Man_t *p, int Id)
Definition: giaTruth.c:40
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition: vecInt.h:56
int nTtVars
Definition: gia.h:182
static word * Gla_ObjTruthNode(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaTruth.c:41
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Vec_Int_t * vTtNodes
Definition: gia.h:185
static int Gia_ObjNumId(Gia_Man_t *p, int Id)
Definition: gia.h:512
Vec_Wrd_t * vTtMemory
Definition: gia.h:187
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
void Gia_ObjCollectInternalCut(Gia_Man_t *p, int iRoot, Vec_Int_t *vLeaves)
Definition: giaTruth.c:324
#define assert(ex)
Definition: util_old.h:213
static void Gia_ObjResetNumId(Gia_Man_t *p, int Id)
Definition: gia.h:516
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static void Vec_WrdFillExtra(Vec_Wrd_t *p, int nSize, word Fill)
Definition: vecWrd.h:509
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
Vec_Int_t * vTtNums
Definition: gia.h:184
void Gia_ObjComputeTruthTableStart ( Gia_Man_t p,
int  nVarsMax 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 282 of file giaTruth.c.

283 {
284  assert( p->vTtMemory == NULL );
285  p->nTtVars = nVarsMax;
287  p->vTtNodes = Vec_IntAlloc( 256 );
289  p->vTtMemory = Vec_WrdStart( p->nTtWords * 64 );
290  p->vTtNums = Vec_IntAlloc( Gia_ManObjNum(p) + 1000 );
292 }
static int Abc_Truth6WordNum(int nVars)
Definition: abc_global.h:257
int nTtWords
Definition: gia.h:183
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static Vec_Ptr_t * Vec_PtrAllocTruthTables(int nVars)
Definition: vecPtr.h:1065
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Vec_Ptr_t * vTtInputs
Definition: gia.h:186
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static int Vec_IntCap(Vec_Int_t *p)
Definition: vecInt.h:368
int nTtVars
Definition: gia.h:182
static Vec_Wrd_t * Vec_WrdStart(int nSize)
Definition: vecWrd.h:103
Vec_Int_t * vTtNodes
Definition: gia.h:185
Vec_Wrd_t * vTtMemory
Definition: gia.h:187
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
#define assert(ex)
Definition: util_old.h:213
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
Vec_Int_t * vTtNums
Definition: gia.h:184
void Gia_ObjComputeTruthTableStop ( Gia_Man_t p)

Definition at line 293 of file giaTruth.c.

294 {
295  p->nTtVars = 0;
296  p->nTtWords = 0;
297  Vec_IntFreeP( &p->vTtNums );
298  Vec_IntFreeP( &p->vTtNodes );
299  Vec_PtrFreeP( &p->vTtInputs );
300  Vec_WrdFreeP( &p->vTtMemory );
301 }
int nTtWords
Definition: gia.h:183
static void Vec_WrdFreeP(Vec_Wrd_t **p)
Definition: vecWrd.h:277
Vec_Ptr_t * vTtInputs
Definition: gia.h:186
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
int nTtVars
Definition: gia.h:182
Vec_Int_t * vTtNodes
Definition: gia.h:185
static void Vec_PtrFreeP(Vec_Ptr_t **p)
Definition: vecPtr.h:240
Vec_Wrd_t * vTtMemory
Definition: gia.h:187
Vec_Int_t * vTtNums
Definition: gia.h:184
void Gia_ObjComputeTruthTableTest ( Gia_Man_t p)

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

Synopsis [Testing truth table computation.]

Description []

SideEffects []

SeeAlso []

Definition at line 256 of file giaTruth.c.

257 {
258  Gia_Obj_t * pObj;
259  unsigned * pTruth;
260  abctime clk = Abc_Clock();
261  int i;
262  Gia_ManForEachPo( p, pObj, i )
263  {
264  pTruth = (unsigned *)Gia_ObjComputeTruthTable( p, pObj );
265 // Extra_PrintHex( stdout, pTruth, Gia_ManPiNum(p) ); printf( "\n" );
266  }
267  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
268 }
static abctime Abc_Clock()
Definition: abc_global.h:279
Definition: gia.h:75
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
word * Gia_ObjComputeTruthTable(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaTruth.c:177
ABC_INT64_T abctime
Definition: abc_global.h:278
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
static word* Gla_ObjTruthConst0 ( Gia_Man_t p,
word pDst 
)
inlinestatic

Definition at line 44 of file giaTruth.c.

44 { int w; for ( w = 0; w < p->nTtWords; w++ ) pDst[w] = 0; return pDst; }
int nTtWords
Definition: gia.h:183
static word* Gla_ObjTruthDup ( Gia_Man_t p,
word pDst,
word pSrc,
int  c 
)
inlinestatic

Definition at line 45 of file giaTruth.c.

45 { int w; for ( w = 0; w < p->nTtWords; w++ ) pDst[w] = c ? ~pSrc[w] : pSrc[w]; return pDst; }
int nTtWords
Definition: gia.h:183
static word* Gla_ObjTruthElem ( Gia_Man_t p,
int  i 
)
inlinestatic

Definition at line 39 of file giaTruth.c.

39 { return (word *)Vec_PtrEntry( p->vTtInputs, i ); }
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Vec_Ptr_t * vTtInputs
Definition: gia.h:186
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static word* Gla_ObjTruthFree1 ( Gia_Man_t p)
inlinestatic

Definition at line 42 of file giaTruth.c.

42 { return Vec_WrdArray(p->vTtMemory) + Vec_WrdSize(p->vTtMemory) - p->nTtWords * 1; }
int nTtWords
Definition: gia.h:183
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
static word * Vec_WrdArray(Vec_Wrd_t *p)
Definition: vecWrd.h:316
Vec_Wrd_t * vTtMemory
Definition: gia.h:187
static word* Gla_ObjTruthFree2 ( Gia_Man_t p)
inlinestatic

Definition at line 43 of file giaTruth.c.

43 { return Vec_WrdArray(p->vTtMemory) + Vec_WrdSize(p->vTtMemory) - p->nTtWords * 2; }
int nTtWords
Definition: gia.h:183
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
static word * Vec_WrdArray(Vec_Wrd_t *p)
Definition: vecWrd.h:316
Vec_Wrd_t * vTtMemory
Definition: gia.h:187
static word* Gla_ObjTruthNode ( Gia_Man_t p,
Gia_Obj_t pObj 
)
inlinestatic

Definition at line 41 of file giaTruth.c.

41 { return Vec_WrdArray(p->vTtMemory) + p->nTtWords * Gia_ObjNum(p, pObj); }
static int Gia_ObjNum(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:513
int nTtWords
Definition: gia.h:183
static word * Vec_WrdArray(Vec_Wrd_t *p)
Definition: vecWrd.h:316
Vec_Wrd_t * vTtMemory
Definition: gia.h:187
static word* Gla_ObjTruthNodeId ( Gia_Man_t p,
int  Id 
)
inlinestatic

Definition at line 40 of file giaTruth.c.

40 { return Vec_WrdArray(p->vTtMemory) + p->nTtWords * Id; }
int nTtWords
Definition: gia.h:183
static word * Vec_WrdArray(Vec_Wrd_t *p)
Definition: vecWrd.h:316
Vec_Wrd_t * vTtMemory
Definition: gia.h:187

Variable Documentation

ABC_NAMESPACE_IMPL_START word s_Truth6[6]
static
Initial value:
= {
ABC_CONST(0xAAAAAAAAAAAAAAAA),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFFFF0000FFFF0000),
}
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206

DECLARATIONS ///.

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

FileName [giaTruth.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Truth table computation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
giaTruth.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 30 of file giaTruth.c.