9209086db466642dde74e6d4967f418b1ea5a3e9
[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   , Vector
12   , hwand
13   , hwor
14   , hwxor
15   , hwnot
16   ) where
17
18 import qualified Prelude as P
19 import Prelude hiding (
20   null, length, head, tail, last, init, take, drop, (++), map, foldl, foldr,
21   zipWith, zip, unzip, concat, reverse, iterate )
22 import Types
23 import qualified Data.Param.TFVec as TFVec
24 import Data.Param.TFVec hiding (TFVec)
25 import Data.RangedWord
26 import Data.SizedInt
27 import Data.SizedWord 
28
29 import Language.Haskell.TH.Lift
30 import Data.Typeable
31
32 type Vector = TFVec.TFVec
33
34 -- The plain Bit type
35 data Bit = High | Low
36   deriving (P.Show, P.Eq, P.Read, Typeable)
37
38 $(deriveLift1 ''Bit)
39
40 hwand :: Bit -> Bit -> Bit
41 hwor  :: Bit -> Bit -> Bit
42 hwxor :: Bit -> Bit -> Bit
43 hwnot :: Bit -> Bit
44
45 High `hwand` High = High
46 _ `hwand` _ = Low
47
48 High `hwor` _  = High
49 _ `hwor` High  = High
50 Low `hwor` Low = Low
51
52 High `hwxor` Low = High
53 Low `hwxor` High = High
54 _ `hwxor` _      = Low
55
56 hwnot High = Low
57 hwnot Low  = High