33 if (arg.
bits.size() > 0 && is_signed)
34 padding = arg.
bits.back();
36 while (
int(arg.
bits.size()) < width)
37 arg.
bits.push_back(padding);
39 arg.
bits.resize(width);
45 for (
size_t i = 0; i < val.
bits.size(); i++) {
47 if (as_signed && i+1 == val.
bits.size())
53 if (undef_bit_pos < 0)
63 if (undef_bit_pos >= 0)
74 for (
int i = 0; i < result_len; i++)
79 for (
int i = 0; i < result_len; i++)
85 if (undef_bit_pos >= 0)
86 for (
int i = undef_bit_pos; i < result_len; i++)
128 result_len = arg1.
bits.size();
131 extend_u0(arg1_ext, result_len, signed1);
134 for (
size_t i = 0; i < size_t(result_len); i++) {
135 if (i >= arg1_ext.
bits.size())
150 result_len = std::max(arg1.
bits.size(), arg2.
bits.size());
156 for (
size_t i = 0; i < size_t(result_len); i++) {
159 result.
bits[i] = logic_func(a, b);
189 for (
size_t i = 0; i < arg1.
bits.size(); i++)
190 temp = logic_func(temp, arg1.
bits[i]);
193 while (
int(result.
bits.size()) < result_len)
216 if (!buffer.
bits.empty()) {
232 int undef_bit_pos_a = -1;
236 while (
int(result.bits.size()) < result_len)
243 int undef_bit_pos_a = -1, undef_bit_pos_b = -1;
251 while (
int(result.
bits.size()) < result_len)
258 int undef_bit_pos_a = -1, undef_bit_pos_b = -1;
266 while (
int(result.
bits.size()) < result_len)
273 int undef_bit_pos = -1;
277 result_len = arg1.
bits.size();
280 if (undef_bit_pos >= 0)
283 for (
int i = 0; i < result_len; i++) {
287 else if (pos >= arg1.
bits.size())
299 extend_u0(arg1_ext, result_len, signed1);
313 return const_shl(arg1, arg2, signed1, signed2, result_len);
320 return const_shr(arg1, arg2, signed1, signed2, result_len);
326 int undef_bit_pos = -1;
330 result_len = arg1.
bits.size();
333 if (undef_bit_pos >= 0)
336 for (
int i = 0; i < result_len; i++) {
338 if (pos < 0 || pos >= arg1.
bits.size())
339 result.
bits[i] = other_bits;
359 int undef_bit_pos = -1;
360 bool y =
const2big(arg1, signed1, undef_bit_pos) <
const2big(arg2, signed2, undef_bit_pos);
363 while (
int(result.
bits.size()) < result_len)
364 result.
bits.push_back(RTLIL::State::S0);
370 int undef_bit_pos = -1;
371 bool y =
const2big(arg1, signed1, undef_bit_pos) <=
const2big(arg2, signed2, undef_bit_pos);
374 while (
int(result.
bits.size()) < result_len)
375 result.
bits.push_back(RTLIL::State::S0);
385 int width = std::max(arg1_ext.
bits.size(), arg2_ext.
bits.size());
386 extend_u0(arg1_ext, width, signed1 && signed2);
387 extend_u0(arg2_ext, width, signed1 && signed2);
390 for (
size_t i = 0; i < arg1_ext.
bits.size(); i++) {
399 result.
bits.front() = matched_status;
419 int width = std::max(arg1_ext.
bits.size(), arg2_ext.
bits.size());
420 extend_u0(arg1_ext, width, signed1 && signed2);
421 extend_u0(arg2_ext, width, signed1 && signed2);
423 for (
size_t i = 0; i < arg1_ext.
bits.size(); i++) {
424 if (arg1_ext.
bits.at(i) != arg2_ext.
bits.at(i))
444 int undef_bit_pos = -1;
445 bool y =
const2big(arg1, signed1, undef_bit_pos) >=
const2big(arg2, signed2, undef_bit_pos);
448 while (
int(result.
bits.size()) < result_len)
449 result.
bits.push_back(RTLIL::State::S0);
455 int undef_bit_pos = -1;
456 bool y =
const2big(arg1, signed1, undef_bit_pos) >
const2big(arg2, signed2, undef_bit_pos);
459 while (
int(result.
bits.size()) < result_len)
460 result.
bits.push_back(RTLIL::State::S0);
466 int undef_bit_pos = -1;
468 return big2const(y, result_len >= 0 ? result_len : std::max(arg1.
bits.size(), arg2.
bits.size()), undef_bit_pos);
473 int undef_bit_pos = -1;
475 return big2const(y, result_len >= 0 ? result_len : std::max(arg1.
bits.size(), arg2.
bits.size()), undef_bit_pos);
480 int undef_bit_pos = -1;
482 return big2const(y, result_len >= 0 ? result_len : std::max(arg1.
bits.size(), arg2.
bits.size()), std::min(undef_bit_pos, 0));
487 int undef_bit_pos = -1;
495 return big2const(result_neg ? -(a / b) : (a / b), result_len >= 0 ? result_len : std::max(arg1.
bits.size(), arg2.
bits.size()), std::min(undef_bit_pos, 0));
500 int undef_bit_pos = -1;
508 return big2const(result_neg ? -(a % b) : (a % b), result_len >= 0 ? result_len : std::max(arg1.
bits.size(), arg2.
bits.size()), std::min(undef_bit_pos, 0));
513 int undef_bit_pos = -1;
530 y = (-b % 2) == 0 ? 1 : -1;
537 int modulus_bits = (result_len >= 0 ? result_len : 1024);
538 for (
int i = 0; i < modulus_bits; i++)
541 bool flip_result_sign =
false;
545 flip_result_sign =
true;
550 y = (y * a) % modulus;
552 a = (a * a) % modulus;
555 if (flip_result_sign)
559 return big2const(y, result_len >= 0 ? result_len : std::max(arg1.
bits.size(), arg2.
bits.size()), std::min(undef_bit_pos, 0));
565 extend_u0(arg1_ext, result_len, signed1);
RTLIL::Const const_logic_or(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_xor(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_pow(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
static RTLIL::State logic_xnor(RTLIL::State a, RTLIL::State b)
RTLIL::Const const_ne(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
static RTLIL::State logic_xor(RTLIL::State a, RTLIL::State b)
RTLIL::Const const_eq(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
#define YOSYS_NAMESPACE_END
static RTLIL::Const logic_wrapper(RTLIL::State(*logic_func)(RTLIL::State, RTLIL::State), RTLIL::Const arg1, RTLIL::Const arg2, bool signed1, bool signed2, int result_len=-1)
RTLIL::Const const_sub(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_logic_not(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
static RTLIL::Const logic_reduce_wrapper(RTLIL::State initial, RTLIL::State(*logic_func)(RTLIL::State, RTLIL::State), const RTLIL::Const &arg1, int result_len)
RTLIL::Const const_or(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
RTLIL::Const const_ge(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_and(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_mul(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
const BigUnsigned & getMagnitude() const
RTLIL::Const const_reduce_and(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_reduce_xor(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_sshl(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_reduce_xnor(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_xnor(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
int GetSize(RTLIL::Wire *wire)
static YOSYS_NAMESPACE_BEGIN void extend_u0(RTLIL::Const &arg, int width, bool is_signed)
RTLIL::Const const_shr(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_mod(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_shl(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_le(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_eqx(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
static RTLIL::Const const_shift_worker(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool sign_ext, int direction, int result_len)
RTLIL::Const const_sshr(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_shiftx(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
static RTLIL::Const const_shift_shiftx(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool, bool signed2, int result_len, RTLIL::State other_bits)
RTLIL::Const const_logic_and(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_reduce_or(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
#define YOSYS_NAMESPACE_BEGIN
RTLIL::Const const_nex(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_div(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_lt(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
std::vector< RTLIL::State > bits
static RTLIL::State logic_or(RTLIL::State a, RTLIL::State b)
RTLIL::Const const_neg(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_add(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
static RTLIL::State logic_and(RTLIL::State a, RTLIL::State b)
RTLIL::Const const_reduce_bool(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_pos(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_gt(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_shift(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const const_not(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
static RTLIL::Const big2const(const BigInteger &val, int result_len, int undef_bit_pos)
bool getBit(Index bi) const