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.Internal.Types

Description

Type definitions for Shockwaves.

Synopsis

Documentation

type TypeName = String Source #

Name of a type.

type SubSignal = String Source #

Name of a subsignal.

type SignalName = SubSignal Source #

Name of a signal.

type Value = String Source #

Text displayed as the value of a signal.

type Prec = Integer Source #

Operator precedence of the value.

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.

type LUTName = TypeName Source #

Reference to a LUT.

type SignalMap = Map SignalName TypeName Source #

Map that links signal names to their types.

type TypeMap = Map TypeName Translator Source #

Map that links type names to their information.

type LUTMap = Map LUTName LUT Source #

Table of LUTs. Usually, the index is a type name, but this is not necessarily the case.

type LUT = Map BitList Translation Source #

A lookup table of Translations.

type Color = RGB Word8 Source #

The color type used in WaveStyle.

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)])))

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))))))

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 NumberSpacer = Maybe (Integer, String) Source #

A type for defining spacers and the way they are placed.

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)])))

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 TypeRef Source #

A type-agnostic reference to various waveform details of a type.

Constructors

TypeRef 

Fields

Instances

Instances details
Show TypeRef Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

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.

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

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.

type Slice = (Int, Int) Source #

A half open slice of Ints.

type ISlice = (Integer, Integer) Source #

A half open slice of Integers.

mergeDuplicateSubsignals :: [(SubSignal, Structure)] -> [(SubSignal, Structure)] Source #

Merge duplicate subsignals in a list of subsignal structures.