abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
aigTruth.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [aigTruth.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [AIG package.]
8 
9  Synopsis [Computes truth table for the cut.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - April 28, 2007.]
16 
17  Revision [$Id: aigTruth.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "aig.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Computes truth table of the cut.]
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
45 unsigned * Aig_ManCutTruthOne( Aig_Obj_t * pNode, unsigned * pTruth, int nWords )
46 {
47  unsigned * pTruth0, * pTruth1;
48  int i;
49  pTruth0 = (unsigned *)Aig_ObjFanin0(pNode)->pData;
50  pTruth1 = (unsigned *)Aig_ObjFanin1(pNode)->pData;
51  if ( Aig_ObjIsExor(pNode) )
52  for ( i = 0; i < nWords; i++ )
53  pTruth[i] = pTruth0[i] ^ pTruth1[i];
54  else if ( !Aig_ObjFaninC0(pNode) && !Aig_ObjFaninC1(pNode) )
55  for ( i = 0; i < nWords; i++ )
56  pTruth[i] = pTruth0[i] & pTruth1[i];
57  else if ( !Aig_ObjFaninC0(pNode) && Aig_ObjFaninC1(pNode) )
58  for ( i = 0; i < nWords; i++ )
59  pTruth[i] = pTruth0[i] & ~pTruth1[i];
60  else if ( Aig_ObjFaninC0(pNode) && !Aig_ObjFaninC1(pNode) )
61  for ( i = 0; i < nWords; i++ )
62  pTruth[i] = ~pTruth0[i] & pTruth1[i];
63  else // if ( Aig_ObjFaninC0(pNode) && Aig_ObjFaninC1(pNode) )
64  for ( i = 0; i < nWords; i++ )
65  pTruth[i] = ~pTruth0[i] & ~pTruth1[i];
66  return pTruth;
67 }
68 
69 /**Function*************************************************************
70 
71  Synopsis [Computes truth table of the cut.]
72 
73  Description [The returned pointer should be used immediately.]
74 
75  SideEffects []
76 
77  SeeAlso []
78 
79 ***********************************************************************/
80 unsigned * Aig_ManCutTruth( Aig_Obj_t * pRoot, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vNodes, Vec_Ptr_t * vTruthElem, Vec_Ptr_t * vTruthStore )
81 {
82  Aig_Obj_t * pObj;
83  int i, nWords;
84  assert( Vec_PtrSize(vLeaves) <= Vec_PtrSize(vTruthElem) );
85  assert( Vec_PtrSize(vNodes) <= Vec_PtrSize(vTruthStore) );
86  assert( Vec_PtrSize(vNodes) == 0 || pRoot == Vec_PtrEntryLast(vNodes) );
87  // assign elementary truth tables
88  Vec_PtrForEachEntry( Aig_Obj_t *, vLeaves, pObj, i )
89  pObj->pData = Vec_PtrEntry( vTruthElem, i );
90  // compute truths for other nodes
91  nWords = Abc_TruthWordNum( Vec_PtrSize(vLeaves) );
92  Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
93  pObj->pData = Aig_ManCutTruthOne( pObj, (unsigned *)Vec_PtrEntry(vTruthStore, i), nWords );
94  return (unsigned *)pRoot->pData;
95 }
96 
97 ////////////////////////////////////////////////////////////////////////
98 /// END OF FILE ///
99 ////////////////////////////////////////////////////////////////////////
100 
101 
103 
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void * pData
Definition: aig.h:87
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Abc_TruthWordNum(int nVars)
Definition: abc_global.h:256
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int nWords
Definition: abcNpn.c:127
ABC_NAMESPACE_IMPL_START unsigned * Aig_ManCutTruthOne(Aig_Obj_t *pNode, unsigned *pTruth, int nWords)
DECLARATIONS ///.
Definition: aigTruth.c:45
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
Definition: vecPtr.h:413
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static int Aig_ObjIsExor(Aig_Obj_t *pObj)
Definition: aig.h:279
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define assert(ex)
Definition: util_old.h:213
unsigned * Aig_ManCutTruth(Aig_Obj_t *pRoot, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vNodes, Vec_Ptr_t *vTruthElem, Vec_Ptr_t *vTruthStore)
Definition: aigTruth.c:80
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55