Skip to content

Commit

Permalink
Move Sgmii dependency out of EbTb tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jvnknvlgl committed Jun 21, 2024
1 parent aed543e commit 67c16fd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 27 deletions.
1 change: 0 additions & 1 deletion clash-cores/clash-cores.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ test-suite unittests
Test.Cores.Internal.Signals
Test.Cores.Sgmii.AutoNeg
Test.Cores.Sgmii.BitSlip
Test.Cores.Sgmii.Common
Test.Cores.Sgmii.Gearbox
Test.Cores.Sgmii.PcsReceive
Test.Cores.Sgmii.PcsTransmit
Expand Down
18 changes: 16 additions & 2 deletions clash-cores/test/Test/Cores/EbTb.hs
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
module Test.Cores.EbTb where

import Clash.Cores.EbTb
import Clash.Cores.Sgmii.Common
import Clash.Hedgehog.Sized.BitVector
import qualified Clash.Prelude as C
import qualified Hedgehog as H
import qualified Hedgehog.Gen as Gen
import Test.Cores.Sgmii.Common
import Test.Tasty
import Test.Tasty.Hedgehog
import Test.Tasty.TH
import Prelude

-- | Check if a 'BitVector' does not contain a sequence of bits with the same
-- value for 5 or more bits consequetively.
checkBitSequence :: (C.KnownNat n) => C.BitVector n -> Bool
checkBitSequence cg =
fst (fst (C.mapAccumL (f 0) (0, 0) (C.bv2v cg)))
< 5
&& fst (fst (C.mapAccumL (f 1) (0, 0) (C.bv2v cg)))
< 5
where
f :: C.Bit -> (Int, Int) -> C.Bit -> ((Int, Int), C.Bit)
f c (accMax, acc) i =
if i == c
then ((if accMax < (acc + 1) then acc + 1 else accMax, acc + 1), i)
else ((accMax, 0), i)

-- Check if the output of 'ebTbDecode' is a valid value for a given value from
-- 'ebTbEncode'.
prop_ebTbDecodeCheckNothing :: H.Property
Expand Down
2 changes: 1 addition & 1 deletion clash-cores/test/Test/Cores/Sgmii/BitSlip.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Data.Maybe (isNothing)
import qualified Hedgehog as H
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
import Test.Cores.Sgmii.Common
import Test.Cores.EbTb
import Test.Tasty
import Test.Tasty.Hedgehog
import Test.Tasty.TH
Expand Down
22 changes: 0 additions & 22 deletions clash-cores/test/Test/Cores/Sgmii/Common.hs

This file was deleted.

2 changes: 1 addition & 1 deletion clash-cores/test/Test/Cores/Sgmii/Sync.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Data.List (group, mapAccumL, maximumBy)
import qualified Hedgehog as H
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
import Test.Cores.Sgmii.Common
import Test.Cores.EbTb
import Test.Tasty
import Test.Tasty.Hedgehog
import Test.Tasty.TH
Expand Down

0 comments on commit 67c16fd

Please sign in to comment.