From 9cec5dda60687631084c9ac0128f0f9b45a38a94 Mon Sep 17 00:00:00 2001 From: Enrico Zelioli Date: Sat, 1 Feb 2025 00:06:48 +0100 Subject: [PATCH] Fix instruction tracer --- common/local/util/instr_tracer.sv | 32 +++++++++++++++++-------------- core/cva6.sv | 11 ++++++++--- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/common/local/util/instr_tracer.sv b/common/local/util/instr_tracer.sv index 9083664069..a44686f0cd 100644 --- a/common/local/util/instr_tracer.sv +++ b/common/local/util/instr_tracer.sv @@ -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, @@ -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 @@ -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 // -------------------- diff --git a/core/cva6.sv b/core/cva6.sv index 511a8144de..6c08f2bd40 100644 --- a/core/cva6.sv +++ b/core/cva6.sv @@ -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), @@ -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),