forked from skynatepro/MIPS32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathALU_tb.v
69 lines (63 loc) · 1.95 KB
/
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
69
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////////
// Company: ////
// Engineer: ////
// ////
// Create Date: 10.08.2022 01:17:25 ////
// Design Name: ////
// Module Name: ALU_tb ////
// Project Name: ////
// Target Devices: ////
// Tool Versions: ////
// Description: ////
// Dependencies: ////
// Revision: ////
// Additional Comments: ////
////////////////////////////////////////////////////////////////////////////////////
module ALU_tb;
reg [31:0] a;
reg [31:0] b;
reg [5:0] alufn;
wire [31:0] otp;
wire overflow;
wire zero;
ALU alu_inst_1(.a(a),.b(b),.alufn(alufn),.otp(otp),.overflow(overflow),.zero(zero));
initial
begin
//add
#100
alufn = 6'b000000;
a = 32'h00000001;
b = 32'h00000001;
//subtract
#100
alufn = 6'b000001;
a = 32'h00000013;
b = 32'h00000002;
//multiply
#100
alufn = 6'b000010;
a = 32'h00000013;
b = 32'h00000002;
#100 //and
alufn = 6'b000100;
a = 1;
b = 0;
#100 //or
alufn = 6'b000101;
a = 32'h00000001;
b = 32'h00000000;
#100 //xor
alufn = 6'b000110;
a = 32'h00000001;
b = 32'h00000000;
#100 //shiftleft
alufn = 6'b001000;
a = 32'h00000001;
b = 32'h00000003;
#100 //shiftright
alufn = 6'b001001;
a = 32'h00000010;
b = 32'h00000003;
end
endmodule