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
|
@ -57,9 +57,9 @@ interface BusMaster =
|
|||
-- This has implications about for the implementor of BusMaster, namely, that it
|
||||
-- should hold its request until it's request method gets called.
|
||||
request :: BusRequest
|
||||
-- From the masters's perspective, the response should not be called until
|
||||
-- the client is ready to accept the response. In other words, response
|
||||
-- should be guarded by the client.
|
||||
-- From the masters's perspective, the response should not be called by the
|
||||
-- arbiter until the master is ready to accept the response. In other words,
|
||||
-- response should be guarded by the client.
|
||||
response :: BusResponse -> Action
|
||||
|
||||
type Token = UInt 5
|
||||
|
|
|
@ -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)
|
||||
|
|
74
bs/Top.bs
74
bs/Top.bs
|
@ -108,43 +108,43 @@ mkSim = do
|
|||
core :: Core FCLK <- mkCore;
|
||||
|
||||
s :: ActionSeq
|
||||
s <- actionSeq
|
||||
$ do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|> do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|> do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|> do
|
||||
res <- tagEngine.retireTag 3
|
||||
$display "retiring tag : 3 " (fshow res)
|
||||
action {}
|
||||
|> do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|> do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|> do
|
||||
res <- tagEngine.retireTag 4
|
||||
$display "retiring tag : 4 " (fshow res)
|
||||
action {}
|
||||
|> do
|
||||
res <- tagEngine.retireTag 4
|
||||
$display "retiring tag : 4 " (fshow res)
|
||||
action {}
|
||||
|> do
|
||||
res <- tagEngine.retireTag 0
|
||||
$display "retiring tag : 0 " (fshow res)
|
||||
action {}
|
||||
|> do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|> do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
|> do
|
||||
res <- tagEngine.retireTag 1
|
||||
$display "retiring tag : 1 " (fshow res)
|
||||
action {}
|
||||
|> do
|
||||
$display "got tag : " tagEngine.requestTag
|
||||
s <-
|
||||
let
|
||||
requestTagAction :: Action
|
||||
requestTagAction =
|
||||
do
|
||||
tag <- tagEngine.requestTag
|
||||
$display "got tag : " (fshow tag)
|
||||
in
|
||||
actionSeq $
|
||||
do requestTagAction
|
||||
|> do requestTagAction
|
||||
|> do requestTagAction
|
||||
|> do
|
||||
res <- tagEngine.retireTag 3
|
||||
$display "retiring tag : 3 " (fshow res)
|
||||
action {}
|
||||
|> do requestTagAction
|
||||
|> do requestTagAction
|
||||
|> do
|
||||
res <- tagEngine.retireTag 4
|
||||
$display "retiring tag : 4 " (fshow res)
|
||||
action {}
|
||||
|> do
|
||||
res <- tagEngine.retireTag 4
|
||||
$display "retiring tag : 4 " (fshow res)
|
||||
action {}
|
||||
|> do
|
||||
res <- tagEngine.retireTag 0
|
||||
$display "retiring tag : 0 " (fshow res)
|
||||
action {}
|
||||
|> do requestTagAction
|
||||
|> do requestTagAction
|
||||
|> do
|
||||
res <- tagEngine.retireTag 1
|
||||
$display "retiring tag : 1 " (fshow res)
|
||||
action {}
|
||||
|> do requestTagAction
|
||||
|
||||
addRules $
|
||||
rules
|
||||
|
|
Loading…
Reference in a new issue