add some comments
This commit is contained in:
parent
020bc5b646
commit
e415d981f9
|
@ -24,9 +24,15 @@ mkTagEngine = do
|
|||
-- Constants
|
||||
let maxTagCount = fromInteger (valueOf numTags)
|
||||
|
||||
-- State
|
||||
tagUsage :: Vector numTags (Reg Bool) <- replicateM (mkReg False) -- Tracks which tags are in use
|
||||
initialTagCounter <- mkReg (Just (maxTagCount - 1)) -- Distributes initial tags
|
||||
|
||||
-- Since Bluespec doesn't allow us to initialize FIFOs with values at
|
||||
-- reset, we can pretend as if the buffer within our freeTagQueue is populated
|
||||
-- with sequentially incrementing values(starting from 0) on reset
|
||||
-- by having our tag engine effectively return the value of a decrementing
|
||||
-- counter initialized to (maxTagCount - 1) for the first n tag requests made
|
||||
-- to TagEngine where `n := maxTagCount`.
|
||||
initialTagDistributor <- mkReg (Just (maxTagCount - 1)) -- Distributes initial tags
|
||||
retireQueue <- mkBypassFIFO -- Queue for tags being retired
|
||||
freeTagQueue <- mkSizedFIFOF maxTagCount -- Queue of available tags
|
||||
|
||||
|
@ -75,13 +81,13 @@ mkTagEngine = do
|
|||
interface TagEngine
|
||||
requestTag :: ActionValue UIntLog2N(numTags)
|
||||
requestTag = do
|
||||
case initialTagCounter of
|
||||
case initialTagDistributor of
|
||||
Just 0 -> do
|
||||
initialTagCounter := Nothing
|
||||
initialTagDistributor := Nothing
|
||||
requestSignal.wset 0
|
||||
return 0
|
||||
Just tag -> do
|
||||
initialTagCounter := Just (tag - 1)
|
||||
initialTagDistributor := Just (tag - 1)
|
||||
requestSignal.wset tag
|
||||
return tag
|
||||
Nothing -> do
|
||||
|
@ -90,6 +96,10 @@ mkTagEngine = do
|
|||
requestSignal.wset tag
|
||||
return tag
|
||||
|
||||
-- `retireTag` isn't guarded on tag validity(this would break Bluespec's safety model)
|
||||
-- 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.
|
||||
retireTag :: UIntLog2N(numTags) -> Action
|
||||
retireTag tag =
|
||||
do
|
||||
|
|
Loading…
Reference in a new issue