Skip to content

Commit 4e4a6aa

Browse files
authored
feat(clockGate): support disable ClockGate with parameters (#451)
Users can disable clockGate by modify coupledL2 parameters. Example: case EnableL2ClockGate => false
1 parent e4fd161 commit 4e4a6aa

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

src/main/scala/coupledL2/CoupledL2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ trait HasCoupledL2Parameters {
3939
val p: Parameters
4040
// val tl2tlParams: HasTLL2Parameters = p(L2ParamKey)
4141
def enableCHI = p(EnableCHI)
42+
def enableClockGate = p(EnableL2ClockGate)
4243
def cacheParams = p(L2ParamKey)
4344
def EnablePrivateClint = cacheParams.EnablePrivateClint
4445

src/main/scala/coupledL2/DataStorage.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class DataStorage(implicit p: Parameters) extends L2Module {
7575
readMCP2 = true,
7676
hasMbist = p(L2ParamKey).hasMbist,
7777
hasSramCtl = p(L2ParamKey).hasSramCtl,
78-
extraHold = true
78+
extraHold = enableClockGate,
79+
withClockGate = enableClockGate
7980
))
8081
array.io_en := io.en
8182
private val mbistPl = MbistPipeline.PlaceMbistPipeline(1, "L2DataStorage", p(L2ParamKey).hasMbist)

src/main/scala/coupledL2/L2Param.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import coupledL2.prefetch._
2828
import utility.{MemReqSource, ReqSourceKey, Code}
2929

3030
case object EnableCHI extends Field[Boolean](false)
31+
case object EnableL2ClockGate extends Field[Boolean](true)
3132

3233
// L1 Cache Params, used for TestTop generation
3334
case class L1Param

src/main/scala/coupledL2/utils/GatedSplittedSRAM.scala

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class GatedSplittedSRAM[T <: Data]
1818
singlePort: Boolean = true, bypassWrite: Boolean = false,
1919
clkDivBy2: Boolean = false, readMCP2: Boolean = true,
2020
hasMbist:Boolean = false, hasSramCtl: Boolean = false,
21-
extraHold: Boolean = false, suffix: Option[String] = None
21+
extraHold: Boolean = false, suffix: Option[String] = None,
22+
withClockGate: Boolean = true,
2223
)(implicit valName: sourcecode.FullName) extends SplittedSRAM[T](
2324
gen = gen,
2425
set = set,
@@ -35,25 +36,27 @@ class GatedSplittedSRAM[T <: Data]
3536
hasMbist = hasMbist,
3637
hasSramCtl = hasSramCtl,
3738
extraHold = extraHold,
38-
extClockGate = true,
39+
extClockGate = withClockGate,
3940
suffix = Some(suffix.getOrElse(SramHelper.getSramSuffix(valName.value)))
4041
) {
4142
// en is the actual r/w valid (last for one cycle)
4243
// en is used to generate gated_clock for each SRAM
4344
val io_en = IO(Input(Bool()))
4445

4546
// Create a ClockGate module for each element in the array
46-
array.map(_.map(_.map(a => {
47-
val cg = Module(new MbistClockGateCell(extraHold))
48-
cg.E := io_en
49-
cg.dft.fromBroadcast(a.io.broadcast.getOrElse(0.U.asTypeOf(new SramBroadcastBundle)))
50-
cg.mbist.req := a.io.mbistCgCtl.map(_.en).getOrElse(false.B)
51-
cg.mbist.writeen := a.io.mbistCgCtl.map(_.wckEn).getOrElse(false.B)
52-
cg.mbist.readen := a.io.mbistCgCtl.map(_.rckEn).getOrElse(false.B)
53-
a.io.mbistCgCtl.foreach(_.wclk := cg.out_clock)
54-
a.io.mbistCgCtl.foreach(_.rclk := cg.out_clock)
55-
a.clock := clock
56-
})))
47+
if (withClockGate) {
48+
array.map(_.map(_.map(a => {
49+
val cg = Module(new MbistClockGateCell(extraHold))
50+
cg.E := io_en
51+
cg.dft.fromBroadcast(a.io.broadcast.getOrElse(0.U.asTypeOf(new SramBroadcastBundle)))
52+
cg.mbist.req := a.io.mbistCgCtl.map(_.en).getOrElse(false.B)
53+
cg.mbist.writeen := a.io.mbistCgCtl.map(_.wckEn).getOrElse(false.B)
54+
cg.mbist.readen := a.io.mbistCgCtl.map(_.rckEn).getOrElse(false.B)
55+
a.io.mbistCgCtl.foreach(_.wclk := cg.out_clock)
56+
a.io.mbistCgCtl.foreach(_.rclk := cg.out_clock)
57+
a.clock := clock
58+
})))
59+
}
5760

5861
// TODO: for now, all small SRAMs use the unified `io_en` signal for gating.
5962
// Theoretically, gating can be set based on whether the small SRAM is activated

0 commit comments

Comments
 (0)