Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions clash-protocols/src/Protocols/Df.hs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ forceResetSanity = forceResetSanityGeneric

-- | Coerce the payload of a Df stream.
coerce :: (Coerce.Coercible a b) => Circuit (Df dom a) (Df dom b)
coerce = fromSignals $ \(fwdA, bwdB) -> (Coerce.coerce bwdB, Coerce.coerce fwdA)
coerce = fromSignals $ \(fwdA, bwdB) -> (bwdB, Coerce.coerce fwdA)

{- | Takes one or more values from the left and "compresses" it into a single
value that is occasionally sent to the right. Useful for taking small high-speed
Expand Down Expand Up @@ -335,7 +335,7 @@ pure a = Circuit (P.const ((), P.pure (Just a)))
consume :: (C.HiddenReset dom) => Circuit (Df dom a) ()
consume = Circuit (P.const (P.pure (Ack True), ()))

-- | Never acknowledge values.
-- | Acknowledge but ignore values when out of reset, otherwise give backpressure.
void :: (C.HiddenReset dom) => Circuit (Df dom a) ()
void =
Circuit
Expand Down Expand Up @@ -677,10 +677,10 @@ faninS ::
Circuit (C.Vec n (Df dom a)) (Df dom a)
faninS fS = bundleVec |> mapS (C.fold @(n C.- 1) <$> fS)

-- | Merge data of multiple 'Df' streams using Monoid's '<>'.
-- | Merge data of multiple 'Df' streams using Semigroup's '<>'.
mfanin ::
forall n dom a.
(C.KnownNat n, Monoid a, 1 <= n) =>
(C.KnownNat n, Semigroup a, 1 <= n) =>
Circuit (C.Vec n (Df dom a)) (Df dom a)
mfanin = fanin (<>)

Expand Down
6 changes: 3 additions & 3 deletions clash-protocols/src/Protocols/DfConv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ pure df a =
Df.pure a
|> dfToDfConvOtp df

-- | Ignore incoming data
-- | Acknowledge but ignore values when out of reset, otherwise give backpressure.
void ::
( DfConv df
, HiddenClockResetEnable (Dom df)
Expand Down Expand Up @@ -1245,7 +1245,7 @@ fanin dfA dfB f =
)
|> toDfCircuit dfB

-- | Merge data of multiple streams using Monoid's '<>'.
-- | Merge data of multiple streams using Semigroup's '<>'.
mfanin ::
( DfConv dfA
, DfConv dfB
Expand All @@ -1254,7 +1254,7 @@ mfanin ::
, HiddenClockResetEnable (Dom dfA)
, FwdPayload dfA ~ FwdPayload dfB
, NFDataX (FwdPayload dfA)
, Monoid (FwdPayload dfA)
, Semigroup (FwdPayload dfA)
, KnownNat numA
, numA ~ (decNumA + 1)
) =>
Expand Down
1 change: 1 addition & 0 deletions clash-protocols/tests/Tests/Protocols/Axi4.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Clash.Prelude qualified as C
import Data.Proxy (Proxy (..))

-- hedgehog
import Clash.Hedgehog.Sized.Vector (genVec)
import Hedgehog
import Hedgehog.Gen qualified as Gen
import Hedgehog.Range qualified as Range
Expand Down
1 change: 1 addition & 0 deletions clash-protocols/tests/Tests/Protocols/Df.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import Control.DeepSeq (NFData)
import Data.Hashable (Hashable)

-- hedgehog
import Clash.Hedgehog.Sized.Vector (genVec)
import Hedgehog
import Hedgehog.Gen qualified as Gen
import Hedgehog.Range qualified as Range
Expand Down
8 changes: 0 additions & 8 deletions clash-protocols/tests/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,18 @@ import Data.HashMap.Strict qualified as HashMap
import Data.Hashable (Hashable)

-- clash-prelude

import Clash.Prelude (type (<=))
import Clash.Prelude qualified as C

-- extra
import "extra" Data.List.Extra (transpose)
import "extra" Data.List.Extra qualified as Extra

-- hedgehog
import Hedgehog qualified as H

chunksOf :: forall n. (C.KnownNat n) => [Int] -> C.Vec n [Int]
chunksOf xs = vecFromList (transpose (Extra.chunksOf (C.natToNum @n) xs))

vecFromList :: forall n a. (C.KnownNat n, Monoid a) => [a] -> C.Vec n a
vecFromList as = C.takeI (unsafeCoerce (as <> repeat mempty))

genVec :: (C.KnownNat n, 1 <= n) => H.Gen a -> H.Gen (C.Vec n a)
genVec gen = sequence (C.repeat gen)

-- | Count the number of times an element occurs in a list
tally :: (Hashable a, Eq a) => [a] -> HashMap a Int
tally = tallyOn id (const 1)
Expand Down