Tag Engine Now Finished it seems #10
|
@ -57,9 +57,9 @@ interface BusMaster =
|
||||||
-- This has implications about for the implementor of BusMaster, namely, that it
|
-- This has implications about for the implementor of BusMaster, namely, that it
|
||||||
-- should hold its request until it's request method gets called.
|
-- should hold its request until it's request method gets called.
|
||||||
request :: BusRequest
|
request :: BusRequest
|
||||||
-- From the masters's perspective, the response should not be called until
|
-- From the masters's perspective, the response should not be called by the
|
||||||
-- the client is ready to accept the response. In other words, response
|
-- arbiter until the master is ready to accept the response. In other words,
|
||||||
-- should be guarded by the client.
|
-- response should be guarded by the client.
|
||||||
response :: BusResponse -> Action
|
response :: BusResponse -> Action
|
||||||
|
|
||||||
type Token = UInt 5
|
type Token = UInt 5
|
||||||
|
|
|
@ -9,7 +9,7 @@ import Util
|
||||||
#define UIntLog2N(n) (UInt (TLog n))
|
#define UIntLog2N(n) (UInt (TLog n))
|
||||||
|
|
||||||
interface (TagEngine :: # -> *) numTags =
|
interface (TagEngine :: # -> *) numTags =
|
||||||
requestTag :: ActionValue UIntLog2N(numTags)
|
requestTag :: ActionValue (Maybe UIntLog2N(numTags))
|
||||||
retireTag :: UIntLog2N(numTags) -> ActionValue BasicResult
|
retireTag :: UIntLog2N(numTags) -> ActionValue BasicResult
|
||||||
|
|
||||||
-- The tag engine returns a tag that is unique for the duration of
|
-- 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 :: Module (TagEngine numTags)
|
||||||
mkTagEngine =
|
mkTagEngine =
|
||||||
do
|
do
|
||||||
|
|
||||||
let reifiedNumTags = fromInteger |> valueOf numTags
|
let reifiedNumTags = fromInteger |> valueOf numTags
|
||||||
|
|
||||||
freeStackVec :: Vector numTags (Reg UIntLog2N(numTags))
|
freeStackVec :: Vector numTags (Reg UIntLog2N(numTags))
|
||||||
|
@ -30,8 +31,20 @@ mkTagEngine =
|
||||||
stackPtr :: (Reg (Maybe(UIntLog2N(numTags))))
|
stackPtr :: (Reg (Maybe(UIntLog2N(numTags))))
|
||||||
stackPtr <- mkReg |> Just |> reifiedNumTags - 1
|
stackPtr <- mkReg |> Just |> reifiedNumTags - 1
|
||||||
|
|
||||||
|
methodRequestTagCalled :: PulseWire
|
||||||
|
methodRequestTagCalled <- mkPulseWire
|
||||||
|
|
||||||
|
|
||||||
|
methodRetireTagCalled :: PulseWire
|
||||||
|
methodRetireTagCalled <- mkPulseWire
|
||||||
|
|
||||||
|
tagResponse :: RWire UIntLog2N(numTags)
|
||||||
|
tagResponse <- mkRWireSBR
|
||||||
|
|
||||||
debugOnce <- mkReg True
|
debugOnce <- mkReg True
|
||||||
|
|
||||||
|
tt :: Reg Bool <- mkReg False
|
||||||
|
|
||||||
addRules $
|
addRules $
|
||||||
rules
|
rules
|
||||||
"display": when (debugOnce == True) ==>
|
"display": when (debugOnce == True) ==>
|
||||||
|
@ -40,20 +53,30 @@ mkTagEngine =
|
||||||
$display "inUseVec : " (fshow |> readVReg inUseVec)
|
$display "inUseVec : " (fshow |> readVReg inUseVec)
|
||||||
$display "stackPtr : " (fshow stackPtr)
|
$display "stackPtr : " (fshow stackPtr)
|
||||||
debugOnce := False
|
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))
|
counter <- mkReg(0 :: UIntLog2N(numTags))
|
||||||
return $
|
return $
|
||||||
interface TagEngine
|
interface TagEngine
|
||||||
|
|
||||||
requestTag :: ActionValue UIntLog2N(numTags)
|
requestTag :: ActionValue (Maybe UIntLog2N(numTags))
|
||||||
requestTag =
|
requestTag =
|
||||||
do
|
do
|
||||||
|
methodRequestTagCalled.send
|
||||||
stackPtr :=
|
stackPtr :=
|
||||||
if sampledStackPtr == 0
|
if sampledStackPtr == 0
|
||||||
then Nothing
|
then Nothing
|
||||||
else Just |> sampledStackPtr - 1
|
else Just |> sampledStackPtr - 1
|
||||||
(select inUseVec sampledStackPtr) := True
|
(select inUseVec sampledStackPtr) := True
|
||||||
return |> readReg (select freeStackVec sampledStackPtr)
|
return |> Just |> readReg (select freeStackVec sampledStackPtr)
|
||||||
when
|
when
|
||||||
Just sampledStackPtr <- stackPtr
|
Just sampledStackPtr <- stackPtr
|
||||||
|
|
||||||
|
@ -64,6 +87,7 @@ mkTagEngine =
|
||||||
retireTag :: UIntLog2N(numTags) -> ActionValue BasicResult
|
retireTag :: UIntLog2N(numTags) -> ActionValue BasicResult
|
||||||
retireTag tag =
|
retireTag tag =
|
||||||
do
|
do
|
||||||
|
methodRetireTagCalled.send
|
||||||
let
|
let
|
||||||
tagValid = tag < reifiedNumTags
|
tagValid = tag < reifiedNumTags
|
||||||
tagInUse = readReg (select inUseVec tag)
|
tagInUse = readReg (select inUseVec tag)
|
||||||
|
|
34
bs/Top.bs
34
bs/Top.bs
|
@ -108,21 +108,24 @@ mkSim = do
|
||||||
core :: Core FCLK <- mkCore;
|
core :: Core FCLK <- mkCore;
|
||||||
|
|
||||||
s :: ActionSeq
|
s :: ActionSeq
|
||||||
s <- actionSeq
|
s <-
|
||||||
$ do
|
let
|
||||||
$display "got tag : " tagEngine.requestTag
|
requestTagAction :: Action
|
||||||
|> do
|
requestTagAction =
|
||||||
$display "got tag : " tagEngine.requestTag
|
do
|
||||||
|> do
|
tag <- tagEngine.requestTag
|
||||||
$display "got tag : " tagEngine.requestTag
|
$display "got tag : " (fshow tag)
|
||||||
|
in
|
||||||
|
actionSeq $
|
||||||
|
do requestTagAction
|
||||||
|
|> do requestTagAction
|
||||||
|
|> do requestTagAction
|
||||||
|> do
|
|> do
|
||||||
res <- tagEngine.retireTag 3
|
res <- tagEngine.retireTag 3
|
||||||
$display "retiring tag : 3 " (fshow res)
|
$display "retiring tag : 3 " (fshow res)
|
||||||
action {}
|
action {}
|
||||||
|> do
|
|> do requestTagAction
|
||||||
$display "got tag : " tagEngine.requestTag
|
|> do requestTagAction
|
||||||
|> do
|
|
||||||
$display "got tag : " tagEngine.requestTag
|
|
||||||
|> do
|
|> do
|
||||||
res <- tagEngine.retireTag 4
|
res <- tagEngine.retireTag 4
|
||||||
$display "retiring tag : 4 " (fshow res)
|
$display "retiring tag : 4 " (fshow res)
|
||||||
|
@ -135,16 +138,13 @@ mkSim = do
|
||||||
res <- tagEngine.retireTag 0
|
res <- tagEngine.retireTag 0
|
||||||
$display "retiring tag : 0 " (fshow res)
|
$display "retiring tag : 0 " (fshow res)
|
||||||
action {}
|
action {}
|
||||||
|> do
|
|> do requestTagAction
|
||||||
$display "got tag : " tagEngine.requestTag
|
|> do requestTagAction
|
||||||
|> do
|
|
||||||
$display "got tag : " tagEngine.requestTag
|
|
||||||
|> do
|
|> do
|
||||||
res <- tagEngine.retireTag 1
|
res <- tagEngine.retireTag 1
|
||||||
$display "retiring tag : 1 " (fshow res)
|
$display "retiring tag : 1 " (fshow res)
|
||||||
action {}
|
action {}
|
||||||
|> do
|
|> do requestTagAction
|
||||||
$display "got tag : " tagEngine.requestTag
|
|
||||||
|
|
||||||
addRules $
|
addRules $
|
||||||
rules
|
rules
|
||||||
|
|
Loading…
Reference in a new issue