xref: /XiangShan/src/main/scala/xiangshan/PMParameters.scala (revision e836c7705c53f8360816d56db7f6d37725aad2a6)
1/***************************************************************************************
2  * Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
3  * Copyright (c) 2020-2021 Peng Cheng Laboratory
4  *
5  * XiangShan is licensed under Mulan PSL v2.
6  * You can use this software according to the terms and conditions of the Mulan PSL v2.
7  * You may obtain a copy of Mulan PSL v2 at:
8  *          http://license.coscl.org.cn/MulanPSL2
9  *
10  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13  *
14  * See the Mulan PSL v2 for more details.
15  ***************************************************************************************/
16
17package xiangshan
18
19import chisel3.util.log2Ceil
20import org.chipsalliance.cde.config.{Field, Parameters}
21import freechips.rocketchip.tile.XLen
22import system.SoCParamsKey
23import xiangshan.backend.fu.{MMPMAConfig, MMPMAMethod}
24
25case object PMParameKey extends Field[PMParameters]
26
27case class PMParameters
28(
29  NumPMP: Int = 16,
30  NumPMA: Int = 16,
31
32  PlatformGrain: Int = log2Ceil(4*1024), // 4KB, a normal page
33  mmpma: MMPMAConfig = MMPMAConfig(
34    address = 0x38021000,
35    mask = 0xfff,
36    lgMaxSize = 3,
37    sameCycle = true,
38    num = 2
39  )
40)
41//trait HasPMParameters extends PMParameters
42trait HasPMParameters {
43  implicit val p: Parameters
44
45  def PMPAddrBits = p(SoCParamsKey).PAddrBits
46  def PMPPmemRanges = p(SoCParamsKey).PmemRanges
47  def PMAConfigs = p(SoCParamsKey).PMAConfigs
48  def PMXLEN = p(XLen)
49  def pmParams = p(PMParameKey)
50  def NumPMP = pmParams.NumPMP
51  def NumPMA = pmParams.NumPMA
52
53  def PlatformGrain = pmParams.PlatformGrain
54  def mmpma = pmParams.mmpma
55}
56