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;
}
public:
~VerilatedCovImp() { clear(); }
~VerilatedCovImp() { clearGuts(); }
static VerilatedCovImp& imp() {
static VerilatedCovImp 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 ("1.2.3.a","9.8.7.a") !="*.a") VL_FATAL_MT(__FILE__,__LINE__,"","%Error: selftest\n");
}
public:
// PUBLIC METHODS
void clear() {
void clearGuts() {
for (ItemList::const_iterator it=m_items.begin(); it!=m_items.end(); ++it) {
VerilatedCovImpItem* itemp = *(it);
delete itemp;
@ -229,6 +226,12 @@ public:
m_indexValues.clear();
m_valueIndexes.clear();
}
public:
// PUBLIC METHODS
void clear() {
clearGuts();
}
void clearNonMatch (const char* matchp) {
if (matchp && matchp[0]) {
ItemList newlist;

View File

@ -219,7 +219,7 @@ void VerilatedVcd::makeNameMap() {
m_namemapp = new NameMap;
for (vluint32_t ent = 0; ent< m_callbacks.size(); 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);
}
@ -265,6 +265,7 @@ VerilatedVcd::~VerilatedVcd() {
}
void VerilatedVcd::closePrev () {
// This function is on the flush() call path
if (!isOpen()) return;
bufferFlush();
@ -275,6 +276,7 @@ void VerilatedVcd::closePrev () {
void VerilatedVcd::closeErr () {
// Close due to an error. We might abort before even getting here,
// depending on the definition of vl_fatal.
// This function is on the flush() call path
if (!isOpen()) return;
// No buffer flush, just fclose
@ -283,6 +285,7 @@ void VerilatedVcd::closeErr () {
}
void VerilatedVcd::close() {
// This function is on the flush() call path
if (!isOpen()) return;
if (m_evcd) {
printStr("$vcdclose ");
@ -311,7 +314,7 @@ void VerilatedVcd::printTime (vluint64_t timeui) {
// Dinotrace doesn't mind, but Cadence vvision seems to choke
if (VL_UNLIKELY(timeui < m_timeLastDump)) {
timeui = m_timeLastDump;
static bool backTime = false;
static VL_THREAD_LOCAL bool backTime = false;
if (!backTime) {
backTime = true;
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 () {
// This function is on the flush() call path
// We add output data to m_writep.
// When it gets nearly full we dump it using this routine which calls write()
// 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
// 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) {
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";
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);
}
@ -638,7 +642,6 @@ void VerilatedVcd::dumpFull (vluint64_t timeui) {
VerilatedVcdCallInfo *cip = m_callbacks[ent];
(cip->m_fullcb) (this, cip->m_userthis, cip->m_code);
}
dumpDone ();
}
void VerilatedVcd::dump (vluint64_t timeui) {
@ -657,7 +660,6 @@ void VerilatedVcd::dump (vluint64_t timeui) {
VerilatedVcdCallInfo *cip = m_callbacks[ent];
(cip->m_changecb) (this, cip->m_userthis, cip->m_code);
}
dumpDone();
}
void VerilatedVcd::dumpPrep (vluint64_t timeui) {
@ -666,9 +668,6 @@ void VerilatedVcd::dumpPrep (vluint64_t timeui) {
printStr("\n");
}
void VerilatedVcd::dumpDone () {
}
//======================================================================
// Static members

View File

@ -24,6 +24,7 @@
#define _VERILATED_VCD_C_H_ 1
#include "verilatedos.h"
#include "verilated.h"
#include <string>
#include <vector>
@ -128,8 +129,6 @@ private:
void dumpHeader();
void dumpPrep (vluint64_t timeui);
void dumpFull (vluint64_t timeui);
// cppcheck-suppress functionConst
void dumpDone ();
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)) *m_writep++ = static_cast<char>((code/94/94)%94+33);
@ -156,8 +155,6 @@ public:
~VerilatedVcd();
// 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
void rolloverMB(vluint64_t rolloverMB) { m_rolloverMB=rolloverMB; };
/// Is file open?
@ -170,9 +167,11 @@ public:
// METHODS
void open (const char* filename); ///< Open the file; call isOpen() to see if errors
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
/// 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 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
AstSenTree* m_domainp; // Clock domain (NULL = to be computed as we iterate)
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:
OrderEitherVertex(V3Graph* graphp, const OrderEitherVertex& old)
: V3GraphVertex(graphp, old), m_scopep(old.m_scopep), m_domainp(old.m_domainp)