--------------------------------------------------------------------------------
-- |
-- Module       :  Language.Netlist.AST
-- Copyright    :  (c) Signali Corp. 2010
-- License      :  All rights reserved
--
-- Maintainer   : pweaver@signalicorp.com
-- Stability    : experimental
-- Portability  : non-portable (DeriveDataTypeable)
--
-- An abstract syntax tree (AST) for a generic netlist, kind of like a
-- high-level subset of Verilog and VHDL that is compatible with both languages.
--
-- There are no definitive semantics assigned to this AST.
--
-- For example, the user may choose to treat the bindings as recursive, so that
-- expressions can reference variables before their declaration, like in
-- Haskell, which is not supported in Verilog and VHDL.  in this case, the user
-- must fix the bindings when converting to an HDL.
--
-- Also, the user may treat module instantiations and processes as having an
-- implict clock/reset, so that they are not explicitly named in those
-- constructs in this AST.  Then, the clock and reset can be inserted when
-- generating HDL.
--
-- When you instantiate a module but information about that module is missing
-- (e.g. the clock/reset are implicit and you need to know what they are called
-- in that module), you can use ExternDecl (TODO) to declare a module's
-- interface so that you know how to instantiate it, or retrieve the interface
-- from a user-maintained database or by parsing and extracting from an HDL
-- file.
--------------------------------------------------------------------------------

{-# LANGUAGE DeriveDataTypeable #-}
{-# OPTIONS_GHC -Wall #-}
{-# OPTIONS_DERIVE --append -d Binary #-}

module Language.Netlist.AST where

import Data.Binary      ( Binary(..), putWord8, getWord8 )
import Data.Generics	( Data, Typeable )

-- -----------------------------------------------------------------------------

-- | A Module corresponds to a \"module\" in Verilog or an \"entity\" in VHDL.
data Module = Module
  { Module -> Ident
module_name    :: Ident
  , Module -> [(Ident, Maybe Range)]
module_inputs  :: [(Ident, Maybe Range)]
  , Module -> [(Ident, Maybe Range)]
module_outputs :: [(Ident, Maybe Range)]
  , Module -> [(Ident, Expr)]
module_statics :: [(Ident, ConstExpr)]
                   -- static parameters (VHDL "generic", Verilog "parameter")
  , Module -> [Decl]
module_decls   :: [Decl]
  }
  deriving (Module -> Module -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Module -> Module -> Bool
$c/= :: Module -> Module -> Bool
== :: Module -> Module -> Bool
$c== :: Module -> Module -> Bool
Eq, Eq Module
Module -> Module -> Bool
Module -> Module -> Ordering
Module -> Module -> Module
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Module -> Module -> Module
$cmin :: Module -> Module -> Module
max :: Module -> Module -> Module
$cmax :: Module -> Module -> Module
>= :: Module -> Module -> Bool
$c>= :: Module -> Module -> Bool
> :: Module -> Module -> Bool
$c> :: Module -> Module -> Bool
<= :: Module -> Module -> Bool
$c<= :: Module -> Module -> Bool
< :: Module -> Module -> Bool
$c< :: Module -> Module -> Bool
compare :: Module -> Module -> Ordering
$ccompare :: Module -> Module -> Ordering
Ord, Int -> Module -> ShowS
[Module] -> ShowS
Module -> Ident
forall a.
(Int -> a -> ShowS) -> (a -> Ident) -> ([a] -> ShowS) -> Show a
showList :: [Module] -> ShowS
$cshowList :: [Module] -> ShowS
show :: Module -> Ident
$cshow :: Module -> Ident
showsPrec :: Int -> Module -> ShowS
$cshowsPrec :: Int -> Module -> ShowS
Show, Typeable Module
Module -> Constr
Module -> DataType
(forall b. Data b => b -> b) -> Module -> Module
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Module -> u
forall u. (forall d. Data d => d -> u) -> Module -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Module -> m Module
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Module -> m Module
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Module
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Module -> c Module
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Module)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Module)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Module -> m Module
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Module -> m Module
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Module -> m Module
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Module -> m Module
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Module -> m Module
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Module -> m Module
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Module -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Module -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Module -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Module -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r
gmapT :: (forall b. Data b => b -> b) -> Module -> Module
$cgmapT :: (forall b. Data b => b -> b) -> Module -> Module
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Module)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Module)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Module)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Module)
dataTypeOf :: Module -> DataType
$cdataTypeOf :: Module -> DataType
toConstr :: Module -> Constr
$ctoConstr :: Module -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Module
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Module
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Module -> c Module
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Module -> c Module
Data, Typeable)

-- | An identifier name.
type Ident = String

-- | The size of a wire.
type Size = Int

-- | A declaration, analogous to an \"item\" in the Verilog formal syntax.
data Decl
  -- | A net (@wire@ in Verilog) has a continuously assigned value.  The net can
  -- be declared and assigned at the same time (@Just Expr@), or separately
  -- (@Nothing@) in a @NetAssign@.
  = NetDecl Ident (Maybe Range) (Maybe Expr)
  | NetAssign Ident Expr

  -- | A mem (@reg@ in Verilog) is stateful.  It can be assigned by a
  -- non-blocking assignment (or blocking, but we don't support those yet)
  -- within a process.  TODO: support optional initial value
  --
  -- The first range is the most significant dimension.
  -- So, @MemDecl x (0, 31) (7, 0)@ corresponds to the following in Verilog:
  -- @reg [7:0] x [0:31]@
  | MemDecl Ident (Maybe Range) (Maybe Range) (Maybe [Expr])

  -- | These are permanent assignments to memory locations,
  -- of the form mem[addr] = val
  | MemAssign Ident Expr Expr

  -- | A module/entity instantiation.  The arguments are the name of the module,
  -- the name of the instance, the parameter assignments, the input port
  -- connections, and the output port connections.
  | InstDecl Ident            -- name of the module
             Ident            -- name of the instance
             [(Ident, Expr)]  -- parameter assignments
             [(Ident, Expr)]  -- input port connections
             [(Ident, Expr)]  -- output port connections

  -- declare an external module entity
  -- TODO: ExternDecl ExternLang

  -- | A sequential process with clock and (optional) asynchronous reset.
  | ProcessDecl Event (Maybe (Event, Stmt)) Stmt

  -- | A statement that executes once at the beginning of simulation.
  -- Equivalent to Verilog \"initial\" statement.
  | InitProcessDecl Stmt

  -- | A basic comment (typically is placed above a decl of interest).
  -- Newlines are allowed, and generate new single line comments.
  | CommentDecl String

  deriving (Decl -> Decl -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Decl -> Decl -> Bool
$c/= :: Decl -> Decl -> Bool
== :: Decl -> Decl -> Bool
$c== :: Decl -> Decl -> Bool
Eq, Eq Decl
Decl -> Decl -> Bool
Decl -> Decl -> Ordering
Decl -> Decl -> Decl
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Decl -> Decl -> Decl
$cmin :: Decl -> Decl -> Decl
max :: Decl -> Decl -> Decl
$cmax :: Decl -> Decl -> Decl
>= :: Decl -> Decl -> Bool
$c>= :: Decl -> Decl -> Bool
> :: Decl -> Decl -> Bool
$c> :: Decl -> Decl -> Bool
<= :: Decl -> Decl -> Bool
$c<= :: Decl -> Decl -> Bool
< :: Decl -> Decl -> Bool
$c< :: Decl -> Decl -> Bool
compare :: Decl -> Decl -> Ordering
$ccompare :: Decl -> Decl -> Ordering
Ord, Int -> Decl -> ShowS
[Decl] -> ShowS
Decl -> Ident
forall a.
(Int -> a -> ShowS) -> (a -> Ident) -> ([a] -> ShowS) -> Show a
showList :: [Decl] -> ShowS
$cshowList :: [Decl] -> ShowS
show :: Decl -> Ident
$cshow :: Decl -> Ident
showsPrec :: Int -> Decl -> ShowS
$cshowsPrec :: Int -> Decl -> ShowS
Show, Typeable Decl
Decl -> Constr
Decl -> DataType
(forall b. Data b => b -> b) -> Decl -> Decl
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Decl -> u
forall u. (forall d. Data d => d -> u) -> Decl -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Decl -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Decl -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Decl -> m Decl
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Decl -> m Decl
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Decl
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Decl -> c Decl
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Decl)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Decl)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Decl -> m Decl
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Decl -> m Decl
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Decl -> m Decl
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Decl -> m Decl
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Decl -> m Decl
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Decl -> m Decl
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Decl -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Decl -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Decl -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Decl -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Decl -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Decl -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Decl -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Decl -> r
gmapT :: (forall b. Data b => b -> b) -> Decl -> Decl
$cgmapT :: (forall b. Data b => b -> b) -> Decl -> Decl
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Decl)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Decl)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Decl)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Decl)
dataTypeOf :: Decl -> DataType
$cdataTypeOf :: Decl -> DataType
toConstr :: Decl -> Constr
$ctoConstr :: Decl -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Decl
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Decl
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Decl -> c Decl
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Decl -> c Decl
Data, Typeable)

