-
Notifications
You must be signed in to change notification settings - Fork 5
/
ALUControl.v
62 lines (50 loc) · 1.58 KB
/
ALUControl.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
/*
* Module: ALUControl
* Dit geeft instructies aan de alu via 11bit opcodes 2bit ALUOP en 4bit operation
* pagina 273 in het boek
* pagina 272 in het boekt geeft aan welke instrcutie nodig zijn + andere instructies in appendix C
*
*/
// D-Type
`define LDUROPCODE 11'b11111000010
`define STUROPCODE 11'b11111000000
// B-Type
`define CBZOPCODE 11'b10110100???
// R-Type
`define ADDOPCODE 11'b10001011000
`define SUBOPCODE 11'b11001011000
`define ANDOPCODE 11'b10001010000
`define ORROPCODE 11'b10101010000
`define LSLOPCODE 11'b11010011011
`define LSROPCODE 11'b11010011010
`define BOPCODE 11'b000101?????
module ALUControl(Operation, ALUOP, OPCode);
input [1:0] ALUOP; //2bit ALUOP
input [10:0] OPCode; //11bit OPCode
output reg [3:0] Operation; //4bit operation
always @ (*)
begin
Operation = 4'b1; // initialiseer
if (ALUOP == 2'b00) // ALUOP[00] D-type
Operation = 4'b0010;
if (ALUOP == 2'b01) // ALUOP[01] B-type
Operation = 4'b0111;
if (ALUOP == 2'b10) // ALUOP[10] R-types
begin
if (OPCode == `ADDOPCODE)
Operation = 4'b0010;
if (OPCode == `SUBOPCODE)
Operation = 4'b0110;
if (OPCode == `ANDOPCODE)
Operation = 4'b0000;
if (OPCode == `ORROPCODE)
Operation = 4'b0001;
if (OPCode == `LSLOPCODE)
Operation = 4'b0011;
if (OPCode == `LSROPCODE)
Operation = 4'b0111;
if (OPCode == `BOPCODE)
Operation = 4'b1111;
end
end
endmodule