How to Make TLM Signals Appear in VCD Trace?
Unfortunately tracing TLM traffic is not directly supported (e.g. discussion. Additional tools are needed for tracing. To minimize the installation effort, we can just add additional signals that will appear in the VCD trace using the trace.cc that is part of cosim demo.
1. Add New Signals
Add the following signals as members of your target class (e.g. in debugdev.h):
// internal signals for tracing
sc_buffer<sc_dt::sc_bv<32>> tr_addr;
sc_buffer<sc_dt::sc_bv<32>> tr_data;
sc_buffer<sc_dt::sc_bv<32>> tr_len;
sc_buffer<sc_dt::sc_bv<4>> tr_command;
2. Give Meaninful Names
Give those s ignals meaningful names, by initizliaing in the target’s constructor (e.g. in debugdev.cc):
debugdev::debugdev(sc_module_name name)
: sc_module(name), socket("socket"), irq("irq"),
tr_addr("addr"), tr_data("data"), tr_len("len"), tr_command("command")
3. Update the values when a new transaction arrives
After cosuming the delay wait(delay)
assign the TLM payload’s values to the trace signals.
wait(delay);
delay = sc_time(0, SC_US);
// write out the trace signals
tr_addr = addr;
tr_command = (unsigned int) cmd;
tr_len = len;
switch(len) {
case 1:
tr_data = *((uint8_t*) data);
break;
case 2:
tr_data = *((uint16_t*) data);
break;
case 4:
tr_data = *((uint32_t*) data);
break;
default:
trans.set_response_status(tlm::TLM_GENERIC_ERROR_RESPONSE);
return;
}
if (trans.get_command() == tlm::TLM_READ_COMMAND)
/* ... */
4. Running
Next time your design is executed, the trace.vcd will contain additional signals.
5. Outlook
HINT: you can trace any signal, and even strings with VCD. They will nicely appear in the trace.
VCD Viewers: GTKWave as a stand alone program. There is also a nice VS Code plugin WaveTrace. Just to give examples.
For a more full fledged analysis of all signals and events, see SystemCComponents.