diff --git a/lib/isa_decoder/isa_decoder.sv b/lib/isa_decoder/isa_decoder.sv index 1e17e19685..9bd20e596c 100644 --- a/lib/isa_decoder/isa_decoder.sv +++ b/lib/isa_decoder/isa_decoder.sv @@ -134,6 +134,23 @@ }; endfunction : get_sort_ciw_imm + function gpr_t get_gpr_from_gpr_rvc(gpr_rvc_t gpr); + gpr_t uncompressed_gpr; + casex (gpr.gpr) + C_X8: uncompressed_gpr.gpr = X8; + C_X9: uncompressed_gpr.gpr = X9; + C_X10: uncompressed_gpr.gpr = X10; + C_X11: uncompressed_gpr.gpr = X11; + C_X12: uncompressed_gpr.gpr = X12; + C_X13: uncompressed_gpr.gpr = X13; + C_X14: uncompressed_gpr.gpr = X14; + C_X15: uncompressed_gpr.gpr = X15; + default: uncompressed_gpr.gpr = X0; // Function used wrong if we ever end up here + endcase + + return uncompressed_gpr; + endfunction : get_gpr_from_gpr_rvc + // --------------------------------------------------------------------------- // Find the value of immediate // --------------------------------------------------------------------------- @@ -294,10 +311,10 @@ casex (format) I_TYPE: begin if (asm.instr inside { FENCE_I, ECALL, EBREAK, MRET, DRET, WFI, WFE }) begin - asm.rd.valid = 0; - asm.rs1.valid = 0; - asm.rs2.valid = 0; - asm.imm.valid = 0; + asm.rd.valid = 0; + asm.rs1.valid = 0; + asm.rs2.valid = 0; + asm.imm.valid = 0; end else if (asm.instr inside { FENCE }) begin asm.imm.imm_raw = instr.uncompressed.format.i.imm; asm.imm.imm_raw_sorted = instr.uncompressed.format.i.imm; @@ -307,12 +324,12 @@ asm.imm.imm_value = get_imm_value_i(instr.uncompressed.format.i.imm); asm.imm.valid = 1; end else if (asm.instr inside { CSRRW, CSRRS, CSRRC }) begin - asm.rd.gpr = instr.uncompressed.format.i.rd.gpr; - asm.rs1.gpr = instr.uncompressed.format.i.rs1.gpr; - asm.csr.address = instr.uncompressed.format.i.imm; - asm.rd.valid = 1; - asm.rs1.valid = 1; - asm.csr.valid = 1; + asm.rd.gpr = instr.uncompressed.format.i.rd.gpr; + asm.rs1.gpr = instr.uncompressed.format.i.rs1.gpr; + asm.csr.address = instr.uncompressed.format.i.imm; + asm.rd.valid = 1; + asm.rs1.valid = 1; + asm.csr.valid = 1; end else if (asm.instr inside { CSRRWI, CSRRSI, CSRRCI }) begin asm.rd.gpr = instr.uncompressed.format.i.rd.gpr; asm.imm.imm_raw = instr.uncompressed.format.i.rs1; @@ -350,109 +367,109 @@ end end J_TYPE: begin - asm.rd.gpr = instr.uncompressed.format.j.rd.gpr; - asm.imm.imm_raw = instr.uncompressed.format.j.imm; - asm.imm.imm_raw_sorted = get_sort_j_imm(instr); - asm.imm.imm_type = OFFSET; - asm.imm.width = 20; - asm.imm.sign_ext = 1; - asm.imm.imm_value = get_imm_value_j(get_sort_j_imm(instr)); - asm.rd.valid = 1; - asm.imm.valid = 1; + asm.rd.gpr = instr.uncompressed.format.j.rd.gpr; + asm.imm.imm_raw = instr.uncompressed.format.j.imm; + asm.imm.imm_raw_sorted = get_sort_j_imm(instr); + asm.imm.imm_type = OFFSET; + asm.imm.width = 20; + asm.imm.sign_ext = 1; + asm.imm.imm_value = get_imm_value_j(get_sort_j_imm(instr)); + asm.rd.valid = 1; + asm.imm.valid = 1; end S_TYPE: begin - asm.rs1.gpr = instr.uncompressed.format.s.rs1.gpr; - asm.rs2.gpr = instr.uncompressed.format.s.rs2.gpr; - asm.imm.imm_raw = get_sort_s_imm(instr); - asm.imm.imm_raw_sorted = get_sort_s_imm(instr); - asm.imm.imm_type = IMM; - asm.imm.width = 12; - asm.imm.sign_ext = 1; - asm.imm.imm_value = get_imm_value_i(get_sort_s_imm(instr)); - asm.rs1.valid = 1; - asm.rs2.valid = 1; - asm.imm.valid = 1; + asm.rs1.gpr = instr.uncompressed.format.s.rs1.gpr; + asm.rs2.gpr = instr.uncompressed.format.s.rs2.gpr; + asm.imm.imm_raw = get_sort_s_imm(instr); + asm.imm.imm_raw_sorted = get_sort_s_imm(instr); + asm.imm.imm_type = IMM; + asm.imm.width = 12; + asm.imm.sign_ext = 1; + asm.imm.imm_value = get_imm_value_i(get_sort_s_imm(instr)); + asm.rs1.valid = 1; + asm.rs2.valid = 1; + asm.imm.valid = 1; end R_TYPE: begin if ( asm.instr inside { LR_W, SC_W, AMOSWAP_W, AMOADD_W, AMOXOR_W, AMOAND_W, AMOOR_W, AMOMIN_W, AMOMAX_W, AMOMINU_W, AMOMAXU_W } ) begin - asm.rd.gpr = instr.uncompressed.format.r.rd.gpr; - asm.rs1.gpr = instr.uncompressed.format.r.rs1.gpr; - asm.rs2.gpr = instr.uncompressed.format.r.rs2.gpr; - asm.atomic.aq = instr.uncompressed.format.r.funct7[26]; - asm.atomic.rl = instr.uncompressed.format.r.funct7[25]; - asm.rd.valid = 1; - asm.rs1.valid = 1; - asm.rs2.valid = 1; - asm.atomic.valid = 1; + asm.rd.gpr = instr.uncompressed.format.r.rd.gpr; + asm.rs1.gpr = instr.uncompressed.format.r.rs1.gpr; + asm.rs2.gpr = instr.uncompressed.format.r.rs2.gpr; + asm.atomic.aq = instr.uncompressed.format.r.funct7[26]; + asm.atomic.rl = instr.uncompressed.format.r.funct7[25]; + asm.rd.valid = 1; + asm.rs1.valid = 1; + asm.rs2.valid = 1; + asm.atomic.valid = 1; end else begin - asm.rd.gpr = instr.uncompressed.format.r.rd.gpr; - asm.rs1.gpr = instr.uncompressed.format.r.rs1.gpr; - asm.rs2.gpr = instr.uncompressed.format.r.rs2.gpr; - asm.rd.valid = 1; - asm.rs1.valid = 1; - asm.rs2.valid = 1; + asm.rd.gpr = instr.uncompressed.format.r.rd.gpr; + asm.rs1.gpr = instr.uncompressed.format.r.rs1.gpr; + asm.rs2.gpr = instr.uncompressed.format.r.rs2.gpr; + asm.rd.valid = 1; + asm.rs1.valid = 1; + asm.rs2.valid = 1; end end R4_TYPE: begin - asm.rd.gpr = instr.uncompressed.format.r4.rd.gpr; - asm.rs1.gpr = instr.uncompressed.format.r4.rs1.gpr; - asm.rs2.gpr = instr.uncompressed.format.r4.rs2.gpr; - asm.rs3.gpr = instr.uncompressed.format.r4.rs3.gpr; - asm.rd.valid = 1; - asm.rs1.valid = 1; - asm.rs2.valid = 1; - asm.rs3.valid = 1; + asm.rd.gpr = instr.uncompressed.format.r4.rd.gpr; + asm.rs1.gpr = instr.uncompressed.format.r4.rs1.gpr; + asm.rs2.gpr = instr.uncompressed.format.r4.rs2.gpr; + asm.rs3.gpr = instr.uncompressed.format.r4.rs3.gpr; + asm.rd.valid = 1; + asm.rs1.valid = 1; + asm.rs2.valid = 1; + asm.rs3.valid = 1; end B_TYPE: begin - asm.rs1.gpr = instr.uncompressed.format.b.rs1.gpr; - asm.rs2.gpr = instr.uncompressed.format.b.rs2.gpr; - asm.imm.imm_raw = {instr.uncompressed.format.b.imm_h, instr.uncompressed.format.b.imm_l}; - asm.imm.imm_raw_sorted = get_sort_b_imm(instr); - asm.imm.imm_type = IMM; - asm.imm.width = 12; - asm.imm.sign_ext = 1; - asm.imm.imm_value = get_imm_value_b(get_sort_b_imm(instr)); - asm.rs1.valid = 1; - asm.rs2.valid = 1; - asm.imm.valid = 1; + asm.rs1.gpr = instr.uncompressed.format.b.rs1.gpr; + asm.rs2.gpr = instr.uncompressed.format.b.rs2.gpr; + asm.imm.imm_raw = {instr.uncompressed.format.b.imm_h, instr.uncompressed.format.b.imm_l}; + asm.imm.imm_raw_sorted = get_sort_b_imm(instr); + asm.imm.imm_type = IMM; + asm.imm.width = 12; + asm.imm.sign_ext = 1; + asm.imm.imm_value = get_imm_value_b(get_sort_b_imm(instr)); + asm.rs1.valid = 1; + asm.rs2.valid = 1; + asm.imm.valid = 1; end U_TYPE: begin - asm.rd.gpr = instr.uncompressed.format.u.rd.gpr; - asm.imm.imm_raw = instr.uncompressed.format.u.imm; - asm.imm.imm_raw_sorted = instr.uncompressed.format.u.imm; - asm.imm.imm_type = IMM; - asm.imm.width = 20; - asm.imm.imm_value = { instr.uncompressed.format.u.imm, 12'b0000_0000_0000 }; - asm.rd.valid = 1; - asm.imm.valid = 1; + asm.rd.gpr = instr.uncompressed.format.u.rd.gpr; + asm.imm.imm_raw = instr.uncompressed.format.u.imm; + asm.imm.imm_raw_sorted = instr.uncompressed.format.u.imm; + asm.imm.imm_type = IMM; + asm.imm.width = 20; + asm.imm.imm_value = { instr.uncompressed.format.u.imm, 12'b0000_0000_0000 }; + asm.rd.valid = 1; + asm.imm.valid = 1; end // Compressed CR_TYPE: begin if (name inside { C_EBREAK }) begin - asm.rd.valid = 0; - asm.rs1.valid = 0; - asm.rs2.valid = 0; - asm.rs3.valid = 0; - asm.imm.valid = 0; + asm.rd.valid = 0; + asm.rs1.valid = 0; + asm.rs2.valid = 0; + asm.rs3.valid = 0; + asm.imm.valid = 0; end else if (name inside { C_MV }) begin - asm.rd.gpr = instr.compressed.format.cr.rd_rs1.gpr; - asm.rs1.gpr = instr.compressed.format.cr.rd_rs1.gpr; - asm.rs2.gpr = instr.compressed.format.cr.rs2.gpr; - asm.rd.valid = 1; - asm.rs2.valid = 1; - asm.rs1.valid = 1; + asm.rd.gpr = instr.compressed.format.cr.rd_rs1.gpr; + asm.rs1.gpr = instr.compressed.format.cr.rd_rs1.gpr; + asm.rs2.gpr = instr.compressed.format.cr.rs2.gpr; + asm.rd.valid = 1; + asm.rs2.valid = 1; + asm.rs1.valid = 1; end else if (name inside { C_ADD }) begin - asm.rd.gpr = instr.compressed.format.cr.rd_rs1.gpr; - asm.rs1.gpr = instr.compressed.format.cr.rd_rs1.gpr; - asm.rs2.gpr = instr.compressed.format.cr.rs2.gpr; - asm.rd.valid = 1; - asm.rs1.valid = 1; - asm.rs2.valid = 1; + asm.rd.gpr = instr.compressed.format.cr.rd_rs1.gpr; + asm.rs1.gpr = instr.compressed.format.cr.rd_rs1.gpr; + asm.rs2.gpr = instr.compressed.format.cr.rs2.gpr; + asm.rd.valid = 1; + asm.rs1.valid = 1; + asm.rs2.valid = 1; end else if (name inside { C_JR, C_JALR }) begin - asm.rs1.gpr = instr.compressed.format.cr.rd_rs1.gpr; - asm.rs2.gpr = instr.compressed.format.cr.rs2.gpr; - asm.rs1.valid = 1; - asm.rs2.valid = 1; + asm.rs1.gpr = instr.compressed.format.cr.rd_rs1.gpr; + asm.rs2.gpr = instr.compressed.format.cr.rs2.gpr; + asm.rs1.valid = 1; + asm.rs2.valid = 1; end end CI_TYPE: begin @@ -468,7 +485,7 @@ asm.rd.valid = 1; asm.rs1.valid = 1; asm.imm.valid = 1; - end else if (name == C_LI) begin + end else if (name == C_LI) begin asm.rd.gpr = instr.compressed.format.ci.rd_rs1.gpr; asm.imm.imm_raw = { instr.compressed.format.ci.imm_12, instr.compressed.format.ci.imm_6_2 }; asm.imm.imm_raw_sorted = { instr.compressed.format.ci.imm_12, instr.compressed.format.ci.imm_6_2 }; @@ -478,7 +495,7 @@ asm.imm.imm_value = get_imm_value_ci({ instr.compressed.format.ci.imm_12, instr.compressed.format.ci.imm_6_2 }); asm.rd.valid = 1; asm.imm.valid = 1; - end else if (name == C_LUI) begin + end else if (name == C_LUI) begin asm.rd.gpr = instr.compressed.format.ci.rd_rs1.gpr; asm.imm.imm_raw = { instr.compressed.format.ci.imm_12, instr.compressed.format.ci.imm_6_2 }; asm.imm.imm_raw_sorted = { instr.compressed.format.ci.imm_12, instr.compressed.format.ci.imm_6_2 }; @@ -523,71 +540,92 @@ end end CSS_TYPE: begin - asm.rs2.gpr = instr.compressed.format.css.rs2.gpr; - asm.imm.imm_raw = instr.compressed.format.css.imm; - asm.imm.imm_raw_sorted = { instr.compressed.format.css.imm[9:7], instr.compressed.format.css.imm[12:10] }; - asm.imm.imm_type = OFFSET; - asm.imm.width = 6; - asm.imm.imm_value = { 24'b0, instr.compressed.format.css.imm[9:7], instr.compressed.format.css.imm[12:10], 2'b0 }; - asm.rs2.valid = 1; - asm.imm.valid = 1; + asm.rs2.gpr = instr.compressed.format.css.rs2.gpr; + asm.imm.imm_raw = instr.compressed.format.css.imm; + asm.imm.imm_raw_sorted = { instr.compressed.format.css.imm[9:7], instr.compressed.format.css.imm[12:10] }; + asm.imm.imm_type = OFFSET; + asm.imm.width = 6; + asm.imm.imm_value = { 24'b0, instr.compressed.format.css.imm[9:7], instr.compressed.format.css.imm[12:10], 2'b0 }; + asm.rs2.valid = 1; + asm.imm.valid = 1; end CIW_TYPE: begin - asm.rd.gpr = instr.compressed.format.ciw.rd.gpr; - asm.imm.imm_raw = instr.compressed.format.ciw.imm; - asm.imm.imm_raw_sorted = get_sort_ciw_imm(instr); - asm.imm.imm_type = NZUIMM; - asm.imm.width = 8; - asm.imm.imm_value = { 22'b0, get_sort_ciw_imm(instr), 2'b0 }; - asm.imm.valid = 1; - asm.rd.valid = 1; + asm.rd.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.ciw.rd.gpr); + asm.rd.gpr_rvc = instr.compressed.format.ciw.rd.gpr; + asm.imm.imm_raw = instr.compressed.format.ciw.imm; + asm.imm.imm_raw_sorted = get_sort_ciw_imm(instr); + asm.imm.imm_type = NZUIMM; + asm.imm.width = 8; + asm.imm.imm_value = { 22'b0, get_sort_ciw_imm(instr), 2'b0 }; + asm.imm.valid = 1; + asm.rd.valid = 1; + asm.rd.valid_gpr_rvc = 1; end CL_TYPE: begin - asm.rd.gpr = instr.compressed.format.cl.rd.gpr; - asm.rs1.gpr = instr.compressed.format.cl.rs1.gpr; - asm.imm.imm_raw = { instr.compressed.format.cl.imm_12_10, instr.compressed.format.cl.imm_6_5 }; - asm.imm.imm_raw_sorted = get_sort_cl_imm(instr); - asm.imm.imm_type = OFFSET; - asm.imm.width = 5; - asm.imm.imm_value = { 25'b0, get_sort_cl_imm(instr), 2'b0 }; - asm.rd.valid = 1; - asm.rs1.valid = 1; - asm.imm.valid = 1; + asm.rd.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.cl.rd.gpr); + asm.rd.gpr_rvc = instr.compressed.format.cl.rd.gpr; + asm.rs1.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.cl.rs1.gpr); + asm.rs1.gpr_rvc = instr.compressed.format.cl.rs1.gpr; + asm.imm.imm_raw = { instr.compressed.format.cl.imm_12_10, instr.compressed.format.cl.imm_6_5 }; + asm.imm.imm_raw_sorted = get_sort_cl_imm(instr); + asm.imm.imm_type = OFFSET; + asm.imm.width = 5; + asm.imm.imm_value = { 25'b0, get_sort_cl_imm(instr), 2'b0 }; + asm.rd.valid = 1; + asm.rd.valid_gpr_rvc = 1; + asm.rs1.valid = 1; + asm.rs1.valid_gpr_rvc = 1; + asm.imm.valid = 1; end CS_TYPE: begin - asm.rs2.gpr = instr.compressed.format.cs.rs2.gpr; - asm.rs1.gpr = instr.compressed.format.cs.rs1.gpr; - asm.imm.imm_raw = { instr.compressed.format.cs.imm_12_10, instr.compressed.format.cs.imm_6_5 }; - asm.imm.imm_raw_sorted = get_sort_cs_imm(instr); - asm.imm.imm_type = OFFSET; - asm.imm.width = 5; - asm.imm.imm_value = { 25'b0, get_sort_cs_imm(instr), 2'b0 }; - asm.rs2.valid = 1; - asm.rs1.valid = 1; - asm.imm.valid = 1; + asm.rs2.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.cs.rs2.gpr); + asm.rs2.gpr_rvc = instr.compressed.format.cs.rs2.gpr; + asm.rs1.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.cs.rs1.gpr); + asm.rs1.gpr_rvc = instr.compressed.format.cs.rs1.gpr; + asm.imm.imm_raw = { instr.compressed.format.cs.imm_12_10, instr.compressed.format.cs.imm_6_5 }; + asm.imm.imm_raw_sorted = get_sort_cs_imm(instr); + asm.imm.imm_type = OFFSET; + asm.imm.width = 5; + asm.imm.imm_value = { 25'b0, get_sort_cs_imm(instr), 2'b0 }; + asm.rs2.valid = 1; + asm.rs2.valid_gpr_rvc = 1; + asm.rs1.valid = 1; + asm.rs1.valid_gpr_rvc = 1; + asm.imm.valid = 1; end CA_TYPE: begin - asm.rd.gpr = instr.compressed.format.ca.rd_rs1.gpr; - asm.rs1.gpr = instr.compressed.format.ca.rd_rs1.gpr; - asm.rs2.gpr = instr.compressed.format.ca.rs2.gpr; - asm.rd.valid = 1; - asm.rs1.valid = 1; - asm.rs2.valid = 1; + asm.rd.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.ca.rd_rs1.gpr); + asm.rd.gpr_rvc = instr.compressed.format.ca.rd_rs1.gpr; + asm.rs1.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.ca.rd_rs1.gpr); + asm.rs1.gpr_rvc = instr.compressed.format.ca.rd_rs1.gpr; + asm.rs2.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.ca.rs2.gpr); + asm.rs2.gpr_rvc = instr.compressed.format.ca.rs2.gpr; + asm.rd.valid = 1; + asm.rd.valid_gpr_rvc = 1; + asm.rs1.valid = 1; + asm.rs1.valid_gpr_rvc = 1; + asm.rs2.valid = 1; + asm.rs2.valid_gpr_rvc = 1; end CB_TYPE: begin if (name inside { C_SRLI, C_SRAI }) begin - asm.rd.gpr = instr.compressed.format.cb.rd_rs1.gpr; - asm.rs1.gpr = instr.compressed.format.cb.rd_rs1.gpr; + asm.rd.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.cb.rd_rs1.gpr); + asm.rd.gpr_rvc = instr.compressed.format.cb.rd_rs1.gpr; + asm.rs1.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.cb.rd_rs1.gpr); + asm.rs1.gpr_rvc = instr.compressed.format.cb.rd_rs1.gpr; asm.imm.imm_raw = { instr.compressed.format.cb.offset_12_10[12], instr.compressed.format.cb.offset_6_2 }; asm.imm.imm_raw_sorted = { instr.compressed.format.cb.offset_12_10[12], instr.compressed.format.cb.offset_6_2 }; asm.imm.imm_type = SHAMT; asm.imm.width = 6; asm.imm.imm_value = { instr.compressed.format.cb.offset_12_10[12], instr.compressed.format.cb.offset_6_2 }; asm.rd.valid = 1; + asm.rd.valid_gpr_rvc = 1; asm.rs1.valid = 1; + asm.rs1.valid_gpr_rvc = 1; asm.imm.valid = 1; end else if (name inside { C_BEQZ, C_BNEZ }) begin - asm.rs1.gpr = instr.compressed.format.cb.rd_rs1.gpr; + asm.rs1.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.cb.rd_rs1.gpr); + asm.rs1.gpr_rvc = instr.compressed.format.cb.rd_rs1.gpr; asm.imm.imm_raw = { instr.compressed.format.cb.offset_12_10, instr.compressed.format.cb.offset_6_2 }; asm.imm.imm_raw_sorted = get_sort_cb_imm_not_sequential(instr); asm.imm.imm_type = OFFSET; @@ -595,100 +633,125 @@ asm.imm.sign_ext = 1; asm.imm.imm_value = get_imm_value_cb(get_sort_cb_imm_not_sequential(instr)); asm.rs1.valid = 1; + asm.rs1.valid_gpr_rvc = 1; asm.imm.valid = 1; end end CJ_TYPE: begin - asm.imm.imm_raw = instr.compressed.format.cj.imm; - asm.imm.imm_raw_sorted = get_sort_cj_imm(instr); - asm.imm.imm_type = OFFSET; - asm.imm.width = 11; - asm.imm.sign_ext = 1; - asm.imm.imm_value = get_imm_value_cj(get_sort_cj_imm(instr)); - asm.imm.valid = 1; + asm.imm.imm_raw = instr.compressed.format.cj.imm; + asm.imm.imm_raw_sorted = get_sort_cj_imm(instr); + asm.imm.imm_type = OFFSET; + asm.imm.width = 11; + asm.imm.sign_ext = 1; + asm.imm.imm_value = get_imm_value_cj(get_sort_cj_imm(instr)); + asm.imm.valid = 1; end CLB_TYPE: begin - asm.imm.imm_raw = instr.compressed.format.clb.uimm; - asm.imm.imm_raw_sorted = { instr.compressed.format.clb.uimm[5], instr.compressed.format.clb.uimm[6] }; - asm.imm.imm_type = UIMM; - asm.imm.width = 2; - asm.imm.imm_value = { instr.compressed.format.clb.uimm[5], instr.compressed.format.clb.uimm[6] }; - asm.rs1.gpr = instr.compressed.format.clb.rs1.gpr; - asm.rd.gpr = instr.compressed.format.clb.rd.gpr; - asm.rs1.valid = 1; - asm.rd.valid = 1; - asm.imm.valid = 1; + asm.imm.imm_raw = instr.compressed.format.clb.uimm; + asm.imm.imm_raw_sorted = { instr.compressed.format.clb.uimm[5], instr.compressed.format.clb.uimm[6] }; + asm.imm.imm_type = UIMM; + asm.imm.width = 2; + asm.imm.imm_value = { instr.compressed.format.clb.uimm[5], instr.compressed.format.clb.uimm[6] }; + asm.rs1.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.clb.rs1.gpr); + asm.rs1.gpr_rvc = instr.compressed.format.clb.rs1.gpr; + asm.rd.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.clb.rd.gpr); + asm.rd.gpr_rvc = instr.compressed.format.clb.rd.gpr; + asm.rs1.valid = 1; + asm.rs1.valid_gpr_rvc = 1; + asm.rd.valid = 1; + asm.rd.valid_gpr_rvc = 1; + asm.imm.valid = 1; end CSB_TYPE: begin - asm.imm.imm_raw = instr.compressed.format.csb.uimm; - asm.imm.imm_raw_sorted = { instr.compressed.format.csb.uimm[5], instr.compressed.format.csb.uimm[6] }; - asm.imm.imm_type = UIMM; - asm.imm.width = 2; - asm.imm.imm_value = { instr.compressed.format.csb.uimm[5], instr.compressed.format.csb.uimm[6] }; - asm.rs1.gpr = instr.compressed.format.csb.rs1.gpr; - asm.rs2.gpr = instr.compressed.format.csb.rs2.gpr; - asm.rs1.valid = 1; - asm.rs2.valid = 1; - asm.imm.valid = 1; + asm.imm.imm_raw = instr.compressed.format.csb.uimm; + asm.imm.imm_raw_sorted = { instr.compressed.format.csb.uimm[5], instr.compressed.format.csb.uimm[6] }; + asm.imm.imm_type = UIMM; + asm.imm.width = 2; + asm.imm.imm_value = { instr.compressed.format.csb.uimm[5], instr.compressed.format.csb.uimm[6] }; + asm.rs1.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.csb.rs1.gpr); + asm.rs1.gpr_rvc = instr.compressed.format.csb.rs1.gpr; + asm.rs2.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.csb.rs2.gpr); + asm.rs2.gpr_rvc = instr.compressed.format.csb.rs2.gpr; + asm.rs1.valid = 1; + asm.rs1.valid_gpr_rvc = 1; + asm.rs2.valid = 1; + asm.rs2.valid_gpr_rvc = 1; + asm.imm.valid = 1; end CLH_TYPE: begin - asm.imm.imm_raw = instr.compressed.format.clh.uimm; - asm.imm.imm_raw_sorted = instr.compressed.format.clh.uimm; - asm.imm.imm_type = UIMM; - asm.imm.width = 1; - asm.imm.imm_value = { 30'b0, instr.compressed.format.clh.uimm }; - asm.rs1.gpr = instr.compressed.format.clh.rs1.gpr; - asm.rd.gpr = instr.compressed.format.clh.rd.gpr; - asm.rs1.valid = 1; - asm.rd.valid = 1; - asm.imm.valid = 1; + asm.imm.imm_raw = instr.compressed.format.clh.uimm; + asm.imm.imm_raw_sorted = instr.compressed.format.clh.uimm; + asm.imm.imm_type = UIMM; + asm.imm.width = 1; + asm.imm.imm_value = { 30'b0, instr.compressed.format.clh.uimm }; + asm.rs1.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.clh.rs1.gpr); + asm.rs1.gpr_rvc = instr.compressed.format.clh.rs1.gpr; + asm.rd.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.clh.rd.gpr); + asm.rd.gpr_rvc = instr.compressed.format.clh.rd.gpr; + asm.rs1.valid = 1; + asm.rs1.valid_gpr_rvc = 1; + asm.rd.valid = 1; + asm.rd.valid_gpr_rvc = 1; + asm.imm.valid = 1; end CSH_TYPE: begin - asm.imm.imm_raw = instr.compressed.format.csh.uimm; - asm.imm.imm_raw_sorted = instr.compressed.format.csh.uimm; - asm.imm.imm_type = UIMM; - asm.imm.width = 1; - asm.imm.imm_value = {30'b0, instr.compressed.format.csh.uimm, 1'b0}; - asm.rs1.gpr = instr.compressed.format.csh.rs1.gpr; - asm.rs2.gpr = instr.compressed.format.csh.rs2.gpr; - asm.rs1.valid = 1; - asm.rs2.valid = 1; - asm.imm.valid = 1; + asm.imm.imm_raw = instr.compressed.format.csh.uimm; + asm.imm.imm_raw_sorted = instr.compressed.format.csh.uimm; + asm.imm.imm_type = UIMM; + asm.imm.width = 1; + asm.imm.imm_value = {30'b0, instr.compressed.format.csh.uimm, 1'b0}; + asm.rs1.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.csh.rs1.gpr); + asm.rs1.gpr_rvc = instr.compressed.format.csh.rs1.gpr; + asm.rs2.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.csh.rs2.gpr); + asm.rs2.gpr_rvc = instr.compressed.format.csh.rs2.gpr; + asm.rs1.valid = 1; + asm.rs1.valid_gpr_rvc = 1; + asm.rs2.valid = 1; + asm.rs2.valid_gpr_rvc = 1; + asm.imm.valid = 1; end CU_TYPE: begin - asm.rs1.gpr = instr.compressed.format.cu.rd_rs1.gpr; - asm.rd.gpr = instr.compressed.format.cu.rd_rs1.gpr; - asm.rs1.valid = 1; - asm.rd.valid = 1; + asm.rs1.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.cu.rd_rs1.gpr); + asm.rs1.gpr_rvc = instr.compressed.format.cu.rd_rs1.gpr; + asm.rd.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.cu.rd_rs1.gpr); + asm.rd.gpr_rvc = instr.compressed.format.cu.rd_rs1.gpr; + asm.rs1.valid = 1; + asm.rs1.valid_gpr_rvc = 1; + asm.rd.valid = 1; + asm.rd.valid_gpr_rvc = 1; end CMMV_TYPE: begin - asm.rs1.gpr = instr.compressed.format.cmmv.r1s.gpr; - asm.rs2.gpr = instr.compressed.format.cmmv.r2s.gpr; - asm.rs1.valid = 1; - asm.rs2.valid = 1; + asm.rs1.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.cmmv.r1s.gpr); + asm.rs1.gpr_rvc = instr.compressed.format.cmmv.r1s.gpr; + asm.rs2.gpr = get_gpr_from_gpr_rvc(instr.compressed.format.cmmv.r2s.gpr); + asm.rs2.gpr_rvc = instr.compressed.format.cmmv.r2s.gpr; + asm.rs1.valid = 1; + asm.rs1.valid_gpr_rvc = 1; + asm.rs2.valid = 1; + asm.rs2.valid_gpr_rvc = 1; end CMJT_TYPE: begin - asm.imm.imm_raw = instr.compressed.format.cmjt.index; - asm.imm.imm_raw_sorted = instr.compressed.format.cmjt.index; - asm.imm.imm_type = INDEX; - asm.imm.width = 1; - asm.imm.imm_value = instr.compressed.format.cmjt.index; - asm.imm.valid = 1; + asm.imm.imm_raw = instr.compressed.format.cmjt.index; + asm.imm.imm_raw_sorted = instr.compressed.format.cmjt.index; + asm.imm.imm_type = INDEX; + asm.imm.width = 1; + asm.imm.imm_value = instr.compressed.format.cmjt.index; + asm.imm.valid = 1; end CMPP_TYPE: begin - asm.imm.imm_raw = instr.compressed.format.cmpp.spimm; - asm.imm.imm_raw_sorted = instr.compressed.format.cmpp.spimm; - asm.imm.imm_type = SPIMM; - asm.imm.width = 1; - asm.rlist.rlist = instr.compressed.format.cmpp.urlist; - asm.stack_adj.stack_adj = get_stack_adj(instr.compressed.format.cmpp.urlist, instr.compressed.format.cmpp.spimm); - asm.imm.valid = 1; - asm.rs1.gpr = instr.compressed.format.csh.rs1.gpr; - asm.rs2.gpr = instr.compressed.format.csh.rs2.gpr; - asm.rs1.valid = 1; - asm.rs2.valid = 1; - asm.rlist.valid = 1; - asm.stack_adj.valid = 1; + asm.imm.imm_raw = instr.compressed.format.cmpp.spimm; + asm.imm.imm_raw_sorted = instr.compressed.format.cmpp.spimm; + asm.imm.imm_type = SPIMM; + asm.imm.width = 1; + asm.rlist.rlist = instr.compressed.format.cmpp.urlist; + asm.stack_adj.stack_adj = get_stack_adj(instr.compressed.format.cmpp.urlist, instr.compressed.format.cmpp.spimm); + asm.imm.valid = 1; + asm.rs1.gpr = instr.compressed.format.csh.rs1.gpr; + asm.rs2.gpr = instr.compressed.format.csh.rs2.gpr; + asm.rs1.valid = 1; + asm.rs2.valid = 1; + asm.rlist.valid = 1; + asm.stack_adj.valid = 1; end default : ; diff --git a/lib/isa_decoder/isa_typedefs.sv b/lib/isa_decoder/isa_typedefs.sv index 1a0a27b97e..374985c103 100644 --- a/lib/isa_decoder/isa_typedefs.sv +++ b/lib/isa_decoder/isa_typedefs.sv @@ -282,7 +282,7 @@ C_X13 = 3'b101, C_X14 = 3'b110, C_X15 = 3'b111 - } c_gpr_name_e; + } gpr_rvc_name_e; typedef enum logic [2:0] { C_S0 = 3'b000, @@ -293,13 +293,13 @@ C_A3 = 3'b101, C_A4 = 3'b110, C_A5 = 3'b111 - } c_gpr_abi_name_e; + } gpr_rvc_abi_name_e; typedef union packed { - bit [2:0] raw; - c_gpr_name_e gpr; - c_gpr_abi_name_e gpr_abi; - } c_gpr_t; + bit [2:0] raw; + gpr_rvc_name_e gpr; + gpr_rvc_abi_name_e gpr_abi; + } gpr_rvc_t; typedef union packed { bit [4:0] raw; @@ -668,42 +668,42 @@ typedef struct packed { logic[15:13] funct3; logic[12:7] imm; - gpr_t rs2; + gpr_t rs2; } css_type_t; typedef struct packed { logic[15:13] funct3; logic[12:5] imm; - c_gpr_t rd; + gpr_rvc_t rd; } ciw_type_t; typedef struct packed { logic[15:13] funct3; logic[12:10] imm_12_10; - c_gpr_t rs1; + gpr_rvc_t rs1; logic[6:5] imm_6_5; - c_gpr_t rd; + gpr_rvc_t rd; } cl_type_t; typedef struct packed { logic[15:13] funct3; logic[12:10] imm_12_10; - c_gpr_t rs1; + gpr_rvc_t rs1; logic[6:5] imm_6_5; - c_gpr_t rs2; + gpr_rvc_t rs2; } cs_type_t; typedef struct packed { logic[15:10] funct6; - c_gpr_t rd_rs1; + gpr_rvc_t rd_rs1; logic[6:5] funct2; - c_gpr_t rs2; + gpr_rvc_t rs2; } ca_type_t; typedef struct packed { logic[15:13] funct3; logic[12:10] offset_12_10; - c_gpr_t rd_rs1; + gpr_rvc_t rd_rs1; logic[6:2] offset_6_2; } cb_type_t; @@ -714,45 +714,45 @@ typedef struct packed { logic[15:10] funct6; - c_gpr_t rs1; + gpr_rvc_t rs1; logic[6:5] uimm; - c_gpr_t rd; + gpr_rvc_t rd; } clb_type_t; typedef struct packed { logic[15:10] funct6; - c_gpr_t rs1; + gpr_rvc_t rs1; logic[6:5] uimm; - c_gpr_t rs2; + gpr_rvc_t rs2; } csb_type_t; typedef struct packed { logic[15:10] funct6; - c_gpr_t rs1; + gpr_rvc_t rs1; logic funct1; logic uimm; - c_gpr_t rd; + gpr_rvc_t rd; } clh_type_t; typedef struct packed { logic[15:10] funct6; - c_gpr_t rs1; + gpr_rvc_t rs1; logic funct1; logic uimm; - c_gpr_t rs2; + gpr_rvc_t rs2; } csh_type_t; typedef struct packed { logic[15:10] funct6; - c_gpr_t rd_rs1; + gpr_rvc_t rd_rs1; logic[6:2] funct5; } cu_type_t; typedef struct packed { logic[15:10] funct6; - c_gpr_t r1s; + gpr_rvc_t r1s; logic[6:5] funct2; - c_gpr_t r2s; + gpr_rvc_t r2s; } cmmv_type_t; typedef struct packed { @@ -810,8 +810,10 @@ // and enumerated abi register names // --------------------------------------------------------------------------- typedef struct packed { - gpr_t gpr; - bit valid; + gpr_t gpr; + gpr_rvc_t gpr_rvc; + bit valid; + bit valid_gpr_rvc; } reg_operand_t; // --------------------------------------------------------------------------- @@ -919,16 +921,16 @@ // Main _decoded_ and _disassembled_ data structure // --------------------------------------------------------------------------- typedef struct packed { - instr_name_e instr; // Instruction name - instr_format_e format; // Instruction format type - reg_operand_t rd; // Destination register, qualified by rd.valid - reg_operand_t rs1; // source register 1, qualified by rs1.valid - reg_operand_t rs2; // -- 2, -- 2 - reg_operand_t rs3; // -- 3, -- 3 - imm_operand_t imm; // Immediate, qualified by imm.valid - csr_operand_t csr; // CSR register address, qualified by csr.valid - logic is_hint; // Indicates whether the current instruction is a HINT. - rlist_operand_t rlist; // structure to handle rlist fields for Zcmp-instructions + instr_name_e instr; // Instruction name + instr_format_e format; // Instruction format type + reg_operand_t rd; // Destination register, qualified by rd.valid + reg_operand_t rs1; // source register 1, qualified by rs1.valid + reg_operand_t rs2; // -- 2, -- 2 + reg_operand_t rs3; // -- 3, -- 3 + imm_operand_t imm; // Immediate, qualified by imm.valid + csr_operand_t csr; // CSR register address, qualified by csr.valid + logic is_hint; // Indicates whether the current instruction is a HINT. + rlist_operand_t rlist; // structure to handle rlist fields for Zcmp-instructions stack_adj_operand_t stack_adj; // structure to handle stack_adj fields for Zcmp-instructions atomic_operand_t atomic; } asm_t; diff --git a/lib/uvm_agents/uvma_isacov/uvma_isacov_mon.sv b/lib/uvm_agents/uvma_isacov/uvma_isacov_mon.sv index 42ed90a75d..96cb32af37 100644 --- a/lib/uvm_agents/uvma_isacov/uvma_isacov_mon.sv +++ b/lib/uvm_agents/uvma_isacov/uvma_isacov_mon.sv @@ -210,13 +210,19 @@ function void uvma_isacov_mon_c::write_rvfi_instr(uvma_rvfi_instr_seq_item_c#(IL end else if (cfg.decoder == ISA_SUPPORT) begin // Attempt to decode instruction with isa_support - mon_trn.instr.c_rdrs1 = instr_asm.rd.gpr; - mon_trn.instr.c_rdp = instr_asm.rd.gpr; - mon_trn.instr.c_rs1s = instr_asm.rs1.gpr; - mon_trn.instr.c_rs2s = instr_asm.rs2.gpr; - mon_trn.instr.rs1 = instr_asm.rs1.gpr; - mon_trn.instr.rs2 = instr_asm.rs2.gpr; - mon_trn.instr.rd = instr_asm.rd.gpr; + + // TODO: silabs-hefegran, isa decoder representation changed for compressed 'rx registers, + // we supply the old (non-translated) value to avoid having to rewrite that logic now, which + // might also interfere with the spike implementation. + // the "get_rx"-functions should no longer be needed if we supply the translated values to + // the coverage model. + mon_trn.instr.c_rdrs1 = instr_asm.rd.valid_gpr_rvc ? instr_asm.rd.gpr_rvc : instr_asm.rd.gpr; + mon_trn.instr.c_rdp = instr_asm.rd.valid_gpr_rvc ? instr_asm.rd.gpr_rvc : instr_asm.rd.gpr; + mon_trn.instr.c_rs1s = instr_asm.rs1.valid_gpr_rvc ? instr_asm.rs1.gpr_rvc : instr_asm.rs1.gpr; + mon_trn.instr.c_rs2s = instr_asm.rs2.valid_gpr_rvc ? instr_asm.rs2.gpr_rvc : instr_asm.rs2.gpr; + mon_trn.instr.rs1 = instr_asm.rs1.valid_gpr_rvc ? instr_asm.rs1.gpr_rvc : instr_asm.rs1.gpr; + mon_trn.instr.rs2 = instr_asm.rs2.valid_gpr_rvc ? instr_asm.rs2.gpr_rvc : instr_asm.rs1.gpr; + mon_trn.instr.rd = instr_asm.rd.valid_gpr_rvc ? instr_asm.rd.gpr_rvc : instr_asm.rd.gpr; mon_trn.instr.immi = instr_asm.imm.imm_raw_sorted; mon_trn.instr.imms = instr_asm.imm.imm_raw_sorted; mon_trn.instr.immb = instr_asm.imm.imm_raw_sorted;