File tree Expand file tree Collapse file tree 8 files changed +68
-21
lines changed Expand file tree Collapse file tree 8 files changed +68
-21
lines changed Original file line number Diff line number Diff line change 1
1
* .vvp
2
- * .vcd
3
-
4
- ! test /fetch_tb.vcd
5
- ! test /beq_tb.vcd
6
2
7
3
.devcontainer /
Original file line number Diff line number Diff line change @@ -3,19 +3,45 @@ OUTPUT := out/top.vvp
3
3
IVERILOG := iverilog
4
4
VVP := vvp
5
5
6
+ TB_SRC_PATTERN := test/%_tb.sv
7
+ TB_OUT_PATTERN := out/%_tb.vvp
8
+
9
+ TB_SRCS := $(wildcard $(subst % ,* ,$(TB_SRC_PATTERN ) ) )
10
+ TB_VVPS := $(patsubst $(TB_SRC_PATTERN ) ,$(TB_OUT_PATTERN ) ,$(TB_SRCS ) )
11
+ TB_UTILS := test/utils.svh
12
+
13
+ TB_VCD_BASE_PATH := test/vcd
14
+
6
15
all : $(OUTPUT )
7
16
8
- $(OUTPUT ) : $( SRCS )
17
+ $(OUTPUT ) :
9
18
$(IVERILOG ) -g2012 -o $(OUTPUT ) -c src/top.cf
10
19
11
20
run : $(OUTPUT )
12
21
$(VVP ) $(OUTPUT )
13
22
14
- # tmp
15
- fetch_tb :
16
- $(IVERILOG ) -g2012 -o $(OUTPUT ) $(SRCS ) -c src/top.cf test/fetch_tb.sv
23
+ $(TB_OUT_PATTERN ) : $(TB_SRC_PATTERN ) $(TB_UTILS )
24
+ $(IVERILOG ) -g2012 -o $@ -c src/top.cf $<
25
+
26
+ build_tb : $(TB_VVPS )
17
27
18
- beq_tb :
19
- $(IVERILOG ) -g2012 -o $(OUTPUT ) $(SRCS ) -c src/top.cf test/beq_tb.sv
28
+ run_tb : $(TB_VVPS )
29
+ @failed=0; \
30
+ for tb in $( TB_VVPS) ; do \
31
+ echo " Running $$ tb..." ; \
32
+ if ! $( VVP) -N $$ tb +VCD_PATH=$( TB_VCD_BASE_PATH) ; then \
33
+ echo " \033[31mFAILED: $$ tb\033[0m" ; \
34
+ failed=1; \
35
+ else \
36
+ echo " \033[32mPASSED: $$ tb\033[0m" ; \
37
+ fi ; \
38
+ echo " " ; \
39
+ done ; \
40
+ if [ $$ failed -eq 1 ]; then \
41
+ echo " \033[31mSome testbenches failed!\033[0m" ; \
42
+ exit 1; \
43
+ else \
44
+ echo " \033[32mAll testbenches passed!\033[0m" ; \
45
+ fi
20
46
21
- .PHONY : all run
47
+ .PHONY : all run testbenches run-tests
Original file line number Diff line number Diff line change 3
3
`include " src/utils.svh"
4
4
`include " src/types.svh"
5
5
6
+ `include " test/utils.svh"
7
+
6
8
module beq_tb ;
7
9
reg clk;
8
10
reg reset;
@@ -110,8 +112,6 @@ module beq_tb;
110
112
$finish ;
111
113
end
112
114
113
- initial begin
114
- $dumpfile (" test/beq_tb.vcd" );
115
- $dumpvars (0 , beq_tb);
116
- end
115
+ `SETUP_VCD_DUMP (beq_tb)
116
+
117
117
endmodule
Original file line number Diff line number Diff line change 3
3
`include " src/utils.svh"
4
4
`include " src/types.svh"
5
5
6
+ `include " test/utils.svh"
7
+
6
8
module fetch_tb ;
7
9
8
10
reg clk;
@@ -184,8 +186,6 @@ module fetch_tb;
184
186
$finish ;
185
187
end
186
188
187
- initial begin
188
- $dumpfile (" test/fetch_tb.vcd" );
189
- $dumpvars (0 , fetch_tb);
190
- end
189
+ `SETUP_VCD_DUMP (fetch_tb)
190
+
191
191
endmodule
Original file line number Diff line number Diff line change
1
+ `ifndef TEST__UTILS_SVH
2
+ `define TEST__UTILS_SVH
3
+
4
+ `define SETUP_VCD_DUMP (module_name) \
5
+ initial begin \
6
+ string vcd_path; \
7
+ string vcd_filename; \
8
+ \
9
+ if ($test$plusargs (" VCD_PATH" )) begin \
10
+ if ($value$plusargs (" VCD_PATH=%s " , vcd_path) == 0 ) begin \
11
+ $display (" VCD_PATH not set, not dumping VCD" ); \
12
+ end \
13
+ \
14
+ vcd_filename = $sformatf (" %s /%s .vcd" , vcd_path, `" module_name`" ); \
15
+ \
16
+ $dumpfile (vcd_filename); \
17
+ $dumpvars (0 , module_name); \
18
+ end \
19
+ end
20
+
21
+ `endif
Original file line number Diff line number Diff line change 1
1
$date
2
- Thu Jun 5 04:15:59 2025
2
+ Sun Jun 15 20:29:55 2025
3
3
$end
4
4
$version
5
5
Icarus Verilog
@@ -125,6 +125,8 @@ $var reg 32 o writeData [31:0] $end
125
125
$upscope $end
126
126
$upscope $end
127
127
$upscope $end
128
+ $scope begin $unm_blk_47 $end
129
+ $upscope $end
128
130
$upscope $end
129
131
$enddefinitions $end
130
132
$comment Show the parameter values. $end
Original file line number Diff line number Diff line change 1
1
$date
2
- Thu Jun 5 04:15:54 2025
2
+ Sun Jun 15 20:29:55 2025
3
3
$end
4
4
$version
5
5
Icarus Verilog
@@ -35,6 +35,8 @@ $upscope $end
35
35
$scope begin $ivl_for_loop0 $end
36
36
$var integer 32 0 i [31:0] $end
37
37
$upscope $end
38
+ $scope begin $unm_blk_48 $end
39
+ $upscope $end
38
40
$upscope $end
39
41
$enddefinitions $end
40
42
$comment Show the parameter values. $end
You can’t perform that action at this time.
0 commit comments