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
|
/**CFile****************************************************************
FileName [gia.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Scalable AIG package.]
Synopsis []
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: gia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "gia.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static inline int Sat_ObjXValue( Gia_Obj_t * pObj ) { return (pObj->fMark1 << 1) | pObj->fMark0; }
static inline void Sat_ObjSetXValue( Gia_Obj_t * pObj, int v) { pObj->fMark0 = (v & 1); pObj->fMark1 = ((v >> 1) & 1); }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Collects nodes in the cone and initialized them to x.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_SatCollectCone_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vVisit )
{
if ( Sat_ObjXValue(pObj) == GIA_UND )
return;
if ( Gia_ObjIsAnd(pObj) )
{
Gia_SatCollectCone_rec( p, Gia_ObjFanin0(pObj), vVisit );
Gia_SatCollectCone_rec( p, Gia_ObjFanin1(pObj), vVisit );
}
assert( Sat_ObjXValue(pObj) == 0 );
Sat_ObjSetXValue( pObj, GIA_UND );
Vec_IntPush( vVisit, Gia_ObjId(p, pObj) );
}
/**Function*************************************************************
Synopsis [Collects nodes in the cone and initialized them to x.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_SatCollectCone( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vVisit )
{
assert( !Gia_IsComplement(pObj) );
assert( !Gia_ObjIsConst0(pObj) );
assert( Sat_ObjXValue(pObj) == 0 );
Vec_IntClear( vVisit );
Gia_SatCollectCone_rec( p, pObj, vVisit );
}
/**Function*************************************************************
Synopsis [Checks if the counter-examples asserts the output.]
Description [Assumes that fMark0 and fMark1 are clean. Leaves them clean.]
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_SatVerifyPattern( Gia_Man_t * p, Gia_Obj_t * pRoot, Vec_Int_t * vCex, Vec_Int_t * vVisit )
{
Gia_Obj_t * pObj;
int i, Entry, Value, Value0, Value1;
assert( Gia_ObjIsCo(pRoot) );
assert( !Gia_ObjIsConst0(Gia_ObjFanin0(pRoot)) );
// collect nodes and initialized them to x
Gia_SatCollectCone( p, Gia_ObjFanin0(pRoot), vVisit );
// set binary values to nodes in the counter-example
Vec_IntForEachEntry( vCex, Entry, i )
// Sat_ObjSetXValue( Gia_ManObj(p, Abc_Lit2Var(Entry)), Abc_LitIsCompl(Entry)? GIA_ZER : GIA_ONE );
Sat_ObjSetXValue( Gia_ManCi(p, Abc_Lit2Var(Entry)), Abc_LitIsCompl(Entry)? GIA_ZER : GIA_ONE );
// simulate
Gia_ManForEachObjVec( vVisit, p, pObj, i )
{
if ( Gia_ObjIsCi(pObj) )
continue;
assert( Gia_ObjIsAnd(pObj) );
Value0 = Sat_ObjXValue( Gia_ObjFanin0(pObj) );
Value1 = Sat_ObjXValue( Gia_ObjFanin1(pObj) );
Value = Gia_XsimAndCond( Value0, Gia_ObjFaninC0(pObj), Value1, Gia_ObjFaninC1(pObj) );
Sat_ObjSetXValue( pObj, Value );
}
Value = Sat_ObjXValue( Gia_ObjFanin0(pRoot) );
Value = Gia_XsimNotCond( Value, Gia_ObjFaninC0(pRoot) );
if ( Value != GIA_ONE )
printf( "Gia_SatVerifyPattern(): Verification FAILED.\n" );
// else
// printf( "Gia_SatVerifyPattern(): Verification succeeded.\n" );
// assert( Value == GIA_ONE );
// clean the nodes
Gia_ManForEachObjVec( vVisit, p, pObj, i )
Sat_ObjSetXValue( pObj, 0 );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
|