Preliminary cleaning before repairing TagEngine
* clean up state machine in Top * `requestTag` method now emits Maybe type * put more thought into comments around asynchronous bus
This commit is contained in:
parent
76e542ff36
commit
6e3b3e9178
3 changed files with 67 additions and 43 deletions
|
@ -9,7 +9,7 @@ import Util
|
|||
#define UIntLog2N(n) (UInt (TLog n))
|
||||
|
||||
interface (TagEngine :: # -> *) numTags =
|
||||
requestTag :: ActionValue UIntLog2N(numTags)
|
||||
requestTag :: ActionValue (Maybe UIntLog2N(numTags))
|
||||
retireTag :: UIntLog2N(numTags) -> ActionValue BasicResult
|
||||
|
||||
-- The tag engine returns a tag that is unique for the duration of
|
||||
|
@ -19,6 +19,7 @@ interface (TagEngine :: # -> *) numTags =
|
|||
mkTagEngine :: Module (TagEngine numTags)
|
||||
mkTagEngine =
|
||||
do
|
||||
|
||||
let reifiedNumTags = fromInteger |> valueOf numTags
|
||||
|
||||
freeStackVec :: Vector numTags (Reg UIntLog2N(numTags))
|
||||
|
@ -30,8 +31,20 @@ mkTagEngine =
|
|||
stackPtr :: (Reg (Maybe(UIntLog2N(numTags))))
|
||||
stackPtr <- mkReg |> Just |> reifiedNumTags - 1
|
||||
|
||||
methodRequestTagCalled :: PulseWire
|
||||
methodRequestTagCalled <- mkPulseWire
|
||||
|
||||
|
||||
methodRetireTagCalled :: PulseWire
|
||||
methodRetireTagCalled <- mkPulseWire
|
||||
|
||||
tagResponse :: RWire UIntLog2N(numTags)
|
||||
tagResponse <- mkRWireSBR
|
||||
|
||||
debugOnce <- mkReg True
|
||||
|
||||
tt :: Reg Bool <- mkReg False
|
||||
|
||||
addRules $
|
||||
rules
|
||||
"display": when (debugOnce == True) ==>
|
||||
|
@ -40,20 +53,30 @@ mkTagEngine =
|
|||
$display "inUseVec : " (fshow |> readVReg inUseVec)
|
||||
$display "stackPtr : " (fshow stackPtr)
|
||||
debugOnce := False
|
||||
<+>
|
||||
rules
|
||||
when (methodRequestTagCalled && methodRetireTagCalled) ==>
|
||||
do
|
||||
$display "ho ho ho"
|
||||
-- let
|
||||
-- nextStackPtr =
|
||||
-- case of (methodRequestTagCalled, methodRetireTagCalled) of
|
||||
-- (True, True) ->
|
||||
|
||||
counter <- mkReg(0 :: UIntLog2N(numTags))
|
||||
return $
|
||||
interface TagEngine
|
||||
|
||||
requestTag :: ActionValue UIntLog2N(numTags)
|
||||
requestTag :: ActionValue (Maybe UIntLog2N(numTags))
|
||||
requestTag =
|
||||
do
|
||||
methodRequestTagCalled.send
|
||||
stackPtr :=
|
||||
if sampledStackPtr == 0
|
||||
then Nothing
|
||||
else Just |> sampledStackPtr - 1
|
||||
(select inUseVec sampledStackPtr) := True
|
||||
return |> readReg (select freeStackVec sampledStackPtr)
|
||||
return |> Just |> readReg (select freeStackVec sampledStackPtr)
|
||||
when
|
||||
Just sampledStackPtr <- stackPtr
|
||||
|
||||
|
@ -64,6 +87,7 @@ mkTagEngine =
|
|||
retireTag :: UIntLog2N(numTags) -> ActionValue BasicResult
|
||||
retireTag tag =
|
||||
do
|
||||
methodRetireTagCalled.send
|
||||
let
|
||||
tagValid = tag < reifiedNumTags
|
||||
tagInUse = readReg (select inUseVec tag)
|
||||
|
|
Reference in a new issue