State newtype has been moved to CLasH.HardwareTypes
[matthijs/master-project/cλash.git] / cλash / CLasH / HardwareTypes.hs
1 {-# LANGUAGE TemplateHaskell, DeriveDataTypeable #-}
2
3 module CLasH.HardwareTypes
4   ( module Types
5   , module Data.Param.TFVec
6   , module Data.RangedWord
7   , module Data.SizedInt
8   , module Data.SizedWord
9   , module Prelude
10   , Bit(..)
11   , State(..)
12   , Vector
13   , hwand
14   , hwor
15   , hwxor
16   , hwnot
17   ) where
18
19 import qualified Prelude as P
20 import Prelude hiding (
21   null, length, head, tail, last, init, take, drop, (++), map, foldl, foldr,
22   zipWith, zip, unzip, concat, reverse, iterate )
23 import Types
24 import qualified Data.Param.TFVec as TFVec
25 import Data.Param.TFVec hiding (TFVec)
26 import Data.RangedWord
27 import Data.SizedInt
28 import Data.SizedWord 
29
30 import Language.Haskell.TH.Lift
31 import Data.Typeable
32
33 newtype State s = State s deriving (P.Show)
34
35 type Vector = TFVec.TFVec
36
37 -- The plain Bit type
38 data Bit = High | Low
39   deriving (P.Show, P.Eq, P.Read, Typeable)
40
41 $(deriveLift1 ''Bit)
42
43 hwand :: Bit -> Bit -> Bit
44 hwor  :: Bit -> Bit -> Bit
45 hwxor :: Bit -> Bit -> Bit
46 hwnot :: Bit -> Bit
47
48 High `hwand` High = High
49 _ `hwand` _ = Low
50
51 High `hwor` _  = High
52 _ `hwor` High  = High
53 Low `hwor` Low = Low
54
55 High `hwxor` Low = High
56 Low `hwxor` High = High
57 _ `hwxor` _      = Low
58
59 hwnot High = Low
60 hwnot Low  = High