1 {-# LANGUAGE TemplateHaskell, DeriveDataTypeable, FlexibleContexts, TypeFamilies, TypeOperators #-}
3 module CLasH.HardwareTypes
5 , module Data.Param.Vector
6 , module Data.Param.Index
7 , module Data.Param.Signed
8 , module Data.Param.Unsigned
23 import qualified Prelude as P
24 import Prelude hiding (
25 null, length, head, tail, last, init, take, drop, (++), map, foldl, foldr,
26 zipWith, zip, unzip, concat, reverse, iterate )
28 import Data.Param.Vector
29 import Data.Param.Index
30 import qualified Data.Param.Signed as Signed
31 import Data.Param.Signed hiding (resize)
32 import qualified Data.Param.Unsigned as Unsigned
33 import Data.Param.Unsigned hiding (resize)
35 import Language.Haskell.TH.Lift
38 newtype State s = State s deriving (P.Show)
40 resizeInt :: (NaturalT nT, NaturalT nT') => Signed nT -> Signed nT'
41 resizeInt = Signed.resize
43 resizeWord :: (NaturalT nT, NaturalT nT') => Unsigned nT -> Unsigned nT'
44 resizeWord = Unsigned.resize
48 deriving (P.Show, P.Eq, P.Read, Typeable)
52 hwand :: Bit -> Bit -> Bit
53 hwor :: Bit -> Bit -> Bit
54 hwxor :: Bit -> Bit -> Bit
57 High `hwand` High = High
64 High `hwxor` Low = High
65 Low `hwxor` High = High
71 type RAM s a = Vector (s :+: D1) a
73 type MemState s a = State (RAM s a)
78 ,((s :+: D1) :>: s) ~ True ) =>
85 blockRAM (State mem) data_in rdaddr wraddr wrenable =
86 ((State mem'), data_out)
89 -- Only write data_in to memory if write is enabled
90 mem' = if wrenable then
91 replace mem wraddr data_in