clash-lib
Copyright(C) 2012-2016 University of Twente
2016-2017 Myrtle Software Ltd
2021-2023 QBayLogic B.V.
2022 LUMI GUIDE FIETSDETECTIE B.V.
2022 Google Inc.
LicenseBSD2 (see the file LICENSE)
MaintainerQBayLogic B.V. <devops@qbaylogic.com>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Clash.Netlist.BlackBox.Util

Description

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

Synopsis

Documentation

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.

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

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

verifyBlackBoxContext Source #

Arguments

:: BlackBoxContext

Blackbox to verify

-> BlackBox

Template to check against

-> Maybe String 

Determine if the number of normal/literal/function inputs of a blackbox context at least matches the number of argument that is expected by the template.

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

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

getUsedArguments :: BlackBox -> [Int] Source #

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

canonicalizeDataFilePath Source #

Arguments

:: [FilePath]

Import directories passed in with -i

-> FilePath

File to canonicalize

-> FilePath 

Canonicalizes a datafile path, keeping in mind that the path might be relative to one of the import directories passed in with -i.

addFilePath Source #

Arguments

:: [FilePath]

Import directories passed in with -i

-> Map FilePath FileName

Map of existing file paths to file names. The file names are guaranteed to be unique, as long as this function is used to add new file paths.

-> FilePath

New file path to add. The canonicalized version of this file path is stored in the map. See canonicalizeFilePath.

-> (Map FilePath FileName, FileName)

Updated map and filename. Note that the returned filename might be different from the filename in the given filepath in case of naming collisions.

Add a data file to a collection of existing files. Typically used in the HDL backend's addAndSetData.

exprToString :: Expr -> Maybe String Source #

Extracts string from SSymbol or string literals

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

Render a single template element

getDomainConf :: (Backend backend, HasCallStack) => HWType -> State backend VDomainConfiguration Source #