clash-lib-0.2.0.1: CAES Language for Synchronous Hardware - As a Library

Safe HaskellNone

CLaSH.Netlist.Util

Description

Utilities for converting Core Type/Term to Netlist datatypes

Synopsis

Documentation

splitNormalized :: (Fresh m, Functor m) => Term -> m (Either String ([Id], [LetBinding], Id))Source

Split a normalized term into: a list of arguments, a list of let-bindings, and a variable reference that is the body of the let-binding. Returns a String containing the error is the term was not in a normalized form.

unsafeCoreTypeToHWType :: (Type -> Maybe (Either String HWType)) -> Type -> HWTypeSource

Converts a Core type to a HWType given a function that translates certain builtin types. Errors if the Core type is not translatable.

unsafeCoreTypeToHWTypeM :: Type -> NetlistMonad HWTypeSource

Converts a Core type to a HWType within the NetlistMonad

synchronizedClk :: Type -> Maybe IdentifierSource

Returns the name of the clock corresponding to a type

coreTypeToHWType :: (Type -> Maybe (Either String HWType)) -> Type -> Either String HWTypeSource

Converts a Core type to a HWType given a function that translates certain builtin types. Returns a string containing the error message when the Core type is not translatable.

mkADTSource

Arguments

:: (Type -> Maybe (Either String HWType))

Hardcoded Type -> HWType translator

-> String

String representation of the Core type for error messages

-> TyCon

The TyCon

-> [Type]

Its applied arguments

-> Either String HWType 

Converts an algebraic Core type (split into a TyCon and its argument) to a HWType.

isRecursiveTy :: TyCon -> BoolSource

Simple check if a TyCon is recursively defined.

representableType :: (Type -> Maybe (Either String HWType)) -> Type -> BoolSource

Determines if a Core type is translatable to a HWType given a function that translates certain builtin types.

typeSize :: HWType -> IntSource

Determines the bitsize of a type

conSize :: HWType -> IntSource

Determines the bitsize of the constructor of a type

typeLength :: HWType -> IntSource

Gives the length of length-indexed types

termHWType :: Term -> NetlistMonad HWTypeSource

Gives the HWType corresponding to a term. Returns an error if the term has a Core type that is not translatable to a HWType.

varToExpr :: Term -> ExprSource

Turns a Core variable reference to a Netlist expression. Errors if the term is not a variable.

mkUniqueNormalized :: ([Id], [LetBinding], Id) -> NetlistMonad ([Id], [LetBinding], TmName)Source

Uniquely rename all the variables and their references in a normalized term

appendToName :: TmName -> String -> TmNameSource

Append a string to a name

preserveVarEnv :: NetlistMonad a -> NetlistMonad aSource

Preserve the Netlist _varEnv and _varCount when executing a monadic action