diff options
author | whitequark <whitequark@whitequark.org> | 2020-12-21 04:32:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-21 04:32:18 +0000 |
commit | a679a761b51ca67b61dc8b2c7316949b41ef9dd2 (patch) | |
tree | 7edd9e357c51b398a82a77134f5d21a863986403 /backends/cxxrtl/cxxrtl.h | |
parent | b90d51e35ddcb4b25814acac9bf6e09b4478b6ef (diff) | |
parent | b9721bedf01ca1f536bbf13ba761333c6867bd29 (diff) | |
download | yosys-a679a761b51ca67b61dc8b2c7316949b41ef9dd2.tar.gz yosys-a679a761b51ca67b61dc8b2c7316949b41ef9dd2.tar.bz2 yosys-a679a761b51ca67b61dc8b2c7316949b41ef9dd2.zip |
Merge pull request #2496 from whitequark/cxxrtl-fixes
cxxrtl: various improvements
Diffstat (limited to 'backends/cxxrtl/cxxrtl.h')
-rw-r--r-- | backends/cxxrtl/cxxrtl.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/backends/cxxrtl/cxxrtl.h b/backends/cxxrtl/cxxrtl.h index 3c315c7df..0a6bcb849 100644 --- a/backends/cxxrtl/cxxrtl.h +++ b/backends/cxxrtl/cxxrtl.h @@ -317,6 +317,14 @@ struct value : public expr_base<value<Bits>> { return sext_cast<NewBits>()(*this); } + // Bit replication is far more efficient than the equivalent concatenation. + template<size_t Count> + CXXRTL_ALWAYS_INLINE + value<Bits * Count> repeat() const { + static_assert(Bits == 1, "repeat() is implemented only for 1-bit values"); + return *this ? value<Bits * Count>().bit_not() : value<Bits * Count>(); + } + // Operations with run-time parameters (offsets, amounts, etc). // // These operations are used for computations. |