@@ -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
151181endmodule
0 commit comments