Fix FST when multi-model tracing.

This commit is contained in:
Wilson Snyder 2020-03-07 18:39:58 -05:00
parent 6f49f802b1
commit 6c6d70a5e5
9 changed files with 183 additions and 146 deletions

View File

@ -77,10 +77,11 @@ protected:
// VerilatedFst
VerilatedFst::VerilatedFst(void* fst)
: m_fst(fst),
m_fullDump(true),
m_scopeEscape('.') {
m_valueStrBuffer.reserve(64+1); // Need enough room for quad
: m_fst(fst)
, m_fullDump(true)
, m_nextCode(1)
, m_scopeEscape('.') {
m_valueStrBuffer.reserve(64 + 1); // Need enough room for quad
}
void VerilatedFst::open(const char* filename) VL_MT_UNSAFE {
@ -91,10 +92,12 @@ void VerilatedFst::open(const char* filename) VL_MT_UNSAFE {
fstWriterSetParallelMode(m_fst, 1);
#endif
m_curScope.clear();
m_nextCode = 1;
for (vluint32_t ent = 0; ent< m_callbacks.size(); ++ent) {
VerilatedFstCallInfo* cip = m_callbacks[ent];
cip->m_code = 1;
cip->m_code = m_nextCode;
// Initialize; callbacks will call decl* which update m_nextCode
(cip->m_initcb)(this, cip->m_userthis, cip->m_code);
}
@ -121,9 +124,15 @@ void VerilatedFst::declDTypeEnum(int dtypenum, const char* name, vluint32_t elem
m_local2fstdtype[dtypenum] = enumNum;
}
void VerilatedFst::declSymbol(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum, vluint32_t len) {
void VerilatedFst::declSymbol(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
fstVarType vartype, bool array, int arraynum, vluint32_t len,
vluint32_t bits) {
// Make sure deduplicate tracking increments for future declarations
int codesNeeded = 1 + int(bits / 32);
//Not supported: if (tri) codesNeeded *= 2; // Space in change array for __en signals
m_nextCode = std::max(m_nextCode, code + codesNeeded);
std::pair<Code2SymbolType::iterator, bool> p
= m_code2symbol.insert(std::make_pair(code, static_cast<fstHandle>(NULL)));
std::istringstream nameiss(name);

View File

@ -50,6 +50,7 @@ private:
void* m_fst;
VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread
bool m_fullDump;
vluint32_t m_nextCode; ///< Next code number to assign
char m_scopeEscape;
std::string m_module;
CallbackVec m_callbacks; ///< Routines to perform dumping
@ -60,7 +61,7 @@ private:
VL_UNCOPYABLE(VerilatedFst);
void declSymbol(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum, vluint32_t len);
bool array, int arraynum, vluint32_t len, vluint32_t bits);
// helpers
std::vector<char> m_valueStrBuffer;
public:
@ -105,32 +106,35 @@ public:
void declBit(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum) {
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 1);
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 1, 1);
}
void declBus(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum, int msb, int lsb) {
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1);
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1,
msb - lsb + 1);
}
void declDouble(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum) {
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 2);
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 2, 64);
}
void declFloat(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum) {
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 1);
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 1, 32);
}
void declQuad(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum, int msb, int lsb) {
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1);
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1,
msb - lsb + 1);
}
void declArray(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum, int msb, int lsb) {
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1);
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1,
msb - lsb + 1);
}
/// Inside dumping routines, dump one signal if it has changed

View File

