Internals: Misc VCD code cleanups. No functional change.

This commit is contained in:
Wilson Snyder 2017-10-21 17:53:23 -04:00
parent b90f383cfe
commit 32874fa848
4 changed files with 22 additions and 21 deletions

View File

@ -111,7 +111,7 @@ private:
m_insertLineno = 0; m_insertLineno = 0;
} }
public: public:
~VerilatedCovImp() { clear(); } ~VerilatedCovImp() { clearGuts(); }
static VerilatedCovImp& imp() { static VerilatedCovImp& imp() {
static VerilatedCovImp s_singleton; static VerilatedCovImp s_singleton;
return s_singleton; return s_singleton;
@ -217,10 +217,7 @@ private:
if (combineHier ("q.za","q.zb") !="q.z*") VL_FATAL_MT(__FILE__,__LINE__,"","%Error: selftest\n"); if (combineHier ("q.za","q.zb") !="q.z*") VL_FATAL_MT(__FILE__,__LINE__,"","%Error: selftest\n");
if (combineHier ("1.2.3.a","9.8.7.a") !="*.a") VL_FATAL_MT(__FILE__,__LINE__,"","%Error: selftest\n"); if (combineHier ("1.2.3.a","9.8.7.a") !="*.a") VL_FATAL_MT(__FILE__,__LINE__,"","%Error: selftest\n");
} }
void clearGuts() {
public:
// PUBLIC METHODS
void clear() {
for (ItemList::const_iterator it=m_items.begin(); it!=m_items.end(); ++it) { for (ItemList::const_iterator it=m_items.begin(); it!=m_items.end(); ++it) {
VerilatedCovImpItem* itemp = *(it); VerilatedCovImpItem* itemp = *(it);
delete itemp; delete itemp;
@ -229,6 +226,12 @@ public:
m_indexValues.clear(); m_indexValues.clear();
m_valueIndexes.clear(); m_valueIndexes.clear();
} }
public:
// PUBLIC METHODS
void clear() {
clearGuts();
}
void clearNonMatch (const char* matchp) { void clearNonMatch (const char* matchp) {
if (matchp && matchp[0]) { if (matchp && matchp[0]) {
ItemList newlist; ItemList newlist;

View File

@ -219,7 +219,7 @@ void VerilatedVcd::makeNameMap() {
m_namemapp = new NameMap; m_namemapp = new NameMap;
for (vluint32_t ent = 0; ent< m_callbacks.size(); ent++) { for (vluint32_t ent = 0; ent< m_callbacks.size(); ent++) {
VerilatedVcdCallInfo *cip = m_callbacks[ent]; VerilatedVcdCallInfo *cip = m_callbacks[ent];
cip->m_code = nextCode(); cip->m_code = m_nextCode;
(cip->m_initcb) (this, cip->m_userthis, cip->m_code); (cip->m_initcb) (this, cip->m_userthis, cip->m_code);
} }
@ -265,6 +265,7 @@ VerilatedVcd::~VerilatedVcd() {
} }
void VerilatedVcd::closePrev () { void VerilatedVcd::closePrev () {
// This function is on the flush() call path
if (!isOpen()) return; if (!isOpen()) return;
bufferFlush(); bufferFlush();
@ -275,6 +276,7 @@ void VerilatedVcd::closePrev () {
void VerilatedVcd::closeErr () { void VerilatedVcd::closeErr () {
// Close due to an error. We might abort before even getting here, // Close due to an error. We might abort before even getting here,
// depending on the definition of vl_fatal. // depending on the definition of vl_fatal.
// This function is on the flush() call path
if (!isOpen()) return; if (!isOpen()) return;
// No buffer flush, just fclose // No buffer flush, just fclose
@ -283,6 +285,7 @@ void VerilatedVcd::closeErr () {
} }
void VerilatedVcd::close() { void VerilatedVcd::close() {
// This function is on the flush() call path
if (!isOpen()) return; if (!isOpen()) return;
if (m_evcd) { if (m_evcd) {
printStr("$vcdclose "); printStr("$vcdclose ");
@ -311,7 +314,7 @@ void VerilatedVcd::printTime (vluint64_t timeui) {
// Dinotrace doesn't mind, but Cadence vvision seems to choke // Dinotrace doesn't mind, but Cadence vvision seems to choke
if (VL_UNLIKELY(timeui < m_timeLastDump)) { if (VL_UNLIKELY(timeui < m_timeLastDump)) {
timeui = m_timeLastDump; timeui = m_timeLastDump;
static bool backTime = false; static VL_THREAD_LOCAL bool backTime = false;
if (!backTime) { if (!backTime) {
backTime = true; backTime = true;
VL_PRINTF_MT("VCD time is moving backwards, wave file may be incorrect.\n"); VL_PRINTF_MT("VCD time is moving backwards, wave file may be incorrect.\n");
@ -336,6 +339,7 @@ void VerilatedVcd::bufferResize(vluint64_t minsize) {
} }
void VerilatedVcd::bufferFlush () { void VerilatedVcd::bufferFlush () {
// This function is on the flush() call path
// We add output data to m_writep. // We add output data to m_writep.
// When it gets nearly full we dump it using this routine which calls write() // When it gets nearly full we dump it using this routine which calls write()
// This is much faster than using buffered I/O // This is much faster than using buffered I/O
@ -511,7 +515,7 @@ void VerilatedVcd::declare (vluint32_t code, const char* name, const char* wirep
if (tri) codesNeeded *= 2; // Space in change array for __en signals if (tri) codesNeeded *= 2; // Space in change array for __en signals
// Make sure array is large enough // Make sure array is large enough
m_nextCode = std::max(nextCode(), code+codesNeeded); m_nextCode = std::max(m_nextCode, code+codesNeeded);
if (m_sigs.capacity() <= m_nextCode) { if (m_sigs.capacity() <= m_nextCode) {
m_sigs.reserve(m_nextCode*2); // Power-of-2 allocation speeds things up m_sigs.reserve(m_nextCode*2); // Power-of-2 allocation speeds things up
} }
@ -625,7 +629,7 @@ void VerilatedVcd::addCallback (
std::string msg = std::string("Internal: ")+__FILE__+"::"+__FUNCTION__+" called with already open file"; std::string msg = std::string("Internal: ")+__FILE__+"::"+__FUNCTION__+" called with already open file";
VL_FATAL_MT(__FILE__,__LINE__,"",msg.c_str()); VL_FATAL_MT(__FILE__,__LINE__,"",msg.c_str());
} }
VerilatedVcdCallInfo* vci = new VerilatedVcdCallInfo(initcb, fullcb, changecb, userthis, nextCode()); VerilatedVcdCallInfo* vci = new VerilatedVcdCallInfo(initcb, fullcb, changecb, userthis, m_nextCode);
m_callbacks.push_back(vci); m_callbacks.push_back(vci);
} }
@ -638,7 +642,6 @@ void VerilatedVcd::dumpFull (vluint64_t timeui) {
VerilatedVcdCallInfo *cip = m_callbacks[ent]; VerilatedVcdCallInfo *cip = m_callbacks[ent];
(cip->m_fullcb) (this, cip->m_userthis, cip->m_code); (cip->m_fullcb) (this, cip->m_userthis, cip->m_code);
} }
dumpDone ();
} }
void VerilatedVcd::dump (vluint64_t timeui) { void VerilatedVcd::dump (vluint64_t timeui) {
@ -657,7 +660,6 @@ void VerilatedVcd::dump (vluint64_t timeui) {
VerilatedVcdCallInfo *cip = m_callbacks[ent]; VerilatedVcdCallInfo *cip = m_callbacks[ent];
(cip->m_changecb) (this, cip->m_userthis, cip->m_code); (cip->m_changecb) (this, cip->m_userthis, cip->m_code);
} }
dumpDone();
} }
void VerilatedVcd::dumpPrep (vluint64_t timeui) { void VerilatedVcd::dumpPrep (vluint64_t timeui) {
@ -666,9 +668,6 @@ void VerilatedVcd::dumpPrep (vluint64_t timeui) {
printStr("\n"); printStr("\n");
} }
void VerilatedVcd::dumpDone () {
}
//====================================================================== //======================================================================
// Static members // Static members

View File

@ -24,6 +24,7 @@
#define _VERILATED_VCD_C_H_ 1 #define _VERILATED_VCD_C_H_ 1
#include "verilatedos.h" #include "verilatedos.h"
#include "verilated.h"
#include <string> #include <string>
#include <vector> #include <vector>
@ -128,8 +129,6 @@ private:
void dumpHeader(); void dumpHeader();
void dumpPrep (vluint64_t timeui); void dumpPrep (vluint64_t timeui);
void dumpFull (vluint64_t timeui); void dumpFull (vluint64_t timeui);
// cppcheck-suppress functionConst
void dumpDone ();
inline void printCode (vluint32_t code) { inline void printCode (vluint32_t code) {
if (code>=(94*94*94)) *m_writep++ = static_cast<char>((code/94/94/94)%94+33); if (code>=(94*94*94)) *m_writep++ = static_cast<char>((code/94/94/94)%94+33);
if (code>=(94*94)) *m_writep++ = static_cast<char>((code/94/94)%94+33); if (code>=(94*94)) *m_writep++ = static_cast<char>((code/94/94)%94+33);
@ -156,8 +155,6 @@ public:
~VerilatedVcd(); ~VerilatedVcd();
// ACCESSORS // ACCESSORS
/// Inside dumping routines, return next VCD signal code
vluint32_t nextCode() const {return m_nextCode;}
/// Set size in megabytes after which new file should be created /// Set size in megabytes after which new file should be created
void rolloverMB(vluint64_t rolloverMB) { m_rolloverMB=rolloverMB; }; void rolloverMB(vluint64_t rolloverMB) { m_rolloverMB=rolloverMB; };
/// Is file open? /// Is file open?
@ -170,9 +167,11 @@ public:
// METHODS // METHODS
void open (const char* filename); ///< Open the file; call isOpen() to see if errors void open (const char* filename); ///< Open the file; call isOpen() to see if errors
void openNext (bool incFilename); ///< Open next data-only file void openNext (bool incFilename); ///< Open next data-only file
void flush() { bufferFlush(); } ///< Flush any remaining data
static void flush_all(); ///< Flush any remaining data from all files
void close (); ///< Close the file void close (); ///< Close the file
/// Flush any remaining data to this file
void flush() { bufferFlush(); }
/// Flush any remaining data from all files
static void flush_all();
void set_time_unit (const char* unit); ///< Set time units (s/ms, defaults to ns) void set_time_unit (const char* unit); ///< Set time units (s/ms, defaults to ns)
void set_time_unit (const std::string& unit) { set_time_unit(unit.c_str()); } void set_time_unit (const std::string& unit) { set_time_unit(unit.c_str()); }

View File

@ -140,7 +140,7 @@ class OrderEitherVertex : public V3GraphVertex {
AstScope* m_scopep; // Scope the vertex is in AstScope* m_scopep; // Scope the vertex is in
AstSenTree* m_domainp; // Clock domain (NULL = to be computed as we iterate) AstSenTree* m_domainp; // Clock domain (NULL = to be computed as we iterate)
OrderLoopId m_inLoop; // Loop number vertex is in OrderLoopId m_inLoop; // Loop number vertex is in
bool m_isFromInput; // From input, or derrived therefrom (conservatively false) bool m_isFromInput; // From input, or derived therefrom (conservatively false)
protected: protected:
OrderEitherVertex(V3Graph* graphp, const OrderEitherVertex& old) OrderEitherVertex(V3Graph* graphp, const OrderEitherVertex& old)
: V3GraphVertex(graphp, old), m_scopep(old.m_scopep), m_domainp(old.m_domainp) : V3GraphVertex(graphp, old), m_scopep(old.m_scopep), m_domainp(old.m_domainp)