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:
Geza Lore 2020-04-24 03:09:26 +01:00 committed by GitHub
parent 27f4399c31
commit c1665818b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -294,18 +294,17 @@ void VerilatedVcd::close() {
// This function is on the flush() call path
m_assertOne.check();
if (!isOpen()) return;
VerilatedTrace<VerilatedVcd>::close();
if (m_evcd) {
printStr("$vcdclose ");
printQuad(timeLastDump());
printStr(" $end\n");
}
closePrev();
}
void VerilatedVcd::flush() {
VerilatedTrace<VerilatedVcd>::flush();
bufferFlush();
// closePrev() already called VerilatedTrace<VerilatedVcd>::flush() via
// bufferFlush(), and there were no opportunities to enqueue further
// buffers as this close() is running on the main thread the same as dump()
// so just shutting down the trace thread will suffice.
VerilatedTrace<VerilatedVcd>::close();
}
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
m_assertOne.check();
if (VL_UNLIKELY(!isOpen())) return;
VerilatedTrace<VerilatedVcd>::flush();
char* wp = m_wrBufp;
while (true) {
ssize_t remaining = (m_writep - wp);

View File

@ -149,7 +149,7 @@ public:
/// Close the file
void close() VL_MT_UNSAFE_ONE;
/// Flush any remaining data to this file
void flush() VL_MT_UNSAFE_ONE;
void flush() VL_MT_UNSAFE_ONE { bufferFlush(); }
/// Is file open?
bool isOpen() const { return m_isOpen; }