69 void add_clause(
const std::vector<int> &
args,
bool argsPolarity,
int a = 0,
int b = 0,
int c = 0);
96 int literal(
const std::string &name);
99 int expression(
OpId op,
int a = 0,
int b = 0,
int c = 0,
int d = 0,
int e = 0,
int f = 0);
114 int eval(
int id,
const std::vector<int> &values)
const;
120 virtual bool solver(
const std::vector<int> &modelExpressions, std::vector<bool> &modelValues,
const std::vector<int> &assumptions);
122 bool solve(
const std::vector<int> &modelExpressions, std::vector<bool> &modelValues,
const std::vector<int> &assumptions) {
123 return solver(modelExpressions, modelValues, assumptions);
126 bool solve(
const std::vector<int> &modelExpressions, std::vector<bool> &modelValues,
int a = 0,
int b = 0,
int c = 0,
int d = 0,
int e = 0,
int f = 0) {
127 std::vector<int> assumptions;
128 if (a != 0) assumptions.push_back(a);
129 if (b != 0) assumptions.push_back(b);
130 if (c != 0) assumptions.push_back(c);
131 if (d != 0) assumptions.push_back(d);
132 if (e != 0) assumptions.push_back(e);
133 if (f != 0) assumptions.push_back(f);
134 return solver(modelExpressions, modelValues, assumptions);
137 bool solve(
int a = 0,
int b = 0,
int c = 0,
int d = 0,
int e = 0,
int f = 0) {
138 std::vector<int> assumptions, modelExpressions;
139 std::vector<bool> modelValues;
140 if (a != 0) assumptions.push_back(a);
141 if (b != 0) assumptions.push_back(b);
142 if (c != 0) assumptions.push_back(c);
143 if (d != 0) assumptions.push_back(d);
144 if (e != 0) assumptions.push_back(e);
145 if (f != 0) assumptions.push_back(f);
146 return solver(modelExpressions, modelValues, assumptions);
159 virtual void clear();
160 virtual void freeze(
int id);
163 int bind(
int id,
bool auto_freeze =
true);
164 int bound(
int id)
const;
174 void getFullCnf(std::vector<std::vector<int>> &full_cnf)
const;
183 _V(
int id) : id(id) { }
185 _V(
const std::string &
name) :
id(0), name(name) { }
189 return that->frozen_literal(
name);
202 return expression(
OpAnd, a.get(
this), b.get(
this), c.get(
this), d.get(
this), e.get(
this), f.get(
this));
206 return expression(
OpOr, a.get(
this), b.get(
this), c.get(
this), d.get(
this), e.get(
this), f.get(
this));
210 return expression(
OpXor, a.get(
this), b.get(
this), c.get(
this), d.get(
this), e.get(
this), f.get(
this));
214 return expression(
OpIFF, a.
get(
this), b.get(
this), c.get(
this), d.get(
this), e.get(
this), f.get(
this));
227 std::vector<int>
vec_const(
const std::vector<bool> &bits);
230 std::vector<int>
vec_var(
int numBits);
231 std::vector<int>
vec_var(std::string name,
int numBits);
232 std::vector<int>
vec_cast(
const std::vector<int> &vec1,
int toBits,
bool signExtend =
false);
234 std::vector<int>
vec_not(
const std::vector<int> &vec1);
235 std::vector<int>
vec_and(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
236 std::vector<int>
vec_or(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
237 std::vector<int>
vec_xor(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
239 std::vector<int>
vec_iff(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
240 std::vector<int>
vec_ite(
const std::vector<int> &vec1,
const std::vector<int> &vec2,
const std::vector<int> &vec3);
241 std::vector<int>
vec_ite(
int sel,
const std::vector<int> &vec1,
const std::vector<int> &vec2);
243 std::vector<int>
vec_count(
const std::vector<int> &
vec,
int numBits,
bool clip =
true);
244 std::vector<int>
vec_add(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
245 std::vector<int>
vec_sub(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
246 std::vector<int>
vec_neg(
const std::vector<int> &
vec);
248 void vec_cmp(
const std::vector<int> &vec1,
const std::vector<int> &vec2,
int &carry,
int &overflow,
int &
sign,
int &zero);
250 int vec_lt_signed(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
251 int vec_le_signed(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
252 int vec_ge_signed(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
253 int vec_gt_signed(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
255 int vec_lt_unsigned(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
256 int vec_le_unsigned(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
257 int vec_ge_unsigned(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
258 int vec_gt_unsigned(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
260 int vec_eq(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
261 int vec_ne(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
263 std::vector<int>
vec_shl(
const std::vector<int> &vec1,
int shift,
bool signExtend =
false);
264 std::vector<int>
vec_srl(
const std::vector<int> &vec1,
int shift);
266 std::vector<int>
vec_shr(
const std::vector<int> &vec1,
int shift,
bool signExtend =
false) {
return vec_shl(vec1, -shift, signExtend); }
267 std::vector<int>
vec_srr(
const std::vector<int> &vec1,
int shift) {
return vec_srl(vec1, -shift); }
269 std::vector<int>
vec_shift(
const std::vector<int> &vec1,
int shift,
int extend_left,
int extend_right);
270 std::vector<int>
vec_shift_right(
const std::vector<int> &vec1,
const std::vector<int> &vec2,
bool vec2_signed,
int extend_left,
int extend_right);
271 std::vector<int>
vec_shift_left(
const std::vector<int> &vec1,
const std::vector<int> &vec2,
bool vec2_signed,
int extend_left,
int extend_right);
273 void vec_append(std::vector<int> &
vec,
const std::vector<int> &vec1)
const;
277 int64_t
vec_model_get_signed(
const std::vector<int> &modelExpressions,
const std::vector<bool> &modelValues,
const std::vector<int> &vec1)
const;
278 uint64_t
vec_model_get_unsigned(
const std::vector<int> &modelExpressions,
const std::vector<bool> &modelValues,
const std::vector<int> &vec1)
const;
283 void vec_set(
const std::vector<int> &vec1,
const std::vector<int> &vec2);
294 void
printDIMACS(FILE *f, bool verbose = false) const;
299 int
onehot(const std::vector<int> &vec, bool max_only = false);
300 int
manyhot(const std::vector<int> &vec, int min_hot, int max_hot = -1);
301 int
ordered(const std::vector<int> &vec1, const std::vector<int> &vec2, bool allow_equal = true);
320 operator int()
const {
return id; }
322 operator std::vector<int>()
const {
return std::vector<int>(1,
id); }
352 operator std::vector<int>()
const {
return vec; }
std::vector< int > vec_sub(const std::vector< int > &vec1, const std::vector< int > &vec2)
const std::vector< std::vector< int > > & cnf() const
std::vector< int > vec_const_signed(int64_t value, int numBits)
std::string cnfLiteralInfo(int idx) const
int vec_ge_signed(const std::vector< int > &vec1, const std::vector< int > &vec2)
void lookup_expression(int id, OpId &op, std::vector< int > &args) const
int parse_string(const std::string &text)
std::vector< int > vec_var(int numBits)
virtual bool solver(const std::vector< int > &modelExpressions, std::vector< bool > &modelValues, const std::vector< int > &assumptions)
int numCnfClauses() const
virtual bool eliminated(int idx)
static const int CONST_FALSE
void vec_append_signed(std::vector< int > &vec, const std::vector< int > &vec1, int64_t value)
std::vector< int > vec_iff(const std::vector< int > &vec1, const std::vector< int > &vec2)
int eval(int id, const std::vector< int > &values) const
int vec_le_signed(const std::vector< int > &vec1, const std::vector< int > &vec2)
static std::string idx(std::string str)
void add_clause(const std::vector< int > &args)
void vec_cmp(const std::vector< int > &vec1, const std::vector< int > &vec2, int &carry, int &overflow, int &sign, int &zero)
int vec_lt_unsigned(const std::vector< int > &vec1, const std::vector< int > &vec2)
bool mode_keep_cnf() const
std::vector< int > vec_count(const std::vector< int > &vec, int numBits, bool clip=true)
std::vector< std::string > literals
void vec_set(const std::vector< int > &vec1, const std::vector< int > &vec2)
std::vector< int > vec_shift(const std::vector< int > &vec1, int shift, int extend_left, int extend_right)
int ITE(_V a, _V b, _V c)
std::vector< int > vec_shl(const std::vector< int > &vec1, int shift, bool signExtend=false)
std::vector< std::pair< OpId, std::vector< int > > > expressions
int AND(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
std::vector< int > vec_or(const std::vector< int > &vec1, const std::vector< int > &vec2)
int onehot(const std::vector< int > &vec, bool max_only=false)
_V(const std::string &name)
void vec_set_unsigned(const std::vector< int > &vec1, uint64_t value)
std::vector< int > vec_srl(const std::vector< int > &vec1, int shift)
int numCnfVariables() const
int numExpressions() const
void lookup_literal(int id, std::string &name) const
std::vector< int > cnfLiteralVariables
std::string to_string(int id) const
std::map< std::pair< OpId, std::vector< int > >, int > expressionsCache
uint64_t vec_model_get_unsigned(const std::vector< int > &modelExpressions, const std::vector< bool > &modelValues, const std::vector< int > &vec1) const
int vec_gt_unsigned(const std::vector< int > &vec1, const std::vector< int > &vec2)
std::vector< int > vec_neg(const std::vector< int > &vec)
ezSATbit(ezSAT &sat, ezSAT::_V a)
std::vector< int > vec_const_unsigned(uint64_t value, int numBits)
void vec_append_unsigned(std::vector< int > &vec, const std::vector< int > &vec1, uint64_t value)
std::vector< int > vec_shr(const std::vector< int > &vec1, int shift, bool signExtend=false)
int vec_ne(const std::vector< int > &vec1, const std::vector< int > &vec2)
bool solve(const std::vector< int > &modelExpressions, std::vector< bool > &modelValues, const std::vector< int > &assumptions)
std::vector< int > vec_shift_left(const std::vector< int > &vec1, const std::vector< int > &vec2, bool vec2_signed, int extend_left, int extend_right)
void printInternalState(FILE *f) const
Lit operator^(Lit p, bool b)
void printDIMACS(FILE *f, bool verbose=false) const
bool solve(int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
int bind_cnf_and(const std::vector< int > &args)
int64_t vec_model_get_signed(const std::vector< int > &modelExpressions, const std::vector< bool > &modelValues, const std::vector< int > &vec1) const
std::vector< int > vec_shift_right(const std::vector< int > &vec1, const std::vector< int > &vec2, bool vec2_signed, int extend_left, int extend_right)
int ordered(const std::vector< int > &vec1, const std::vector< int > &vec2, bool allow_equal=true)
int vec_reduce_and(const std::vector< int > &vec1)
std::vector< int > vec_cast(const std::vector< int > &vec1, int toBits, bool signExtend=false)
std::vector< int > vec_xor(const std::vector< int > &vec1, const std::vector< int > &vec2)
int vec_reduce_or(const std::vector< int > &vec1)
int vec_gt_signed(const std::vector< int > &vec1, const std::vector< int > &vec2)
virtual void freeze(int id)
int bind_cnf_not(const std::vector< int > &args)
static const int CONST_TRUE
std::vector< int > vec_add(const std::vector< int > &vec1, const std::vector< int > &vec2)
void getFullCnf(std::vector< std::vector< int >> &full_cnf) const
std::vector< int > vec_ite(const std::vector< int > &vec1, const std::vector< int > &vec2, const std::vector< int > &vec3)
int manyhot(const std::vector< int > &vec, int min_hot, int max_hot=-1)
std::vector< int > vec_srr(const std::vector< int > &vec1, int shift)
int XOR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
void setSolverTimeout(int newTimeoutSeconds)
int expression(OpId op, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
bool getSolverTimoutStatus()
bool solve(const std::vector< int > &modelExpressions, std::vector< bool > &modelValues, int a=0, int b=0, int c=0, int d=0, int e=0, int f=0)
int vec_eq(const std::vector< int > &vec1, const std::vector< int > &vec2)
int vec_lt_signed(const std::vector< int > &vec1, const std::vector< int > &vec2)
int OR(_V a=0, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
bool flag_non_incremental
std::vector< int > vec_const(const std::vector< bool > &bits)
std::ostream & operator<<(std::ostream &os, const BigUnsigned &x)
int bind_cnf_or(const std::vector< int > &args)
std::vector< std::vector< int > > cnfClauses
std::string id(RTLIL::IdString internal_id, bool may_rename=true)
std::map< std::string, int > literalsCache
void vec_set_signed(const std::vector< int > &vec1, int64_t value)
int IFF(_V a, _V b=0, _V c=0, _V d=0, _V e=0, _V f=0)
std::vector< std::vector< int > > cnfClausesBackup
bool mode_non_incremental() const
std::vector< int > vec_not(const std::vector< int > &vec1)
std::vector< int > cnfExpressionVariables
int vec_ge_unsigned(const std::vector< int > &vec1, const std::vector< int > &vec2)
struct ezSATbit bit(_V a)
bool non_incremental_solve_used_up
void vec_append(std::vector< int > &vec, const std::vector< int > &vec1) const
struct ezSATvec vec(const std::vector< int > &vec)
int vec_le_unsigned(const std::vector< int > &vec1, const std::vector< int > &vec2)
int bind(int id, bool auto_freeze=true)
std::vector< int > vec_and(const std::vector< int > &vec1, const std::vector< int > &vec2)
ezSATvec(ezSAT &sat, const std::vector< int > &vec)