-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalu_control_test.v
160 lines (154 loc) · 2.4 KB
/
alu_control_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
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
154
155
156
157
158
`timescale 1ns/10ps
module alu_control_test();
reg [5:0] func;
reg [1:0] alu_op;
wire [2:0] alu_ctrl;
alu_control ac1 (func, alu_op, alu_ctrl);
initial begin
// itype
// add
// should be 010
func = 6'b101010;
alu_op = 2'b00;
#10
// should be 010 for add
func = 6'b111111;
alu_op = 2'b00;
#10
// should be 010 for add
func = 6'b000000;
alu_op = 2'b00;
#10
//sub
// should be 110 for sub
func = 6'b100100;
alu_op = 2'b01;
#10
// should be 110 for sub
func = 6'b111111;
alu_op = 2'b01;
#10
// should be 110 for sub
func = 6'b000000;
alu_op = 2'b01;
#10
// rtype
// and
// should be 000
func = 6'b100100;
alu_op = 2'b10;
#10
// should be 000
func = 6'b100100;
alu_op = 2'b10;
#10
// should be 000
func = 6'b100100;
alu_op = 2'b11;
#10
// or
// should be 001
func = 6'b100101;
alu_op = 2'b10;
#10
// should be 001
func = 6'b100101;
alu_op = 2'b10;
#10
// should be 001
func = 6'b100101;
alu_op = 2'b11;
#10
// add
// should be 010
func = 6'b100000;
alu_op = 2'b10;
#10
// should be 010
func = 6'b100000;
alu_op = 2'b10;
#10
// should be 010
func = 6'b100000;
alu_op = 2'b11;
#10
// addu
// should be 010
func = 6'b100001;
alu_op = 2'b10;
#10
// should be 010
func = 6'b100001;
alu_op = 2'b10;
#10
// should be 010
func = 6'b100001;
alu_op = 2'b11;
#10
// sub
// should be 110
func = 6'b100010;
alu_op = 2'b10;
#10
// should be 110
func = 6'b100010;
alu_op = 2'b10;
#10
// should be 110
func = 6'b100010;
alu_op = 2'b11;
#10
// subu
// should be 110
func = 6'b100011;
alu_op = 2'b10;
#10
// should be 110
func = 6'b100011;
alu_op = 2'b11;
#10
// should be 110
func = 6'b100011;
alu_op = 2'b11;
#10
// slt
// should be 011
func = 6'b101010;
alu_op = 2'b10;
#10
// should be 011
func = 6'b101010;
alu_op = 2'b11;
#10
// should be 011
func = 6'b101010;
alu_op = 2'b11;
#10
// sltu
// should be 111
func = 6'b101011;
alu_op = 2'b10;
#10
// should be 111
func = 6'b101011;
alu_op = 2'b11;
#10
// should be 111
func = 6'b101011;
alu_op = 2'b11;
#10
// sll
// should be 101
func = 6'b000000;
alu_op = 2'b10;
#10
// should be 101
func = 6'b000000;
alu_op = 2'b11;
#10
// should be 101
func = 6'b000000;
alu_op = 2'b11;
#10 $finish;
end
endmodule