diff options
author | Jannis Harder <me@jix.one> | 2023-01-11 16:26:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-11 16:26:04 +0100 |
commit | 5abaa5908082f13f6b574d66f6f8a9ebb476fd54 (patch) | |
tree | 4438609065528688666e63ffa2e737bced73d35c /kernel/calc.cc | |
parent | d742d063d4e887f3e4dba8bab1a37d160596977d (diff) | |
parent | eb0039848b42afa196f440301492a5afc09b4cf4 (diff) | |
download | yosys-5abaa5908082f13f6b574d66f6f8a9ebb476fd54.tar.gz yosys-5abaa5908082f13f6b574d66f6f8a9ebb476fd54.tar.bz2 yosys-5abaa5908082f13f6b574d66f6f8a9ebb476fd54.zip |
Merge pull request #3537 from jix/xprop
New xprop pass
Diffstat (limited to 'kernel/calc.cc')
-rw-r--r-- | kernel/calc.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/kernel/calc.cc b/kernel/calc.cc index 32e8a49fe..9b02a6e30 100644 --- a/kernel/calc.cc +++ b/kernel/calc.cc @@ -690,5 +690,28 @@ RTLIL::Const RTLIL::const_demux(const RTLIL::Const &arg1, const RTLIL::Const &ar return res; } +RTLIL::Const RTLIL::const_bweqx(const RTLIL::Const &arg1, const RTLIL::Const &arg2) +{ + log_assert(arg2.size() == arg1.size()); + RTLIL::Const result(RTLIL::State::S0, arg1.size()); + for (int i = 0; i < arg1.size(); i++) + result[i] = arg1[i] == arg2[i] ? State::S1 : State::S0; + + return result; +} + +RTLIL::Const RTLIL::const_bwmux(const RTLIL::Const &arg1, const RTLIL::Const &arg2, const RTLIL::Const &arg3) +{ + log_assert(arg2.size() == arg1.size()); + log_assert(arg3.size() == arg1.size()); + RTLIL::Const result(RTLIL::State::Sx, arg1.size()); + for (int i = 0; i < arg1.size(); i++) { + if (arg3[i] != State::Sx || arg1[i] == arg2[i]) + result[i] = arg3[i] == State::S1 ? arg2[i] : arg1[i]; + } + + return result; +} + YOSYS_NAMESPACE_END |