Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better mstatus when FPU instruction #867

Merged
merged 3 commits into from
Sep 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions bhv/cv32e40p_rvfi.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -1111,6 +1101,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();
Expand Down
Loading