clash-lib-0.99.2: CAES Language for Synchronous Hardware - As a Library

Copyright(C) 2012-2016 University of Twente
2016 Myrtle Software Ltd
2017 Google Inc.
LicenseBSD2 (see the file LICENSE)
MaintainerChristiaan Baaij <>
Safe HaskellNone



Turn CoreHW terms into normalized CoreHW Terms



runNormalization Source #


:: ClashOpts

Level of debug messages to print

-> Supply


-> BindingMap

Global Binders

-> (HashMap TyConOccName TyCon -> Bool -> Type -> Maybe (Either String HWType))

Hardcoded Type -> HWType translator

-> HashMap TyConOccName TyCon

TyCon cache

-> IntMap TyConName

Tuple TyCon cache

-> PrimEvaluator

Hardcoded evaluator (delta-reduction)

-> PrimMap BlackBoxTemplate

Primitive Definitions

-> HashMap TmOccName Bool

Map telling whether a components is part of a recursive group

-> [TmOccName]


-> NormalizeSession a

NormalizeSession to run

-> a 

Run a NormalizeSession in a given environment

rewriteExpr Source #


:: (String, NormRewrite)

Transformation to apply

-> (String, Term)

Term to transform

-> NormalizeSession Term 

Rewrite a term according to the provided transformation

checkNonRecursive Source #


:: BindingMap

List of normalized binders

-> BindingMap 

Check whether the normalized bindings are non-recursive. Errors when one of the components is recursive.

cleanupGraph :: TmOccName -> BindingMap -> NormalizeSession BindingMap Source #

Perform general "clean up" of the normalized (non-recursive) function hierarchy. This includes:

  • Inlining functions that simply "wrap" another function

mkCallTree Source #


:: [TmOccName]


-> BindingMap

Global binders

-> TmOccName

Root of the call graph

-> Maybe CallTree 

clockResetErrors :: SrcSpan -> (HashMap TyConOccName TyCon -> Bool -> Type -> Maybe (Either String HWType)) -> HashMap TyConOccName TyCon -> Type -> [String] Source #

Clash's clock and reset domain annotations prevent most accidental meta-stability situations. That is, unless the developer uses the functions marked "unsafe", the type system will prevent things like illegal clock domain crossing, or improper use of asynchronous resets.

However, this all depends on clock and resets being unique. With explicit clocks and resets, it is possible to have multiple clock and reset arguments that are annotated with the same domain. If these arguments aren't connected to the same source, we can still get metastability due to either illegal clock domain crossing, or improper use of asynchronous resets.

The following situations are reported: * There are 2 or more clock arguments in scope that have the same clock domain annotation. * There are 2 or more reset arguments in scope that have the same reset domain annotation, and at least one of them is an asynchronous reset.