mirror of
https://github.com/lowRISC/ibex.git
synced 2025-04-20 11:57:12 -04:00
fixed perf counters
This commit is contained in:
parent
ef744a9174
commit
e97d18e829
6 changed files with 36 additions and 52 deletions
|
@ -74,7 +74,6 @@ module zeroriscy_controller
|
|||
input logic branch_taken_ex_i, // branch taken signal
|
||||
input logic branch_set_i, // branch taken set signal
|
||||
input logic jump_set_i, // jump taken set signal
|
||||
input logic jump_in_id_i, // jump is being calculated in ALU
|
||||
|
||||
input logic instr_multicyle_i, // multicycle instructions active
|
||||
|
||||
|
@ -114,17 +113,11 @@ module zeroriscy_controller
|
|||
output logic halt_if_o,
|
||||
output logic halt_id_o,
|
||||
|
||||
input logic jump_stall_i,
|
||||
input logic load_stall_i,
|
||||
input logic branch_stall_i,
|
||||
|
||||
input logic id_ready_i, // ID stage is ready
|
||||
|
||||
// Performance Counters
|
||||
output logic perf_jump_o, // we are executing a jump instruction (j, jr, jal, jalr)
|
||||
output logic perf_jr_stall_o, // stall due to jump instruction
|
||||
output logic perf_br_stall_o, // stall due to branch instruction
|
||||
output logic perf_ld_stall_o // stall due to load instruction
|
||||
output logic perf_tbranch_o // we are executing a taken branch instruction
|
||||
);
|
||||
|
||||
// FSM state encoding
|
||||
|
@ -203,6 +196,9 @@ module zeroriscy_controller
|
|||
// - Debuger requests halt
|
||||
dbg_trap_o = 1'b0;
|
||||
|
||||
perf_tbranch_o = 1'b0;
|
||||
perf_jump_o = 1'b0;
|
||||
|
||||
unique case (ctrl_fsm_cs)
|
||||
// We were just reset, wait for fetch_enable
|
||||
RESET:
|
||||
|
@ -300,6 +296,7 @@ module zeroriscy_controller
|
|||
branch_set_i: begin
|
||||
pc_mux_o = PC_JUMP;
|
||||
pc_set_o = 1'b1;
|
||||
perf_tbranch_o = 1'b1;
|
||||
dbg_trap_o = dbg_settings_i[DBG_SETS_SSTE];
|
||||
if (dbg_req_i)
|
||||
ctrl_fsm_ns = DBG_SIGNAL;
|
||||
|
@ -307,6 +304,7 @@ module zeroriscy_controller
|
|||
jump_set_i: begin
|
||||
pc_mux_o = PC_JUMP;
|
||||
pc_set_o = 1'b1;
|
||||
perf_jump_o = 1'b1;
|
||||
dbg_trap_o = dbg_settings_i[DBG_SETS_SSTE];
|
||||
if (dbg_req_i)
|
||||
ctrl_fsm_ns = DBG_SIGNAL;
|
||||
|
@ -531,12 +529,6 @@ module zeroriscy_controller
|
|||
end
|
||||
end
|
||||
|
||||
// Performance Counters
|
||||
assign perf_jump_o = jump_in_id_i;
|
||||
assign perf_jr_stall_o = jump_stall_i;
|
||||
assign perf_br_stall_o = branch_stall_i;
|
||||
assign perf_ld_stall_o = load_stall_i;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Assertions
|
||||
|
|
|
@ -221,8 +221,8 @@ module zeroriscy_core
|
|||
// Performance Counters
|
||||
logic perf_imiss;
|
||||
logic perf_jump;
|
||||
logic perf_jr_stall;
|
||||
logic perf_ld_stall;
|
||||
logic perf_branch;
|
||||
logic perf_tbranch;
|
||||
|
||||
//core busy signals
|
||||
logic core_ctrl_firstfetch, core_busy_int, core_busy_q;
|
||||
|
@ -328,6 +328,7 @@ module zeroriscy_core
|
|||
// pipeline stalls
|
||||
.halt_if_i ( halt_if ),
|
||||
.id_ready_i ( id_ready ),
|
||||
.if_valid_o ( if_valid ),
|
||||
|
||||
.if_busy_o ( if_busy ),
|
||||
.perf_imiss_o ( perf_imiss )
|
||||
|
@ -455,8 +456,9 @@ module zeroriscy_core
|
|||
|
||||
// Performance Counters
|
||||
.perf_jump_o ( perf_jump ),
|
||||
.perf_jr_stall_o ( perf_jr_stall ),
|
||||
.perf_ld_stall_o ( perf_ld_stall )
|
||||
.perf_branch_o ( perf_branch ),
|
||||
.perf_tbranch_o ( perf_tbranch )
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
@ -593,6 +595,7 @@ module zeroriscy_core
|
|||
|
||||
|
||||
// performance counter related signals
|
||||
.if_valid_i ( if_valid ),
|
||||
.id_valid_i ( id_valid ),
|
||||
.is_compressed_i ( is_compressed_id ),
|
||||
.is_decoding_i ( is_decoding ),
|
||||
|
@ -600,11 +603,8 @@ module zeroriscy_core
|
|||
.imiss_i ( perf_imiss ),
|
||||
.pc_set_i ( pc_set ),
|
||||
.jump_i ( perf_jump ),
|
||||
.branch_i ( branch_in_ex ),
|
||||
.branch_taken_i ( branch_decision ),
|
||||
.ld_stall_i ( perf_ld_stall ),
|
||||
.jr_stall_i ( perf_jr_stall ),
|
||||
|
||||
.branch_i ( perf_branch ),
|
||||
.branch_taken_i ( perf_tbranch ),
|
||||
.mem_load_i ( data_req_o & data_gnt_i & (~data_we_o) ),
|
||||
.mem_store_i ( data_req_o & data_gnt_i & data_we_o ),
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ module zeroriscy_cs_registers
|
|||
|
||||
|
||||
// Performance Counters
|
||||
input logic if_valid_i, // IF stage gives a new instruction
|
||||
input logic id_valid_i, // ID stage is done
|
||||
input logic is_compressed_i, // compressed instruction in ID
|
||||
input logic is_decoding_i, // controller is in DECODE state
|
||||
|
@ -84,12 +85,8 @@ module zeroriscy_cs_registers
|
|||
input logic jump_i, // jump instruction seen (j, jr, jal, jalr)
|
||||
input logic branch_i, // branch instruction seen (bf, bnf)
|
||||
input logic branch_taken_i, // branch was taken
|
||||
input logic ld_stall_i, // load use hazard
|
||||
input logic jr_stall_i, // jump register use hazard
|
||||
|
||||
input logic mem_load_i, // load from memory in this cycle
|
||||
input logic mem_store_i, // store to memory in this cycle
|
||||
|
||||
input logic [N_EXT_CNT-1:0] ext_counters_i
|
||||
);
|
||||
|
||||
|
@ -314,14 +311,16 @@ module zeroriscy_cs_registers
|
|||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
assign PCCR_in[0] = 1'b1; // cycle counter
|
||||
assign PCCR_in[1] = id_valid_i & is_decoding_i; // instruction counter
|
||||
assign PCCR_in[1] = if_valid_i; // instruction counter
|
||||
assign PCCR_in[2] = 1'b0; // Reserved
|
||||
assign PCCR_in[3] = 1'b0; // Reserved
|
||||
assign PCCR_in[4] = imiss_i & (~pc_set_i); // cycles waiting for instruction fetches, excluding jumps and branches
|
||||
assign PCCR_in[5] = mem_load_i; // nr of loads
|
||||
assign PCCR_in[6] = mem_store_i; // nr of stores
|
||||
assign PCCR_in[7] = jump_i & id_valid_q; // nr of jumps (unconditional)
|
||||
assign PCCR_in[8] = branch_i & id_valid_q; // nr of branches (conditional)
|
||||
assign PCCR_in[9] = branch_i & branch_taken_i & id_valid_q; // nr of taken branches (conditional)
|
||||
assign PCCR_in[10] = id_valid_i & is_decoding_i & is_compressed_i; // compressed instruction counter
|
||||
assign PCCR_in[7] = jump_i; // nr of jumps (unconditional)
|
||||
assign PCCR_in[8] = branch_i; // nr of branches (conditional)
|
||||
assign PCCR_in[9] = branch_taken_i; // nr of taken branches (conditional)
|
||||
assign PCCR_in[10] = id_valid_i & is_decoding_i & is_compressed_i; // compressed instruction counter
|
||||
|
||||
// assign external performance counters
|
||||
generate
|
||||
|
@ -347,7 +346,7 @@ module zeroriscy_cs_registers
|
|||
unique case (csr_addr_i)
|
||||
12'h7A0: begin
|
||||
is_pcer = 1'b1;
|
||||
perf_rdata[N_PERF_COUNTERS-1:0] = PCER_q;
|
||||
perf_rdata[15:0] = PCER_q;
|
||||
end
|
||||
12'h7A1: begin
|
||||
is_pcmr = 1'b1;
|
||||
|
|
|
@ -68,7 +68,7 @@ module zeroriscy_ex_block
|
|||
output logic ex_ready_o // EX stage gets new data
|
||||
);
|
||||
|
||||
localparam MULT_TYPE = 0; //0 is SLOW
|
||||
localparam MULT_TYPE = 1; //0 is SLOW
|
||||
|
||||
logic [31:0] alu_result, multdiv_result;
|
||||
|
||||
|
|
|
@ -150,8 +150,8 @@ module zeroriscy_id_stage
|
|||
|
||||
// Performance Counters
|
||||
output logic perf_jump_o, // we are executing a jump instruction
|
||||
output logic perf_jr_stall_o, // jump-register-hazard
|
||||
output logic perf_ld_stall_o // load-use-hazard
|
||||
output logic perf_branch_o, // we are executing a branch instruction
|
||||
output logic perf_tbranch_o // we are executing a taken branch instruction
|
||||
);
|
||||
|
||||
logic [31:0] instr;
|
||||
|
@ -552,7 +552,6 @@ module zeroriscy_id_stage
|
|||
.branch_taken_ex_i ( branch_taken_ex ),
|
||||
.branch_set_i ( branch_set_q ),
|
||||
.jump_set_i ( jump_set ),
|
||||
.jump_in_id_i ( jump_in_id ),
|
||||
|
||||
.instr_multicyle_i ( instr_multicyle ),
|
||||
|
||||
|
@ -589,17 +588,11 @@ module zeroriscy_id_stage
|
|||
.halt_if_o ( halt_if_o ),
|
||||
.halt_id_o ( halt_id ),
|
||||
|
||||
.jump_stall_i ( jump_stall ),
|
||||
.branch_stall_i ( branch_stall ),
|
||||
.load_stall_i ( load_stall ),
|
||||
|
||||
.id_ready_i ( id_ready_o ),
|
||||
|
||||
// Performance Counters
|
||||
.perf_jump_o ( perf_jump_o ),
|
||||
.perf_jr_stall_o ( perf_jr_stall_o ),
|
||||
.perf_br_stall_o ( ),
|
||||
.perf_ld_stall_o ( perf_ld_stall_o )
|
||||
.perf_tbranch_o ( perf_tbranch_o )
|
||||
);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -701,6 +694,7 @@ module zeroriscy_id_stage
|
|||
branch_mux_dec = 1'b0;
|
||||
jump_set = 1'b0;
|
||||
jump_mux_dec = 1'b0;
|
||||
perf_branch_o = 1'b0;
|
||||
|
||||
unique case (id_wb_fsm_cs)
|
||||
|
||||
|
@ -722,6 +716,7 @@ module zeroriscy_id_stage
|
|||
branch_stall = branch_decision_i;
|
||||
instr_multicyle = branch_decision_i;
|
||||
branch_set_n = branch_decision_i;
|
||||
perf_branch_o = 1'b1;
|
||||
end
|
||||
multdiv_int_en: begin
|
||||
//MUL or DIV operation
|
||||
|
|
|
@ -59,17 +59,15 @@ module zeroriscy_if_stage
|
|||
input logic [2:0] pc_mux_i, // sel for pc multiplexer
|
||||
input logic [1:0] exc_pc_mux_i, // selects ISR address
|
||||
input logic [4:0] exc_vec_pc_mux_i, // selects ISR address for vectorized interrupt lines
|
||||
// jump and branch target and decision
|
||||
|
||||
// jump and branch target and decision
|
||||
input logic [31:0] jump_target_ex_i, // jump target address
|
||||
// from hwloop controller
|
||||
// from debug unit
|
||||
input logic [31:0] dbg_jump_addr_i,
|
||||
// pipeline stall
|
||||
input logic halt_if_i,
|
||||
|
||||
input logic id_ready_i,
|
||||
|
||||
output logic if_valid_o,
|
||||
// misc signals
|
||||
output logic if_busy_o, // is the IF stage busy fetching instructions?
|
||||
output logic perf_imiss_o // Instruction Fetch Miss
|
||||
|
@ -79,7 +77,7 @@ module zeroriscy_if_stage
|
|||
enum logic[0:0] {WAIT, IDLE } offset_fsm_cs, offset_fsm_ns;
|
||||
|
||||
logic valid;
|
||||
logic if_ready, if_valid;
|
||||
logic if_ready;
|
||||
// prefetch buffer related signals
|
||||
logic prefetch_busy;
|
||||
logic branch_req;
|
||||
|
@ -186,7 +184,7 @@ module zeroriscy_if_stage
|
|||
if (fetch_valid) begin
|
||||
valid = 1'b1; // an instruction is ready for ID stage
|
||||
|
||||
if (req_i && if_valid) begin
|
||||
if (req_i && if_valid_o) begin
|
||||
fetch_ready = 1'b1;
|
||||
offset_fsm_ns = WAIT;
|
||||
end
|
||||
|
@ -250,7 +248,7 @@ module zeroriscy_if_stage
|
|||
else
|
||||
begin
|
||||
|
||||
if (if_valid)
|
||||
if (if_valid_o)
|
||||
begin
|
||||
instr_valid_id_o <= 1'b1;
|
||||
instr_rdata_id_o <= instr_decompressed;
|
||||
|
@ -266,7 +264,7 @@ module zeroriscy_if_stage
|
|||
|
||||
|
||||
assign if_ready = valid & id_ready_i;
|
||||
assign if_valid = (~halt_if_i) & if_ready;
|
||||
assign if_valid_o = (~halt_if_i) & if_ready;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Assertions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue