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

Clash.Primitives.Util

Description

Utility functions to generate Primitives

Synopsis

Documentation

generatePrimMap Source #

Arguments

:: HasCallStack 
=> [UnresolvedPrimitive]

unresolved primitives found in annotations (in LoadModules and LoadInterfaceFiles)

-> [(Text, PrimitiveGuard ())] 
-> [FilePath]

Directories to search for primitive definitions

-> IO ResolvedPrimMap 

Generate a set of primitives that are found in the primitive definition files in the given directories.

hashCompiledPrimMap :: CompiledPrimMap -> Int Source #

Hash a compiled primitive map. It needs a separate function (as opposed to just hash) as it might contain (obviously unhashable) Haskell functions. This function takes the hash value stored with the function instead.

constantArgs :: Text -> CompiledPrimitive -> Set Int Source #

Determine what argument should be constant / literal

decodeOrErr Source #

Arguments

:: (HasCallStack, FromJSON a) 
=> FilePath

Path read from (for error message)

-> ByteString

Bytestring to parse

-> a 

Parse a ByteString according to the given JSON template. Throws exception if it fails.

getFunctionPlurality Source #

Arguments

:: HasCallStack 
=> CompiledPrimitive 
-> [Either Term Type]

Arguments passed to blackbox

-> [Type]

Result types

-> Int

Argument number holding the function of interest

-> NetlistMonad Int

Plurality of function. Defaults to 1. Does not err if argument isn't a function in the first place. State of monad will not be modified.

Looks up the plurality of a function's function argument. See functionPlurality for more information. If not set, the returned plurality will default to 1.