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