-- | A 'Range' tells us the type of a bit vector.  It can count up or down.
data Range
  = Range ConstExpr ConstExpr
  deriving (Range -> Range -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Range -> Range -> Bool
$c/= :: Range -> Range -> Bool
== :: Range -> Range -> Bool
$c== :: Range -> Range -> Bool
Eq, Eq Range
Range -> Range -> Bool
Range -> Range -> Ordering
Range -> Range -> Range
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Range -> Range -> Range
$cmin :: Range -> Range -> Range
max :: Range -> Range -> Range
$cmax :: Range -> Range -> Range
>= :: Range -> Range -> Bool
$c>= :: Range -> Range -> Bool
> :: Range -> Range -> Bool
$c> :: Range -> Range -> Bool
<= :: Range -> Range -> Bool
$c<= :: Range -> Range -> Bool
< :: Range -> Range -> Bool
$c< :: Range -> Range -> Bool
compare :: Range -> Range -> Ordering
$ccompare :: Range -> Range -> Ordering
Ord, Int -> Range -> ShowS
[Range] -> ShowS
Range -> Ident
forall a.
(Int -> a -> ShowS) -> (a -> Ident) -> ([a] -> ShowS) -> Show a
showList :: [Range] -> ShowS
$cshowList :: [Range] -> ShowS
show :: Range -> Ident
$cshow :: Range -> Ident
showsPrec :: Int -> Range -> ShowS
$cshowsPrec :: Int -> Range -> ShowS
Show, Typeable Range
Range -> Constr
Range -> DataType
(forall b. Data b => b -> b) -> Range -> Range
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Range -> u
forall u. (forall d. Data d => d -> u) -> Range -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Range -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Range -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Range -> m Range
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Range -> m Range
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Range
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Range -> c Range
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Range)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Range)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Range -> m Range
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Range -> m Range
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Range -> m Range
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Range -> m Range
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Range -> m Range
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Range -> m Range
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Range -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Range -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Range -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Range -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Range -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Range -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Range -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Range -> r
gmapT :: (forall b. Data b => b -> b) -> Range -> Range
$cgmapT :: (forall b. Data b => b -> b) -> Range -> Range
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Range)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Range)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Range)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Range)
dataTypeOf :: Range -> DataType
$cdataTypeOf :: Range -> DataType
toConstr :: Range -> Constr
$ctoConstr :: Range -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Range
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Range
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Range -> c Range
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Range -> c Range
Data, Typeable)

-- | A constant expression is simply an expression that must be a constant
-- (i.e. the only free variables are static parameters).  This restriction is
-- not made in the AST.
type ConstExpr = Expr

data Event
  = Event Expr Edge
  deriving (Event -> Event -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Event -> Event -> Bool
$c/= :: Event -> Event -> Bool
== :: Event -> Event -> Bool
$c== :: Event -> Event -> Bool
Eq, Eq Event
Event -> Event -> Bool
Event -> Event -> Ordering
Event -> Event -> Event
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Event -> Event -> Event
$cmin :: Event -> Event -> Event
max :: Event -> Event -> Event
$cmax :: Event -> Event -> Event
>= :: Event -> Event -> Bool
$c>= :: Event -> Event -> Bool
> :: Event -> Event -> Bool
$c> :: Event -> Event -> Bool
<= :: Event -> Event -> Bool
$c<= :: Event -> Event -> Bool
< :: Event -> Event -> Bool
$c< :: Event -> Event -> Bool
compare :: Event -> Event -> Ordering
$ccompare :: Event -> Event -> Ordering
Ord, Int -> Event -> ShowS
[Event] -> ShowS
Event -> Ident
forall a.
(Int -> a -> ShowS) -> (a -> Ident) -> ([a] -> ShowS) -> Show a
showList :: [Event] -> ShowS
$cshowList :: [Event] -> ShowS
show :: Event -> Ident
$cshow :: Event -> Ident
showsPrec :: Int -> Event -> ShowS
$cshowsPrec :: Int -> Event -> ShowS
Show, Typeable Event
Event -> Constr
Event -> DataType
(forall b. Data b => b -> b) -> Event -> Event
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Event -> u
forall u. (forall d. Data d => d -> u) -> Event -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Event -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Event -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Event -> m Event
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Event -> m Event
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Event
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Event -> c Event
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Event)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Event)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Event -> m Event
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Event -> m Event
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Event -> m Event
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Event -> m Event
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Event -> m Event
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Event -> m Event
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Event -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Event -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Event -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Event -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Event -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Event -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Event -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Event -> r
gmapT :: (forall b. Data b => b -> b) -> Event -> Event
$cgmapT :: (forall b. Data b => b -> b) -> Event -> Event
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Event)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Event)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Event)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Event)
dataTypeOf :: Event -> DataType
$cdataTypeOf :: Event -> DataType
toConstr :: Event -> Constr
$ctoConstr :: Event -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Event
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Event
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Event -> c Event
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Event -> c Event
Data, Typeable)

-- | An event can be triggered by the rising edge ('PosEdge') or falling edge
-- ('NegEdge') of a signal.
data Edge
  = PosEdge
  | NegEdge
  deriving (Edge -> Edge -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Edge -> Edge -> Bool
$c/= :: Edge -> Edge -> Bool
== :: Edge -> Edge -> Bool
$c== :: Edge -> Edge -> Bool
Eq, Eq Edge
Edge -> Edge -> Bool
Edge -> Edge -> Ordering
Edge -> Edge -> Edge
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Edge -> Edge -> Edge
$cmin :: Edge -> Edge -> Edge
max :: Edge -> Edge -> Edge
$cmax :: Edge -> Edge -> Edge
>= :: Edge -> Edge -> Bool
$c>= :: Edge -> Edge -> Bool
> :: Edge -> Edge -> Bool
$c> :: Edge -> Edge -> Bool
<= :: Edge -> Edge -> Bool
$c<= :: Edge -> Edge -> Bool
< :: Edge -> Edge -> Bool
$c< :: Edge -> Edge -> Bool
compare :: Edge -> Edge -> Ordering
$ccompare :: Edge -> Edge -> Ordering
Ord, Int -> Edge -> ShowS
[Edge] -> ShowS
Edge -> Ident
forall a.
(Int -> a -> ShowS) -> (a -> Ident) -> ([a] -> ShowS) -> Show a
showList :: [Edge] -> ShowS
$cshowList :: [Edge] -> ShowS
show :: Edge -> Ident
$cshow :: Edge -> Ident
showsPrec :: Int -> Edge -> ShowS
$cshowsPrec :: Int -> Edge -> ShowS
Show, Typeable Edge
Edge -> Constr
Edge -> DataType
(forall b. Data b => b -> b) -> Edge -> Edge
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Edge -> u
forall u. (forall d. Data d => d -> u) -> Edge -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Edge -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Edge -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Edge -> m Edge
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Edge -> m Edge
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Edge
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Edge -> c Edge
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Edge)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Edge)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Edge -> m Edge
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Edge -> m Edge
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Edge -> m Edge
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Edge -> m Edge
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Edge -> m Edge
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Edge -> m Edge
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Edge -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Edge -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Edge -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Edge -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Edge -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Edge -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Edge -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Edge -> r
gmapT :: (forall b. Data b => b -> b) -> Edge -> Edge
$cgmapT :: (forall b. Data b => b -> b) -> Edge -> Edge
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Edge)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Edge)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Edge)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Edge)
dataTypeOf :: Edge -> DataType
$cdataTypeOf :: Edge -> DataType
toConstr :: Edge -> Constr
$ctoConstr :: Edge -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Edge
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Edge
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Edge -> c Edge
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Edge -> c Edge
Data, Typeable)

