RVSCC/rtl/ALUDecoder.sv

66 lines
1.5 KiB
Systemverilog
Raw Normal View History

2023-01-01 22:28:56 +00:00
`timescale 1ns / 1ps
2023-01-29 04:55:22 +00:00
module ALUDecoder (
2023-01-01 22:28:56 +00:00
input logic opcode_5,
2023-01-29 04:55:22 +00:00
input logic [2:0] funct_3,
2023-01-01 22:28:56 +00:00
input logic funct_7_5,
2023-01-29 04:55:22 +00:00
input logic [1:0] alu_op,
output logic [2:0] alu_ctrl,
2023-01-01 22:28:56 +00:00
output logic branch_neg
);
2023-01-29 04:55:22 +00:00
always_comb begin
casex ({
alu_op, funct_3, opcode_5, funct_7_5
})
'b00xxxxx: begin
alu_ctrl = 'b000; // lw sw
branch_neg = 'dx;
end
'b01000xx: begin
alu_ctrl = 'b001; // beq
branch_neg = 1;
end
'b01100xx: begin
alu_ctrl = 'b101; // blt
branch_neg = 0;
end
'b01101xx: begin
alu_ctrl = 'b101; // bge
branch_neg = 1;
end
'b1000000: begin
alu_ctrl = 'b000; // add
branch_neg = 'dx;
end
'b1000001: begin
alu_ctrl = 'b000; // add
branch_neg = 'dx;
end
'b1000010: begin
alu_ctrl = 'b000; // add
branch_neg = 'dx;
end
'b1000011: begin
alu_ctrl = 'b001; // sub
branch_neg = 'dx;
end
'b10010xx: begin
alu_ctrl = 'b101; // slt
branch_neg = 'dx;
end
'b10110xx: begin
alu_ctrl = 'b000; // or
branch_neg = 'dx;
end
'b10111xx: begin
alu_ctrl = 'b000; // and
branch_neg = 'dx;
end
default: begin
alu_ctrl = 'dx;
branch_neg = 'dx;
end
endcase
end
2023-01-01 22:28:56 +00:00
endmodule