Skip to content

Commit

Permalink
Add autoreg instances
Browse files Browse the repository at this point in the history
  • Loading branch information
t-wallet committed Sep 16, 2024
1 parent 0f9192d commit d5f6541
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions clash-protocols/src/Protocols/PacketStream/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,18 @@ data PacketStreamM2S (dataWidth :: Nat) (meta :: Type) = PacketStreamM2S
-- ^ Iff true, the packet corresponding to this transfer is invalid. The subordinate
-- must either drop the packet or forward the `_abort`.
}
deriving (Eq, Generic, ShowX, Show, NFData, Bundle, Functor)
deriving (Bundle, Eq, Functor, Generic, NFData, Show, ShowX)

deriving instance
(KnownNat dataWidth, NFDataX meta) =>
NFDataX (PacketStreamM2S dataWidth meta)

-- | Used by circuit-notation to create an empty stream
instance Default (Maybe (PacketStreamM2S dataWidth meta)) where
def = Nothing

deriveAutoReg ''PacketStreamM2S

{- |
Data sent from the subordinate to manager.
Expand All @@ -109,12 +115,14 @@ newtype PacketStreamS2M = PacketStreamS2M
{ _ready :: Bool
-- ^ Iff True, the subordinate is ready to receive data.
}
deriving (Eq, Generic, ShowX, Show, NFData, Bundle, NFDataX)
deriving (Bundle, Eq, Generic, NFData, NFDataX, Show, ShowX)

-- | Used by circuit-notation to create a sink that always acknowledges
instance Default PacketStreamS2M where
def = PacketStreamS2M True

deriveAutoReg ''PacketStreamS2M

{- |
Simple valid-ready streaming protocol for transferring packets between components.
Expand All @@ -129,10 +137,6 @@ Invariants:
-}
data PacketStream (dom :: Domain) (dataWidth :: Nat) (meta :: Type)

deriving instance
(KnownNat dataWidth, NFDataX meta) =>
NFDataX (PacketStreamM2S dataWidth meta)

instance Protocol (PacketStream dom dataWidth meta) where
type
Fwd (PacketStream dom dataWidth meta) =
Expand Down

0 comments on commit d5f6541

Please sign in to comment.