From 8cdbc81bddcd4871ee61ca754072e65143f2d2bb Mon Sep 17 00:00:00 2001 From: Hansung Kim Date: Mon, 8 May 2023 14:26:05 -0700 Subject: [PATCH] Only write in MemTraceLogger when TL fire Without this we log extraneous lines that were valid but not transacted with the downstream as it was not ready, which affects validity of memtrace testing. --- src/main/scala/tilelink/Coalescing.scala | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/scala/tilelink/Coalescing.scala b/src/main/scala/tilelink/Coalescing.scala index 62c0473..0addef1 100644 --- a/src/main/scala/tilelink/Coalescing.scala +++ b/src/main/scala/tilelink/Coalescing.scala @@ -1334,7 +1334,9 @@ class MemTraceLogger( // requests on TL A channel // - req.valid := tlIn.a.valid + // Only log trace when fired, e.g. both upstream and downstream is ready + // and transaction happened. + req.valid := tlIn.a.fire req.size := tlIn.a.bits.size req.is_store := TLUtils.AOpcodeIsStore(tlIn.a.bits.opcode) req.source := tlIn.a.bits.source @@ -1378,7 +1380,9 @@ class MemTraceLogger( // responses on TL D channel // - resp.valid := tlOut.d.valid + // Only log trace when fired, e.g. both upstream and downstream is ready + // and transaction happened. + resp.valid := tlOut.d.fire resp.size := tlOut.d.bits.size resp.is_store := TLUtils.DOpcodeIsStore(tlOut.d.bits.opcode) resp.source := tlOut.d.bits.source @@ -1412,7 +1416,7 @@ class MemTraceLogger( // // This is a clunky workaround of the fact that Chisel doesn't allow partial // assignment to a bitfield range of a wide signal. - def flattenTrace(traceLogIO: Bundle with HasTraceLine, perLane: Vec[TraceLine]) = { + def flattenTrace(simIO: Bundle with HasTraceLine, perLane: Vec[TraceLine]) = { // these will get optimized out val vecValid = Wire(Vec(numLanes, chiselTypeOf(perLane(0).valid))) val vecSource = Wire(Vec(numLanes, chiselTypeOf(perLane(0).source))) @@ -1428,12 +1432,12 @@ class MemTraceLogger( vecSize(i) := l.size vecData(i) := l.data } - traceLogIO.valid := vecValid.asUInt - traceLogIO.source := vecSource.asUInt - traceLogIO.address := vecAddress.asUInt - traceLogIO.is_store := vecIsStore.asUInt - traceLogIO.size := vecSize.asUInt - traceLogIO.data := vecData.asUInt + simIO.valid := vecValid.asUInt + simIO.source := vecSource.asUInt + simIO.address := vecAddress.asUInt + simIO.is_store := vecIsStore.asUInt + simIO.size := vecSize.asUInt + simIO.data := vecData.asUInt } if (simReq.isDefined) {