From 93304f3b827eaf03a9d2f1d745b62c57e0a23275 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 12 Dec 2020 08:58:03 -0500 Subject: [PATCH] Internals: Reorder library code. No functional change. --- include/verilated_heavy.h | 78 +++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/include/verilated_heavy.h b/include/verilated_heavy.h index 6dbb3d530..16f63e2d7 100644 --- a/include/verilated_heavy.h +++ b/include/verilated_heavy.h @@ -87,6 +87,45 @@ public: void print(QData addr, bool addrstamp, const void* valuep); }; +//=================================================================== +// Verilog wide-number-in-array container +// Similar to std::array, but lighter weight, only methods needed +// by Verilator, to help compile time. +// +// This is only used when we need an upper-level container and so can't +// simply use a C style array (which is just a pointer). + +template class VlWide final { + WData m_storage[T_Words]; + +public: + // cppcheck-suppress uninitVar + VlWide() = default; + ~VlWide() = default; + VlWide(const VlWide&) = default; + VlWide(VlWide&&) = default; + VlWide& operator=(const VlWide&) = default; + VlWide& operator=(VlWide&&) = default; + // METHODS + const WData& at(size_t index) const { return m_storage[index]; } + WData& at(size_t index) { return m_storage[index]; } + WData* data() { return &m_storage[0]; } + const WData* data() const { return &m_storage[0]; } + bool operator<(const VlWide& rhs) const { + return VL_LT_W(T_Words, data(), rhs.data()); + } +}; + +// Convert a C array to std::array reference by pointer magic, without copy. +// Data type (second argument) is so the function template can automatically generate. +template VlWide& VL_CVT_W_A(WDataInP inp, const VlWide&) { + return *((VlWide*)inp); +} + +template std::string VL_TO_STRING(const VlWide& obj) { + return VL_TO_STRING_W(T_Words, obj.data()); +} + //=================================================================== // Verilog queue and dynamic array container // There are no multithreaded locks on this; the base variable must @@ -444,45 +483,6 @@ template std::string VL_TO_STRING(const VlQueue& obj) { return obj.to_string(); } -//=================================================================== -// Verilog array container -// Similar to std::array, but lighter weight, only methods needed -// by Verilator, to help compile time. -// -// This is only used when we need an upper-level container and so can't -// simply use a C style array (which is just a pointer). - -template class VlWide final { - WData m_storage[T_Words]; - -public: - // cppcheck-suppress uninitVar - VlWide() = default; - ~VlWide() = default; - VlWide(const VlWide&) = default; - VlWide(VlWide&&) = default; - VlWide& operator=(const VlWide&) = default; - VlWide& operator=(VlWide&&) = default; - // METHODS - const WData& at(size_t index) const { return m_storage[index]; } - WData& at(size_t index) { return m_storage[index]; } - WData* data() { return &m_storage[0]; } - const WData* data() const { return &m_storage[0]; } - bool operator<(const VlWide& rhs) const { - return VL_LT_W(T_Words, data(), rhs.data()); - } -}; - -// Convert a C array to std::array reference by pointer magic, without copy. -// Data type (second argument) is so the function template can automatically generate. -template VlWide& VL_CVT_W_A(WDataInP inp, const VlWide&) { - return *((VlWide*)inp); -} - -template std::string VL_TO_STRING(const VlWide& obj) { - return VL_TO_STRING_W(T_Words, obj.data()); -} - //=================================================================== // Verilog associative array container // There are no multithreaded locks on this; the base variable must