Internals: Fix some cppcheck issues. Some dump functions fixed.

This commit is contained in:
Wilson Snyder 2022-07-30 10:01:25 -04:00
parent 1f9323d086
commit b9d7819faa
49 changed files with 192 additions and 174 deletions

View File

@ -326,6 +326,8 @@ CLANGTIDY_FLAGS = -config='' -checks='-fuchsia-*,-cppcoreguidelines-avoid-c-arra
CLANGTIDY_DEP = $(subst .h,.h.tidy,$(CPPCHECK_H)) \ CLANGTIDY_DEP = $(subst .h,.h.tidy,$(CPPCHECK_H)) \
$(subst .cpp,.cpp.tidy,$(CPPCHECK_CPP)) $(subst .cpp,.cpp.tidy,$(CPPCHECK_CPP))
CLANGTIDY_DEFS = -DVL_DEBUG=1 -DVL_THREADED=1 -DVL_CPPCHECK=1 CLANGTIDY_DEFS = -DVL_DEBUG=1 -DVL_THREADED=1 -DVL_CPPCHECK=1
# cppcoreguidelines-avoid-goto modernize-avoid-c-arrays readability-magic-numbers readability-simplify-boolean-expr
# cppcoreguidelines-macro-usage
clang-tidy: $(CLANGTIDY_DEP) clang-tidy: $(CLANGTIDY_DEP)
%.cpp.tidy: %.cpp %.cpp.tidy: %.cpp

View File

@ -679,7 +679,10 @@ std::string _vl_vsformat_time(char* tmp, T ld, int timeunit, bool left, size_t w
if (std::numeric_limits<T>::is_integer) { if (std::numeric_limits<T>::is_integer) {
constexpr int b = 128; constexpr int b = 128;
constexpr int w = VL_WORDS_I(b); constexpr int w = VL_WORDS_I(b);
VlWide<w> tmp0, tmp1, tmp2, tmp3; VlWide<w> tmp0;
VlWide<w> tmp1;
VlWide<w> tmp2;
VlWide<w> tmp3;
WDataInP shifted = VL_EXTEND_WQ(b, 0, tmp0, static_cast<QData>(ld)); WDataInP shifted = VL_EXTEND_WQ(b, 0, tmp0, static_cast<QData>(ld));
if (shift < 0) { if (shift < 0) {

View File

@ -76,15 +76,15 @@ private:
public: public:
// METHODS // METHODS
// cppcheck-suppress truncLongCastReturn // cppcheck-suppress truncLongCastReturn
virtual uint64_t count() const override { return *m_countp; } uint64_t count() const override { return *m_countp; }
virtual void zero() const override { *m_countp = 0; } void zero() const override { *m_countp = 0; }
// CONSTRUCTORS // CONSTRUCTORS
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
explicit VerilatedCoverItemSpec(T* countp) explicit VerilatedCoverItemSpec(T* countp)
: m_countp{countp} { : m_countp{countp} {
*m_countp = 0; *m_countp = 0;
} }
virtual ~VerilatedCoverItemSpec() override = default; ~VerilatedCoverItemSpec() override = default;
}; };
//============================================================================= //=============================================================================
@ -122,7 +122,7 @@ public:
protected: protected:
friend class VerilatedCovContext; friend class VerilatedCovContext;
virtual ~VerilatedCovImp() override { clearGuts(); } ~VerilatedCovImp() override { clearGuts(); }
private: private:
// PRIVATE METHODS // PRIVATE METHODS
@ -511,8 +511,10 @@ VerilatedCovContext* VerilatedCov::threadCovp() VL_MT_SAFE {
VerilatedCovContext* VerilatedContext::coveragep() VL_MT_SAFE { VerilatedCovContext* VerilatedContext::coveragep() VL_MT_SAFE {
static VerilatedMutex s_mutex; static VerilatedMutex s_mutex;
// cppcheck-suppress identicalInnerCondition
if (VL_UNLIKELY(!m_coveragep)) { if (VL_UNLIKELY(!m_coveragep)) {
const VerilatedLockGuard lock{s_mutex}; const VerilatedLockGuard lock{s_mutex};
// cppcheck-suppress identicalInnerCondition
if (VL_LIKELY(!m_coveragep)) { // Not redundant, prevents race if (VL_LIKELY(!m_coveragep)) { // Not redundant, prevents race
m_coveragep.reset(new VerilatedCovImp); m_coveragep.reset(new VerilatedCovImp);
} }

View File

@ -67,18 +67,18 @@ protected:
// Implementation of VerilatedTrace interface // Implementation of VerilatedTrace interface
// Called when the trace moves forward to a new time point // Called when the trace moves forward to a new time point
virtual void emitTimeChange(uint64_t timeui) override; void emitTimeChange(uint64_t timeui) override;
// Hooks called from VerilatedTrace // Hooks called from VerilatedTrace
virtual bool preFullDump() override { return isOpen(); } bool preFullDump() override { return isOpen(); }
virtual bool preChangeDump() override { return isOpen(); } bool preChangeDump() override { return isOpen(); }
// Trace buffer management // Trace buffer management
virtual Buffer* getTraceBuffer() override; Buffer* getTraceBuffer() override;
virtual void commitTraceBuffer(Buffer*) override; void commitTraceBuffer(Buffer*) override;
// Configure sub-class // Configure sub-class
virtual void configure(const VerilatedTraceConfig&) override; void configure(const VerilatedTraceConfig&) override;
public: public:
//========================================================================= //=========================================================================

View File

@ -60,6 +60,7 @@ public:
} }
// Override VerilatedFstC. Must be called after starting simulation. // Override VerilatedFstC. Must be called after starting simulation.
// cppcheck-suppress missingOverride // GCC won't accept override
virtual void open(const char* filename) /*override*/ VL_MT_SAFE; virtual void open(const char* filename) /*override*/ VL_MT_SAFE;
private: private:

View File

@ -194,16 +194,16 @@ public:
/// Construct new object /// Construct new object
VerilatedSave() = default; VerilatedSave() = default;
/// Flush, close and destruct /// Flush, close and destruct
virtual ~VerilatedSave() override { close(); } ~VerilatedSave() override { close(); }
// METHODS // METHODS
/// Open the file; call isOpen() to see if errors /// Open the file; call isOpen() to see if errors
void open(const char* filenamep) VL_MT_UNSAFE_ONE; void open(const char* filenamep) VL_MT_UNSAFE_ONE;
/// Open the file; call isOpen() to see if errors /// Open the file; call isOpen() to see if errors
void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); } void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); }
/// Flush and close the file /// Flush and close the file
virtual void close() override VL_MT_UNSAFE_ONE; void close() override VL_MT_UNSAFE_ONE;
/// Flush data to file /// Flush data to file
virtual void flush() override VL_MT_UNSAFE_ONE; void flush() override VL_MT_UNSAFE_ONE;
}; };
//============================================================================= //=============================================================================
@ -221,7 +221,7 @@ public:
/// Construct new object /// Construct new object
VerilatedRestore() = default; VerilatedRestore() = default;
/// Flush, close and destruct /// Flush, close and destruct
virtual ~VerilatedRestore() override { close(); } ~VerilatedRestore() override { close(); }
// METHODS // METHODS
/// Open the file; call isOpen() to see if errors /// Open the file; call isOpen() to see if errors
@ -229,9 +229,9 @@ public:
/// Open the file; call isOpen() to see if errors /// Open the file; call isOpen() to see if errors
void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); } void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); }
/// Close the file /// Close the file
virtual void close() override VL_MT_UNSAFE_ONE; void close() override VL_MT_UNSAFE_ONE;
virtual void flush() override VL_MT_UNSAFE_ONE {} void flush() override VL_MT_UNSAFE_ONE {}
virtual void fill() override VL_MT_UNSAFE_ONE; void fill() override VL_MT_UNSAFE_ONE;
}; };
//============================================================================= //=============================================================================

View File

