Skip to content

Commit

Permalink
[rtl] fix unaligned vl for load unit.
Browse files Browse the repository at this point in the history
  • Loading branch information
qinjun-li committed Jan 25, 2024
1 parent e7ee8cd commit 6c8266a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions t1/src/lsu/LoadUnit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ class LoadUnit(param: MSHRParam) extends StrideBase(param) with LSUPublic {

val alignedDequeueValid: Bool =
unalignedCacheLine.valid &&
// 只有在base address 对齐的时候才需要推出最后一条访问的cache line
(dataValid || ((unalignedCacheLine.bits.index === cacheLineNumberReg) && baseAddressAlignedReg))
// 只有在 vlMisaligned || base address 对齐的时候才需要推出最后一条访问的cache line
(dataValid || ((unalignedCacheLine.bits.index === cacheLineNumberReg) && (vlMisalignedReg || baseAddressAlignedReg)))
// update unalignedCacheLine
when(unalignedEnqueueFire) {
unalignedCacheLine.bits.data := nextData
Expand Down
5 changes: 4 additions & 1 deletion t1/src/lsu/StrideBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,15 @@ abstract class StrideBase(param: MSHRParam) extends Module {
val bytePerInstruction = ((nFiled * csrInterface.vl) << lsuRequest.bits.instructionInformation.eew).asUInt

val baseAddressAligned: Bool = !lsuRequest.bits.rs1Data(param.cacheLineBits - 1, 0).orR
val vlMisaligned: Bool = bytePerInstruction(param.cacheLineBits - 1, 0).orR

/** How many cache lines will be accessed by this instruction
* nFiled * vl * (2 ** eew) / 32
*/
val lastCacheLineIndex: UInt = (bytePerInstruction >> param.cacheLineBits).asUInt +
bytePerInstruction(param.cacheLineBits - 1, 0).orR - baseAddressAligned
vlMisaligned - baseAddressAligned

val vlMisalignedReg: Bool = RegEnable(vlMisaligned, false.B, lsuRequest.valid)

val cacheLineNumberReg: UInt = RegEnable(lastCacheLineIndex, 0.U, lsuRequest.valid)
}

0 comments on commit 6c8266a

Please sign in to comment.