clash-shockwaves
Copyright(C) 2025-2026 QBayLogic B.V.
LicenseBSD2 (see the file LICENSE)
MaintainerQBayLogic B.V. <devops@qbaylogic.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Shockwaves.Waveform

Description

Everything needed to create custom implementations of Waveform.

Synopsis

The Waveform class

class (Typeable a, BitPack a) => Waveform a where Source #

Waveform is the main class for making types displayable in the waveform viewer. The class is responsible for defining an appropriate translator and subsignal structure, as well as registering types.

To make a LUT approache possible, the class must also be able to translate values, and to register individual values.

By default, Generic is used to automatically derive this behaviour. Extra classes are provided to help implement lookup tables or common types, like numerical translators. Custom implementations are also very possible.

Minimal complete definition

Nothing

Methods

translator :: Translator Source #

The translator used for the data type. Must match the structure value.

default translator :: WaveformG (Rep a ()) => Translator Source #

constructorStyles :: [WaveStyle] Source #

List of styles used for constructors.

Since assigning different constructors different colors is a very common usecase of the waveform style, this list can be overridden to provides styles for the constructors, in order. To not change a style, use WSDefault.

Instances

Instances details
Waveform Bit Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform ClockWave Source #

Control the styles of the clock wave through style variables clk_pre, clk_a and clk_b.

Instance details

Defined in Clash.Shockwaves.Internal.Trace.CRE

Waveform EnableWave Source #

Control the styles of the enable wave through style variables enable_on and enable_off.

Instance details

Defined in Clash.Shockwaves.Internal.Trace.CRE

Waveform Int16 Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform Int32 Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform Int64 Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform Int8 Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform Word16 Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform Word32 Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform Word64 Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform Word8 Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform Ordering Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform () Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform Bool Source #

Configure styles through style variables bool_false and bool_true.

Instance details

Defined in Clash.Shockwaves.Internal.Waveform

