Fix missing flush with threaded VCD tracing. (#2282)
VerilatedVcdC::openNext() failed to flush the tracing thread before opening the next output file, which caused t_trace_cat.pl to fail with --vltmt on occasion.
This commit is contained in:
parent
27f4399c31
commit
c1665818b9
|
|
@ -294,18 +294,17 @@ void VerilatedVcd::close() {
|
||||||
// This function is on the flush() call path
|
// This function is on the flush() call path
|
||||||
m_assertOne.check();
|
m_assertOne.check();
|
||||||
if (!isOpen()) return;
|
if (!isOpen()) return;
|
||||||
VerilatedTrace<VerilatedVcd>::close();
|
|
||||||
if (m_evcd) {
|
if (m_evcd) {
|
||||||
printStr("$vcdclose ");
|
printStr("$vcdclose ");
|
||||||
printQuad(timeLastDump());
|
printQuad(timeLastDump());
|
||||||
printStr(" $end\n");
|
printStr(" $end\n");
|
||||||
}
|
}
|
||||||
closePrev();
|
closePrev();
|
||||||
}
|
// closePrev() already called VerilatedTrace<VerilatedVcd>::flush() via
|
||||||
|
// bufferFlush(), and there were no opportunities to enqueue further
|
||||||
void VerilatedVcd::flush() {
|
// buffers as this close() is running on the main thread the same as dump()
|
||||||
VerilatedTrace<VerilatedVcd>::flush();
|
// so just shutting down the trace thread will suffice.
|
||||||
bufferFlush();
|
VerilatedTrace<VerilatedVcd>::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedVcd::printStr(const char* str) {
|
void VerilatedVcd::printStr(const char* str) {
|
||||||
|
|
@ -343,6 +342,7 @@ void VerilatedVcd::bufferFlush() VL_MT_UNSAFE_ONE {
|
||||||
// This is much faster than using buffered I/O
|
// This is much faster than using buffered I/O
|
||||||
m_assertOne.check();
|
m_assertOne.check();
|
||||||
if (VL_UNLIKELY(!isOpen())) return;
|
if (VL_UNLIKELY(!isOpen())) return;
|
||||||
|
VerilatedTrace<VerilatedVcd>::flush();
|
||||||
char* wp = m_wrBufp;
|
char* wp = m_wrBufp;
|
||||||
while (true) {
|
while (true) {
|
||||||
ssize_t remaining = (m_writep - wp);
|
ssize_t remaining = (m_writep - wp);
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ public:
|
||||||
/// Close the file
|
/// Close the file
|
||||||
void close() VL_MT_UNSAFE_ONE;
|
void close() VL_MT_UNSAFE_ONE;
|
||||||
/// Flush any remaining data to this file
|
/// Flush any remaining data to this file
|
||||||
void flush() VL_MT_UNSAFE_ONE;
|
void flush() VL_MT_UNSAFE_ONE { bufferFlush(); }
|
||||||
/// Is file open?
|
/// Is file open?
|
||||||
bool isOpen() const { return m_isOpen; }
|
bool isOpen() const { return m_isOpen; }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue