Copyright | (C) 2012-2016 University of Twente 2016 Myrtle Software Ltd 2017 Google Inc. |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Turn CoreHW terms into normalized CoreHW Terms
Synopsis
- runNormalization :: ClashOpts -> Supply -> BindingMap -> (HashMap TyConOccName TyCon -> Bool -> Type -> Maybe (Either String HWType)) -> HashMap TyConOccName TyCon -> IntMap TyConName -> PrimEvaluator -> PrimMap BlackBoxTemplate -> HashMap TmOccName Bool -> [TmOccName] -> NormalizeSession a -> a
- normalize :: [TmOccName] -> NormalizeSession BindingMap
- normalize' :: TmOccName -> NormalizeSession ([TmOccName], (TmOccName, (TmName, Type, SrcSpan, InlineSpec, Term)))
- rewriteExpr :: (String, NormRewrite) -> (String, Term) -> NormalizeSession Term
- checkNonRecursive :: BindingMap -> BindingMap
- cleanupGraph :: TmOccName -> BindingMap -> NormalizeSession BindingMap
- data CallTree
- mkCallTree :: [TmOccName] -> BindingMap -> TmOccName -> Maybe CallTree
- stripArgs :: [TmOccName] -> [Id] -> [Either Term Type] -> Maybe [Either Term Type]
- flattenNode :: CallTree -> NormalizeSession (Either CallTree ((TmOccName, Term), [CallTree]))
- flattenCallTree :: CallTree -> NormalizeSession CallTree
- callTreeToList :: [TmOccName] -> CallTree -> ([TmOccName], [(TmOccName, (TmName, Type, SrcSpan, InlineSpec, Term))])
- clockResetErrors :: SrcSpan -> (HashMap TyConOccName TyCon -> Bool -> Type -> Maybe (Either String HWType)) -> HashMap TyConOccName TyCon -> Type -> [String]
Documentation
:: ClashOpts | Level of debug messages to print |
-> Supply | UniqueSupply |
-> 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] | topEntities |
-> NormalizeSession a | NormalizeSession to run |
-> a |
Run a NormalizeSession in a given environment
normalize :: [TmOccName] -> NormalizeSession BindingMap Source #
normalize' :: TmOccName -> NormalizeSession ([TmOccName], (TmOccName, (TmName, Type, SrcSpan, InlineSpec, Term))) Source #
:: (String, NormRewrite) | Transformation to apply |
-> (String, Term) | Term to transform |
-> NormalizeSession Term |
Rewrite a term according to the provided transformation
:: 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
:: [TmOccName] | Visited |
-> BindingMap | Global binders |
-> TmOccName | Root of the call graph |
-> Maybe CallTree |
flattenNode :: CallTree -> NormalizeSession (Either CallTree ((TmOccName, Term), [CallTree])) Source #
callTreeToList :: [TmOccName] -> CallTree -> ([TmOccName], [(TmOccName, (TmName, Type, SrcSpan, InlineSpec, Term))]) Source #
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.