未验证 提交 e6e4a58d 编写于 作者: Y Yinan Xu 提交者: GitHub

WaitTable: use 2-bit counter and optimize XORFold logic (#681)

上级 f50aa934
......@@ -133,8 +133,10 @@ object GetOddBits {
}
object XORFold {
def apply(input: UInt, reswidth: Int): UInt = {
require(input.getWidth*2>=reswidth)
input(reswidth-1, 0) ^ input(2*reswidth-1, reswidth)
def apply(input: UInt, resWidth: Int): UInt = {
require(resWidth > 0)
val fold_range = input.getWidth / resWidth
val value = ZeroExt(input, fold_range * resWidth)
ParallelXOR((0 until fold_range).map(i => value(i*resWidth+resWidth-1, i*resWidth)))
}
}
\ No newline at end of file
}
......@@ -36,8 +36,8 @@ class DecodeStage extends XSModule {
}
waittable.io.csrCtrl <> io.csrCtrl
val loadWaitBitSet = PopCount(VecInit((0 until DecodeWidth).map(i => waittable.io.rdata(i) && io.out(i).fire())))
XSPerf("loadWaitBitSet", loadWaitBitSet, acc = true) // rollback redirect generated
val loadWaitBitSet = PopCount(io.out.map(o => o.fire() && o.bits.cf.loadWaitBit))
XSPerf("loadWaitBitSet", loadWaitBitSet)
val hasValid = VecInit(io.in.map(_.valid)).asUInt.orR
XSPerf("utilization", PopCount(io.in.map(_.valid)))
......
......@@ -21,19 +21,19 @@ class WaitTable extends XSModule with WaitTableParameters {
val csrCtrl = Input(new CustomCSRCtrlIO)
})
val data = Reg(Vec(WaitTableSize, Bool())) // init val false.B
val data = RegInit(VecInit(Seq.fill(WaitTableSize)(0.U(2.W))))
val resetCounter = RegInit(0.U(ResetTimeMax2Pow.W))
resetCounter := resetCounter + 1.U
// read ports
for (i <- 0 until DecodeWidth) {
io.rdata(i) := (data(io.raddr(i)) || io.csrCtrl.no_spec_load) && !io.csrCtrl.lvpred_disable
io.rdata(i) := (data(io.raddr(i))(1) || io.csrCtrl.no_spec_load) && !io.csrCtrl.lvpred_disable
}
// write ports (with priority)
(0 until StorePipelineWidth).map(i => {
when(io.update(i).valid){
data(io.update(i).waddr) := io.update(i).wdata
data(io.update(i).waddr) := Cat(data(io.update(i).waddr)(0), true.B)
}
})
......@@ -41,7 +41,7 @@ class WaitTable extends XSModule with WaitTableParameters {
// reset period: ResetTimeMax2Pow
when(resetCounter(ResetTimeMax2Pow-1, ResetTimeMin2Pow)(RegNext(io.csrCtrl.waittable_timeout))) {
for (j <- 0 until WaitTableSize) {
data(j) := false.B
data(j) := 0.U
}
resetCounter:= 0.U
}
......@@ -53,5 +53,5 @@ class WaitTable extends XSModule with WaitTableParameters {
}
}
XSPerf("wait_table_bit_set", PopCount(data))
XSPerf("wait_table_bit_set", PopCount(data.map(d => d(1))))
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册