Skip to content

Commit

Permalink
[ipemu] refactor to an single Probe to avoid using Record
Browse files Browse the repository at this point in the history
  • Loading branch information
Clo91eaf authored and sequencer committed Aug 9, 2024
1 parent 7b59526 commit 3be38a1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 55 deletions.
24 changes: 8 additions & 16 deletions ipemu/src/TestBench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -190,32 +190,24 @@ class TestBench(generator: SerializableModuleGenerator[T1, T1Parameter])

// Events for difftest and performance modeling

val laneProbes = dut.io.laneProbes.zipWithIndex.map {
case (p, idx) =>
val wire = Wire(p.cloneType).suggestName(s"lane${idx}Probe")
wire := probe.read(p)
wire
// Probes
val laneProbes = t1Probe.laneProbes.zipWithIndex.map {
case (lane, i) => lane.suggestName(s"lane${i}Probe")
}

val lsuProbe = probe.read(dut.io.lsuProbe).suggestName("lsuProbe")
val lsuProbe = t1Probe.lsuProbe.suggestName("lsuProbe")

val storeUnitProbe = lsuProbe.storeUnitProbe.suggestName("storeUnitProbe")

val otherUnitProbe = lsuProbe.otherUnitProbe.suggestName("otherUnitProbe")

val laneVrfProbes = dut.io.laneVrfProbes.zipWithIndex.map {
case (p, idx) =>
val wire = Wire(p.cloneType).suggestName(s"lane${idx}VrfProbe")
wire := probe.read(p)
wire
}

// vrf write
laneVrfProbes.zipWithIndex.foreach {
laneProbes.zipWithIndex.foreach {
case (lane, i) =>
when(lane.valid)(
val vrf = lane.vrfProbe.suggestName(s"lane${i}VrfProbe")
when(vrf.valid)(
printf(
cf"""{"event":"VrfWrite","issue_idx":${lane.requestInstruction},"vd":${lane.requestVd},"offset":${lane.requestOffset},"mask":"${lane.requestMask}%x","data":"${lane.requestData}%x","lane":$i,"cycle":${simulationTime}}\n"""
cf"""{"event":"VrfWrite","issue_idx":${vrf.requestInstruction},"vd":${vrf.requestVd},"offset":${vrf.requestOffset},"mask":"${vrf.requestMask}%x","data":"${vrf.requestData}%x","lane":$i,"cycle":${simulationTime}}\n"""
)
)
}
Expand Down
23 changes: 8 additions & 15 deletions t1/src/Lane.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,15 @@ class LaneWriteProbe(instructionIndexBits: Int) extends Bundle {

class LaneProbe(parameter: LaneParameter) extends Bundle {
val slots = Vec(parameter.chainingSize, new LaneSlotProbe(parameter.instructionIndexBits))
// @todo @Clo91eaf remove valid here, add stall := valid & !ready
val laneRequestValid: Bool = Bool()
// @todo remove it.
val laneRequestReady: Bool = Bool()
val laneRequestStall: Bool = Bool()
// @todo @Clo91eaf change to occupied for each slot.
val lastSlotOccupied: Bool = Bool()
// @todo replace it with VRFProbe
val vrfInstructionWriteReportReady: Bool = Bool()
val instructionFinished: UInt = UInt(parameter.chainingSize.W)
val instructionValid: UInt = UInt(parameter.chainingSize.W)

val crossWriteProbe: Vec[ValidIO[LaneWriteProbe]] = Vec(2, Valid(new LaneWriteProbe(parameter.instructionIndexBits)))

val vrfProbe: VRFProbe = new VRFProbe(parameter.vrfParam)
}

object LaneParameter {
Expand Down Expand Up @@ -314,11 +311,9 @@ class Lane(val parameter: LaneParameter) extends Module with SerializableModule[
val vrfReadyToStore: Bool = IO(Output(Bool()))

@public
val probe: LaneProbe = IO(Output(Probe(new LaneProbe(parameter))))
val probeWire: LaneProbe = Wire(new LaneProbe(parameter))
define(probe, ProbeValue(probeWire))
@public
val vrfProbe = IO(Output(Probe(new VRFProbe(parameter.vrfParam))))
val laneProbe = IO(Output(Probe(new LaneProbe(parameter))))
val probeWire = Wire(new LaneProbe(parameter))
define(laneProbe, ProbeValue(probeWire))

@public
val vrfAllocateIssue: Bool = IO(Output(Bool()))
Expand All @@ -328,7 +323,6 @@ class Lane(val parameter: LaneParameter) extends Module with SerializableModule[

/** VRF instantces. */
val vrf: Instance[VRF] = Instantiate(new VRF(parameter.vrfParam))
define(vrfProbe, vrf.probe)

/** TODO: review later
*/
Expand Down Expand Up @@ -1217,15 +1211,14 @@ class Lane(val parameter: LaneParameter) extends Module with SerializableModule[
tokenManager.topWriteDeq.bits := allVrfWriteAfterCheck(parameter.chainingSize).instructionIndex

// probe wire
probeWire.laneRequestValid := laneRequest.valid
probeWire.laneRequestReady := laneRequest.ready
probeWire.laneRequestStall := laneRequest.valid && !laneRequest.ready
probeWire.lastSlotOccupied := slotOccupied.last
probeWire.vrfInstructionWriteReportReady := vrf.instructionWriteReport.ready
probeWire.instructionFinished := instructionFinished
probeWire.instructionValid := instructionValid
probeWire.crossWriteProbe.zip(writeBusPort).foreach {case (pb, port) =>
pb.valid := port.deq.valid
pb.bits.writeTag := port.deq.bits.instructionIndex
pb.bits.writeMask := port.deq.bits.mask
}
probeWire.vrfProbe := probe.read(vrf.vrfProbe)
}
26 changes: 6 additions & 20 deletions t1/src/T1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ class T1Probe(parameter: T1Parameter) extends Bundle {
val instructionValid: UInt = UInt((parameter.chainingSize * 2).W)
// instruction index for check rd
val responseCounter: UInt = UInt(parameter.instructionIndexBits.W)
// probes
val lsuProbe: LSUProbe = new LSUProbe(parameter.lsuParameters)
val laneProbes: Vec[LaneProbe] = Vec(parameter.laneNumber, new LaneProbe(parameter.laneParam))
}

class T1Interface(parameter: T1Parameter) extends Record {
Expand All @@ -314,11 +317,7 @@ class T1Interface(parameter: T1Parameter) extends Record {
def highBandwidthLoadStorePort: AXI4RWIrrevocable = elements("highBandwidthLoadStorePort").asInstanceOf[AXI4RWIrrevocable]
def indexedLoadStorePort: AXI4RWIrrevocable = elements("indexedLoadStorePort").asInstanceOf[AXI4RWIrrevocable]
def om: Property[ClassType] = elements("om").asInstanceOf[Property[ClassType]]
// TODO: refactor to an single Probe to avoid using Record on the [[T1Interface]].
def lsuProbe: LSUProbe = elements("lsuProbe").asInstanceOf[LSUProbe]
def t1Probe: T1Probe = elements("t1Probe").asInstanceOf[T1Probe]
def laneProbes: Seq[LaneProbe] = Seq.tabulate(parameter.laneNumber)(i => elements(s"lane${i}Probe").asInstanceOf[LaneProbe])
def laneVrfProbes: Seq[VRFProbe] = Seq.tabulate(parameter.laneNumber)(i => elements(s"lane${i}VrfProbe").asInstanceOf[VRFProbe])
val elements: SeqMap[String, Data] = SeqMap.from(
Seq(
"clock" -> Input(Clock()),
Expand All @@ -328,15 +327,8 @@ class T1Interface(parameter: T1Parameter) extends Record {
"highBandwidthLoadStorePort" -> new AXI4RWIrrevocable(parameter.axi4BundleParameter),
"indexedLoadStorePort" -> new AXI4RWIrrevocable(parameter.axi4BundleParameter.copy(dataWidth=32)),
"om" -> Output(Property[AnyClassType]()),
"lsuProbe" -> Output(Probe(new LSUProbe(parameter.lsuParameters))),
"t1Probe" -> Output(Probe(new T1Probe(parameter))),
) ++
Seq.tabulate(parameter.laneNumber)(
i => s"lane${i}Probe" -> Output(Probe(new LaneProbe(parameter.laneParam)))
) ++
Seq.tabulate(parameter.laneNumber)(
i => s"lane${i}VrfProbe" -> Output(Probe(new VRFProbe(parameter.laneParam.vrfParam)))
)
)
)
}

Expand Down Expand Up @@ -1583,15 +1575,7 @@ class T1(val parameter: T1Parameter)
lane
}

laneVec.zipWithIndex.foreach { case (lane, index) =>
define(io.laneProbes(index), lane.probe)
define(io.laneVrfProbes(index), lane.vrfProbe)
}

omInstance.lanesIn := Property(laneVec.map(_.om.asAnyClassType))

define(io.lsuProbe, lsu._probe)

dataInWritePipeVec := VecInit(laneVec.map(_.writeQueueValid))

// 连lsu
Expand Down Expand Up @@ -1745,6 +1729,8 @@ class T1(val parameter: T1Parameter)
!slots.last.state.sMaskUnitExecution && !slots.last.state.idle,
indexToOH(slots.last.record.instructionIndex, parameter.chainingSize * 2)).asUInt
probeWire.responseCounter := responseCounter
probeWire.laneProbes.zip(laneVec).foreach { case (p, l) => p := probe.read(l.laneProbe) }
probeWire.lsuProbe := probe.read(lsu.lsuProbe)


// new V Request from core
Expand Down
4 changes: 2 additions & 2 deletions t1/src/lsu/LSU.scala
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ class LSU(param: LSUParameter) extends Module {
)

@public
val _probe = IO(Output(Probe(new LSUProbe(param))))
val lsuProbe = IO(Output(Probe(new LSUProbe(param))))
val probeWire = Wire(new LSUProbe(param))
define(_probe, ProbeValue(probeWire))
define(lsuProbe, ProbeValue(probeWire))

// read vrf
val otherTryReadVrf: UInt = Mux(otherUnit.vrfReadDataPorts.valid, otherUnit.status.targetLane, 0.U)
Expand Down
4 changes: 2 additions & 2 deletions t1/src/vrf/VRF.scala
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,9 @@ class VRF(val parameter: VRFParam) extends Module with SerializableModule[VRFPar
* Probe
*/
@public
val probe = IO(Output(Probe(new VRFProbe(parameter))))
val vrfProbe = IO(Output(Probe(new VRFProbe(parameter))))
val probeWire = Wire(new VRFProbe(parameter))
define(probe, ProbeValue(probeWire))
define(vrfProbe, ProbeValue(probeWire))

probeWire.valid := writePipe.valid
probeWire.requestVd := writePipe.bits.vd
Expand Down

0 comments on commit 3be38a1

Please sign in to comment.