@ -91,9 +91,9 @@ class VlReadMem final {
const int m_bits; // Bit width of values const int m_bits; // Bit width of values
const std::string& m_filename; // Filename const std::string& m_filename; // Filename
const QData m_end; // End address (as specified by user) const QData m_end; // End address (as specified by user)
FILE* m_fp; // File handle for filename FILE* m_fp = nullptr; // File handle for filename
QData m_addr; // Next address to read QData m_addr = 0; // Next address to read
int m_linenum; // Line number last read from file int m_linenum = 0; // Line number last read from file
bool m_anyAddr = false; // Had address directive in the file bool m_anyAddr = false; // Had address directive in the file
public: public:
VlReadMem(bool hex, int bits, const std::string& filename, QData start, QData end); VlReadMem(bool hex, int bits, const std::string& filename, QData start, QData end);
@ -107,8 +107,8 @@ public:
class VlWriteMem final { class VlWriteMem final {
const bool m_hex; // Hex format const bool m_hex; // Hex format
const int m_bits; // Bit width of values const int m_bits; // Bit width of values
FILE* m_fp; // File handle for filename FILE* m_fp = nullptr; // File handle for filename
QData m_addr; // Next address to write QData m_addr = 0; // Next address to write
public: public:
VlWriteMem(bool hex, int bits, const std::string& filename, QData start, QData end); VlWriteMem(bool hex, int bits, const std::string& filename, QData start, QData end);
~VlWriteMem(); ~VlWriteMem();

View File

@ -102,18 +102,18 @@ protected:
// Implementation of VerilatedTrace interface // Implementation of VerilatedTrace interface
// Called when the trace moves forward to a new time point // Called when the trace moves forward to a new time point
virtual void emitTimeChange(uint64_t timeui) override; void emitTimeChange(uint64_t timeui) override;
// Hooks called from VerilatedTrace // Hooks called from VerilatedTrace
virtual bool preFullDump() override { return isOpen(); } bool preFullDump() override { return isOpen(); }
virtual bool preChangeDump() override; bool preChangeDump() override;
// Trace buffer management // Trace buffer management
virtual Buffer* getTraceBuffer() override; Buffer* getTraceBuffer() override;
virtual void commitTraceBuffer(Buffer*) override; void commitTraceBuffer(Buffer*) override;
// Configure sub-class // Configure sub-class
virtual void configure(const VerilatedTraceConfig&) override { return; }; void configure(const VerilatedTraceConfig&) override { return; };
public: public:
//========================================================================= //=========================================================================

View File

@ -63,6 +63,7 @@ public:
} }
// Override VerilatedVcdC. Must be called after starting simulation. // Override VerilatedVcdC. Must be called after starting simulation.
// cppcheck-suppress missingOverride // GCC won't accept override
virtual void open(const char* filename) /*override*/ VL_MT_SAFE; virtual void open(const char* filename) /*override*/ VL_MT_SAFE;
private: private:

View File

@ -135,12 +135,12 @@ public:
VerilatedVpioTimedCb(uint64_t id, QData time) VerilatedVpioTimedCb(uint64_t id, QData time)
: m_id{id} : m_id{id}
, m_time{time} {} , m_time{time} {}
virtual ~VerilatedVpioTimedCb() override = default; ~VerilatedVpioTimedCb() override = default;
static VerilatedVpioTimedCb* castp(vpiHandle h) { static VerilatedVpioTimedCb* castp(vpiHandle h) {
return dynamic_cast<VerilatedVpioTimedCb*>(reinterpret_cast<VerilatedVpioTimedCb*>(h)); return dynamic_cast<VerilatedVpioTimedCb*>(reinterpret_cast<VerilatedVpioTimedCb*>(h));
} }
virtual uint32_t type() const override { return vpiCallback; } uint32_t type() const override { return vpiCallback; }
virtual PLI_INT32 dovpi_remove_cb() override; PLI_INT32 dovpi_remove_cb() override;
}; };
class VerilatedVpioReasonCb final : public VerilatedVpio { class VerilatedVpioReasonCb final : public VerilatedVpio {
@ -154,12 +154,12 @@ public:
VerilatedVpioReasonCb(uint64_t id, PLI_INT32 reason) VerilatedVpioReasonCb(uint64_t id, PLI_INT32 reason)
: m_id{id} : m_id{id}
, m_reason{reason} {} , m_reason{reason} {}
virtual ~VerilatedVpioReasonCb() override = default; ~VerilatedVpioReasonCb() override = default;
static VerilatedVpioReasonCb* castp(vpiHandle h) { static VerilatedVpioReasonCb* castp(vpiHandle h) {
return dynamic_cast<VerilatedVpioReasonCb*>(reinterpret_cast<VerilatedVpioReasonCb*>(h)); return dynamic_cast<VerilatedVpioReasonCb*>(reinterpret_cast<VerilatedVpioReasonCb*>(h));
} }
virtual uint32_t type() const override { return vpiCallback; } uint32_t type() const override { return vpiCallback; }
virtual PLI_INT32 dovpi_remove_cb() override; PLI_INT32 dovpi_remove_cb() override;
}; };
class VerilatedVpioConst final : public VerilatedVpio { class VerilatedVpioConst final : public VerilatedVpio {
@ -168,11 +168,11 @@ class VerilatedVpioConst final : public VerilatedVpio {
public: public:
explicit VerilatedVpioConst(int32_t num) explicit VerilatedVpioConst(int32_t num)
: m_num{num} {} : m_num{num} {}
virtual ~VerilatedVpioConst() override = default; ~VerilatedVpioConst() override = default;
static VerilatedVpioConst* castp(vpiHandle h) { static VerilatedVpioConst* castp(vpiHandle h) {
return dynamic_cast<VerilatedVpioConst*>(reinterpret_cast<VerilatedVpio*>(h)); return dynamic_cast<VerilatedVpioConst*>(reinterpret_cast<VerilatedVpio*>(h));
} }
virtual uint32_t type() const override { return vpiConstant; } uint32_t type() const override { return vpiConstant; }
int32_t num() const { return m_num; } int32_t num() const { return m_num; }
}; };
@ -200,10 +200,10 @@ public:
} }
const VerilatedVar* varp() const { return m_varp; } const VerilatedVar* varp() const { return m_varp; }
const VerilatedScope* scopep() const { return m_scopep; } const VerilatedScope* scopep() const { return m_scopep; }
virtual uint32_t size() const override { return get_range().elements(); } uint32_t size() const override { return get_range().elements(); }
virtual const VerilatedRange* rangep() const override { return &get_range(); } const VerilatedRange* rangep() const override { return &get_range(); }
virtual const char* name() const override { return m_varp->name(); } const char* name() const override { return m_varp->name(); }
virtual const char* fullname() const override { const char* fullname() const override {
static VL_THREAD_LOCAL std::string t_out; static VL_THREAD_LOCAL std::string t_out;
t_out = std::string{m_scopep->name()} + "." + name(); t_out = std::string{m_scopep->name()} + "." + name();
return t_out.c_str(); return t_out.c_str();
@ -214,12 +214,12 @@ class VerilatedVpioParam final : public VerilatedVpioVarBase {
public: public:
VerilatedVpioParam(const VerilatedVar* varp, const VerilatedScope* scopep) VerilatedVpioParam(const VerilatedVar* varp, const VerilatedScope* scopep)
: VerilatedVpioVarBase{varp, scopep} {} : VerilatedVpioVarBase{varp, scopep} {}
virtual ~VerilatedVpioParam() override = default; ~VerilatedVpioParam() override = default;
static VerilatedVpioParam* castp(vpiHandle h) { static VerilatedVpioParam* castp(vpiHandle h) {
return dynamic_cast<VerilatedVpioParam*>(reinterpret_cast<VerilatedVpio*>(h)); return dynamic_cast<VerilatedVpioParam*>(reinterpret_cast<VerilatedVpio*>(h));
} }
virtual uint32_t type() const override { return vpiParameter; } uint32_t type() const override { return vpiParameter; }
void* varDatap() const { return m_varp->datap(); } void* varDatap() const { return m_varp->datap(); }
}; };
@ -229,13 +229,13 @@ class VerilatedVpioRange final : public VerilatedVpio {
public: public:
explicit VerilatedVpioRange(const VerilatedRange* range) explicit VerilatedVpioRange(const VerilatedRange* range)
: m_range{range} {} : m_range{range} {}
virtual ~VerilatedVpioRange() override = default; ~VerilatedVpioRange() override = default;
static VerilatedVpioRange* castp(vpiHandle h) { static VerilatedVpioRange* castp(vpiHandle h) {
return dynamic_cast<VerilatedVpioRange*>(reinterpret_cast<VerilatedVpio*>(h)); return dynamic_cast<VerilatedVpioRange*>(reinterpret_cast<VerilatedVpio*>(h));
} }
virtual uint32_t type() const override { return vpiRange; } uint32_t type() const override { return vpiRange; }
virtual uint32_t size() const override { return m_range->elements(); } uint32_t size() const override { return m_range->elements(); }
virtual const VerilatedRange* rangep() const override { return m_range; } const VerilatedRange* rangep() const override { return m_range; }
}; };
class VerilatedVpioRangeIter final : public VerilatedVpio { class VerilatedVpioRangeIter final : public VerilatedVpio {
@ -246,12 +246,12 @@ class VerilatedVpioRangeIter final : public VerilatedVpio {
public: public:
explicit VerilatedVpioRangeIter(const VerilatedRange* range) explicit VerilatedVpioRangeIter(const VerilatedRange* range)
: m_range{range} {} : m_range{range} {}
virtual ~VerilatedVpioRangeIter() override = default; ~VerilatedVpioRangeIter() override = default;
static VerilatedVpioRangeIter* castp(vpiHandle h) { static VerilatedVpioRangeIter* castp(vpiHandle h) {
return dynamic_cast<VerilatedVpioRangeIter*>(reinterpret_cast<VerilatedVpio*>(h)); return dynamic_cast<VerilatedVpioRangeIter*>(reinterpret_cast<VerilatedVpio*>(h));
} }
virtual uint32_t type() const override { return vpiIterator; } uint32_t type() const override { return vpiIterator; }
virtual vpiHandle dovpi_scan() override { vpiHandle dovpi_scan() override {
if (VL_UNLIKELY(m_done)) { if (VL_UNLIKELY(m_done)) {
delete this; // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle delete this; // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle
return nullptr; return nullptr;
@ -268,14 +268,14 @@ protected:
public: public:
explicit VerilatedVpioScope(const VerilatedScope* scopep) explicit VerilatedVpioScope(const VerilatedScope* scopep)
: m_scopep{scopep} {} : m_scopep{scopep} {}
virtual ~VerilatedVpioScope() override = default; ~VerilatedVpioScope() override = default;
static VerilatedVpioScope* castp(vpiHandle h) { static VerilatedVpioScope* castp(vpiHandle h) {
return dynamic_cast<VerilatedVpioScope*>(reinterpret_cast<VerilatedVpio*>(h)); return dynamic_cast<VerilatedVpioScope*>(reinterpret_cast<VerilatedVpio*>(h));
} }
virtual uint32_t type() const override { return vpiScope; } uint32_t type() const override { return vpiScope; }
const VerilatedScope* scopep() const { return m_scopep; } const VerilatedScope* scopep() const { return m_scopep; }
virtual const char* name() const override { return m_scopep->name(); } const char* name() const override { return m_scopep->name(); }
virtual const char* fullname() const override { return m_scopep->name(); } const char* fullname() const override { return m_scopep->name(); }
}; };
class VerilatedVpioVar VL_NOT_FINAL : public VerilatedVpioVarBase { class VerilatedVpioVar VL_NOT_FINAL : public VerilatedVpioVarBase {
@ -308,7 +308,7 @@ public:
m_mask.u32 = 0; m_mask.u32 = 0;
} }
} }
virtual ~VerilatedVpioVar() override { ~VerilatedVpioVar() override {
if (m_prevDatap) VL_DO_CLEAR(delete[] m_prevDatap, m_prevDatap = nullptr); if (m_prevDatap) VL_DO_CLEAR(delete[] m_prevDatap, m_prevDatap = nullptr);
} }
static VerilatedVpioVar* castp(vpiHandle h) { static VerilatedVpioVar* castp(vpiHandle h) {
@ -318,7 +318,7 @@ public:
uint8_t mask_byte(int idx) const { return m_mask.u8[idx & 3]; } uint8_t mask_byte(int idx) const { return m_mask.u8[idx & 3]; }
uint32_t entSize() const { return m_entSize; } uint32_t entSize() const { return m_entSize; }
uint32_t index() const { return m_index; } uint32_t index() const { return m_index; }
virtual uint32_t type() const override { uint32_t type() const override {
return (varp()->dims() > 1) ? vpiMemory : vpiReg; // but might be wire, logic return (varp()->dims() > 1) ? vpiMemory : vpiReg; // but might be wire, logic
} }
void* prevDatap() const { return m_prevDatap; } void* prevDatap() const { return m_prevDatap; }
@ -339,14 +339,14 @@ public:
m_index = index; m_index = index;
m_varDatap = (static_cast<uint8_t*>(varp->datap())) + entSize() * offset; m_varDatap = (static_cast<uint8_t*>(varp->datap())) + entSize() * offset;
} }
virtual ~VerilatedVpioMemoryWord() override = default; ~VerilatedVpioMemoryWord() override = default;
static VerilatedVpioMemoryWord* castp(vpiHandle h) { static VerilatedVpioMemoryWord* castp(vpiHandle h) {
return dynamic_cast<VerilatedVpioMemoryWord*>(reinterpret_cast<VerilatedVpio*>(h)); return dynamic_cast<VerilatedVpioMemoryWord*>(reinterpret_cast<VerilatedVpio*>(h));
} }
virtual uint32_t type() const override { return vpiMemoryWord; } uint32_t type() const override { return vpiMemoryWord; }
virtual uint32_t size() const override { return varp()->packed().elements(); } uint32_t size() const override { return varp()->packed().elements(); }
virtual const VerilatedRange* rangep() const override { return &(varp()->packed()); } const VerilatedRange* rangep() const override { return &(varp()->packed()); }
virtual const char* fullname() const override { const char* fullname() const override {
static VL_THREAD_LOCAL std::string t_out; static VL_THREAD_LOCAL std::string t_out;
constexpr size_t LEN_MAX_INDEX = 25; constexpr size_t LEN_MAX_INDEX = 25;
char num[LEN_MAX_INDEX]; char num[LEN_MAX_INDEX];
@ -364,12 +364,12 @@ class VerilatedVpioVarIter final : public VerilatedVpio {
public: public:
explicit VerilatedVpioVarIter(const VerilatedScope* scopep) explicit VerilatedVpioVarIter(const VerilatedScope* scopep)
: m_scopep{scopep} {} : m_scopep{scopep} {}
virtual ~VerilatedVpioVarIter() override = default; ~VerilatedVpioVarIter() override = default;
static VerilatedVpioVarIter* castp(vpiHandle h) { static VerilatedVpioVarIter* castp(vpiHandle h) {
return dynamic_cast<VerilatedVpioVarIter*>(reinterpret_cast<VerilatedVpio*>(h)); return dynamic_cast<VerilatedVpioVarIter*>(reinterpret_cast<VerilatedVpio*>(h));
} }
virtual uint32_t type() const override { return vpiIterator; } uint32_t type() const override { return vpiIterator; }
virtual vpiHandle dovpi_scan() override { vpiHandle dovpi_scan() override {
if (VL_LIKELY(m_scopep->varsp())) { if (VL_LIKELY(m_scopep->varsp())) {
const VerilatedVarNameMap* const varsp = m_scopep->varsp(); const VerilatedVarNameMap* const varsp = m_scopep->varsp();
if (VL_UNLIKELY(!m_started)) { if (VL_UNLIKELY(!m_started)) {
@ -405,15 +405,15 @@ public:
, m_varp{varp} , m_varp{varp}
, m_iteration{varp->unpacked().right()} , m_iteration{varp->unpacked().right()}
, m_direction{VL_LIKELY(varp->unpacked().left() > varp->unpacked().right()) ? 1 : -1} {} , m_direction{VL_LIKELY(varp->unpacked().left() > varp->unpacked().right()) ? 1 : -1} {}
virtual ~VerilatedVpioMemoryWordIter() override = default; ~VerilatedVpioMemoryWordIter() override = default;
static VerilatedVpioMemoryWordIter* castp(vpiHandle h) { static VerilatedVpioMemoryWordIter* castp(vpiHandle h) {
return dynamic_cast<VerilatedVpioMemoryWordIter*>(reinterpret_cast<VerilatedVpio*>(h)); return dynamic_cast<VerilatedVpioMemoryWordIter*>(reinterpret_cast<VerilatedVpio*>(h));
} }
virtual uint32_t type() const override { return vpiIterator; } uint32_t type() const override { return vpiIterator; }
void iterationInc() { void iterationInc() {
if (!(m_done = (m_iteration == m_varp->unpacked().left()))) m_iteration += m_direction; if (!(m_done = (m_iteration == m_varp->unpacked().left()))) m_iteration += m_direction;
} }
virtual vpiHandle dovpi_scan() override { vpiHandle dovpi_scan() override {
if (VL_UNLIKELY(m_done)) { if (VL_UNLIKELY(m_done)) {
delete this; // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle delete this; // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle
return nullptr; return nullptr;
@ -438,9 +438,9 @@ public:
static VerilatedVpioModule* castp(vpiHandle h) { static VerilatedVpioModule* castp(vpiHandle h) {
return dynamic_cast<VerilatedVpioModule*>(reinterpret_cast<VerilatedVpio*>(h)); return dynamic_cast<VerilatedVpioModule*>(reinterpret_cast<VerilatedVpio*>(h));
} }
virtual uint32_t type() const override { return vpiModule; } uint32_t type() const override { return vpiModule; }
virtual const char* name() const override { return m_name; } const char* name() const override { return m_name; }
virtual const char* fullname() const override { return m_fullname; } const char* fullname() const override { return m_fullname; }
}; };
class VerilatedVpioModuleIter final : public VerilatedVpio { class VerilatedVpioModuleIter final : public VerilatedVpio {
@ -452,12 +452,12 @@ public:
: m_vec{&vec} { : m_vec{&vec} {
m_it = m_vec->begin(); m_it = m_vec->begin();
} }
virtual ~VerilatedVpioModuleIter() override = default; ~VerilatedVpioModuleIter() override = default;
static VerilatedVpioModuleIter* castp(vpiHandle h) { static VerilatedVpioModuleIter* castp(vpiHandle h) {
return dynamic_cast<VerilatedVpioModuleIter*>(reinterpret_cast<VerilatedVpio*>(h)); return dynamic_cast<VerilatedVpioModuleIter*>(reinterpret_cast<VerilatedVpio*>(h));
} }
virtual uint32_t type() const override { return vpiIterator; } uint32_t type() const override { return vpiIterator; }
virtual vpiHandle dovpi_scan() override { vpiHandle dovpi_scan() override {
if (m_it == m_vec->end()) { if (m_it == m_vec->end()) {
delete this; // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle delete this; // IEEE 37.2.2 vpi_scan at end does a vpi_release_handle
return nullptr; return nullptr;

View File

@ -456,7 +456,8 @@ using ssize_t = uint32_t; ///< signed size_t; returned from read()
// or 0x0 if not implemented on this platform // or 0x0 if not implemented on this platform
#define VL_GET_CPU_TICK(val) \ #define VL_GET_CPU_TICK(val) \
{ \ { \
uint32_t hi, lo; \ uint32_t hi; \
uint32_t lo; \
asm volatile("rdtsc" : "=a"(lo), "=d"(hi)); \ asm volatile("rdtsc" : "=a"(lo), "=d"(hi)); \
(val) = ((uint64_t)lo) | (((uint64_t)hi) << 32); \ (val) = ((uint64_t)lo) | (((uint64_t)hi) << 32); \
} }

View File

@ -75,7 +75,7 @@ public:
class LatchDetectGraph final : public V3Graph { class LatchDetectGraph final : public V3Graph {
protected: protected:
LatchDetectGraphVertex* m_curVertexp; // Current latch detection graph vertex LatchDetectGraphVertex* m_curVertexp = nullptr; // Current latch detection graph vertex
std::vector<AstVarRef*> m_outputs; // Vector of lvalues encountered on this pass std::vector<AstVarRef*> m_outputs; // Vector of lvalues encountered on this pass
VL_DEBUG_FUNC; // Declare debug() VL_DEBUG_FUNC; // Declare debug()
@ -290,13 +290,13 @@ private:
// STATE // STATE
LatchDetectGraph m_graph; // Graph used to detect latches in combo always LatchDetectGraph m_graph; // Graph used to detect latches in combo always
// VISITORS // VISITORS
virtual void visit(AstVarRef* nodep) { virtual void visit(AstVarRef* nodep) override {
const AstVar* const varp = nodep->varp(); const AstVar* const varp = nodep->varp();
if (nodep->access().isWriteOrRW() && varp->isSignal() && !varp->isUsedLoopIdx()) { if (nodep->access().isWriteOrRW() && varp->isSignal() && !varp->isUsedLoopIdx()) {
m_graph.addAssignment(nodep); m_graph.addAssignment(nodep);
} }
} }
virtual void visit(AstNodeIf* nodep) { virtual void visit(AstNodeIf* nodep) override {
if (!nodep->isBoundsCheck()) { if (!nodep->isBoundsCheck()) {
LatchDetectGraphVertex* const parentp = m_graph.currentp(); LatchDetectGraphVertex* const parentp = m_graph.currentp();
LatchDetectGraphVertex* const branchp = m_graph.addPathVertex(parentp, "BRANCH", true); LatchDetectGraphVertex* const branchp = m_graph.addPathVertex(parentp, "BRANCH", true);
@ -308,7 +308,7 @@ private:
} }
} }
//-------------------- //--------------------
virtual void visit(AstNode* nodep) { iterateChildren(nodep); } virtual void visit(AstNode* nodep) override { iterateChildren(nodep); }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
@ -317,7 +317,7 @@ public:
iterate(nodep); iterate(nodep);
m_graph.latchCheck(nodep, kwd == VAlwaysKwd::ALWAYS_LATCH); m_graph.latchCheck(nodep, kwd == VAlwaysKwd::ALWAYS_LATCH);
} }
virtual ~ActiveLatchCheckVisitor() = default; ~ActiveLatchCheckVisitor() override = default;
}; };
//###################################################################### //######################################################################
@ -387,7 +387,7 @@ public:
: m_check{check} { : m_check{check} {
iterate(nodep); iterate(nodep);
} }
virtual ~ActiveDlyVisitor() override = default; ~ActiveDlyVisitor() override = default;
}; };
//###################################################################### //######################################################################
@ -530,7 +530,7 @@ private:
// Warn and/or convert any delayed assignments // Warn and/or convert any delayed assignments
if (combo && !sequent) { if (combo && !sequent) {
ActiveDlyVisitor{nodep, ActiveDlyVisitor::CT_COMB}; { ActiveDlyVisitor{nodep, ActiveDlyVisitor::CT_COMB}; }
const ActiveLatchCheckVisitor latchvisitor{nodep, kwd}; const ActiveLatchCheckVisitor latchvisitor{nodep, kwd};
} else if (!combo && sequent) { } else if (!combo && sequent) {
ActiveDlyVisitor{nodep, ActiveDlyVisitor::CT_SEQ}; ActiveDlyVisitor{nodep, ActiveDlyVisitor::CT_SEQ};
@ -598,7 +598,7 @@ private:
public: public:
// CONSTRUCTORS // CONSTRUCTORS
explicit ActiveVisitor(AstNetlist* nodep) { iterate(nodep); } explicit ActiveVisitor(AstNetlist* nodep) { iterate(nodep); }
virtual ~ActiveVisitor() override = default; ~ActiveVisitor() override = default;
}; };
//###################################################################### //######################################################################

View File

@ -2605,7 +2605,7 @@ protected:
: AstNodeMath{t, fl} : AstNodeMath{t, fl}
, m_access{access} , m_access{access}
, m_name{name} { , m_name{name} {
this->varp(nullptr); varp(nullptr);
} }
AstNodeVarRef(VNType t, FileLine* fl, const string& name, AstVar* varp, const VAccess& access) AstNodeVarRef(VNType t, FileLine* fl, const string& name, AstVar* varp, const VAccess& access)
: AstNodeMath{t, fl} : AstNodeMath{t, fl}

View File

@ -489,7 +489,7 @@ string AstVar::cPubArgType(bool named, bool forReturn) const {
class dpiTypesToStringConverter VL_NOT_FINAL { class dpiTypesToStringConverter VL_NOT_FINAL {
public: public:
virtual string openArray(const AstVar*) const { return "const svOpenArrayHandle"; } virtual string openArray(const AstVar*) const { return "const svOpenArrayHandle"; }
virtual string bitLogicVector(const AstVar* varp, bool isBit) const { virtual string bitLogicVector(const AstVar* /*varp*/, bool isBit) const {
return isBit ? "svBitVecVal" : "svLogicVecVal"; return isBit ? "svBitVecVal" : "svLogicVecVal";
} }
virtual string primitive(const AstVar* varp) const { virtual string primitive(const AstVar* varp) const {
@ -659,7 +659,7 @@ public:
} }
}; };
string AstNodeDType::cType(const string& name, bool forFunc, bool isRef) const { string AstNodeDType::cType(const string& name, bool /*forFunc*/, bool isRef) const {
const CTypeRecursed info = cTypeRecurse(false); const CTypeRecursed info = cTypeRecurse(false);
return info.render(name, isRef); return info.render(name, isRef);
} }
@ -1326,8 +1326,9 @@ void AstClass::repairCache() {
clearCache(); clearCache();
for (auto* itemp = membersp(); itemp; itemp = itemp->nextp()) { for (auto* itemp = membersp(); itemp; itemp = itemp->nextp()) {
if (const auto* const scopep = VN_CAST(itemp, Scope)) { if (const auto* const scopep = VN_CAST(itemp, Scope)) {
for (auto* itemp = scopep->blocksp(); itemp; itemp = itemp->nextp()) for (auto* blockp = scopep->blocksp(); blockp; blockp = blockp->nextp()) {
insertCache(itemp); insertCache(blockp);
}
} else { } else {
insertCache(itemp); insertCache(itemp);
} }
@ -1354,7 +1355,7 @@ AstClass* AstClassExtends::classp() const {
return refp->classp(); return refp->classp();
} }
void AstClassRefDType::dump(std::ostream& str) const { void AstClassRefDType::dump(std::ostream& str) const {
this->AstNode::dump(str); this->AstNodeDType::dump(str);
if (classOrPackagep()) str << " cpkg=" << nodeAddr(classOrPackagep()); if (classOrPackagep()) str << " cpkg=" << nodeAddr(classOrPackagep());
if (classp()) { if (classp()) {
str << " -> "; str << " -> ";
@ -1385,7 +1386,7 @@ void AstEnumItemRef::dump(std::ostream& str) const {
} }
} }
void AstIfaceRefDType::dump(std::ostream& str) const { void AstIfaceRefDType::dump(std::ostream& str) const {
this->AstNode::dump(str); this->AstNodeDType::dump(str);
if (cellName() != "") str << " cell=" << cellName(); if (cellName() != "") str << " cell=" << cellName();
if (ifaceName() != "") str << " if=" << ifaceName(); if (ifaceName() != "") str << " if=" << ifaceName();
if (modportName() != "") str << " mp=" << modportName(); if (modportName() != "") str << " mp=" << modportName();
@ -1434,7 +1435,7 @@ void AstJumpLabel::dump(std::ostream& str) const {
} }
} }
void AstLogOr::dump(std::ostream& str) const { void AstLogOr::dump(std::ostream& str) const {
this->AstNode::dump(str); this->AstNodeMath::dump(str);
if (sideEffect()) str << " [SIDE]"; if (sideEffect()) str << " [SIDE]";
} }
void AstMemberSel::dump(std::ostream& str) const { void AstMemberSel::dump(std::ostream& str) const {
@ -1447,7 +1448,7 @@ void AstMemberSel::dump(std::ostream& str) const {
} }
} }
void AstMethodCall::dump(std::ostream& str) const { void AstMethodCall::dump(std::ostream& str) const {
this->AstNodeStmt::dump(str); this->AstNodeFTaskRef::dump(str);
if (isStatement()) str << " [STMT]"; if (isStatement()) str << " [STMT]";
str << " -> "; str << " -> ";
if (taskp()) { if (taskp()) {
@ -1533,7 +1534,7 @@ void AstRefDType::dump(std::ostream& str) const {
} }
} }
void AstNodeUOrStructDType::dump(std::ostream& str) const { void AstNodeUOrStructDType::dump(std::ostream& str) const {
this->AstNode::dump(str); this->AstNodeDType::dump(str);
if (packed()) str << " [PACKED]"; if (packed()) str << " [PACKED]";
if (isFourstate()) str << " [4STATE]"; if (isFourstate()) str << " [4STATE]";
} }
@ -1624,7 +1625,7 @@ void AstPackageImport::dump(std::ostream& str) const {
str << " -> " << packagep(); str << " -> " << packagep();
} }
void AstPatMember::dump(std::ostream& str) const { void AstPatMember::dump(std::ostream& str) const {
this->AstNode::dump(str); this->AstNodeMath::dump(str);
if (isDefault()) str << " [DEFAULT]"; if (isDefault()) str << " [DEFAULT]";
} }
void AstNodeTriop::dump(std::ostream& str) const { this->AstNodeMath::dump(str); } void AstNodeTriop::dump(std::ostream& str) const { this->AstNodeMath::dump(str); }
@ -1773,7 +1774,7 @@ void AstScope::dump(std::ostream& str) const {
str << " [modp=" << reinterpret_cast<const void*>(modp()) << "]"; str << " [modp=" << reinterpret_cast<const void*>(modp()) << "]";
} }
void AstScopeName::dump(std::ostream& str) const { void AstScopeName::dump(std::ostream& str) const {
this->AstNode::dump(str); this->AstNodeMath::dump(str);
if (dpiExport()) str << " [DPIEX]"; if (dpiExport()) str << " [DPIEX]";
if (forFormat()) str << " [FMT]"; if (forFormat()) str << " [FMT]";
} }
@ -1840,7 +1841,7 @@ void AstNodeBlock::dump(std::ostream& str) const {
if (unnamed()) str << " [UNNAMED]"; if (unnamed()) str << " [UNNAMED]";
} }
void AstBegin::dump(std::ostream& str) const { void AstBegin::dump(std::ostream& str) const {
this->AstNode::dump(str); this->AstNodeBlock::dump(str);
if (generate()) str << " [GEN]"; if (generate()) str << " [GEN]";
if (genforp()) str << " [GENFOR]"; if (genforp()) str << " [GENFOR]";
if (implied()) str << " [IMPLIED]"; if (implied()) str << " [IMPLIED]";
@ -1866,7 +1867,7 @@ void AstCoverInc::dump(std::ostream& str) const {
} }
} }
void AstFork::dump(std::ostream& str) const { void AstFork::dump(std::ostream& str) const {
this->AstNode::dump(str); this->AstNodeBlock::dump(str);
if (!joinType().join()) str << " [" << joinType() << "]"; if (!joinType().join()) str << " [" << joinType() << "]";
} }
void AstTraceDecl::dump(std::ostream& str) const { void AstTraceDecl::dump(std::ostream& str) const {

View File

@ -186,7 +186,7 @@ public:
class AstEmpty final : public AstNode { class AstEmpty final : public AstNode {
// Represents something missing, e.g. a missing argument in FOREACH // Represents something missing, e.g. a missing argument in FOREACH
public: public:
AstEmpty(FileLine* fl) explicit AstEmpty(FileLine* fl)
: ASTGEN_SUPER_Empty(fl) {} : ASTGEN_SUPER_Empty(fl) {}
ASTNODE_NODE_FUNCS(Empty) ASTNODE_NODE_FUNCS(Empty)
virtual bool same(const AstNode* samep) const override { return true; } virtual bool same(const AstNode* samep) const override { return true; }
@ -194,7 +194,7 @@ public:
class AstEmptyQueue final : public AstNodeMath { class AstEmptyQueue final : public AstNodeMath {
public: public:
AstEmptyQueue(FileLine* fl) explicit AstEmptyQueue(FileLine* fl)
: ASTGEN_SUPER_EmptyQueue(fl) {} : ASTGEN_SUPER_EmptyQueue(fl) {}
ASTNODE_NODE_FUNCS(EmptyQueue) ASTNODE_NODE_FUNCS(EmptyQueue)
virtual string emitC() override { V3ERROR_NA_RETURN(""); } virtual string emitC() override { V3ERROR_NA_RETURN(""); }

View File

@ -48,7 +48,7 @@ static class BrokenCntGlobal {
uint8_t m_count = MIN_VALUE; uint8_t m_count = MIN_VALUE;
public: public:
uint8_t get() { uint8_t get() const {
UASSERT(MIN_VALUE <= m_count && m_count <= MAX_VALUE, "Invalid generation number"); UASSERT(MIN_VALUE <= m_count && m_count <= MAX_VALUE, "Invalid generation number");
return m_count; return m_count;
} }

View File

@ -115,13 +115,13 @@ private:
// Move later, or we wouldn't keep interating the class // Move later, or we wouldn't keep interating the class
// We're really moving the VarScope but we might not // We're really moving the VarScope but we might not
// have a pointer to it yet // have a pointer to it yet
m_toScopeMoves.push_back(std::make_pair(nodep, m_packageScopep)); m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep));
} }
if (!m_ftaskp && nodep->lifetime().isStatic()) { if (!m_ftaskp && nodep->lifetime().isStatic()) {
m_toPackageMoves.push_back(std::make_pair(nodep, m_classPackagep)); m_toPackageMoves.emplace_back(std::make_pair(nodep, m_classPackagep));
// We're really moving the VarScope but we might not // We're really moving the VarScope but we might not
// have a pointer to it yet // have a pointer to it yet
m_toScopeMoves.push_back(std::make_pair(nodep, m_packageScopep)); m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep));
} }
} }
} }
@ -137,7 +137,7 @@ private:
m_ftaskp = nodep; m_ftaskp = nodep;
iterateChildren(nodep); iterateChildren(nodep);
if (m_packageScopep && nodep->lifetime().isStatic()) { if (m_packageScopep && nodep->lifetime().isStatic()) {
m_toScopeMoves.push_back(std::make_pair(nodep, m_packageScopep)); m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep));
} }
} }
} }
@ -152,12 +152,16 @@ private:
virtual void visit(AstInitial* nodep) override { virtual void visit(AstInitial* nodep) override {
// But not AstInitialAutomatic, which remains under the class // But not AstInitialAutomatic, which remains under the class
iterateChildren(nodep); iterateChildren(nodep);
if (m_packageScopep) { m_toScopeMoves.push_back(std::make_pair(nodep, m_packageScopep)); } if (m_packageScopep) {
m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep));
}
} }
virtual void visit(AstInitialStatic* nodep) override { virtual void visit(AstInitialStatic* nodep) override {
// But not AstInitialAutomatic, which remains under the class // But not AstInitialAutomatic, which remains under the class
iterateChildren(nodep); iterateChildren(nodep);
if (m_packageScopep) { m_toScopeMoves.push_back(std::make_pair(nodep, m_packageScopep)); } if (m_packageScopep) {
m_toScopeMoves.emplace_back(std::make_pair(nodep, m_packageScopep));
}
} }
virtual void visit(AstNodeMath* nodep) override {} // Short circuit virtual void visit(AstNodeMath* nodep) override {} // Short circuit

View File

@ -220,7 +220,9 @@ class CombineVisitor final : VNVisitor {
// CONSTRUCTORS // CONSTRUCTORS
explicit CombineVisitor(AstNetlist* nodep) { iterate(nodep); } explicit CombineVisitor(AstNetlist* nodep) { iterate(nodep); }
~CombineVisitor() { V3Stats::addStat("Optimizations, Combined CFuncs", m_cfuncsCombined); } ~CombineVisitor() override {
V3Stats::addStat("Optimizations, Combined CFuncs", m_cfuncsCombined);
}
public: public:
static void apply(AstNetlist* netlistp) { CombineVisitor{netlistp}; } static void apply(AstNetlist* netlistp) { CombineVisitor{netlistp}; }

View File

@ -325,7 +325,6 @@ class ConstBitOpTreeVisitor final : public VNVisitor {
return ResultTerm{resultp, ops, clean}; return ResultTerm{resultp, ops, clean};
} }
public:
// CONSTRUCTORS // CONSTRUCTORS
VarInfo(ConstBitOpTreeVisitor* parent, AstVarRef* refp, int width) VarInfo(ConstBitOpTreeVisitor* parent, AstVarRef* refp, int width)
: m_parentp{parent} : m_parentp{parent}
@ -754,10 +753,11 @@ public:
if (debug() >= 9) { // LCOV_EXCL_START if (debug() >= 9) { // LCOV_EXCL_START
cout << "Bitop tree considered: " << endl; cout << "Bitop tree considered: " << endl;
for (AstNode* const termp : termps) termp->dumpTree("Reduced term: "); for (AstNode* const termp : termps) termp->dumpTree("Reduced term: ");
for (const std::pair<AstNode*, FrozenNodeInfo>& termp : visitor.m_frozenNodes) for (const std::pair<AstNode*, FrozenNodeInfo>& termp : visitor.m_frozenNodes) {
termp.first->dumpTree("Frozen term with lsb " + std::to_string(termp.second.m_lsb) termp.first->dumpTree("Frozen term with lsb " + std::to_string(termp.second.m_lsb)
+ " polarity " + std::to_string(termp.second.m_polarity) + " polarity " + std::to_string(termp.second.m_polarity)
+ ": "); + ": ");
}
cout << "Needs flipping: " << needsFlip << endl; cout << "Needs flipping: " << needsFlip << endl;
cout << "Needs cleaning: " << needsCleaning << endl; cout << "Needs cleaning: " << needsCleaning << endl;
cout << "Size: " << resultOps << " input size: " << visitor.m_ops << endl; cout << "Size: " << resultOps << " input size: " << visitor.m_ops << endl;

View File

@ -52,7 +52,7 @@ public:
V3DupFinder() V3DupFinder()
: m_hasherp{new V3Hasher} : m_hasherp{new V3Hasher}
, m_hasher{*m_hasherp} {} , m_hasher{*m_hasherp} {}
V3DupFinder(const V3Hasher& hasher) explicit V3DupFinder(const V3Hasher& hasher)
: m_hasherp{nullptr} : m_hasherp{nullptr}
, m_hasher{hasher} {} , m_hasher{hasher} {}
~V3DupFinder() { ~V3DupFinder() {

View File

@ -600,7 +600,7 @@ void EmitCFunc::emitVarReset(AstVar* varp) {
// If an ARRAYINIT we initialize it using an initial block similar to a signal // If an ARRAYINIT we initialize it using an initial block similar to a signal
// puts("// parameter "+varp->nameProtect()+" = "+varp->valuep()->name()+"\n"); // puts("// parameter "+varp->nameProtect()+" = "+varp->valuep()->name()+"\n");
} else if (const AstInitArray* const initarp = VN_CAST(varp->valuep(), InitArray)) { } else if (const AstInitArray* const initarp = VN_CAST(varp->valuep(), InitArray)) {
if (AstAssocArrayDType* const adtypep = VN_CAST(dtypep, AssocArrayDType)) { if (VN_IS(dtypep, AssocArrayDType)) {
if (initarp->defaultp()) { if (initarp->defaultp()) {
emitSetVarConstant(varNameProtected + ".atDefault()", emitSetVarConstant(varNameProtected + ".atDefault()",
VN_AS(initarp->defaultp(), Const)); VN_AS(initarp->defaultp(), Const));
@ -611,7 +611,7 @@ void EmitCFunc::emitVarReset(AstVar* varp) {
emitSetVarConstant(varNameProtected + ".at(" + cvtToStr(itr.first) + ")", emitSetVarConstant(varNameProtected + ".at(" + cvtToStr(itr.first) + ")",
VN_AS(valuep, Const)); VN_AS(valuep, Const));
} }
} else if (AstWildcardArrayDType* const adtypep = VN_CAST(dtypep, WildcardArrayDType)) { } else if (VN_IS(dtypep, WildcardArrayDType)) {
if (initarp->defaultp()) { if (initarp->defaultp()) {
emitSetVarConstant(varNameProtected + ".atDefault()", emitSetVarConstant(varNameProtected + ".atDefault()",
VN_AS(initarp->defaultp(), Const)); VN_AS(initarp->defaultp(), Const));

View File

@ -236,11 +236,12 @@ class EmitCHeader final : public EmitCConstInit {
void emitAll(const AstNodeModule* modp) { void emitAll(const AstNodeModule* modp) {
// Include files required by this AstNodeModule // Include files required by this AstNodeModule
if (const AstClass* const classp = VN_CAST(modp, Class)) { if (const AstClass* const classp = VN_CAST(modp, Class)) {
if (classp->extendsp()) if (classp->extendsp()) {
puts("#include \"" puts("#include \""
+ prefixNameProtect(classp->extendsp()->classp()->classOrPackagep()) + prefixNameProtect(classp->extendsp()->classp()->classOrPackagep())
+ ".h\"\n"); + ".h\"\n");
} }
}
emitModCUse(modp, VUseType::INT_INCLUDE); emitModCUse(modp, VUseType::INT_INCLUDE);
// Forward declarations required by this AstNodeModule // Forward declarations required by this AstNodeModule

View File

@ -208,19 +208,15 @@ class CMakeEmitter final {
*of << "target_link_libraries(${TOP_TARGET_NAME} PRIVATE " << prefix << ")\n"; *of << "target_link_libraries(${TOP_TARGET_NAME} PRIVATE " << prefix << ")\n";
if (!children.empty()) { if (!children.empty()) {
*of << "target_link_libraries(" << prefix << " INTERFACE"; *of << "target_link_libraries(" << prefix << " INTERFACE";
for (V3HierBlock::HierBlockSet::const_iterator child = children.begin(); for (const auto& childr : children) { *of << " " << (childr)->hierPrefix(); }
child != children.end(); ++child) {
*of << " " << (*child)->hierPrefix();
}
*of << ")\n"; *of << ")\n";
} }
*of << "verilate(" << prefix << " PREFIX " << prefix << " TOP_MODULE " *of << "verilate(" << prefix << " PREFIX " << prefix << " TOP_MODULE "
<< hblockp->modp()->name() << " DIRECTORY " << hblockp->modp()->name() << " DIRECTORY "
<< deslash(v3Global.opt.makeDir() + "/" + prefix) << " SOURCES "; << deslash(v3Global.opt.makeDir() + "/" + prefix) << " SOURCES ";
for (V3HierBlock::HierBlockSet::const_iterator child = children.begin(); for (const auto& childr : children) {
child != children.end(); ++child) {
*of << " " *of << " "
<< deslash(v3Global.opt.makeDir() + "/" + (*child)->hierWrapper(true)); << deslash(v3Global.opt.makeDir() + "/" + childr->hierWrapper(true));
} }
*of << " "; *of << " ";
const string vFile = hblockp->vFileIfNecessary(); const string vFile = hblockp->vFileIfNecessary();

View File

@ -689,5 +689,5 @@ public:
void V3EmitC::emitcModel() { void V3EmitC::emitcModel() {
UINFO(2, __FUNCTION__ << ": " << endl); UINFO(2, __FUNCTION__ << ": " << endl);
{ EmitCModel emit(v3Global.rootp()); } { EmitCModel{v3Global.rootp()}; }
} }

View File

@ -774,7 +774,7 @@ void EmitCSyms::emitSymImp() {
puts(protectIf(aboveScopep->nameDotless(), aboveScopep->protect())); puts(protectIf(aboveScopep->nameDotless(), aboveScopep->protect()));
} }
puts("."); puts(".");
puts(protName.substr(protName.rfind(".") + 1)); puts(protName.substr(protName.rfind('.') + 1));
puts(" = &"); puts(" = &");
puts(protectIf(scopep->nameDotless(), scopep->protect()) + ";\n"); puts(protectIf(scopep->nameDotless(), scopep->protect()) + ";\n");
++m_numStmts; ++m_numStmts;

View File

@ -72,10 +72,10 @@ int FileLineSingleton::nameToNumber(const string& filename) {
//! Experimental. Updated to also put out the language. //! Experimental. Updated to also put out the language.
void FileLineSingleton::fileNameNumMapDumpXml(std::ostream& os) { void FileLineSingleton::fileNameNumMapDumpXml(std::ostream& os) {
os << "<files>\n"; os << "<files>\n";
for (auto it = m_namemap.cbegin(); it != m_namemap.cend(); ++it) { for (const auto& itr : m_namemap) {
os << "<file id=\"" << filenameLetters(it->second) << "\" filename=\"" os << "<file id=\"" << filenameLetters(itr.second) << "\" filename=\""
<< V3OutFormatter::quoteNameControls(it->first, V3OutFormatter::LA_XML) << V3OutFormatter::quoteNameControls(itr.first, V3OutFormatter::LA_XML)
<< "\" language=\"" << numberToLang(it->second).ascii() << "\"/>\n"; << "\" language=\"" << numberToLang(itr.second).ascii() << "\"/>\n";
} }
os << "</files>\n"; os << "</files>\n";
} }

View File

@ -81,16 +81,16 @@ public:
AstScope* scopep() const { return m_scopep; } AstScope* scopep() const { return m_scopep; }
bool reducible() const { return m_reducible; } bool reducible() const { return m_reducible; }
bool dedupable() const { return m_dedupable; } bool dedupable() const { return m_dedupable; }
void setConsumed(const char* consumedReason) { void setConsumed(const char* /*consumedReason*/) {
m_consumed = true; m_consumed = true;
// UINFO(0, "\t\tSetConsumed "<<consumedReason<<" "<<this<<endl); // UINFO(0, "\t\tSetConsumed "<<consumedReason<<" "<<this<<endl);
} }
bool consumed() const { return m_consumed; } bool consumed() const { return m_consumed; }
void clearReducible(const char* nonReducibleReason) { void clearReducible(const char* /*nonReducibleReason*/) {
m_reducible = false; m_reducible = false;
// UINFO(0, " NR: "<<nonReducibleReason<<" "<<name()<<endl); // UINFO(0, " NR: "<<nonReducibleReason<<" "<<name()<<endl);
} }
void clearDedupable(const char* nonDedupableReason) { void clearDedupable(const char* /*nonDedupableReason*/) {
m_dedupable = false; m_dedupable = false;
// UINFO(0, " ND: "<<nonDedupableReason<<" "<<name()<<endl); // UINFO(0, " ND: "<<nonDedupableReason<<" "<<name()<<endl);
} }

View File

@ -159,7 +159,7 @@ std::ostream& operator<<(std::ostream& os, V3GraphVertex* vertexp) {
//###################################################################### //######################################################################
// Edges // Edges
void V3GraphEdge::init(V3Graph* graphp, V3GraphVertex* fromp, V3GraphVertex* top, int weight, void V3GraphEdge::init(V3Graph* /*graphp*/, V3GraphVertex* fromp, V3GraphVertex* top, int weight,
bool cutable) { bool cutable) {
UASSERT(fromp, "Null from pointer"); UASSERT(fromp, "Null from pointer");
UASSERT(top, "Null to pointer"); UASSERT(top, "Null to pointer");

View File

@ -494,7 +494,7 @@ private:
public: public:
// CONSTRUCTORS // CONSTRUCTORS
HasherVisitor(AstNode* nodep) explicit HasherVisitor(AstNode* nodep)
: m_cacheInUser4{true} { : m_cacheInUser4{true} {
iterate(nodep); iterate(nodep);
} }
@ -517,7 +517,7 @@ V3Hash V3Hasher::operator()(AstNode* nodep) const {
V3Hash V3Hasher::rehash(AstNode* nodep) const { V3Hash V3Hasher::rehash(AstNode* nodep) const {
nodep->user4(0); nodep->user4(0);
HasherVisitor{nodep}; { HasherVisitor{nodep}; }
return V3Hash(nodep->user4()); return V3Hash(nodep->user4());
} }

View File

@ -1902,7 +1902,7 @@ private:
static int debug() { return LinkDotState::debug(); } static int debug() { return LinkDotState::debug(); }
// METHODS - Variables // METHODS - Variables
void createImplicitVar(VSymEnt* lookupSymp, AstVarRef* nodep, AstNodeModule* modp, void createImplicitVar(VSymEnt* /*lookupSymp*/, AstVarRef* nodep, AstNodeModule* modp,
VSymEnt* moduleSymp, bool noWarn) { VSymEnt* moduleSymp, bool noWarn) {
// Create implicit after warning // Create implicit after warning
if (!nodep->varp()) { if (!nodep->varp()) {

View File

@ -445,7 +445,7 @@ private:
selp->rhsp()->unlinkFrBackWithNext()}; selp->rhsp()->unlinkFrBackWithNext()};
selp->replaceWith(newp); selp->replaceWith(newp);
VL_DO_DANGLING(selp->deleteTree(), selp); VL_DO_DANGLING(selp->deleteTree(), selp);
} else if (AstSelLoopVars* const selp = VN_CAST(bracketp, SelLoopVars)) { } else if (VN_IS(bracketp, SelLoopVars)) {
// Ok // Ok
} else { } else {
nodep->v3error( nodep->v3error(

View File

@ -404,7 +404,7 @@ private:
return newFormat; return newFormat;
} }
static void expectDescriptor(AstNode* nodep, AstNodeVarRef* filep) { static void expectDescriptor(AstNode* /*nodep*/, AstNodeVarRef* filep) {
// This might fail on complex expressions like arrays // This might fail on complex expressions like arrays
// We use attrFileDescr() only for lint suppression, so that's ok // We use attrFileDescr() only for lint suppression, so that's ok
if (filep && filep->varp()) filep->varp()->attrFileDescr(true); if (filep && filep->varp()) filep->varp()->attrFileDescr(true);

View File

@ -69,7 +69,7 @@ private:
&& m_accessors(nodep).size() == 1); // .. a block temp used in a single CFunc && m_accessors(nodep).size() == 1); // .. a block temp used in a single CFunc
} }
bool existsNonLeaf(const std::unordered_set<AstCFunc*>& funcps) { static bool existsNonLeaf(const std::unordered_set<AstCFunc*>& funcps) {
for (const AstCFunc* const funcp : funcps) { for (const AstCFunc* const funcp : funcps) {
if (funcp->user1()) return true; if (funcp->user1()) return true;
} }

View File

@ -414,7 +414,7 @@ public:
// Given an AstNode list (held via AstNode::nextp()), move conditional statements as close // Given an AstNode list (held via AstNode::nextp()), move conditional statements as close
// together as possible // together as possible
static AstNode* optimize(AstNode* nodep, const StmtPropertiesAllocator& stmtProperties) { static AstNode* optimize(AstNode* nodep, const StmtPropertiesAllocator& stmtProperties) {
CodeMotionOptimizeVisitor{nodep, stmtProperties}; { CodeMotionOptimizeVisitor{nodep, stmtProperties}; }
// It is possible for the head of the list to be moved later such that it is no longer // It is possible for the head of the list to be moved later such that it is no longer
// in head position. If so, rewind the list and return the new head. // in head position. If so, rewind the list and return the new head.
while (nodep->backp()->nextp() == nodep) nodep = nodep->backp(); while (nodep->backp()->nextp() == nodep) nodep = nodep->backp();

View File

@ -737,7 +737,7 @@ class OrderBuildVisitor final : public VNVisitor {
virtual void visit(AstNode* nodep) override { iterateChildren(nodep); } virtual void visit(AstNode* nodep) override { iterateChildren(nodep); }
// CONSTRUCTOR // CONSTRUCTOR
OrderBuildVisitor(AstNetlist* nodep) { explicit OrderBuildVisitor(AstNetlist* nodep) {
// Enable debugging (3 is default if global debug; we want acyc debugging) // Enable debugging (3 is default if global debug; we want acyc debugging)
if (debug()) m_graphp->debug(5); if (debug()) m_graphp->debug(5);
@ -753,7 +753,7 @@ class OrderBuildVisitor final : public VNVisitor {
// Build the rest of the graph // Build the rest of the graph
iterate(nodep); iterate(nodep);
} }
virtual ~OrderBuildVisitor() = default; ~OrderBuildVisitor() override = default;
public: public:
// Process the netlist and return the constructed ordering graph. It's 'process' because // Process the netlist and return the constructed ordering graph. It's 'process' because
@ -1331,7 +1331,7 @@ class OrderProcess final : VNDeleter {
pushDeletep(m_deleteDomainp); pushDeletep(m_deleteDomainp);
} }
~OrderProcess() { ~OrderProcess() override {
// Stats // Stats
for (int type = 0; type < OrderVEdgeType::_ENUM_END; type++) { for (int type = 0; type < OrderVEdgeType::_ENUM_END; type++) {
const double count = double(m_statCut[type]); const double count = double(m_statCut[type]);
@ -2103,9 +2103,9 @@ void V3Order::orderAll(AstNetlist* netlistp) {
// Build ordering graph // Build ordering graph
std::unique_ptr<OrderGraph> orderGraph = OrderBuildVisitor::process(netlistp); std::unique_ptr<OrderGraph> orderGraph = OrderBuildVisitor::process(netlistp);
// Order the netlist // Order the netlist
OrderProcess::main(netlistp, *orderGraph.get()); OrderProcess::main(netlistp, *orderGraph);
// Reset debug level // Reset debug level
orderGraph.get()->debug(V3Error::debugDefault()); orderGraph->debug(V3Error::debugDefault());
// Dump tree // Dump tree
V3Global::dumpCheckGlobalTree("order", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); V3Global::dumpCheckGlobalTree("order", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3);
} }

View File

@ -26,7 +26,7 @@ class AstNetlist;
class V3Order final { class V3Order final {
public: public:
static void orderAll(AstNetlist* nodep); static void orderAll(AstNetlist* netlistp);
}; };
#endif // Guard #endif // Guard

View File

@ -289,7 +289,7 @@ class ParamProcessor final {
} }
} }
} }
string paramSmallName(AstNodeModule* modp, AstNode* varp) { static string paramSmallName(AstNodeModule* modp, AstNode* varp) {
if (varp->user4() <= 1) makeSmallNames(modp); if (varp->user4() <= 1) makeSmallNames(modp);
int index = varp->user4() / 256; int index = varp->user4() / 256;
const char ch = varp->user4() & 255; const char ch = varp->user4() & 255;

View File

@ -468,13 +468,13 @@ void V3ParseImp::tokenPipeline() {
if (nexttok == yP_COLONCOLON) { if (nexttok == yP_COLONCOLON) {
token = yaID__CC; token = yaID__CC;
} else if (nexttok == '#') { } else if (nexttok == '#') {
const V3ParseBisonYYSType curValue const V3ParseBisonYYSType curValueHold
= yylval; // Remember value, as about to read ahead = yylval; // Remember value, as about to read ahead
{ {
const size_t depth = tokenPipeScanParam(0); const size_t depth = tokenPipeScanParam(0);
if (tokenPeekp(depth)->token == yP_COLONCOLON) token = yaID__CC; if (tokenPeekp(depth)->token == yP_COLONCOLON) token = yaID__CC;
} }
yylval = curValue; yylval = curValueHold;
} }
} }
// If add to above "else if", also add to "if (token" further above // If add to above "else if", also add to "if (token" further above

View File

@ -261,7 +261,7 @@ private:
// METHODS // METHODS
protected: protected:
friend class PartPropagateCp<PartPropagateCpSelfTest>; friend class PartPropagateCp<PartPropagateCpSelfTest>;
void notifyEdgeCp(V3GraphVertex* vxp, GraphWay way, V3GraphVertex* throughp, void notifyEdgeCp(V3GraphVertex* /*vxp*/, GraphWay way, V3GraphVertex* throughp,
uint32_t cp) const { uint32_t cp) const {
const uint32_t throughCost = critPathCost(throughp, way); const uint32_t throughCost = critPathCost(throughp, way);
UASSERT_SELFTEST(uint32_t, cp, (1 + throughCost)); UASSERT_SELFTEST(uint32_t, cp, (1 + throughCost));
@ -272,7 +272,7 @@ private:
// Don't need to check this in the self test; it supports an assert // Don't need to check this in the self test; it supports an assert
// that runs in production code. // that runs in production code.
} }
void setCritPathCost(V3GraphVertex* vxp, GraphWay way, uint32_t cost) { void setCritPathCost(V3GraphVertex* vxp, GraphWay /*way*/, uint32_t cost) {
m_cp[vxp] = cost; m_cp[vxp] = cost;
// Confirm that we only set each node's CP once. That's an // Confirm that we only set each node's CP once. That's an
// important property of PartPropagateCp which allows it to be far // important property of PartPropagateCp which allows it to be far
@ -281,7 +281,7 @@ private:
UASSERT_OBJ(it == m_seen.end(), vxp, "Set CP on node twice"); UASSERT_OBJ(it == m_seen.end(), vxp, "Set CP on node twice");
m_seen[vxp] = cost; m_seen[vxp] = cost;
} }
uint32_t critPathCost(V3GraphVertex* vxp, GraphWay way) const { uint32_t critPathCost(V3GraphVertex* vxp, GraphWay /*way*/) const {
const auto it = m_cp.find(vxp); const auto it = m_cp.find(vxp);
if (it != m_cp.end()) return it->second; if (it != m_cp.end()) return it->second;
return 0; return 0;
@ -743,7 +743,7 @@ public:
bool mergeWouldCreateCycle() const; // Instead of virtual method bool mergeWouldCreateCycle() const; // Instead of virtual method
bool removedFromSb() const { return (m_id & REMOVED_MASK) != 0; } bool removedFromSb() const { return (m_id & REMOVED_MASK) != 0; }
void removedFromSb(bool removed) { m_id |= REMOVED_MASK; } void removedFromSb(bool /*removed*/) { m_id |= REMOVED_MASK; }
bool operator<(const MergeCandidate& other) const { return m_id < other.m_id; } bool operator<(const MergeCandidate& other) const { return m_id < other.m_id; }
}; };

View File

@ -378,7 +378,7 @@ public:
: m_tempNames{"__Vtemp"} { : m_tempNames{"__Vtemp"} {
iterate(nodep); iterate(nodep);
} }
virtual ~PremitVisitor() { ~PremitVisitor() override {
V3Stats::addStat("Optimizations, Prelim extracted value to ConstPool", V3Stats::addStat("Optimizations, Prelim extracted value to ConstPool",
m_extractedToConstPool); m_extractedToConstPool);
} }

View File

@ -75,7 +75,7 @@ private:
} }
} }
void markAllDerived() { void markAllDerived() {
for (auto p : m_baseToDerivedMap) { for (const auto& p : m_baseToDerivedMap) {
if (p.first->user1()) markDerived(p.first); if (p.first->user1()) markDerived(p.first);
} }
} }

View File

@ -67,11 +67,11 @@ private:
// METHODS // METHODS
VL_DEBUG_FUNC; // Declare debug() VL_DEBUG_FUNC; // Declare debug()
AstVar* findCreateVarTemp(FileLine* fl, AstCFunc* cfuncp) { static AstVar* findCreateVarTemp(FileLine* fl, AstCFunc* cfuncp) {
AstVar* varp = VN_AS(cfuncp->user1p(), Var); AstVar* varp = VN_AS(cfuncp->user1p(), Var);
if (!varp) { if (!varp) {
const string newvarname = string("__Vilp"); const string newvarname = string("__Vilp");
varp = new AstVar(fl, VVarType::STMTTEMP, newvarname, VFlagLogicPacked(), 32); varp = new AstVar{fl, VVarType::STMTTEMP, newvarname, VFlagLogicPacked{}, 32};
UASSERT_OBJ(cfuncp, fl, "Assignment not under a function"); UASSERT_OBJ(cfuncp, fl, "Assignment not under a function");
cfuncp->addInitsp(varp); cfuncp->addInitsp(varp);
cfuncp->user1p(varp); cfuncp->user1p(varp);

View File

@ -610,7 +610,7 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl {
} }
AstVarRef* createTempVar(AstNode* context, AstNode* nodep, AstUnpackArrayDType* dtypep, AstVarRef* createTempVar(AstNode* context, AstNode* nodep, AstUnpackArrayDType* dtypep,
const std::string& name_prefix, std::vector<AstVar*>& vars, const std::string& name_prefix, std::vector<AstVar*>& vars,
int start_idx, bool lvalue, bool ftask) { int start_idx, bool lvalue, bool /*ftask*/) {
FileLine* const fl = nodep->fileline(); FileLine* const fl = nodep->fileline();
const std::string name = m_tempNames.get(nodep) + "__" + name_prefix; const std::string name = m_tempNames.get(nodep) + "__" + name_prefix;
AstNodeAssign* const assignp = VN_CAST(context, NodeAssign); AstNodeAssign* const assignp = VN_CAST(context, NodeAssign);
@ -773,8 +773,7 @@ class SplitUnpackedVarVisitor final : public VNVisitor, public SplitVarImpl {
public: public:
explicit SplitUnpackedVarVisitor(AstNetlist* nodep) explicit SplitUnpackedVarVisitor(AstNetlist* nodep)
: m_refs{} : m_tempNames{"__VsplitVar"} {
, m_tempNames{"__VsplitVar"} {
iterate(nodep); iterate(nodep);
} }
~SplitUnpackedVarVisitor() override { ~SplitUnpackedVarVisitor() override {
@ -1114,10 +1113,10 @@ class SplitPackedVarVisitor final : public VNVisitor, public SplitVarImpl {
<< " is added for " << varp->prettyNameQ() << '\n'); << " is added for " << varp->prettyNameQ() << '\n');
} }
} }
static void updateReferences(AstVar* varp, PackedVarRef& ref, static void updateReferences(AstVar* varp, PackedVarRef& pref,
const std::vector<SplitNewVar>& vars) { const std::vector<SplitNewVar>& vars) {
for (const bool lvalue : {false, true}) { // Refer the new split variables for (const bool lvalue : {false, true}) { // Refer the new split variables
std::vector<PackedVarRefEntry>& refs = lvalue ? ref.lhs() : ref.rhs(); std::vector<PackedVarRefEntry>& refs = lvalue ? pref.lhs() : pref.rhs();
for (PackedVarRefEntry& ref : refs) { for (PackedVarRefEntry& ref : refs) {
auto varit auto varit
= std::upper_bound(vars.begin(), vars.end(), ref.lsb(), SplitNewVar::Match()); = std::upper_bound(vars.begin(), vars.end(), ref.lsb(), SplitNewVar::Match());

View File

@ -112,7 +112,7 @@ private:
AstVarScope* m_vscp; // AstVarScope being traced (non const to allow copy during sorting) AstVarScope* m_vscp; // AstVarScope being traced (non const to allow copy during sorting)
std::string m_path; // Path to enclosing module in hierarchy std::string m_path; // Path to enclosing module in hierarchy
std::string m_name; // Name of signal std::string m_name; // Name of signal
Signal(AstVarScope* vscp) explicit Signal(AstVarScope* vscp)
: m_vscp{vscp} { : m_vscp{vscp} {
// Compute path in hierarchy and signal name // Compute path in hierarchy and signal name
const string& vcdName = AstNode::vcdName(vscp->varp()->name()); const string& vcdName = AstNode::vcdName(vscp->varp()->name());
@ -312,13 +312,13 @@ private:
const string intfScopeName = irpName.substr(0, scopeLen); const string intfScopeName = irpName.substr(0, scopeLen);
if (scopeName != intfScopeName) continue; if (scopeName != intfScopeName) continue;
string scopeName = AstNode::vcdName(irp->name()); string iscopeName = AstNode::vcdName(irp->name());
if (scopeName.substr(0, 4) == "TOP ") scopeName.erase(0, 4); if (iscopeName.substr(0, 4) == "TOP ") iscopeName.erase(0, 4);
// Note this insert doesn't know what above is interfaces. // Note this insert doesn't know what above is interfaces.
// Perhaps all scopes should be changed to include the VLT_TRACE_SCOPE characters. // Perhaps all scopes should be changed to include the VLT_TRACE_SCOPE characters.
// Instead we fix up when printing m_scopeSubFuncps // Instead we fix up when printing m_scopeSubFuncps
scopeName += getScopeChar(VLT_TRACE_SCOPE_INTERFACE) + ' '; iscopeName += getScopeChar(VLT_TRACE_SCOPE_INTERFACE) + ' ';
m_scopeSubFuncps.emplace(scopeName, m_subFuncps); m_scopeSubFuncps.emplace(iscopeName, m_subFuncps);
VL_DO_DANGLING(irp->unlinkFrBack(), irp); VL_DO_DANGLING(irp->unlinkFrBack(), irp);
} }

View File

@ -607,7 +607,6 @@ class TristateVisitor final : public TristateBaseVisitor {
if (!outvarp) { if (!outvarp) {
// This is the final pre-forced resolution of the tristate, so we apply // This is the final pre-forced resolution of the tristate, so we apply
// the pull direction to any undriven pins. // the pull direction to any undriven pins.
V3Number pull(invarp, lhsp->width());
const AstPull* const pullp = static_cast<AstPull*>(lhsp->user3p()); const AstPull* const pullp = static_cast<AstPull*>(lhsp->user3p());
bool pull1 = pullp && pullp->direction() == 1; // Else default is down bool pull1 = pullp && pullp->direction() == 1; // Else default is down
undrivenp undrivenp
@ -989,12 +988,13 @@ class TristateVisitor final : public TristateBaseVisitor {
if (!dropop[2]) iterateAndNextNull(nodep->fhsp()); if (!dropop[2]) iterateAndNextNull(nodep->fhsp());
} else { } else {
AstNode* nonXp = nullptr; AstNode* nonXp = nullptr;
if (!dropop[0]) if (!dropop[0]) {
nonXp = nodep->rhsp(); nonXp = nodep->rhsp();
else if (!dropop[1]) } else if (!dropop[1]) {
nonXp = nodep->thsp(); nonXp = nodep->thsp();
else if (!dropop[2]) } else if (!dropop[2]) {
nonXp = nodep->fhsp(); nonXp = nodep->fhsp();
}
// Replace 'z with non-Z // Replace 'z with non-Z
if (dropop[0] || dropop[1] || dropop[2]) { if (dropop[0] || dropop[1] || dropop[2]) {
// Unsupported: A $countones('0) should compare with the enables, but we don't // Unsupported: A $countones('0) should compare with the enables, but we don't

View File

@ -48,7 +48,7 @@ public:
: m_mtaskIds(mtaskIds) { // Cannot be {} or GCC 4.8 false warning : m_mtaskIds(mtaskIds) { // Cannot be {} or GCC 4.8 false warning
m_serial = ++s_serialNext; // Cannot be ()/{} or GCC 4.8 false warning m_serial = ++s_serialNext; // Cannot be ()/{} or GCC 4.8 false warning
} }
virtual ~VarTspSorter() = default; ~VarTspSorter() override = default;
// METHODS // METHODS
virtual bool operator<(const TspStateBase& other) const override { virtual bool operator<(const TspStateBase& other) const override {
return operator<(dynamic_cast<const VarTspSorter&>(other)); return operator<(dynamic_cast<const VarTspSorter&>(other));

View File

@ -674,10 +674,11 @@ private:
AstNodeDType* const vdtypep = m_vup->dtypeNullSkipRefp(); AstNodeDType* const vdtypep = m_vup->dtypeNullSkipRefp();
if (VN_IS(vdtypep, QueueDType) || VN_IS(vdtypep, DynArrayDType) if (VN_IS(vdtypep, QueueDType) || VN_IS(vdtypep, DynArrayDType)
|| VN_IS(vdtypep, UnpackArrayDType)) { || VN_IS(vdtypep, UnpackArrayDType)) {
if (times != 1) if (times != 1) {
nodep->v3warn(E_UNSUPPORTED, "Unsupported: Non-1 replication to form " nodep->v3warn(E_UNSUPPORTED, "Unsupported: Non-1 replication to form "
<< vdtypep->prettyDTypeNameQ() << vdtypep->prettyDTypeNameQ()
<< " data type"); << " data type");
}
// Don't iterate lhsp as SELF, the potential Concat below needs // Don't iterate lhsp as SELF, the potential Concat below needs
// the adtypep passed down to recognize the QueueDType // the adtypep passed down to recognize the QueueDType
userIterateAndNext(nodep->lhsp(), WidthVP(vdtypep, BOTH).p()); userIterateAndNext(nodep->lhsp(), WidthVP(vdtypep, BOTH).p());
@ -1125,10 +1126,11 @@ private:
} }
virtual void visit(AstEmptyQueue* nodep) override { virtual void visit(AstEmptyQueue* nodep) override {
nodep->dtypeSetEmptyQueue(); nodep->dtypeSetEmptyQueue();
if (!VN_IS(nodep->backp(), Assign)) if (!VN_IS(nodep->backp(), Assign)) {
nodep->v3warn(E_UNSUPPORTED, nodep->v3warn(E_UNSUPPORTED,
"Unsupported/Illegal: empty queue ('{}') in this context"); "Unsupported/Illegal: empty queue ('{}') in this context");
} }
}
virtual void visit(AstFell* nodep) override { virtual void visit(AstFell* nodep) override {
if (m_vup->prelim()) { if (m_vup->prelim()) {
iterateCheckSizedSelf(nodep, "LHS", nodep->exprp(), SELF, BOTH); iterateCheckSizedSelf(nodep, "LHS", nodep->exprp(), SELF, BOTH);
@ -4040,6 +4042,7 @@ private:
argsp->v3error("Illegal to foreach loop on basic '" + fromDtp->prettyTypeName() argsp->v3error("Illegal to foreach loop on basic '" + fromDtp->prettyTypeName()
+ "'"); + "'");
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep); VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
VL_DO_DANGLING(bodyPointp->deleteTree(), bodyPointp);
return; return;
} }
if (varp) { if (varp) {
@ -4592,9 +4595,11 @@ private:
// TOP LEVEL NODE // TOP LEVEL NODE
if (nodep->modVarp() && nodep->modVarp()->isGParam()) { if (nodep->modVarp() && nodep->modVarp()->isGParam()) {
// Widthing handled as special init() case // Widthing handled as special init() case
if (auto* const patternp = VN_CAST(nodep->exprp(), Pattern)) if (auto* const patternp = VN_CAST(nodep->exprp(), Pattern)) {
if (const auto* modVarp = nodep->modVarp()) if (const auto* modVarp = nodep->modVarp()) {
patternp->childDTypep(modVarp->childDTypep()->cloneTree(false)); patternp->childDTypep(modVarp->childDTypep()->cloneTree(false));
}
}
userIterateChildren(nodep, WidthVP(SELF, BOTH).p()); userIterateChildren(nodep, WidthVP(SELF, BOTH).p());
} else if (!m_paramsOnly) { } else if (!m_paramsOnly) {
if (!nodep->modVarp()->didWidth()) { if (!nodep->modVarp()->didWidth()) {

View File

@ -70,7 +70,7 @@ private:
, m_fromRange{fromRange} {} , m_fromRange{fromRange} {}
~FromData() = default; ~FromData() = default;
}; };
FromData fromDataForArray(AstNode* nodep, AstNode* basefromp) { static FromData fromDataForArray(AstNode* nodep, AstNode* basefromp) {
// What is the data type and information for this SEL-ish's from()? // What is the data type and information for this SEL-ish's from()?
UINFO(9, " fromData start ddtypep = " << basefromp << endl); UINFO(9, " fromData start ddtypep = " << basefromp << endl);
VNumRange fromRange; // constructs to isRanged(false) VNumRange fromRange; // constructs to isRanged(false)

View File

@ -703,7 +703,7 @@ static void execHierVerilation() {
//###################################################################### //######################################################################
int main(int argc, char** argv, char** env) { int main(int argc, char** argv, char** /*env*/) {
// General initialization // General initialization
std::ios::sync_with_stdio(); std::ios::sync_with_stdio();