From be3385dfda4133f26472d43148b9edef7d942ae1 Mon Sep 17 00:00:00 2001 From: qinjun-li Date: Mon, 18 Nov 2024 12:25:12 +0800 Subject: [PATCH] [rocketv] change icache axi width blockBytes -> fetchBytes. --- rocketv/src/Frontend.scala | 2 +- rocketv/src/ICache.scala | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/rocketv/src/Frontend.scala b/rocketv/src/Frontend.scala index 2aad99178..1ccdd1e88 100644 --- a/rocketv/src/Frontend.scala +++ b/rocketv/src/Frontend.scala @@ -113,7 +113,7 @@ case class FrontendParameter( exec = exec, sideEffects = sideEffects ) - val rowBits: Int = blockBytes * 8 + val rowBits: Int = fetchBytes * 8 val instructionFetchParameter: AXI4BundleParameter = AXI4BundleParameter( idWidth = 1, dataWidth = rowBits, diff --git a/rocketv/src/ICache.scala b/rocketv/src/ICache.scala index 48ac2ea34..fc1f84621 100644 --- a/rocketv/src/ICache.scala +++ b/rocketv/src/ICache.scala @@ -41,7 +41,7 @@ case class ICacheParameter( val hasUncorrekoctable: Boolean = itimBaseAddr.nonEmpty && dataCode.canDetect val isDM: Boolean = nWays == 1 // axi data with - val rowBits: Int = blockBytes * 8 + val rowBits: Int = fetchBytes * 8 val refillCycles: Int = blockBytes * 8 / rowBits val blockOffBits: Int = log2Up(blockBytes) val idxBits: Int = log2Up(nSets) @@ -542,8 +542,13 @@ class ICache(val parameter: ICacheParameter) for ((data_array, i) <- icacheDataSRAM.zipWithIndex) { /** bank match (vaddr[2]) */ - def wordMatch(addr: UInt): Bool = - addr(log2Ceil(io.instructionFetchAXI.r.bits.data.getWidth / 8) - 1, log2Ceil(wordBits / 8)) === i.U + def wordMatch(addr: UInt): Bool = { + if (io.instructionFetchAXI.r.bits.data.getWidth == wordBits) { true.B } + else { + addr(log2Ceil(io.instructionFetchAXI.r.bits.data.getWidth / 8) - 1, log2Ceil(wordBits / 8)) === i.U + } + } + // TODO: if we have last? do we need refillCycles? def row(addr: UInt) = addr(untagBits - 1, blockOffBits - log2Ceil(refillCycles)) @@ -792,7 +797,7 @@ class ICache(val parameter: ICacheParameter) arQueue.enq.bits.id := 0.U arQueue.enq.bits.addr := (refill_paddr >> blockOffBits) << blockOffBits arQueue.enq.bits.size := log2Up(parameter.blockBytes).U - arQueue.enq.bits.len := 0.U + arQueue.enq.bits.len := (parameter.blockBytes * 8 / parameter.instructionFetchParameter.dataWidth - 1).U arQueue.enq.bits.burst := 1.U io.instructionFetchAXI.ar <> arQueue.deq