-- | Expr is a combination of VHDL and Verilog expressions.
--
-- In VHDL, concatenation is a binary operator, but in Verilog it takes any
-- number of arguments.  In this AST, we define it like the Verilog operator.
-- If we translate to VHDL, we have to convert it to the VHDL binary operator.
--
-- There are some HDL operators that we don't represent here.  For example, in
-- Verilog there is a multiple concatenation (a.k.a. replication) operator,
-- which we don't bother to support.

data Expr
  = ExprLit (Maybe Size) ExprLit  -- ^ a sized or unsized literal
  | ExprVar Ident                 -- ^ a variable ference
  | ExprString String             -- ^ a quoted string (useful for parameters)

  | ExprIndex Ident Expr          -- ^ @x[e]@
  | ExprSlice Ident Expr Expr     -- ^ @x[e1 : e2]@
  | ExprSliceOff Ident Expr Int   -- ^ @x[e : e+i]@, where @i@ can be negative
  | ExprCase Expr [([ConstExpr], Expr)] (Maybe Expr)
                                  -- ^ case expression.  supports multiple matches
                                  -- per result value, and an optional default value
  | ExprConcat [Expr]             -- ^ concatenation
  | ExprCond Expr Expr Expr       -- ^ conditional expression
  | ExprUnary UnaryOp Expr        -- ^ application of a unary operator
  | ExprBinary BinaryOp Expr Expr -- ^ application of a binary operator
  | ExprFunCall Ident [Expr]      -- ^ a function application
  deriving (Expr -> Expr -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Expr -> Expr -> Bool
$c/= :: Expr -> Expr -> Bool
== :: Expr -> Expr -> Bool
$c== :: Expr -> Expr -> Bool
Eq, Eq Expr
Expr -> Expr -> Bool
Expr -> Expr -> Ordering
Expr -> Expr -> Expr
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Expr -> Expr -> Expr
$cmin :: Expr -> Expr -> Expr
max :: Expr -> Expr -> Expr
$cmax :: Expr -> Expr -> Expr
>= :: Expr -> Expr -> Bool
$c>= :: Expr -> Expr -> Bool
> :: Expr -> Expr -> Bool
$c> :: Expr -> Expr -> Bool
<= :: Expr -> Expr -> Bool
$c<= :: Expr -> Expr -> Bool
< :: Expr -> Expr -> Bool
$c< :: Expr -> Expr -> Bool
compare :: Expr -> Expr -> Ordering
$ccompare :: Expr -> Expr -> Ordering
Ord, Int -> Expr -> ShowS
[Expr] -> ShowS
Expr -> Ident
forall a.
(Int -> a -> ShowS) -> (a -> Ident) -> ([a] -> ShowS) -> Show a
showList :: [Expr] -> ShowS
$cshowList :: [Expr] -> ShowS
show :: Expr -> Ident
$cshow :: Expr -> Ident
showsPrec :: Int -> Expr -> ShowS
$cshowsPrec :: Int -> Expr -> ShowS
Show, Typeable Expr
Expr -> Constr
Expr -> DataType
(forall b. Data b => b -> b) -> Expr -> Expr
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Expr -> u
forall u. (forall d. Data d => d -> u) -> Expr -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Expr -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Expr -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Expr -> m Expr
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Expr -> m Expr
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Expr
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Expr -> c Expr
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Expr)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Expr)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Expr -> m Expr
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Expr -> m Expr
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Expr -> m Expr
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Expr -> m Expr
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Expr -> m Expr
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Expr -> m Expr
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Expr -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Expr -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Expr -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Expr -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Expr -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Expr -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Expr -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Expr -> r
gmapT :: (forall b. Data b => b -> b) -> Expr -> Expr
$cgmapT :: (forall b. Data b => b -> b) -> Expr -> Expr
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Expr)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Expr)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Expr)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Expr)
dataTypeOf :: Expr -> DataType
$cdataTypeOf :: Expr -> DataType
toConstr :: Expr -> Constr
$ctoConstr :: Expr -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Expr
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Expr
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Expr -> c Expr
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Expr -> c Expr
Data, Typeable)

data ExprLit
  = ExprNum Integer               -- ^ a number
  | ExprBit Bit                   -- ^ a single bit.  in vhdl, bits are different than 1-bit bitvectors
  | ExprBitVector [Bit]
  deriving (ExprLit -> ExprLit -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExprLit -> ExprLit -> Bool
$c/= :: ExprLit -> ExprLit -> Bool
== :: ExprLit -> ExprLit -> Bool
$c== :: ExprLit -> ExprLit -> Bool
Eq, Eq ExprLit
ExprLit -> ExprLit -> Bool
ExprLit -> ExprLit -> Ordering
ExprLit -> ExprLit -> ExprLit
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ExprLit -> ExprLit -> ExprLit
$cmin :: ExprLit -> ExprLit -> ExprLit
max :: ExprLit -> ExprLit -> ExprLit
$cmax :: ExprLit -> ExprLit -> ExprLit
>= :: ExprLit -> ExprLit -> Bool
$c>= :: ExprLit -> ExprLit -> Bool
> :: ExprLit -> ExprLit -> Bool
$c> :: ExprLit -> ExprLit -> Bool
<= :: ExprLit -> ExprLit -> Bool
$c<= :: ExprLit -> ExprLit -> Bool
< :: ExprLit -> ExprLit -> Bool
$c< :: ExprLit -> ExprLit -> Bool
compare :: ExprLit -> ExprLit -> Ordering
$ccompare :: ExprLit -> ExprLit -> Ordering
Ord, Int -> ExprLit -> ShowS
[ExprLit] -> ShowS
ExprLit -> Ident
forall a.
(Int -> a -> ShowS) -> (a -> Ident) -> ([a] -> ShowS) -> Show a
showList :: [ExprLit] -> ShowS
$cshowList :: [ExprLit] -> ShowS
show :: ExprLit -> Ident
$cshow :: ExprLit -> Ident
showsPrec :: Int -> ExprLit -> ShowS
$cshowsPrec :: Int -> ExprLit -> ShowS
Show, Typeable ExprLit
ExprLit -> Constr
ExprLit -> DataType
(forall b. Data b => b -> b) -> ExprLit -> ExprLit
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> ExprLit -> u
forall u. (forall d. Data d => d -> u) -> ExprLit -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ExprLit -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ExprLit -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ExprLit -> m ExprLit
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ExprLit -> m ExprLit
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ExprLit
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExprLit -> c ExprLit
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ExprLit)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ExprLit)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ExprLit -> m ExprLit
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ExprLit -> m ExprLit
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ExprLit -> m ExprLit
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ExprLit -> m ExprLit
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ExprLit -> m ExprLit
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ExprLit -> m ExprLit
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ExprLit -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ExprLit -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> ExprLit -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ExprLit -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ExprLit -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ExprLit -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ExprLit -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ExprLit -> r
gmapT :: (forall b. Data b => b -> b) -> ExprLit -> ExprLit
$cgmapT :: (forall b. Data b => b -> b) -> ExprLit -> ExprLit
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ExprLit)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ExprLit)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ExprLit)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ExprLit)
dataTypeOf :: ExprLit -> DataType
$cdataTypeOf :: ExprLit -> DataType
toConstr :: ExprLit -> Constr
$ctoConstr :: ExprLit -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ExprLit
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ExprLit
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExprLit -> c ExprLit
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExprLit -> c ExprLit
Data, Typeable)

