| Copyright | (C) 2024 QBayLogic B.V. |
|---|---|
| License | BSD2 (see the file LICENSE) |
| Maintainer | QBayLogic B.V. <devops@qbaylogic.com> |
| Safe Haskell | None |
| Language | GHC2021 |
Protocols.PacketStream
Description
Provides the PacketStream protocol, a simple streaming protocol for transferring packets of data between components.
Apart from the protocol definition, some components, all of which are generic in
dataWidth, are also provided:
- Several small utilities such as filtering a stream based on its metadata.
- FIFOs
- Components which upsize or downsize
dataWidth - Components which read from the stream (depacketizers)
- Components which write to the stream (packetizers)
- Components which split and merge a stream based on its metadata
Synopsis
- bimapMeta :: forall p a b c d (dom :: Domain) (dataWidth :: Nat). Bifunctor p => (a -> b) -> (c -> d) -> Circuit (PacketStream dom dataWidth (p a c)) (PacketStream dom dataWidth (p b d))
- bimapMetaS :: forall p (dom :: Domain) a b c d (dataWidth :: Nat). Bifunctor p => Signal dom (a -> b) -> Signal dom (c -> d) -> Circuit (PacketStream dom dataWidth (p a c)) (PacketStream dom dataWidth (p b d))
- consume :: forall (dom :: Domain) (dataWidth :: Nat) meta. HiddenReset dom => Circuit (PacketStream dom dataWidth meta) ()
- eitherMeta :: forall a c b (dom :: Domain) (dataWidth :: Nat). (a -> c) -> (b -> c) -> Circuit (PacketStream dom dataWidth (Either a b)) (PacketStream dom dataWidth c)
- eitherMetaS :: forall (dom :: Domain) a c b (dataWidth :: Nat). Signal dom (a -> c) -> Signal dom (b -> c) -> Circuit (PacketStream dom dataWidth (Either a b)) (PacketStream dom dataWidth c)
- empty :: forall (dom :: Domain) (dataWidth :: Nat) meta. Circuit () (PacketStream dom dataWidth meta)
- fanout :: forall (n :: Nat) (dataWidth :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat n, KnownNat dataWidth, 1 <= n, NFDataX meta) => Circuit (PacketStream dom dataWidth meta) (Vec n (PacketStream dom dataWidth meta))
- filterMeta :: forall meta (dom :: Domain) (dataWidth :: Nat). (meta -> Bool) -> Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta)
- filterMetaS :: forall (dom :: Domain) meta (dataWidth :: Nat). Signal dom (meta -> Bool) -> Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta)
- firstMeta :: forall p a b (dom :: Domain) (dataWidth :: Nat) c. Bifunctor p => (a -> b) -> Circuit (PacketStream dom dataWidth (p a c)) (PacketStream dom dataWidth (p b c))
- firstMetaS :: forall p (dom :: Domain) a b (dataWidth :: Nat) c. Bifunctor p => Signal dom (a -> b) -> Circuit (PacketStream dom dataWidth (p a c)) (PacketStream dom dataWidth (p b c))
- forceResetSanity :: forall (dom :: Domain) (dataWidth :: Nat) meta. (KnownDomain dom, HiddenReset dom) => Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta)
- fstMeta :: forall (dom :: Domain) (dataWidth :: Nat) a b. Circuit (PacketStream dom dataWidth (a, b)) (PacketStream dom dataWidth a)
- mapMeta :: forall metaIn metaOut (dom :: Domain) (dataWidth :: Nat). (metaIn -> metaOut) -> Circuit (PacketStream dom dataWidth metaIn) (PacketStream dom dataWidth metaOut)
- mapMetaS :: forall (dom :: Domain) metaIn metaOut (dataWidth :: Nat). Signal dom (metaIn -> metaOut) -> Circuit (PacketStream dom dataWidth metaIn) (PacketStream dom dataWidth metaOut)
- nullByte :: String -> BitVector 8
- registerBoth :: forall (dataWidth :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat dataWidth, NFDataX meta) => Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta)
- registerBwd :: forall (dataWidth :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat dataWidth, NFDataX meta) => Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta)
- registerFwd :: forall (dataWidth :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat dataWidth, NFDataX meta) => Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta)
- secondMeta :: forall p b c (dom :: Domain) (dataWidth :: Nat) a. Bifunctor p => (b -> c) -> Circuit (PacketStream dom dataWidth (p a b)) (PacketStream dom dataWidth (p a c))
- secondMetaS :: forall p (dom :: Domain) b c (dataWidth :: Nat) a. Bifunctor p => Signal dom (b -> c) -> Circuit (PacketStream dom dataWidth (p a b)) (PacketStream dom dataWidth (p a c))
- sndMeta :: forall (dom :: Domain) (dataWidth :: Nat) a b. Circuit (PacketStream dom dataWidth (a, b)) (PacketStream dom dataWidth b)
- stripTrailingEmptyC :: forall (dataWidth :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat dataWidth, NFDataX meta) => Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta)
- toCSignal :: forall (dom :: Domain) (dataWidth :: Nat) meta. HiddenClockResetEnable dom => Circuit (PacketStream dom dataWidth meta) (CSignal dom (Maybe (PacketStreamM2S dataWidth meta)))
- truncateAbortedPackets :: forall (dom :: Domain) (dataWidth :: Nat) meta. (HiddenClockResetEnable dom, KnownNat dataWidth, ShowX meta, 1 <= dataWidth) => Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta)
- unsafeAbortOnBackpressureC :: forall (dataWidth :: Nat) meta (dom :: Domain). HiddenClockResetEnable dom => Circuit (CSignal dom (Maybe (PacketStreamM2S dataWidth meta))) (PacketStream dom dataWidth meta)
- unsafeDropBackpressure :: forall (dom :: Domain) (dwIn :: Nat) meta (dwOut :: Nat). HiddenClockResetEnable dom => Circuit (PacketStream dom dwIn meta) (PacketStream dom dwOut meta) -> Circuit (CSignal dom (Maybe (PacketStreamM2S dwIn meta))) (CSignal dom (Maybe (PacketStreamM2S dwOut meta)))
- unsafeFromCSignal :: forall (dom :: Domain) (dataWidth :: Nat) meta. Circuit (CSignal dom (Maybe (PacketStreamM2S dataWidth meta))) (PacketStream dom dataWidth meta)
- void :: forall (dom :: Domain) (dataWidth :: Nat) meta. HiddenClockResetEnable dom => Circuit (PacketStream dom dataWidth meta) ()
- zeroOutInvalidBytesC :: forall (dom :: Domain) (dataWidth :: Nat) meta. (KnownNat dataWidth, 1 <= dataWidth) => Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta)
- data PacketStream (dom :: Domain) (dataWidth :: Nat) meta
- data PacketStreamM2S (dataWidth :: Nat) meta = PacketStreamM2S {}
- newtype PacketStreamS2M = PacketStreamS2M {}
- packetFifoC :: forall (dom :: Domain) (dataWidth :: Nat) meta (contentDepth :: Nat) (metaDepth :: Nat). (HiddenClockResetEnable dom, KnownNat dataWidth, 1 <= contentDepth, 1 <= metaDepth, NFDataX meta) => SNat contentDepth -> SNat metaDepth -> FullMode -> Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta)
- data FullMode
- = Backpressure
- | Drop
- asyncFifoC :: forall (wDom :: Domain) (rDom :: Domain) (depth :: Nat) (dataWidth :: Nat) meta. (KnownDomain wDom, KnownDomain rDom, KnownNat depth, KnownNat dataWidth, 2 <= depth, 1 <= dataWidth, NFDataX meta) => SNat depth -> Clock wDom -> Reset wDom -> Enable wDom -> Clock rDom -> Reset rDom -> Enable rDom -> Circuit (PacketStream wDom dataWidth meta) (PacketStream rDom dataWidth meta)
- downConverterC :: forall (dwOut :: Nat) (n :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat dwOut, KnownNat n, 1 <= dwOut, 1 <= n, NFDataX meta) => Circuit (PacketStream dom (dwOut * n) meta) (PacketStream dom dwOut meta)
- unsafeUpConverterC :: forall (dwIn :: Nat) meta (dom :: Domain) (n :: Nat). (HiddenClockResetEnable dom, 1 <= dwIn, 1 <= n, KnownNat dwIn, KnownNat n, NFDataX meta) => Circuit (CSignal dom (Maybe (PacketStreamM2S dwIn meta))) (CSignal dom (Maybe (PacketStreamM2S (dwIn * n) meta)))
- upConverterC :: forall (dwIn :: Nat) (n :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, 1 <= dwIn, 1 <= n, KnownNat dwIn, KnownNat n, NFDataX meta) => Circuit (PacketStream dom dwIn meta) (PacketStream dom (dwIn * n) meta)
- depacketizeToDfC :: forall (headerBytes :: Nat) header meta a (dataWidth :: Nat) (dom :: Domain). (HiddenClockResetEnable dom, NFDataX meta, NFDataX a, BitPack header, KnownNat headerBytes, KnownNat dataWidth, 1 <= headerBytes, 1 <= dataWidth, BitSize header ~ (headerBytes * 8)) => (header -> meta -> a) -> Circuit (PacketStream dom dataWidth meta) (Df dom a)
- depacketizerC :: forall (headerBytes :: Nat) header metaIn metaOut (dataWidth :: Nat) (dom :: Domain). (HiddenClockResetEnable dom, BitPack header, BitSize header ~ (headerBytes * 8), NFDataX metaIn, KnownNat headerBytes, KnownNat dataWidth, 1 <= headerBytes, 1 <= dataWidth) => (header -> metaIn -> metaOut) -> Circuit (PacketStream dom dataWidth metaIn) (PacketStream dom dataWidth metaOut)
- packetizeFromDfC :: forall (dom :: Domain) (dataWidth :: Nat) a metaOut header (headerBytes :: Nat). (HiddenClockResetEnable dom, NFDataX metaOut, BitPack header, BitSize header ~ (headerBytes * 8), KnownNat headerBytes, KnownNat dataWidth, 1 <= headerBytes, 1 <= dataWidth) => (a -> metaOut) -> (a -> header) -> Circuit (Df dom a) (PacketStream dom dataWidth metaOut)
- packetizerC :: forall (dom :: Domain) (dataWidth :: Nat) metaIn metaOut header (headerBytes :: Nat). (HiddenClockResetEnable dom, NFDataX metaOut, BitPack header, BitSize header ~ (headerBytes * 8), KnownNat headerBytes, 1 <= dataWidth, 1 <= headerBytes, KnownNat dataWidth) => (metaIn -> metaOut) -> (metaIn -> header) -> Circuit (PacketStream dom dataWidth metaIn) (PacketStream dom dataWidth metaOut)
- stripPaddingC :: forall (dataWidth :: Nat) meta (p :: Nat) (dom :: Domain). (HiddenClockResetEnable dom, KnownNat dataWidth, KnownNat p, NFDataX meta) => (meta -> Unsigned p) -> Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta)
- packetArbiterC :: forall (dataWidth :: Nat) (sources :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat sources, 1 <= sources) => CollectMode -> Circuit (Vec sources (PacketStream dom dataWidth meta)) (PacketStream dom dataWidth meta)
- packetDispatcherC :: forall (dataWidth :: Nat) (sinks :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat sinks) => Vec sinks (meta -> Bool) -> Circuit (PacketStream dom dataWidth meta) (Vec sinks (PacketStream dom dataWidth meta))
- routeBy :: forall a meta (sinks :: Nat). Eq a => (meta -> a) -> Vec sinks a -> Vec sinks (meta -> Bool)
Documentation
bimapMeta :: forall p a b c d (dom :: Domain) (dataWidth :: Nat). Bifunctor p => (a -> b) -> (c -> d) -> Circuit (PacketStream dom dataWidth (p a c)) (PacketStream dom dataWidth (p b d)) Source #
Like bimap, but over the metadata of a PacketStream.
bimapMetaS :: forall p (dom :: Domain) a b c d (dataWidth :: Nat). Bifunctor p => Signal dom (a -> b) -> Signal dom (c -> d) -> Circuit (PacketStream dom dataWidth (p a c)) (PacketStream dom dataWidth (p b d)) Source #
consume :: forall (dom :: Domain) (dataWidth :: Nat) meta. HiddenReset dom => Circuit (PacketStream dom dataWidth meta) () Source #
Always acknowledges incoming data.
eitherMeta :: forall a c b (dom :: Domain) (dataWidth :: Nat). (a -> c) -> (b -> c) -> Circuit (PacketStream dom dataWidth (Either a b)) (PacketStream dom dataWidth c) Source #
Like either, but over the metadata of a PacketStream.
eitherMetaS :: forall (dom :: Domain) a c b (dataWidth :: Nat). Signal dom (a -> c) -> Signal dom (b -> c) -> Circuit (PacketStream dom dataWidth (Either a b)) (PacketStream dom dataWidth c) Source #
Like eitherMeta but can reason over signals,
this circuit combinator is akin to <*>.
empty :: forall (dom :: Domain) (dataWidth :: Nat) meta. Circuit () (PacketStream dom dataWidth meta) Source #
Never produces a value.
fanout :: forall (n :: Nat) (dataWidth :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat n, KnownNat dataWidth, 1 <= n, NFDataX meta) => Circuit (PacketStream dom dataWidth meta) (Vec n (PacketStream dom dataWidth meta)) Source #
Copy data of a single PacketStream to multiple. LHS will only receive
an acknowledgement when all RHS receivers have acknowledged data.
Arguments
| :: forall meta (dom :: Domain) (dataWidth :: Nat). (meta -> Bool) | Predicate which specifies whether to keep a fragment based on its metadata |
| -> Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta) |
Like filter, but over the metadata of a PacketStream.
Arguments
| :: forall (dom :: Domain) meta (dataWidth :: Nat). Signal dom (meta -> Bool) | Predicate which specifies whether to keep a fragment based on its metadata,
wrapped in a |
| -> Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta) |
Like filterMeta but can reason over signals,
this circuit combinator is akin to <*>.
firstMeta :: forall p a b (dom :: Domain) (dataWidth :: Nat) c. Bifunctor p => (a -> b) -> Circuit (PacketStream dom dataWidth (p a c)) (PacketStream dom dataWidth (p b c)) Source #
Like first, but over the metadata of a PacketStream.
firstMetaS :: forall p (dom :: Domain) a b (dataWidth :: Nat) c. Bifunctor p => Signal dom (a -> b) -> Circuit (PacketStream dom dataWidth (p a c)) (PacketStream dom dataWidth (p b c)) Source #
forceResetSanity :: forall (dom :: Domain) (dataWidth :: Nat) meta. (KnownDomain dom, HiddenReset dom) => Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta) Source #
Force a nack on the backward channel and Nothing on the forward channel if reset is asserted.
fstMeta :: forall (dom :: Domain) (dataWidth :: Nat) a b. Circuit (PacketStream dom dataWidth (a, b)) (PacketStream dom dataWidth a) Source #
Like fst, but over the metadata of a PacketStream.
Arguments
| :: forall metaIn metaOut (dom :: Domain) (dataWidth :: Nat). (metaIn -> metaOut) | Function to apply on the metadata |
| -> Circuit (PacketStream dom dataWidth metaIn) (PacketStream dom dataWidth metaOut) |
Like map, but over the metadata of a PacketStream.
Arguments
| :: forall (dom :: Domain) metaIn metaOut (dataWidth :: Nat). Signal dom (metaIn -> metaOut) | Function to apply on the metadata, wrapped in a |
| -> Circuit (PacketStream dom dataWidth metaIn) (PacketStream dom dataWidth metaOut) |
Undefined PacketStream null byte. Will throw an error if evaluated. The source of the error should be supplied for a more informative error message; otherwise it is unclear which component threw the error.
registerBoth :: forall (dataWidth :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat dataWidth, NFDataX meta) => Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta) Source #
A pipeline skid buffer: places registers on both the backward and forward
part of a circuit. This completely breaks up the combinatorial path between
the left and right side of this component. In order to achieve this, it has to
buffer Fwd twice.
Another benefit of this component is that the circuit on the left hand side
may now use Bwd in order to compute its Fwd, because this cannot
introduce combinatorial loops anymore.
Runs at full throughput, but causes 2 clock cycles of latency.
registerBwd :: forall (dataWidth :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat dataWidth, NFDataX meta) => Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta) Source #
Place a register on the backward part of a circuit. This adds combinational delay on the forward path.
registerFwd :: forall (dataWidth :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat dataWidth, NFDataX meta) => Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta) Source #
Place a register on the forward part of a circuit. This adds combinational delay on the backward path.
secondMeta :: forall p b c (dom :: Domain) (dataWidth :: Nat) a. Bifunctor p => (b -> c) -> Circuit (PacketStream dom dataWidth (p a b)) (PacketStream dom dataWidth (p a c)) Source #
Like second, but over the metadata of a PacketStream.
secondMetaS :: forall p (dom :: Domain) b c (dataWidth :: Nat) a. Bifunctor p => Signal dom (b -> c) -> Circuit (PacketStream dom dataWidth (p a b)) (PacketStream dom dataWidth (p a c)) Source #
Like secondMeta but can reason over signals,
this circuit combinator is akin to <*>.
sndMeta :: forall (dom :: Domain) (dataWidth :: Nat) a b. Circuit (PacketStream dom dataWidth (a, b)) (PacketStream dom dataWidth b) Source #
Like snd, but over the metadata of a PacketStream.
stripTrailingEmptyC :: forall (dataWidth :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat dataWidth, NFDataX meta) => Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta) Source #
Strips trailing zero-byte transfers from packets in the stream. That is,
if a packet consists of more than one transfer and _last of the last
transfer in that packet is Just 0, the last transfer of that packet will
be dropped and _last of the transfer before that will be set to maxBound.
If such a trailing zero-byte transfer had _abort asserted, it will be
preserved.
Has one clock cycle latency, but runs at full throughput.
toCSignal :: forall (dom :: Domain) (dataWidth :: Nat) meta. HiddenClockResetEnable dom => Circuit (PacketStream dom dataWidth meta) (CSignal dom (Maybe (PacketStreamM2S dataWidth meta))) Source #
Converts a PacketStream into a CSignal: always acknowledges.
truncateAbortedPackets :: forall (dom :: Domain) (dataWidth :: Nat) meta. (HiddenClockResetEnable dom, KnownNat dataWidth, ShowX meta, 1 <= dataWidth) => Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta) Source #
unsafeAbortOnBackpressureC :: forall (dataWidth :: Nat) meta (dom :: Domain). HiddenClockResetEnable dom => Circuit (CSignal dom (Maybe (PacketStreamM2S dataWidth meta))) (PacketStream dom dataWidth meta) Source #
Sets _abort upon receiving backpressure from the subordinate.
UNSAFE: because fwdOut depends on bwdIn, this may introduce
combinatorial loops. You need to make sure that a sequential element is
inserted along this path. It is possible to use one of the skid buffers to
ensure this. For example:
>>>safeAbortOnBackpressureC1 = unsafeAbortOnBackpressureC |> registerFwd>>>safeAbortOnBackpressureC2 = unsafeAbortOnBackpressureC |> registerBwd
Note that registerFwd utilizes less resources than registerBwd.
unsafeDropBackpressure :: forall (dom :: Domain) (dwIn :: Nat) meta (dwOut :: Nat). HiddenClockResetEnable dom => Circuit (PacketStream dom dwIn meta) (PacketStream dom dwOut meta) -> Circuit (CSignal dom (Maybe (PacketStreamM2S dwIn meta))) (CSignal dom (Maybe (PacketStreamM2S dwOut meta))) Source #
Drop all backpressure signals.
unsafeFromCSignal :: forall (dom :: Domain) (dataWidth :: Nat) meta. Circuit (CSignal dom (Maybe (PacketStreamM2S dataWidth meta))) (PacketStream dom dataWidth meta) Source #
Circuit to convert a CSignal into a PacketStream.
This is unsafe, because it ignores all incoming backpressure.
void :: forall (dom :: Domain) (dataWidth :: Nat) meta. HiddenClockResetEnable dom => Circuit (PacketStream dom dataWidth meta) () Source #
Never acknowledges incoming data.
zeroOutInvalidBytesC :: forall (dom :: Domain) (dataWidth :: Nat) meta. (KnownNat dataWidth, 1 <= dataWidth) => Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta) Source #
Sets data bytes that are not enabled in a PacketStream to 0x00.
data PacketStream (dom :: Domain) (dataWidth :: Nat) meta Source #
Simple valid-ready streaming protocol for transferring packets between components.
Invariants:
- A manager must not check the
Bwdchannel when it is sendingNothingover theFwdchannel. - A manager must keep sending the same data until the subordinate has acknowledged it, i.e. upon observing
_readyasTrue. - A manager must keep the metadata (
_meta) of an entire packet it sends constant. - A subordinate which receives a transfer with
_abortasserted must either forward this_abortor drop the packet. - A packet may not be interrupted by another packet.
This protocol allows the last transfer of a packet to have zero valid bytes in
_data, so it also allows 0-byte packets. Note that concrete implementations
of the protocol are free to disallow 0-byte packets or packets with a trailing
zero-byte transfer for whatever reason.
The value of data bytes which are not enabled is undefined.
Instances
data PacketStreamM2S (dataWidth :: Nat) meta Source #
Data sent from manager to subordinate.
Heavily inspired by the M2S data of AMBA AXI4-Stream, but simplified:
_tdatais moved into_data, which serves the exact same purpose: the actual data of the transfer._tkeepis changed to_last._tstrbis removed as there are no position bytes._tidis removed, because packets may not be interrupted by other packets._tdestis moved into_meta._tuseris moved into_meta._tvalidis modeled by wrapping this type into aMaybe.
Constructors
| PacketStreamM2S | |
Fields
| |
Instances
| Default (Maybe (PacketStreamM2S dataWidth meta)) Source # | Used by circuit-notation to create an empty stream | ||||
Defined in Protocols.PacketStream.Base Methods def :: Maybe (PacketStreamM2S dataWidth meta) # | |||||
| Functor (PacketStreamM2S dataWidth) Source # | |||||
Defined in Protocols.PacketStream.Base Methods fmap :: (a -> b) -> PacketStreamM2S dataWidth a -> PacketStreamM2S dataWidth b # (<$) :: a -> PacketStreamM2S dataWidth b -> PacketStreamM2S dataWidth a # | |||||
| (KnownNat dataWidth, AutoReg meta) => AutoReg (PacketStreamM2S dataWidth meta) Source # | |||||
Defined in Protocols.PacketStream.Base Methods autoReg :: forall (dom :: Domain). (HasCallStack, KnownDomain dom) => Clock dom -> Reset dom -> Enable dom -> PacketStreamM2S dataWidth meta -> Signal dom (PacketStreamM2S dataWidth meta) -> Signal dom (PacketStreamM2S dataWidth meta) # | |||||
| Bundle (PacketStreamM2S dataWidth meta) Source # | |||||
Defined in Protocols.PacketStream.Base Methods bundle :: forall (dom :: Domain). Unbundled dom (PacketStreamM2S dataWidth meta) -> Signal dom (PacketStreamM2S dataWidth meta) # unbundle :: forall (dom :: Domain). Signal dom (PacketStreamM2S dataWidth meta) -> Unbundled dom (PacketStreamM2S dataWidth meta) # | |||||
| (KnownNat dataWidth, NFDataX meta) => NFDataX (PacketStreamM2S dataWidth meta) Source # | |||||
Defined in Protocols.PacketStream.Base Methods deepErrorX :: String -> PacketStreamM2S dataWidth meta # hasUndefined :: PacketStreamM2S dataWidth meta -> Bool # ensureSpine :: PacketStreamM2S dataWidth meta -> PacketStreamM2S dataWidth meta # rnfX :: PacketStreamM2S dataWidth meta -> () # | |||||
| ShowX meta => ShowX (PacketStreamM2S dataWidth meta) Source # | |||||
Defined in Protocols.PacketStream.Base Methods showsPrecX :: Int -> PacketStreamM2S dataWidth meta -> ShowS # showX :: PacketStreamM2S dataWidth meta -> String # showListX :: [PacketStreamM2S dataWidth meta] -> ShowS # | |||||
| NFData meta => NFData (PacketStreamM2S dataWidth meta) Source # | |||||
Defined in Protocols.PacketStream.Base Methods rnf :: PacketStreamM2S dataWidth meta -> () # | |||||
| Generic (PacketStreamM2S dataWidth meta) Source # | |||||
Defined in Protocols.PacketStream.Base Associated Types
Methods from :: PacketStreamM2S dataWidth meta -> Rep (PacketStreamM2S dataWidth meta) x # to :: Rep (PacketStreamM2S dataWidth meta) x -> PacketStreamM2S dataWidth meta # | |||||
| Show meta => Show (PacketStreamM2S dataWidth meta) Source # | |||||
Defined in Protocols.PacketStream.Base Methods showsPrec :: Int -> PacketStreamM2S dataWidth meta -> ShowS # show :: PacketStreamM2S dataWidth meta -> String # showList :: [PacketStreamM2S dataWidth meta] -> ShowS # | |||||
| (KnownNat dataWidth, Eq meta) => Eq (PacketStreamM2S dataWidth meta) Source # | Two PacketStream transfers are equal if and only if:
Data bytes that are not enabled are not considered in the equality check, because the protocol allows them to be undefined. Examples
| ||||
Defined in Protocols.PacketStream.Base Methods (==) :: PacketStreamM2S dataWidth meta -> PacketStreamM2S dataWidth meta -> Bool # (/=) :: PacketStreamM2S dataWidth meta -> PacketStreamM2S dataWidth meta -> Bool # | |||||
| type Unbundled dom (PacketStreamM2S dataWidth meta) Source # | |||||
Defined in Protocols.PacketStream.Base | |||||
| type Rep (PacketStreamM2S dataWidth meta) Source # | |||||
Defined in Protocols.PacketStream.Base type Rep (PacketStreamM2S dataWidth meta) = D1 ('MetaData "PacketStreamM2S" "Protocols.PacketStream.Base" "clash-protocols-0.1-inplace" 'False) (C1 ('MetaCons "PacketStreamM2S" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_data") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Vec dataWidth (BitVector 8))) :*: S1 ('MetaSel ('Just "_last") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Index (dataWidth + 1))))) :*: (S1 ('MetaSel ('Just "_meta") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 meta) :*: S1 ('MetaSel ('Just "_abort") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))) | |||||
newtype PacketStreamS2M Source #
Data sent from the subordinate to manager.
The only information transmitted is whether the subordinate is ready to receive data.
Constructors
| PacketStreamS2M | |
Instances
| AutoReg PacketStreamS2M Source # | |||||
Defined in Protocols.PacketStream.Base Methods autoReg :: forall (dom :: Domain). (HasCallStack, KnownDomain dom) => Clock dom -> Reset dom -> Enable dom -> PacketStreamS2M -> Signal dom PacketStreamS2M -> Signal dom PacketStreamS2M # | |||||
| Bundle PacketStreamS2M Source # | |||||
Defined in Protocols.PacketStream.Base Associated Types
Methods bundle :: forall (dom :: Domain). Unbundled dom PacketStreamS2M -> Signal dom PacketStreamS2M # unbundle :: forall (dom :: Domain). Signal dom PacketStreamS2M -> Unbundled dom PacketStreamS2M # | |||||
| NFDataX PacketStreamS2M Source # | |||||
Defined in Protocols.PacketStream.Base Methods deepErrorX :: String -> PacketStreamS2M # hasUndefined :: PacketStreamS2M -> Bool # ensureSpine :: PacketStreamS2M -> PacketStreamS2M # rnfX :: PacketStreamS2M -> () # | |||||
| ShowX PacketStreamS2M Source # | |||||
Defined in Protocols.PacketStream.Base Methods showsPrecX :: Int -> PacketStreamS2M -> ShowS # showX :: PacketStreamS2M -> String # showListX :: [PacketStreamS2M] -> ShowS # | |||||
| Default PacketStreamS2M Source # | Used by circuit-notation to create a sink that always acknowledges | ||||
Defined in Protocols.PacketStream.Base Methods def :: PacketStreamS2M # | |||||
| Generic PacketStreamS2M Source # | |||||
Defined in Protocols.PacketStream.Base Associated Types
Methods from :: PacketStreamS2M -> Rep PacketStreamS2M x # to :: Rep PacketStreamS2M x -> PacketStreamS2M # | |||||
| Show PacketStreamS2M Source # | |||||
Defined in Protocols.PacketStream.Base Methods showsPrec :: Int -> PacketStreamS2M -> ShowS # show :: PacketStreamS2M -> String # showList :: [PacketStreamS2M] -> ShowS # | |||||
| Eq PacketStreamS2M Source # | |||||
Defined in Protocols.PacketStream.Base Methods (==) :: PacketStreamS2M -> PacketStreamS2M -> Bool # (/=) :: PacketStreamS2M -> PacketStreamS2M -> Bool # | |||||
| type Rep PacketStreamS2M Source # | |||||
Defined in Protocols.PacketStream.Base type Rep PacketStreamS2M = D1 ('MetaData "PacketStreamS2M" "Protocols.PacketStream.Base" "clash-protocols-0.1-inplace" 'True) (C1 ('MetaCons "PacketStreamS2M" 'PrefixI 'True) (S1 ('MetaSel ('Just "_ready") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool))) | |||||
| type Unbundled dom PacketStreamS2M Source # | |||||
Defined in Protocols.PacketStream.Base | |||||
FIFOs
Arguments
| :: forall (dom :: Domain) (dataWidth :: Nat) meta (contentDepth :: Nat) (metaDepth :: Nat). (HiddenClockResetEnable dom, KnownNat dataWidth, 1 <= contentDepth, 1 <= metaDepth, NFDataX meta) | |
| => SNat contentDepth | The content FIFO will contain |
| -> SNat metaDepth | The metadata FIFO will contain |
| -> FullMode | The backpressure behaviour of the FIFO when it is full. |
| -> Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta) |
FIFO circuit optimized for the PacketStream protocol. Contains two FIFOs, one
for packet data (_data, _last) and one for packet metadata (_meta).
Because metadata is constant per packet, the metadata FIFO can be significantly
shallower, saving resources.
Moreover, the output of the FIFO has some other properties:
- All packets which contain a transfer with
_abortset are dropped. - All packets that are bigger than or equal to
2^contentDepth - 1transfers are dropped. - There are no gaps in output packets, i.e.
Nothingin between valid transfers of a packet.
The circuit is able to satisfy these properties because it first loads an entire packet before it may transmit it. That is also why packets bigger than the content FIFO need to be dropped.
Two modes can be selected:
Backpressure: assert backpressure like normal when the FIFO is full.Drop: never give backpressure, instead drop the current packet we are loading.
Specifies the behaviour of packetFifoC when it is full.
Constructors
| Backpressure | Assert backpressure when the FIFO is full. |
| Drop | Drop new packets when the FIFO is full. The FIFO never asserts backpressure. |
Arguments
| :: forall (wDom :: Domain) (rDom :: Domain) (depth :: Nat) (dataWidth :: Nat) meta. (KnownDomain wDom, KnownDomain rDom, KnownNat depth, KnownNat dataWidth, 2 <= depth, 1 <= dataWidth, NFDataX meta) | |
| => SNat depth | 2^depth is the number of elements this component can store |
| -> Clock wDom | Clock signal in the write domain |
| -> Reset wDom | Reset signal in the write domain |
| -> Enable wDom | Enable signal in the write domain |
| -> Clock rDom | Clock signal in the read domain |
| -> Reset rDom | Reset signal in the read domain |
| -> Enable rDom | Enable signal in the read domain |
| -> Circuit (PacketStream wDom dataWidth meta) (PacketStream rDom dataWidth meta) |
Asynchronous FIFO circuit that can be used to safely cross clock domains.
Uses asyncFIFOSynchronizer internally.
Converters
Arguments
| :: forall (dwOut :: Nat) (n :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat dwOut, KnownNat n, 1 <= dwOut, 1 <= n, NFDataX meta) | |
| => Circuit (PacketStream dom (dwOut * n) meta) (PacketStream dom dwOut meta) | Downconverter circuit |
Converts packet streams of a data width which is a multiple of n, i.e.
dwOut * n, to packet streams of a smaller (or equal) data width dwOut,
where n > 0.
When n ~ 1, this component is just the identity circuit, idC.
If _abort is asserted on an input transfer, it will be asserted on all
corresponding output sub-transfers as well. All zero-byte transfers are
preserved.
Has one clock cycle of latency, all M2S outputs are registered.
Throughput is optimal, a transfer of k valid bytes is transmitted in k
clock cycles. To be precise, throughput is at least (1 / n)%, so at
least 50% if n = 2 for example. We specify at least,
because the throughput may be on the last transfer of a packet, when not all
bytes have to be valid. If there is only one valid byte in the last transfer,
then the throughput will always be 100% for that particular transfer.
Arguments
| :: forall (dwIn :: Nat) meta (dom :: Domain) (n :: Nat). (HiddenClockResetEnable dom, 1 <= dwIn, 1 <= n, KnownNat dwIn, KnownNat n, NFDataX meta) | |
| => Circuit (CSignal dom (Maybe (PacketStreamM2S dwIn meta))) (CSignal dom (Maybe (PacketStreamM2S (dwIn * n) meta))) | Unsafe upconverter circuit |
Unsafe version of upConverterC.
Because upConverterC runs at full throughput, i.e. it only asserts backpressure
if the subordinate asserts backpressure, we supply this variant which drops all
backpressure signals. This can be used when the source circuit does not support
backpressure. Using this variant in that case will improve timing and probably
reduce resource usage.
Arguments
| :: forall (dwIn :: Nat) (n :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, 1 <= dwIn, 1 <= n, KnownNat dwIn, KnownNat n, NFDataX meta) | |
| => Circuit (PacketStream dom dwIn meta) (PacketStream dom (dwIn * n) meta) | Upconverter circuit |
Converts packet streams of arbitrary data width dwIn to packet streams of
a bigger (or equal) data width dwIn * n, where n > 0.
When n ~ 1, this component is just the identity circuit, idC.
If _abort is asserted on any of the input sub-transfers, it will be asserted
on the corresponding output transfer as well. All zero-byte transfers are
preserved.
Has one cycle of latency, all M2S outputs are registered. Provides full throughput.
Depacketizers
Arguments
| :: forall (headerBytes :: Nat) header meta a (dataWidth :: Nat) (dom :: Domain). (HiddenClockResetEnable dom, NFDataX meta, NFDataX a, BitPack header, KnownNat headerBytes, KnownNat dataWidth, 1 <= headerBytes, 1 <= dataWidth, BitSize header ~ (headerBytes * 8)) | |
| => (header -> meta -> a) | Mapping from the parsed header and input |
| -> Circuit (PacketStream dom dataWidth meta) (Df dom a) |
Reads bytes at the start of each packet into a header structure, and
transforms this header structure along with the input metadata to an output
structure a, which is transmitted over a Df channel. Such a structure
is sent once per packet over the Df channel, but only if the packet was big
enough (contained at least headerBytes valid data bytes) and did not
contain any transfer with _abort set.
The remainder of the packet (padding) is dropped.
If the packet is not padded, or if the packet is padded but the padding fits in the last transfer of the packet together with valid data bytes, this component will give one clock cycle of backpressure per packet (for efficiency reasons). Otherwise, it runs at full throughput.
Arguments
| :: forall (headerBytes :: Nat) header metaIn metaOut (dataWidth :: Nat) (dom :: Domain). (HiddenClockResetEnable dom, BitPack header, BitSize header ~ (headerBytes * 8), NFDataX metaIn, KnownNat headerBytes, KnownNat dataWidth, 1 <= headerBytes, 1 <= dataWidth) | |
| => (header -> metaIn -> metaOut) | Mapping from the parsed header and input |
| -> Circuit (PacketStream dom dataWidth metaIn) (PacketStream dom dataWidth metaOut) |
Reads bytes at the start of each packet into _meta. If a packet contains
less valid bytes than headerBytes + 1, it will silently drop that packet.
If dataWidth divides headerBytes, this component runs at full throughput.
Otherwise, it gives backpressure for one clock cycle per packet larger than
headerBytes + 1 valid bytes.
Packetizers
Arguments
| :: forall (dom :: Domain) (dataWidth :: Nat) a metaOut header (headerBytes :: Nat). (HiddenClockResetEnable dom, NFDataX metaOut, BitPack header, BitSize header ~ (headerBytes * 8), KnownNat headerBytes, KnownNat dataWidth, 1 <= headerBytes, 1 <= dataWidth) | |
| => (a -> metaOut) | |
| -> (a -> header) | Mapping from |
| -> Circuit (Df dom a) (PacketStream dom dataWidth metaOut) |
Starts a packet stream upon receiving some data over a Df channel.
The bytes to be packetized and the output metadata are specified by the
input functions.
Arguments
| :: forall (dom :: Domain) (dataWidth :: Nat) metaIn metaOut header (headerBytes :: Nat). (HiddenClockResetEnable dom, NFDataX metaOut, BitPack header, BitSize header ~ (headerBytes * 8), KnownNat headerBytes, 1 <= dataWidth, 1 <= headerBytes, KnownNat dataWidth) | |
| => (metaIn -> metaOut) | |
| -> (metaIn -> header) | Mapping from input |
| -> Circuit (PacketStream dom dataWidth metaIn) (PacketStream dom dataWidth metaOut) |
Writes a portion of the metadata to the front of the packet stream, and shifts
the stream accordingly. This portion is defined by the (metaIn -> header)
input function. If this function is id, the entire metadata is put in front
of the packet stream.
Padding removal
Arguments
| :: forall (dataWidth :: Nat) meta (p :: Nat) (dom :: Domain). (HiddenClockResetEnable dom, KnownNat dataWidth, KnownNat p, NFDataX meta) | |
| => (meta -> Unsigned p) | Function that extracts the expected packet length from the metadata |
| -> Circuit (PacketStream dom dataWidth meta) (PacketStream dom dataWidth meta) |
Removes padding from packets according to some expected packet length field in the metadata. If the actual length of a packet is smaller than expected, the packet is aborted.
Has one clock cycle of latency, because all M2S outputs are registered. Runs at full throughput.
NB: dataWidth must be smaller than 2^p. Because this should never
occur in practice, this constraint is not enforced on the type-level.
Routing components
Arguments
| :: forall (dataWidth :: Nat) (sources :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat sources, 1 <= sources) | |
| => CollectMode | Determines the mode of arbitration. See |
| -> Circuit (Vec sources (PacketStream dom dataWidth meta)) (PacketStream dom dataWidth meta) |
Merges multiple packet streams into one, respecting packet boundaries.
Arguments
| :: forall (dataWidth :: Nat) (sinks :: Nat) meta (dom :: Domain). (HiddenClockResetEnable dom, KnownNat sinks) | |
| => Vec sinks (meta -> Bool) | Dispatch function |
| -> Circuit (PacketStream dom dataWidth meta) (Vec sinks (PacketStream dom dataWidth meta)) |
Routes packets depending on their metadata, using given routing functions.
Data is sent to at most one sink, for which the dispatch function evaluates to
True when applied to the input metadata. If none of the predicates hold, the
input packet is dropped. If more than one of the predicates hold, the sink
that occurs first in the vector is picked.
Sends out packets in the same clock cycle as they are received, this component has zero latency and runs at full throughput.