Skip to content

Commit

Permalink
Fix wb dead lock
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolu1990 committed Mar 11, 2024
1 parent 72225c4 commit 8984918
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/main/scala/vexiiriscv/execute/lsu/LsuL1Plugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,9 @@ class LsuL1Plugin(val lane : ExecuteLaneService,
val loadDataHazard = LOAD && (bankNotRead || writeToReadHazard)
val storeHazard = (STORE || FLUSH) && (!bankWriteReservation.win || !reservation.win)

// A few explanation : Some things have to be accurate, while some other can be deflected / ignored, especially
// when is need some shared ressources.
// For instance, a load miss may not trigger a refill, a flush may hit but may not trigger a flush
val hazardReg = RegNext(this(HAZARD) && lane.isFreezed()) init(False)
HAZARD := hazardReg || loadDataHazard || refillHazard || storeHazard
MISS := !HAZARD && !WAYS_HIT && !FLUSH
Expand Down
10 changes: 6 additions & 4 deletions src/main/scala/vexiiriscv/execute/lsu/LsuPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ class LsuPlugin(var layer : LaneLayer,

val holdHart = new Area{
val wordPerLine = LsuL1.LINE_BYTES*8/XLEN
assert(storeBufferOps >= wordPerLine)
val waitIt = RegInit(False) clearWhen (slotsFree && ops.occupancy <= storeBufferOps - wordPerLine)
val threshold = Math.max(storeBufferOps - wordPerLine, storeBufferOps/2)
val waitIt = RegInit(False) clearWhen (slotsFree && ops.occupancy <= threshold)
host[DispatchPlugin].haltDispatchWhen(waitIt)
}

Expand Down Expand Up @@ -305,8 +305,10 @@ class LsuPlugin(var layer : LaneLayer,
}

val wb = withStoreBuffer generate new Area {
val isHead = storeBuffer.pop.ptr === storeBuffer.ops.freePtr
val flush = storeBuffer.waitL1.valid && !isHead
val port = ports.addRet(Stream(LsuL1Cmd()))
port.valid := storeBuffer.pop.valid && !storeBuffer.waitL1.valid
port.valid := storeBuffer.pop.valid && !storeBuffer.waitL1.valid && !flush
port.address := storeBuffer.pop.op.address.resized
port.size := storeBuffer.pop.op.size
port.load := False
Expand All @@ -315,7 +317,7 @@ class LsuPlugin(var layer : LaneLayer,
port.fromFlush := False
port.fromAccess := False
port.fromStoreBuffer := True
storeBuffer.pop.ready := port.ready
storeBuffer.pop.ready := port.ready || flush
}

val arbiter = StreamArbiterFactory().noLock.lowerFirst.buildOn(ports)
Expand Down

0 comments on commit 8984918

Please sign in to comment.