From 54549c5cc1de5ea47410310f5ab04e25a1bfc54d Mon Sep 17 00:00:00 2001 From: Yoann Pruvost Date: Wed, 6 Sep 2023 12:45:01 +0800 Subject: [PATCH 1/3] Updating mstatus for out of order instruction when APU response --- bhv/cv32e40p_rvfi.sv | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bhv/cv32e40p_rvfi.sv b/bhv/cv32e40p_rvfi.sv index cd1cf6f75..bc12c4ec8 100644 --- a/bhv/cv32e40p_rvfi.sv +++ b/bhv/cv32e40p_rvfi.sv @@ -627,7 +627,7 @@ insn_trace_t trace_if, trace_id, trace_ex, trace_ex_next, trace_wb; function void empty_fifo(); integer i, trace_q_size; trace_q_size = wb_bypass_trace_q.size(); - if (trace_q_size > 40) begin + if (trace_q_size > 50) begin $fatal("Reorder queue too long\n"); end if (trace_q_size != 0) begin @@ -636,6 +636,7 @@ insn_trace_t trace_if, trace_id, trace_ex, trace_ex_next, trace_wb; new_rvfi_trace = new(); new_rvfi_trace.copy_full(wb_bypass_trace_q.pop_front()); if (next_send == new_rvfi_trace.m_order) begin + new_rvfi_trace.m_csr.mstatus_rdata = r_pipe_freeze_trace.csr.mstatus_full_n; rvfi_trace_q.push_back(new_rvfi_trace); next_send = next_send + 1; end else begin @@ -655,7 +656,6 @@ insn_trace_t trace_if, trace_id, trace_ex, trace_ex_next, trace_wb; if (next_send == new_rvfi_trace.m_order) begin rvfi_trace_q.push_back(new_rvfi_trace); next_send = next_send + 1; - // empty_fifo(); end else begin wb_bypass_trace_q.push_back(new_rvfi_trace); end @@ -706,11 +706,11 @@ insn_trace_t trace_if, trace_id, trace_ex, trace_ex_next, trace_wb; new_rvfi_trace.m_csr.fflags_rdata = s_fflags_mirror; new_rvfi_trace.m_csr.frm_rdata = s_frm_mirror; new_rvfi_trace.m_csr.fcsr_rdata = s_fcsr_mirror; - if (s_mstatus_sd_fs_mirror != 32'h0) begin - new_rvfi_trace.m_csr.mstatus_wdata = new_rvfi_trace.m_csr.mstatus_wdata | s_mstatus_sd_fs_mirror; - new_rvfi_trace.m_csr.mstatus_wmask = 32'hFFFF_FFFF; - s_mstatus_sd_fs_mirror = 32'h0; // Reset mirror - end + // if (s_mstatus_sd_fs_mirror != 32'h0) begin + // new_rvfi_trace.m_csr.mstatus_wdata = new_rvfi_trace.m_csr.mstatus_wdata | s_mstatus_sd_fs_mirror; + // new_rvfi_trace.m_csr.mstatus_wmask = 32'hFFFF_FFFF; + // s_mstatus_sd_fs_mirror = 32'h0; // Reset mirror + // end if (new_rvfi_trace.m_fflags_we_non_apu) begin s_fflags_mirror = new_rvfi_trace.m_csr.fflags_wdata; s_fcsr_mirror = new_rvfi_trace.m_csr.fcsr_wdata; @@ -1111,6 +1111,10 @@ insn_trace_t trace_if, trace_id, trace_ex, trace_ex_next, trace_wb; trace_apu_resp.m_csr.mstatus_rmask = '1; trace_apu_resp.m_csr.mstatus_wdata = r_pipe_freeze_trace.csr.mstatus_full_n; trace_apu_resp.m_csr.mstatus_wmask = r_pipe_freeze_trace.csr.mstatus_we ? '1 : '0; + + if(r_pipe_freeze_trace.csr.mstatus_we) begin + trace_ex.m_csr.mstatus_rdata = r_pipe_freeze_trace.csr.mstatus_full_n; + end endfunction function void csr_to_apu_req(); From 9787eaa794d34c7b6712a103ab61534c331c8807 Mon Sep 17 00:00:00 2001 From: Yoann Pruvost Date: Wed, 6 Sep 2023 12:47:27 +0800 Subject: [PATCH 2/3] Verible --- bhv/cv32e40p_rvfi.sv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bhv/cv32e40p_rvfi.sv b/bhv/cv32e40p_rvfi.sv index bc12c4ec8..ae32bb649 100644 --- a/bhv/cv32e40p_rvfi.sv +++ b/bhv/cv32e40p_rvfi.sv @@ -1112,8 +1112,8 @@ insn_trace_t trace_if, trace_id, trace_ex, trace_ex_next, trace_wb; trace_apu_resp.m_csr.mstatus_wdata = r_pipe_freeze_trace.csr.mstatus_full_n; trace_apu_resp.m_csr.mstatus_wmask = r_pipe_freeze_trace.csr.mstatus_we ? '1 : '0; - if(r_pipe_freeze_trace.csr.mstatus_we) begin - trace_ex.m_csr.mstatus_rdata = r_pipe_freeze_trace.csr.mstatus_full_n; + if (r_pipe_freeze_trace.csr.mstatus_we) begin + trace_ex.m_csr.mstatus_rdata = r_pipe_freeze_trace.csr.mstatus_full_n; end endfunction From d763271550c095d91147261c08bd49d9cecc7265 Mon Sep 17 00:00:00 2001 From: Yoann Pruvost Date: Wed, 6 Sep 2023 15:42:59 +0800 Subject: [PATCH 3/3] Removing unused code --- bhv/cv32e40p_rvfi.sv | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/bhv/cv32e40p_rvfi.sv b/bhv/cv32e40p_rvfi.sv index ae32bb649..b8fae0ff5 100644 --- a/bhv/cv32e40p_rvfi.sv +++ b/bhv/cv32e40p_rvfi.sv @@ -674,7 +674,6 @@ insn_trace_t trace_if, trace_id, trace_ex, trace_ex_next, trace_wb; logic [31:0] s_fflags_mirror; logic [31:0] s_frm_mirror; logic [31:0] s_fcsr_mirror; - logic [31:0] s_mstatus_sd_fs_mirror; function void set_rvfi(); insn_trace_t new_rvfi_trace; @@ -696,21 +695,12 @@ insn_trace_t trace_if, trace_id, trace_ex, trace_ex_next, trace_wb; end else begin s_fcsr_mirror = new_rvfi_trace.m_csr.fcsr_rdata; end - if (new_rvfi_trace.m_csr.mstatus_we) begin - s_mstatus_sd_fs_mirror = new_rvfi_trace.m_csr.mstatus_wdata & 32'h8000_6000; - end else begin - s_mstatus_sd_fs_mirror = new_rvfi_trace.m_csr.mstatus_rdata & 32'h8000_6000; - end end else begin new_rvfi_trace.m_csr.fflags_rdata = s_fflags_mirror; new_rvfi_trace.m_csr.frm_rdata = s_frm_mirror; new_rvfi_trace.m_csr.fcsr_rdata = s_fcsr_mirror; - // if (s_mstatus_sd_fs_mirror != 32'h0) begin - // new_rvfi_trace.m_csr.mstatus_wdata = new_rvfi_trace.m_csr.mstatus_wdata | s_mstatus_sd_fs_mirror; - // new_rvfi_trace.m_csr.mstatus_wmask = 32'hFFFF_FFFF; - // s_mstatus_sd_fs_mirror = 32'h0; // Reset mirror - // end + if (new_rvfi_trace.m_fflags_we_non_apu) begin s_fflags_mirror = new_rvfi_trace.m_csr.fflags_wdata; s_fcsr_mirror = new_rvfi_trace.m_csr.fcsr_wdata;