ibuffer addition
This commit is contained in:
@@ -15,11 +15,13 @@ module VX_decode #(
|
||||
VX_wstall_if wstall_if,
|
||||
VX_join_if join_if
|
||||
);
|
||||
wire valid_in = ifetch_rsp_if.valid;
|
||||
wire [31:0] instr = ifetch_rsp_if.instr;
|
||||
`UNUSED_VAR (clk)
|
||||
`UNUSED_VAR (reset)
|
||||
|
||||
wire [31:0] instr = ifetch_rsp_if.instr;
|
||||
|
||||
reg [`ALU_BITS-1:0] alu_op;
|
||||
reg [`BRU_BITS-1:0] br_op;
|
||||
reg [`BR_BITS-1:0] br_op;
|
||||
reg [`LSU_BITS-1:0] lsu_op;
|
||||
reg [`CSR_BITS-1:0] csr_op;
|
||||
reg [`MUL_BITS-1:0] mul_op;
|
||||
@@ -100,27 +102,27 @@ module VX_decode #(
|
||||
wire is_br = (is_btype || is_jal || is_jalr || is_jals);
|
||||
|
||||
always @(*) begin
|
||||
br_op = `BRU_OTHER;
|
||||
br_op = `BR_OTHER;
|
||||
case (opcode)
|
||||
`INST_B: begin
|
||||
case (func3)
|
||||
3'h0: br_op = `BRU_EQ;
|
||||
3'h1: br_op = `BRU_NE;
|
||||
3'h4: br_op = `BRU_LT;
|
||||
3'h5: br_op = `BRU_GE;
|
||||
3'h6: br_op = `BRU_LTU;
|
||||
3'h7: br_op = `BRU_GEU;
|
||||
3'h0: br_op = `BR_EQ;
|
||||
3'h1: br_op = `BR_NE;
|
||||
3'h4: br_op = `BR_LT;
|
||||
3'h5: br_op = `BR_GE;
|
||||
3'h6: br_op = `BR_LTU;
|
||||
3'h7: br_op = `BR_GEU;
|
||||
default:;
|
||||
endcase
|
||||
end
|
||||
`INST_JAL: br_op = `BRU_JAL;
|
||||
`INST_JALR: br_op = `BRU_JALR;
|
||||
`INST_JAL: br_op = `BR_JAL;
|
||||
`INST_JALR: br_op = `BR_JALR;
|
||||
`INST_SYS: begin
|
||||
if (is_jals && u_12 == 12'h000) br_op = `BRU_ECALL;
|
||||
if (is_jals && u_12 == 12'h001) br_op = `BRU_EBREAK;
|
||||
if (is_jals && u_12 == 12'h302) br_op = `BRU_MRET;
|
||||
if (is_jals && u_12 == 12'h102) br_op = `BRU_SRET;
|
||||
if (is_jals && u_12 == 12'h7B2) br_op = `BRU_DRET;
|
||||
if (is_jals && u_12 == 12'h000) br_op = `BR_ECALL;
|
||||
if (is_jals && u_12 == 12'h001) br_op = `BR_EBREAK;
|
||||
if (is_jals && u_12 == 12'h302) br_op = `BR_MRET;
|
||||
if (is_jals && u_12 == 12'h102) br_op = `BR_SRET;
|
||||
if (is_jals && u_12 == 12'h7B2) br_op = `BR_DRET;
|
||||
end
|
||||
default:;
|
||||
endcase
|
||||
@@ -290,104 +292,93 @@ module VX_decode #(
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VX_decode_if decode_tmp_if();
|
||||
assign decode_if.valid = ifetch_rsp_if.valid
|
||||
&& (decode_if.ex_type != `EX_NOP); // skip noop
|
||||
|
||||
assign decode_tmp_if.valid = ifetch_rsp_if.valid;
|
||||
assign decode_tmp_if.wid = ifetch_rsp_if.wid;
|
||||
assign decode_tmp_if.thread_mask = ifetch_rsp_if.thread_mask;
|
||||
assign decode_tmp_if.curr_PC = ifetch_rsp_if.curr_PC;
|
||||
assign decode_if.wid = ifetch_rsp_if.wid;
|
||||
assign decode_if.thread_mask = ifetch_rsp_if.thread_mask;
|
||||
assign decode_if.curr_PC = ifetch_rsp_if.curr_PC;
|
||||
|
||||
assign decode_tmp_if.ex_type = is_lsu ? `EX_LSU :
|
||||
is_csr ? `EX_CSR :
|
||||
is_mul ? `EX_MUL :
|
||||
is_fpu ? `EX_FPU :
|
||||
is_gpu ? `EX_GPU :
|
||||
is_br ? `EX_BRU :
|
||||
(is_rtype || is_itype || is_lui || is_auipc) ? `EX_ALU :
|
||||
`EX_NOP;
|
||||
assign decode_if.ex_type = is_lsu ? `EX_LSU :
|
||||
is_csr ? `EX_CSR :
|
||||
is_mul ? `EX_MUL :
|
||||
is_fpu ? `EX_FPU :
|
||||
is_gpu ? `EX_GPU :
|
||||
is_br ? `EX_ALU :
|
||||
(is_rtype || is_itype || is_lui || is_auipc) ? `EX_ALU :
|
||||
`EX_NOP;
|
||||
|
||||
assign decode_tmp_if.ex_op = is_lsu ? `OP_BITS'(lsu_op) :
|
||||
is_csr ? `OP_BITS'(csr_op) :
|
||||
is_mul ? `OP_BITS'(mul_op) :
|
||||
is_fpu ? `OP_BITS'(fpu_op) :
|
||||
is_gpu ? `OP_BITS'(gpu_op) :
|
||||
is_br ? `OP_BITS'(br_op) :
|
||||
(is_rtype || is_itype || is_lui || is_auipc) ? `OP_BITS'(alu_op) :
|
||||
0;
|
||||
assign decode_if.ex_op = is_lsu ? `OP_BITS'(lsu_op) :
|
||||
is_csr ? `OP_BITS'(csr_op) :
|
||||
is_mul ? `OP_BITS'(mul_op) :
|
||||
is_fpu ? `OP_BITS'(fpu_op) :
|
||||
is_gpu ? `OP_BITS'(gpu_op) :
|
||||
is_br ? `OP_BITS'({1'b1, br_op}) :
|
||||
(is_rtype || is_itype || is_lui || is_auipc) ? `OP_BITS'({1'b0, alu_op}) :
|
||||
0;
|
||||
|
||||
assign decode_tmp_if.wb = use_rd;
|
||||
assign decode_if.wb = use_rd;
|
||||
|
||||
`ifdef EXT_F_ENABLE
|
||||
|
||||
wire rd_is_fp = is_fpu && ~(is_fcmp || is_fcvti || (fpu_op == `FPU_MVXW || fpu_op == `FPU_CLASS));
|
||||
wire rs1_is_fp = is_fr4 || (is_fci && ~(is_fcvtf || (fpu_op == `FPU_MVWX)));
|
||||
wire rs2_is_fp = is_fs || is_fr4 || is_fci;
|
||||
|
||||
assign decode_tmp_if.rd = {rd_is_fp, rd};
|
||||
assign decode_tmp_if.rs1 = {rs1_is_fp, rs1_qual};
|
||||
assign decode_tmp_if.rs2 = {rs2_is_fp, rs2};
|
||||
assign decode_tmp_if.rs3 = {1'b1, rs3};
|
||||
assign decode_if.rd = {rd_is_fp, rd};
|
||||
assign decode_if.rs1 = {rs1_is_fp, rs1_qual};
|
||||
assign decode_if.rs2 = {rs2_is_fp, rs2};
|
||||
assign decode_if.rs3 = {1'b1, rs3};
|
||||
`else
|
||||
assign decode_tmp_if.rd = rd;
|
||||
assign decode_tmp_if.rs1 = rs1_qual;
|
||||
assign decode_tmp_if.rs2 = rs2;
|
||||
assign decode_tmp_if.rs3 = rs3;
|
||||
assign decode_if.rd = rd;
|
||||
assign decode_if.rs1 = rs1_qual;
|
||||
assign decode_if.rs2 = rs2;
|
||||
assign decode_if.rs3 = rs3;
|
||||
`endif
|
||||
|
||||
assign decode_tmp_if.use_rs3 = use_rs3;
|
||||
assign decode_if.use_rs3 = use_rs3;
|
||||
|
||||
assign decode_tmp_if.reg_use_mask = ((`NUM_REGS)'(use_rd) << decode_tmp_if.rd)
|
||||
| ((`NUM_REGS)'(use_rs1) << decode_tmp_if.rs1)
|
||||
| ((`NUM_REGS)'(use_rs2) << decode_tmp_if.rs2)
|
||||
| ((`NUM_REGS)'(use_rs3) << decode_tmp_if.rs3);
|
||||
assign decode_if.used_regs = ((`NUM_REGS)'(use_rd) << decode_if.rd)
|
||||
| ((`NUM_REGS)'(use_rs1) << decode_if.rs1)
|
||||
| ((`NUM_REGS)'(use_rs2) << decode_if.rs2)
|
||||
| ((`NUM_REGS)'(use_rs3) << decode_if.rs3);
|
||||
|
||||
assign decode_tmp_if.imm = (is_lui || is_auipc) ? {upper_imm, 12'(0)} :
|
||||
(is_jal || is_jalr || is_jals) ? jalx_offset :
|
||||
is_csr ? 32'(u_12) :
|
||||
src2_imm;
|
||||
assign decode_if.imm = (is_lui || is_auipc) ? {upper_imm, 12'(0)} :
|
||||
(is_jal || is_jalr || is_jals) ? jalx_offset :
|
||||
is_csr ? 32'(u_12) :
|
||||
src2_imm;
|
||||
|
||||
assign decode_tmp_if.rs1_is_PC = is_auipc || is_btype || is_jal || is_jals;
|
||||
assign decode_tmp_if.rs2_is_imm = is_itype || is_lui || is_auipc || is_csr_imm;
|
||||
assign decode_if.rs1_is_PC = is_auipc || is_btype || is_jal || is_jals;
|
||||
assign decode_if.rs2_is_imm = is_itype || is_lui || is_auipc || is_csr_imm || is_br;
|
||||
|
||||
assign decode_tmp_if.frm = func3;
|
||||
assign decode_if.frm = func3;
|
||||
|
||||
assign join_if.is_join = valid_in && is_gpu && (gpu_op == `GPU_JOIN);
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
wire decode_fire = decode_if.valid && decode_if.ready;
|
||||
|
||||
assign join_if.is_join = decode_fire && is_gpu && (gpu_op == `GPU_JOIN);
|
||||
assign join_if.wid = ifetch_rsp_if.wid;
|
||||
|
||||
assign wstall_if.wstall = valid_in && (is_btype || is_jal || is_jalr || (is_gpu && (gpu_op == `GPU_TMC || gpu_op == `GPU_SPLIT || gpu_op == `GPU_BAR)));
|
||||
assign wstall_if.wstall = decode_fire && (is_btype || is_jal || is_jalr
|
||||
|| (is_gpu && (gpu_op == `GPU_TMC
|
||||
|| gpu_op == `GPU_SPLIT
|
||||
|| gpu_op == `GPU_BAR)));
|
||||
assign wstall_if.wid = ifetch_rsp_if.wid;
|
||||
|
||||
wire stall = ~decode_if.ready && decode_if.valid;
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VX_generic_register #(
|
||||
.N(1 + `NW_BITS + `NUM_THREADS + 32 + `NR_BITS + `NR_BITS + `NR_BITS + 32 + 1 + `EX_BITS + `OP_BITS + 1 + `NR_BITS + 1 + 1 + `FRM_BITS + `NUM_REGS)
|
||||
) decode_reg (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
.stall (stall),
|
||||
.flush (0),
|
||||
.in ({decode_tmp_if.valid, decode_tmp_if.wid, decode_tmp_if.thread_mask, decode_tmp_if.curr_PC, decode_tmp_if.rd, decode_tmp_if.rs1, decode_tmp_if.rs2, decode_tmp_if.imm, decode_tmp_if.rs1_is_PC, decode_tmp_if.rs2_is_imm, decode_tmp_if.ex_type, decode_tmp_if.ex_op, decode_tmp_if.wb, decode_tmp_if.rs3, decode_tmp_if.use_rs3, decode_tmp_if.frm, decode_tmp_if.reg_use_mask}),
|
||||
.out ({decode_if.valid, decode_if.wid, decode_if.thread_mask, decode_if.curr_PC, decode_if.rd, decode_if.rs1, decode_if.rs2, decode_if.imm, decode_if.rs1_is_PC, decode_if.rs2_is_imm, decode_if.ex_type, decode_if.ex_op, decode_if.wb, decode_if.rs3, decode_if.use_rs3, decode_if.frm, decode_if.reg_use_mask})
|
||||
);
|
||||
|
||||
assign ifetch_rsp_if.ready = ~stall;
|
||||
assign ifetch_rsp_if.ready = decode_if.ready;
|
||||
|
||||
`ifdef DBG_PRINT_PIPELINE
|
||||
always @(posedge clk) begin
|
||||
if (decode_tmp_if.valid && ~stall) begin
|
||||
$write("%t: Core%0d-Decode: wid=%0d, PC=%0h, ex=", $time, CORE_ID, decode_tmp_if.wid, decode_tmp_if.curr_PC);
|
||||
print_ex_type(decode_tmp_if.ex_type);
|
||||
if (decode_if.valid && decode_if.ready) begin
|
||||
$write("%t: core%0d-decode: wid=%0d, PC=%0h, ex=", $time, CORE_ID, decode_if.wid, decode_if.curr_PC);
|
||||
print_ex_type(decode_if.ex_type);
|
||||
$write(", op=");
|
||||
print_ex_op(decode_tmp_if.ex_type, decode_tmp_if.ex_op);
|
||||
$write(", tmask=%b, wb=%b, rd=%0d, rs1=%0d, rs2=%0d, rs3=%0d, imm=%0h, use_pc=%b, use_imm=%b, frm=", decode_tmp_if.thread_mask, decode_tmp_if.wb, decode_tmp_if.rd, decode_tmp_if.rs1, decode_tmp_if.rs2, decode_tmp_if.rs3, decode_tmp_if.imm, decode_tmp_if.rs1_is_PC, decode_tmp_if.rs2_is_imm);
|
||||
print_frm(decode_tmp_if.frm);
|
||||
$write("\n");
|
||||
|
||||
// trap unsupported instructions
|
||||
assert(~(~stall && (decode_tmp_if.ex_type == `EX_ALU) && `ALU_OP(decode_tmp_if.ex_op) == `ALU_OTHER));
|
||||
assert(~(~stall && (decode_tmp_if.ex_type == `EX_BRU) && `BRU_OP(decode_tmp_if.ex_op) == `BRU_OTHER));
|
||||
assert(~(~stall && (decode_tmp_if.ex_type == `EX_CSR) && `CSR_OP(decode_tmp_if.ex_op) == `CSR_OTHER));
|
||||
assert(~(~stall && (decode_tmp_if.ex_type == `EX_GPU) && `GPU_OP(decode_tmp_if.ex_op) == `GPU_OTHER));
|
||||
print_ex_op(decode_if.ex_type, decode_if.ex_op);
|
||||
$write(", tmask=%b, wb=%b, rd=%0d, rs1=%0d, rs2=%0d, rs3=%0d, imm=%0h, use_pc=%b, use_imm=%b, frm=", decode_if.thread_mask, decode_if.wb, decode_if.rd, decode_if.rs1, decode_if.rs2, decode_if.rs3, decode_if.imm, decode_if.rs1_is_PC, decode_if.rs2_is_imm);
|
||||
print_frm(decode_if.frm);
|
||||
$write("\n");
|
||||
end
|
||||
end
|
||||
`endif
|
||||
|
||||
Reference in New Issue
Block a user