diff options
Diffstat (limited to 'kernel/calc.cc')
-rw-r--r-- | kernel/calc.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/kernel/calc.cc b/kernel/calc.cc index 61025104d..a56db93aa 100644 --- a/kernel/calc.cc +++ b/kernel/calc.cc @@ -386,6 +386,35 @@ RTLIL::Const RTLIL::const_ne(const RTLIL::Const &arg1, const RTLIL::Const &arg2, return result; } +RTLIL::Const RTLIL::const_eqx(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len) +{ + RTLIL::Const arg1_ext = arg1; + RTLIL::Const arg2_ext = arg2; + RTLIL::Const result(RTLIL::State::S0, result_len); + + int width = std::max(arg1_ext.bits.size(), arg2_ext.bits.size()); + extend_u0(arg1_ext, width, signed1 && signed2); + extend_u0(arg2_ext, width, signed1 && signed2); + + for (size_t i = 0; i < arg1_ext.bits.size(); i++) { + if (arg1_ext.bits.at(i) != arg2_ext.bits.at(i)) + return result; + } + + result.bits.front() = RTLIL::State::S1; + return result; +} + +RTLIL::Const RTLIL::const_nex(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len) +{ + RTLIL::Const result = RTLIL::const_eqx(arg1, arg2, signed1, signed2, result_len); + if (result.bits.front() == RTLIL::State::S0) + result.bits.front() = RTLIL::State::S1; + else if (result.bits.front() == RTLIL::State::S1) + result.bits.front() = RTLIL::State::S0; + return result; +} + RTLIL::Const RTLIL::const_ge(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len) { int undef_bit_pos = -1; @@ -514,6 +543,14 @@ RTLIL::Const RTLIL::const_pos(const RTLIL::Const &arg1, const RTLIL::Const&, boo return arg1_ext; } +RTLIL::Const RTLIL::const_bu0(const RTLIL::Const &arg1, const RTLIL::Const&, bool signed1, bool, int result_len) +{ + RTLIL::Const arg1_ext = arg1; + extend_u0(arg1_ext, result_len, signed1); + + return arg1_ext; +} + RTLIL::Const RTLIL::const_neg(const RTLIL::Const &arg1, const RTLIL::Const&, bool signed1, bool, int result_len) { RTLIL::Const arg1_ext = arg1; |