better names in TagEngine
This commit is contained in:
parent
d1e3358197
commit
271148e538
|
@ -23,10 +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
|
||||
-- we really only use tagUsageTracker after emptying out our
|
||||
-- `initialTagDistributor` buffer
|
||||
tagUsageTracker :: Vector numTags (Reg Bool)
|
||||
tagUsageTracker <- replicateM |> mkReg False
|
||||
|
||||
-- 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
|
||||
|
@ -34,15 +34,14 @@ 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
|
||||
initialTagDistributor :: (Reg (Maybe UIntLog2N(numTags)))
|
||||
initialTagDistributor <- mkReg |> Just |> reifiedNumTags - 1
|
||||
|
||||
retireTag :: Wire UIntLog2N(numTags)
|
||||
retireTag <- mkWire
|
||||
|
||||
freeQueue :: FIFOF UIntLog2N(numTags)
|
||||
freeQueue <- mkSizedFIFOF reifiedNumTags
|
||||
tagFIFO :: FIFOF UIntLog2N(numTags)
|
||||
tagFIFO <- mkSizedFIFOF reifiedNumTags
|
||||
|
||||
debugOnce <- mkReg True
|
||||
|
||||
|
@ -50,18 +49,14 @@ mkTagEngine =
|
|||
rules
|
||||
"display": when (debugOnce == True) ==>
|
||||
do
|
||||
$display "inUseVec : " (fshow |> readVReg inUseVec)
|
||||
$display "tagUsageTracker : " (fshow |> readVReg tagUsageTracker)
|
||||
debugOnce := False
|
||||
|
||||
-- The "retire_tags" rule can't fire when the `requestTag` method is called.
|
||||
-- In practice, this is Ok since:
|
||||
-- 1. the `requestTag` method should take priority over the "retire_tags" rule
|
||||
-- 2. the `requestTag` method handles the case where there are some tags to retire.
|
||||
"retire_tags": when True ==>
|
||||
do
|
||||
$display "firing retire_tags" (fshow retireTag)
|
||||
freeQueue.enq retireTag
|
||||
(select inUseVec retireTag) := False
|
||||
tagFIFO.enq retireTag
|
||||
(select tagUsageTracker retireTag) := False
|
||||
|
||||
return $
|
||||
interface TagEngine
|
||||
|
@ -69,18 +64,18 @@ mkTagEngine =
|
|||
requestTag :: ActionValue UIntLog2N(numTags)
|
||||
requestTag =
|
||||
do
|
||||
case resetTagCounter of
|
||||
case initialTagDistributor of
|
||||
Just 0 -> do
|
||||
resetTagCounter := Nothing
|
||||
(select inUseVec 0) := True
|
||||
initialTagDistributor := Nothing
|
||||
(select tagUsageTracker 0) := True
|
||||
return 0
|
||||
Just tag -> do
|
||||
resetTagCounter := Just |> tag - 1
|
||||
(select inUseVec tag) := True
|
||||
initialTagDistributor := Just |> tag - 1
|
||||
(select tagUsageTracker tag) := True
|
||||
return tag
|
||||
Nothing -> do
|
||||
let tag = freeQueue.first
|
||||
freeQueue.deq
|
||||
let tag = tagFIFO.first
|
||||
tagFIFO.deq
|
||||
return tag
|
||||
|
||||
-- `retireTag` isn't guarded on tag validity(this would break Bluespec's safety model)
|
||||
|
@ -92,7 +87,7 @@ mkTagEngine =
|
|||
do
|
||||
let
|
||||
tagValid = tag < reifiedNumTags
|
||||
tagInUse = readReg (select inUseVec tag)
|
||||
tagInUse = readReg (select tagUsageTracker tag)
|
||||
if (tagValid && tagInUse)
|
||||
then do
|
||||
retireTag := tag
|
||||
|
|
Loading…
Reference in a new issue