-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strongly separate
clash-protocols-base
and clash-protocols
`clash-protocols-base` should only contain code and definitions related to the circuit plugin. This includes the `Circuit` definition and `Protocol` typeclass. Furthermore we include instances for types imported from underlying clash libraries such as tuples, `Vec` and `Signal`.
- Loading branch information
Showing
7 changed files
with
70 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{-# OPTIONS_GHC -Wno-dodgy-exports #-} | ||
{-# OPTIONS_GHC -fno-warn-orphans #-} | ||
|
||
module Protocols.Circuit ( | ||
module Protocols.Internal.Classes, | ||
) where | ||
|
||
import Clash.Signal | ||
import Clash.Sized.Vector | ||
import GHC.TypeNats (KnownNat) | ||
import Protocols.Cpp (maxTupleSize) | ||
import Protocols.Internal.TH | ||
import Protocols.Internal.Classes | ||
|
||
instance Protocol () where | ||
type Fwd () = () | ||
type Bwd () = () | ||
|
||
{- | __NB__: The documentation only shows instances up to /3/-tuples. By | ||
default, instances up to and including /12/-tuples will exist. If the flag | ||
@large-tuples@ is set instances up to the GHC imposed limit will exist. The | ||
GHC imposed limit is either 62 or 64 depending on the GHC version. | ||
-} | ||
instance Protocol (a, b) where | ||
type Fwd (a, b) = (Fwd a, Fwd b) | ||
type Bwd (a, b) = (Bwd a, Bwd b) | ||
|
||
-- Generate n-tuple instances, where n > 2 | ||
protocolTupleInstances 3 maxTupleSize | ||
|
||
instance (KnownNat n) => Protocol (Vec n a) where | ||
type Fwd (Vec n a) = Vec n (Fwd a) | ||
type Bwd (Vec n a) = Vec n (Bwd a) | ||
|
||
-- XXX: Type families with Signals on LHS are currently broken on Clash: | ||
instance Protocol (CSignal dom a) where | ||
type Fwd (CSignal dom a) = Signal dom a | ||
type Bwd (CSignal dom a) = Signal dom () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters