-
Notifications
You must be signed in to change notification settings - Fork 0
/
decode.v
69 lines (69 loc) · 1.43 KB
/
decode.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
module decode (
Op,
Funct,
Rd,
FlagW,
PCS,
RegW,
MemW,
MemtoReg,
ALUSrc,
ImmSrc,
RegSrc,
ALUControl,
RegByte
);
input wire [1:0] Op;
input wire [5:0] Funct;
input wire [3:0] Rd;
output reg [1:0] FlagW;
output wire PCS;
output wire RegW;
output wire MemW;
output wire MemtoReg;
output wire ALUSrc;
output wire [1:0] ImmSrc;
output wire [1:0] RegSrc;
output reg [2:0] ALUControl;
output wire RegByte;
reg [10:0] controls;
wire Branch;
wire ALUOp;
always @(*)
casex (Op)
2'b00:
if (Funct[5])
controls = 11'b00001010010;
else
controls = 11'b00000010010;
2'b01:
if(Funct[0] & Funct[2])
controls = 11'b00011110001;
else if (Funct[0])
controls = 11'b00011110000;
else
controls = 11'b10011101000;
2'b10: controls = 11'b01101000100;
default: controls = 11'bxxxxxxxxxxx;
endcase
assign {RegSrc, ImmSrc, ALUSrc, MemtoReg, RegW, MemW, Branch, ALUOp,RegByte} = controls;
always @(*)
if (ALUOp) begin
case (Funct[4:1])
//cambiar aqui.
4'b0100: ALUControl = 3'b000;
4'b0010: ALUControl = 3'b001;
4'b0000: ALUControl = 3'b010;
4'b1100: ALUControl = 3'b011;
4'b0001: ALUControl = 3'b110;
default: ALUControl = 3'bxxx;
endcase
FlagW[1] = Funct[0];
FlagW[0] = Funct[0] & ((ALUControl == 3'b000) | (ALUControl == 3'b001));
end
else begin
ALUControl = 3'b000;
FlagW = 2'b00;
end
assign PCS = ((Rd == 4'b1111) & RegW) | Branch;
endmodule