diff options
author | Claire Xenia Wolf <claire@clairexen.net> | 2022-12-01 11:31:39 +0100 |
---|---|---|
committer | Claire Xenia Wolf <claire@clairexen.net> | 2022-12-01 11:31:39 +0100 |
commit | 956b7f5fd1739f8571da5c02055c64a9d911780c (patch) | |
tree | 7530783b4eb40ab78e22e1d9fbbc1c849158ed65 /kernel/calc.cc | |
parent | fbf8bcf38f4cc6ea11f4b6461531deb17bd9765c (diff) | |
parent | eb0039848b42afa196f440301492a5afc09b4cf4 (diff) | |
download | yosys-956b7f5fd1739f8571da5c02055c64a9d911780c.tar.gz yosys-956b7f5fd1739f8571da5c02055c64a9d911780c.tar.bz2 yosys-956b7f5fd1739f8571da5c02055c64a9d911780c.zip |
Merge branch 'xprop' of github.com:jix/yosys into claire/eqystuff
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 |