Skip to content

Commit

Permalink
Fix instruction tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
ezelioli committed Jan 31, 2025
1 parent dd6b70f commit 9cec5dd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
32 changes: 18 additions & 14 deletions common/local/util/instr_tracer.sv
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ module instr_tracer #(
input logic rstn,
input logic flush_unissued,
input logic flush_all,
input logic [31:0] instruction,
input logic fetch_valid,
input logic fetch_ack,
input logic issue_ack, // issue acknowledged
input scoreboard_entry_t issue_sbe, // issue scoreboard entry
input logic [31:0] [CVA6Cfg.NrIssuePorts-1:0] instruction,
input logic [CVA6Cfg.NrIssuePorts-1:0] fetch_valid,
input logic [CVA6Cfg.NrIssuePorts-1:0] fetch_ack,
input logic [CVA6Cfg.NrIssuePorts-1:0] issue_ack, // issue acknowledged
input scoreboard_entry_t [CVA6Cfg.NrIssuePorts-1:0] issue_sbe, // issue scoreboard entry
input logic [1:0][4:0] waddr, // WB stage
input logic [1:0][63:0] wdata,
input logic [1:0] we_gpr,
Expand Down Expand Up @@ -94,7 +94,7 @@ module instr_tracer #(
forever begin
automatic bp_resolve_t bp_instruction = '0;
// new cycle, we are only interested if reset is de-asserted
@(pck) if (rstn !== 1'b1) begin
@(posedge pck) if (rstn !== 1'b1) begin
flush();
continue;
end
Expand All @@ -106,20 +106,24 @@ module instr_tracer #(
// Instruction Decode
// -------------------
// we are decoding an instruction
if (fetch_valid && fetch_ack) begin
decode_instruction = instruction;
decode_queue.push_back(decode_instruction);
for (int unsigned i = 0; i < CVA6Cfg.NrIssuePorts; ++i) begin
if (fetch_valid[i] && fetch_ack[i]) begin
decode_instruction = instruction[i];
decode_queue.push_back(decode_instruction);
end
end
// -------------------
// Instruction Issue
// -------------------
// we got a new issue ack, so put the element from the decode queue to
// the issue queue
if (issue_ack && !flush_unissued) begin
issue_instruction = decode_queue.pop_front();
issue_queue.push_back(issue_instruction);
// also save the scoreboard entry to a separate issue queue
issue_sbe_queue.push_back(scoreboard_entry_t'(issue_sbe));
for (int unsigned i = 0; i < CVA6Cfg.NrIssuePorts; ++i) begin
if (issue_ack[i] && !flush_unissued) begin
issue_instruction = decode_queue.pop_front();
issue_queue.push_back(issue_instruction);
// also save the scoreboard entry to a separate issue queue
issue_sbe_queue.push_back(scoreboard_entry_t'(issue_sbe[i]));
end
end

// --------------------
Expand Down
11 changes: 8 additions & 3 deletions core/cva6.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,11 @@ module cva6
`endif // PITON_ARIANE

`ifndef VERILATOR

logic [31:0] [CVA6Cfg.NrIssuePorts-1:0] fetch_instructions;
for(genvar i = 0; i < CVA6Cfg.NrIssuePorts; ++i) begin
assign fetch_instructions[i] = fetch_entry_if_id[i].instruction;
end
instr_tracer #(
.CVA6Cfg(CVA6Cfg),
.bp_resolve_t(bp_resolve_t),
Expand All @@ -1720,9 +1725,9 @@ module cva6
.rstn(rst_ni),
.flush_unissued(flush_unissued_instr_ctrl_id),
.flush_all(flush_ctrl_ex),
.instruction(id_stage_i.fetch_entry_i[0].instruction),
.fetch_valid(id_stage_i.fetch_entry_valid_i[0]),
.fetch_ack(id_stage_i.fetch_entry_ready_o[0]),
.instruction(fetch_instructions),
.fetch_valid(id_stage_i.fetch_entry_valid_i),
.fetch_ack(id_stage_i.fetch_entry_ready_o),
.issue_ack(issue_stage_i.i_scoreboard.issue_ack_i),
.issue_sbe(issue_stage_i.i_scoreboard.issue_instr_o),
.waddr(waddr_commit_id),
Expand Down

0 comments on commit 9cec5dd

Please sign in to comment.