Skip to content

Commit

Permalink
[rocketv] add fpu reg write probe
Browse files Browse the repository at this point in the history
  • Loading branch information
Clo91eaf committed Aug 16, 2024
1 parent 5e639ee commit 6fdeb87
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
18 changes: 17 additions & 1 deletion rocketv/src/FPU.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
package org.chipsalliance.rocketv

import chisel3._
import chisel3.experimental.hierarchy.{Instance, Instantiate, instantiable}
import chisel3.experimental.hierarchy.{instantiable, Instance, Instantiate}
import chisel3.experimental.{BaseModule, SerializableModule, SerializableModuleParameter}
import chisel3.probe.{define, Probe, ProbeValue}
import chisel3.util._
import chisel3.util.circt.ClockGate

class FPUProbe(param: FPUParameter) extends Bundle {
val rfWen: Bool = Bool()
val rfWaddr: UInt = UInt(5.W)
val rfWdata: UInt = UInt((param.fLen + 1).W)
}

object FPUParameter {
implicit def rwP: upickle.default.ReadWriter[FPUParameter] = upickle.default.macroRW[FPUParameter]
}
Expand All @@ -32,6 +39,7 @@ class FPUInterface(parameter: FPUParameter) extends Bundle {
val core = new FPUCoreIO(parameter.hartIdLen, parameter.xLen, parameter.fLen)
val cp_req = Flipped(Decoupled(new FPInput(parameter.fLen))) //cp doesn't pay attn to kill sigs
val cp_resp = Decoupled(new FPResult(parameter.fLen))
val fpuProbe = Output(Probe(new FPUProbe(parameter)))
}

// TODO: all hardfloat module can be replaced by DWBB?
Expand Down Expand Up @@ -415,6 +423,14 @@ class FPU(val parameter: FPUParameter)
wen.orR || divSqrt_inFlight || // post-WB stage
io.core.dmem_resp_val // load writeback

// probe defination
val probeWire = Wire(new FPUProbe(parameter))
define(io.fpuProbe, ProbeValue(probeWire))

probeWire.rfWen := load_wb || (!wbInfo(0).cp && wen(0)) || divSqrt_wen
probeWire.rfWaddr := Mux(load_wb, load_wb_tag, waddr)
probeWire.rfWdata := Mux(load_wb, recode(load_wb_data, load_wb_typeTag), wdata)

} // leaving gated-clock domain
val fpuImpl = withClockAndReset(gated_clock, io.reset) { new FPUImpl }
}
Expand Down
6 changes: 5 additions & 1 deletion t1rocket/src/T1RocketTile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import chisel3.util.experimental.BitSet
import chisel3.util.log2Ceil
import chisel3.probe.{Probe, ProbeValue, define}
import org.chipsalliance.amba.axi4.bundle.{AXI4BundleParameter, AXI4ROIrrevocable, AXI4RWIrrevocable}
import org.chipsalliance.rocketv.{BHTParameter, FPU, FPUParameter, Frontend, FrontendParameter, HellaCache, HellaCacheArbiter, HellaCacheArbiterParameter, HellaCacheParameter, PTW, PTWParameter, Rocket, RocketParameter, RocketTileParameter, RocketProbe}
import org.chipsalliance.rocketv.{BHTParameter, FPU, FPUParameter, Frontend, FrontendParameter, HellaCache, HellaCacheArbiter, HellaCacheArbiterParameter, HellaCacheParameter, PTW, PTWParameter, Rocket, RocketParameter, RocketTileParameter, RocketProbe, FPUProbe}
import org.chipsalliance.rvdecoderdb.Instruction
import org.chipsalliance.t1.rtl.decoder.T1CustomInstruction
import org.chipsalliance.t1.rtl.vrf.RamType
Expand Down Expand Up @@ -426,6 +426,7 @@ case class T1RocketTileParameter(

class T1RocketProbe(parameter: T1RocketTileParameter) extends Bundle {
val rocketProbe: RocketProbe = Output(new RocketProbe(parameter.rocketParameter))
val fpuProbe: Option[FPUProbe] = parameter.fpuParameter.map(param => Output(new FPUProbe(param)))
val t1Probe: T1Probe = Output(new T1Probe(parameter.t1Parameter))
}

Expand Down Expand Up @@ -559,4 +560,7 @@ class T1RocketTile(val parameter: T1RocketTileParameter)
define(io.t1RocketProbe, ProbeValue(probeWire))
probeWire.rocketProbe := probe.read(rocket.io.rocketProbe)
probeWire.t1Probe := probe.read(t1.io.t1Probe)
probeWire.fpuProbe.foreach { fpuProbe =>
fpuProbe := probe.read(fpu.get.io.fpuProbe)
}
}
9 changes: 9 additions & 0 deletions t1rocketemu/src/TestBench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ class TestBench(generator: SerializableModuleGenerator[T1RocketTile, T1RocketTil
)
)

// [[option]] rocket fpu reg write
t1RocketProbe.fpuProbe.foreach { fpu =>
when(fpu.rfWen)(
printf(
cf"""{"event":"RegWrite","idx":${fpu.rfWaddr},"data":"${fpu.rfWdata}%x","cycle":${simulationTime}}\n"""
)
)
}

// t1 vrf write
laneVrfProbes.zipWithIndex.foreach {
case (lane, i) =>
Expand Down

0 comments on commit 6fdeb87

Please sign in to comment.