Skip to content

Commit

Permalink
Add Vec and unit type instances to IdleCircuit (#112)
Browse files Browse the repository at this point in the history
* Add Vec and unit type instances to IdleCircuit
  • Loading branch information
Linouth authored Sep 23, 2024
1 parent c8584ba commit 8b80277
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions clash-protocols/src/Protocols/Idle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Protocols.Idle (
idleSink,
) where

import qualified Clash.Prelude as C
import Data.Proxy
import Protocols.Cpp (maxTupleSize)
import Protocols.Internal
Expand All @@ -18,6 +19,14 @@ instance (IdleCircuit a, IdleCircuit b) => IdleCircuit (a, b) where
idleFwd _ = (idleFwd $ Proxy @a, idleFwd $ Proxy @b)
idleBwd _ = (idleBwd $ Proxy @a, idleBwd $ Proxy @b)

instance (IdleCircuit a, C.KnownNat n) => IdleCircuit (C.Vec n a) where
idleFwd _ = C.repeat $ idleFwd $ Proxy @a
idleBwd _ = C.repeat $ idleBwd $ Proxy @a

instance IdleCircuit () where
idleFwd _ = ()
idleBwd _ = ()

-- Derive instances for tuples up to maxTupleSize
idleCircuitTupleInstances 3 maxTupleSize

Expand Down

0 comments on commit 8b80277

Please sign in to comment.