Adjust loop conditions in VlTriggerVec functions

This change is not a functional one; it is only meant to appease the
compiler with respect to warnings such as GCC's `-Wtype-limits`.

Signed-off-by: Krzysztof Bieganski <kbieganski@antmicro.com>
This commit is contained in:
Krzysztof Bieganski 2022-05-25 12:59:21 +02:00 committed by Geza Lore
parent d7a75dc026
commit 3a310f19f0
1 changed files with 4 additions and 3 deletions

View File

@ -76,6 +76,7 @@ extern std::string VL_TO_STRING_W(int words, const WDataInP obj);
template <std::size_t T_size> // template <std::size_t T_size> //
class VlTriggerVec final { class VlTriggerVec final {
// TODO: static assert T_size > 0, and don't generate when empty
private: private:
// MEMBERS // MEMBERS
std::array<bool, T_size> m_flags; // State of the assoc array std::array<bool, T_size> m_flags; // State of the assoc array
@ -95,19 +96,19 @@ public:
// Return true iff at least one element is set // Return true iff at least one element is set
bool any() const { bool any() const {
for (size_t i = 0; i < T_size; ++i) for (size_t i = 0; i < m_flags.size(); ++i)
if (m_flags[i]) return true; if (m_flags[i]) return true;
return false; return false;
} }
// Set all elements true in 'this' that are set in 'other' // Set all elements true in 'this' that are set in 'other'
void set(const VlTriggerVec<T_size>& other) { void set(const VlTriggerVec<T_size>& other) {
for (size_t i = 0; i < T_size; ++i) m_flags[i] |= other.m_flags[i]; for (size_t i = 0; i < m_flags.size(); ++i) m_flags[i] |= other.m_flags[i];
} }
// Set elements of 'this' to 'a & !b' element-wise // Set elements of 'this' to 'a & !b' element-wise
void andNot(const VlTriggerVec<T_size>& a, const VlTriggerVec<T_size>& b) { void andNot(const VlTriggerVec<T_size>& a, const VlTriggerVec<T_size>& b) {
for (size_t i = 0; i < T_size; ++i) m_flags[i] = a.m_flags[i] & !b.m_flags[i]; for (size_t i = 0; i < m_flags.size(); ++i) m_flags[i] = a.m_flags[i] & !b.m_flags[i];
} }
}; };