Skip to content

Commit

Permalink
FTB(timing): delay replacer update on read (OpenXiangShan#2227)
Browse files Browse the repository at this point in the history
* FTB: postpone read replacer access

this helps with timing

* FTB: add comments about replace logic
  • Loading branch information
eastonman authored Aug 23, 2023
1 parent 0e8170d commit 21bd600
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main/scala/xiangshan/frontend/FTB.scala
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,18 @@ class FTB(implicit p: Parameters) extends BasePredictor with FTBParams with BPUU
read_way.valid := hit
read_way.bits := hit_way

touch_set(0) := Mux(write_way.valid, write_set, read_set)

touch_way(0).valid := write_way.valid || read_way.valid
touch_way(0).bits := Mux(write_way.valid, write_way.bits, read_way.bits)
// Read replacer access is postponed for 1 cycle
// this helps timing
touch_set(0) := Mux(write_way.valid, write_set, RegNext(read_set))
touch_way(0).valid := write_way.valid || RegNext(read_way.valid)
touch_way(0).bits := Mux(write_way.valid, write_way.bits, RegNext(read_way.bits))

replacer.access(touch_set, touch_way)

// Select the update allocate way
// Selection logic:
// 1. if any entries within the same index is not valid, select it
// 2. if all entries is valid, use replacer
def allocWay(valids: UInt, idx: UInt): UInt = {
if (numWays > 1) {
val w = Wire(UInt(log2Up(numWays).W))
Expand Down

0 comments on commit 21bd600

Please sign in to comment.