-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathAdder_OK_testsuite.sv
126 lines (98 loc) · 3.11 KB
/
Adder_OK_testsuite.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Mandatory file to be able to launch SVUT flow
`include "svut_h.sv"
// Specify here the module to load or setup the path in files.f
`include "Adder.v"
`timescale 1 ns / 1 ps
module Adder_unit_test_OK;
`SVUT_SETUP
parameter WIDTH = 8;
reg aclk;
reg arstn;
reg clr;
reg inc;
reg [WIDTH-1:0] out;
Adder
#(
WIDTH
)
dut
(
aclk,
arstn,
clr,
inc,
out
);
// An example to create a clock
initial aclk = 0;
always #2 aclk <= ~aclk;
// An example to dump data for visualization
initial $dumpvars(0, Adder_unit_test_OK);
task setup(msg="Here is the setup function");
begin
// setup() runs when a test begins
inc = 1'b0;
clr = 1'b0;
arstn = 1'b0;
#100;
arstn = 1'b1;
end
endtask
task teardown(msg="Here is the teardown function");
begin
// teardown() runs when a test ends
end
endtask
`TEST_SUITE("This is my OK Testsuite")
/* Available macros:
- `INFO("message"); Print a grey message
- `SUCCESS("message"); Print a green message
- `WARNING("message"); Print an orange message and increment warning counter
- `CRITICAL("message"); Print an pink message and increment critical counter
- `ERROR("message"); Print a red message and increment error counter
- `FAIL_IF(aSignal); Increment error counter if evaluaton is positive
- `FAIL_IF_NOT(aSignal); Increment error coutner if evaluation is false
- `FAIL_IF_EQUAL(aSignal, 23); Increment error counter if evaluation is equal
- `FAIL_IF_NOT_EQUAL(aSignal, 45); Increment error counter if evaluation is not equal
*/
/* Available flag:
- `LAST_STATUS: tied to 1 if last macros has been asserted, else tied to 0
*/
`UNIT_TEST("Macro test")
`MSG("I print a message for myself");
`SUCCESS("All tests are expected OK!");
// Basic tests of the main functions. All results are expected OK
`INFO("Test FAIL_IF");
`FAIL_IF(inc);
`INFO("Test FAIL_IF_EQUAL");
`FAIL_IF_EQUAL(out, 8'd18);
`INFO("Test FAIL_IF_NOT_EQUAL");
`FAIL_IF_NOT_EQUAL(out, 8'd0);
@(posedge aclk);
inc = 1'b1;
`INFO("Test FAIL_IF_NOT");
`FAIL_IF_NOT(inc);
@(posedge aclk);
inc = 1'b0;
`INFO("Test FAIL_IF");
`FAIL_IF(inc);
`INFO("Test FAIL_IF_EQUAL");
`FAIL_IF_EQUAL(out, 8'd0);
`INFO("Test FAIL_IF_NOT_EQUAL");
`FAIL_IF_NOT_EQUAL(out, 8'd1);
`INFO("Test ASSERT");
`ASSERT(inc === 1'b0);
`SUCCESS("Test finished");
`UNIT_TEST_END
`UNIT_TEST("Define check")
`ifndef MYDEF1
`ERROR("No define 1 found!");
`endif
if (`MYDEF1!=5)
`ERROR("MYDEF1 is not equal to 5");
`ifndef MYDEF2
`ERROR("No define 2 found!");
`endif
`UNIT_TEST_END
`TEST_SUITE_END
endmodule