clash-lib-1.8.4: Clash: a functional hardware description language - As a library

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.
License | BSD2 (see the file LICENSE)
Maintainer | QBayLogic B.V. <devops@qbaylogic.com>
Safe Haskell | None
Language | Haskell2010

Clash.Netlist.BlackBox.Util

Description

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

Synopsis

- renderTemplate :: Backend backend => BlackBoxContext -> BlackBoxTemplate -> State backend (Int -> Text)
- walkElement :: (Element -> Maybe a) -> Element -> [a]
- verifyBlackBoxContext :: BlackBoxContext -> BlackBox -> Maybe String
- onBlackBox :: (BlackBoxTemplate -> r) -> (BBName -> BBHash -> TemplateFunction -> r) -> BlackBox -> r
- setSym :: IdentifierSetMonad m => BlackBoxContext -> BlackBoxTemplate -> m (BlackBoxTemplate, [Declaration])
- extractLiterals :: BlackBoxContext -> [Expr]
- renderBlackBox :: Backend backend => [BlackBoxTemplate] -> [BlackBoxTemplate] -> [((Text, Text), BlackBox)] -> BlackBox -> BlackBoxContext -> State backend (Int -> Doc)
- getUsedArguments :: BlackBox -> [Int]
- canonicalizeDataFilePath :: [FilePath] -> FilePath -> FilePath
- addFilePath :: [FilePath] -> Map FilePath FileName -> FilePath -> (Map FilePath FileName, FileName)
- exprToString :: Expr -> Maybe String
- renderElem :: (HasCallStack, Backend backend) => BlackBoxContext -> Element -> State backend (Int -> Text)
- getDomainConf :: (Backend backend, HasCallStack) => HWType -> State backend VDomainConfiguration
- prettyBlackBox :: forall (m :: Type -> Type). Monad m => BlackBoxTemplate -> Ap m Text

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

onBlackBox :: (BlackBoxTemplate -> r) -> (BBName -> BBHash -> TemplateFunction -> r) -> BlackBox -> r Source #

setSym :: 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.

extractLiterals :: BlackBoxContext -> [Expr] Source #

renderBlackBox :: Backend backend => [BlackBoxTemplate] -> [BlackBoxTemplate] -> [((Text, Text), BlackBox)] -> BlackBox -> BlackBoxContext -> State backend (Int -> Doc) Source #

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 #

prettyBlackBox :: forall (m :: Type -> Type). Monad m => BlackBoxTemplate -> Ap m Text Source #