data Bit
  = T | F | U | Z
  deriving (Bit -> Bit -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Bit -> Bit -> Bool
$c/= :: Bit -> Bit -> Bool
== :: Bit -> Bit -> Bool
$c== :: Bit -> Bit -> Bool
Eq, Eq Bit
Bit -> Bit -> Bool
Bit -> Bit -> Ordering
Bit -> Bit -> Bit
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Bit -> Bit -> Bit
$cmin :: Bit -> Bit -> Bit
max :: Bit -> Bit -> Bit
$cmax :: Bit -> Bit -> Bit
>= :: Bit -> Bit -> Bool
$c>= :: Bit -> Bit -> Bool
> :: Bit -> Bit -> Bool
$c> :: Bit -> Bit -> Bool
<= :: Bit -> Bit -> Bool
$c<= :: Bit -> Bit -> Bool
< :: Bit -> Bit -> Bool
$c< :: Bit -> Bit -> Bool
compare :: Bit -> Bit -> Ordering
$ccompare :: Bit -> Bit -> Ordering
Ord, Int -> Bit -> ShowS
[Bit] -> ShowS
Bit -> Ident
forall a.
(Int -> a -> ShowS) -> (a -> Ident) -> ([a] -> ShowS) -> Show a
showList :: [Bit] -> ShowS
$cshowList :: [Bit] -> ShowS
show :: Bit -> Ident
$cshow :: Bit -> Ident
showsPrec :: Int -> Bit -> ShowS
$cshowsPrec :: Int -> Bit -> ShowS
Show, Typeable Bit
Bit -> Constr
Bit -> DataType
(forall b. Data b => b -> b) -> Bit -> Bit
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Bit -> u
forall u. (forall d. Data d => d -> u) -> Bit -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bit -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bit -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Bit -> m Bit
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Bit -> m Bit
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Bit
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Bit -> c Bit
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Bit)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Bit)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Bit -> m Bit
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Bit -> m Bit
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Bit -> m Bit
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Bit -> m Bit
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Bit -> m Bit
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Bit -> m Bit
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Bit -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Bit -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Bit -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Bit -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bit -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Bit -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bit -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Bit -> r
gmapT :: (forall b. Data b => b -> b) -> Bit -> Bit
$cgmapT :: (forall b. Data b => b -> b) -> Bit -> Bit
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Bit)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Bit)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Bit)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Bit)
dataTypeOf :: Bit -> DataType
$cdataTypeOf :: Bit -> DataType
toConstr :: Bit -> Constr
$ctoConstr :: Bit -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Bit
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Bit
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Bit -> c Bit
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Bit -> c Bit
Data, Typeable)

-- | Behavioral sequential statement
data Stmt
  = Assign LValue Expr         -- ^ non-blocking assignment
  | If Expr Stmt (Maybe Stmt)  -- ^ @if@ statement
  | Case Expr [([Expr], Stmt)] (Maybe Stmt)
                               -- ^ case statement, with optional default case
  | Seq [Stmt]                 -- ^ multiple statements in sequence
  | FunCallStmt Ident [Expr]   -- ^ a function call that can appear as a statement,
                               -- useful for calling Verilog tasks (e.g. $readmem).
  deriving (Stmt -> Stmt -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Stmt -> Stmt -> Bool
$c/= :: Stmt -> Stmt -> Bool
== :: Stmt -> Stmt -> Bool
$c== :: Stmt -> Stmt -> Bool
Eq, Eq Stmt
Stmt -> Stmt -> Bool
Stmt -> Stmt -> Ordering
Stmt -> Stmt -> Stmt
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Stmt -> Stmt -> Stmt
$cmin :: Stmt -> Stmt -> Stmt
max :: Stmt -> Stmt -> Stmt
$cmax :: Stmt -> Stmt -> Stmt
>= :: Stmt -> Stmt -> Bool
$c>= :: Stmt -> Stmt -> Bool
> :: Stmt -> Stmt -> Bool
$c> :: Stmt -> Stmt -> Bool
<= :: Stmt -> Stmt -> Bool
$c<= :: Stmt -> Stmt -> Bool
< :: Stmt -> Stmt -> Bool
$c< :: Stmt -> Stmt -> Bool
compare :: Stmt -> Stmt -> Ordering
$ccompare :: Stmt -> Stmt -> Ordering
Ord, Int -> Stmt -> ShowS
[Stmt] -> ShowS
Stmt -> Ident
forall a.
(Int -> a -> ShowS) -> (a -> Ident) -> ([a] -> ShowS) -> Show a
showList :: [Stmt] -> ShowS
$cshowList :: [Stmt] -> ShowS
show :: Stmt -> Ident
$cshow :: Stmt -> Ident
showsPrec :: Int -> Stmt -> ShowS
$cshowsPrec :: Int -> Stmt -> ShowS
Show, Typeable Stmt
Stmt -> Constr
Stmt -> DataType
(forall b. Data b => b -> b) -> Stmt -> Stmt
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Stmt -> u
forall u. (forall d. Data d => d -> u) -> Stmt -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Stmt -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Stmt -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Stmt -> m Stmt
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Stmt -> m Stmt
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Stmt
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Stmt -> c Stmt
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Stmt)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Stmt)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Stmt -> m Stmt
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Stmt -> m Stmt
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Stmt -> m Stmt
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Stmt -> m Stmt
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Stmt -> m Stmt
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Stmt -> m Stmt
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Stmt -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Stmt -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Stmt -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Stmt -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Stmt -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Stmt -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Stmt -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Stmt -> r
gmapT :: (forall b. Data b => b -> b) -> Stmt -> Stmt
$cgmapT :: (forall b. Data b => b -> b) -> Stmt -> Stmt
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Stmt)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Stmt)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Stmt)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Stmt)
dataTypeOf :: Stmt -> DataType
$cdataTypeOf :: Stmt -> DataType
toConstr :: Stmt -> Constr
$ctoConstr :: Stmt -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Stmt
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Stmt
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Stmt -> c Stmt
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Stmt -> c Stmt
Data, Typeable)

-- | An 'LValue' is something that can appear on the left-hand side of an
-- assignment.  We're lazy and do not enforce any restriction, and define this
-- simply to be 'Expr'.
type LValue = Expr

-- | Unary operators
--
-- 'LNeg' is logical negation, 'Neg' is bitwise negation.  'UAnd', 'UNand',
-- 'UOr', 'UNor', 'UXor', and 'UXnor' are sometimes called \"reduction
-- operators\".

data UnaryOp
  = UPlus | UMinus | LNeg | Neg | UAnd | UNand | UOr | UNor | UXor | UXnor
  deriving (UnaryOp -> UnaryOp -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnaryOp -> UnaryOp -> Bool
$c/= :: UnaryOp -> UnaryOp -> Bool
== :: UnaryOp -> UnaryOp -> Bool
$c== :: UnaryOp -> UnaryOp -> Bool
Eq, Eq UnaryOp
UnaryOp -> UnaryOp -> Bool
UnaryOp -> UnaryOp -> Ordering
UnaryOp -> UnaryOp -> UnaryOp
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: UnaryOp -> UnaryOp -> UnaryOp
$cmin :: UnaryOp -> UnaryOp -> UnaryOp
max :: UnaryOp -> UnaryOp -> UnaryOp
$cmax :: UnaryOp -> UnaryOp -> UnaryOp
>= :: UnaryOp -> UnaryOp -> Bool
$c>= :: UnaryOp -> UnaryOp -> Bool
> :: UnaryOp -> UnaryOp -> Bool
$c> :: UnaryOp -> UnaryOp -> Bool
<= :: UnaryOp -> UnaryOp -> Bool
$c<= :: UnaryOp -> UnaryOp -> Bool
< :: UnaryOp -> UnaryOp -> Bool
$c< :: UnaryOp -> UnaryOp -> Bool
compare :: UnaryOp -> UnaryOp -> Ordering
$ccompare :: UnaryOp -> UnaryOp -> Ordering
Ord, Int -> UnaryOp -> ShowS
[UnaryOp] -> ShowS
UnaryOp -> Ident
forall a.
(Int -> a -> ShowS) -> (a -> Ident) -> ([a] -> ShowS) -> Show a
showList :: [UnaryOp] -> ShowS
$cshowList :: [UnaryOp] -> ShowS
show :: UnaryOp -> Ident
$cshow :: UnaryOp -> Ident
showsPrec :: Int -> UnaryOp -> ShowS
$cshowsPrec :: Int -> UnaryOp -> ShowS
Show, Typeable UnaryOp
UnaryOp -> Constr
UnaryOp -> DataType
(forall b. Data b => b -> b) -> UnaryOp -> UnaryOp
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> UnaryOp -> u
forall u. (forall d. Data d => d -> u) -> UnaryOp -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnaryOp -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnaryOp -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UnaryOp -> m UnaryOp
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnaryOp -> m UnaryOp
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnaryOp
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnaryOp -> c UnaryOp
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnaryOp)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UnaryOp)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnaryOp -> m UnaryOp
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnaryOp -> m UnaryOp
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnaryOp -> m UnaryOp
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> UnaryOp -> m UnaryOp
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UnaryOp -> m UnaryOp
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> UnaryOp -> m UnaryOp
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> UnaryOp -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> UnaryOp -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> UnaryOp -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> UnaryOp -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnaryOp -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnaryOp -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnaryOp -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnaryOp -> r
gmapT :: (forall b. Data b => b -> b) -> UnaryOp -> UnaryOp
$cgmapT :: (forall b. Data b => b -> b) -> UnaryOp -> UnaryOp
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UnaryOp)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UnaryOp)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnaryOp)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnaryOp)
dataTypeOf :: UnaryOp -> DataType
$cdataTypeOf :: UnaryOp -> DataType
toConstr :: UnaryOp -> Constr
$ctoConstr :: UnaryOp -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnaryOp
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnaryOp
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnaryOp -> c UnaryOp
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> UnaryOp -> c UnaryOp
Data, Typeable)

