ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sbdCnf.c
Go to the documentation of this file.
1
20
21#include "sbdInt.h"
22
24
25
29
33
45void Sbd_PrintCnf( Vec_Str_t * vCnf )
46{
47 signed char Entry;
48 int i, Lit;
49 Vec_StrForEachEntry( vCnf, Entry, i )
50 {
51 Lit = (int)Entry;
52 if ( Lit == -1 )
53 printf( "\n" );
54 else
55 printf( "%s%d ", Abc_LitIsCompl(Lit) ? "-":"", Abc_Lit2Var(Lit) );
56 }
57}
58
70int Sbd_TruthToCnf( word Truth, int nVars, Vec_Int_t * vCover, Vec_Str_t * vCnf )
71{
72 Vec_StrClear( vCnf );
73 if ( Truth == 0 || ~Truth == 0 )
74 {
75// assert( nVars == 0 );
76 Vec_StrPush( vCnf, (char)(Truth == 0) );
77 Vec_StrPush( vCnf, (char)-1 );
78 return 1;
79 }
80 else
81 {
82 int i, k, c, RetValue, Literal, Cube, nCubes = 0;
83 assert( nVars > 0 );
84 for ( c = 0; c < 2; c ++ )
85 {
86 Truth = c ? ~Truth : Truth;
87 RetValue = Kit_TruthIsop( (unsigned *)&Truth, nVars, vCover, 0 );
88 assert( RetValue == 0 );
89 nCubes += Vec_IntSize( vCover );
90 Vec_IntForEachEntry( vCover, Cube, i )
91 {
92 for ( k = 0; k < nVars; k++ )
93 {
94 Literal = 3 & (Cube >> (k << 1));
95 if ( Literal == 1 ) // '0' -> pos lit
96 Vec_StrPush( vCnf, (char)Abc_Var2Lit(k, 0) );
97 else if ( Literal == 2 ) // '1' -> neg lit
98 Vec_StrPush( vCnf, (char)Abc_Var2Lit(k, 1) );
99 else if ( Literal != 0 )
100 assert( 0 );
101 }
102 Vec_StrPush( vCnf, (char)Abc_Var2Lit(nVars, c) );
103 Vec_StrPush( vCnf, (char)-1 );
104 }
105 }
106 return nCubes;
107 }
108}
109
121void Sbd_TranslateCnf( Vec_Wec_t * vRes, Vec_Str_t * vCnf, Vec_Int_t * vFaninMap, int iPivotVar )
122{
123 Vec_Int_t * vClause;
124 signed char Entry;
125 int i, Lit;
126 Vec_WecClear( vRes );
127 vClause = Vec_WecPushLevel( vRes );
128 Vec_StrForEachEntry( vCnf, Entry, i )
129 {
130 if ( (int)Entry == -1 )
131 {
132 vClause = Vec_WecPushLevel( vRes );
133 continue;
134 }
135 Lit = Abc_Lit2LitV( Vec_IntArray(vFaninMap), (int)Entry );
136 Lit = Abc_LitNotCond( Lit, Abc_Lit2Var(Lit) == iPivotVar );
137 Vec_IntPush( vClause, Lit );
138 }
139}
140
144
145
147
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
struct cube Cube
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
Definition kitIsop.c:134
ABC_NAMESPACE_IMPL_START void Sbd_PrintCnf(Vec_Str_t *vCnf)
DECLARATIONS ///.
Definition sbdCnf.c:45
void Sbd_TranslateCnf(Vec_Wec_t *vRes, Vec_Str_t *vCnf, Vec_Int_t *vFaninMap, int iPivotVar)
Definition sbdCnf.c:121
int Sbd_TruthToCnf(word Truth, int nVars, Vec_Int_t *vCover, Vec_Str_t *vCnf)
Definition sbdCnf.c:70
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Vec_StrForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecStr.h:54
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42