-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalu_32_tb.v
More file actions
153 lines (136 loc) · 2.11 KB
/
Copy pathalu_32_tb.v
File metadata and controls
153 lines (136 loc) · 2.11 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
`timescale 1ns/1ns
module alu_32_tb;
reg [31:0] A;
reg [31:0] B;
reg [5:0] opcode;
wire [31:0] out;
alu_32 alu(.A(A), .B(B), .opcode(opcode), .out(out));
initial begin
$monitor("A=%b B=%b, opcode=%b -> out=%b", A, B, opcode, out);
//Testing SLL
#100
A = 32'b1;
B = 32'b1;
opcode = 6'b000100;
#100
// if (out != A << B) begin
// $finish(1);
// end
//Testing SRL
#100
A = 32'b10;
B = 32'b1;
opcode = 6'b000110;
#100
// if (out != A >> B) begin
// $finish(1);
// end
//Testing SRA
#100
A={{1'b1}, {31{1'b0}}};
B = 32'b1;
opcode = 6'b000111;
#100
// if (out != A >>> B) begin
// $finish(1);
// end
//Testing ADD
#100
A={{1'b1}, {31{1'b0}}};
B = 32'b1;
opcode = 6'b100000;
#100
// if (out != A + B) begin
// $finish(1);
// end
//Testing SUB
#100
A={{1'b1}, {31{1'b0}}};
B = 32'b1;
opcode = 6'b100010;
#100
//if (out != A - B) begin
// $finish(1);
//end
//Testing AND
#100
A=32'b101;
B = 32'b1;
opcode = 6'b100100;
#100
//if (out != 32'b1) begin
// $finish(1);
// end
//Testing OR
#100
A=32'b101;
B = 32'b1;
opcode = 6'b100101;
#100
// if (out != 32'b101) begin
// $finish(1);
// end
//Testing XOR
#100
A=32'b101;
B = 32'b1;
opcode = 6'b100110;
#100
//if (out != 32'b100) begin
// $finish(1);
// end
//Testing SEQ
#100
A=32'b101;
B = 32'b101;
opcode = 6'b101000;
#100
// if (out != 32'b1) begin
// $finish(1);
// end
//Testing SNE
#100
A=32'b101;
B = 32'b101;
opcode = 6'b101001;
#100
// if (out != 32'b0) begin
// $finish(1);
// end
//Testing SLT
#100
A=32'b101;
B = 32'b01;
opcode = 6'b101010;
#100
// if (out != 32'b0) begin
// $finish(1);
// end
//Testing SGT
#100
A=32'b101;
B = 32'b01;
opcode = 6'b101011;
#100
// if (out != 32'b1) begin
// $finish(1);
// end
//Testing SLE
#100
A=32'b101;
B = 32'b101;
opcode = 6'b101100;
#100
// if (out != 32'b1) begin
// $finish(1);
// end
//Testing SGE
#100
A=32'b101;
B = 32'b101;
opcode = 6'b101101;
// if (out != 32'b1) begin
// $finish(1);
// end
end
endmodule