Includes: Fix spacing and style in prep for new LXT2. No functional change.
This commit is contained in:
parent
aad5c3ae75
commit
0b84222500
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
// SPDIFF_ON
|
// SPDIFF_ON
|
||||||
|
|
||||||
#ifndef O_LARGEFILE // For example on WIN32
|
#ifndef O_LARGEFILE // For example on WIN32
|
||||||
# define O_LARGEFILE 0
|
# define O_LARGEFILE 0
|
||||||
#endif
|
#endif
|
||||||
#ifndef O_NONBLOCK
|
#ifndef O_NONBLOCK
|
||||||
|
|
@ -58,25 +58,25 @@ private:
|
||||||
VerilatedMutex s_vcdMutex; ///< Protect the singleton
|
VerilatedMutex s_vcdMutex; ///< Protect the singleton
|
||||||
VcdVec s_vcdVecp VL_GUARDED_BY(s_vcdMutex); ///< List of all created traces
|
VcdVec s_vcdVecp VL_GUARDED_BY(s_vcdMutex); ///< List of all created traces
|
||||||
};
|
};
|
||||||
static Singleton& singleton() { static Singleton s; return s; }
|
static Singleton& singleton() { static Singleton s; return s; }
|
||||||
public:
|
public:
|
||||||
static void pushVcd(VerilatedVcd* vcdp) VL_EXCLUDES(singleton().s_vcdMutex) {
|
static void pushVcd(VerilatedVcd* vcdp) VL_EXCLUDES(singleton().s_vcdMutex) {
|
||||||
VerilatedLockGuard lock(singleton().s_vcdMutex);
|
VerilatedLockGuard lock(singleton().s_vcdMutex);
|
||||||
singleton().s_vcdVecp.push_back(vcdp);
|
singleton().s_vcdVecp.push_back(vcdp);
|
||||||
}
|
}
|
||||||
static void removeVcd(const VerilatedVcd* vcdp) VL_EXCLUDES(singleton().s_vcdMutex) {
|
static void removeVcd(const VerilatedVcd* vcdp) VL_EXCLUDES(singleton().s_vcdMutex) {
|
||||||
VerilatedLockGuard lock(singleton().s_vcdMutex);
|
VerilatedLockGuard lock(singleton().s_vcdMutex);
|
||||||
VcdVec::iterator pos = find(singleton().s_vcdVecp.begin(), singleton().s_vcdVecp.end(), vcdp);
|
VcdVec::iterator pos = find(singleton().s_vcdVecp.begin(), singleton().s_vcdVecp.end(), vcdp);
|
||||||
if (pos != singleton().s_vcdVecp.end()) { singleton().s_vcdVecp.erase(pos); }
|
if (pos != singleton().s_vcdVecp.end()) { singleton().s_vcdVecp.erase(pos); }
|
||||||
}
|
}
|
||||||
static void flush_all() VL_EXCLUDES(singleton().s_vcdMutex) VL_MT_UNSAFE_ONE {
|
static void flush_all() VL_EXCLUDES(singleton().s_vcdMutex) VL_MT_UNSAFE_ONE {
|
||||||
// Thread safety: Although this function is protected by a mutex so perhaps
|
// Thread safety: Although this function is protected by a mutex so perhaps
|
||||||
// in the future we can allow tracing in separate threads, vcdp->flush() assumes call from single thread
|
// in the future we can allow tracing in separate threads, vcdp->flush() assumes call from single thread
|
||||||
VerilatedLockGuard lock(singleton().s_vcdMutex);
|
VerilatedLockGuard lock(singleton().s_vcdMutex);
|
||||||
for (VcdVec::const_iterator it=singleton().s_vcdVecp.begin(); it!=singleton().s_vcdVecp.end(); ++it) {
|
for (VcdVec::const_iterator it=singleton().s_vcdVecp.begin(); it!=singleton().s_vcdVecp.end(); ++it) {
|
||||||
VerilatedVcd* vcdp = *it;
|
VerilatedVcd* vcdp = *it;
|
||||||
vcdp->flush();
|
vcdp->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -91,16 +91,16 @@ public:
|
||||||
class VerilatedVcdCallInfo {
|
class VerilatedVcdCallInfo {
|
||||||
protected:
|
protected:
|
||||||
friend class VerilatedVcd;
|
friend class VerilatedVcd;
|
||||||
VerilatedVcdCallback_t m_initcb; ///< Initialization Callback function
|
VerilatedVcdCallback_t m_initcb; ///< Initialization Callback function
|
||||||
VerilatedVcdCallback_t m_fullcb; ///< Full Dumping Callback function
|
VerilatedVcdCallback_t m_fullcb; ///< Full Dumping Callback function
|
||||||
VerilatedVcdCallback_t m_changecb; ///< Incremental Dumping Callback function
|
VerilatedVcdCallback_t m_changecb; ///< Incremental Dumping Callback function
|
||||||
void* m_userthis; ///< Fake "this" for caller
|
void* m_userthis; ///< Fake "this" for caller
|
||||||
vluint32_t m_code; ///< Starting code number
|
vluint32_t m_code; ///< Starting code number
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
VerilatedVcdCallInfo (VerilatedVcdCallback_t icb, VerilatedVcdCallback_t fcb,
|
VerilatedVcdCallInfo(VerilatedVcdCallback_t icb, VerilatedVcdCallback_t fcb,
|
||||||
VerilatedVcdCallback_t changecb,
|
VerilatedVcdCallback_t changecb,
|
||||||
void* ut, vluint32_t code)
|
void* ut, vluint32_t code)
|
||||||
: m_initcb(icb), m_fullcb(fcb), m_changecb(changecb), m_userthis(ut), m_code(code) {};
|
: m_initcb(icb), m_fullcb(fcb), m_changecb(changecb), m_userthis(ut), m_code(code) {};
|
||||||
~VerilatedVcdCallInfo() {}
|
~VerilatedVcdCallInfo() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -146,7 +146,7 @@ VerilatedVcd::VerilatedVcd(VerilatedVcdFile* filep)
|
||||||
m_wroteBytes = 0;
|
m_wroteBytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::open (const char* filename) {
|
void VerilatedVcd::open(const char* filename) {
|
||||||
m_assertOne.check();
|
m_assertOne.check();
|
||||||
if (isOpen()) return;
|
if (isOpen()) return;
|
||||||
|
|
||||||
|
|
@ -159,64 +159,64 @@ void VerilatedVcd::open (const char* filename) {
|
||||||
Verilated::flushCb(&flush_all);
|
Verilated::flushCb(&flush_all);
|
||||||
|
|
||||||
// SPDIFF_ON
|
// SPDIFF_ON
|
||||||
openNext (m_rolloverMB!=0);
|
openNext(m_rolloverMB!=0);
|
||||||
if (!isOpen()) return;
|
if (!isOpen()) return;
|
||||||
|
|
||||||
dumpHeader();
|
dumpHeader();
|
||||||
|
|
||||||
// Allocate space now we know the number of codes
|
// Allocate space now we know the number of codes
|
||||||
if (!m_sigs_oldvalp) {
|
if (!m_sigs_oldvalp) {
|
||||||
m_sigs_oldvalp = new vluint32_t [m_nextCode+10];
|
m_sigs_oldvalp = new vluint32_t [m_nextCode+10];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_rolloverMB) {
|
if (m_rolloverMB) {
|
||||||
openNext(true);
|
openNext(true);
|
||||||
if (!isOpen()) return;
|
if (!isOpen()) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::openNext (bool incFilename) {
|
void VerilatedVcd::openNext(bool incFilename) {
|
||||||
// Open next filename in concat sequence, mangle filename if
|
// Open next filename in concat sequence, mangle filename if
|
||||||
// incFilename is true.
|
// incFilename is true.
|
||||||
m_assertOne.check();
|
m_assertOne.check();
|
||||||
closePrev(); // Close existing
|
closePrev(); // Close existing
|
||||||
if (incFilename) {
|
if (incFilename) {
|
||||||
// Find _0000.{ext} in filename
|
// Find _0000.{ext} in filename
|
||||||
std::string name = m_filename;
|
std::string name = m_filename;
|
||||||
size_t pos=name.rfind(".");
|
size_t pos=name.rfind(".");
|
||||||
if (pos>8 && 0==strncmp("_cat",name.c_str()+pos-8,4)
|
if (pos>8 && 0==strncmp("_cat",name.c_str()+pos-8,4)
|
||||||
&& isdigit(name.c_str()[pos-4])
|
&& isdigit(name.c_str()[pos-4])
|
||||||
&& isdigit(name.c_str()[pos-3])
|
&& isdigit(name.c_str()[pos-3])
|
||||||
&& isdigit(name.c_str()[pos-2])
|
&& isdigit(name.c_str()[pos-2])
|
||||||
&& isdigit(name.c_str()[pos-1])) {
|
&& isdigit(name.c_str()[pos-1])) {
|
||||||
// Increment code.
|
// Increment code.
|
||||||
if ((++(name[pos-1])) > '9') {
|
if ((++(name[pos-1])) > '9') {
|
||||||
name[pos-1] = '0';
|
name[pos-1] = '0';
|
||||||
if ((++(name[pos-2])) > '9') {
|
if ((++(name[pos-2])) > '9') {
|
||||||
name[pos-2] = '0';
|
name[pos-2] = '0';
|
||||||
if ((++(name[pos-3])) > '9') {
|
if ((++(name[pos-3])) > '9') {
|
||||||
name[pos-3] = '0';
|
name[pos-3] = '0';
|
||||||
if ((++(name[pos-4])) > '9') {
|
if ((++(name[pos-4])) > '9') {
|
||||||
name[pos-4] = '0';
|
name[pos-4] = '0';
|
||||||
}}}}
|
}}}}
|
||||||
} else {
|
} else {
|
||||||
// Append _cat0000
|
// Append _cat0000
|
||||||
name.insert(pos,"_cat0000");
|
name.insert(pos,"_cat0000");
|
||||||
}
|
}
|
||||||
m_filename = name;
|
m_filename = name;
|
||||||
}
|
}
|
||||||
if (m_filename[0]=='|') {
|
if (m_filename[0]=='|') {
|
||||||
assert(0); // Not supported yet.
|
assert(0); // Not supported yet.
|
||||||
} else {
|
} else {
|
||||||
// cppcheck-suppress duplicateExpression
|
// cppcheck-suppress duplicateExpression
|
||||||
if (!m_filep->open(m_filename)) {
|
if (!m_filep->open(m_filename)) {
|
||||||
// User code can check isOpen()
|
// User code can check isOpen()
|
||||||
m_isOpen = false;
|
m_isOpen = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_isOpen = true;
|
m_isOpen = true;
|
||||||
m_fullDump = true; // First dump must be full
|
m_fullDump = true; // First dump must be full
|
||||||
m_wroteBytes = 0;
|
m_wroteBytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -226,9 +226,9 @@ void VerilatedVcd::makeNameMap() {
|
||||||
m_nextCode = 1;
|
m_nextCode = 1;
|
||||||
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 = m_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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Though not speced, it's illegal to generate a vcd with signals
|
// Though not speced, it's illegal to generate a vcd with signals
|
||||||
|
|
@ -237,21 +237,21 @@ void VerilatedVcd::makeNameMap() {
|
||||||
// This comes from user instantiations with no name - IE Vtop("").
|
// This comes from user instantiations with no name - IE Vtop("").
|
||||||
bool nullScope = false;
|
bool nullScope = false;
|
||||||
for (NameMap::const_iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) {
|
for (NameMap::const_iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) {
|
||||||
const std::string& hiername = it->first;
|
const std::string& hiername = it->first;
|
||||||
if (hiername.size() >= 1 && hiername[0] == '\t') nullScope=true;
|
if (hiername.size() >= 1 && hiername[0] == '\t') nullScope=true;
|
||||||
}
|
}
|
||||||
if (nullScope) {
|
if (nullScope) {
|
||||||
NameMap* newmapp = new NameMap;
|
NameMap* newmapp = new NameMap;
|
||||||
for (NameMap::const_iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) {
|
for (NameMap::const_iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) {
|
||||||
const std::string& hiername = it->first;
|
const std::string& hiername = it->first;
|
||||||
const std::string& decl = it->second;
|
const std::string& decl = it->second;
|
||||||
std::string newname = std::string("top");
|
std::string newname = std::string("top");
|
||||||
if (hiername[0] != '\t') newname += ' ';
|
if (hiername[0] != '\t') newname += ' ';
|
||||||
newname += hiername;
|
newname += hiername;
|
||||||
newmapp->insert(std::make_pair(newname,decl));
|
newmapp->insert(std::make_pair(newname,decl));
|
||||||
}
|
}
|
||||||
deleteNameMap();
|
deleteNameMap();
|
||||||
m_namemapp = newmapp;
|
m_namemapp = newmapp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,13 +266,13 @@ 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; }
|
||||||
for (CallbackVec::const_iterator it=m_callbacks.begin(); it!=m_callbacks.end(); ++it) {
|
for (CallbackVec::const_iterator it=m_callbacks.begin(); it!=m_callbacks.end(); ++it) {
|
||||||
delete (*it);
|
delete (*it);
|
||||||
}
|
}
|
||||||
m_callbacks.clear();
|
m_callbacks.clear();
|
||||||
VerilatedVcdSingleton::removeVcd(this);
|
VerilatedVcdSingleton::removeVcd(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::closePrev () {
|
void VerilatedVcd::closePrev() {
|
||||||
// This function is on the flush() call path
|
// This function is on the flush() call path
|
||||||
if (!isOpen()) return;
|
if (!isOpen()) return;
|
||||||
|
|
||||||
|
|
@ -281,7 +281,7 @@ void VerilatedVcd::closePrev () {
|
||||||
m_filep->close();
|
m_filep->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::closeErr () {
|
void VerilatedVcd::closeErr() {
|
||||||
// This function is on the flush() call path
|
// This function is on the flush() call path
|
||||||
// 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.
|
||||||
|
|
@ -297,37 +297,37 @@ void VerilatedVcd::close() {
|
||||||
m_assertOne.check();
|
m_assertOne.check();
|
||||||
if (!isOpen()) return;
|
if (!isOpen()) return;
|
||||||
if (m_evcd) {
|
if (m_evcd) {
|
||||||
printStr("$vcdclose ");
|
printStr("$vcdclose ");
|
||||||
printTime(m_timeLastDump);
|
printTime(m_timeLastDump);
|
||||||
printStr(" $end\n");
|
printStr(" $end\n");
|
||||||
}
|
}
|
||||||
closePrev();
|
closePrev();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::printStr (const char* str) {
|
void VerilatedVcd::printStr(const char* str) {
|
||||||
// Not fast...
|
// Not fast...
|
||||||
while (*str) {
|
while (*str) {
|
||||||
*m_writep++ = *str++;
|
*m_writep++ = *str++;
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::printQuad (vluint64_t n) {
|
void VerilatedVcd::printQuad(vluint64_t n) {
|
||||||
char buf [100];
|
char buf [100];
|
||||||
sprintf(buf,"%" VL_PRI64 "u", n);
|
sprintf(buf,"%" VL_PRI64 "u", n);
|
||||||
printStr(buf);
|
printStr(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::printTime (vluint64_t timeui) {
|
void VerilatedVcd::printTime(vluint64_t timeui) {
|
||||||
// VCD file format specification does not allow non-integers for timestamps
|
// VCD file format specification does not allow non-integers for timestamps
|
||||||
// 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 VL_THREAD_LOCAL bool backTime = false;
|
static VL_THREAD_LOCAL bool backTime = false;
|
||||||
if (!backTime) {
|
if (!backTime) {
|
||||||
backTime = true;
|
backTime = true;
|
||||||
VL_PRINTF_MT("%%Warning: VCD time is moving backwards, wave file may be incorrect.\n");
|
VL_PRINTF_MT("%%Warning: VCD time is moving backwards, wave file may be incorrect.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_timeLastDump = timeui;
|
m_timeLastDump = timeui;
|
||||||
printQuad(timeui);
|
printQuad(timeui);
|
||||||
|
|
@ -337,17 +337,17 @@ void VerilatedVcd::bufferResize(vluint64_t minsize) {
|
||||||
// minsize is size of largest write. We buffer at least 8 times as much data,
|
// minsize is size of largest write. We buffer at least 8 times as much data,
|
||||||
// writing when we are 3/4 full (with thus 2*minsize remaining free)
|
// writing when we are 3/4 full (with thus 2*minsize remaining free)
|
||||||
if (VL_UNLIKELY(minsize > m_wrChunkSize)) {
|
if (VL_UNLIKELY(minsize > m_wrChunkSize)) {
|
||||||
char* oldbufp = m_wrBufp;
|
char* oldbufp = m_wrBufp;
|
||||||
m_wrChunkSize = minsize*2;
|
m_wrChunkSize = minsize*2;
|
||||||
m_wrBufp = new char [m_wrChunkSize * 8];
|
m_wrBufp = new char [m_wrChunkSize * 8];
|
||||||
memcpy(m_wrBufp, oldbufp, m_writep - oldbufp);
|
memcpy(m_wrBufp, oldbufp, m_writep - oldbufp);
|
||||||
m_writep = m_wrBufp + (m_writep - oldbufp);
|
m_writep = m_wrBufp + (m_writep - oldbufp);
|
||||||
m_wrFlushp = m_wrBufp + m_wrChunkSize * 6;
|
m_wrFlushp = m_wrBufp + m_wrChunkSize * 6;
|
||||||
delete [] oldbufp; oldbufp=NULL;
|
delete [] oldbufp; oldbufp=NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::bufferFlush () VL_MT_UNSAFE_ONE {
|
void VerilatedVcd::bufferFlush() VL_MT_UNSAFE_ONE {
|
||||||
// This function is on the flush() call path
|
// 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()
|
||||||
|
|
@ -356,22 +356,22 @@ void VerilatedVcd::bufferFlush () VL_MT_UNSAFE_ONE {
|
||||||
if (VL_UNLIKELY(!isOpen())) return;
|
if (VL_UNLIKELY(!isOpen())) return;
|
||||||
char* wp = m_wrBufp;
|
char* wp = m_wrBufp;
|
||||||
while (1) {
|
while (1) {
|
||||||
ssize_t remaining = (m_writep - wp);
|
ssize_t remaining = (m_writep - wp);
|
||||||
if (remaining==0) break;
|
if (remaining==0) break;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
ssize_t got = m_filep->write(wp, remaining);
|
ssize_t got = m_filep->write(wp, remaining);
|
||||||
if (got>0) {
|
if (got>0) {
|
||||||
wp += got;
|
wp += got;
|
||||||
m_wroteBytes += got;
|
m_wroteBytes += got;
|
||||||
} else if (got < 0) {
|
} else if (got < 0) {
|
||||||
if (errno != EAGAIN && errno != EINTR) {
|
if (errno != EAGAIN && errno != EINTR) {
|
||||||
// write failed, presume error (perhaps out of disk space)
|
// write failed, presume error (perhaps out of disk space)
|
||||||
std::string msg = std::string("VerilatedVcd::bufferFlush: ")+strerror(errno);
|
std::string msg = std::string("VerilatedVcd::bufferFlush: ")+strerror(errno);
|
||||||
VL_FATAL_MT("",0,"",msg.c_str());
|
VL_FATAL_MT("",0,"",msg.c_str());
|
||||||
closeErr();
|
closeErr();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset buffer
|
// Reset buffer
|
||||||
|
|
@ -381,19 +381,19 @@ void VerilatedVcd::bufferFlush () VL_MT_UNSAFE_ONE {
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Simple methods
|
// Simple methods
|
||||||
|
|
||||||
void VerilatedVcd::set_time_unit (const char* unitp) {
|
void VerilatedVcd::set_time_unit(const char* unitp) {
|
||||||
//cout<<" set_time_unit ("<<unitp<<") == "<<timescaleToDouble(unitp)
|
//cout<<" set_time_unit("<<unitp<<") == "<<timescaleToDouble(unitp)
|
||||||
// <<" == "<<doubleToTimescale(timescaleToDouble(unitp))<<endl;
|
// <<" == "<<doubleToTimescale(timescaleToDouble(unitp))<<endl;
|
||||||
m_timeUnit = timescaleToDouble(unitp);
|
m_timeUnit = timescaleToDouble(unitp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::set_time_resolution (const char* unitp) {
|
void VerilatedVcd::set_time_resolution(const char* unitp) {
|
||||||
//cout<<"set_time_resolution ("<<unitp<<") == "<<timescaleToDouble(unitp)
|
//cout<<"set_time_resolution("<<unitp<<") == "<<timescaleToDouble(unitp)
|
||||||
// <<" == "<<doubleToTimescale(timescaleToDouble(unitp))<<endl;
|
// <<" == "<<doubleToTimescale(timescaleToDouble(unitp))<<endl;
|
||||||
m_timeRes = timescaleToDouble(unitp);
|
m_timeRes = timescaleToDouble(unitp);
|
||||||
}
|
}
|
||||||
|
|
||||||
double VerilatedVcd::timescaleToDouble (const char* unitp) {
|
double VerilatedVcd::timescaleToDouble(const char* unitp) {
|
||||||
char* endp;
|
char* endp;
|
||||||
double value = strtod(unitp, &endp);
|
double value = strtod(unitp, &endp);
|
||||||
if (value==0.0 && endp==unitp) value=1; // On error so we allow just "ns" to return 1e-9.
|
if (value==0.0 && endp==unitp) value=1; // On error so we allow just "ns" to return 1e-9.
|
||||||
|
|
@ -411,9 +411,9 @@ double VerilatedVcd::timescaleToDouble (const char* unitp) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string VerilatedVcd::doubleToTimescale (double value) {
|
std::string VerilatedVcd::doubleToTimescale(double value) {
|
||||||
const char* suffixp = "s";
|
const char* suffixp = "s";
|
||||||
if (value>=1e0) { suffixp="s"; value *= 1e0; }
|
if (value>=1e0) { suffixp="s"; value *= 1e0; }
|
||||||
else if (value>=1e-3 ) { suffixp="ms"; value *= 1e3; }
|
else if (value>=1e-3 ) { suffixp="ms"; value *= 1e3; }
|
||||||
else if (value>=1e-6 ) { suffixp="us"; value *= 1e6; }
|
else if (value>=1e-6 ) { suffixp="us"; value *= 1e6; }
|
||||||
else if (value>=1e-9 ) { suffixp="ns"; value *= 1e9; }
|
else if (value>=1e-9 ) { suffixp="ns"; value *= 1e9; }
|
||||||
|
|
@ -427,14 +427,14 @@ std::string VerilatedVcd::doubleToTimescale (double value) {
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Definitions
|
// Definitions
|
||||||
|
|
||||||
void VerilatedVcd::printIndent (int level_change) {
|
void VerilatedVcd::printIndent(int level_change) {
|
||||||
if (level_change<0) m_modDepth += level_change;
|
if (level_change<0) m_modDepth += level_change;
|
||||||
assert(m_modDepth>=0);
|
assert(m_modDepth>=0);
|
||||||
for (int i=0; i<m_modDepth; i++) printStr(" ");
|
for (int i=0; i<m_modDepth; i++) printStr(" ");
|
||||||
if (level_change>0) m_modDepth += level_change;
|
if (level_change>0) m_modDepth += level_change;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::dumpHeader () {
|
void VerilatedVcd::dumpHeader() {
|
||||||
printStr("$version Generated by VerilatedVcd $end\n");
|
printStr("$version Generated by VerilatedVcd $end\n");
|
||||||
time_t time_str = time(NULL);
|
time_t time_str = time(NULL);
|
||||||
printStr("$date "); printStr(ctime(&time_str)); printStr(" $end\n");
|
printStr("$date "); printStr(ctime(&time_str)); printStr(" $end\n");
|
||||||
|
|
@ -447,7 +447,7 @@ void VerilatedVcd::dumpHeader () {
|
||||||
makeNameMap();
|
makeNameMap();
|
||||||
|
|
||||||
// Signal header
|
// Signal header
|
||||||
assert (m_modDepth==0);
|
assert(m_modDepth==0);
|
||||||
printIndent(1);
|
printIndent(1);
|
||||||
printStr("\n");
|
printStr("\n");
|
||||||
|
|
||||||
|
|
@ -459,78 +459,78 @@ void VerilatedVcd::dumpHeader () {
|
||||||
// Print the signal names
|
// Print the signal names
|
||||||
const char* lastName = "";
|
const char* lastName = "";
|
||||||
for (NameMap::const_iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) {
|
for (NameMap::const_iterator it=m_namemapp->begin(); it!=m_namemapp->end(); ++it) {
|
||||||
const std::string& hiernamestr = it->first;
|
const std::string& hiernamestr = it->first;
|
||||||
const std::string& decl = it->second;
|
const std::string& decl = it->second;
|
||||||
|
|
||||||
// Determine difference between the old and new names
|
// Determine difference between the old and new names
|
||||||
const char* hiername = hiernamestr.c_str();
|
const char* hiername = hiernamestr.c_str();
|
||||||
const char* lp = lastName;
|
const char* lp = lastName;
|
||||||
const char* np = hiername;
|
const char* np = hiername;
|
||||||
lastName = hiername;
|
lastName = hiername;
|
||||||
|
|
||||||
// Skip common prefix, it must break at a space or tab
|
// Skip common prefix, it must break at a space or tab
|
||||||
for (; *np && (*np == *lp); np++, lp++) {}
|
for (; *np && (*np == *lp); np++, lp++) {}
|
||||||
while (np!=hiername && *np && *np!=' ' && *np!='\t') { np--; lp--; }
|
while (np!=hiername && *np && *np!=' ' && *np!='\t') { np--; lp--; }
|
||||||
//printf("hier %s\n lp=%s\n np=%s\n",hiername,lp,np);
|
//printf("hier %s\n lp=%s\n np=%s\n",hiername,lp,np);
|
||||||
|
|
||||||
// Any extra spaces in last name are scope ups we need to do
|
// Any extra spaces in last name are scope ups we need to do
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (; *lp; lp++) {
|
for (; *lp; lp++) {
|
||||||
if (*lp==' ' || (first && *lp!='\t')) {
|
if (*lp==' ' || (first && *lp!='\t')) {
|
||||||
printIndent(-1);
|
printIndent(-1);
|
||||||
printStr("$upscope $end\n");
|
printStr("$upscope $end\n");
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any new spaces are scope downs we need to do
|
// Any new spaces are scope downs we need to do
|
||||||
while (*np) {
|
while (*np) {
|
||||||
if (*np==' ') np++;
|
if (*np==' ') np++;
|
||||||
if (*np=='\t') break; // tab means signal name starts
|
if (*np=='\t') break; // tab means signal name starts
|
||||||
printIndent(1);
|
printIndent(1);
|
||||||
printStr("$scope module ");
|
printStr("$scope module ");
|
||||||
for (; *np && *np!=' ' && *np!='\t'; np++) {
|
for (; *np && *np!=' ' && *np!='\t'; np++) {
|
||||||
if (*np=='[') printStr("(");
|
if (*np=='[') printStr("(");
|
||||||
else if (*np==']') printStr(")");
|
else if (*np==']') printStr(")");
|
||||||
else *m_writep++=*np;
|
else *m_writep++=*np;
|
||||||
}
|
}
|
||||||
printStr(" $end\n");
|
printStr(" $end\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
printIndent(0);
|
printIndent(0);
|
||||||
printStr(decl.c_str());
|
printStr(decl.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
while (m_modDepth>1) {
|
while (m_modDepth>1) {
|
||||||
printIndent(-1);
|
printIndent(-1);
|
||||||
printStr("$upscope $end\n");
|
printStr("$upscope $end\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
printIndent(-1);
|
printIndent(-1);
|
||||||
printStr("$enddefinitions $end\n\n\n");
|
printStr("$enddefinitions $end\n\n\n");
|
||||||
assert (m_modDepth==0);
|
assert(m_modDepth==0);
|
||||||
|
|
||||||
// Reclaim storage
|
// Reclaim storage
|
||||||
deleteNameMap();
|
deleteNameMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::module (const std::string& name) {
|
void VerilatedVcd::module(const std::string& name) {
|
||||||
m_assertOne.check();
|
m_assertOne.check();
|
||||||
m_modName = name;
|
m_modName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::declare (vluint32_t code, const char* name, const char* wirep,
|
void VerilatedVcd::declare(vluint32_t code, const char* name, const char* wirep,
|
||||||
int arraynum, bool tri, bool bussed, int msb, int lsb) {
|
int arraynum, bool tri, bool bussed, int msb, int lsb) {
|
||||||
if (!code) { VL_FATAL_MT(__FILE__,__LINE__,"","Internal: internal trace problem, code 0 is illegal"); }
|
if (!code) { VL_FATAL_MT(__FILE__,__LINE__,"","Internal: internal trace problem, code 0 is illegal"); }
|
||||||
|
|
||||||
int bits = ((msb>lsb)?(msb-lsb):(lsb-msb))+1;
|
int bits = ((msb>lsb)?(msb-lsb):(lsb-msb))+1;
|
||||||
int codesNeeded = 1+int(bits/32);
|
int codesNeeded = 1+int(bits/32);
|
||||||
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(m_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
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure write buffer is large enough (one character per bit), plus header
|
// Make sure write buffer is large enough (one character per bit), plus header
|
||||||
|
|
@ -551,14 +551,14 @@ void VerilatedVcd::declare (vluint32_t code, const char* name, const char* wirep
|
||||||
std::string hiername;
|
std::string hiername;
|
||||||
std::string basename;
|
std::string basename;
|
||||||
for (const char* cp=nameasstr.c_str(); *cp; cp++) {
|
for (const char* cp=nameasstr.c_str(); *cp; cp++) {
|
||||||
if (isScopeEscape(*cp)) {
|
if (isScopeEscape(*cp)) {
|
||||||
// Ahh, we've just read a scope, not a basename
|
// Ahh, we've just read a scope, not a basename
|
||||||
if (hiername!="") hiername += " ";
|
if (hiername!="") hiername += " ";
|
||||||
hiername += basename;
|
hiername += basename;
|
||||||
basename = "";
|
basename = "";
|
||||||
} else {
|
} else {
|
||||||
basename += *cp;
|
basename += *cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hiername += "\t"+basename;
|
hiername += "\t"+basename;
|
||||||
|
|
||||||
|
|
@ -570,49 +570,49 @@ void VerilatedVcd::declare (vluint32_t code, const char* name, const char* wirep
|
||||||
decl += buf;
|
decl += buf;
|
||||||
if (m_evcd) {
|
if (m_evcd) {
|
||||||
sprintf(buf, "<%u", code);
|
sprintf(buf, "<%u", code);
|
||||||
decl += buf;
|
decl += buf;
|
||||||
} else {
|
} else {
|
||||||
decl += stringCode(code);
|
decl += stringCode(code);
|
||||||
}
|
}
|
||||||
decl += " ";
|
decl += " ";
|
||||||
decl += basename;
|
decl += basename;
|
||||||
if (arraynum>=0) {
|
if (arraynum>=0) {
|
||||||
sprintf(buf, "(%d)", arraynum);
|
sprintf(buf, "(%d)", arraynum);
|
||||||
decl += buf;
|
decl += buf;
|
||||||
hiername += buf;
|
hiername += buf;
|
||||||
}
|
}
|
||||||
if (bussed) {
|
if (bussed) {
|
||||||
sprintf(buf, " [%d:%d]", msb, lsb);
|
sprintf(buf, " [%d:%d]", msb, lsb);
|
||||||
decl += buf;
|
decl += buf;
|
||||||
}
|
}
|
||||||
decl += " $end\n";
|
decl += " $end\n";
|
||||||
m_namemapp->insert(std::make_pair(hiername,decl));
|
m_namemapp->insert(std::make_pair(hiername,decl));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::declBit (vluint32_t code, const char* name, int arraynum)
|
void VerilatedVcd::declBit (vluint32_t code, const char* name, int arraynum)
|
||||||
{ declare (code, name, "wire", arraynum, false, false, 0, 0); }
|
{ declare(code, name, "wire", arraynum, false, false, 0, 0); }
|
||||||
void VerilatedVcd::declBus (vluint32_t code, const char* name, int arraynum, int msb, int lsb)
|
void VerilatedVcd::declBus (vluint32_t code, const char* name, int arraynum, int msb, int lsb)
|
||||||
{ declare (code, name, "wire", arraynum, false, true, msb, lsb); }
|
{ declare(code, name, "wire", arraynum, false, true, msb, lsb); }
|
||||||
void VerilatedVcd::declQuad (vluint32_t code, const char* name, int arraynum, int msb, int lsb)
|
void VerilatedVcd::declQuad (vluint32_t code, const char* name, int arraynum, int msb, int lsb)
|
||||||
{ declare (code, name, "wire", arraynum, false, true, msb, lsb); }
|
{ declare(code, name, "wire", arraynum, false, true, msb, lsb); }
|
||||||
void VerilatedVcd::declArray (vluint32_t code, const char* name, int arraynum, int msb, int lsb)
|
void VerilatedVcd::declArray (vluint32_t code, const char* name, int arraynum, int msb, int lsb)
|
||||||
{ declare (code, name, "wire", arraynum, false, true, msb, lsb); }
|
{ declare(code, name, "wire", arraynum, false, true, msb, lsb); }
|
||||||
void VerilatedVcd::declTriBit (vluint32_t code, const char* name, int arraynum)
|
void VerilatedVcd::declTriBit (vluint32_t code, const char* name, int arraynum)
|
||||||
{ declare (code, name, "wire", arraynum, true, false, 0, 0); }
|
{ declare(code, name, "wire", arraynum, true, false, 0, 0); }
|
||||||
void VerilatedVcd::declTriBus (vluint32_t code, const char* name, int arraynum, int msb, int lsb)
|
void VerilatedVcd::declTriBus (vluint32_t code, const char* name, int arraynum, int msb, int lsb)
|
||||||
{ declare (code, name, "wire", arraynum, true, true, msb, lsb); }
|
{ declare(code, name, "wire", arraynum, true, true, msb, lsb); }
|
||||||
void VerilatedVcd::declTriQuad (vluint32_t code, const char* name, int arraynum, int msb, int lsb)
|
void VerilatedVcd::declTriQuad (vluint32_t code, const char* name, int arraynum, int msb, int lsb)
|
||||||
{ declare (code, name, "wire", arraynum, true, true, msb, lsb); }
|
{ declare(code, name, "wire", arraynum, true, true, msb, lsb); }
|
||||||
void VerilatedVcd::declTriArray (vluint32_t code, const char* name, int arraynum, int msb, int lsb)
|
void VerilatedVcd::declTriArray (vluint32_t code, const char* name, int arraynum, int msb, int lsb)
|
||||||
{ declare (code, name, "wire", arraynum, true, true, msb, lsb); }
|
{ declare(code, name, "wire", arraynum, true, true, msb, lsb); }
|
||||||
void VerilatedVcd::declFloat (vluint32_t code, const char* name, int arraynum)
|
void VerilatedVcd::declFloat (vluint32_t code, const char* name, int arraynum)
|
||||||
{ declare (code, name, "real", arraynum, false, false, 31, 0); }
|
{ declare(code, name, "real", arraynum, false, false, 31, 0); }
|
||||||
void VerilatedVcd::declDouble (vluint32_t code, const char* name, int arraynum)
|
void VerilatedVcd::declDouble (vluint32_t code, const char* name, int arraynum)
|
||||||
{ declare (code, name, "real", arraynum, false, false, 63, 0); }
|
{ declare(code, name, "real", arraynum, false, false, 63, 0); }
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
void VerilatedVcd::fullDouble (vluint32_t code, const double newval) {
|
void VerilatedVcd::fullDouble(vluint32_t code, const double newval) {
|
||||||
// cppcheck-suppress invalidPointerCast
|
// cppcheck-suppress invalidPointerCast
|
||||||
(*(reinterpret_cast<double*>(&m_sigs_oldvalp[code]))) = newval;
|
(*(reinterpret_cast<double*>(&m_sigs_oldvalp[code]))) = newval;
|
||||||
// Buffer can't overflow before sprintf; we sized during declaration
|
// Buffer can't overflow before sprintf; we sized during declaration
|
||||||
|
|
@ -621,7 +621,7 @@ void VerilatedVcd::fullDouble (vluint32_t code, const double newval) {
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void VerilatedVcd::fullFloat (vluint32_t code, const float newval) {
|
void VerilatedVcd::fullFloat(vluint32_t code, const float newval) {
|
||||||
// cppcheck-suppress invalidPointerCast
|
// cppcheck-suppress invalidPointerCast
|
||||||
(*(reinterpret_cast<float*>(&m_sigs_oldvalp[code]))) = newval;
|
(*(reinterpret_cast<float*>(&m_sigs_oldvalp[code]))) = newval;
|
||||||
// Buffer can't overflow before sprintf; we sized during declaration
|
// Buffer can't overflow before sprintf; we sized during declaration
|
||||||
|
|
@ -634,14 +634,14 @@ void VerilatedVcd::fullFloat (vluint32_t code, const float newval) {
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Callbacks
|
// Callbacks
|
||||||
|
|
||||||
void VerilatedVcd::addCallback VL_MT_UNSAFE_ONE (
|
void VerilatedVcd::addCallback(
|
||||||
VerilatedVcdCallback_t initcb, VerilatedVcdCallback_t fullcb, VerilatedVcdCallback_t changecb,
|
VerilatedVcdCallback_t initcb, VerilatedVcdCallback_t fullcb, VerilatedVcdCallback_t changecb,
|
||||||
void* userthis)
|
void* userthis) VL_MT_UNSAFE_ONE
|
||||||
{
|
{
|
||||||
m_assertOne.check();
|
m_assertOne.check();
|
||||||
if (VL_UNLIKELY(isOpen())) {
|
if (VL_UNLIKELY(isOpen())) {
|
||||||
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, m_nextCode);
|
VerilatedVcdCallInfo* vci = new VerilatedVcdCallInfo(initcb, fullcb, changecb, userthis, m_nextCode);
|
||||||
m_callbacks.push_back(vci);
|
m_callbacks.push_back(vci);
|
||||||
|
|
@ -650,37 +650,37 @@ void VerilatedVcd::addCallback VL_MT_UNSAFE_ONE (
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Dumping
|
// Dumping
|
||||||
|
|
||||||
void VerilatedVcd::dumpFull (vluint64_t timeui) {
|
void VerilatedVcd::dumpFull(vluint64_t timeui) {
|
||||||
m_assertOne.check();
|
m_assertOne.check();
|
||||||
dumpPrep (timeui);
|
dumpPrep(timeui);
|
||||||
Verilated::quiesce();
|
Verilated::quiesce();
|
||||||
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_fullcb) (this, cip->m_userthis, cip->m_code);
|
(cip->m_fullcb) (this, cip->m_userthis, cip->m_code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::dump (vluint64_t timeui) {
|
void VerilatedVcd::dump(vluint64_t timeui) {
|
||||||
m_assertOne.check();
|
m_assertOne.check();
|
||||||
if (!isOpen()) return;
|
if (!isOpen()) return;
|
||||||
if (VL_UNLIKELY(m_fullDump)) {
|
if (VL_UNLIKELY(m_fullDump)) {
|
||||||
m_fullDump = false; // No need for more full dumps
|
m_fullDump = false; // No need for more full dumps
|
||||||
dumpFull(timeui);
|
dumpFull(timeui);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (VL_UNLIKELY(m_rolloverMB && m_wroteBytes > this->m_rolloverMB)) {
|
if (VL_UNLIKELY(m_rolloverMB && m_wroteBytes > this->m_rolloverMB)) {
|
||||||
openNext(true);
|
openNext(true);
|
||||||
if (!isOpen()) return;
|
if (!isOpen()) return;
|
||||||
}
|
}
|
||||||
dumpPrep (timeui);
|
dumpPrep(timeui);
|
||||||
Verilated::quiesce();
|
Verilated::quiesce();
|
||||||
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_changecb) (this, cip->m_userthis, cip->m_code);
|
(cip->m_changecb) (this, cip->m_userthis, cip->m_code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::dumpPrep (vluint64_t timeui) {
|
void VerilatedVcd::dumpPrep(vluint64_t timeui) {
|
||||||
printStr("#");
|
printStr("#");
|
||||||
printTime(timeui);
|
printTime(timeui);
|
||||||
printStr("\n");
|
printStr("\n");
|
||||||
|
|
@ -705,40 +705,40 @@ vluint8_t ch;
|
||||||
vluint64_t timestamp = 1;
|
vluint64_t timestamp = 1;
|
||||||
double doub = 0;
|
double doub = 0;
|
||||||
|
|
||||||
void vcdInit (VerilatedVcd* vcdp, void* userthis, vluint32_t code) {
|
void vcdInit(VerilatedVcd* vcdp, void* userthis, vluint32_t code) {
|
||||||
vcdp->scopeEscape('.');
|
vcdp->scopeEscape('.');
|
||||||
vcdp->module ("top");
|
vcdp->module("top");
|
||||||
vcdp->declBus (0x2, "v1",-1,5,1);
|
vcdp->declBus(0x2, "v1",-1,5,1);
|
||||||
vcdp->declBus (0x3, "v2",-1,6,0);
|
vcdp->declBus(0x3, "v2",-1,6,0);
|
||||||
vcdp->module ("top.sub1");
|
vcdp->module("top.sub1");
|
||||||
vcdp->declBit (0x4, "s1",-1);
|
vcdp->declBit(0x4, "s1",-1);
|
||||||
vcdp->declBit (0x5, "ch",-1);
|
vcdp->declBit(0x5, "ch",-1);
|
||||||
vcdp->module ("top.sub2");
|
vcdp->module("top.sub2");
|
||||||
vcdp->declArray (0x6, "s2",-1, 40,3);
|
vcdp->declArray(0x6, "s2",-1, 40,3);
|
||||||
// Note need to add 3 for next code.
|
// Note need to add 3 for next code.
|
||||||
vcdp->module ("top2");
|
vcdp->module("top2");
|
||||||
vcdp->declBus (0x2, "t2v1",-1,4,1);
|
vcdp->declBus(0x2, "t2v1",-1,4,1);
|
||||||
vcdp->declTriBit (0x10, "io1", -1);
|
vcdp->declTriBit (0x10, "io1", -1);
|
||||||
vcdp->declTriBus (0x12, "io5", -1,4,0);
|
vcdp->declTriBus (0x12, "io5", -1,4,0);
|
||||||
vcdp->declTriArray (0x16, "io96",-1,95,0);
|
vcdp->declTriArray(0x16, "io96",-1,95,0);
|
||||||
// Note need to add 6 for next code.
|
// Note need to add 6 for next code.
|
||||||
vcdp->declDouble (0x1c, "doub",-1);
|
vcdp->declDouble (0x1c, "doub",-1);
|
||||||
// Note need to add 2 for next code.
|
// Note need to add 2 for next code.
|
||||||
}
|
}
|
||||||
|
|
||||||
void vcdFull (VerilatedVcd* vcdp, void* userthis, vluint32_t code) {
|
void vcdFull(VerilatedVcd* vcdp, void* userthis, vluint32_t code) {
|
||||||
vcdp->fullBus (0x2, v1,5);
|
vcdp->fullBus (0x2, v1,5);
|
||||||
vcdp->fullBus (0x3, v2,7);
|
vcdp->fullBus (0x3, v2,7);
|
||||||
vcdp->fullBit (0x4, s1);
|
vcdp->fullBit (0x4, s1);
|
||||||
vcdp->fullBus (0x5, ch,2);
|
vcdp->fullBus (0x5, ch,2);
|
||||||
vcdp->fullArray(0x6, &s2[0], 38);
|
vcdp->fullArray(0x6, &s2[0], 38);
|
||||||
vcdp->fullTriBit (0x10, tri96[0]&1, tri96__tri[0]&1);
|
vcdp->fullTriBit (0x10, tri96[0]&1, tri96__tri[0]&1);
|
||||||
vcdp->fullTriBus (0x12, tri96[0]&0x1f, tri96__tri[0]&0x1f, 5);
|
vcdp->fullTriBus (0x12, tri96[0]&0x1f, tri96__tri[0]&0x1f, 5);
|
||||||
vcdp->fullTriArray (0x16, tri96, tri96__tri, 96);
|
vcdp->fullTriArray(0x16, tri96, tri96__tri, 96);
|
||||||
vcdp->fullDouble(0x1c, doub);
|
vcdp->fullDouble(0x1c, doub);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vcdChange (VerilatedVcd* vcdp, void* userthis, vluint32_t code) {
|
void vcdChange(VerilatedVcd* vcdp, void* userthis, vluint32_t code) {
|
||||||
vcdp->chgBus (0x2, v1,5);
|
vcdp->chgBus (0x2, v1,5);
|
||||||
vcdp->chgBus (0x3, v2,7);
|
vcdp->chgBus (0x3, v2,7);
|
||||||
vcdp->chgBit (0x4, s1);
|
vcdp->chgBit (0x4, s1);
|
||||||
|
|
@ -760,34 +760,34 @@ main() {
|
||||||
ch = 0;
|
ch = 0;
|
||||||
doub = 0;
|
doub = 0;
|
||||||
{
|
{
|
||||||
VerilatedVcdC* vcdp = new VerilatedVcdC;
|
VerilatedVcdC* vcdp = new VerilatedVcdC;
|
||||||
vcdp->spTrace()->addCallback (&vcdInit, &vcdFull, &vcdChange, 0);
|
vcdp->spTrace()->addCallback(&vcdInit, &vcdFull, &vcdChange, 0);
|
||||||
vcdp->open ("test.vcd");
|
vcdp->open("test.vcd");
|
||||||
// Dumping
|
// Dumping
|
||||||
vcdp->dump(timestamp++);
|
vcdp->dump(timestamp++);
|
||||||
v1 = 0xfff;
|
v1 = 0xfff;
|
||||||
tri96[2] = 4; tri96[1] = 2; tri96[0] = 1;
|
tri96[2] = 4; tri96[1] = 2; tri96[0] = 1;
|
||||||
tri96__tri[2] = tri96__tri[1] = tri96__tri[0] = ~0; // Still tri
|
tri96__tri[2] = tri96__tri[1] = tri96__tri[0] = ~0; // Still tri
|
||||||
doub = 1.5;
|
doub = 1.5;
|
||||||
vcdp->dump(timestamp++);
|
vcdp->dump(timestamp++);
|
||||||
v2 = 0x1;
|
v2 = 0x1;
|
||||||
s2[1] = 2;
|
s2[1] = 2;
|
||||||
tri96__tri[2] = tri96__tri[1] = tri96__tri[0] = 0; // enable w/o data change
|
tri96__tri[2] = tri96__tri[1] = tri96__tri[0] = 0; // enable w/o data change
|
||||||
doub = -1.66e13;
|
doub = -1.66e13;
|
||||||
vcdp->dump(timestamp++);
|
vcdp->dump(timestamp++);
|
||||||
ch = 2;
|
ch = 2;
|
||||||
tri96[2] = ~4; tri96[1] = ~2; tri96[0] = ~1;
|
tri96[2] = ~4; tri96[1] = ~2; tri96[0] = ~1;
|
||||||
doub = -3.33e-13;
|
doub = -3.33e-13;
|
||||||
vcdp->dump(timestamp++);
|
vcdp->dump(timestamp++);
|
||||||
vcdp->dump(timestamp++);
|
vcdp->dump(timestamp++);
|
||||||
# ifdef VERILATED_VCD_TEST_64BIT
|
# ifdef VERILATED_VCD_TEST_64BIT
|
||||||
vluint64_t bytesPerDump = 15ULL;
|
vluint64_t bytesPerDump = 15ULL;
|
||||||
for (vluint64_t i=0; i<((1ULL<<32) / bytesPerDump); i++) {
|
for (vluint64_t i=0; i<((1ULL<<32) / bytesPerDump); i++) {
|
||||||
v1 = i;
|
v1 = i;
|
||||||
vcdp->dump(timestamp++);
|
vcdp->dump(timestamp++);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
vcdp->close();
|
vcdp->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class VerilatedVcdCallInfo;
|
||||||
|
|
||||||
class VerilatedVcdFile {
|
class VerilatedVcdFile {
|
||||||
private:
|
private:
|
||||||
int m_fd; ///< File descriptor we're writing to
|
int m_fd; ///< File descriptor we're writing to
|
||||||
public:
|
public:
|
||||||
// METHODS
|
// METHODS
|
||||||
VerilatedVcdFile() : m_fd(0) {}
|
VerilatedVcdFile() : m_fd(0) {}
|
||||||
|
|
@ -57,10 +57,10 @@ public:
|
||||||
class VerilatedVcdSig {
|
class VerilatedVcdSig {
|
||||||
protected:
|
protected:
|
||||||
friend class VerilatedVcd;
|
friend class VerilatedVcd;
|
||||||
vluint32_t m_code; ///< VCD file code number
|
vluint32_t m_code; ///< VCD file code number
|
||||||
int m_bits; ///< Size of value in bits
|
int m_bits; ///< Size of value in bits
|
||||||
VerilatedVcdSig (vluint32_t code, int bits)
|
VerilatedVcdSig(vluint32_t code, int bits)
|
||||||
: m_code(code), m_bits(bits) {}
|
: m_code(code), m_bits(bits) {}
|
||||||
public:
|
public:
|
||||||
~VerilatedVcdSig() {}
|
~VerilatedVcdSig() {}
|
||||||
};
|
};
|
||||||
|
|
@ -76,75 +76,75 @@ typedef void (*VerilatedVcdCallback_t)(VerilatedVcd* vcdp, void* userthis, vluin
|
||||||
|
|
||||||
class VerilatedVcd {
|
class VerilatedVcd {
|
||||||
private:
|
private:
|
||||||
VerilatedVcdFile* m_filep; ///< File we're writing to
|
VerilatedVcdFile* m_filep; ///< File we're writing to
|
||||||
bool m_fileNewed; ///< m_filep needs destruction
|
bool m_fileNewed; ///< m_filep needs destruction
|
||||||
bool m_isOpen; ///< True indicates open file
|
bool m_isOpen; ///< True indicates open file
|
||||||
bool m_evcd; ///< True for evcd format
|
bool m_evcd; ///< True for evcd format
|
||||||
std::string m_filename; ///< Filename we're writing to (if open)
|
std::string m_filename; ///< Filename we're writing to (if open)
|
||||||
vluint64_t m_rolloverMB; ///< MB of file size to rollover at
|
vluint64_t m_rolloverMB; ///< MB of file size to rollover at
|
||||||
char m_scopeEscape; ///< Character to separate scope components
|
char m_scopeEscape; ///< Character to separate scope components
|
||||||
int m_modDepth; ///< Depth of module hierarchy
|
int m_modDepth; ///< Depth of module hierarchy
|
||||||
bool m_fullDump; ///< True indicates dump ignoring if changed
|
bool m_fullDump; ///< True indicates dump ignoring if changed
|
||||||
vluint32_t m_nextCode; ///< Next code number to assign
|
vluint32_t m_nextCode; ///< Next code number to assign
|
||||||
std::string m_modName; ///< Module name being traced now
|
std::string m_modName; ///< Module name being traced now
|
||||||
double m_timeRes; ///< Time resolution (ns/ms etc)
|
double m_timeRes; ///< Time resolution (ns/ms etc)
|
||||||
double m_timeUnit; ///< Time units (ns/ms etc)
|
double m_timeUnit; ///< Time units (ns/ms etc)
|
||||||
vluint64_t m_timeLastDump; ///< Last time we did a dump
|
vluint64_t m_timeLastDump; ///< Last time we did a dump
|
||||||
|
|
||||||
char* m_wrBufp; ///< Output buffer
|
char* m_wrBufp; ///< Output buffer
|
||||||
char* m_wrFlushp; ///< Output buffer flush trigger location
|
char* m_wrFlushp; ///< Output buffer flush trigger location
|
||||||
char* m_writep; ///< Write pointer into output buffer
|
char* m_writep; ///< Write pointer into output buffer
|
||||||
vluint64_t m_wrChunkSize; ///< Output buffer size
|
vluint64_t m_wrChunkSize; ///< Output buffer size
|
||||||
vluint64_t m_wroteBytes; ///< Number of bytes written to this file
|
vluint64_t m_wroteBytes; ///< Number of bytes written to this file
|
||||||
|
|
||||||
vluint32_t* m_sigs_oldvalp; ///< Pointer to old signal values
|
vluint32_t* m_sigs_oldvalp; ///< Pointer to old signal values
|
||||||
typedef std::vector<VerilatedVcdSig> SigVec;
|
typedef std::vector<VerilatedVcdSig> SigVec;
|
||||||
SigVec m_sigs; ///< Pointer to signal information
|
SigVec m_sigs; ///< Pointer to signal information
|
||||||
typedef std::vector<VerilatedVcdCallInfo*> CallbackVec;
|
typedef std::vector<VerilatedVcdCallInfo*> CallbackVec;
|
||||||
CallbackVec m_callbacks; ///< Routines to perform dumping
|
CallbackVec 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
|
||||||
|
|
||||||
VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread
|
VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread
|
||||||
|
|
||||||
void bufferResize(vluint64_t minsize);
|
void bufferResize(vluint64_t minsize);
|
||||||
void bufferFlush() VL_MT_UNSAFE_ONE;
|
void bufferFlush() VL_MT_UNSAFE_ONE;
|
||||||
inline void bufferCheck() {
|
inline void bufferCheck() {
|
||||||
// Flush the write buffer if there's not enough space left for new information
|
// Flush the write buffer if there's not enough space left for new information
|
||||||
// We only call this once per vector, so we need enough slop for a very wide "b###" line
|
// We only call this once per vector, so we need enough slop for a very wide "b###" line
|
||||||
if (VL_UNLIKELY(m_writep > m_wrFlushp)) {
|
if (VL_UNLIKELY(m_writep > m_wrFlushp)) {
|
||||||
bufferFlush();
|
bufferFlush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void closePrev();
|
void closePrev();
|
||||||
void closeErr();
|
void closeErr();
|
||||||
void openNext();
|
void openNext();
|
||||||
void makeNameMap();
|
void makeNameMap();
|
||||||
void deleteNameMap();
|
void deleteNameMap();
|
||||||
void printIndent (int levelchange);
|
void printIndent(int levelchange);
|
||||||
void printStr (const char* str);
|
void printStr(const char* str);
|
||||||
void printQuad (vluint64_t n);
|
void printQuad(vluint64_t n);
|
||||||
void printTime (vluint64_t timeui);
|
void printTime(vluint64_t timeui);
|
||||||
void declare (vluint32_t code, const char* name, const char* wirep,
|
void declare(vluint32_t code, const char* name, const char* wirep,
|
||||||
int arraynum, bool tri, bool bussed, int msb, int lsb);
|
int arraynum, bool tri, bool bussed, int msb, int lsb);
|
||||||
|
|
||||||
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
|
// cppcheck-suppress functionConst
|
||||||
void dumpDone ();
|
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);
|
||||||
if (code>=(94)) *m_writep++ = static_cast<char>((code/94)%94+33);
|
if (code>=(94)) *m_writep++ = static_cast<char>((code/94)%94+33);
|
||||||
*m_writep++ = static_cast<char>((code)%94+33);
|
*m_writep++ = static_cast<char>((code)%94+33);
|
||||||
}
|
}
|
||||||
static std::string stringCode (vluint32_t code) VL_PURE {
|
static std::string stringCode(vluint32_t code) VL_PURE {
|
||||||
std::string out;
|
std::string out;
|
||||||
if (code>=(94*94*94)) out += static_cast<char>((code/94/94/94)%94+33);
|
if (code>=(94*94*94)) out += static_cast<char>((code/94/94/94)%94+33);
|
||||||
if (code>=(94*94)) out += static_cast<char>((code/94/94)%94+33);
|
if (code>=(94*94)) out += static_cast<char>((code/94/94)%94+33);
|
||||||
if (code>=(94)) out += static_cast<char>((code/94)%94+33);
|
if (code>=(94)) out += static_cast<char>((code/94)%94+33);
|
||||||
return out + static_cast<char>((code)%94+33);
|
return out + static_cast<char>((code)%94+33);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
|
|
@ -165,34 +165,34 @@ public:
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
void open(const char* filename) VL_MT_UNSAFE_ONE; ///< Open the file; call isOpen() to see if errors
|
void open(const char* filename) VL_MT_UNSAFE_ONE; ///< 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 close() VL_MT_UNSAFE_ONE; ///< Close the file
|
void close() VL_MT_UNSAFE_ONE; ///< Close the file
|
||||||
/// Flush any remaining data to this file
|
/// Flush any remaining data to this file
|
||||||
void flush() VL_MT_UNSAFE_ONE { bufferFlush(); }
|
void flush() VL_MT_UNSAFE_ONE { bufferFlush(); }
|
||||||
/// Flush any remaining data from all files
|
/// Flush any remaining data from all files
|
||||||
static void flush_all() VL_MT_UNSAFE_ONE;
|
static void flush_all() VL_MT_UNSAFE_ONE;
|
||||||
|
|
||||||
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()); }
|
||||||
|
|
||||||
void set_time_resolution (const char* unit); ///< Set time resolution (s/ms, defaults to ns)
|
void set_time_resolution(const char* unit); ///< Set time resolution (s/ms, defaults to ns)
|
||||||
void set_time_resolution (const std::string& unit) { set_time_resolution(unit.c_str()); }
|
void set_time_resolution(const std::string& unit) { set_time_resolution(unit.c_str()); }
|
||||||
|
|
||||||
double timescaleToDouble (const char* unitp);
|
double timescaleToDouble(const char* unitp);
|
||||||
std::string doubleToTimescale (double value);
|
std::string doubleToTimescale(double value);
|
||||||
|
|
||||||
/// Inside dumping routines, called each cycle to make the dump
|
/// Inside dumping routines, called each cycle to make the dump
|
||||||
void dump (vluint64_t timeui);
|
void dump(vluint64_t timeui);
|
||||||
/// Call dump with a absolute unscaled time in seconds
|
/// Call dump with a absolute unscaled time in seconds
|
||||||
void dumpSeconds (double secs) { dump(static_cast<vluint64_t>(secs * m_timeRes)); }
|
void dumpSeconds(double secs) { dump(static_cast<vluint64_t>(secs * m_timeRes)); }
|
||||||
|
|
||||||
/// Inside dumping routines, declare callbacks for tracings
|
/// Inside dumping routines, declare callbacks for tracings
|
||||||
void addCallback (VerilatedVcdCallback_t init, VerilatedVcdCallback_t full,
|
void addCallback(VerilatedVcdCallback_t init, VerilatedVcdCallback_t full,
|
||||||
VerilatedVcdCallback_t change,
|
VerilatedVcdCallback_t change,
|
||||||
void* userthis) VL_MT_UNSAFE_ONE;
|
void* userthis) VL_MT_UNSAFE_ONE;
|
||||||
|
|
||||||
/// Inside dumping routines, declare a module
|
/// Inside dumping routines, declare a module
|
||||||
void module (const std::string& name);
|
void module(const std::string& name);
|
||||||
/// Inside dumping routines, declare a signal
|
/// Inside dumping routines, declare a signal
|
||||||
void declBit (vluint32_t code, const char* name, int arraynum);
|
void declBit (vluint32_t code, const char* name, int arraynum);
|
||||||
void declBus (vluint32_t code, const char* name, int arraynum, int msb, int lsb);
|
void declBus (vluint32_t code, const char* name, int arraynum, int msb, int lsb);
|
||||||
|
|
@ -204,192 +204,192 @@ public:
|
||||||
void declTriArray (vluint32_t code, const char* name, int arraynum, int msb, int lsb);
|
void declTriArray (vluint32_t code, const char* name, int arraynum, int msb, int lsb);
|
||||||
void declDouble (vluint32_t code, const char* name, int arraynum);
|
void declDouble (vluint32_t code, const char* name, int arraynum);
|
||||||
void declFloat (vluint32_t code, const char* name, int arraynum);
|
void declFloat (vluint32_t code, const char* name, int arraynum);
|
||||||
// ... other module_start for submodules (based on cell name)
|
// ... other module_start for submodules (based on cell name)
|
||||||
|
|
||||||
/// Inside dumping routines, dump one signal
|
/// Inside dumping routines, dump one signal
|
||||||
void fullBit (vluint32_t code, const vluint32_t newval) {
|
void fullBit(vluint32_t code, const vluint32_t newval) {
|
||||||
// Note the &1, so we don't require clean input -- makes more common no change case faster
|
// Note the &1, so we don't require clean input -- makes more common no change case faster
|
||||||
m_sigs_oldvalp[code] = newval;
|
m_sigs_oldvalp[code] = newval;
|
||||||
*m_writep++=('0'+static_cast<char>(newval&1)); printCode(code); *m_writep++='\n';
|
*m_writep++=('0'+static_cast<char>(newval&1)); printCode(code); *m_writep++='\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullBus (vluint32_t code, const vluint32_t newval, int bits) {
|
void fullBus(vluint32_t code, const vluint32_t newval, int bits) {
|
||||||
m_sigs_oldvalp[code] = newval;
|
m_sigs_oldvalp[code] = newval;
|
||||||
*m_writep++='b';
|
*m_writep++='b';
|
||||||
for (int bit=bits-1; bit>=0; --bit) {
|
for (int bit=bits-1; bit>=0; --bit) {
|
||||||
*m_writep++=((newval&(1L<<bit))?'1':'0');
|
*m_writep++=((newval&(1L<<bit))?'1':'0');
|
||||||
}
|
}
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullQuad (vluint32_t code, const vluint64_t newval, int bits) {
|
void fullQuad(vluint32_t code, const vluint64_t newval, int bits) {
|
||||||
(*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code]))) = newval;
|
(*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code]))) = newval;
|
||||||
*m_writep++='b';
|
*m_writep++='b';
|
||||||
for (int bit=bits-1; bit>=0; --bit) {
|
for (int bit=bits-1; bit>=0; --bit) {
|
||||||
*m_writep++=((newval&(1ULL<<bit))?'1':'0');
|
*m_writep++=((newval&(1ULL<<bit))?'1':'0');
|
||||||
}
|
}
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullArray (vluint32_t code, const vluint32_t* newval, int bits) {
|
void fullArray(vluint32_t code, const vluint32_t* newval, int bits) {
|
||||||
for (int word=0; word<(((bits-1)/32)+1); ++word) {
|
for (int word=0; word<(((bits-1)/32)+1); ++word) {
|
||||||
m_sigs_oldvalp[code+word] = newval[word];
|
m_sigs_oldvalp[code+word] = newval[word];
|
||||||
}
|
}
|
||||||
*m_writep++='b';
|
*m_writep++='b';
|
||||||
for (int bit=bits-1; bit>=0; --bit) {
|
for (int bit=bits-1; bit>=0; --bit) {
|
||||||
*m_writep++=((newval[(bit/32)]&(1L<<(bit&0x1f)))?'1':'0');
|
*m_writep++=((newval[(bit/32)]&(1L<<(bit&0x1f)))?'1':'0');
|
||||||
}
|
}
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullTriBit (vluint32_t code, const vluint32_t newval, const vluint32_t newtri) {
|
void fullTriBit(vluint32_t code, const vluint32_t newval, const vluint32_t newtri) {
|
||||||
m_sigs_oldvalp[code] = newval;
|
m_sigs_oldvalp[code] = newval;
|
||||||
m_sigs_oldvalp[code+1] = newtri;
|
m_sigs_oldvalp[code+1] = newtri;
|
||||||
*m_writep++ = "01zz"[m_sigs_oldvalp[code]
|
*m_writep++ = "01zz"[m_sigs_oldvalp[code]
|
||||||
| (m_sigs_oldvalp[code+1]<<1)];
|
| (m_sigs_oldvalp[code+1]<<1)];
|
||||||
printCode(code); *m_writep++='\n';
|
printCode(code); *m_writep++='\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullTriBus (vluint32_t code, const vluint32_t newval, const vluint32_t newtri, int bits) {
|
void fullTriBus(vluint32_t code, const vluint32_t newval, const vluint32_t newtri, int bits) {
|
||||||
m_sigs_oldvalp[code] = newval;
|
m_sigs_oldvalp[code] = newval;
|
||||||
m_sigs_oldvalp[code+1] = newtri;
|
m_sigs_oldvalp[code+1] = newtri;
|
||||||
*m_writep++='b';
|
*m_writep++='b';
|
||||||
for (int bit=bits-1; bit>=0; --bit) {
|
for (int bit=bits-1; bit>=0; --bit) {
|
||||||
*m_writep++ = "01zz"[((newval >> bit)&1)
|
*m_writep++ = "01zz"[((newval >> bit)&1)
|
||||||
| (((newtri >> bit)&1)<<1)];
|
| (((newtri >> bit)&1)<<1)];
|
||||||
}
|
}
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullTriQuad (vluint32_t code, const vluint64_t newval, const vluint32_t newtri, int bits) {
|
void fullTriQuad(vluint32_t code, const vluint64_t newval, const vluint32_t newtri, int bits) {
|
||||||
(*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code]))) = newval;
|
(*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code]))) = newval;
|
||||||
(*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code+1]))) = newtri;
|
(*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code+1]))) = newtri;
|
||||||
*m_writep++='b';
|
*m_writep++='b';
|
||||||
for (int bit=bits-1; bit>=0; --bit) {
|
for (int bit=bits-1; bit>=0; --bit) {
|
||||||
*m_writep++ = "01zz"[((newval >> bit)&1ULL)
|
*m_writep++ = "01zz"[((newval >> bit)&1ULL)
|
||||||
| (((newtri >> bit)&1ULL)<<1ULL)];
|
| (((newtri >> bit)&1ULL)<<1ULL)];
|
||||||
}
|
}
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullTriArray (vluint32_t code, const vluint32_t* newvalp, const vluint32_t* newtrip, int bits) {
|
void fullTriArray(vluint32_t code, const vluint32_t* newvalp, const vluint32_t* newtrip, int bits) {
|
||||||
for (int word=0; word<(((bits-1)/32)+1); ++word) {
|
for (int word=0; word<(((bits-1)/32)+1); ++word) {
|
||||||
m_sigs_oldvalp[code+word*2] = newvalp[word];
|
m_sigs_oldvalp[code+word*2] = newvalp[word];
|
||||||
m_sigs_oldvalp[code+word*2+1] = newtrip[word];
|
m_sigs_oldvalp[code+word*2+1] = newtrip[word];
|
||||||
}
|
}
|
||||||
*m_writep++='b';
|
*m_writep++='b';
|
||||||
for (int bit=bits-1; bit>=0; --bit) {
|
for (int bit=bits-1; bit>=0; --bit) {
|
||||||
vluint32_t valbit = (newvalp[(bit/32)]>>(bit&0x1f)) & 1;
|
vluint32_t valbit = (newvalp[(bit/32)]>>(bit&0x1f)) & 1;
|
||||||
vluint32_t tribit = (newtrip[(bit/32)]>>(bit&0x1f)) & 1;
|
vluint32_t tribit = (newtrip[(bit/32)]>>(bit&0x1f)) & 1;
|
||||||
*m_writep++ = "01zz"[valbit | (tribit<<1)];
|
*m_writep++ = "01zz"[valbit | (tribit<<1)];
|
||||||
}
|
}
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
void fullDouble (vluint32_t code, const double newval);
|
void fullDouble(vluint32_t code, const double newval);
|
||||||
void fullFloat (vluint32_t code, const float newval);
|
void fullFloat(vluint32_t code, const float newval);
|
||||||
|
|
||||||
/// Inside dumping routines, dump one signal as unknowns
|
/// Inside dumping routines, dump one signal as unknowns
|
||||||
/// Presently this code doesn't change the oldval vector.
|
/// Presently this code doesn't change the oldval vector.
|
||||||
/// Thus this is for special standalone applications that after calling
|
/// Thus this is for special standalone applications that after calling
|
||||||
/// fullBitX, must when then value goes non-X call fullBit.
|
/// fullBitX, must when then value goes non-X call fullBit.
|
||||||
inline void fullBitX (vluint32_t code) {
|
inline void fullBitX(vluint32_t code) {
|
||||||
*m_writep++='x'; printCode(code); *m_writep++='\n';
|
*m_writep++='x'; printCode(code); *m_writep++='\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
inline void fullBusX (vluint32_t code, int bits) {
|
inline void fullBusX(vluint32_t code, int bits) {
|
||||||
*m_writep++='b';
|
*m_writep++='b';
|
||||||
for (int bit=bits-1; bit>=0; --bit) {
|
for (int bit=bits-1; bit>=0; --bit) {
|
||||||
*m_writep++='x';
|
*m_writep++='x';
|
||||||
}
|
}
|
||||||
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
*m_writep++=' '; printCode(code); *m_writep++='\n';
|
||||||
bufferCheck();
|
bufferCheck();
|
||||||
}
|
}
|
||||||
inline void fullQuadX (vluint32_t code, int bits) { fullBusX (code, bits); }
|
inline void fullQuadX(vluint32_t code, int bits) { fullBusX (code, bits); }
|
||||||
inline void fullArrayX (vluint32_t code, int bits) { fullBusX (code, bits); }
|
inline void fullArrayX(vluint32_t code, int bits) { fullBusX (code, bits); }
|
||||||
|
|
||||||
/// Inside dumping routines, dump one signal if it has changed
|
/// Inside dumping routines, dump one signal if it has changed
|
||||||
inline void chgBit (vluint32_t code, const vluint32_t newval) {
|
inline void chgBit(vluint32_t code, const vluint32_t newval) {
|
||||||
vluint32_t diff = m_sigs_oldvalp[code] ^ newval;
|
vluint32_t diff = m_sigs_oldvalp[code] ^ newval;
|
||||||
if (VL_UNLIKELY(diff)) {
|
if (VL_UNLIKELY(diff)) {
|
||||||
// Verilator 3.510 and newer provide clean input, so the below is only for back compatibility
|
// Verilator 3.510 and newer provide clean input, so the below is only for back compatibility
|
||||||
if (VL_UNLIKELY(diff & 1)) { // Change after clean?
|
if (VL_UNLIKELY(diff & 1)) { // Change after clean?
|
||||||
fullBit (code, newval);
|
fullBit(code, newval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void chgBus (vluint32_t code, const vluint32_t newval, int bits) {
|
inline void chgBus(vluint32_t code, const vluint32_t newval, int bits) {
|
||||||
vluint32_t diff = m_sigs_oldvalp[code] ^ newval;
|
vluint32_t diff = m_sigs_oldvalp[code] ^ newval;
|
||||||
if (VL_UNLIKELY(diff)) {
|
if (VL_UNLIKELY(diff)) {
|
||||||
if (VL_UNLIKELY(bits==32 || (diff & ((1U<<bits)-1) ))) {
|
if (VL_UNLIKELY(bits==32 || (diff & ((1U<<bits)-1) ))) {
|
||||||
fullBus (code, newval, bits);
|
fullBus(code, newval, bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void chgQuad (vluint32_t code, const vluint64_t newval, int bits) {
|
inline void chgQuad(vluint32_t code, const vluint64_t newval, int bits) {
|
||||||
vluint64_t diff = (*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code]))) ^ newval;
|
vluint64_t diff = (*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code]))) ^ newval;
|
||||||
if (VL_UNLIKELY(diff)) {
|
if (VL_UNLIKELY(diff)) {
|
||||||
if (VL_UNLIKELY(bits==64 || (diff & ((1ULL<<bits)-1) ))) {
|
if (VL_UNLIKELY(bits==64 || (diff & ((1ULL<<bits)-1) ))) {
|
||||||
fullQuad(code, newval, bits);
|
fullQuad(code, newval, bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void chgArray (vluint32_t code, const vluint32_t* newval, int bits) {
|
inline void chgArray(vluint32_t code, const vluint32_t* newval, int bits) {
|
||||||
for (int word=0; word<(((bits-1)/32)+1); ++word) {
|
for (int word=0; word<(((bits-1)/32)+1); ++word) {
|
||||||
if (VL_UNLIKELY(m_sigs_oldvalp[code+word] ^ newval[word])) {
|
if (VL_UNLIKELY(m_sigs_oldvalp[code+word] ^ newval[word])) {
|
||||||
fullArray (code,newval,bits);
|
fullArray(code,newval,bits);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void chgTriBit (vluint32_t code, const vluint32_t newval, const vluint32_t newtri) {
|
inline void chgTriBit(vluint32_t code, const vluint32_t newval, const vluint32_t newtri) {
|
||||||
vluint32_t diff = ((m_sigs_oldvalp[code] ^ newval)
|
vluint32_t diff = ((m_sigs_oldvalp[code] ^ newval)
|
||||||
| (m_sigs_oldvalp[code+1] ^ newtri));
|
| (m_sigs_oldvalp[code+1] ^ newtri));
|
||||||
if (VL_UNLIKELY(diff)) {
|
if (VL_UNLIKELY(diff)) {
|
||||||
// Verilator 3.510 and newer provide clean input, so the below is only for back compatibility
|
// Verilator 3.510 and newer provide clean input, so the below is only for back compatibility
|
||||||
if (VL_UNLIKELY(diff & 1)) { // Change after clean?
|
if (VL_UNLIKELY(diff & 1)) { // Change after clean?
|
||||||
fullTriBit (code, newval, newtri);
|
fullTriBit(code, newval, newtri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void chgTriBus (vluint32_t code, const vluint32_t newval, const vluint32_t newtri, int bits) {
|
inline void chgTriBus(vluint32_t code, const vluint32_t newval, const vluint32_t newtri, int bits) {
|
||||||
vluint32_t diff = ((m_sigs_oldvalp[code] ^ newval)
|
vluint32_t diff = ((m_sigs_oldvalp[code] ^ newval)
|
||||||
| (m_sigs_oldvalp[code+1] ^ newtri));
|
| (m_sigs_oldvalp[code+1] ^ newtri));
|
||||||
if (VL_UNLIKELY(diff)) {
|
if (VL_UNLIKELY(diff)) {
|
||||||
if (VL_UNLIKELY(bits==32 || (diff & ((1U<<bits)-1) ))) {
|
if (VL_UNLIKELY(bits==32 || (diff & ((1U<<bits)-1) ))) {
|
||||||
fullTriBus (code, newval, newtri, bits);
|
fullTriBus(code, newval, newtri, bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void chgTriQuad (vluint32_t code, const vluint64_t newval, const vluint32_t newtri, int bits) {
|
inline void chgTriQuad(vluint32_t code, const vluint64_t newval, const vluint32_t newtri, int bits) {
|
||||||
vluint64_t diff = ( ((*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code]))) ^ newval)
|
vluint64_t diff = ( ((*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code]))) ^ newval)
|
||||||
| ((*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code+1]))) ^ newtri));
|
| ((*(reinterpret_cast<vluint64_t*>(&m_sigs_oldvalp[code+1]))) ^ newtri));
|
||||||
if (VL_UNLIKELY(diff)) {
|
if (VL_UNLIKELY(diff)) {
|
||||||
if (VL_UNLIKELY(bits==64 || (diff & ((1ULL<<bits)-1) ))) {
|
if (VL_UNLIKELY(bits==64 || (diff & ((1ULL<<bits)-1) ))) {
|
||||||
fullTriQuad(code, newval, newtri, bits);
|
fullTriQuad(code, newval, newtri, bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void chgTriArray (vluint32_t code, const vluint32_t* newvalp, const vluint32_t* newtrip, int bits) {
|
inline void chgTriArray(vluint32_t code, const vluint32_t* newvalp, const vluint32_t* newtrip, int bits) {
|
||||||
for (int word=0; word<(((bits-1)/32)+1); ++word) {
|
for (int word=0; word<(((bits-1)/32)+1); ++word) {
|
||||||
if (VL_UNLIKELY((m_sigs_oldvalp[code+word*2] ^ newvalp[word])
|
if (VL_UNLIKELY((m_sigs_oldvalp[code+word*2] ^ newvalp[word])
|
||||||
| (m_sigs_oldvalp[code+word*2+1] ^ newtrip[word]))) {
|
| (m_sigs_oldvalp[code+word*2+1] ^ newtrip[word]))) {
|
||||||
fullTriArray (code,newvalp,newtrip,bits);
|
fullTriArray(code,newvalp,newtrip,bits);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void chgDouble (vluint32_t code, const double newval) {
|
inline void chgDouble(vluint32_t code, const double newval) {
|
||||||
// cppcheck-suppress invalidPointerCast
|
// cppcheck-suppress invalidPointerCast
|
||||||
if (VL_UNLIKELY((*(reinterpret_cast<double*>(&m_sigs_oldvalp[code]))) != newval)) {
|
if (VL_UNLIKELY((*(reinterpret_cast<double*>(&m_sigs_oldvalp[code]))) != newval)) {
|
||||||
fullDouble (code, newval);
|
fullDouble(code, newval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void chgFloat (vluint32_t code, const float newval) {
|
inline void chgFloat(vluint32_t code, const float newval) {
|
||||||
// cppcheck-suppress invalidPointerCast
|
// cppcheck-suppress invalidPointerCast
|
||||||
if (VL_UNLIKELY((*(reinterpret_cast<float*>(&m_sigs_oldvalp[code]))) != newval)) {
|
if (VL_UNLIKELY((*(reinterpret_cast<float*>(&m_sigs_oldvalp[code]))) != newval)) {
|
||||||
fullFloat (code, newval);
|
fullFloat(code, newval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -404,7 +404,7 @@ protected:
|
||||||
/// Thread safety: Unless otherwise indicated, every function is VL_MT_UNSAFE_ONE
|
/// Thread safety: Unless otherwise indicated, every function is VL_MT_UNSAFE_ONE
|
||||||
|
|
||||||
class VerilatedVcdC {
|
class VerilatedVcdC {
|
||||||
VerilatedVcd m_sptrace; ///< Trace file being created
|
VerilatedVcd m_sptrace; ///< Trace file being created
|
||||||
|
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
VL_UNCOPYABLE(VerilatedVcdC);
|
VL_UNCOPYABLE(VerilatedVcdC);
|
||||||
|
|
@ -431,23 +431,23 @@ public:
|
||||||
/// Flush dump
|
/// Flush dump
|
||||||
void flush() VL_MT_UNSAFE_ONE { m_sptrace.flush(); }
|
void flush() VL_MT_UNSAFE_ONE { m_sptrace.flush(); }
|
||||||
/// Write one cycle of dump data
|
/// Write one cycle of dump data
|
||||||
void dump (vluint64_t timeui) { m_sptrace.dump(timeui); }
|
void dump(vluint64_t timeui) { m_sptrace.dump(timeui); }
|
||||||
/// Write one cycle of dump data - backward compatible and to reduce
|
/// Write one cycle of dump data - backward compatible and to reduce
|
||||||
/// conversion warnings. It's better to use a vluint64_t time instead.
|
/// conversion warnings. It's better to use a vluint64_t time instead.
|
||||||
void dump (double timestamp) { dump(static_cast<vluint64_t>(timestamp)); }
|
void dump(double timestamp) { dump(static_cast<vluint64_t>(timestamp)); }
|
||||||
void dump (vluint32_t timestamp) { dump(static_cast<vluint64_t>(timestamp)); }
|
void dump(vluint32_t timestamp) { dump(static_cast<vluint64_t>(timestamp)); }
|
||||||
void dump (int timestamp) { dump(static_cast<vluint64_t>(timestamp)); }
|
void dump(int timestamp) { dump(static_cast<vluint64_t>(timestamp)); }
|
||||||
/// Set time units (s/ms, defaults to ns)
|
/// Set time units (s/ms, defaults to ns)
|
||||||
/// See also VL_TIME_PRECISION, and VL_TIME_MULTIPLIER in verilated.h
|
/// See also VL_TIME_PRECISION, and VL_TIME_MULTIPLIER in verilated.h
|
||||||
void set_time_unit (const char* unit) { m_sptrace.set_time_unit(unit); }
|
void set_time_unit(const char* unit) { m_sptrace.set_time_unit(unit); }
|
||||||
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()); }
|
||||||
/// Set time resolution (s/ms, defaults to ns)
|
/// Set time resolution (s/ms, defaults to ns)
|
||||||
/// See also VL_TIME_PRECISION, and VL_TIME_MULTIPLIER in verilated.h
|
/// See also VL_TIME_PRECISION, and VL_TIME_MULTIPLIER in verilated.h
|
||||||
void set_time_resolution (const char* unit) { m_sptrace.set_time_resolution(unit); }
|
void set_time_resolution(const char* unit) { m_sptrace.set_time_resolution(unit); }
|
||||||
void set_time_resolution (const std::string& unit) { set_time_resolution(unit.c_str()); }
|
void set_time_resolution(const std::string& unit) { set_time_resolution(unit.c_str()); }
|
||||||
|
|
||||||
/// Internal class access
|
/// Internal class access
|
||||||
inline VerilatedVcd* spTrace () { return &m_sptrace; };
|
inline VerilatedVcd* spTrace() { return &m_sptrace; };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@
|
||||||
#if (SYSTEMC_VERSION>=20050714)
|
#if (SYSTEMC_VERSION>=20050714)
|
||||||
// SystemC 2.1.v1
|
// SystemC 2.1.v1
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
void VerilatedVcdSc::write_comment (const std::string &) {}
|
void VerilatedVcdSc::write_comment(const std::string &) {}
|
||||||
void VerilatedVcdSc::trace (const unsigned int &, const std::string &, const char **) {}
|
void VerilatedVcdSc::trace(const unsigned int &, const std::string &, const char **) {}
|
||||||
|
|
||||||
# define DECL_TRACE_METHOD_A(tp) \
|
# define DECL_TRACE_METHOD_A(tp) \
|
||||||
void VerilatedVcdSc::trace( const tp& object, const std::string& name ) {}
|
void VerilatedVcdSc::trace( const tp& object, const std::string& name ) {}
|
||||||
|
|
@ -81,8 +81,8 @@ void VerilatedVcdSc::trace (const unsigned int &, const std::string &, const cha
|
||||||
#elif (SYSTEMC_VERSION>20011000)
|
#elif (SYSTEMC_VERSION>20011000)
|
||||||
// SystemC 2.0.1
|
// SystemC 2.0.1
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
void VerilatedVcdSc::write_comment (const sc_string &) {}
|
void VerilatedVcdSc::write_comment(const sc_string &) {}
|
||||||
void VerilatedVcdSc::trace (const unsigned int &, const sc_string &, const char **) {}
|
void VerilatedVcdSc::trace(const unsigned int &, const sc_string &, const char **) {}
|
||||||
|
|
||||||
#define DECL_TRACE_METHOD_A(tp) \
|
#define DECL_TRACE_METHOD_A(tp) \
|
||||||
void VerilatedVcdSc::trace( const tp& object, const sc_string& name ) {}
|
void VerilatedVcdSc::trace( const tp& object, const sc_string& name ) {}
|
||||||
|
|
@ -124,8 +124,8 @@ void VerilatedVcdSc::trace (const unsigned int &, const sc_string &, const char
|
||||||
#else
|
#else
|
||||||
// SystemC 1.2.1beta
|
// SystemC 1.2.1beta
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
void VerilatedVcdSc::write_comment (const sc_string &) {}
|
void VerilatedVcdSc::write_comment(const sc_string &) {}
|
||||||
void VerilatedVcdSc::trace (const unsigned int &, const sc_string &, const char **) {}
|
void VerilatedVcdSc::trace(const unsigned int &, const sc_string &, const char **) {}
|
||||||
|
|
||||||
#define DECL_TRACE_METHOD_A(tp) \
|
#define DECL_TRACE_METHOD_A(tp) \
|
||||||
void VerilatedVcdSc::trace( const tp& object, const sc_string& name ) {}
|
void VerilatedVcdSc::trace( const tp& object, const sc_string& name ) {}
|
||||||
|
|
|
||||||
|
|
@ -43,33 +43,33 @@ class VerilatedVcdSc
|
||||||
VL_UNCOPYABLE(VerilatedVcdSc);
|
VL_UNCOPYABLE(VerilatedVcdSc);
|
||||||
public:
|
public:
|
||||||
VerilatedVcdSc() {
|
VerilatedVcdSc() {
|
||||||
sc_get_curr_simcontext()->add_trace_file(this);
|
sc_get_curr_simcontext()->add_trace_file(this);
|
||||||
# if (SYSTEMC_VERSION>=20060505)
|
# if (SYSTEMC_VERSION>=20060505)
|
||||||
// We want to avoid a depreciated warning, but still be back compatible.
|
// We want to avoid a depreciated warning, but still be back compatible.
|
||||||
// Turning off the message just for this still results in an annoying "to turn off" message.
|
// Turning off the message just for this still results in an annoying "to turn off" message.
|
||||||
sc_time t1sec(1,SC_SEC);
|
sc_time t1sec(1,SC_SEC);
|
||||||
if (t1sec.to_default_time_units()!=0) {
|
if (t1sec.to_default_time_units()!=0) {
|
||||||
sc_time tunits(1.0/t1sec.to_default_time_units(),SC_SEC);
|
sc_time tunits(1.0/t1sec.to_default_time_units(),SC_SEC);
|
||||||
spTrace()->set_time_unit(tunits.to_string());
|
spTrace()->set_time_unit(tunits.to_string());
|
||||||
}
|
}
|
||||||
spTrace()->set_time_resolution(sc_get_time_resolution().to_string());
|
spTrace()->set_time_resolution(sc_get_time_resolution().to_string());
|
||||||
# elif (SYSTEMC_VERSION>20011000)
|
# elif (SYSTEMC_VERSION>20011000)
|
||||||
// To confuse matters 2.1.beta returns a char* here, while 2.1.v1 returns a std::string
|
// To confuse matters 2.1.beta returns a char* here, while 2.1.v1 returns a std::string
|
||||||
// we allow both flavors with overloaded set_time_* functions.
|
// we allow both flavors with overloaded set_time_* functions.
|
||||||
spTrace()->set_time_unit(sc_get_default_time_unit().to_string());
|
spTrace()->set_time_unit(sc_get_default_time_unit().to_string());
|
||||||
spTrace()->set_time_resolution(sc_get_time_resolution().to_string());
|
spTrace()->set_time_resolution(sc_get_time_resolution().to_string());
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
virtual ~VerilatedVcdSc() {}
|
virtual ~VerilatedVcdSc() {}
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
/// Called by SystemC simulate()
|
/// Called by SystemC simulate()
|
||||||
virtual void cycle (bool delta_cycle) {
|
virtual void cycle(bool delta_cycle) {
|
||||||
# if (SYSTEMC_VERSION>20011000)
|
# if (SYSTEMC_VERSION>20011000)
|
||||||
if (!delta_cycle) { this->dump(sc_time_stamp().to_double()); }
|
if (!delta_cycle) { this->dump(sc_time_stamp().to_double()); }
|
||||||
# else
|
# else
|
||||||
// VCD files must have integer timestamps, so we write all times in increments of time_resolution
|
// VCD files must have integer timestamps, so we write all times in increments of time_resolution
|
||||||
if (!delta_cycle) { this->dump(sc_time_stamp().to_double()); }
|
if (!delta_cycle) { this->dump(sc_time_stamp().to_double()); }
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,10 +78,10 @@ private:
|
||||||
|
|
||||||
#ifdef NC_SYSTEMC
|
#ifdef NC_SYSTEMC
|
||||||
// Cadence Incisive has these as abstract functions so we must create them
|
// Cadence Incisive has these as abstract functions so we must create them
|
||||||
virtual void set_time_unit( int exponent10_seconds ) {} // deprecated
|
virtual void set_time_unit(int exponent10_seconds) {} // deprecated
|
||||||
#endif
|
#endif
|
||||||
#if defined(NC_SYSTEMC) || (SYSTEMC_VERSION>=20111100)
|
#if defined(NC_SYSTEMC) || (SYSTEMC_VERSION>=20111100)
|
||||||
virtual void set_time_unit( double v, sc_time_unit tu ) {}
|
virtual void set_time_unit(double v, sc_time_unit tu) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -89,12 +89,12 @@ private:
|
||||||
# if (SYSTEMC_VERSION>=20050714)
|
# if (SYSTEMC_VERSION>=20050714)
|
||||||
// SystemC 2.1.v1
|
// SystemC 2.1.v1
|
||||||
# define DECL_TRACE_METHOD_A(tp) \
|
# define DECL_TRACE_METHOD_A(tp) \
|
||||||
virtual void trace( const tp& object, const std::string& name );
|
virtual void trace(const tp& object, const std::string& name);
|
||||||
# define DECL_TRACE_METHOD_B(tp) \
|
# define DECL_TRACE_METHOD_B(tp) \
|
||||||
virtual void trace( const tp& object, const std::string& name, int width );
|
virtual void trace(const tp& object, const std::string& name, int width);
|
||||||
|
|
||||||
virtual void write_comment (const std::string &);
|
virtual void write_comment(const std::string &);
|
||||||
virtual void trace (const unsigned int &, const std::string &, const char **);
|
virtual void trace(const unsigned int &, const std::string &, const char **);
|
||||||
|
|
||||||
#if (SYSTEMC_VERSION>=20171012)
|
#if (SYSTEMC_VERSION>=20171012)
|
||||||
DECL_TRACE_METHOD_A( sc_event )
|
DECL_TRACE_METHOD_A( sc_event )
|
||||||
|
|
@ -138,14 +138,14 @@ private:
|
||||||
# elif (SYSTEMC_VERSION>20011000)
|
# elif (SYSTEMC_VERSION>20011000)
|
||||||
// SystemC 2.0.1
|
// SystemC 2.0.1
|
||||||
# define DECL_TRACE_METHOD_A(tp) \
|
# define DECL_TRACE_METHOD_A(tp) \
|
||||||
virtual void trace( const tp& object, const sc_string& name );
|
virtual void trace(const tp& object, const sc_string& name);
|
||||||
# define DECL_TRACE_METHOD_B(tp) \
|
# define DECL_TRACE_METHOD_B(tp) \
|
||||||
virtual void trace( const tp& object, const sc_string& name, int width );
|
virtual void trace(const tp& object, const sc_string& name, int width);
|
||||||
|
|
||||||
virtual void write_comment (const sc_string &);
|
virtual void write_comment(const sc_string &);
|
||||||
virtual void trace (const unsigned int &, const sc_string &, const char **);
|
virtual void trace(const unsigned int &, const sc_string &, const char **);
|
||||||
virtual void delta_cycles (bool) {}
|
virtual void delta_cycles(bool) {}
|
||||||
virtual void space( int n ) {}
|
virtual void space(int n) {}
|
||||||
|
|
||||||
DECL_TRACE_METHOD_A( bool )
|
DECL_TRACE_METHOD_A( bool )
|
||||||
DECL_TRACE_METHOD_A( sc_bit )
|
DECL_TRACE_METHOD_A( sc_bit )
|
||||||
|
|
@ -182,12 +182,12 @@ private:
|
||||||
# else
|
# else
|
||||||
// SystemC 1.2.1beta
|
// SystemC 1.2.1beta
|
||||||
# define DECL_TRACE_METHOD_A(tp) \
|
# define DECL_TRACE_METHOD_A(tp) \
|
||||||
virtual void trace( const tp& object, const sc_string& name );
|
virtual void trace(const tp& object, const sc_string& name);
|
||||||
# define DECL_TRACE_METHOD_B(tp) \
|
# define DECL_TRACE_METHOD_B(tp) \
|
||||||
virtual void trace( const tp& object, const sc_string& name, int width );
|
virtual void trace(const tp& object, const sc_string& name, int width);
|
||||||
|
|
||||||
virtual void write_comment (const sc_string &);
|
virtual void write_comment(const sc_string &);
|
||||||
virtual void trace (const unsigned int &, const sc_string &, const char **);
|
virtual void trace(const unsigned int &, const sc_string &, const char **);
|
||||||
|
|
||||||
DECL_TRACE_METHOD_A( bool )
|
DECL_TRACE_METHOD_A( bool )
|
||||||
DECL_TRACE_METHOD_B( unsigned char )
|
DECL_TRACE_METHOD_B( unsigned char )
|
||||||
|
|
@ -220,4 +220,4 @@ private:
|
||||||
# undef DECL_TRACE_METHOD_B
|
# undef DECL_TRACE_METHOD_B
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // guard
|
#endif // Guard
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue