ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
gates.c
Go to the documentation of this file.
1#include "gates.h"
2#include "ands.h"
3#include "definition.h"
4#include "eliminate.h"
5#include "equivalences.h"
6#include "ifthenelse.h"
7#include "inline.h"
8
10
12 value *marks = solver->marks;
13 size_t res = 0;
16 if (!watch.type.binary)
17 continue;
18 const unsigned other = watch.binary.lit;
19 KISSAT_assert (!solver->values[other]);
20 if (marks[other])
21 continue;
22 marks[other] = 1;
23 res++;
24 }
25 return res;
26}
27
29 value *marks = solver->marks;
32 if (watch.type.binary)
33 marks[watch.binary.lit] = 0;
34}
35
37 solver->gate_eliminated = 0;
38 solver->resolve_gate = false;
39 if (!GET_OPTION (extract))
40 return false;
41 INC (gates_checked);
42 const unsigned not_lit = NOT (lit);
43 if (EMPTY_WATCHES (WATCHES (not_lit)))
44 return false;
45 bool res = false;
47 res = true;
48 else if (kissat_find_and_gate (solver, lit, 0))
49 res = true;
50 else if (kissat_find_and_gate (solver, not_lit, 1))
51 res = true;
53 res = true;
54 else if (kissat_find_if_then_else_gate (solver, not_lit, 1))
55 res = true;
57 res = true;
58 if (res)
59 INC (gates_extracted);
60 return res;
61}
62
63static void get_antecedents (kissat *solver, unsigned lit,
64 unsigned negative) {
65 KISSAT_assert (!solver->watching);
66 KISSAT_assert (!negative || negative == 1);
67
68 statches *gates = solver->gates + negative;
70
71 statches *antecedents = solver->antecedents + negative;
72 KISSAT_assert (EMPTY_STACK (*antecedents));
73
74 const watch *const begin_gates = BEGIN_STACK (*gates);
75 const watch *const end_gates = END_STACK (*gates);
76 watch const *g = begin_gates;
77
78 const watch *const begin_watches = BEGIN_WATCHES (*watches);
79 const watch *const end_watches = END_WATCHES (*watches);
80 watch const *w = begin_watches;
81
82 while (w != end_watches) {
83 const watch watch = *w++;
84 if (g != end_gates && g->raw == watch.raw)
85 g++;
86 else
87 PUSH_STACK (*antecedents, watch);
88 }
89
90 KISSAT_assert (g == end_gates);
91#ifdef LOGGING
92 size_t size_gates = SIZE_STACK (*gates);
93 size_t size_antecedents = SIZE_STACK (*antecedents);
94 size_t size_watches = SIZE_WATCHES (*watches);
95 LOG ("got %zu antecedent %.0f%% and %zu gate clauses %.0f%% "
96 "out of %zu watches of literal %s",
97 size_antecedents, kissat_percent (size_antecedents, size_watches),
98 size_gates, kissat_percent (size_gates, size_watches), size_watches,
99 LOGLIT (lit));
100#endif
101}
102
104 get_antecedents (solver, lit, 0);
105 get_antecedents (solver, NOT (lit), 1);
106}
107
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_IMPL_START bool kissat_find_and_gate(kissat *solver, unsigned lit, unsigned negative)
Definition ands.c:8
#define BEGIN_STACK(S)
Definition stack.h:46
#define SIZE_STACK(S)
Definition stack.h:19
#define EMPTY_STACK(S)
Definition stack.h:18
#define PUSH_STACK(S, E)
Definition stack.h:39
#define END_STACK(S)
Definition stack.h:48
#define INC(NAME)
#define LOG(...)
ABC_NAMESPACE_IMPL_START typedef signed char value
bool kissat_find_definition(kissat *solver, unsigned lit)
Definition definition.c:93
ABC_NAMESPACE_IMPL_START bool kissat_find_equivalence_gate(kissat *solver, unsigned lit)
Definition equivalences.c:7
bool kissat_find_gates(kissat *solver, unsigned lit)
Definition gates.c:36
void kissat_unmark_binaries(kissat *solver, unsigned lit)
Definition gates.c:28
ABC_NAMESPACE_IMPL_START size_t kissat_mark_binaries(kissat *solver, unsigned lit)
Definition gates.c:11
void kissat_get_antecedents(kissat *solver, unsigned lit)
Definition gates.c:103
bool kissat_find_if_then_else_gate(kissat *solver, unsigned lit, unsigned negative)
Definition ifthenelse.c:97
#define KISSAT_assert(ignore)
Definition global.h:13
#define solver
Definition kitten.c:211
#define LOGLIT(...)
Definition logging.hpp:99
#define GET_OPTION(N)
Definition options.h:295
int lit
Definition satVec.h:130
#define NOT(LIT)
Definition literal.h:33
Definition watch.h:41
unsigned raw
Definition watch.h:46
watch_type type
Definition watch.h:42
binary_watch binary
Definition watch.h:43
#define SIZE_WATCHES(W)
Definition watch.h:104
#define BEGIN_WATCHES(WS)
Definition watch.h:115
#define END_WATCHES(WS)
Definition watch.h:118
#define EMPTY_WATCHES(W)
Definition watch.h:103
vector watches
Definition watch.h:49
#define all_binary_large_watches(WATCH, WATCHES)
Definition watch.h:158
#define WATCHES(LIT)
Definition watch.h:137