-- | Binary operators.
--
-- These operators include almost all VHDL and Verilog operators.
--
--  * precedence and pretty-printing are language specific, and defined elsewhere.
--
--  * exponentation operators were introduced in Verilog-2001.
--
--  * some operators are not prefix/infix, such as verilog concatenation and the
--    conditional (@x ? y : z@) operator.  those operators are defined in
--    'Expr'.
--
--  * VHDL has both \"logical\" and \"barithmetic\" shift operators, which we
--    don't yet distinguish between here.
--
--  * VHDL has both a @mod@ and a @rem@ operator, but so far we only define
--    'Modulo'.
--
--  * VHDL has a concat operator (@&@) that isn't yet supported here.  Use
--    'ExprConcat' instead.
--
--  * VHDL has an @abs@ operator that isn't yet supported here.

data BinaryOp
  = Pow | Plus | Minus | Times | Divide | Modulo      -- arithmetic
  | Equals | NotEquals                                -- logical equality
  | CEquals | CNotEquals                              -- case equality
  | LAnd | LOr                                        -- logical and/or
  | LessThan | LessEqual | GreaterThan | GreaterEqual -- relational
  | And | Nand | Or | Nor | Xor | Xnor                -- bitwise
  | ShiftLeft | ShiftRight | RotateLeft | RotateRight -- shift/rotate
  | ShiftLeftArith | ShiftRightArith                  -- arithmetical shift
  deriving (BinaryOp -> BinaryOp -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BinaryOp -> BinaryOp -> Bool
$c/= :: BinaryOp -> BinaryOp -> Bool
== :: BinaryOp -> BinaryOp -> Bool
$c== :: BinaryOp -> BinaryOp -> Bool
Eq, Eq BinaryOp
BinaryOp -> BinaryOp -> Bool
BinaryOp -> BinaryOp -> Ordering
BinaryOp -> BinaryOp -> BinaryOp
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: BinaryOp -> BinaryOp -> BinaryOp
$cmin :: BinaryOp -> BinaryOp -> BinaryOp
max :: BinaryOp -> BinaryOp -> BinaryOp
$cmax :: BinaryOp -> BinaryOp -> BinaryOp
>= :: BinaryOp -> BinaryOp -> Bool
$c>= :: BinaryOp -> BinaryOp -> Bool
> :: BinaryOp -> BinaryOp -> Bool
$c> :: BinaryOp -> BinaryOp -> Bool
<= :: BinaryOp -> BinaryOp -> Bool
$c<= :: BinaryOp -> BinaryOp -> Bool
< :: BinaryOp -> BinaryOp -> Bool
$c< :: BinaryOp -> BinaryOp -> Bool
compare :: BinaryOp -> BinaryOp -> Ordering
$ccompare :: BinaryOp -> BinaryOp -> Ordering
Ord, Int -> BinaryOp -> ShowS
[BinaryOp] -> ShowS
BinaryOp -> Ident
forall a.
(Int -> a -> ShowS) -> (a -> Ident) -> ([a] -> ShowS) -> Show a
showList :: [BinaryOp] -> ShowS
$cshowList :: [BinaryOp] -> ShowS
show :: BinaryOp -> Ident
$cshow :: BinaryOp -> Ident
showsPrec :: Int -> BinaryOp -> ShowS
$cshowsPrec :: Int -> BinaryOp -> ShowS
Show, Typeable BinaryOp
BinaryOp -> Constr
BinaryOp -> DataType
(forall b. Data b => b -> b) -> BinaryOp -> BinaryOp
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> BinaryOp -> u
forall u. (forall d. Data d => d -> u) -> BinaryOp -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BinaryOp -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BinaryOp -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BinaryOp -> m BinaryOp
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BinaryOp -> m BinaryOp
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BinaryOp
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BinaryOp -> c BinaryOp
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BinaryOp)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BinaryOp)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BinaryOp -> m BinaryOp
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BinaryOp -> m BinaryOp
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BinaryOp -> m BinaryOp
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> BinaryOp -> m BinaryOp
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BinaryOp -> m BinaryOp
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> BinaryOp -> m BinaryOp
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BinaryOp -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> BinaryOp -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> BinaryOp -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> BinaryOp -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BinaryOp -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> BinaryOp -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BinaryOp -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> BinaryOp -> r
gmapT :: (forall b. Data b => b -> b) -> BinaryOp -> BinaryOp
$cgmapT :: (forall b. Data b => b -> b) -> BinaryOp -> BinaryOp
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BinaryOp)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BinaryOp)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BinaryOp)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c BinaryOp)
dataTypeOf :: BinaryOp -> DataType
$cdataTypeOf :: BinaryOp -> DataType
toConstr :: BinaryOp -> Constr
$ctoConstr :: BinaryOp -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BinaryOp
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c BinaryOp
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BinaryOp -> c BinaryOp
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> BinaryOp -> c BinaryOp
Data, Typeable)

-- -----------------------------------------------------------------------------
-- GENERATED START


instance Binary Module where
        put :: Module -> Put
put (Module Ident
x1 [(Ident, Maybe Range)]
x2 [(Ident, Maybe Range)]
x3 [(Ident, Expr)]
x4 [Decl]
x5)
          = do forall t. Binary t => t -> Put
put Ident
x1
               forall t. Binary t => t -> Put
put [(Ident, Maybe Range)]
x2
               forall t. Binary t => t -> Put
put [(Ident, Maybe Range)]
x3
               forall t. Binary t => t -> Put
put [(Ident, Expr)]
x4
               forall t. Binary t => t -> Put
put [Decl]
x5
        get :: Get Module
get
          = do Ident
x1 <- forall t. Binary t => Get t
get
               [(Ident, Maybe Range)]
x2 <- forall t. Binary t => Get t
get
               [(Ident, Maybe Range)]
x3 <- forall t. Binary t => Get t
get
               [(Ident, Expr)]
x4 <- forall t. Binary t => Get t
get
               [Decl]
x5 <- forall t. Binary t => Get t
get
               forall (m :: * -> *) a. Monad m => a -> m a
return (Ident
-> [(Ident, Maybe Range)]
-> [(Ident, Maybe Range)]
-> [(Ident, Expr)]
-> [Decl]
-> Module
Module Ident
x1 [(Ident, Maybe Range)]
x2 [(Ident, Maybe Range)]
x3 [(Ident, Expr)]
x4 [Decl]
x5)


instance Binary Decl where
        put :: Decl -> Put
put Decl
x
          = case Decl
x of
                NetDecl Ident
x1 Maybe Range
x2 Maybe Expr
x3 -> do Word8 -> Put
putWord8 Word8
0
                                       forall t. Binary t => t -> Put
put Ident
x1
                                       forall t. Binary t => t -> Put
