Skip to content

Commit

Permalink
Merge pull request #2969 from riscv-zju/master
Browse files Browse the repository at this point in the history
Bind Verilog path with EICG_wrapper
  • Loading branch information
sequencer authored May 12, 2022
2 parents 850e1d5 + a44ec9e commit 38d62d1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/scala/subsystem/Configs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ class WithBootROMFile(bootROMFile: String) extends Config((site, here, up) => {
case BootROMLocated(x) => up(BootROMLocated(x), site).map(_.copy(contentFileName = bootROMFile))
})

class WithClockGateModel(file: String = "/vsrc/EICG_wrapper.v") extends Config((site, here, up) => {
case ClockGateModelFile => Some(file)
})

class WithSynchronousRocketTiles extends Config((site, here, up) => {
case RocketCrossingKey => up(RocketCrossingKey, site) map { r =>
r.copy(crossingType = SynchronousCrossing())
Expand Down
16 changes: 15 additions & 1 deletion src/main/scala/util/ClockGate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@
package freechips.rocketchip.util

import chisel3._
import chisel3.util.{HasBlackBoxResource, HasBlackBoxPath}
import freechips.rocketchip.config.{Field, Parameters}

import java.nio.file.{Files, Paths}

case object ClockGateImpl extends Field[() => ClockGate](() => new EICG_wrapper)
case object ClockGateModelFile extends Field[Option[String]](None)

abstract class ClockGate extends BlackBox {
abstract class ClockGate extends BlackBox
with HasBlackBoxResource with HasBlackBoxPath {
val io = IO(new Bundle{
val in = Input(Clock())
val test_en = Input(Bool())
val en = Input(Bool())
val out = Output(Clock())
})

def addVerilogResource(vsrc: String): Unit = {
if (Files.exists(Paths.get(vsrc)))
addPath(vsrc)
else
addResource(vsrc)
}
}

object ClockGate {
Expand All @@ -23,6 +35,8 @@ object ClockGate {
name: Option[String] = None)(implicit p: Parameters): Clock = {
val cg = Module(p(ClockGateImpl)())
name.foreach(cg.suggestName(_))
p(ClockGateModelFile).map(cg.addVerilogResource(_))

cg.io.in := in
cg.io.test_en := false.B
cg.io.en := en
Expand Down

0 comments on commit 38d62d1

Please sign in to comment.