@ -239,6 +239,7 @@ void VerilatedVcd::makeNameMap() {
for (vluint32_t ent = 0; ent < m_callbacks.size(); ent++) {
VerilatedVcdCallInfo* cip = m_callbacks[ent];
cip->m_code = m_nextCode;
// Initialize; callbacks will call decl* which update m_nextCode
(cip->m_initcb)(this, cip->m_userthis, cip->m_code);
}
@ -535,12 +536,12 @@ void VerilatedVcd::declare(vluint32_t code, const char* name, const char* wirep,
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 codesNeeded = 1+int(bits/32);
int bits = ((msb > lsb) ? (msb - lsb) : (lsb - msb)) + 1;
int codesNeeded = 1 + int(bits / 32);
if (tri) codesNeeded *= 2; // Space in change array for __en signals
// 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) {
m_sigs.reserve(m_nextCode*2); // Power-of-2 allocation speeds things up
}

View File

@ -36,10 +36,6 @@ int main(int argc, char** argv, char** env) {
srand48(5);
ap = new VM_PREFIX("topa");
bp = new Vt_trace_two_b("topb");
ap->eval_step();
bp->eval_step();
ap->eval_end_step();
bp->eval_end_step();
#ifdef TEST_HDR_TRACE
Verilated::traceEverOn(true);
@ -54,8 +50,16 @@ int main(int argc, char** argv, char** env) {
bp->trace(tfp, 99);
tfp->open(VL_STRINGIFY(TEST_OBJ_DIR) "/simx.vcd");
# endif
#endif
#ifdef TEST_HDR_TRACE
ap->eval_step();
bp->eval_step();
ap->eval_end_step();
bp->eval_end_step();
if (tfp) tfp->dump(main_time);
#endif
{
ap->clk = false;
ap->clk = false;
@ -78,6 +82,7 @@ int main(int argc, char** argv, char** env) {
}
ap->final();
bp->final();
#ifdef TEST_HDR_TRACE
if (tfp) tfp->close();
#endif

View File

@ -1,5 +1,5 @@
$version Generated by VerilatedVcd $end
$date Sun Mar 1 20:48:56 2020
$date Sat Mar 7 18:39:02 2020
$end
$timescale 1ns $end
@ -17,86 +17,89 @@ $timescale 1ns $end
$enddefinitions $end
#0
#10
b00000000000000000000000000000001 #
b00000000000000000000000000000000 +
03
13
b00000000000000000000000000000001 ;
#0
#10
#10
#15
#15
03
#20
#20
b00000000000000000000000000000010 #
b00000000000000000000000000000011 +
13
#15
#15
#25
#25
03
#20
#20
#30
#30
b00000000000000000000000000000011 #
b00000000000000000000000000000100 +
13
#25
#25
#35
#35
03
#30
#30
#40
#40
b00000000000000000000000000000100 #
b00000000000000000000000000000101 +
13
#35
#35
#45
#45
03
#40
#40
#50
#50
b00000000000000000000000000000101 #
b00000000000000000000000000000110 +
13
#45
#45
#55
#55
03
#50
#50
#60
#60
b00000000000000000000000000000110 #
b00000000000000000000000000000111 +
13
#55
#55
#65
#65
03
#60
#60
#70
#70
b00000000000000000000000000000111 #
b00000000000000000000000000001000 +
13
#65
#65
#75
#75
03
#70
#70
#80
#80
b00000000000000000000000000001000 #
b00000000000000000000000000001001 +
13
#75
#75
#85
#85
03
#80
#80
#90
#90
b00000000000000000000000000001001 #
b00000000000000000000000000001010 +
13
#85
#85
#95
#95
03
#90
#90
#100
#100
b00000000000000000000000000001010 #
b00000000000000000000000000001011 +
13
#95
#95
#105
#105
03
#100
#100
#110
#110
b00000000000000000000000000001011 #
b00000000000000000000000000001100 +
13

View File

@ -1,5 +1,5 @@
$date
Sun Mar 1 21:31:56 2020
Sat Mar 7 18:39:05 2020
$end
$version
@ -21,63 +21,69 @@ $upscope $end
$upscope $end
$enddefinitions $end
$dumpvars
#0
0!
1!
b00000000000000000000000000000001 "
b00000000000000000000000000000000 #
b00000000000000000000000000000001 $
#10
1!
b00000000000000000000000000000011 #
b00000000000000000000000000000010 "
#15
0!
#20
1!
b00000000000000000000000000000011 "
b00000000000000000000000000000100 #
b00000000000000000000000000000011 #
b00000000000000000000000000000010 "
#25
0!
#30
1!
b00000000000000000000000000000101 #
b00000000000000000000000000000100 "
b00000000000000000000000000000011 "
b00000000000000000000000000000100 #
#35
0!
#40
1!
b00000000000000000000000000000101 "
b00000000000000000000000000000110 #
b00000000000000000000000000000101 #
b00000000000000000000000000000100 "
#45
0!
#50
1!
b00000000000000000000000000000111 #
b00000000000000000000000000000110 "
b00000000000000000000000000000101 "
b00000000000000000000000000000110 #
#55
0!
#60
1!
b00000000000000000000000000000111 "
b00000000000000000000000000001000 #
b00000000000000000000000000000111 #
b00000000000000000000000000000110 "
#65
0!
#70
1!
b00000000000000000000000000001001 #
b00000000000000000000000000001000 "
b00000000000000000000000000000111 "
b00000000000000000000000000001000 #
#75
0!
#80
1!
b00000000000000000000000000001001 "
b00000000000000000000000000001010 #
b00000000000000000000000000001001 #
b00000000000000000000000000001000 "
#85
0!
#90
1!
b00000000000000000000000000001011 #
b00000000000000000000000000001010 "
b00000000000000000000000000001001 "
b00000000000000000000000000001010 #
#95
0!
#100
1!
b00000000000000000000000000001011 #
b00000000000000000000000000001010 "
#105
0!
#110
1!
b00000000000000000000000000001011 "
b00000000000000000000000000001100 #

View File

@ -1,5 +1,5 @@
$version Generated by VerilatedVcd $end
$date Sun Mar 1 21:32:13 2020
$date Sat Mar 7 18:38:11 2020
$end
$timescale 1ns $end
@ -17,86 +17,89 @@ $timescale 1ns $end
$enddefinitions $end
#0
#10
b00000000000000000000000000000001 #
b00000000000000000000000000000000 +
03
13
b00000000000000000000000000000001 ;
#0
#10
#10
#15
#15
03
#20
#20
b00000000000000000000000000000010 #
b00000000000000000000000000000011 +
13
#15
#15
#25
#25
03
#20
#20
#30
#30
b00000000000000000000000000000011 #
b00000000000000000000000000000100 +
13
#25
#25
#35
#35
03
#30
#30
#40
#40
b00000000000000000000000000000100 #
b00000000000000000000000000000101 +
13
#35
#35
#45
#45
03
#40
#40
#50
#50
b00000000000000000000000000000101 #
b00000000000000000000000000000110 +
13
#45
#45
#55
#55
03
#50
#50
#60
#60
b00000000000000000000000000000110 #
b00000000000000000000000000000111 +
13
#55
#55
#65
#65
03
#60
#60
#70
#70
b00000000000000000000000000000111 #
b00000000000000000000000000001000 +
13
#65
#65
#75
#75
03
#70
#70
#80
#80
b00000000000000000000000000001000 #
b00000000000000000000000000001001 +
13
#75
#75
#85
#85
03
#80
#80
#90
#90
b00000000000000000000000000001001 #
b00000000000000000000000000001010 +
13
#85
#85
#95
#95
03
#90
#90
#100
#100
b00000000000000000000000000001010 #
b00000000000000000000000000001011 +
13
#95
#95
#105
#105
03
#100
#100
#110
#110
b00000000000000000000000000001011 #
b00000000000000000000000000001100 +
13

View File

@ -1,5 +1,5 @@
$date
Sun Mar 1 21:32:04 2020
Sat Mar 7 18:37:58 2020
$end
$version
@ -21,63 +21,69 @@ $upscope $end
$upscope $end
$enddefinitions $end
$dumpvars
#0
0!
1!
b00000000000000000000000000000001 "
b00000000000000000000000000000000 #
b00000000000000000000000000000001 $
#10
1!
b00000000000000000000000000000011 #
b00000000000000000000000000000010 "
#15
0!
#20
1!
b00000000000000000000000000000011 "
b00000000000000000000000000000100 #
b00000000000000000000000000000011 #
b00000000000000000000000000000010 "
#25
0!
#30
1!
b00000000000000000000000000000101 #
b00000000000000000000000000000100 "
b00000000000000000000000000000011 "
b00000000000000000000000000000100 #
#35
0!
#40
1!
b00000000000000000000000000000101 "
b00000000000000000000000000000110 #
b00000000000000000000000000000101 #
b00000000000000000000000000000100 "
#45
0!
#50
1!
b00000000000000000000000000000111 #
b00000000000000000000000000000110 "
b00000000000000000000000000000101 "
b00000000000000000000000000000110 #
#55
0!
#60
1!
b00000000000000000000000000000111 "
b00000000000000000000000000001000 #
b00000000000000000000000000000111 #
b00000000000000000000000000000110 "
#65
0!
#70
1!
b00000000000000000000000000001001 #
b00000000000000000000000000001000 "
b00000000000000000000000000000111 "
b00000000000000000000000000001000 #
#75
0!
#80
1!
b00000000000000000000000000001001 "
b00000000000000000000000000001010 #
b00000000000000000000000000001001 #
b00000000000000000000000000001000 "
#85
0!
#90
1!
b00000000000000000000000000001011 #
b00000000000000000000000000001010 "
b00000000000000000000000000001001 "
b00000000000000000000000000001010 #
#95
0!
#100
1!
b00000000000000000000000000001011 #
b00000000000000000000000000001010 "
#105
0!
#110
1!
b00000000000000000000000000001011 "
b00000000000000000000000000001100 #