put Maybe Range
x2
                                       forall t. Binary t => t -> Put
put Maybe Expr
x3
                NetAssign Ident
x1 Expr
x2 -> do Word8 -> Put
putWord8 Word8
1
                                      forall t. Binary t => t -> Put
put Ident
x1
                                      forall t. Binary t => t -> Put
put Expr
x2
                MemDecl Ident
x1 Maybe Range
x2 Maybe Range
x3 Maybe [Expr]
x4 -> do Word8 -> Put
putWord8 Word8
2
                                          forall t. Binary t => t -> Put
put Ident
x1
                                          forall t. Binary t => t -> Put
put Maybe Range
x2
                                          forall t. Binary t => t -> Put
put Maybe Range
x3
                                          forall t. Binary t => t -> Put
put Maybe [Expr]
x4
                MemAssign Ident
x1 Expr
x2 Expr
x3 -> do Word8 -> Put
putWord8 Word8
3
                                         forall t. Binary t => t -> Put
put Ident
x1
                                         forall t. Binary t => t -> Put
put Expr
x2
                                         forall t. Binary t => t -> Put
put Expr
x3
                InstDecl Ident
x1 Ident
x2 [(Ident, Expr)]
x3 [(Ident, Expr)]
x4 [(Ident, Expr)]
x5 -> do Word8 -> Put
putWord8 Word8
4
                                              forall t. Binary t => t -> Put
put Ident
x1
                                              forall t. Binary t => t -> Put
put Ident
x2
                                              forall t. Binary t => t -> Put
put [(Ident, Expr)]
x3
                                              forall t. Binary t => t -> Put
put [(Ident, Expr)]
x4
                                              forall t. Binary t => t -> Put
put [(Ident, Expr)]
x5
                ProcessDecl Event
x1 Maybe (Event, Stmt)
x2 Stmt
x3 -> do Word8 -> Put
putWord8 Word8
5
                                           forall t. Binary t => t -> Put
put Event
x1
                                           forall t. Binary t => t -> Put
put Maybe (Event, Stmt)
x2
                                           forall t. Binary t => t -> Put
put Stmt
x3
                InitProcessDecl Stmt
x1 -> do Word8 -> Put
putWord8 Word8
6
                                         forall t. Binary t => t -> Put
put Stmt
x1
                CommentDecl Ident
x1 -> do Word8 -> Put
putWord8 Word8
7
                                     forall t. Binary t => t -> Put
put Ident
x1
        get :: Get Decl
get
          = do Word8
i <- Get Word8
getWord8
               case Word8
i of
                   Word8
0 -> do Ident
x1 <- forall t. Binary t => Get t
get
                           Maybe Range
x2 <- forall t. Binary t => Get t
get
                           Maybe Expr
x3 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Maybe Range -> Maybe Expr -> Decl
NetDecl Ident
x1 Maybe Range
x2 Maybe Expr
x3)
                   Word8
1 -> do Ident
x1 <- forall t. Binary t => Get t
get
                           Expr
x2 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Expr -> Decl
NetAssign Ident
x1 Expr
x2)
                   Word8
2 -> do Ident
x1 <- forall t. Binary t => Get t
get
                           Maybe Range
x2 <- forall t. Binary t => Get t
get
                           Maybe Range
x3 <- forall t. Binary t => Get t
get
                           Maybe [Expr]
x4 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Maybe Range -> Maybe Range -> Maybe [Expr] -> Decl
MemDecl Ident
x1 Maybe Range
x2 Maybe Range
x3 Maybe [Expr]
x4)
                   Word8
3 -> do Ident
x1 <- forall t. Binary t => Get t
get
                           Expr
x2 <- forall t. Binary t => Get t
get
                           Expr
x3 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Expr -> Expr -> Decl
MemAssign Ident
x1 Expr
x2 Expr
x3)
                   Word8
4 -> do Ident
x1 <- forall t. Binary t => Get t
get
                           Ident
x2 <- forall t. Binary t => Get t
get
                           [(Ident, Expr)]
x3 <- forall t. Binary t => Get t
get
                           [(Ident, Expr)]
x4 <- forall t. Binary t => Get t
get
                           [(Ident, Expr)]
x5 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Ident
-> Ident
-> [(Ident, Expr)]
-> [(Ident, Expr)]
-> [(Ident, Expr)]
-> Decl
InstDecl Ident
x1 Ident
x2 [(Ident, Expr)]
x3 [(Ident, Expr)]
x4 [(Ident, Expr)]
x5)
                   Word8
5 -> do Event
x1 <- forall t. Binary t => Get t
get
                           Maybe (Event, Stmt)
x2 <- forall t. Binary t => Get t
get
                           Stmt
x3 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Event -> Maybe (Event, Stmt) -> Stmt -> Decl
ProcessDecl Event
x1 Maybe (Event, Stmt)
x2 Stmt
x3)
                   Word8
6 -> do Stmt
x1 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Stmt -> Decl
InitProcessDecl Stmt
x1)
                   Word8
7 -> do Ident
x1 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Decl
CommentDecl Ident
x1)
                   Word8
_ -> forall a. HasCallStack => Ident -> a
error Ident
"Corrupted binary data for Decl"


instance Binary Range where
        put :: Range -> Put
put (Range Expr
x1 Expr
x2)
          = do forall t. Binary t => t -> Put
put Expr
x1
               forall t. Binary t => t -> Put
put Expr
x2
        get :: Get Range
get
          = do Expr
x1 <- forall t. Binary t => Get t
get
               Expr
x2 <- forall t. Binary t => Get t
get
               forall (m :: * -> *) a. Monad m => a -> m a
return (Expr -> Expr -> Range
Range Expr
x1 Expr
x2)


instance Binary Event where
        put :: Event -> Put
put (Event Expr
x1 Edge
x2)
          = do forall t. Binary t => t -> Put
put Expr
x1
               forall t. Binary t => t -> Put
put Edge
x2
        get :: Get Event
get
          = do Expr
x1 <- forall t. Binary t => Get t
get
               Edge
x2 <- forall t. Binary t => Get t
get
               forall (m :: * -> *) a. Monad m => a -> m a
return (Expr -> Edge -> Event
Event Expr
x1 Edge
x2)


instance Binary Edge where
        put :: Edge -> Put
put Edge
x
          = case Edge
x of
                Edge
PosEdge   -> Word8 -> Put
putWord8 Word8
0
                Edge
NegEdge   -> Word8 -> Put
putWord8 Word8
1
        get :: Get Edge
get
          = do Word8
i <- Get Word8
getWord8
               case Word8
i of
                   Word8
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return Edge
PosEdge
                   Word8
1 -> forall (m :: * -> *) a. Monad m => a -> m a
return Edge
NegEdge
                   Word8
_ -> forall a. HasCallStack => Ident -> a
error Ident
"Corrupted binary data for Edge"


instance Binary Expr where
        put :: Expr -> Put
put Expr
x
          = case Expr
x of
                ExprLit Maybe Int
x1 ExprLit
x2 -> do Word8 -> Put
putWord8 Word8
0
                                    forall t. Binary t => t -> Put
put Maybe Int
x1
                                    forall t. Binary t => t -> Put
put ExprLit
x2
                ExprVar Ident
x1 -> do Word8 -> Put
putWord8 Word8
1
                                 forall t. Binary t => t -> Put
put Ident
x1
                ExprString Ident
x1 -> do Word8 -> Put
putWord8 Word8
2
                                    forall t. Binary t => t -> Put
put Ident
x1
                ExprIndex Ident
x1 Expr
x2 -> do Word8 -> Put
putWord8 Word8
3
                                      forall t. Binary t => t -> Put
put Ident
x1
                                      forall t. Binary t => t -> Put
put Expr
x2
                ExprSlice Ident
x1 Expr
x2 Expr
x3 -> do Word8 -> Put
putWord8 Word8
4
                                         forall t. Binary t => t -> Put
put Ident
x1
                                         forall t. Binary t => t -> Put
put Expr
x2
                                         forall t. Binary t => t -> Put
put Expr
x3
                ExprSliceOff Ident
x1 Expr
x2 Int
x3 -> do Word8 -> Put
putWord8 Word8
5
                                            forall t. Binary t => t -> Put