BitPack Char => Waveform Char Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform Double Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform Float Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform Int Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform Word Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform a => Waveform (Complex a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform a => Waveform (Erroring a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform a => Waveform (Overflowing a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform a => Waveform (Saturating a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform a => Waveform (Wrapping a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform a => Waveform (Zeroing a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

(KnownNat n, BitPack (SNat n)) => Waveform (SNat n) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

KnownNat n => Waveform (BitVector n) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

(1 <= n, KnownNat n) => Waveform (Index n) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

KnownNat n => Waveform (Signed n) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

KnownNat n => Waveform (Unsigned n) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

KnownDomain dom => Waveform (CREWave dom) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Trace.CRE

KnownDomain dom => Waveform (ResetWave dom) Source #

Control the styles of the reset wave through style variables reset_on and reset_off.

Instance details

Defined in Clash.Shockwaves.Internal.Trace.CRE

(WaveformConst a, BitPack a, Typeable a) => Waveform (WaveformForConst a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

(Waveform a, WaveformLUT a, BitPack a, Typeable a) => Waveform (WaveformForLut a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform a => Waveform (Identity a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform a => Waveform (Down a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Waveform a => Waveform (Maybe a) Source #

Configure styles through style variables maybe_nothing and maybe_just.

Instance details

Defined in Clash.Shockwaves.Internal.Waveform

(Waveform a, KnownNat d, WaveformRTree (RTreeIsLeaf d) d a) => Waveform (RTree d a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

(KnownNat n, Waveform a) => Waveform (Vec n a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

(Waveform a, Waveform b) => Waveform (Either a b) Source #

Configure styles through style variables either_left and either_right.

Instance details

Defined in Clash.Shockwaves.Internal.Waveform

(Waveform a1, Waveform a2) => Waveform (a1, a2) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

(BitPack (Fixed r i f), KnownNat i, KnownNat f, Show (Fixed r i f), Typeable r) => Waveform (Fixed r i f) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

(BitPack a, Typeable a, Typeable f, Typeable s, KnownNFormat f, KnownNSpacer s) => Waveform (WaveformForNumber f s a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

(Waveform a1, Waveform a2, Waveform a3) => Waveform (a1, a2, a3) Source #

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 details

Defined in Clash.Shockwaves.Internal.Waveform

translate :: (Waveform a, BitPack a) => a -> Translation Source #

Function to translate values. This function creates a translation from the binary representation of the data using translateBin, and the translator.

translateBin :: Waveform a => BitList -> Translation Source #

Translate binary data. Normally, this simply translates the value according to the translator. For LUTs, this involves translating the value back to the original type and translating it using a specially defined translation function.

hasGeneratedLut :: Waveform a => Bool Source #

Check if the type requires values to be added to LUTs.

translateBinT :: Translator -> BitList -> Translation Source #

Translate a BitList using the provided translator.

hasGeneratedLutT :: Translator -> Bool Source #

Test if there is a LUT translator in a translator (following references).

Translations

data Translation Source #

Translation of a value. The translation consists of a Render value (the representation of the value itself) and a list of subsignal translations.

Instances

Instances details
ToJSON Translation Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

NFData Translation Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Methods

rnf :: Translation -> () #

Generic Translation Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Associated Types

type Rep Translation 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep Translation = D1 ('MetaData "Translation" "Clash.Shockwaves.Internal.Types" "clash-shockwaves-1.1.0-inplace" 'False) (C1 ('MetaCons "Translation" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Render) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(SubSignal, Translation)])))
Show Translation Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Eq Translation Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep Translation Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep Translation = D1 ('MetaData "Translation" "Clash.Shockwaves.Internal.Types" "clash-shockwaves-1.1.0-inplace" 'False) (C1 ('MetaCons "Translation" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Render) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(SubSignal, Translation)])))

type Render = Maybe (Value, WaveStyle, Prec) Source #

Rendered value. This can be Nothing is the value does not exists, or a tuple of the text representation, style, and precedence.

data WaveStyle Source #

The style in which a signal should be displayed.

Constructors

WSDefault

The default waveform style. It is rendered as WSNormal. This is the only style overwritten by TStyled.

WSError

An error value. Errors are propagated by translators.

WSHidden

Do not display any value, even if it exists.

WSInherit Natural

Copy the style of the nth subsignal.

WSNormal

A normal value.

WSWarn

A warning value.

WSUndef

An undefined value.

WSHighImp

A high impedance value.

WSDontCare

A value that does not matter.

WSWeak

A weakly defined value.

WSColor Color

A custom color. See Clash.Shockwaves.Style for more information.

WSVar String WaveStyle

A variable in a style configuration file, with a default.

Instances

Instances details
ToJSON WaveStyle Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

NFData WaveStyle Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Methods

rnf :: WaveStyle -> () #

IsString WaveStyle Source #

A WaveStyle may be constructed from a value in various ways. Values starting with $ are treated as WSVar with WSDefault as fallback value. Hexadecimals and color names are used to create WSColor (see readColourName).

Instance details

Defined in Clash.Shockwaves.Internal.Types

Generic WaveStyle Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Associated Types

type Rep WaveStyle 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep WaveStyle = D1 ('MetaData "WaveStyle" "Clash.Shockwaves.Internal.Types" "clash-shockwaves-1.1.0-inplace" 'False) (((C1 ('MetaCons "WSDefault" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WSError" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WSHidden" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "WSInherit" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural)) :+: (C1 ('MetaCons "WSNormal" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WSWarn" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "WSUndef" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WSHighImp" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WSDontCare" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "WSWeak" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WSColor" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: C1 ('MetaCons "WSVar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 WaveStyle))))))
Show WaveStyle Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Eq WaveStyle Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep WaveStyle Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep WaveStyle = D1 ('MetaData "WaveStyle" "Clash.Shockwaves.Internal.Types" "clash-shockwaves-1.1.0-inplace" 'False) (((C1 ('MetaCons "WSDefault" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WSError" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WSHidden" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "WSInherit" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural)) :+: (C1 ('MetaCons "WSNormal" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WSWarn" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "WSUndef" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WSHighImp" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WSDontCare" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "WSWeak" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WSColor" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: C1 ('MetaCons "WSVar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 WaveStyle))))))

type Value = String Source #

Text displayed as the value of a signal.

type Prec = Integer Source #

Operator precedence of the value.

type SubSignal = String Source #

Name of a subsignal.

Translators

data Translator Source #

A translator. The translator has a width, indicating the number of bits it translates, as well as a TranslatorVariant that determines the translation algorithm.

data TranslatorVariant Source #

The translation algorithm used. Translator variants determine how the bits are interpreted, split, manipulated, and in the end, translatated and displayed in the waveform viewer.

Constructors

TRef TypeName TypeRef

Use the translator of a different type. Note that the width value of the Translators should match that of the target. The TypeRef parameter does not end up in the actual output, but is used to access functionality for the referenced type. Use tRef to create this translator.

TLut LUTName (Maybe LUT) TypeRef

A reference to a lookup table. Implement Waveform through WaveformLUT to stably use this functionality.

TSum [Translator]

Select one translator to be used based on the first bits of the binary representation. Translate the rest of the bits using the selected translator. To be exact, if k translators are provided, ceil(log2(k)) bits will be consumed to select the translator.

No subsignals for the translators are created. Keep in mind that problems may occur if two translators specify subsignals with identical names.

TAdvancedSum

Use index to take a slice of the binary data. This slice is interpreted as an unsigned integer. This index value is checked against the ranges in rangeTrans; the first translator with a value in the range is used. If no ranges match, the defTrans is used.

The selected translator is passed the full binary.

  • *Important**: Slice indices start to the left, i.e. with the MSB!

Fields

TProduct

Split the binary data into separate fields, translate each of these, and join together the values. Specifically, for each of the listed translators, consume as many bits as specified by the translator, then pass on the rest of the bits to the other translators.

The value is constructed from the values of the subtranslators. A start, stop and separator string can be specified, as well as optional labels to put in front of the different values.

Example:

   data T = T{a::Bool,b::Bool}
   translatorVariantT = TProduct
   { subs = [("a",Bool,"b",Bool)],
   , start = "T{"
   , sep = ","
   , stop = "}"
   , labels = ["a=","b="]
   , preci = -1
   , preco = 11
   }
   

Fields

  • subs :: [(SubSignal, Translator)]

    List of fields to translate.

  • start :: Value

    Text to insert at the start of the value.

  • sep :: Value

    Text to use to separate values.

  • stop :: Value

    Text to insert at the end of the value.

  • labels :: [Value]

    List of labels to insert before each value. If empty, insert no labels. Else, the length must match that of subs.

  • preci :: Prec

    Inner precedence: used on subvalues.

  • preco :: Prec

    Outer precedence: used for the combined value.

TArray

An array value. This behaves much like TProduct, except that no labels can be provided, and all fields use the same translator. The fields are numbered starting from 0.

Fields

  • sub :: Translator

    Translator used for all values.

  • len :: Int

    Length of the array.

  • start :: Value

    Text to insert at the start of the value.

  • sep :: Value

    Text to use to separate values.

  • stop :: Value

    Text to insert at the end of the value.

  • preci :: Prec

    Inner precedence: used on subvalues.

  • preco :: Prec

    Outer precedence: used for the combined value.

TAdvancedProduct

Advance product type. First, a number of slices of the binary are translated. Then, the subsignals are picked from these translations, and the value is constructed from fixed strings and values from the translators.

  • *Important**: Slice indices start to the left, i.e. with the MSB!

Fields

TDuplicate SubSignal Translator

Translate the binary data using the translator specified, and duplicate the value into a subsignal of the provided name. This duplication applies the WSInherit 0 style to copy the actual style of the subvalue.

TStyled WaveStyle Translator

Apply a style to a translation, replacing only WSDefault. This translator is purely cosmetic and otherwise does not influence translation.

TChangeBits

Modify the binary input of the contained translator The binary data is modified using bits (see BitPart) before being passed onto the subtranslator.

Fields

TNumber

Translate the binary data as an integer. format and spacer determine how exactly the value is displayed.

Fields

TConst Translation

A constant translation value. The binary value provided is completely ignored.

Signal structure

newtype Structure Source #

A structure value that shows what subsignals are present.

Constructors

Structure [(SubSignal, Structure)] 

Instances

Instances details
ToJSON Structure Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Semigroup Structure Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Generic Structure Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Associated Types

type Rep Structure 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep Structure = D1 ('MetaData "Structure" "Clash.Shockwaves.Internal.Types" "clash-shockwaves-1.1.0-inplace" 'True) (C1 ('MetaCons "Structure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(SubSignal, Structure)])))
Show Structure Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep Structure Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep Structure = D1 ('MetaData "Structure" "Clash.Shockwaves.Internal.Types" "clash-shockwaves-1.1.0-inplace" 'True) (C1 ('MetaCons "Structure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(SubSignal, Structure)])))

structure :: Waveform a => Structure Source #

Return the structure of a type.

structureT :: Translator -> Structure Source #

Return the Structure implied by a Translator. Useful for determining the structure of a constant translation.

Translator-specific types

data NumberFormat Source #

Different number formats.

Constructors

NFSig

A signed decimal value.

NFUns

An unsigned decimal value.

NFHex

A hexadecimal value. Supports partially undefined values.

NFOct

An octal value. Supports partially undefined values.

NFBin

A binary value. Supports partially undefined values.

Instances

Instances details
ToJSON NumberFormat Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

NFData NumberFormat Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Methods

rnf :: NumberFormat -> () #

Generic NumberFormat Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Associated Types

type Rep NumberFormat 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep NumberFormat = D1 ('MetaData "NumberFormat" "Clash.Shockwaves.Internal.Types" "clash-shockwaves-1.1.0-inplace" 'False) ((C1 ('MetaCons "NFSig" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NFUns" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NFHex" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NFOct" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NFBin" 'PrefixI 'False) (U1 :: Type -> Type))))
Show NumberFormat Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep NumberFormat Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep NumberFormat = D1 ('MetaData "NumberFormat" "Clash.Shockwaves.Internal.Types" "clash-shockwaves-1.1.0-inplace" 'False) ((C1 ('MetaCons "NFSig" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NFUns" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NFHex" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NFOct" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NFBin" 'PrefixI 'False) (U1 :: Type -> Type))))

type DecSpacer = 'Just '(3, "_") Source #

Default spacer for decimal values (_ every 3 digits)

type HexSpacer = 'Just '(2, "_") Source #

Default spacer for hexadecimal values (_ every 2 digits)

type OctSpacer = 'Just '(4, "_") Source #

Default spacer for octal values (_ every 4 digits)

type BinSpacer = 'Just '(8, "_") Source #

Default spacer for binary values (_ every 8 digits)

type NoSpacer = 'Nothing :: Maybe NSPair Source #

Do not add spacers.

type SpacerEvery (n :: k) = 'Just '(n, "_") Source #

Add _ every n digits.

data ValuePart Source #

Parts of the value of TAdvancedProduct.

Constructors

VPLit String

A literal string.

VPRef Int Prec

The value of a subtranslation parsed with outer precedence.

data BitPart Source #

Parts of the binary output of TChangeBits. Each constructor modifies bits in a certain way.

More may be added later.

Constructors

BPIn

Return the input binary.

BPLit BitList

Return the BitList, ignoring the input.

BPSlice Slice BitPart

Return a slice of the input. **Important**: slice indices start to the left, i.e. with the MSB!

BPConcat [BitPart]

Pass the binary data onto multiple BitParts, and concatenate their results.

BPHasUndefined BitPart

Return `1` if there are undefined bits in the binary.

BPReverse BitPart

Return bits in reverse order.

BPInvert BitPart

Invert 0 and 1.

BPAnd [BitPart]

Bitwise and. If values of different lengths are provided, values are zero-padded on the left. Short-cirtuits (x & 0 = 0).

BPOr [BitPart]

Bitwise or. If values of different lengths are provided, values are zero-padded on the left. Short-cirtuits (x | 1 = 1).

BPXor [BitPart]

Bitwise xor. If multiple values of different lengths are provided, values are zero-padded on the left.

BPOneHot Slice BitPart

Turn a binary value into a one-hot signal based on the provided range. This essentially loops over all values in the range, creating a 1 iff the input BitPart's result is equal to that value. I.e. BPOneHot (0,3) "10" results in "001".

BPNHot Slice BitPart

Turn a binary value into a n-hot signal based on the provided range. This essentially loops over all values in the range, creating a 1 iff the input BitPart's result is less than or equal to that value.

BPIf BitPart BitPart BitPart BitPart

Switch bitparts based on the first bit in the condition bitpart: `BPIf (true) (false) (undef) (cond)`

Instances

Instances details
ToJSON BitPart Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

IsString BitPart Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Methods

fromString :: String -> BitPart #

Show BitPart Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Creating Translators

bitSize :: BitPack a => Int Source #

Returns the BitSize of a type as a runtime Int.

pprintT :: Translator -> String Source #

Debug function for pretty printing Translators. The output of this function may change. It is merely intended as a debug tool when creating and modifying translators.

defaultTranslator :: (Waveform a, WaveformG (Rep a ())) => Translator Source #

Return the default translator that is derived for a data type. This default can be modified to obtain a slightly different translator.

withConstructorStyles :: [WaveStyle] -> Translator -> Translator Source #

Apply constructor styles. This wraps TProduct translators and modifies the style of TConst translators. Does nothing if the list of styles is empty. Otherwise, errors if the number of styles does not match the number of constructors.

inheritSingleFieldStyle :: Translator -> Translator Source #

Wrap constructors with a single field in the WSInherit 0 style. Ignores any structures that are wrapped in a TStyled translator.

noConstructorSubsignals :: Bool -> Translator -> Translator Source #

Remove constructor subsignals from a (generated) translator. This results in all constructor field subsignals becoming direct subsignals of the toplevel signal. Set rename to True to add the constructor's name as a prefix to the signal name.

Essentially, this function searches through TStyled and TSum for any TDuplicate translators to remove. If renaming subsignals, it then searches through TStyled to rename subsignals in TProduct.

renameFields :: [[String]] -> Translator -> Translator Source #

Rename constructor fields. This is particularly useful for non-record types. The input is a list of a list of field names, per constructor. Errors if the number of constructors/fields does not match the structure of the Translator. For translators other than TProduct, use an empty list of fieldnames.

defaultTypeName :: forall {k} (a :: k). Typeable a => TypeName Source #

Obtain the default name of a type. The name consists of a unique fingerprint (which is safe to use) and a human readable representation of the type (which may not be unique if multiple sources define the same types).

tRef :: Waveform a => Translator Source #

Generate a translator reference for a type. Also checks whether the translator width matches the value of bitSize for the type: if not, the function errors.

tDup :: SubSignal -> Translator -> Translator Source #

Wrap a Translator in a TDuplicate variant translator with the provided subsignal name.

tStyled :: WaveStyle -> Translator -> Translator Source #

Wrap a Translator in a TStyled variant translator with the provided style.

tConst :: Render -> Translator Source #

Create a constant translator that consumes 0 bits and has no subsignals.

Special Waveform instances

class (BitPack a, Typeable a) => WaveformConst a where Source #

Helper class for defining a constant translation value. To use this, derive Waveform via WaveformForConst.

Minimal complete definition

constTrans | constRen

Methods

constTrans :: Translation Source #

The constant translation value. Overwrite this if the translation has subsignals.

constRen :: Render Source #

Constant render value. Overwrite this if the constant value has no subsignals.

Instances

Instances details
WaveformConst () Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

(KnownNat n, BitPack (SNat n)) => WaveformConst (SNat n) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

data WaveformForConst a Source #

Helper class for deriving Waveform for types implementing WaveformConst.

Instances

Instances details
BitPack a => BitPack (WaveformForConst a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

(WaveformConst a, BitPack a, Typeable a) => Waveform (WaveformForConst a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Generic (WaveformForConst a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Associated Types

type Rep (WaveformForConst a) 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

type Rep (WaveformForConst a) = D1 ('MetaData "WaveformForConst" "Clash.Shockwaves.Internal.Waveform" "clash-shockwaves-1.1.0-inplace" 'True) (C1 ('MetaCons "WfConst" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))
type BitSize (WaveformForConst a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

type Rep (WaveformForConst a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

type Rep (WaveformForConst a) = D1 ('MetaData "WaveformForConst" "Clash.Shockwaves.Internal.Waveform" "clash-shockwaves-1.1.0-inplace" 'True) (C1 ('MetaCons "WfConst" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

newtype WaveformForNumber (f :: NumberFormat) (s :: Maybe NSPair) a Source #

Helper class for deriving Waveform for numerical types. Options are provided at the type level (signed, format).

Example: deriving via WaveformForNumber NFSig ('Just '(3,"_")) instance Waveform (Signed 3)

Constructors

WaveformForNumber a 

Instances

Instances details
BitPack a => BitPack (WaveformForNumber f s a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Associated Types

type BitSize (WaveformForNumber f s a) 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

(BitPack a, Typeable a, Typeable f, Typeable s, KnownNFormat f, KnownNSpacer s) => Waveform (WaveformForNumber f s a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Generic (WaveformForNumber f s a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Associated Types

type Rep (WaveformForNumber f s a) 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

type Rep (WaveformForNumber f s a) = D1 ('MetaData "WaveformForNumber" "Clash.Shockwaves.Internal.Waveform" "clash-shockwaves-1.1.0-inplace" 'True) (C1 ('MetaCons "WaveformForNumber" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

from :: WaveformForNumber f s a -> Rep (WaveformForNumber f s a) x #

to :: Rep (WaveformForNumber f s a) x -> WaveformForNumber f s a #

type BitSize (WaveformForNumber f s a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

type Rep (WaveformForNumber f s a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

type Rep (WaveformForNumber f s a) = D1 ('MetaData "WaveformForNumber" "Clash.Shockwaves.Internal.Waveform" "clash-shockwaves-1.1.0-inplace" 'True) (C1 ('MetaCons "WaveformForNumber" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))