abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaPat.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [gia.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Scalable AIG package.]
8 
9  Synopsis []
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: gia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "gia.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 static inline int Sat_ObjXValue( Gia_Obj_t * pObj ) { return (pObj->fMark1 << 1) | pObj->fMark0; }
31 static inline void Sat_ObjSetXValue( Gia_Obj_t * pObj, int v) { pObj->fMark0 = (v & 1); pObj->fMark1 = ((v >> 1) & 1); }
32 
33 ////////////////////////////////////////////////////////////////////////
34 /// FUNCTION DEFINITIONS ///
35 ////////////////////////////////////////////////////////////////////////
36 
37 /**Function*************************************************************
38 
39  Synopsis [Collects nodes in the cone and initialized them to x.]
40 
41  Description []
42 
43  SideEffects []
44 
45  SeeAlso []
46 
47 ***********************************************************************/
49 {
50  if ( Sat_ObjXValue(pObj) == GIA_UND )
51  return;
52  if ( Gia_ObjIsAnd(pObj) )
53  {
54  Gia_SatCollectCone_rec( p, Gia_ObjFanin0(pObj), vVisit );
55  Gia_SatCollectCone_rec( p, Gia_ObjFanin1(pObj), vVisit );
56  }
57  assert( Sat_ObjXValue(pObj) == 0 );
58  Sat_ObjSetXValue( pObj, GIA_UND );
59  Vec_IntPush( vVisit, Gia_ObjId(p, pObj) );
60 }
61 
62 /**Function*************************************************************
63 
64  Synopsis [Collects nodes in the cone and initialized them to x.]
65 
66  Description []
67 
68  SideEffects []
69 
70  SeeAlso []
71 
72 ***********************************************************************/
73 void Gia_SatCollectCone( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vVisit )
74 {
75  assert( !Gia_IsComplement(pObj) );
76  assert( !Gia_ObjIsConst0(pObj) );
77  assert( Sat_ObjXValue(pObj) == 0 );
78  Vec_IntClear( vVisit );
79  Gia_SatCollectCone_rec( p, pObj, vVisit );
80 }
81 
82 /**Function*************************************************************
83 
84  Synopsis [Checks if the counter-examples asserts the output.]
85 
86  Description [Assumes that fMark0 and fMark1 are clean. Leaves them clean.]
87 
88  SideEffects []
89 
90  SeeAlso []
91 
92 ***********************************************************************/
93 void Gia_SatVerifyPattern( Gia_Man_t * p, Gia_Obj_t * pRoot, Vec_Int_t * vCex, Vec_Int_t * vVisit )
94 {
95  Gia_Obj_t * pObj;
96  int i, Entry, Value, Value0, Value1;
97  assert( Gia_ObjIsCo(pRoot) );
99  // collect nodes and initialized them to x
100  Gia_SatCollectCone( p, Gia_ObjFanin0(pRoot), vVisit );
101  // set binary values to nodes in the counter-example
102  Vec_IntForEachEntry( vCex, Entry, i )
103 // Sat_ObjSetXValue( Gia_ManObj(p, Abc_Lit2Var(Entry)), Abc_LitIsCompl(Entry)? GIA_ZER : GIA_ONE );
105  // simulate
106  Gia_ManForEachObjVec( vVisit, p, pObj, i )
107  {
108  if ( Gia_ObjIsCi(pObj) )
109  continue;
110  assert( Gia_ObjIsAnd(pObj) );
111  Value0 = Sat_ObjXValue( Gia_ObjFanin0(pObj) );
112  Value1 = Sat_ObjXValue( Gia_ObjFanin1(pObj) );
113  Value = Gia_XsimAndCond( Value0, Gia_ObjFaninC0(pObj), Value1, Gia_ObjFaninC1(pObj) );
114  Sat_ObjSetXValue( pObj, Value );
115  }
116  Value = Sat_ObjXValue( Gia_ObjFanin0(pRoot) );
117  Value = Gia_XsimNotCond( Value, Gia_ObjFaninC0(pRoot) );
118  if ( Value != GIA_ONE )
119  printf( "Gia_SatVerifyPattern(): Verification FAILED.\n" );
120 // else
121 // printf( "Gia_SatVerifyPattern(): Verification succeeded.\n" );
122 // assert( Value == GIA_ONE );
123  // clean the nodes
124  Gia_ManForEachObjVec( vVisit, p, pObj, i )
125  Sat_ObjSetXValue( pObj, 0 );
126 }
127 
128 
129 ////////////////////////////////////////////////////////////////////////
130 /// END OF FILE ///
131 ////////////////////////////////////////////////////////////////////////
132 
133 
135 
#define GIA_UND
Definition: gia.h:749
static void Sat_ObjSetXValue(Gia_Obj_t *pObj, int v)
Definition: giaPat.c:31
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static Gia_Obj_t * Gia_ManCi(Gia_Man_t *p, int v)
Definition: gia.h:403
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Gia_SatCollectCone_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vVisit)
FUNCTION DEFINITIONS ///.
Definition: giaPat.c:48
#define GIA_ZER
Definition: gia.h:747
static int Gia_ObjIsConst0(Gia_Obj_t *pObj)
Definition: gia.h:430
void Gia_SatVerifyPattern(Gia_Man_t *p, Gia_Obj_t *pRoot, Vec_Int_t *vCex, Vec_Int_t *vVisit)
Definition: giaPat.c:93
static int Gia_XsimNotCond(int Value, int fCompl)
Definition: gia.h:751
unsigned fMark1
Definition: gia.h:84
static int Gia_XsimAndCond(int Value0, int fCompl0, int Value1, int fCompl1)
Definition: gia.h:759
Definition: gia.h:75
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
void Gia_SatCollectCone(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vVisit)
Definition: giaPat.c:73
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
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 Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
unsigned fMark0
Definition: gia.h:79
Definition: gia.h:95
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static ABC_NAMESPACE_IMPL_START int Sat_ObjXValue(Gia_Obj_t *pObj)
DECLARATIONS ///.
Definition: giaPat.c:30
#define GIA_ONE
Definition: gia.h:748