3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-06-06 14:13:23 +00:00

cxxrtl: speed up bit repeats (sign extends, etc).

On Minerva SoC SRAM, depending on the compiler, this change improves
overall time by 4-7%.
This commit is contained in:
whitequark 2020-12-21 02:15:55 +00:00
parent 40ca9d038b
commit b9721bedf0
2 changed files with 28 additions and 5 deletions

View file

@ -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.