From 09bb733088e4ea6b9112d79618bc7c3636513321 Mon Sep 17 00:00:00 2001 From: Ross Thompson Date: Thu, 5 Jan 2023 18:00:11 -0600 Subject: [PATCH] Added code to print out performance counters at end of each test. --- pipelined/testbench/testbench.sv | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pipelined/testbench/testbench.sv b/pipelined/testbench/testbench.sv index d2031fb8f..48cd58c8d 100644 --- a/pipelined/testbench/testbench.sv +++ b/pipelined/testbench/testbench.sv @@ -32,6 +32,8 @@ `include "wally-config.vh" `include "tests.vh" +`define PrintHPMCounters 0 + module testbench; parameter DEBUG=0; parameter TEST="none"; @@ -401,6 +403,34 @@ logic [3:0] dummy; end end // always @ (negedge clk) + + if(`PrintHPMCounters) begin + integer HPMCindex; + string HPMCnames[] = '{"Mcycle", + "------", + "InstRet", + "Load Stall", + "Br Dir Wrong", + "Br Count", + "Br Target Wrong", + "Jump, JR, ret", + "RAS Wrong", + "ret", + "Instr Class Wrong", + "D Cache Access", + "D Cache Miss", + "I Cache Access", + "I Cache Miss"}; + always @(negedge clk) begin + if(DCacheFlushStart & ~DCacheFlushDone) begin + for(HPMCindex = 0; HPMCindex < HPMCnames.size(); HPMCindex += 1) begin + // unlikely to have more than 10M in any counter. + $display("Cnt[%2d] = %7d %s", HPMCindex, dut.core.priv.priv.csr.counters.counters.HPMCOUNTER_REGW[HPMCindex], HPMCnames[HPMCindex]); + end + end + end + end + // track the current function or global label if (DEBUG == 1) begin : FunctionName FunctionName FunctionName(.reset(reset),