put Ident
x1
                                            forall t. Binary t => t -> Put
put Expr
x2
                                            forall t. Binary t => t -> Put
put Int
x3
                ExprCase Expr
x1 [([Expr], Expr)]
x2 Maybe Expr
x3 -> do Word8 -> Put
putWord8 Word8
6
                                        forall t. Binary t => t -> Put
put Expr
x1
                                        forall t. Binary t => t -> Put
put [([Expr], Expr)]
x2
                                        forall t. Binary t => t -> Put
put Maybe Expr
x3
                ExprConcat [Expr]
x1 -> do Word8 -> Put
putWord8 Word8
7
                                    forall t. Binary t => t -> Put
put [Expr]
x1
                ExprCond Expr
x1 Expr
x2 Expr
x3 -> do Word8 -> Put
putWord8 Word8
8
                                        forall t. Binary t => t -> Put
put Expr
x1
                                        forall t. Binary t => t -> Put
put Expr
x2
                                        forall t. Binary t => t -> Put
put Expr
x3
                ExprUnary UnaryOp
x1 Expr
x2 -> do Word8 -> Put
putWord8 Word8
9
                                      forall t. Binary t => t -> Put
put UnaryOp
x1
                                      forall t. Binary t => t -> Put
put Expr
x2
                ExprBinary BinaryOp
x1 Expr
x2 Expr
x3 -> do Word8 -> Put
putWord8 Word8
10
                                          forall t. Binary t => t -> Put
put BinaryOp
x1
                                          forall t. Binary t => t -> Put
put Expr
x2
                                          forall t. Binary t => t -> Put
put Expr
x3
                ExprFunCall Ident
x1 [Expr]
x2 -> do Word8 -> Put
putWord8 Word8
11
                                        forall t. Binary t => t -> Put
put Ident
x1
                                        forall t. Binary t => t -> Put
put [Expr]
x2
        get :: Get Expr
get
          = do Word8
i <- Get Word8
getWord8
               case Word8
i of
                   Word8
0 -> do Maybe Int
x1 <- forall t. Binary t => Get t
get
                           ExprLit
x2 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Int -> ExprLit -> Expr
ExprLit Maybe Int
x1 ExprLit
x2)
                   Word8
1 -> do Ident
x1 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Expr
ExprVar Ident
x1)
                   Word8
2 -> do Ident
x1 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Expr
ExprString Ident
x1)
                   Word8
3 -> do Ident
x1 <- forall t. Binary t => Get t
get
                           Expr
x2 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Expr -> Expr
ExprIndex Ident
x1 Expr
x2)
                   Word8
4 -> do Ident
x1 <- forall t. Binary t => Get t
get
                           Expr
x2 <- forall t. Binary t => Get t
get
                           Expr
x3 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Expr -> Expr -> Expr
ExprSlice Ident
x1 Expr
x2 Expr
x3)
                   Word8
5 -> do Ident
x1 <- forall t. Binary t => Get t
get
                           Expr
x2 <- forall t. Binary t => Get t
get
                           Int
x3 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> Expr -> Int -> Expr
ExprSliceOff Ident
x1 Expr
x2 Int
x3)
                   Word8
6 -> do Expr
x1 <- forall t. Binary t => Get t
get
                           [([Expr], Expr)]
x2 <- forall t. Binary t => Get t
get
                           Maybe Expr
x3 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Expr -> [([Expr], Expr)] -> Maybe Expr -> Expr
ExprCase Expr
x1 [([Expr], Expr)]
x2 Maybe Expr
x3)
                   Word8
7 -> do [Expr]
x1 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return ([Expr] -> Expr
ExprConcat [Expr]
x1)
                   Word8
8 -> do Expr
x1 <- forall t. Binary t => Get t
get
                           Expr
x2 <- forall t. Binary t => Get t
get
                           Expr
x3 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Expr -> Expr -> Expr -> Expr
ExprCond Expr
x1 Expr
x2 Expr
x3)
                   Word8
9 -> do UnaryOp
x1 <- forall t. Binary t => Get t
get
                           Expr
x2 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (UnaryOp -> Expr -> Expr
ExprUnary UnaryOp
x1 Expr
x2)
                   Word8
10 -> do BinaryOp
x1 <- forall t. Binary t => Get t
get
                            Expr
x2 <- forall t. Binary t => Get t
get
                            Expr
x3 <- forall t. Binary t => Get t
get
                            forall (m :: * -> *) a. Monad m => a -> m a
return (BinaryOp -> Expr -> Expr -> Expr
ExprBinary BinaryOp
x1 Expr
x2 Expr
x3)
                   Word8
11 -> do Ident
x1 <- forall t. Binary t => Get t
get
                            [Expr]
x2 <- forall t. Binary t => Get t
get
                            forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> [Expr] -> Expr
ExprFunCall Ident
x1 [Expr]
x2)
                   Word8
_ -> forall a. HasCallStack => Ident -> a
error Ident
"Corrupted binary data for Expr"


instance Binary ExprLit where
        put :: ExprLit -> Put
put ExprLit
x
          = case ExprLit
x of
                ExprNum Integer
x1 -> do Word8 -> Put
putWord8 Word8
0
                                 forall t. Binary t => t -> Put
put Integer
x1
                ExprBit Bit
x1 -> do Word8 -> Put
putWord8 Word8
1
                                 forall t. Binary t => t -> Put
put Bit
x1
                ExprBitVector [Bit]
x1 -> do Word8 -> Put
putWord8 Word8
2
                                       forall t. Binary t => t -> Put
put [Bit]
x1
        get :: Get ExprLit
get
          = do Word8
i <- Get Word8
getWord8
               case Word8
i of
                   Word8
0 -> do Integer
x1 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Integer -> ExprLit
ExprNum Integer
x1)
                   Word8
1 -> do Bit
x1 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Bit -> ExprLit
ExprBit Bit
x1)
                   Word8
2 -> do [Bit]
x1 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return ([Bit] -> ExprLit
ExprBitVector [Bit]
x1)
                   Word8
_ -> forall a. HasCallStack => Ident -> a
error Ident
"Corrupted binary data for ExprLit"


instance Binary Bit where
        put :: Bit -> Put
put Bit
x
          = case Bit
x of
                Bit
T -> Word8 -> Put
putWord8 Word8
0
                Bit
F -> Word8 -> Put
putWord8 Word8
1
                Bit
U -> Word8 -> Put
putWord8 Word8
2
                Bit
Z -> Word8 -> Put
putWord8 Word8
3
        get :: Get Bit
get
          = do Word8
i <- Get Word8
getWord8
               case Word8
i of
                   Word8
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return Bit
T
                   Word8
1 -> forall (m :: * -> *) a. Monad m => a -> m a
return Bit
F
                   Word8
2 -> forall (m :: * -> *) a. Monad m => a -> m a
return Bit
U
                   Word8
3 -> forall (m :: * -> *) a. Monad m => a -> m a
return Bit
Z
                   Word8
_ -> forall a. HasCallStack => Ident -> a
error Ident
"Corrupted binary data for Bit"


instance Binary Stmt where
        put :: Stmt -> Put
put Stmt
x
          = case Stmt
x of
                Assign Expr
x1 Expr
x2 -> do Word8 -> Put
putWord8 Word8
0
                                   forall t. Binary t => t -> Put
put Expr
x1
                                   forall t. Binary t => t -> Put
put Expr
x2
                If Expr
x1 Stmt
x2 Maybe Stmt
x3 -> do Word8 -> Put
putWord8 Word8
1
                                  forall t. Binary t => t -> Put
put Expr
x1
                                  forall t. Binary t => t -> Put
put Stmt
x2
                                  forall t. Binary t => t -> Put
put Maybe Stmt
x3
                Case Expr
x1 [([Expr], Stmt)]
x2 Maybe Stmt
x3 -> do Word8 -> Put
putWord8 Word8
2
                                    forall t. Binary t => t -> Put
put Expr
x1
                                    forall t. Binary t => t -> Put
put [([Expr], Stmt)]
x2
                                    forall t. Binary t => t -> Put
put Maybe Stmt
x3
                Seq [Stmt]
