From 7e0a6dfd4a850c9364b09a883c4238f57731bb09 Mon Sep 17 00:00:00 2001 From: qinjun-li Date: Mon, 8 Jul 2024 20:52:01 +0800 Subject: [PATCH] [difftest] fix test bench. --- ipemu/src/TestBench.scala | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ipemu/src/TestBench.scala b/ipemu/src/TestBench.scala index d999c3575..4ebc956ca 100644 --- a/ipemu/src/TestBench.scala +++ b/ipemu/src/TestBench.scala @@ -6,7 +6,7 @@ package org.chipsalliance.t1.ipemu import chisel3._ import chisel3.experimental.SerializableModuleGenerator import chisel3.experimental.dataview.DataViewable -import chisel3.util.{Valid, log2Ceil} +import chisel3.util.{UIntToOH, Valid, log2Ceil} import chisel3.util.circt.dpi.{RawClockedNonVoidFunctionCall, RawClockedVoidFunctionCall, RawUnlockedNonVoidFunctionCall} import org.chipsalliance.amba.axi4.bundle._ import org.chipsalliance.t1.ipemu.dpi._ @@ -167,13 +167,12 @@ class TestBench(generator: SerializableModuleGenerator[T1, T1Parameter]) extends when(lsuProbe.reqEnq.orR)(printf(cf"""{"event":"LsuEnq","enq":${lsuProbe.reqEnq},"cycle": ${simulationTime}}\n""")) // allocate 2 * chainingSize scoreboards - val vrfWriteScoreboard = Seq.tabulate(2 * dut.parameter.chainingSize) { _ => RegInit(0.U.asTypeOf(Valid(UInt(16.W))))} - when(dut.request.fire) { - val scoreboard: Valid[UInt] = VecInit(vrfWriteScoreboard)(t1Probe.instructionCounter) - scoreboard.valid := true.B - assert(!scoreboard.valid) - scoreboard.bits := 0.U - } + val vrfWriteScoreboard: Seq[Valid[UInt]] = Seq.tabulate(2 * dut.parameter.chainingSize) { _ => RegInit(0.U.asTypeOf(Valid(UInt(16.W))))} + vrfWriteScoreboard.foreach(scoreboard => dontTouch(scoreboard)) + val instructionValid = + (laneProbes.map(laneProbe => laneProbe.instructionValid) :+ + lsuProbe.lsuInstructionValid :+ t1Probe.instructionValid).reduce(_ | _) + val scoreboardEnq = Mux(dut.request.fire, UIntToOH(t1Probe.instructionCounter), 0.U((2 * dut.parameter.chainingSize).W)) vrfWriteScoreboard.zipWithIndex.foreach { case (scoreboard, tag) => // always equal to array index scoreboard.bits := @@ -185,15 +184,16 @@ class TestBench(generator: SerializableModuleGenerator[T1, T1Parameter]) extends // vrf write from Sequencer Some(t1Probe.writeQueueEnq.bits === tag.U && t1Probe.writeQueueEnq.valid) ).reduce[UInt](_ + _) - - val instructionValid = - (laneProbes.map(laneProbe => laneProbe.instructionValid) :+ - lsuProbe.lsuInstructionValid :+ t1Probe.instructionValid).reduce(_ | _) val tagTruncation: Int = (1 << log2Ceil(dut.parameter.chainingSize)) - 1 when(scoreboard.valid && !instructionValid(tag & tagTruncation)){ printf(cf"""{"event":"VrfScoreboardReport","count":${scoreboard.bits},"tag":${tag},"cycle": ${simulationTime}}\n""") scoreboard.valid := false.B } + when(scoreboardEnq(tag)) { + scoreboard.valid := true.B + assert(!scoreboard.valid) + scoreboard.bits := 0.U + } } } }