xref: /XiangShan/src/main/scala/xiangshan/PMParameters.scala (revision 2caa7ef23d5d6566d68f5f98a59dc7ee9066b96a)
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 system.CVMParamskey
24import xiangshan.backend.fu.{MMPMAConfig, MMPMAMethod}
25
26case object PMParameKey extends Field[PMParameters]
27
28case class PMParameters
29(
30  NumPMP: Int = 16,
31  NumPMA: Int = 16,
32
33  PlatformGrain: Int = log2Ceil(4*1024), // 4KB, a normal page
34  mmpma: MMPMAConfig = MMPMAConfig(
35    address = 0x38021000,
36    mask = 0xfff,
37    lgMaxSize = 3,
38    sameCycle = true,
39    num = 2
40  )
41)
42//trait HasPMParameters extends PMParameters
43trait HasPMParameters {
44  implicit val p: Parameters
45
46  def PMPAddrBits = p(SoCParamsKey).PAddrBits
47  def PMPPmemRanges = p(SoCParamsKey).PmemRanges
48  def PMAConfigs = p(SoCParamsKey).PMAConfigs
49  val PMPKeyIDBits = p(CVMParamskey).KeyIDBits
50  def PMXLEN = p(XLen)
51  def pmParams = p(PMParameKey)
52  def NumPMP = pmParams.NumPMP
53  def NumPMA = pmParams.NumPMA
54
55  def PlatformGrain = pmParams.PlatformGrain
56  def mmpma = pmParams.mmpma
57}
58