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.LUT

Description

Everything needed to create Waveform instances that use lookup tables.

Synopsis

WaveformLUT

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

Class for easily defining custom translations for a type by using LUTs. To use this class, a type must derive Waveform via WaveformForLut.

Bye default, the implementation uses Generic for defining subsignals and operator precedence, and Show for displaying the value.

Minimal complete definition

Nothing

Methods

structureL :: Structure Source #

Provides the hierarchy of subsignals.

default structureL :: WaveformG (Rep a ()) => Structure Source #

translateL :: a -> Translation Source #

Translate a value. The translations must adhere to the structure defined in structureL. This function must be robust to undefined values!

default translateL :: (Generic a, Show a, WaveformG (Rep a ()), PrecG (Rep a ())) => a -> Translation Source #

staticL :: Maybe [(a, Translation)] Source #

A static lookup table. To use a static lookup table rather than one created from the values found during simulation, set this to a list of values and their translations. Set translateL and structureL to undefined.

Instances

Instances details
WaveformLUT Bit Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

BitPack Char => WaveformLUT Char Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

WaveformLUT Double Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

WaveformLUT Float Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

KnownDomain dom => WaveformLUT (CREWave dom) Source #

Control the style of a combined disable and reset through style variable reset_on_enable_off.

Instance details

Defined in Clash.Shockwaves.Internal.Trace.CRE

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

Defined in Clash.Shockwaves.Internal.Waveform

translateWith :: (a -> Render) -> (Render -> a -> [(SubSignal, Translation)]) -> a -> Translation Source #

Given a function that renders a value, and a function that (given this Render) prodices the subsignals, create a translation. If rendering fails, "undefined" is displayed. If creating the subsignals fails, no subsignals are shown.

renderWith :: (a -> Value) -> (a -> WaveStyle) -> (a -> Prec) -> a -> Render Source #

Display a value with the provided functions for creating the text value, style and operator precedence.

renderShow :: (Show a, Generic a, PrecG (Rep a ())) => a -> Render Source #

Display a value with Show, the default wave style, and operator precedence determined using Generic.

translateAtomWith :: (a -> Value) -> a -> Translation Source #

Display an atomic value (such as a number) using the provided function to obtain the value. (normal wavestyle, precedence 11).

translateAtomShow :: Show a => a -> Translation Source #

Display an atomic value (like a number) with Show. See translateAtomWith.

translateAtomSigWith :: Show a => (a -> Value) -> a -> Translation Source #

Render an atomic value representing a signed number. If the render value is found to start with -, the precedence is set to 0.

translateAtomSigShow :: Show a => a -> Translation Source #

Render an atomic value representing a signed number using show. See translateAtomSigWith.

noSplit :: Render -> a -> [(SubSignal, Translation)] Source #

Create no subsignals for this type.

splitL :: (Generic a, WaveformG (Rep a ())) => Render -> a -> [(SubSignal, Translation)] Source #

Create subsignals for the constructors and fields. Constructor translations are a copy of the toplevel render value provided.

precL :: (PrecG (Rep a ()), Generic a) => a -> Prec Source #

Get the operator precedence of a value.

newtype WaveformForLut a Source #

Type for deriving Waveform for types implementing WaveformLUT.

type T = ... deriving (...)
deriving via WaveformForLut T instance Waveform T

isntance WaveformLUT T where
  ...

Constructors

WaveformForLut a 

Instances

Instances details
BitPack a => BitPack (WaveformForLut 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

Generic (WaveformForLut a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Associated Types

type Rep (WaveformForLut a) 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

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

Defined in Clash.Shockwaves.Internal.Waveform

type Rep (WaveformForLut a) Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

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

tLut :: (Waveform a, WaveformLUT a) => Maybe LUT -> Translator Source #

Create a LUT translator for a type, using either the static LUT or the translation function specified in WaveformLUT

tGeneratedLut :: (Waveform a, WaveformLUT a) => Translator Source #

Create a LUT translator for a type, using the translation function of WaveformLUT.

tStaticLut :: (Waveform a, WaveformLUT a) => LUT -> Translator Source #

Create a LUT translator for a type, using the static LUT in WaveformLUT.

Utility

defaultRender :: Value -> Render Source #

Get a Render from a Value using WSDefault and precedence 11.

safeWHNF :: a -> Maybe a Source #

Evaluate to WHNF. If this fails, return a default value.

safeNF :: NFData a => a -> Maybe a Source #

Check if a value is completely defined.

safeNFOr :: NFData a => a -> a -> a Source #

Check if a value is completely defined. If not, return the default value provided.

safeTranslation :: Translation -> Translation Source #

Make sure a Translation is fully defined. If not, return a Translation with "undefined".

errorT :: Value -> Translation Source #

Create a translation from an error message using errorR.

errorR :: Value -> Render Source #

Render some error message. The precedence is set to 11 (i.e. an atomic).

Standard Shockwaves types and functions

class (Typeable a, BitPack a) => Waveform a 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.

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

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 Value = String Source #

Text displayed as the value of a signal.

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 Prec = Integer Source #

Operator precedence of the value.

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

type SubSignal = String Source #

Name of a subsignal.

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.