-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_decoder.sv
More file actions
55 lines (46 loc) · 1 KB
/
Copy pathmain_decoder.sv
File metadata and controls
55 lines (46 loc) · 1 KB
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
module main_decoder(opcode,resultsrc,immsrc,
memwrite,
regwrite,alusrc,aluop,
branch);
input logic [6:0]opcode;
output logic memwrite,regwrite,alusrc,branch;
output logic [1:0]aluop,resultsrc,immsrc;
always_comb begin
if (opcode == 7'b0000011) begin
regwrite= 1;
immsrc=2'b00;
alusrc=1;
memwrite=0;
resultsrc=2'b01;
branch=0;
aluop=2'b00;
end
else if (opcode == 7'b0100011) begin
regwrite= 0;
immsrc=2'b01;
alusrc=1;
memwrite=1;
resultsrc=0;
branch=0;
aluop=2'b00;
end
else if (opcode == 7'b0110011) begin
regwrite= 1;
immsrc=2'b00;
alusrc=0;
memwrite=0;
resultsrc=0;
branch=0;
aluop=2'b10;
end
else begin
regwrite= 0;
immsrc=2'b10;
alusrc=0;
memwrite=0;
resultsrc=0;
branch=1;
aluop=2'b01;
end
end
endmodule