reduce noise in tag engine unit test as well as make results apparent
This commit is contained in:
parent
2d9bc945c5
commit
89664a01f6
3 changed files with 79 additions and 9 deletions
67
bs/Tests/BusTester.bs
Normal file
67
bs/Tests/BusTester.bs
Normal file
|
@ -0,0 +1,67 @@
|
|||
package TagEngineTester(mkTagEngineTester) where
|
||||
|
||||
import TagEngine
|
||||
import ActionSeq
|
||||
import Assert
|
||||
|
||||
mkTagEngineTester :: Module Empty
|
||||
mkTagEngineTester = do
|
||||
tagEngine :: TagEngine 5 <- mkTagEngine
|
||||
runOnce :: Reg Bool <- mkReg False
|
||||
|
||||
s :: ActionSeq
|
||||
s <-
|
||||
let
|
||||
requestTagAction :: Action
|
||||
requestTagAction =
|
||||
do
|
||||
tag <- tagEngine.requestTag
|
||||
$display $time " got tag : " (fshow tag)
|
||||
|
||||
retireTagAction :: UInt 3 -> Action
|
||||
retireTagAction tag =
|
||||
do
|
||||
res <- tagEngine.retireTag tag
|
||||
$display $time " retiring tag : " (fshow tag) " " (fshow res)
|
||||
action {}
|
||||
|
||||
in
|
||||
actionSeq $
|
||||
do requestTagAction
|
||||
|> do
|
||||
requestTagAction
|
||||
-- tag <- tagEngine.requestTag
|
||||
|> do requestTagAction
|
||||
|> do requestTagAction
|
||||
|> do requestTagAction
|
||||
|> do retireTagAction 2
|
||||
-- |> do $display "BEGIN TRY SIMULTANEOUS RETIRE and REQUEST"
|
||||
|> do
|
||||
retireTagAction 4
|
||||
requestTagAction
|
||||
-- |> do $display "END TRY SIMULTANEOUS RETIRE and REQUEST"
|
||||
-- |> do $display "BEGIN TRY SIMULTANEOUS RETIRE and REQUEST"
|
||||
|> do
|
||||
retireTagAction 4
|
||||
requestTagAction
|
||||
-- |> do $display "END TRY SIMULTANEOUS RETIRE and REQUEST"
|
||||
|> do $finish
|
||||
-- |> do retireTagAction 4
|
||||
-- |> do retireTagAction 4
|
||||
-- |> do retireTagAction 0
|
||||
-- |> do requestTagAction
|
||||
-- |> do requestTagAction
|
||||
-- |> do retireTagAction 1
|
||||
-- |> do requestTagAction
|
||||
-- |> do $finish
|
||||
|
||||
addRules $
|
||||
rules
|
||||
-- "counter": when True ==>
|
||||
-- do
|
||||
-- count := count + 1
|
||||
-- $display "count : " (fshow count)
|
||||
"testIncrement": when (runOnce == False) ==>
|
||||
do
|
||||
s.start
|
||||
runOnce := True
|
|
@ -19,18 +19,20 @@ mkTagEngineTester = do
|
|||
requestTagAction =
|
||||
do
|
||||
tag <- tagEngine.requestTag
|
||||
$display $time " got tag : " (fshow tag)
|
||||
-- $display $time " got tag : " (fshow tag)
|
||||
action {}
|
||||
|
||||
retireTagAction :: UInt 3 -> Action
|
||||
retireTagAction tag =
|
||||
do
|
||||
res <- tagEngine.retireTag tag
|
||||
$display $time " retiring tag : " (fshow tag) " " (fshow res)
|
||||
-- $display $time " retiring tag : " (fshow tag) " " (fshow res)
|
||||
action {}
|
||||
|
||||
in
|
||||
actionSeq $
|
||||
do
|
||||
$display "=== TESTING TagEngine ==="
|
||||
let expectedTag = 4
|
||||
tag <- tagEngine.requestTag
|
||||
dynamicAssert (tag == expectedTag) ""
|
||||
|
@ -59,10 +61,11 @@ mkTagEngineTester = do
|
|||
dynamicAssert (tag == expectedTag) ""
|
||||
|> do
|
||||
retireTagAction 2
|
||||
let expectedTag = 3
|
||||
let expectedTag = 4
|
||||
tag <- tagEngine.requestTag
|
||||
dynamicAssert (tag == expectedTag) ""
|
||||
|> do
|
||||
$display "=== PASSED ==="
|
||||
terminateSimNoError
|
||||
|
||||
addRules $
|
||||
|
|
Reference in a new issue