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

Description

Code for rendering values using the translators specified. Values are constructed from their subvalues.

Synopsis

Documentation

applyStyleR :: WaveStyle -> Render -> Render Source #

Apply a WaveStyle to a Render value. Only replaces WSDefault.

applyPrec :: Prec -> Translation -> Translation Source #

Apply a precedence value to a Translation. If the precedence is higher or equal to that of the current value, it is wrapped in parentheses.

applyPrecR :: Prec -> Render -> Render Source #

Apply a precedence value to a Render. If the precedence is higher or equal to that of the current value, it is wrapped in parentheses.

applyPrecs :: Prec -> [(a, Translation)] -> [(a, Translation)] Source #

Apply a precedence value to a list of subsignal translations. If the precedence is higher or equal to that of the current value, it is wrapped in parentheses.

getVal :: Translation -> Value Source #

Get the value of a Translation. If the value is not defined, return {value missing}.

filterSignals :: [(SubSignal, Translation)] -> [(SubSignal, Translation)] Source #

Remove subsignal translators that do not have a subsignal name.

changeBits :: BitPart -> BitList -> BitList Source #

Change bits using BitPart.

decodeUns :: Integer -> String -> Maybe Integer Source #

Decode a string of bits into an unsigned integer.

decodeSig :: String -> Maybe Integer Source #

Decode a string of bits into a signed integer.

translateFromSubs :: Translator -> [(SubSignal, Translation)] -> Translation Source #

Complete a translation based on already translated subsignals.

The exact behaviour is non-trivial. Translators that require special translation (TRef,TLut,TNumber) cannot be translated. If a single subsignal is provided with label `""`, this translation is used as if it was the result of the translation. Otherwise, an error is raised.

TSum, TProduct, TArray and TConst render a value as expected based on the subtranslations. Note for TSum that this is a list containing only the translation of the variant used, i.e. it behaves like TRef, TLut and TNumber.

Advanced translators are not supported.

The final two variants, TStyled and TDuplicate are considered wrappers and translate the value recursively.

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

Translate a BitList using the provided translator.

structureT :: Translator -> Structure Source #

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

foldTranslator :: (Translator -> a) -> ([a] -> b) -> Translator -> b Source #

Run a function on a translator's subtranslators, and combine the results. This follows TRef references.

hasGeneratedLutT :: Translator -> Bool Source #

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

addTypesT :: Translator -> TypeMap -> TypeMap Source #

Add all type references in a translator structure to a type map. To add the types in a type, run this function on a reference to said type.

addValueT :: Translator -> BitList -> [LUTMap -> LUTMap] Source #

From a translator, create a function that given a binary value returns a list of functions to add all LUT values to the LUT maps.

getStaticLuts :: Translator -> [(String, LUT)] Source #

Get all static LUTs in a Translator, not following references.