aboutsummaryrefslogtreecommitdiffstats
path: root/src/VeriFuzz/Context.hs
blob: 8aeed8d236f449952126c56040fa8f4f93a08949 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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)