clash-lib-1.2.4: CAES Language for Synchronous Hardware - As a Library
Copyright(C) 2012-2016 University of Twente
2016-2017 Myrtle Software Ltd
LicenseBSD2 (see the file LICENSE)
MaintainerChristiaan Baaij <christiaan.baaij@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Netlist.BlackBox.Util

Description

Utilties to verify blackbox contexts against templates and rendering filled in templates

Synopsis

Documentation

verifyBlackBoxContext Source #

Arguments

:: BlackBoxContext

Blackbox to verify

-> BlackBox

Template to check against

-> Maybe String 

Determine if the number of normalliteralfunction inputs of a blackbox context at least matches the number of argument that is expected by the template.

setSym :: forall m. Monad m => (IdType -> Identifier -> m Identifier) -> BlackBoxContext -> BlackBoxTemplate -> m (BlackBoxTemplate, [Declaration]) Source #

Update all the symbol references in a template, and increment the symbol counter for every newly encountered symbol.

selectNewName Source #

Arguments

:: Foldable t 
=> t String

Set of existing names

-> FilePath

Name for new file (

-> String 

renderTemplate Source #

Arguments

:: Backend backend 
=> BlackBoxContext

Context used to fill in the hole

-> BlackBoxTemplate

Blackbox template

-> State backend (Int -> Text) 

Render a blackbox given a certain context. Returns a filled out template and a list of hidden inputs that must be added to the encompassing component.

renderElem :: HasCallStack => Backend backend => BlackBoxContext -> Element -> State backend (Int -> Text) Source #

Render a single template element

lineToIdentifier :: Backend backend => BlackBoxContext -> BlackBoxTemplate -> State backend Text Source #

Fill out the template corresponding to an output/input assignment of a component instantiation, and turn it into a single identifier so it can be used for a new blackbox context.

renderTag :: Backend backend => BlackBoxContext -> Element -> State backend Text Source #

Give a context and a tagged hole (of a template), returns part of the context that matches the tag of the hole.

elementsToText :: BlackBoxContext -> [Element] -> Either String Text Source #

Compute string from a list of elements. Can interpret ~NAME string literals on template level (constants).

exprToString :: Expr -> Maybe String Source #

Extracts string from SSymbol or string literals

walkElement :: (Element -> Maybe a) -> Element -> [a] Source #

Recursively walk Element, applying f to each element in the tree.

usedVariables :: Expr -> [Identifier] Source #

Determine variables used in an expression. Used for VHDL sensitivity list. Also see: https://github.com/clash-lang/clash-compiler/issues/365

getUsedArguments :: BlackBox -> [Int] Source #

Collect arguments (e.g., ~ARG, ~LIT) used in this blackbox