-
Notifications
You must be signed in to change notification settings - Fork 0
/
alu_test.v
53 lines (50 loc) · 1.05 KB
/
alu_test.v
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
`timescale 1ps/1ps
module ALU_TEST();
reg clk = 0;
initial begin
forever begin
clk <= ~clk;
#5;
end
end
reg [31:0] A, B;
reg [3:0] ctrl;
wire zero;
wire[31:0] out;
ALU DUT(A, B, ctrl, out, zero);
initial begin
$dumpfile("alu_test_dump.vcd");
$dumpvars;
//reset
A = 32'b0;
B = 32'b0;
ctrl = 4'b0000;
#10;
//add all 0 and all 1, should be 1
A = 32'b0;
B = {32{1'b1}};
ctrl = 4'b0010;
#10;
//and all 0 and all 1, should be 0
A = 32'b0;
B = {32{1'b1}};
ctrl = 4'b0000;
#10;
//or all 1 and all 1, should be 1
A = {32{1'b1}};
B = {32{1'b1}};
ctrl = 4'b0001;
#10;
//sub 1 and 1, should be 0
A = 32'b1;
B = 32'b1;
ctrl = 4'b1011;
#10;
//slt 0 and 1, should be 1
A = 32'b0;
B = 32'b1;
ctrl = 4'b1011;
#10;
$finish;
end
endmodule