| Copyright | (C) 2025-2026 QBayLogic B.V. |
|---|---|
| License | BSD2 (see the file LICENSE) |
| Maintainer | QBayLogic B.V. <devops@qbaylogic.com> |
| Safe Haskell | None |
| Language | Haskell2010 |
Clash.Shockwaves.LUT
Description
Everything needed to create Waveform instances that use lookup tables.
Synopsis
- class (Typeable a, BitPack a) => WaveformLUT a where
- structureL :: Structure
- translateL :: a -> Translation
- staticL :: Maybe [(a, Translation)]
- translateWith :: (a -> Render) -> (Render -> a -> [(SubSignal, Translation)]) -> a -> Translation
- renderWith :: (a -> Value) -> (a -> WaveStyle) -> (a -> Prec) -> a -> Render
- renderShow :: (Show a, Generic a, PrecG (Rep a ())) => a -> Render
- translateAtomWith :: (a -> Value) -> a -> Translation
- translateAtomShow :: Show a => a -> Translation
- translateAtomSigWith :: Show a => (a -> Value) -> a -> Translation
- translateAtomSigShow :: Show a => a -> Translation
- noSplit :: Render -> a -> [(SubSignal, Translation)]
- splitL :: (Generic a, WaveformG (Rep a ())) => Render -> a -> [(SubSignal, Translation)]
- precL :: (PrecG (Rep a ()), Generic a) => a -> Prec
- newtype WaveformForLut a = WaveformForLut a
- tLut :: (Waveform a, WaveformLUT a) => Maybe LUT -> Translator
- tGeneratedLut :: (Waveform a, WaveformLUT a) => Translator
- tStaticLut :: (Waveform a, WaveformLUT a) => LUT -> Translator
- defaultRender :: Value -> Render
- safeWHNF :: a -> Maybe a
- safeNF :: NFData a => a -> Maybe a
- safeNFOr :: NFData a => a -> a -> a
- safeTranslation :: Translation -> Translation
- errorT :: Value -> Translation
- errorR :: Value -> Render
- class (Typeable a, BitPack a) => Waveform a
- data Translation = Translation Render [(SubSignal, Translation)]
- type Value = String
- data WaveStyle
- type Prec = Integer
- newtype Structure = Structure [(SubSignal, Structure)]
- type SubSignal = String
- structure :: Waveform a => Structure
- structureT :: Translator -> Structure
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.
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
| WaveformLUT Bit Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| BitPack Char => WaveformLUT Char Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| WaveformLUT Double Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| WaveformLUT Float Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| KnownDomain dom => WaveformLUT (CREWave dom) Source # | Control the style of a combined disable and reset through style variable
|
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 # | |
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.
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.
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.
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
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 #
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".
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
| Waveform Bit Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform ClockWave Source # | Control the styles of the clock wave through style variables
|
Defined in Clash.Shockwaves.Internal.Trace.CRE | |
| Waveform EnableWave Source # | Control the styles of the enable wave through style variables
|
Defined in Clash.Shockwaves.Internal.Trace.CRE | |
| Waveform Int16 Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform Int32 Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform Int64 Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform Int8 Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform Word16 Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform Word32 Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform Word64 Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform Word8 Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform Ordering Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform () Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform Bool Source # | Configure styles through style variables |
Defined in Clash.Shockwaves.Internal.Waveform | |
| BitPack Char => Waveform Char Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform Double Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform Float Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform Int Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform Word Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform a => Waveform (Complex a) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform a => Waveform (Erroring a) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform a => Waveform (Overflowing a) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform a => Waveform (Saturating a) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform a => Waveform (Wrapping a) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform a => Waveform (Zeroing a) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| (KnownNat n, BitPack (SNat n)) => Waveform (SNat n) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| KnownNat n => Waveform (BitVector n) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| (1 <= n, KnownNat n) => Waveform (Index n) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| KnownNat n => Waveform (Signed n) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| KnownNat n => Waveform (Unsigned n) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| KnownDomain dom => Waveform (CREWave dom) Source # | |
Defined in Clash.Shockwaves.Internal.Trace.CRE | |
| KnownDomain dom => Waveform (ResetWave dom) Source # | Control the styles of the reset wave through style variables
|
Defined in Clash.Shockwaves.Internal.Trace.CRE | |
| (WaveformConst a, BitPack a, Typeable a) => Waveform (WaveformForConst a) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| (Waveform a, WaveformLUT a, BitPack a, Typeable a) => Waveform (WaveformForLut a) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform a => Waveform (Identity a) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform a => Waveform (Down a) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| Waveform a => Waveform (Maybe a) Source # | Configure styles through style variables |
Defined in Clash.Shockwaves.Internal.Waveform | |
| (Waveform a, KnownNat d, WaveformRTree (RTreeIsLeaf d) d a) => Waveform (RTree d a) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| (KnownNat n, Waveform a) => Waveform (Vec n a) Source # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| (Waveform a, Waveform b) => Waveform (Either a b) Source # | Configure styles through style variables |
Defined in Clash.Shockwaves.Internal.Waveform | |
| (Waveform a1, Waveform a2) => Waveform (a1, a2) Source # | |
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 # | |
Defined in Clash.Shockwaves.Internal.Waveform | |
| (BitPack a, Typeable a, Typeable f, Typeable s, KnownNFormat f, KnownNSpacer s) => Waveform (WaveformForNumber f s a) Source # | |
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
|
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.
Constructors
| Translation Render [(SubSignal, Translation)] |
Instances
| ToJSON Translation Source # | |||||
Defined in Clash.Shockwaves.Internal.Types Methods toJSON :: Translation -> Value # toEncoding :: Translation -> Encoding # toJSONList :: [Translation] -> Value # toEncodingList :: [Translation] -> Encoding # omitField :: Translation -> Bool # | |||||
| NFData Translation Source # | |||||
Defined in Clash.Shockwaves.Internal.Types Methods rnf :: Translation -> () # | |||||
| Generic Translation Source # | |||||
Defined in Clash.Shockwaves.Internal.Types Associated Types
| |||||
| Show Translation Source # | |||||
Defined in Clash.Shockwaves.Internal.Types Methods showsPrec :: Int -> Translation -> ShowS # show :: Translation -> String # showList :: [Translation] -> ShowS # | |||||
| Eq Translation Source # | |||||
Defined in Clash.Shockwaves.Internal.Types | |||||
| type Rep Translation Source # | |||||
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)]))) | |||||
The style in which a signal should be displayed.
Constructors
| WSDefault | The default waveform style. It is rendered as |
| 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
| ToJSON WaveStyle Source # | |||||
| NFData WaveStyle Source # | |||||
Defined in Clash.Shockwaves.Internal.Types | |||||
| IsString WaveStyle Source # | A | ||||
Defined in Clash.Shockwaves.Internal.Types Methods fromString :: String -> WaveStyle # | |||||
| Generic WaveStyle Source # | |||||
Defined in Clash.Shockwaves.Internal.Types Associated Types
| |||||
| Show WaveStyle Source # | |||||
| Eq WaveStyle Source # | |||||
| type Rep WaveStyle Source # | |||||
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)))))) | |||||
A structure value that shows what subsignals are present.
Instances
structureT :: Translator -> Structure Source #
Return the Structure implied by a Translator. Useful for determining
the structure of a constant translation.