reduced latency
This commit is contained in:
parent
d436209f54
commit
e055b1bbdf
|
@ -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 {}
|
||||
|
|
|
@ -6,7 +6,7 @@ import ActionSeq
|
|||
mkTagEngineTester :: Module Empty
|
||||
mkTagEngineTester = do
|
||||
tagEngine :: TagEngine 5 <- mkTagEngine
|
||||
count :: Reg (UInt 4) <- mkReg 0;
|
||||
count :: Reg (UInt 32) <- mkReg 0;
|
||||
runOnce :: Reg Bool <- mkReg False
|
||||
|
||||
s :: ActionSeq
|
||||
|
@ -30,24 +30,35 @@ mkTagEngineTester = do
|
|||
do requestTagAction
|
||||
|> do requestTagAction
|
||||
|> do requestTagAction
|
||||
|> do retireTagAction 3
|
||||
|> do $display "BEGIN TRY SIMULTANEOUS RETIRE and REQUEST"
|
||||
|> do requestTagAction
|
||||
|> do requestTagAction
|
||||
|> do retireTagAction 2
|
||||
-- |> do $display "BEGIN TRY SIMULTANEOUS RETIRE and REQUEST"
|
||||
|> do
|
||||
retireTagAction 4
|
||||
requestTagAction
|
||||
|> do $display "END TRY SIMULTANEOUS RETIRE and REQUEST"
|
||||
|> do requestTagAction
|
||||
|> do retireTagAction 4
|
||||
|> do retireTagAction 4
|
||||
|> do retireTagAction 0
|
||||
|> do requestTagAction
|
||||
|> do requestTagAction
|
||||
|> do retireTagAction 1
|
||||
|> do requestTagAction
|
||||
-- |> do $display "END TRY SIMULTANEOUS RETIRE and REQUEST"
|
||||
-- |> do $display "BEGIN TRY SIMULTANEOUS RETIRE and REQUEST"
|
||||
|> do
|
||||
retireTagAction 4
|
||||
requestTagAction
|
||||
-- |> do $display "END TRY SIMULTANEOUS RETIRE and REQUEST"
|
||||
|> do $finish
|
||||
-- |> do retireTagAction 4
|
||||
-- |> do retireTagAction 4
|
||||
-- |> do retireTagAction 0
|
||||
-- |> do requestTagAction
|
||||
-- |> do requestTagAction
|
||||
-- |> do retireTagAction 1
|
||||
-- |> do requestTagAction
|
||||
-- |> do $finish
|
||||
|
||||
addRules $
|
||||
rules
|
||||
"counter": when True ==>
|
||||
do
|
||||
count := count + 1
|
||||
$display "count : " (fshow count)
|
||||
"testIncrement": when (runOnce == False) ==>
|
||||
do
|
||||
s.start
|
||||
|
|
Loading…
Reference in a new issue