diff --git a/src/ariane.sv b/src/ariane.sv index 2d76b1a83..a7131cc45 100644 --- a/src/ariane.sv +++ b/src/ariane.sv @@ -553,6 +553,8 @@ module ariane assign tracer_if.ld_paddr = ex_stage_i.lsu_i.load_unit_i.paddr_i; // exceptions assign tracer_if.exception = commit_stage_i.exception_o; + // assign current privilege level + assign tracer_if.priv_lvl = priv_lvl; program instr_tracer (instruction_tracer_if tracer_if); instruction_tracer it = new (tracer_if, 1'b0); diff --git a/src/util/instruction_trace_item.svh b/src/util/instruction_trace_item.svh index 8505819cc..acae4119c 100755 --- a/src/util/instruction_trace_item.svh +++ b/src/util/instruction_trace_item.svh @@ -29,9 +29,10 @@ class instruction_trace_item; logic [63:0] imm; logic [63:0] result; logic [63:0] paddr; + string priv_lvl; // constructor creating a new instruction trace item, e.g.: a single instruction with all relevant information - function new (time simtime, longint unsigned cycle, scoreboard_entry sbe, logic [31:0] instr, logic [63:0] reg_file [32], logic [63:0] result, logic [63:0] paddr); + function new (time simtime, longint unsigned cycle, scoreboard_entry sbe, logic [31:0] instr, logic [63:0] reg_file [32], logic [63:0] result, logic [63:0] paddr, priv_lvl_t priv_lvl); this.simtime = simtime; this.cycle = cycle; this.pc = sbe.pc; @@ -40,6 +41,7 @@ class instruction_trace_item; this.reg_file = reg_file; this.result = result; this.paddr = paddr; + this.priv_lvl = getPrivLevel(priv_lvl); endfunction // convert register address to ABI compatible form function string regAddrToStr(logic [5:0] addr); @@ -183,8 +185,9 @@ class instruction_trace_item; endcase - s = $sformatf("%10t %10d %h %h %-36s", simtime, + s = $sformatf("%10t %10d %s %h %h %-36s", simtime, cycle, + priv_lvl, sbe.pc, instr, s); @@ -211,7 +214,16 @@ class instruction_trace_item; end endcase return s; - endfunction + endfunction : printInstr + + // Return the current privilege level as a string + function string getPrivLevel(input priv_lvl_t priv_lvl); + case (priv_lvl) + PRIV_LVL_M: return "M"; + PRIV_LVL_S: return "S"; + PRIV_LVL_U: return "U"; + endcase + endfunction : getPrivLevel function string printMnemonic(input string mnemonic); return mnemonic; diff --git a/src/util/instruction_tracer.svh b/src/util/instruction_tracer.svh index fc9792e15..b08679eae 100755 --- a/src/util/instruction_tracer.svh +++ b/src/util/instruction_tracer.svh @@ -117,9 +117,9 @@ class instruction_tracer; // check if the write back is valid, if not we need to source the result from the register file // as the most recent version of this register will be there. if (tracer_if.pck.we) begin - printInstr(issue_sbe, issue_commit_instruction, tracer_if.pck.wdata, address_mapping); + printInstr(issue_sbe, issue_commit_instruction, tracer_if.pck.wdata, address_mapping, tracer_if.priv_lvl); end else - printInstr(issue_sbe, issue_commit_instruction, reg_file[commit_instruction.rd], address_mapping); + printInstr(issue_sbe, issue_commit_instruction, reg_file[commit_instruction.rd], address_mapping, tracer_if.priv_lvl); end // -------------- @@ -168,8 +168,8 @@ class instruction_tracer; load_mapping = {}; endfunction; - function void printInstr(scoreboard_entry sbe, logic [31:0] instr, logic [63:0] result, logic [63:0] paddr); - instruction_trace_item iti = new ($time, clk_ticks, sbe, instr, this.reg_file, result, paddr); + function void printInstr(scoreboard_entry sbe, logic [31:0] instr, logic [63:0] result, logic [63:0] paddr, priv_lvl_t priv_lvl); + instruction_trace_item iti = new ($time, clk_ticks, sbe, instr, this.reg_file, result, paddr, priv_lvl); // print instruction to console string print_instr = iti.printInstr(); uvm_report_info( "Tracer", print_instr, UVM_HIGH); diff --git a/src/util/instruction_tracer_if.sv b/src/util/instruction_tracer_if.sv index 3b0209301..16dc58c03 100755 --- a/src/util/instruction_tracer_if.sv +++ b/src/util/instruction_tracer_if.sv @@ -51,6 +51,8 @@ interface instruction_tracer_if ( // exceptions exception exception; + // current privilege level + priv_lvl_t priv_lvl; // the tracer just has a passive interface we do not drive anything with it clocking pck @(posedge clk); input rstn, flush_unissued, flush, instruction, fetch_valid, fetch_ack, issue_ack, issue_sbe, waddr, @@ -59,4 +61,4 @@ interface instruction_tracer_if ( endclocking endinterface -`endif \ No newline at end of file +`endif diff --git a/tb b/tb index be85974f7..af427ba56 160000 --- a/tb +++ b/tb @@ -1 +1 @@ -Subproject commit be85974f7894a7c44c6002cbd8529507e22f525a +Subproject commit af427ba569cd9695e19d17e94c3f627381a9dded