mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
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
|
||||
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);
|
||||
|
@ -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; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user