Skip to content

Commit 026b6b4

Browse files
collucathommythomaso
authored andcommitted
tracer: Improve capabilities for Snitch, fix smaller issues
* util/mario: Correct potentially dangerous typo in tracer RTL * src: Restore DMA tracing in Snitch DMA * Correct SV linting errors * src: Enable tracing multiple channels * util/mario: Trace signals required for parsing in Snitch * treewide: Enable tracing in Verilator * src: Guard tracing logic during synthesis (#58)
1 parent a6b190c commit 026b6b4

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

src/frontend/inst64/idma_inst64_top.sv

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
`include "common_cells/registers.svh"
99
`include "idma/typedef.svh"
10+
`include "idma/tracer.svh"
1011

1112
/// Implements the tightly-coupled frontend. This module can directly be connected
1213
/// to an accelerator bus in the snitch system
@@ -18,6 +19,7 @@ module idma_inst64_top #(
1819
parameter int unsigned NumAxInFlight = 32'd3,
1920
parameter int unsigned DMAReqFifoDepth = 32'd3,
2021
parameter int unsigned NumChannels = 32'd1,
22+
parameter int unsigned DMATracing = 32'd0,
2123
parameter type axi_ar_chan_t = logic,
2224
parameter type axi_aw_chan_t = logic,
2325
parameter type axi_req_t = logic,
@@ -209,7 +211,6 @@ module idma_inst64_top #(
209211
end
210212

211213

212-
213214
//--------------------------------------
214215
// 2D Extension
215216
//--------------------------------------
@@ -507,4 +508,29 @@ module idma_inst64_top #(
507508
//--------------------------------------
508509
`FF(idma_fe_req_q, idma_fe_req_d, '0)
509510

511+
512+
//--------------------------------------
513+
// DMA Tracer
514+
//--------------------------------------
515+
// only activate tracer if requested
516+
`ifndef SYNTHESIS
517+
if (DMATracing) begin : gen_tracer
518+
for (genvar c = 0; c < NumChannels; c++) begin : gen_channels
519+
// derive the name of the trace file from the hart and channel IDs
520+
string trace_file;
521+
initial begin
522+
// We need to schedule the assignment into a safe region, otherwise
523+
// `hart_id_i` won't have a value assigned at the beginning of the first
524+
// delta cycle.
525+
`ifndef VERILATOR
526+
#0;
527+
`endif
528+
$sformat(trace_file, "dma_trace_%05x_%05x.log", hart_id_i, c);
529+
end
530+
// attach the tracer
531+
`IDMA_TRACER_RW_AXI(gen_backend[c].i_idma_backend_rw_axi, trace_file);
532+
end
533+
end
534+
`endif
535+
510536
endmodule

util/mario/tracer.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,26 @@
1414
TRACER_BODY = '''
1515
// The tracer for the ${identifier} iDMA
1616
`define IDMA_TRACER_${identifier_cap}(__backend_inst, __out_f) <%text>\\</%text>
17-
`ifndef SYNTHESYS <%text>\\</%text>
18-
`ifndef VERILATOR <%text>\\</%text>
17+
`ifndef SYNTHESIS <%text>\\</%text>
1918
initial begin : inital_tracer_${identifier} <%text>\\</%text>
2019
automatic bit first_iter = 1; <%text>\\</%text>
2120
automatic integer tf; <%text>\\</%text>
2221
automatic `IDMA_TRACER_MAX_TYPE cnst [string]; <%text>\\</%text>
2322
automatic `IDMA_TRACER_MAX_TYPE meta [string]; <%text>\\</%text>
23+
automatic `IDMA_TRACER_MAX_TYPE backend [string]; <%text>\\</%text>
2424
automatic `IDMA_TRACER_MAX_TYPE busy [string]; <%text>\\</%text>
2525
automatic `IDMA_TRACER_MAX_TYPE bus [string]; <%text>\\</%text>
2626
automatic string trace; <%text>\\</%text>
27+
`ifndef VERILATOR <%text>\\</%text>
2728
#0; <%text>\\</%text>
29+
`endif <%text>\\</%text>
2830
tf = $fopen(__out_f, "w"); <%text>\\</%text>
2931
$display("[iDMA Tracer] Logging %s to %s", `"__backend_inst`", __out_f); <%text>\\</%text>
3032
forever begin <%text>\\</%text>
3133
@(posedge __backend_inst``.clk_i); <%text>\\</%text>
32-
if(__backend_inst``.rst_ni & |__backend_inst``.busy_o) begin <%text>\\</%text>
34+
if(__backend_inst``.rst_ni & (|__backend_inst``.busy_o | <%text>\\</%text>
35+
__backend_inst``.req_valid_i | <%text>\\</%text>
36+
__backend_inst``.rsp_valid_o)) begin <%text>\\</%text>
3337
/* Trace */ <%text>\\</%text>
3438
trace = "{"; <%text>\\</%text>
3539
/* Constants */ <%text>\\</%text>
@@ -55,6 +59,13 @@
5559
meta = '{ <%text>\\</%text>
5660
"time" : $time() <%text>\\</%text>
5761
}; <%text>\\</%text>
62+
backend = '{ <%text>\\</%text>
63+
"req_valid" : __backend_inst``.req_valid_i, <%text>\\</%text>
64+
"req_ready" : __backend_inst``.req_ready_o, <%text>\\</%text>
65+
"rsp_valid" : __backend_inst``.rsp_valid_o, <%text>\\</%text>
66+
"rsp_ready" : __backend_inst``.rsp_ready_i, <%text>\\</%text>
67+
"req_length" : __backend_inst``.idma_req_i.length <%text>\\</%text>
68+
}; <%text>\\</%text>
5869
busy = '{ <%text>\\</%text>
5970
"buffer" : __backend_inst``.busy_o.buffer_busy, <%text>\\</%text>
6071
"r_dp" : __backend_inst``.busy_o.r_dp_busy, <%text>\\</%text>
@@ -71,6 +82,7 @@
7182
/* Assembly */ <%text>\\</%text>
7283
`IDMA_TRACER_STR_ASSEMBLY(cnst, first_iter); <%text>\\</%text>
7384
`IDMA_TRACER_STR_ASSEMBLY(meta, 1); <%text>\\</%text>
85+
`IDMA_TRACER_STR_ASSEMBLY(backend, 1); <%text>\\</%text>
7486
`IDMA_TRACER_STR_ASSEMBLY(busy, 1); <%text>\\</%text>
7587
`IDMA_TRACER_STR_ASSEMBLY(bus, 1); <%text>\\</%text>
7688
`IDMA_TRACER_CLEAR_COND(first_iter); <%text>\\</%text>
@@ -79,7 +91,6 @@
7991
end <%text>\\</%text>
8092
end <%text>\\</%text>
8193
end <%text>\\</%text>
82-
`endif <%text>\\</%text>
8394
`endif
8495
'''
8596

0 commit comments

Comments
 (0)