Skip to content

Commit

Permalink
Generalize Vec[TracedInstruction] to a TraceBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryz123 committed May 10, 2023
1 parent b727880 commit 85aca71
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/rocket/RocketCore.scala
Expand Up @@ -812,7 +812,7 @@ class Rocket(tile: RocketTile)(implicit p: Parameters) extends CoreModule()(p)
csr.io.rw.addr := wb_reg_inst(31,20)
csr.io.rw.cmd := CSR.maskCmd(wb_reg_valid, wb_ctrl.csr)
csr.io.rw.wdata := wb_reg_wdata
io.trace := csr.io.trace
io.trace.insns := csr.io.trace
for (((iobpw, wphit), bp) <- io.bpwatch zip wb_reg_wphit zip csr.io.bp) {
iobpw.valid(0) := wphit
iobpw.action := bp.control.action
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/tile/BaseTile.scala
Expand Up @@ -283,10 +283,10 @@ abstract class BaseTile private (val crossing: ClockCrossingType, q: Parameters)

protected def traceRetireWidth = tileParams.core.retireWidth
/** Node for the core to drive legacy "raw" instruction trace. */
val traceSourceNode = BundleBridgeSource(() => Vec(traceRetireWidth, new TracedInstruction()))
private val traceNexus = BundleBroadcast[Vec[TracedInstruction]]() // backwards compatiblity; not blocked during stretched reset
val traceSourceNode = BundleBridgeSource(() => new TraceBundle)
private val traceNexus = BundleBroadcast[TraceBundle]() // backwards compatiblity; not blocked during stretched reset
/** Node for external consumers to source a legacy instruction trace from the core. */
val traceNode: BundleBridgeOutwardNode[Vec[TracedInstruction]] = traceNexus := traceSourceNode
val traceNode: BundleBridgeOutwardNode[TraceBundle] = traceNexus := traceSourceNode

protected def traceCoreParams = new TraceCoreParams()
/** Node for core to drive instruction trace conforming to RISC-V Processor Trace spec V1.0 */
Expand Down
7 changes: 6 additions & 1 deletion src/main/scala/tile/Core.scala
Expand Up @@ -150,6 +150,11 @@ class CoreInterrupts(implicit p: Parameters) extends TileInterrupts()(p) {
val buserror = tileParams.beuAddr.map(a => Bool())
}

// This is a raw commit trace from the core, not the TraceCoreInterface
class TraceBundle(implicit val p: Parameters) extends Bundle with HasCoreParameters {
val insns = Vec(coreParams.retireWidth, new TracedInstruction)
}

trait HasCoreIO extends HasTileParameters {
implicit val p: Parameters
val io = new CoreBundle()(p) {
Expand All @@ -161,7 +166,7 @@ trait HasCoreIO extends HasTileParameters {
val ptw = new DatapathPTWIO().flip
val fpu = new FPUCoreIO().flip
val rocc = new RoCCCoreIO().flip
val trace = Vec(coreParams.retireWidth, new TracedInstruction).asOutput
val trace = Output(new TraceBundle)
val bpwatch = Vec(coreParams.nBreakpoints, new BPWatch(coreParams.retireWidth)).asOutput
val cease = Bool().asOutput
val wfi = Bool().asOutput
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/tile/TilePRCIDomain.scala
Expand Up @@ -50,13 +50,13 @@ abstract class TilePRCIDomain[T <: BaseTile](
private val traceSignalName = "trace"
private val traceCoreSignalName = "tracecore"
/** Node to broadcast legacy "raw" instruction trace while surpressing it during (async) reset. */
val traceNode: BundleBridgeIdentityNode[Vec[TracedInstruction]] = BundleBridgeNameNode(traceSignalName)
val traceNode: BundleBridgeIdentityNode[TraceBundle] = BundleBridgeNameNode(traceSignalName)
/** Node to broadcast standardized instruction trace while surpressing it during (async) reset. */
val traceCoreNode: BundleBridgeIdentityNode[TraceCoreInterface] = BundleBridgeNameNode(traceCoreSignalName)

/** Function to handle all trace crossings when tile is instantiated inside domains */
def crossTracesOut(): Unit = this {
val traceNexusNode = BundleBridgeBlockDuringReset[Vec[TracedInstruction]](
val traceNexusNode = BundleBridgeBlockDuringReset[TraceBundle](
resetCrossingType = crossingParams.resetCrossingType,
name = Some(traceSignalName))
traceNode :*= traceNexusNode := tile.traceNode
Expand Down
10 changes: 10 additions & 0 deletions src/main/scala/util/Blockable.scala
Expand Up @@ -4,6 +4,8 @@ package freechips.rocketchip.util

import chisel3._
import chisel3.util.DecoupledIO
import freechips.rocketchip.tile.{TraceBundle}
import freechips.rocketchip.rocket.{TracedInstruction}

/** A trait supplying a function allowing the contents of data
* to be supressed for a time period, i.e. be blocked.
Expand Down Expand Up @@ -59,4 +61,12 @@ object Blockable {
blocked
}
}

implicit object BlockableTraceBundle extends Blockable[TraceBundle] {
def blockWhile(enable_blocking: Bool, data: TraceBundle) = {
val blocked = Wire(chiselTypeOf(data))
blocked.insns := implicitly[Blockable[Vec[TracedInstruction]]].blockWhile(enable_blocking, data.insns)
blocked
}
}
}

0 comments on commit 85aca71

Please sign in to comment.