-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWB_Mux_Selection_Unit.v.bak
More file actions
40 lines (37 loc) · 1.01 KB
/
WB_Mux_Selection_Unit.v.bak
File metadata and controls
40 lines (37 loc) · 1.01 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
// msrv32_wb_mux_sel_unit 21BCE0289
module msrv32_wb_mux_sel_unit(
input alu_src_reg_in,
input [2:0] wb_mux_sel_reg_in,
input [31:0] alu_result_in,
input [31:0] lu_output_in,
input [31:0] imm_reg_in,
input [31:0] iadder_out_reg_in,
input [31:0] csr_data_in,
input [31:0] pc_plus_4_reg_in,
input [31:0] rs2_reg_in,
output [31:0] wb_mux_out,
output [31:0] alu_2nd_src_mux_out
);
parameter WB_ALU = 3'b000,
WB_LU = 3'b001,
WB_IMM = 3'b010,
WB_IADDER_OUT = 3'b011,
WB_CSR = 3'b100,
WB_PC_PLUS = 3'b101;
reg [31:0] wb_res;
reg [31:0] alu_2nd_src_res;
always@(*) begin
alu_2nd_src_res = (alu_src_reg_in) ? rs2_reg_in : imm_reg_in;
case(wb_mux_sel_reg_in)
WB_ALU: wb_res = alu_result_in;
WB_LU: wb_res = lu_output_in;
WB_IMM: wb_res = imm_reg_in;
WB_IADDER_OUT: wb_res = iadder_out_reg_in;
WB_CSR: wb_res = csr_data_in;
WB_PC_PLUS: wb_res = pc_plus_4_reg_in;
default: wb_res = alu_result_in;
endcase
end
assign wb_mux_out = wb_res;
assign alu_2nd_src_mux_out = alu_2nd_src_res;
endmodule