BusyTable.scala 980 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
package xiangshan.backend.rename

import chisel3._
import chisel3.util._
import xiangshan._

class BusyTable extends XSModule {
  val io = IO(new Bundle() {
    val flush = Input(Bool())
    // set preg state to busy
    val allocPregs = Vec(RenameWidth, Flipped(ValidIO(UInt(PhyRegIdxWidth.W))))
    // set preg state to ready
    val wbPregs = Vec(NRWritePorts, Flipped(ValidIO(UInt(PhyRegIdxWidth.W))))
    // read preg state
    val rfReadAddr = Vec(NRReadPorts, Input(UInt(PhyRegIdxWidth.W)))
    val pregRdy = Vec(NRReadPorts, Output(Bool()))
  })

  val table = RegInit(VecInit(Seq.fill(NRPhyRegs)(false.B)))

  for((raddr, rdy) <- io.rfReadAddr.zip(io.pregRdy)){
    rdy := !table(raddr)
  }

  for((alloc, i) <- io.allocPregs.zipWithIndex){
    when(alloc.valid){
      table(alloc.bits) := true.B
    }
  }

  for((wb, i) <- io.wbPregs.zipWithIndex){
    when(wb.valid){
      table(wb.bits) := false.B
    }
  }

  when(io.flush){
    table.foreach(_ := false.B)
  }
}