From 1f04df16afb0fdd7b6b2ba44694fc070685900d9 Mon Sep 17 00:00:00 2001 From: Henrik Fegran Date: Tue, 21 Nov 2023 10:33:51 +0100 Subject: [PATCH] Updated disassembler to handle sreg representation of compressed regs Signed-off-by: Henrik Fegran --- lib/isa_decoder/isa_decoder.sv | 793 +++++++++--------- lib/isa_decoder/isa_typedefs.sv | 52 +- lib/uvm_agents/uvma_isacov/uvma_isacov_mon.sv | 66 +- 3 files changed, 505 insertions(+), 406 deletions(-) diff --git a/lib/isa_decoder/isa_decoder.sv b/lib/isa_decoder/isa_decoder.sv index 1a0b0d593b..eb173dae71 100644 --- a/lib/isa_decoder/isa_decoder.sv +++ b/lib/isa_decoder/isa_decoder.sv @@ -136,6 +136,7 @@ function automatic 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; @@ -151,6 +152,24 @@ return uncompressed_gpr; endfunction : get_gpr_from_gpr_rvc + function automatic gpr_t get_gpr_from_gpr_rvc_sreg(gpr_rvc_sreg_t gpr); + gpr_t uncompressed_gpr; + + casex (gpr.gpr) + CS_X8: uncompressed_gpr.gpr = X8; + CS_X9: uncompressed_gpr.gpr = X9; + CS_X18: uncompressed_gpr.gpr = X18; + CS_X19: uncompressed_gpr.gpr = X19; + CS_X20: uncompressed_gpr.gpr = X20; + CS_X21: uncompressed_gpr.gpr = X21; + CS_X22: uncompressed_gpr.gpr = X22; + CS_X23: uncompressed_gpr.gpr = X23; + default: uncompressed_gpr.gpr = X0; // Function used wrong if we ever end up here + endcase + + return uncompressed_gpr; + endfunction : get_gpr_from_gpr_rvc_sreg + // --------------------------------------------------------------------------- // Find the value of immediate // --------------------------------------------------------------------------- @@ -311,463 +330,463 @@ 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; - asm.imm.imm_type = IMM; - asm.imm.width = 12; - asm.imm.sign_ext = 1; - asm.imm.imm_value = get_imm_value_i(instr.uncompressed.format.i.imm); - asm.imm.valid = 1; + asm.imm.imm_raw = instr.uncompressed.format.i.imm; + asm.imm.imm_raw_sorted = instr.uncompressed.format.i.imm; + asm.imm.imm_type = IMM; + asm.imm.width = 12; + asm.imm.sign_ext = 1; + 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; - asm.imm.imm_raw_sorted = instr.uncompressed.format.i.rs1; - asm.imm.imm_type = UIMM; - asm.imm.width = 5; - asm.imm.imm_value = instr.uncompressed.format.i.rs1; - asm.csr.address = instr.uncompressed.format.i.imm; - asm.rd.valid = 1; - asm.imm.valid = 1; - asm.csr.valid = 1; + asm.rd.gpr = instr.uncompressed.format.i.rd.gpr; + asm.imm.imm_raw = instr.uncompressed.format.i.rs1; + asm.imm.imm_raw_sorted = instr.uncompressed.format.i.rs1; + asm.imm.imm_type = UIMM; + asm.imm.width = 5; + asm.imm.imm_value = instr.uncompressed.format.i.rs1; + asm.csr.address = instr.uncompressed.format.i.imm; + asm.rd.valid = 1; + asm.imm.valid = 1; + asm.csr.valid = 1; end else if (asm.instr inside { RORI, BEXTI, BCLRI, BINVI, BSETI, SLLI, SRLI, SRAI }) begin - asm.rd.gpr = instr.uncompressed.format.i.rd.gpr; - asm.rs1.gpr = instr.uncompressed.format.i.rs1.gpr; - asm.imm.imm_raw = instr.uncompressed.format.i.imm.shamt; - asm.imm.imm_raw_sorted = instr.uncompressed.format.i.imm.shamt; - asm.imm.imm_type = SHAMT; - asm.imm.width = 5; - asm.imm.imm_value = instr.uncompressed.format.i.imm.shamt; - asm.rd.valid = 1; - asm.rs1.valid = 1; - asm.imm.valid = 1; + asm.rd.gpr = instr.uncompressed.format.i.rd.gpr; + asm.rs1.gpr = instr.uncompressed.format.i.rs1.gpr; + asm.imm.imm_raw = instr.uncompressed.format.i.imm.shamt; + asm.imm.imm_raw_sorted = instr.uncompressed.format.i.imm.shamt; + asm.imm.imm_type = SHAMT; + asm.imm.width = 5; + asm.imm.imm_value = instr.uncompressed.format.i.imm.shamt; + asm.rd.valid = 1; + asm.rs1.valid = 1; + asm.imm.valid = 1; end else begin - asm.rd.gpr = instr.uncompressed.format.i.rd.gpr; - asm.rs1.gpr = instr.uncompressed.format.i.rs1.gpr; - asm.imm.imm_raw = instr.uncompressed.format.i.imm; - asm.imm.imm_raw_sorted = instr.uncompressed.format.i.imm; - asm.imm.imm_type = IMM; - asm.imm.width = 12; - asm.imm.sign_ext = 1; - asm.imm.imm_value = get_imm_value_i(instr.uncompressed.format.i.imm); - asm.rd.valid = 1; - asm.rs1.valid = 1; - asm.imm.valid = 1; + asm.rd.gpr = instr.uncompressed.format.i.rd.gpr; + asm.rs1.gpr = instr.uncompressed.format.i.rs1.gpr; + asm.imm.imm_raw = instr.uncompressed.format.i.imm; + asm.imm.imm_raw_sorted = instr.uncompressed.format.i.imm; + asm.imm.imm_type = IMM; + asm.imm.width = 12; + asm.imm.sign_ext = 1; + asm.imm.imm_value = get_imm_value_i(instr.uncompressed.format.i.imm); + asm.rd.valid = 1; + asm.rs1.valid = 1; + asm.imm.valid = 1; 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 if (name inside { C_NOP, C_ADDI }) begin - asm.rd.gpr = instr.compressed.format.ci.rd_rs1.gpr; - asm.rs1.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 }; - asm.imm.imm_type = IMM; - asm.imm.width = 6; - asm.imm.sign_ext = 1; - 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.rs1.valid = 1; - asm.imm.valid = 1; - 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 }; - asm.imm.imm_type = IMM; - asm.imm.width = 6; - asm.imm.sign_ext = 1; - 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 - 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 }; - asm.imm.imm_type = NZIMM; - asm.imm.width = 6; - asm.imm.sign_ext = 1; - asm.imm.imm_value = get_imm_value_ci_lui({ instr.compressed.format.ci.imm_12, instr.compressed.format.ci.imm_6_2 }); - asm.rd.valid = 1; - asm.imm.valid = 1; + asm.rd.gpr = instr.compressed.format.ci.rd_rs1.gpr; + asm.rs1.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 }; + asm.imm.imm_type = IMM; + asm.imm.width = 6; + asm.imm.sign_ext = 1; + 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.rs1.valid = 1; + asm.imm.valid = 1; + 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 }; + asm.imm.imm_type = IMM; + asm.imm.width = 6; + asm.imm.sign_ext = 1; + 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 + 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 }; + asm.imm.imm_type = NZIMM; + asm.imm.width = 6; + asm.imm.sign_ext = 1; + asm.imm.imm_value = get_imm_value_ci_lui({ 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 inside { C_LWSP }) 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 = get_sort_ci_imm_lwsp(instr); - asm.imm.imm_type = OFFSET; - asm.imm.width = 6; - asm.imm.imm_value = {24'b0, get_sort_ci_imm_lwsp(instr), 2'b0}; - asm.rd.valid = 1; - asm.imm.valid = 1; + 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 = get_sort_ci_imm_lwsp(instr); + asm.imm.imm_type = OFFSET; + asm.imm.width = 6; + asm.imm.imm_value = {24'b0, get_sort_ci_imm_lwsp(instr), 2'b0}; + asm.rd.valid = 1; + asm.imm.valid = 1; end else if (name inside { C_ADDI16SP }) begin - asm.rs1.gpr = instr.compressed.format.ci.rd_rs1.gpr; - 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 = get_sort_ci_imm_addi16sp(instr); - asm.imm.imm_type = NZIMM; - asm.imm.width = 6; - asm.imm.sign_ext = 1; - asm.imm.imm_value = get_imm_value_ci_addi16sp(get_sort_ci_imm_addi16sp(instr)); - asm.rs1.valid = 1; - asm.rd.valid = 1; - asm.imm.valid = 1; + asm.rs1.gpr = instr.compressed.format.ci.rd_rs1.gpr; + 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 = get_sort_ci_imm_addi16sp(instr); + asm.imm.imm_type = NZIMM; + asm.imm.width = 6; + asm.imm.sign_ext = 1; + asm.imm.imm_value = get_imm_value_ci_addi16sp(get_sort_ci_imm_addi16sp(instr)); + asm.rs1.valid = 1; + asm.rd.valid = 1; + asm.imm.valid = 1; end else if (name inside { C_SLLI }) begin - asm.rs1.gpr = instr.compressed.format.ci.rd_rs1.gpr; - 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 }; - asm.imm.imm_type = SHAMT; - asm.imm.width = 6; - asm.imm.imm_value = { instr.compressed.format.ci.imm_12, instr.compressed.format.ci.imm_6_2 }; - asm.rs1.valid = 1; - asm.rd.valid = 1; - asm.imm.valid = 1; + asm.rs1.gpr = instr.compressed.format.ci.rd_rs1.gpr; + 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 }; + asm.imm.imm_type = SHAMT; + asm.imm.width = 6; + asm.imm.imm_value = { instr.compressed.format.ci.imm_12, instr.compressed.format.ci.imm_6_2 }; + asm.rs1.valid = 1; + asm.rd.valid = 1; + asm.imm.valid = 1; 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 = 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; + 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 = 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; + 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 = 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; + 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 = 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; + 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 = 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; + 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 = 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; - asm.imm.width = 8; - 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; + 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; + asm.imm.width = 8; + 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 else if (name inside { C_ANDI }) begin - 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 = IMM; - asm.imm.width = 6; - asm.imm.sign_ext = 1; - asm.imm.imm_value = get_imm_value_cb({ 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; + 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 = IMM; + asm.imm.width = 6; + asm.imm.sign_ext = 1; + asm.imm.imm_value = get_imm_value_cb({ 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 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 = 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; + 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 = 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; + 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 = 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; + 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 = 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; + 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 = 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; + 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 = 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; + asm.rs1.gpr = get_gpr_from_gpr_rvc_sreg(instr.compressed.format.cmmv.r1s.gpr); + asm.rs1.gpr_rvc_sreg = instr.compressed.format.cmmv.r1s.gpr; + asm.rs2.gpr = get_gpr_from_gpr_rvc_sreg(instr.compressed.format.cmmv.r2s.gpr); + asm.rs2.gpr_rvc_sreg = instr.compressed.format.cmmv.r2s.gpr; + asm.rs1.valid = 1; + asm.rs1.valid_gpr_rvc_sreg = 1; + asm.rs2.valid = 1; + asm.rs2.valid_gpr_rvc_sreg = 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 374985c103..416e705db9 100644 --- a/lib/isa_decoder/isa_typedefs.sv +++ b/lib/isa_decoder/isa_typedefs.sv @@ -295,12 +295,40 @@ C_A5 = 3'b111 } gpr_rvc_abi_name_e; + typedef enum logic [2:0] { + CS_X8 = 3'b000, + CS_X9 = 3'b001, + CS_X18 = 3'b010, + CS_X19 = 3'b011, + CS_X20 = 3'b100, + CS_X21 = 3'b101, + CS_X22 = 3'b110, + CS_X23 = 3'b111 + } gpr_rvc_sreg_name_e; + + typedef enum logic [2:0] { + CS_S0 = 3'b000, + CS_S1 = 3'b001, + CS_S2 = 3'b010, + CS_S3 = 3'b011, + CS_S4 = 3'b100, + CS_S5 = 3'b101, + CS_S6 = 3'b110, + CS_S7 = 3'b111 + } gpr_rvc_sreg_abi_name_e; + typedef union packed { bit [2:0] raw; gpr_rvc_name_e gpr; gpr_rvc_abi_name_e gpr_abi; } gpr_rvc_t; + typedef union packed { + bit [2:0] raw; + gpr_rvc_sreg_name_e gpr; + gpr_rvc_sreg_abi_name_e gpr_abi; + } gpr_rvc_sreg_t; + typedef union packed { bit [4:0] raw; gpr_name_e gpr; @@ -748,13 +776,6 @@ logic[6:2] funct5; } cu_type_t; - typedef struct packed { - logic[15:10] funct6; - gpr_rvc_t r1s; - logic[6:5] funct2; - gpr_rvc_t r2s; - } cmmv_type_t; - typedef struct packed { logic[15:10] funct6; logic[9:2] index; @@ -767,6 +788,13 @@ logic[5:4] spimm; } cmpp_type_t; + typedef struct packed { + logic[15:10] funct6; + gpr_rvc_sreg_t r1s; + logic[6:5] funct2; + gpr_rvc_sreg_t r2s; + } cmmv_type_t; + // Compressed instruction types typedef struct packed { logic [31:16] reserved_31_16; @@ -810,10 +838,12 @@ // and enumerated abi register names // --------------------------------------------------------------------------- typedef struct packed { - gpr_t gpr; - gpr_rvc_t gpr_rvc; - bit valid; - bit valid_gpr_rvc; + gpr_t gpr; + gpr_rvc_t gpr_rvc; + gpr_rvc_sreg_t gpr_rvc_sreg; + bit valid; + bit valid_gpr_rvc; + bit valid_gpr_rvc_sreg; } reg_operand_t; // --------------------------------------------------------------------------- diff --git a/lib/uvm_agents/uvma_isacov/uvma_isacov_mon.sv b/lib/uvm_agents/uvma_isacov/uvma_isacov_mon.sv index adf1842114..8a4a7a45d0 100644 --- a/lib/uvm_agents/uvma_isacov/uvma_isacov_mon.sv +++ b/lib/uvm_agents/uvma_isacov/uvma_isacov_mon.sv @@ -216,14 +216,64 @@ function void uvma_isacov_mon_c::write_rvfi_instr(uvma_rvfi_instr_seq_item_c#(IL // 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 ? ( instr_asm.rd.valid_gpr_rvc ? instr_asm.rd.gpr_rvc : instr_asm.rd.gpr ) - : ( instr_asm.rs1.valid_gpr_rvc ? instr_asm.rs1.gpr_rvc : instr_asm.rs1.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; + + if ( instr_asm.rd.valid ) begin + case (1) + instr_asm.rd.valid_gpr_rvc_sreg : begin + mon_trn.instr.c_rdrs1 = instr_asm.rd.gpr_rvc_sreg; + mon_trn.instr.c_rdp = instr_asm.rd.gpr_rvc_sreg; + mon_trn.instr.rd = instr_asm.rd.gpr_rvc_sreg; + end + instr_asm.rd.valid_gpr_rvc : begin + mon_trn.instr.c_rdrs1 = instr_asm.rd.gpr_rvc; + mon_trn.instr.c_rdp = instr_asm.rd.gpr_rvc; + mon_trn.instr.rd = instr_asm.rd.gpr_rvc; + end + default : begin + mon_trn.instr.c_rdrs1 = instr_asm.rd.gpr; + mon_trn.instr.c_rdp = instr_asm.rd.gpr; + mon_trn.instr.rd = instr_asm.rd.gpr; + end + endcase + end + + if ( instr_asm.rs1.valid ) begin + case (1) + instr_asm.rs1.valid_gpr_rvc_sreg : begin + mon_trn.instr.c_rdrs1 = instr_asm.rd.valid ? mon_trn.instr.c_rdrs1 : instr_asm.rs1.gpr_rvc_sreg; + mon_trn.instr.c_rs1s = instr_asm.rs1.gpr_rvc_sreg; + mon_trn.instr.rs1 = instr_asm.rs1.gpr_rvc_sreg; + end + instr_asm.rs1.valid_gpr_rvc : begin + mon_trn.instr.c_rdrs1 = instr_asm.rd.valid ? mon_trn.instr.c_rdrs1 : instr_asm.rs1.gpr_rvc; + mon_trn.instr.c_rs1s = instr_asm.rs1.gpr_rvc; + mon_trn.instr.rs1 = instr_asm.rs1.gpr_rvc; + end + default : begin + mon_trn.instr.c_rdrs1 = instr_asm.rd.valid ? mon_trn.instr.c_rdrs1 : instr_asm.rs1.gpr; + mon_trn.instr.c_rs1s = instr_asm.rs1.gpr; + mon_trn.instr.rs1 = instr_asm.rs1.gpr; + end + endcase + end + + if ( instr_asm.rs2.valid ) begin + case (1) + instr_asm.rs2.valid_gpr_rvc_sreg : begin + mon_trn.instr.c_rs2s = instr_asm.rs2.gpr_rvc_sreg; + mon_trn.instr.rs2 = instr_asm.rs2.gpr_rvc_sreg; + end + instr_asm.rs2.valid_gpr_rvc : begin + mon_trn.instr.c_rs2s = instr_asm.rs2.gpr_rvc; + mon_trn.instr.rs2 = instr_asm.rs2.gpr_rvc; + end + default : begin + mon_trn.instr.c_rs2s = instr_asm.rs2.gpr; + mon_trn.instr.rs2 = instr_asm.rs2.gpr; + end + endcase + end + 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;