@@ -14,7 +14,9 @@ import Prelude
1414
1515-- clash-prelude
1616
17- import Clash.Prelude (type (<= ))
17+ import Clash.Explicit.Prelude qualified as E
18+ import Clash.Explicit.Reset (noReset )
19+ import Clash.Prelude (Vec (Nil , (:>) ), type (<= ))
1820import Clash.Prelude qualified as C
1921
2022-- containers
@@ -37,6 +39,7 @@ import Hedgehog.Range qualified as Range
3739
3840-- tasty
3941import Test.Tasty
42+ import Test.Tasty.HUnit (Assertion , testCase , (@?=) )
4043import Test.Tasty.Hedgehog (HedgehogTestLimit (HedgehogTestLimit ))
4144import Test.Tasty.Hedgehog.Extra (testProperty )
4245import Test.Tasty.TH (testGroupGenerator )
@@ -47,6 +50,8 @@ import Protocols.Df qualified as Df
4750import Protocols.Hedgehog
4851
4952-- tests
53+
54+ import Data.Bifunctor (Bifunctor (first ))
5055import Util
5156
5257newtype PlusInt = PlusInt Int
@@ -319,6 +324,36 @@ prop_roundrobinCollectParallel =
319324 prop :: [Int ] -> [Int ] -> PropertyT IO ()
320325 prop expected actual = HashSet. fromList expected === HashSet. fromList actual
321326
327+ {- | Asserts that roundrobinCollect with Parallel mode behaves in a left-biased
328+ fashion.
329+ -}
330+ case_roundrobinCollectParallel :: Assertion
331+ case_roundrobinCollectParallel = do
332+ expected @?= actual
333+ where
334+ actual =
335+ E. sampleN 5
336+ . C. bundle
337+ . first C. bundle
338+ $ dut (input0 :> input1 :> input2 :> Nil , pure $ Ack True )
339+
340+ expected =
341+ [ (Ack True :> Ack False :> Ack False :> Nil , Just (1 :: Int ))
342+ , (Ack True :> Ack False :> Ack False :> Nil , Just 2 )
343+ , (Ack False :> Ack True :> Ack False :> Nil , Just 10 )
344+ , (Ack False :> Ack True :> Ack False :> Nil , Just 40 )
345+ , (Ack False :> Ack False :> Ack True :> Nil , Just 100 )
346+ ]
347+
348+ input0 = C. fromList @ _ @ C. System [Just 1 , Just 2 , Nothing , Nothing , Nothing ]
349+ input1 = C. fromList @ _ @ C. System [Just 10 , Just 10 , Just 10 , Just 40 , Nothing ]
350+ input2 = C. fromList @ _ @ C. System [Just 100 , Just 100 , Just 100 , Just 100 , Just 100 ]
351+
352+ dut =
353+ toSignals $
354+ C. withClockResetEnable @ C. System C. clockGen noReset C. enableGen $
355+ Df. roundrobinCollect @ 3 Df. Parallel
356+
322357prop_unbundleVec :: Property
323358prop_unbundleVec =
324359 idWithModelSingleDomain
0 commit comments