Skip to content

Commit b5a3e9c

Browse files
committed
rtl: comment vip, simplify wave dump
1 parent cdf12a9 commit b5a3e9c

File tree

4 files changed

+47
-22
lines changed

4 files changed

+47
-22
lines changed

rtl/test/croc_vip.sv

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ module croc_vip #(
5959
// JTAG //
6060
////////////
6161

62-
localparam time TApplJtag = 0.2*ClkPeriodJtag;
63-
localparam time TTestJtag = 0.8*ClkPeriodJtag;
62+
localparam realtime TApplJtag = 0.2*ClkPeriodJtag;
63+
localparam realtime TTestJtag = 0.8*ClkPeriodJtag;
6464
localparam dm::sbcs_t JtagInitSbcs = dm::sbcs_t'{
6565
sbautoincrement: 1'b1, sbreadondata: 1'b1, sbaccess: 3, default: '0};
6666

@@ -278,20 +278,13 @@ module croc_vip #(
278278
localparam int unsigned ClkFrequency = 1s / ClkPeriodSys;
279279
localparam int unsigned UartDivisior = ClkFrequency / (UartBaudRate*16);
280280
localparam int unsigned UartRealBaudRate = ClkFrequency / (UartDivisior*16);
281-
localparam time UartBaudPeriod = 1s / UartRealBaudRate;
281+
localparam realtime UartBaudPeriod = 1s / UartRealBaudRate;
282282

283283
initial begin
284284
$display("ClkFrequency: %dMHz", ClkFrequency / 1_000_000);
285285
$display("UartRealBaudRate: %d", UartRealBaudRate);
286286
end
287287

288-
localparam byte_bt UartDebugCmdRead = 'h11;
289-
localparam byte_bt UartDebugCmdWrite = 'h12;
290-
localparam byte_bt UartDebugCmdExec = 'h13;
291-
localparam byte_bt UartDebugAck = 'h06;
292-
localparam byte_bt UartDebugEot = 'h04;
293-
localparam byte_bt UartDebugEoc = 'h14;
294-
295288
logic uart_reading_byte;
296289

297290
initial begin

rtl/test/tb_croc_pkg.sv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
package tb_croc_pkg;
1010

1111
// Clocks
12-
localparam time ClkPeriodSys = 50ns; // 20 MHz
13-
localparam time ClkPeriodJtag = 50ns; // 20 MHz
14-
localparam time ClkPeriodRef = 30518ns; // 32 KiHz
12+
localparam realtime ClkPeriodSys = 50ns; // 20 MHz
13+
localparam realtime ClkPeriodJtag = 50ns; // 20 MHz
14+
localparam realtime ClkPeriodRef = 30518ns; // 32 KiHz
1515

1616
// Number of clock cycles the reset is applied
1717
// for at the beginnig of the simulation

rtl/test/tb_croc_soc.sv

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ module tb_croc_soc #(
1414

1515
import tb_croc_pkg::*;
1616

17+
// Signals fully controlled by the VIP
18+
// use VIP functions/tasks to manipulate these signals
1719
logic rst_n;
1820
logic sys_clk;
1921
logic ref_clk;
2022

21-
logic fetch_en;
22-
2323
logic jtag_tck;
2424
logic jtag_trst_n;
2525
logic jtag_tms;
@@ -29,17 +29,22 @@ module tb_croc_soc #(
2929
logic uart_rx;
3030
logic uart_tx;
3131

32+
// Signals partially controlled by the VIP
3233
logic [GpioCount-1:0] gpio_in;
3334
logic [GpioCount-1:0] gpio_out;
3435
logic [GpioCount-1:0] gpio_out_en;
3536

37+
// Signals controlled by the testbench
38+
logic fetch_en;
39+
3640
/////////////////////////////
3741
// Command Line Arguments //
3842
/////////////////////////////
3943

4044
string binary_path;
4145

4246
initial begin
47+
// $value$plusargs defines what to look for (here +binary=...)
4348
if ($value$plusargs("binary=%s", binary_path)) begin
4449
$display("Running program: %s", binary_path);
4550
end else begin
@@ -51,6 +56,16 @@ module tb_croc_soc #(
5156
////////////
5257
// VIP //
5358
////////////
59+
// Verification IP
60+
// - drives clocks and resets
61+
// - provides helper tasks and functions for JTAG, namely:
62+
// - jtag_load_hex: loads a hex file into the DUT's memory
63+
// - jtag_write_reg32: write 32-bit value to DUT
64+
// - jtag_read_reg32: read 32-bit value from DUT
65+
// - jtag_halt / jtag_resume: control core execution
66+
// - jtag_wait_for_eoc: wait for end of code execution (core writes non-zero to status register)
67+
// - prints UART output to console (you can also write via uart_write_byte)
68+
// - internal GPIO loopback for helloworld test
5469

5570
croc_vip #(
5671
.GpioCount ( GpioCount )
@@ -108,11 +123,6 @@ module tb_croc_soc #(
108123

109124
initial begin
110125
$timeformat(-9, 0, "ns", 12); // 1: scale (ns=-9), 2: decimals, 3: suffix, 4: print-field width
111-
// configure FST (waveform) dump
112-
`ifdef TRACE_WAVE
113-
$dumpfile("croc.fst");
114-
$dumpvars(1, i_croc_soc);
115-
`endif
116126

117127
fetch_en = 1'b0;
118128

@@ -142,10 +152,30 @@ module tb_croc_soc #(
142152

143153
// finish simulation
144154
repeat(50) @(posedge sys_clk);
155+
$finish();
156+
end
157+
158+
////////////////
159+
// Waveform //
160+
////////////////
161+
// start waveform dump at time 0, independent of stimuli
162+
initial begin
145163
`ifdef TRACE_WAVE
146-
$dumpflush;
164+
`ifdef VERILATOR
165+
$dumpfile("croc.fst");
166+
$dumpvars(1, i_croc_soc);
167+
`else
168+
$dumpfile("croc.vcd");
169+
$dumpvars(1, i_croc_soc);
170+
`endif
171+
`endif
172+
end
173+
174+
// flush waveform dump when simulation ends
175+
final begin
176+
`ifdef TRACE_WAVE
177+
$dumpflush;
147178
`endif
148-
$finish();
149179
end
150180

151181
endmodule

vsim/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ transcript
55
vsim.wlf
66
modelsim.ini
77
*.vcd
8+
*.fst
9+
*.wlf

0 commit comments

Comments
 (0)