Really revert all of the recent rotating changes.
[matthijs/master-project/cλash.git] / Bits.hs
1 {-# LANGUAGE FlexibleContexts,GADTs,ExistentialQuantification,LiberalTypeSynonyms,TemplateHaskell, DeriveDataTypeable #-}
2
3 module Bits where
4
5 -- import qualified Data.Param.TFVec as TFVec
6 -- import qualified Types
7 import Language.Haskell.TH.Lift
8
9 import Data.Typeable
10
11 --class Signal a where
12 --      hwand :: a -> a -> a
13 --      hwor  :: a -> a -> a
14 --      hwxor :: a -> a -> a
15 --      hwnot :: a -> a
16 --
17 --      -- Prettyprint a signal. We're not extending Show here, since show must
18 --      -- return a valid haskell syntax
19 --      displaysig :: a -> String
20
21 hwand :: Bit -> Bit -> Bit
22 hwor  :: Bit -> Bit -> Bit
23 hwxor :: Bit -> Bit -> Bit
24 hwnot :: Bit -> Bit
25
26 -- Prettyprint Bit signal. We're not extending Show here, since show must
27 -- return Bit valid haskell syntax
28 displaysig :: Bit -> String
29
30 --instance Signal Bit where
31 High `hwand` High = High
32 _ `hwand` _ = Low
33
34 High `hwor` _  = High
35 _ `hwor` High  = High
36 Low `hwor` Low = Low
37
38 High `hwxor` Low = High
39 Low `hwxor` High = High
40 _ `hwxor` _      = Low
41
42 hwnot High = Low
43 hwnot Low  = High
44
45 displaysig High = "1" 
46 displaysig Low  = "0"
47
48 -- The plain Bit type
49 data Bit = High | Low
50   deriving (Show, Eq, Read, Typeable)
51
52 $(deriveLift1 ''Bit)
53
54 -- A function to prettyprint a bitvector
55
56 --displaysigs :: (Signal s) => [s] -> String
57 -- displaysigs :: [Bit] -> String
58 -- displaysigs = (foldl (++) "") . (map displaysig)
59
60 -- type Stream a = [a]
61
62 -- An infinite streams of highs or lows
63 -- lows  = Low : lows
64 -- highs = High : highs
65 -- 
66 -- type BitVec len = TFVec.TFVec len Bit
67
68 -- vim: set ts=8 sw=2 sts=2 expandtab: