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
2 changed files with 62 additions and 34 deletions
Showing only changes of commit ed8e0b8337 - Show all commits

View file

@ -34,12 +34,8 @@ mkTagEngine =
methodRequestTagCalled :: PulseWire methodRequestTagCalled :: PulseWire
methodRequestTagCalled <- mkPulseWire methodRequestTagCalled <- mkPulseWire
methodRetireTagCalledValid :: RWire UIntLog2N(numTags)
methodRetireTagCalled :: PulseWire methodRetireTagCalledValid <- mkUnsafeRWire
methodRetireTagCalled <- mkPulseWire
tagResponse :: RWire UIntLog2N(numTags)
tagResponse <- mkRWireSBR
debugOnce <- mkReg True debugOnce <- mkReg True
@ -53,15 +49,48 @@ mkTagEngine =
$display "inUseVec : " (fshow |> readVReg inUseVec) $display "inUseVec : " (fshow |> readVReg inUseVec)
$display "stackPtr : " (fshow stackPtr) $display "stackPtr : " (fshow stackPtr)
debugOnce := False debugOnce := False
<+>
rules "update stack pointer": when True ==>
when (methodRequestTagCalled && methodRetireTagCalled) ==>
do do
$display "ho ho ho" stackPtr :=
-- let case (methodRequestTagCalled, methodRetireTagCalledValid.wget) of
-- nextStackPtr = (True, Just tag) -> stackPtr
-- case of (methodRequestTagCalled, methodRetireTagCalled) of (True, Nothing) ->
-- (True, True) -> case stackPtr of
Just 0 -> Nothing
Just sampledStackPtr -> Just |> sampledStackPtr - 1
Nothing -> Nothing
(False, Just tag) ->
case stackPtr of
Just sampledStackPtr -> Just |> sampledStackPtr + 1
Nothing -> Nothing
(False, Nothing) -> stackPtr
"update free stack": when True ==>
do
case (methodRequestTagCalled, methodRetireTagCalledValid.wget) of
(True, Just tag) -> do action {}
(True, Nothing) -> do action {}
(False, Just tag) -> do
case stackPtr of
Just sampledStackPtr -> do
(select freeStackVec (sampledStackPtr + 1)) := tag
Nothing -> do
(select freeStackVec 0) := tag
(False, Nothing) -> do action {}
"update in use": when True ==>
do
case (methodRequestTagCalled, methodRetireTagCalledValid.wget) of
(True, Just tag) -> do action {}
(True, Nothing) ->
case stackPtr of
Just sampledStackPtr -> do
(select inUseVec sampledStackPtr) := True
Nothing -> do action {}
(False, Just tag) -> do
(select inUseVec tag) := False
(False, Nothing) -> do action {}
counter <- mkReg(0 :: UIntLog2N(numTags)) counter <- mkReg(0 :: UIntLog2N(numTags))
return $ return $
@ -71,23 +100,19 @@ mkTagEngine =
requestTag = requestTag =
do do
methodRequestTagCalled.send methodRequestTagCalled.send
stackPtr := case methodRetireTagCalledValid.wget of
if sampledStackPtr == 0 Just tag -> do
then Nothing return |> Just tag
else Just |> sampledStackPtr - 1 Nothing -> do
(select inUseVec sampledStackPtr) := True return |>
return |> Just |> readReg (select freeStackVec sampledStackPtr) case stackPtr of
when Just sampledStackPtr ->
Just sampledStackPtr <- stackPtr Just |> readReg (select freeStackVec sampledStackPtr)
Nothing -> Nothing
-- retireTag isn't guarded so its up to external module to only attempt to
-- retire valid tags... At any rate, we can notify the requestor of failures
-- to retire tags - although the requestor can merely ignore this
-- notification.
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)
@ -97,9 +122,7 @@ mkTagEngine =
Just n -> n + 1 Just n -> n + 1
if (tagValid && tagInUse) if (tagValid && tagInUse)
then do then do
(select inUseVec tag) := False methodRetireTagCalledValid.wset tag
(select freeStackVec nextStackPtrUint) := tag
stackPtr := Just nextStackPtrUint
return Success return Success
else do else do
return Failure return Failure

View file

@ -7,6 +7,7 @@ mkTagEngineTester :: Module Empty
mkTagEngineTester = do mkTagEngineTester = do
tagEngine :: TagEngine 5 <- mkTagEngine tagEngine :: TagEngine 5 <- mkTagEngine
count :: Reg (UInt 4) <- mkReg 0; count :: Reg (UInt 4) <- mkReg 0;
runOnce :: Reg Bool <- mkReg False
s :: ActionSeq s :: ActionSeq
s <- s <-
@ -30,7 +31,11 @@ mkTagEngineTester = do
|> do requestTagAction |> do requestTagAction
|> do requestTagAction |> do requestTagAction
|> do retireTagAction 3 |> do retireTagAction 3
|> do requestTagAction |> do $display "BEGIN TRY SIMULTANEOUS RETIRE and REQUEST"
|> do
retireTagAction 4
requestTagAction
|> do $display "END TRY SIMULTANEOUS RETIRE and REQUEST"
|> do requestTagAction |> do requestTagAction
|> do retireTagAction 4 |> do retireTagAction 4
|> do retireTagAction 4 |> do retireTagAction 4
@ -42,7 +47,7 @@ mkTagEngineTester = do
addRules $ addRules $
rules rules
"testIncrement": when (count < 10) ==> "testIncrement": when (runOnce == False) ==>
do do
count := count + 1 s.start
s.start runOnce := True