mirror of
https://github.com/lowRISC/ibex.git
synced 2025-06-28 09:17:17 -04:00
[pmp] Use top-level straps for PMP reset values
By using top-level straps for the PMP reset configuration its easier to implement different reset configurations if there are multiple Ibex cores in the system. Signed-off-by: Robert Schilling <rschilling@rivosinc.com>
This commit is contained in:
parent
4ed20f4ac3
commit
f92d599e00
8 changed files with 178 additions and 165 deletions
|
@ -50,5 +50,5 @@ Custom Reset Values
|
|||
|
||||
By default all PMP CSRs (include ``mseccfg``) are reset to 0.
|
||||
Some applications may want other reset values.
|
||||
Default reset values are defined in :file:`ibex_pmp_reset_default.svh`.
|
||||
An implementation can either modify this file or define ``IBEX_CUSTOM_PMP_RESET_VALUES`` and place a copy of :file:`ibex_pmp_result_default.svh` in a new file, :file:`ibex_pmp_reset.svh`, changing the values as required and adding the new file to the include path of whatever build flow is being used.
|
||||
Default reset values are defined in :file:`ibex_pkg.sv`.
|
||||
An implementation can either modify this file or pass custom reset values as a module parameter.
|
||||
|
|
|
@ -36,7 +36,6 @@ filesets:
|
|||
- rtl/ibex_wb_stage.sv
|
||||
- rtl/ibex_dummy_instr.sv
|
||||
- rtl/ibex_core.sv
|
||||
- rtl/ibex_pmp_reset_default.svh: {is_include_file: true}
|
||||
file_type: systemVerilogSource
|
||||
|
||||
files_lint_verilator:
|
||||
|
|
|
@ -17,6 +17,9 @@ module ibex_core import ibex_pkg::*; #(
|
|||
parameter bit PMPEnable = 1'b0,
|
||||
parameter int unsigned PMPGranularity = 0,
|
||||
parameter int unsigned PMPNumRegions = 4,
|
||||
parameter ibex_pkg::pmp_cfg_t PMPRstCfg[16] = ibex_pkg::PmpCfgRst,
|
||||
parameter logic [33:0] PMPRstAddr[16] = ibex_pkg::PmpAddrRst,
|
||||
parameter ibex_pkg::pmp_mseccfg_t PMPRstMsecCfg = ibex_pkg::PmpMseccfgRst,
|
||||
parameter int unsigned MHPMCounterNum = 0,
|
||||
parameter int unsigned MHPMCounterWidth = 40,
|
||||
parameter bit RV32E = 1'b0,
|
||||
|
@ -1049,6 +1052,9 @@ module ibex_core import ibex_pkg::*; #(
|
|||
.PMPEnable (PMPEnable),
|
||||
.PMPGranularity (PMPGranularity),
|
||||
.PMPNumRegions (PMPNumRegions),
|
||||
.PMPRstCfg (PMPRstCfg),
|
||||
.PMPRstAddr (PMPRstAddr),
|
||||
.PMPRstMsecCfg (PMPRstMsecCfg),
|
||||
.RV32E (RV32E),
|
||||
.RV32M (RV32M),
|
||||
.RV32B (RV32B)
|
||||
|
|
|
@ -21,6 +21,9 @@ module ibex_cs_registers #(
|
|||
parameter bit PMPEnable = 0,
|
||||
parameter int unsigned PMPGranularity = 0,
|
||||
parameter int unsigned PMPNumRegions = 4,
|
||||
parameter ibex_pkg::pmp_cfg_t PMPRstCfg[16] = ibex_pkg::PmpCfgRst,
|
||||
parameter logic [33:0] PMPRstAddr[16] = ibex_pkg::PmpAddrRst,
|
||||
parameter ibex_pkg::pmp_mseccfg_t PMPRstMsecCfg = ibex_pkg::PmpMseccfgRst,
|
||||
parameter bit RV32E = 0,
|
||||
parameter ibex_pkg::rv32m_e RV32M = ibex_pkg::RV32MFast,
|
||||
parameter ibex_pkg::rv32b_e RV32B = ibex_pkg::RV32BNone
|
||||
|
@ -1073,13 +1076,6 @@ module ibex_cs_registers #(
|
|||
// -----------------
|
||||
|
||||
if (PMPEnable) begin : g_pmp_registers
|
||||
// PMP reset values
|
||||
`ifdef IBEX_CUSTOM_PMP_RESET_VALUES
|
||||
`include "ibex_pmp_reset.svh"
|
||||
`else
|
||||
`include "ibex_pmp_reset_default.svh"
|
||||
`endif
|
||||
|
||||
pmp_mseccfg_t pmp_mseccfg_q, pmp_mseccfg_d;
|
||||
logic pmp_mseccfg_we;
|
||||
logic pmp_mseccfg_err;
|
||||
|
@ -1168,7 +1164,7 @@ module ibex_cs_registers #(
|
|||
ibex_csr #(
|
||||
.Width ($bits(pmp_cfg_t)),
|
||||
.ShadowCopy(ShadowCSR),
|
||||
.ResetValue(pmp_cfg_rst[i])
|
||||
.ResetValue(PMPRstCfg[i])
|
||||
) u_pmp_cfg_csr (
|
||||
.clk_i (clk_i),
|
||||
.rst_ni (rst_ni),
|
||||
|
@ -1203,7 +1199,7 @@ module ibex_cs_registers #(
|
|||
ibex_csr #(
|
||||
.Width (PMPAddrWidth),
|
||||
.ShadowCopy(ShadowCSR),
|
||||
.ResetValue(pmp_addr_rst[i][33-:PMPAddrWidth])
|
||||
.ResetValue(PMPRstAddr[i][33-:PMPAddrWidth])
|
||||
) u_pmp_addr_csr (
|
||||
.clk_i (clk_i),
|
||||
.rst_ni (rst_ni),
|
||||
|
@ -1213,7 +1209,7 @@ module ibex_cs_registers #(
|
|||
.rd_error_o(pmp_addr_err[i])
|
||||
);
|
||||
|
||||
`ASSERT_INIT(PMPAddrRstLowBitsZero_A, pmp_addr_rst[i][33-PMPAddrWidth:0] == '0)
|
||||
`ASSERT_INIT(PMPAddrRstLowBitsZero_A, PMPRstAddr[i][33-PMPAddrWidth:0] == '0)
|
||||
|
||||
assign csr_pmp_cfg_o[i] = pmp_cfg[i];
|
||||
assign csr_pmp_addr_o[i] = {pmp_addr_rdata[i], 2'b00};
|
||||
|
@ -1236,7 +1232,7 @@ module ibex_cs_registers #(
|
|||
ibex_csr #(
|
||||
.Width ($bits(pmp_mseccfg_t)),
|
||||
.ShadowCopy(ShadowCSR),
|
||||
.ResetValue(pmp_mseccfg_rst)
|
||||
.ResetValue(PMPRstMsecCfg)
|
||||
) u_pmp_mseccfg (
|
||||
.clk_i (clk_i),
|
||||
.rst_ni (rst_ni),
|
||||
|
|
|
@ -13,6 +13,9 @@ module ibex_lockstep import ibex_pkg::*; #(
|
|||
parameter bit PMPEnable = 1'b0,
|
||||
parameter int unsigned PMPGranularity = 0,
|
||||
parameter int unsigned PMPNumRegions = 4,
|
||||
parameter ibex_pkg::pmp_cfg_t PMPRstCfg[16] = ibex_pkg::PmpCfgRst,
|
||||
parameter logic [33:0] PMPRstAddr[16] = ibex_pkg::PmpAddrRst,
|
||||
parameter ibex_pkg::pmp_mseccfg_t PMPRstMsecCfg = ibex_pkg::PmpMseccfgRst,
|
||||
parameter int unsigned MHPMCounterNum = 0,
|
||||
parameter int unsigned MHPMCounterWidth = 40,
|
||||
parameter bit RV32E = 1'b0,
|
||||
|
@ -347,6 +350,9 @@ module ibex_lockstep import ibex_pkg::*; #(
|
|||
.PMPEnable ( PMPEnable ),
|
||||
.PMPGranularity ( PMPGranularity ),
|
||||
.PMPNumRegions ( PMPNumRegions ),
|
||||
.PMPRstCfg ( PMPRstCfg ),
|
||||
.PMPRstAddr ( PMPRstAddr ),
|
||||
.PMPRstMsecCfg ( PMPRstMsecCfg ),
|
||||
.MHPMCounterNum ( MHPMCounterNum ),
|
||||
.MHPMCounterWidth ( MHPMCounterWidth ),
|
||||
.RV32E ( RV32E ),
|
||||
|
|
|
@ -664,4 +664,54 @@ package ibex_pkg;
|
|||
// and core_busy signals within `ibex_core` may need adjusting.
|
||||
parameter ibex_mubi_t IbexMuBiOn = 4'b0101;
|
||||
parameter ibex_mubi_t IbexMuBiOff = 4'b1010;
|
||||
|
||||
// Default reset values for PMP CSRs. Where the number of regions
|
||||
// (PMPNumRegions) is less than 16 the reset values for the higher numbered
|
||||
// regions are ignored.
|
||||
//
|
||||
// See the Ibex Reference Guide (Custom Reset Values under Physical Memory
|
||||
// Protection) for more information.
|
||||
|
||||
parameter pmp_cfg_t PmpCfgRst[16] = '{
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 0
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 1
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 2
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 3
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 4
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 5
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 6
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 7
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 8
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 9
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 10
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 11
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 12
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 13
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 14
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0} // region 15
|
||||
};
|
||||
|
||||
// Addresses are given in byte granularity for readibility. A minimum of two
|
||||
// bits will be stripped off the bottom (PMPGranularity == 0) with more stripped
|
||||
// off at coarser granularities.
|
||||
parameter logic [33:0] PmpAddrRst[16] = '{
|
||||
34'h0, // region 0
|
||||
34'h0, // region 1
|
||||
34'h0, // region 2
|
||||
34'h0, // region 3
|
||||
34'h0, // region 4
|
||||
34'h0, // region 5
|
||||
34'h0, // region 6
|
||||
34'h0, // region 7
|
||||
34'h0, // region 8
|
||||
34'h0, // region 9
|
||||
34'h0, // region 10
|
||||
34'h0, // region 11
|
||||
34'h0, // region 12
|
||||
34'h0, // region 13
|
||||
34'h0, // region 14
|
||||
34'h0 // region 15
|
||||
};
|
||||
|
||||
parameter pmp_mseccfg_t PmpMseccfgRst = '{rlb : 1'b0, mmwp: 1'b0, mml: 1'b0};
|
||||
endpackage
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
// Copyright lowRISC contributors.
|
||||
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Default reset values for PMP CSRs. Where the number of regions
|
||||
// (PMPNumRegions) is less than 16 the reset values for the higher numbered
|
||||
// regions are ignored.
|
||||
//
|
||||
// See the Ibex Reference Guide (Custom Reset Values under Physical Memory
|
||||
// Protection) for more information.
|
||||
|
||||
localparam pmp_cfg_t pmp_cfg_rst[16] = '{
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 0
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 1
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 2
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 3
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 4
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 5
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 6
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 7
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 8
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 9
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 10
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 11
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 12
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 13
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0}, // region 14
|
||||
'{lock: 1'b0, mode: PMP_MODE_OFF, exec: 1'b0, write: 1'b0, read: 1'b0} // region 15
|
||||
};
|
||||
|
||||
// Addresses are given in byte granularity for readibility. A minimum of two
|
||||
// bits will be stripped off the bottom (PMPGranularity == 0) with more stripped
|
||||
// off at coarser granularities.
|
||||
localparam [33:0] pmp_addr_rst[16] = '{
|
||||
34'h0, // region 0
|
||||
34'h0, // region 1
|
||||
34'h0, // region 2
|
||||
34'h0, // region 3
|
||||
34'h0, // region 4
|
||||
34'h0, // region 5
|
||||
34'h0, // region 6
|
||||
34'h0, // region 7
|
||||
34'h0, // region 8
|
||||
34'h0, // region 9
|
||||
34'h0, // region 10
|
||||
34'h0, // region 11
|
||||
34'h0, // region 12
|
||||
34'h0, // region 13
|
||||
34'h0, // region 14
|
||||
34'h0 // region 15
|
||||
};
|
||||
|
||||
localparam pmp_mseccfg_t pmp_mseccfg_rst = '{rlb : 1'b0, mmwp: 1'b0, mml: 1'b0};
|
|
@ -18,6 +18,9 @@ module ibex_top import ibex_pkg::*; #(
|
|||
parameter int unsigned PMPNumRegions = 4,
|
||||
parameter int unsigned MHPMCounterNum = 0,
|
||||
parameter int unsigned MHPMCounterWidth = 40,
|
||||
parameter ibex_pkg::pmp_cfg_t PMPRstCfg[16] = ibex_pkg::PmpCfgRst,
|
||||
parameter logic [33:0] PMPRstAddr[16] = ibex_pkg::PmpAddrRst,
|
||||
parameter ibex_pkg::pmp_mseccfg_t PMPRstMsecCfg = ibex_pkg::PmpMseccfgRst,
|
||||
parameter bit RV32E = 1'b0,
|
||||
parameter rv32m_e RV32M = RV32MFast,
|
||||
parameter rv32b_e RV32B = RV32BNone,
|
||||
|
@ -283,6 +286,9 @@ module ibex_top import ibex_pkg::*; #(
|
|||
.PMPEnable (PMPEnable),
|
||||
.PMPGranularity (PMPGranularity),
|
||||
.PMPNumRegions (PMPNumRegions),
|
||||
.PMPRstCfg (PMPRstCfg),
|
||||
.PMPRstAddr (PMPRstAddr),
|
||||
.PMPRstMsecCfg (PMPRstMsecCfg),
|
||||
.MHPMCounterNum (MHPMCounterNum),
|
||||
.MHPMCounterWidth (MHPMCounterWidth),
|
||||
.RV32E (RV32E),
|
||||
|
@ -984,6 +990,9 @@ module ibex_top import ibex_pkg::*; #(
|
|||
.PMPEnable (PMPEnable),
|
||||
.PMPGranularity (PMPGranularity),
|
||||
.PMPNumRegions (PMPNumRegions),
|
||||
.PMPRstCfg (PMPRstCfg),
|
||||
.PMPRstAddr (PMPRstAddr),
|
||||
.PMPRstMsecCfg (PMPRstMsecCfg),
|
||||
.MHPMCounterNum (MHPMCounterNum),
|
||||
.MHPMCounterWidth (MHPMCounterWidth),
|
||||
.RV32E (RV32E),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue