Internals: Use singleton in place of global
This commit is contained in:
parent
c2e8062f84
commit
3f14e649b5
|
|
@ -46,11 +46,6 @@
|
||||||
# define O_NONBLOCK 0
|
# define O_NONBLOCK 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
// Global
|
|
||||||
|
|
||||||
VerilatedVcd::VcdVec VerilatedVcd::s_vcdVecp; ///< List of all created traces
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// VerilatedVcdCallInfo
|
// VerilatedVcdCallInfo
|
||||||
/// Internal callback routines for each module being traced.
|
/// Internal callback routines for each module being traced.
|
||||||
|
|
@ -121,7 +116,7 @@ void VerilatedVcd::open (const char* filename) {
|
||||||
|
|
||||||
// Set member variables
|
// Set member variables
|
||||||
m_filename = filename;
|
m_filename = filename;
|
||||||
s_vcdVecp.push_back(this);
|
singleton().s_vcdVecp.push_back(this);
|
||||||
|
|
||||||
// SPDIFF_OFF
|
// SPDIFF_OFF
|
||||||
// Set callback so an early exit will flush us
|
// Set callback so an early exit will flush us
|
||||||
|
|
@ -234,8 +229,8 @@ VerilatedVcd::~VerilatedVcd() {
|
||||||
deleteNameMap();
|
deleteNameMap();
|
||||||
if (m_filep && m_fileNewed) { delete m_filep; m_filep = NULL; }
|
if (m_filep && m_fileNewed) { delete m_filep; m_filep = NULL; }
|
||||||
// Remove from list of traces
|
// Remove from list of traces
|
||||||
VcdVec::iterator pos = find(s_vcdVecp.begin(), s_vcdVecp.end(), this);
|
VcdVec::iterator pos = find(singleton().s_vcdVecp.begin(), singleton().s_vcdVecp.end(), this);
|
||||||
if (pos != s_vcdVecp.end()) { s_vcdVecp.erase(pos); }
|
if (pos != singleton().s_vcdVecp.end()) { singleton().s_vcdVecp.erase(pos); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::closePrev () {
|
void VerilatedVcd::closePrev () {
|
||||||
|
|
@ -647,8 +642,8 @@ void VerilatedVcd::dumpDone () {
|
||||||
// Static members
|
// Static members
|
||||||
|
|
||||||
void VerilatedVcd::flush_all() {
|
void VerilatedVcd::flush_all() {
|
||||||
for (vluint32_t ent = 0; ent< s_vcdVecp.size(); ent++) {
|
for (vluint32_t ent = 0; ent< singleton().s_vcdVecp.size(); ent++) {
|
||||||
VerilatedVcd* vcdp = s_vcdVecp[ent];
|
VerilatedVcd* vcdp = singleton().s_vcdVecp[ent];
|
||||||
vcdp->flush();
|
vcdp->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,8 +101,12 @@ private:
|
||||||
std::vector<VerilatedVcdCallInfo*> m_callbacks; ///< Routines to perform dumping
|
std::vector<VerilatedVcdCallInfo*> m_callbacks; ///< Routines to perform dumping
|
||||||
typedef std::map<std::string,std::string> NameMap;
|
typedef std::map<std::string,std::string> NameMap;
|
||||||
NameMap* m_namemapp; ///< List of names for the header
|
NameMap* m_namemapp; ///< List of names for the header
|
||||||
|
|
||||||
typedef std::vector<VerilatedVcd*> VcdVec;
|
typedef std::vector<VerilatedVcd*> VcdVec;
|
||||||
static VcdVec s_vcdVecp; ///< List of all created traces
|
struct Singleton {
|
||||||
|
VcdVec s_vcdVecp; ///< List of all created traces
|
||||||
|
};
|
||||||
|
static Singleton& singleton() { static Singleton s; return s; }
|
||||||
|
|
||||||
void bufferResize(vluint64_t minsize);
|
void bufferResize(vluint64_t minsize);
|
||||||
void bufferFlush();
|
void bufferFlush();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue