-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DCache RAS): add DCache RAS inject support
- Loading branch information
Showing
11 changed files
with
396 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
/*************************************************************************************** | ||
* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences | ||
* Copyright (c) 2020-2021 Peng Cheng Laboratory | ||
* | ||
* XiangShan is licensed under Mulan PSL v2. | ||
* You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
* You may obtain a copy of Mulan PSL v2 at: | ||
* http://license.coscl.org.cn/MulanPSL2 | ||
* | ||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
* | ||
* See the Mulan PSL v2 for more details. | ||
***************************************************************************************/ | ||
|
||
package xiangshan.cache | ||
|
||
import org.chipsalliance.cde.config.Parameters | ||
import chisel3._ | ||
import chisel3.util._ | ||
import freechips.rocketchip.subsystem._ | ||
import freechips.rocketchip.diplomacy._ | ||
import freechips.rocketchip.regmapper._ | ||
import freechips.rocketchip.tilelink._ | ||
import freechips.rocketchip.interrupts._ | ||
import freechips.rocketchip.util._ | ||
import freechips.rocketchip.util.property | ||
import chisel3.experimental.SourceInfo | ||
import xiangshan._ | ||
|
||
case class L1CacheCtrlParams ( | ||
address: AddressSet, | ||
beatBytes: Int = 8, | ||
) { | ||
def maxBanks = 1 | ||
def bankBytes = 128 | ||
|
||
def regWidth = 64 | ||
def regBytes = regWidth / 8 | ||
|
||
def ctrlOffset = 0x0 | ||
def delayOffset = ctrlOffset + regBytes | ||
def maskOffset = delayOffset + regBytes | ||
|
||
def nSignalComps = 2 | ||
} | ||
|
||
class CtrlUnitCtrlBundle(implicit p: Parameters) extends XSBundle with HasDCacheParameters { | ||
val zero0 = UInt((60-DCacheBanks).W) // padding bits | ||
val comp = UInt(2.W) // components: 2'b01 tag, 2'b10 data | ||
val ede = Bool() // error delay enable | ||
val ese = Bool() // error signaling enable | ||
} | ||
|
||
class CtrlUnit(params: L1CacheCtrlParams)(implicit p: Parameters) extends LazyModule | ||
with HasDCacheParameters | ||
{ | ||
val device: SimpleDevice = new SimpleDevice("L1DCacheCtrl", Seq("xiangshan,l1dcache_ctrl")) | ||
|
||
val node: TLRegisterNode = TLRegisterNode( | ||
address = Seq(params.address), | ||
device = device, | ||
beatBytes = params.beatBytes, | ||
concurrency = 1, | ||
) | ||
|
||
lazy val module = new CtrlUnitImp | ||
|
||
class CtrlUnitImp extends LazyModuleImp(this) { | ||
val io_pseudoError = IO(Vec(params.nSignalComps, DecoupledIO(Vec(DCacheBanks, UInt(DCacheSRAMRowBits.W))))) | ||
|
||
require(params.maxBanks > 0, "At least one bank!") | ||
require(params.maxBanks == 1, "Is it necessary to have more than 1 bank?") | ||
require(params.regWidth == DCacheSRAMRowBits, "regWidth must be equal to DCacheSRAMRowBits!") | ||
val ctrlRegs = RegInit(VecInit(Seq.fill(1)(0.U(params.regWidth.W)))) | ||
val delayRegs = RegInit(VecInit(Seq.fill(1)(0.U(params.regWidth.W)))) | ||
val maskRegs = RegInit(VecInit(Seq.fill(DCacheBanks)(0.U(DCacheSRAMRowBits.W)))) | ||
|
||
io_pseudoError.zipWithIndex.foreach { | ||
case (pErr, i) => | ||
val ctrlReg = ctrlRegs(0) | ||
val ctrlRegBundle = ctrlRegs(0).asTypeOf(new CtrlUnitCtrlBundle) | ||
val delayReg = delayRegs(0) | ||
|
||
require(io_pseudoError.length == ctrlRegBundle.comp.getWidth, "io_pseudoError must equal number of components!") | ||
pErr.valid := ctrlRegBundle.ese && ctrlRegBundle.comp(i) && (!ctrlRegBundle.ede || delayReg === 0.U) | ||
pErr.bits := maskRegs | ||
|
||
when (pErr.fire) { | ||
val newCtrlReg = WireInit(0.U.asTypeOf(ctrlRegBundle)) | ||
newCtrlReg := ctrlRegBundle | ||
newCtrlReg.ese := false.B | ||
|
||
ctrlReg := newCtrlReg.asUInt | ||
} | ||
} | ||
|
||
ctrlRegs.map(_.asTypeOf(new CtrlUnitCtrlBundle)).zip(delayRegs).foreach { | ||
case (ctl, delay) => | ||
when (ctl.ese && ctl.ede && delay =/= 0.U) { | ||
delay := delay - 1.U | ||
} | ||
} | ||
|
||
def ctrlRegDesc(i: Int) = | ||
RegFieldDesc( | ||
name = s"control_$i", | ||
desc = s"Acting control of controller $i", | ||
group = Some(s"controll_${i}"), | ||
groupDesc = Some(s"Acting control of controller ${i}"), | ||
reset = Some(0) | ||
) | ||
|
||
def delayRegDesc(i: Int) = | ||
RegFieldDesc( | ||
name = s"delay_$i", | ||
desc = s"pseudo error delay $i", | ||
group = Some(s"delay_${i}"), | ||
groupDesc = Some(s"pseudo error delay ${i}"), | ||
reset = Some(0) | ||
) | ||
|
||
def maskRegDesc(i: Int) = | ||
RegFieldDesc( | ||
name = s"mask_$i", | ||
desc = s"pseudo error toggle mask$i", | ||
group = Some(s"mask_${i}"), | ||
groupDesc = Some(s"pseudo error toggle mask ${i}"), | ||
reset = Some(0) | ||
) | ||
|
||
def ctrlRegField(x: UInt, i: Int) = { | ||
RegField(params.regWidth, x, ctrlRegDesc(i)) | ||
} | ||
|
||
def delayRegField(x: UInt, i: Int) = { | ||
RegField(params.regWidth, x, delayRegDesc(i)) | ||
} | ||
|
||
def maskRegField(x: UInt, i: Int) = { | ||
RegField(params.regWidth, x, maskRegDesc(i)) | ||
} | ||
|
||
val ctrlRegFields = ctrlRegs.zipWithIndex.map { | ||
case (reg, i) => | ||
params.ctrlOffset -> Seq(ctrlRegField(reg, i)) | ||
} | ||
val delayRegFields = delayRegs.zipWithIndex.map { | ||
case (reg, i) => | ||
params.delayOffset -> Seq(delayRegField(reg, i)) | ||
} | ||
val maskRegFields = maskRegs.zipWithIndex.map { | ||
case (reg, i) => | ||
(params.maskOffset + 8 * i) -> Seq(maskRegField(reg, i)) | ||
} | ||
|
||
node.regmap((ctrlRegFields ++ delayRegFields ++ maskRegFields):_*) | ||
} | ||
} |
Oops, something went wrong.