Skip to content

Commit

Permalink
[t1emu] refactor t1 testbench
Browse files Browse the repository at this point in the history
  • Loading branch information
Clo91eaf committed Nov 7, 2024
1 parent ab80b1f commit 19d360e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
10 changes: 5 additions & 5 deletions difftest/offline_t1emu/src/json_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub(crate) enum JsonEvents {
issue_idx: u8,
cycle: u64,
},
VrfScoreboardReport {
VrfScoreboard {
count: u32,
issue_idx: u8,
cycle: u64,
Expand Down Expand Up @@ -122,7 +122,7 @@ pub struct MemoryWriteEvent {
pub cycle: u64,
}

pub struct VrfScoreboardReportEvent {
pub struct VrfScoreboardEvent {
pub count: u32,
pub issue_idx: u8,
pub cycle: u64,
Expand All @@ -141,7 +141,7 @@ pub(crate) trait JsonEventRunner {

fn peek_vrf_write(&mut self, vrf_write: &VrfWriteEvent) -> anyhow::Result<()>;

fn vrf_scoreboard_report(&mut self, report: &VrfScoreboardReportEvent) -> anyhow::Result<()>;
fn vrf_scoreboard(&mut self, report: &VrfScoreboardEvent) -> anyhow::Result<()>;

fn peek_memory_write(&mut self, memory_write: &MemoryWriteEvent) -> anyhow::Result<()>;

Expand Down Expand Up @@ -314,7 +314,7 @@ impl JsonEventRunner for SpikeRunner {
panic!("[{cycle}] cannot find se with instruction lsu_idx={lsu_idx}")
}

fn vrf_scoreboard_report(&mut self, report: &VrfScoreboardReportEvent) -> anyhow::Result<()> {
fn vrf_scoreboard(&mut self, report: &VrfScoreboardEvent) -> anyhow::Result<()> {
let count = report.count;
let issue_idx = report.issue_idx;
let cycle = report.cycle;
Expand All @@ -336,7 +336,7 @@ impl JsonEventRunner for SpikeRunner {
se.vrf_access_record.unretired_writes = Some(count - se.vrf_access_record.retired_writes);

info!(
"[{cycle}] VrfScoreboardReport: count={count}, issue_idx={issue_idx}, retired={} ({})",
"[{cycle}] VrfScoreboard: count={count}, issue_idx={issue_idx}, retired={} ({})",
se.vrf_access_record.retired_writes,
se.describe_insn()
);
Expand Down
2 changes: 1 addition & 1 deletion difftest/offline_t1rocketemu/src/json_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ impl JsonEventRunner for SpikeRunner {
se.vrf_access_record.unretired_writes = Some(count - se.vrf_access_record.retired_writes);

info!(
"[{cycle}] VrfScoreboardReport: count={count}, issue_idx={issue_idx}, retired={} ({})",
"[{cycle}] VrfScoreboard: count={count}, issue_idx={issue_idx}, retired={} ({})",
se.vrf_access_record.retired_writes,
se.describe_insn()
);
Expand Down
27 changes: 13 additions & 14 deletions t1emu/src/TestBench.scala
Original file line number Diff line number Diff line change
Expand Up @@ -153,25 +153,24 @@ class TestBench(val parameter: T1Parameter)
agent.io.gateWrite := false.B
}

// Events for difftest and performance modeling

// Probes
val laneProbes = t1Probe.laneProbes.zipWithIndex.map { case (lane, i) =>
lane.suggestName(s"lane${i}Probe")
// probes
val lsuProbe = t1Probe.lsuProbe.suggestName("lsuProbe")
val laneProbes = t1Probe.laneProbes.zipWithIndex.map { case (p, idx) =>
val wire = WireDefault(p).suggestName(s"lane${idx}Probe")
wire
}
val laneVrfProbes = t1Probe.laneProbes.map(_.vrfProbe).zipWithIndex.map { case (p, idx) =>
val wire = WireDefault(p).suggestName(s"lane${idx}VrfProbe")
wire
}

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

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

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

// vrf write
laneProbes.zipWithIndex.foreach { case (lane, i) =>
val vrf = lane.vrfProbe.suggestName(s"lane${i}VrfProbe")
when(vrf.valid)(
laneVrfProbes.zipWithIndex.foreach { case (lane, i) =>
when(lane.valid)(
printf(
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"""
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"""
)
)
}
Expand Down Expand Up @@ -227,7 +226,7 @@ class TestBench(val parameter: T1Parameter)
scoreboard.bits := scoreboard.bits + PopCount(writeEnq)
when(scoreboard.valid && !instructionValid(tag)) {
printf(
cf"""{"event":"VrfScoreboardReport","count":${scoreboard.bits},"issue_idx":${tag},"cycle":${simulationTime}}\n"""
cf"""{"event":"VrfScoreboard","count":${scoreboard.bits},"issue_idx":${tag},"cycle":${simulationTime}}\n"""
)
scoreboard.valid := false.B
}
Expand Down

0 comments on commit 19d360e

Please sign in to comment.