提交 84a16e99 编写于 作者: Z zhanglinjuan

Merge branch 'dev-rs' into dev-prefetcher

......@@ -143,32 +143,31 @@ class ReservationStationCtrl
val issFire = Wire(Bool())
val moveMask = WireInit(0.U(iqSize.W))
val selectMask = WireInit(VecInit((0 until iqSize).map(i => readyIdxQue(i))))
val haveBubble = Wire(Bool())
// val selIdx = ParallelMux(selectMask zip idxQueue) // NOTE: the idx in the idxQueue
val (selPtr, haveReady) = PriorityEncoderWithFlag(selectMask) // NOTE: the idx of idxQueue
val selIdx = idxQueue(selPtr)
val selIdxReg = RegNext(selIdx) // NOTE: may dup with other signal, fix it later
val redSel = redVec(selIdx)
val selValid = !redSel && haveReady && !haveBubble
val selValid = !redSel && haveReady
val selReg = RegNext(selValid)
val selPtrReg = RegNext(Mux(moveMask(selPtr), selPtr-1.U, selPtr)) // TODO: deal with the long latency
val selPtrReg = RegNext(Mux(moveMask(selPtr), selPtr-1.U, selPtr))
// sel bubble
val bubMask = WireInit(VecInit((0 until iqSize).map(i => emptyIdxQue(i))))
// val bubIdx = ParallelMux(bubMask zip idxQueue) // NOTE: the idx in the idxQueue
val (bubPtr, findBubble) = PriorityEncoderWithFlag(bubMask) // NOTE: the idx of the idxQueue
haveBubble := findBubble && (bubPtr < tailPtr.asUInt)
val haveBubble = findBubble && (bubPtr < tailPtr.asUInt)
val bubIdx = idxQueue(bubPtr)
val bubIdxReg = RegNext(bubIdx) // NOTE: may dup with other signal, fix it later
val bubValid = haveBubble
val bubValid = haveBubble && (if (feedback) true.B else !selValid)
val bubReg = RegNext(bubValid)
val bubPtrReg = RegNext(Mux(moveMask(bubPtr), bubPtr-1.U, bubPtr)) // TODO: deal with the long latency
val bubPtrReg = RegNext(Mux(moveMask(bubPtr), bubPtr-1.U, bubPtr))
// deq
// TODO: mem's rs will issue but not deq( the bub), so just divide issue and deq
// TODO: when need feadback, only deq when becomes bubble
val dequeue = if (feedback) bubReg else bubReg || issFire
val deqPtr = Mux(bubReg, bubPtrReg, selPtrReg)
val dequeue = if (feedback) bubReg
else bubReg || issFire
val deqPtr = if (feedback) bubPtrReg
else Mux(selReg, selPtrReg, bubPtrReg)
moveMask := {
(Fill(iqSize, 1.U(1.W)) << deqPtr)(iqSize-1, 0)
} & Fill(iqSize, dequeue)
......@@ -184,32 +183,18 @@ class ReservationStationCtrl
}
when (selValid) {
stateQueue(selIdx) := s_selected
// TODO: may have long latency
}
when (haveBubble) {
when (bubValid) {
stateQueue(bubIdx) := s_bubble
}
when (stateQueue(selIdxReg) === s_selected) {
when (io.data.fuReady) {
if (feedback) {
stateQueue(selIdxReg) := s_wait
} else {
stateQueue(selIdxReg) := s_idle
}
}.otherwise { stateQueue(selIdxReg) := s_valid } // fu is not ready and re-select next cycle
}
when (stateQueue(bubIdxReg) === s_bubble) {
stateQueue(bubIdxReg) := s_idle // move the bubble to the last positon
}
// redirect and feedback && wakeup
for (i <- 0 until iqSize) {
// replay
val cnt = cntQueue(i)
when (stateQueue(i) === s_replay) {
cnt := cnt - 1.U
when (cnt === 0.U) { stateQueue(i) := s_valid }
.otherwise { cnt := cnt - 1.U }
}
// feedback
when (fbMatchVec(i)) {
......@@ -224,6 +209,20 @@ class ReservationStationCtrl
XSDebug(p"srcHit: i:${i.U} j:${j.U} src:${srcQueue(i)(j)}\n")
}
}
// mask last selectet slot and deal with the mask
// TODO: state queu change may have long 'when' chain -> long latency
when (stateQueue(i) === s_selected) {
when (io.data.fuReady) {
if (feedback) {
stateQueue(i) := s_wait
} else {
stateQueue(i) := s_idle
}
}.otherwise { stateQueue(i) := s_valid }
}
when (stateQueue(i) === s_bubble) {
stateQueue(i) := s_idle
}
// redirect
when (redVec(i) && stateQueue(i) =/= s_idle) {
stateQueue(i) := s_idle
......@@ -296,7 +295,7 @@ class ReservationStationCtrl
XSDebug(print, p"moveMask:${Binary(moveMask)} selMask:${Binary(selectMask.asUInt)} bubMask:${Binary(bubMask.asUInt)}\n")
XSDebug(print, p"selIdxWire:${selPtr} haveReady:${haveReady} redSel:${redSel}" +
p"selV:${selValid} selReg:${selReg} selPtrReg:${selPtrReg} selIdx:${selIdx} selIdxReg:${selIdxReg}\n")
XSDebug(print, p"haveBub:${haveBubble} bubPtr:${bubPtr} findBub:${findBubble} " +
XSDebug(print, p"bubValid:${bubValid} haveBub:${haveBubble} bubPtr:${bubPtr} findBub:${findBubble} " +
p"bubReg:${bubReg} bubPtrReg:${bubPtrReg} bubIdx:${bubIdx} bubIdxReg:${bubIdxReg}\n")
XSDebug(print, p"issValid:${issValid} issueFire:${issFire} dequeue:${dequeue} deqPtr:${deqPtr}\n")
XSDebug(p" :Idx|v|r|s |cnt|s1:s2:s3\n")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册