Reset index counts on clearing verilated_cov (static removal)

This commit is contained in:
Wilson Snyder 2020-12-01 18:30:25 -05:00
parent d21b4e3fc7
commit 014e43f0ef
1 changed files with 7 additions and 6 deletions

View File

@ -99,6 +99,7 @@ private:
ValueIndexMap m_valueIndexes VL_GUARDED_BY(m_mutex); ///< Unique arbitrary value for values ValueIndexMap m_valueIndexes VL_GUARDED_BY(m_mutex); ///< Unique arbitrary value for values
IndexValueMap m_indexValues VL_GUARDED_BY(m_mutex); ///< Unique arbitrary value for keys IndexValueMap m_indexValues VL_GUARDED_BY(m_mutex); ///< Unique arbitrary value for keys
ItemList m_items VL_GUARDED_BY(m_mutex); ///< List of all items ItemList m_items VL_GUARDED_BY(m_mutex); ///< List of all items
int m_nextIndex VL_GUARDED_BY(m_mutex) = (KEY_UNDEF + 1); ///< Next insert value
VerilatedCovImpItem* m_insertp VL_GUARDED_BY(m_mutex) = nullptr; ///< Item about to insert VerilatedCovImpItem* m_insertp VL_GUARDED_BY(m_mutex) = nullptr; ///< Item about to insert
const char* m_insertFilenamep VL_GUARDED_BY(m_mutex) = nullptr; ///< Filename about to insert const char* m_insertFilenamep VL_GUARDED_BY(m_mutex) = nullptr; ///< Filename about to insert
@ -118,14 +119,13 @@ public:
private: private:
// PRIVATE METHODS // PRIVATE METHODS
int valueIndex(const std::string& value) VL_REQUIRES(m_mutex) { int valueIndex(const std::string& value) VL_REQUIRES(m_mutex) {
static int nextIndex = KEY_UNDEF + 1;
const auto iter = m_valueIndexes.find(value); const auto iter = m_valueIndexes.find(value);
if (iter != m_valueIndexes.end()) return iter->second; if (iter != m_valueIndexes.end()) return iter->second;
nextIndex++; m_nextIndex++;
assert(nextIndex > 0); // Didn't rollover assert(m_nextIndex > 0); // Didn't rollover
m_valueIndexes.insert(std::make_pair(value, nextIndex)); m_valueIndexes.insert(std::make_pair(value, m_nextIndex));
m_indexValues.insert(std::make_pair(nextIndex, value)); m_indexValues.insert(std::make_pair(m_nextIndex, value));
return nextIndex; return m_nextIndex;
} }
static std::string dequote(const std::string& text) VL_PURE { static std::string dequote(const std::string& text) VL_PURE {
// Quote any special characters // Quote any special characters
@ -235,6 +235,7 @@ private:
m_items.clear(); m_items.clear();
m_indexValues.clear(); m_indexValues.clear();
m_valueIndexes.clear(); m_valueIndexes.clear();
m_nextIndex = KEY_UNDEF + 1;
} }
public: public: