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