-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_ALU.v
68 lines (53 loc) · 1.45 KB
/
test_ALU.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
module tb_ALU;
reg clk;
reg [7:0] op1, op2;
reg [2:0] sel;
wire [7:0] out;
wire co;
// Instantiate the ALU module
ALU uut (
.clk(clk),
.op1(op1),
.op2(op2),
.sel(sel),
.out(out),
.co(co)
);
initial begin
// Initialize clock
clk = 0;
forever #5 clk = ~clk;
end
initial begin
// Initialize inputs
//ADD test cout:0 out:3
op1 = 8'b00000001; op2 = 8'b00000010; sel = 3'b000;
#10;
// ADD test cout:1 out:3
op1 = 8'b10000001; op2 = 8'b10000010; sel = 3'b000;
#10;
// ASHL test cout:0 out:2
op1 = 8'b00000001; op2 = 8'b00000010; sel = 3'b001;
#10;
// XNOR test cout:0 out:3
op1 = 8'b11111110; op2 = 8'b00000010; sel = 3'b010;
#10;
//DIV2 test cout:1 out:4
op1 = 8'b00001001; op2 = 8'b00000010; sel = 3'b011;
#10;
//LOAD
op1 = 8'b00000001; op2 = 8'b00000010; sel = 3'b100;
#10;
//STORE
op1 = 8'b00000001; op2 = 8'b00000010; sel = 3'b101;
#10;
//COMP2S test cout:0 out:ff
op1 = 8'b00000001; op2 = 8'b00000010; sel = 3'b110;
#10;
//ROUND test cout:0 out:16
op1 = 8'b00001100; op2 = 8'b00000010; sel = 3'b111;
#10;
//ROUND test cout:0 out:16
op1 = 8'b00001010; op2 = 8'b00000010; sel = 3'b111;
end
endmodule