Add generate to avoid elaborating internals of PMP/triggers with 0 PMP regions or triggers.

This commit is contained in:
Luke Wren 2022-09-05 00:36:41 +01:00
parent 18c64bd633
commit 9eb8590858
2 changed files with 32 additions and 0 deletions

View File

@ -39,6 +39,19 @@ localparam PMP_A_NAPOT = 2'b11;
`include "hazard3_csr_addr.vh"
generate
if (PMP_REGIONS == 0) begin: no_pmp
// This should already be stubbed out in core.v, but use a generate here too
// so that we don't get a warning for elaborating this module with a region
// count of 0.
always @ (*) cfg_rdata = {W_DATA{1'b0}};
assign i_kill = 1'b0;
assign d_kill = 1'b0;
end else begin: have_pmp
// ----------------------------------------------------------------------------
// Config registers and read/write interface
@ -279,6 +292,9 @@ assign i_kill = i_partial_match || (
(!i_m_mode || i_l || i_m) && !i_x
);
end
endgenerate
endmodule
`ifndef YOSYS

View File

@ -36,6 +36,19 @@ module hazard3_triggers #(
`include "hazard3_csr_addr.vh"
generate
if (BREAKPOINT_TRIGGERS == 0) begin: no_triggers
// The instantiation of this block should already be stubbed out in core.v if
// there are no triggers, but we still get warnings for elaborating this
// module with zero triggers, so add a generate block here too.
always @ (*) cfg_rdata = {W_DATA{1'b0}};
assign break_any = 1'b0;
assign break_d_mode = 1'b0;
end else begin: have_triggers
// ----------------------------------------------------------------------------
// Configuration state
@ -156,6 +169,9 @@ end
assign break_any = |want_m_mode_break || |want_d_mode_break;
assign break_d_mode = |want_d_mode_break;
end
endgenerate
endmodule
`ifndef YOSYS