x1 -> do Word8 -> Put
putWord8 Word8
3
                             forall t. Binary t => t -> Put
put [Stmt]
x1
                FunCallStmt Ident
x1 [Expr]
x2 -> do Word8 -> Put
putWord8 Word8
4
                                        forall t. Binary t => t -> Put
put Ident
x1
                                        forall t. Binary t => t -> Put
put [Expr]
x2
        get :: Get Stmt
get
          = do Word8
i <- Get Word8
getWord8
               case Word8
i of
                   Word8
0 -> do Expr
x1 <- forall t. Binary t => Get t
get
                           Expr
x2 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Expr -> Expr -> Stmt
Assign Expr
x1 Expr
x2)
                   Word8
1 -> do Expr
x1 <- forall t. Binary t => Get t
get
                           Stmt
x2 <- forall t. Binary t => Get t
get
                           Maybe Stmt
x3 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Expr -> Stmt -> Maybe Stmt -> Stmt
If Expr
x1 Stmt
x2 Maybe Stmt
x3)
                   Word8
2 -> do Expr
x1 <- forall t. Binary t => Get t
get
                           [([Expr], Stmt)]
x2 <- forall t. Binary t => Get t
get
                           Maybe Stmt
x3 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Expr -> [([Expr], Stmt)] -> Maybe Stmt -> Stmt
Case Expr
x1 [([Expr], Stmt)]
x2 Maybe Stmt
x3)
                   Word8
3 -> do [Stmt]
x1 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return ([Stmt] -> Stmt
Seq [Stmt]
x1)
                   Word8
4 -> do Ident
x1 <- forall t. Binary t => Get t
get
                           [Expr]
x2 <- forall t. Binary t => Get t
get
                           forall (m :: * -> *) a. Monad m => a -> m a
return (Ident -> [Expr] -> Stmt
FunCallStmt Ident
x1 [Expr]
x2)
                   Word8
_ -> forall a. HasCallStack => Ident -> a
error Ident
"Corrupted binary data for Stmt"


instance Binary UnaryOp where
        put :: UnaryOp -> Put
put UnaryOp
x
          = case UnaryOp
x of
                UnaryOp
UPlus -> Word8 -> Put
putWord8 Word8
0
                UnaryOp
UMinus -> Word8 -> Put
putWord8 Word8
1
                UnaryOp
LNeg -> Word8 -> Put
putWord8 Word8
2
                UnaryOp
Neg -> Word8 -> Put
putWord8 Word8
3
                UnaryOp
UAnd -> Word8 -> Put
putWord8 Word8
4
                UnaryOp
UNand -> Word8 -> Put
putWord8 Word8
5
                UnaryOp
UOr -> Word8 -> Put
putWord8 Word8
6
                UnaryOp
UNor -> Word8 -> Put
putWord8 Word8
7
                UnaryOp
UXor -> Word8 -> Put
putWord8 Word8
8
                UnaryOp
UXnor -> Word8 -> Put
putWord8 Word8
9
        get :: Get UnaryOp
get
          = do Word8
i <- Get Word8
getWord8
               case Word8
i of
                   Word8
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return UnaryOp
UPlus
                   Word8
1 -> forall (m :: * -> *) a. Monad m => a -> m a
return UnaryOp
UMinus
                   Word8
2 -> forall (m :: * -> *) a. Monad m => a -> m a
return UnaryOp
LNeg
                   Word8
3 -> forall (m :: * -> *) a. Monad m => a -> m a
return UnaryOp
Neg
                   Word8
4 -> forall (m :: * -> *) a. Monad m => a -> m a
return UnaryOp
UAnd
                   Word8
5 -> forall (m :: * -> *) a. Monad m => a -> m a
return UnaryOp
UNand
                   Word8
6 -> forall (m :: * -> *) a. Monad m => a -> m a
return UnaryOp
UOr
                   Word8
7 -> forall (m :: * -> *) a. Monad m => a -> m a
return UnaryOp
UNor
                   Word8
8 -> forall (m :: * -> *) a. Monad m => a -> m a
return UnaryOp
UXor
                   Word8
9 -> forall (m :: * -> *) a. Monad m => a -> m a
return UnaryOp
UXnor
                   Word8
_ -> forall a. HasCallStack => Ident -> a
error Ident
"Corrupted binary data for UnaryOp"


instance Binary BinaryOp where
        put :: BinaryOp -> Put
put BinaryOp
x
          = case BinaryOp
x of
                BinaryOp
Pow -> Word8 -> Put
putWord8 Word8
0
                BinaryOp
Plus -> Word8 -> Put
putWord8 Word8
1
                BinaryOp
Minus -> Word8 -> Put
putWord8 Word8
2
                BinaryOp
Times -> Word8 -> Put
putWord8 Word8
3
                BinaryOp
Divide -> Word8 -> Put
putWord8 Word8
4
                BinaryOp
Modulo -> Word8 -> Put
putWord8 Word8
5
                BinaryOp
Equals -> Word8 -> Put
putWord8 Word8
6
                BinaryOp
NotEquals -> Word8 -> Put
putWord8 Word8
7
                BinaryOp
CEquals -> Word8 -> Put
putWord8 Word8
8
                BinaryOp
CNotEquals -> Word8 -> Put
putWord8 Word8
9
                BinaryOp
LAnd -> Word8 -> Put
putWord8 Word8
10
                BinaryOp
LOr -> Word8 -> Put
putWord8 Word8
11
                BinaryOp
LessThan -> Word8 -> Put
putWord8 Word8
12
                BinaryOp
LessEqual -> Word8 -> Put
putWord8 Word8
13
                BinaryOp
GreaterThan -> Word8 -> Put
putWord8 Word8
14
                BinaryOp
GreaterEqual -> Word8 -> Put
putWord8 Word8
15
                BinaryOp
And -> Word8 -> Put
putWord8 Word8
16
                BinaryOp
Nand -> Word8 -> Put
putWord8 Word8
17
                BinaryOp
Or -> Word8 -> Put
putWord8 Word8
18
                BinaryOp
Nor -> Word8 -> Put
putWord8 Word8
19
                BinaryOp
Xor -> Word8 -> Put
putWord8 Word8
20
                BinaryOp
Xnor -> Word8 -> Put
putWord8 Word8
21
                BinaryOp
ShiftLeft -> Word8 -> Put
putWord8 Word8
22
                BinaryOp
ShiftRight -> Word8 -> Put
putWord8 Word8
23
                BinaryOp
RotateLeft -> Word8 -> Put
putWord8 Word8
24
                BinaryOp
RotateRight -> Word8 -> Put
putWord8 Word8
25
                BinaryOp
ShiftLeftArith -> Word8 -> Put
putWord8 Word8
26
                BinaryOp
ShiftRightArith -> Word8 -> Put
putWord8 Word8
27
        get :: Get BinaryOp
get
          = do Word8
i <- Get Word8
getWord8
               case Word8
i of
                   Word8
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
Pow
                   Word8
1 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
Plus
                   Word8
2 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
Minus
                   Word8
3 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
Times
                   Word8
4 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
Divide
                   Word8
5 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
Modulo
                   Word8
6 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
Equals
                   Word8
7 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
NotEquals
                   Word8
8 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
CEquals
                   Word8
9 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
CNotEquals
                   Word8
10 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
LAnd
                   Word8
11 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
LOr
                   Word8
12 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
LessThan
                   Word8
13 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
LessEqual
                   Word8
14 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
GreaterThan
                   Word8
15 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
GreaterEqual
                   Word8
16 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
And
                   Word8
17 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
Nand
                   Word8
18 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
Or
                   Word8
19 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
Nor
                   Word8
20 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
Xor
                   Word8
21 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
Xnor
                   Word8
22 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
ShiftLeft
                   Word8
23 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
ShiftRight
                   Word8
24 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
RotateLeft
                   Word8
25 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
RotateRight
                   Word8
26 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
ShiftLeftArith
                   Word8
27 -> forall (m :: * -> *) a. Monad m => a -> m a
return BinaryOp
ShiftRightArith
                   Word8
_ -> forall a. HasCallStack => Ident -> a
error Ident
"Corrupted binary data for BinaryOp"
-- GENERATED STOP