reduced latency
This commit is contained in:
parent
d436209f54
commit
e055b1bbdf
2 changed files with 38 additions and 24 deletions
|
@ -23,8 +23,10 @@ mkTagEngine =
|
|||
do
|
||||
let reifiedNumTags = fromInteger |> valueOf numTags
|
||||
|
||||
-- we really only use inUseVec after emptying out our `resetTagCounter` buffer
|
||||
-- perhaps rename this variable to better communicate that
|
||||
inUseVec :: Vector numTags (Reg Bool)
|
||||
inUseVec <- replicateM |> mkReg False
|
||||
inUseVec <- replicateM |> mkReg True
|
||||
|
||||
-- Since Bluespec doesn't allow us to initialize FIFOs with values at
|
||||
-- reset, we can pretend as if the buffer within our tagFIFO is populated
|
||||
|
@ -32,11 +34,12 @@ mkTagEngine =
|
|||
-- by having our tag engine effectively return the value of a decrementing
|
||||
-- counter initialized to (numTags - 1) for the first n tag requests made
|
||||
-- to TagEngine where `n := numTags`.
|
||||
-- Maybe resetTagCounter isn't the greatest name?
|
||||
resetTagCounter :: (Reg (Maybe UIntLog2N(numTags)))
|
||||
resetTagCounter <- mkReg |> Just |> reifiedNumTags - 1
|
||||
|
||||
retireQueue :: FIFOF UIntLog2N(numTags)
|
||||
retireQueue <- mkSizedFIFOF reifiedNumTags
|
||||
retireTag :: Wire UIntLog2N(numTags)
|
||||
retireTag <- mkWire
|
||||
|
||||
freeQueue :: FIFOF UIntLog2N(numTags)
|
||||
freeQueue <- mkSizedFIFOF reifiedNumTags
|
||||
|
@ -56,11 +59,9 @@ mkTagEngine =
|
|||
-- 2. the `requestTag` method handles the case where there are some tags to retire.
|
||||
"retire_tags": when True ==>
|
||||
do
|
||||
let tag = retireQueue.first
|
||||
$display "firing retire_tags" (fshow tag)
|
||||
retireQueue.deq
|
||||
freeQueue.enq tag
|
||||
(select inUseVec tag) := False
|
||||
$display "firing retire_tags" (fshow retireTag)
|
||||
freeQueue.enq retireTag
|
||||
(select inUseVec retireTag) := False
|
||||
|
||||
return $
|
||||
interface TagEngine
|
||||
|
@ -71,11 +72,9 @@ mkTagEngine =
|
|||
case resetTagCounter of
|
||||
Just 0 -> do
|
||||
resetTagCounter := Nothing
|
||||
(select inUseVec 0) := True
|
||||
return 0
|
||||
Just tag -> do
|
||||
resetTagCounter := Just |> tag - 1
|
||||
(select inUseVec tag) := True
|
||||
return tag
|
||||
Nothing -> do
|
||||
let tag = freeQueue.first
|
||||
|
@ -86,14 +85,18 @@ mkTagEngine =
|
|||
-- so it is advisable that the caller of `retireTag` only attempt to retire valid tags.
|
||||
-- Internally, the tagEngine will keep a correct and consistent state since TagEngine
|
||||
-- validates tags before attempting to retire them.
|
||||
-- Also worth noting the TagEngin will ignore attempts to retire a tag you just
|
||||
-- requested in the same cycle. This is enforce with `tag > tagCounter` below.
|
||||
retireTag :: UIntLog2N(numTags) -> Action
|
||||
retireTag tag =
|
||||
do
|
||||
let
|
||||
tagValid = tag < reifiedNumTags
|
||||
tagInUse = readReg (select inUseVec tag)
|
||||
tagInUse = case resetTagCounter of
|
||||
Just tagCounter -> tag > tagCounter
|
||||
Nothing -> readReg (select inUseVec tag)
|
||||
if (tagValid && tagInUse)
|
||||
then do
|
||||
retireQueue.enq tag
|
||||
retireTag := tag
|
||||
else do
|
||||
action {}
|
||||
|
|
Reference in a new issue