Tag Engine Now Finished it seems #10

Merged
Yehowshua merged 12 commits from tag_engine_version_3 into main 2025-04-08 01:32:40 +00:00
3 changed files with 67 additions and 43 deletions
Showing only changes of commit 6e3b3e9178 - Show all commits

View file

@ -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

View file

@ -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)

View file

@ -108,43 +108,43 @@ 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)
|> do in
res <- tagEngine.retireTag 3 actionSeq $
$display "retiring tag : 3 " (fshow res) do requestTagAction
action {} |> do requestTagAction
|> do |> do requestTagAction
$display "got tag : " tagEngine.requestTag |> do
|> do res <- tagEngine.retireTag 3
$display "got tag : " tagEngine.requestTag $display "retiring tag : 3 " (fshow res)
|> do action {}
res <- tagEngine.retireTag 4 |> do requestTagAction
$display "retiring tag : 4 " (fshow res) |> do requestTagAction
action {} |> do
|> do res <- tagEngine.retireTag 4
res <- tagEngine.retireTag 4 $display "retiring tag : 4 " (fshow res)
$display "retiring tag : 4 " (fshow res) action {}
action {} |> do
|> do res <- tagEngine.retireTag 4
res <- tagEngine.retireTag 0 $display "retiring tag : 4 " (fshow res)
$display "retiring tag : 0 " (fshow res) action {}
action {} |> do
|> do res <- tagEngine.retireTag 0
$display "got tag : " tagEngine.requestTag $display "retiring tag : 0 " (fshow res)
|> do action {}
$display "got tag : " tagEngine.requestTag |> do requestTagAction
|> do |> do requestTagAction
res <- tagEngine.retireTag 1 |> do
$display "retiring tag : 1 " (fshow res) res <- tagEngine.retireTag 1
action {} $display "retiring tag : 1 " (fshow res)
|> do action {}
$display "got tag : " tagEngine.requestTag |> do requestTagAction
addRules $ addRules $
rules rules