From 8b80277437c7c17cff0db997b49990aa6daa8032 Mon Sep 17 00:00:00 2001 From: Marten Trip Date: Mon, 23 Sep 2024 12:02:18 +0200 Subject: [PATCH] Add Vec and unit type instances to IdleCircuit (#112) * Add Vec and unit type instances to IdleCircuit --- clash-protocols/src/Protocols/Idle.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/clash-protocols/src/Protocols/Idle.hs b/clash-protocols/src/Protocols/Idle.hs index d1f20988..6f7e6114 100644 --- a/clash-protocols/src/Protocols/Idle.hs +++ b/clash-protocols/src/Protocols/Idle.hs @@ -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 @@ -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