From c2ada55bccc73cb604b77270049f0cfcc7e92bb8 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Mon, 29 Jul 2019 15:47:22 +0200 Subject: Use HashMap for context --- src/VeriFuzz/Context.hs | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/VeriFuzz/Context.hs (limited to 'src/VeriFuzz/Context.hs') diff --git a/src/VeriFuzz/Context.hs b/src/VeriFuzz/Context.hs new file mode 100644 index 0000000..8aeed8d --- /dev/null +++ b/src/VeriFuzz/Context.hs @@ -0,0 +1,59 @@ +{-| +Module : VeriFuzz.Context +Description : Context types used in the generation. +Copyright : (c) 2019, Yann Herklotz +License : GPL-3 +Maintainer : yann [at] yannherklotz [dot] com +Stability : experimental +Portability : POSIX + +Context types used in the generation of the Verilog. +-} + +{-# LANGUAGE TemplateHaskell #-} + +module VeriFuzz.Context + ( -- * Context types + Context (..) + , variables + , parameters + , modules + , nameCounter + , stmntDepth + , modDepth + , determinism + , VarContext (..) + , ParamContext (..) + , ModuleContext (..) + , PortContext (..) + , portContPort + , portContND + ) +where + +import Control.Lens (makeLenses) +import Data.HashMap.Lazy (HashMap) +import VeriFuzz.Verilog + +data PortContext = PortContext { _portContPort :: !Port + , _portContND :: !Bool + } + +$(makeLenses ''PortContext) + +type VarContext = HashMap Identifier PortContext + +type ParamContext = HashMap Identifier Parameter + +type ModuleContext = HashMap Identifier ModDecl + +data Context = Context { _variables :: VarContext + , _parameters :: ParamContext + , _modules :: ModuleContext + , _nameCounter :: {-# UNPACK #-} !Int + , _stmntDepth :: {-# UNPACK #-} !Int + , _modDepth :: {-# UNPACK #-} !Int + , _determinism :: !Bool + } + +$(makeLenses ''Context) -- cgit