clash-lib-1.6.3: Clash: a functional hardware description language - As a library
Copyright(C) 2012-2016 University of Twente
2016-2017 Myrtle Software Ltd
2017 Google Inc.
2021-2022 QBayLogic B.V.
LicenseBSD2 (see the file LICENSE)
MaintainerQBayLogic B.V. <devops@qbaylogic.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Netlist.BlackBox

Description

Functions to create BlackBox Contexts and fill in BlackBox templates

Synopsis

Documentation

warn :: ClashOpts -> String -> IO () Source #

Emits (colorized) warning to stderr

mkBlackBoxContext Source #

Arguments

:: HasCallStack 
=> Text

Blackbox function name

-> [Id]

Identifiers binding the primitive/blackbox application

-> [Either Term Type]

Arguments of the primitive/blackbox application

-> NetlistMonad (BlackBoxContext, [Declaration]) 

Generate the context for a BlackBox instantiation.

isLiteral :: Term -> Bool Source #

Determine if a term represents a literal

mkArgument Source #

Arguments

:: Text

Blackbox function name

-> Identifier

LHS of the original let-binder. Is used as a name hint to generate new names in case the argument is a declaration.

-> Int

Argument n (zero-indexed). Used for error message.

-> Term 
-> NetlistMonad ((Expr, HWType, Bool), [Declaration]) 

extractPrimWarnOrFail Source #

Arguments

:: HasCallStack 
=> Text

Name of primitive

-> NetlistMonad CompiledPrimitive 

Extract a compiled primitive from a guarded primitive. Emit a warning if the guard wants to, or fail entirely.

mkPrimitive Source #

Arguments

:: Bool

Put BlackBox expression in parenthesis

-> Bool

Treat BlackBox expression as declaration

-> NetlistId

Id to assign the result to

-> PrimInfo

Primitive info

-> [Either Term Type]

Arguments

-> [Declaration]

Tick declarations

-> NetlistMonad (Expr, [Declaration]) 

collectMealy Source #

Arguments

:: HasCallStack 
=> Identifier

Identifier to assign the final result to

-> NetlistId

Id to assign the final result to

-> TyConMap 
-> [Term]

The arguments to mealyIO

-> NetlistMonad [Declaration] 

Turn a mealyIO expression into a two sequential processes, one "initial" process for the starting state, and one clocked sequential process.

collectBindIO :: NetlistId -> [Term] -> NetlistMonad (Expr, [Declaration]) Source #

Collect the sequential declarations for bindIO

collectAppIO :: NetlistId -> [Term] -> [Term] -> NetlistMonad (Expr, [Declaration]) Source #

Collect the sequential declarations for appIO

unSimIO :: TyConMap -> Term -> Term Source #

Unwrap the new-type wrapper for things of type SimIO, this is needed to allow applications of the `State# World` token to the underlying IO type.

XXX: this is most likely needed because Ghc2Core that threw away the cast that this unwrapping; we should really start to support casts.

mkFunInput Source #

Arguments

:: HasCallStack 
=> Id

Identifier binding the encompassing primitive/blackbox application. Used as a name hint if mkFunInput needs intermediate signals.

-> Term

The function argument term

-> NetlistMonad ((Either BlackBox (Identifier, [Declaration]), WireOrReg, [BlackBoxTemplate], [BlackBoxTemplate], [((Text, Text), BlackBox)], BlackBoxContext), [Declaration]) 

Create an template instantiation text and a partial blackbox content for an argument term, given that the term is a function. Errors if the term is not a function