-
Notifications
You must be signed in to change notification settings - Fork 1
/
alu_tb.v
68 lines (56 loc) · 1017 Bytes
/
alu_tb.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
`timescale 1ns / 1ps
module alu_tb();
//inputs
reg[31:0] Operand1;
reg[31:0] Operand2;
reg[3:0] OPCODE;
//output
wire[31:0] result;
//design under test
alu DUT (.Operand1(Operand1), .Operand2(Operand2), .OPCODE(OPCODE), .result(result));
initial begin
//Addition
Operand1 = 1;
Operand2 = 2;
OPCODE = 4'b0000;
#10;
//Substraction
Operand1 = 4;
Operand2 = 3;
OPCODE = 4'b0001;
#10;
//Multiplication
Operand1 = 7;
Operand2 = 12;
OPCODE = 4'b0010;
#10;
//AND
Operand1 = 4;
Operand2 = 5;
OPCODE = 4'b0011;
#10;
//OR
Operand1 = 5;
Operand2 = 7;
OPCODE = 4'b0100;
#10;
//XOR
Operand1 = 2;
Operand2 = 6;
OPCODE = 4'b0110;
#10;
//NOT
Operand1 = 1;
Operand2 = 0;
OPCODE = 4'b0111;
#10;
//Left Shift
Operand1 = 4;
OPCODE = 4'b1000;
#10;
//Right Shift
Operand1 = 4;
OPCODE = 4'b1001;
#10;
end
endmodule