Reflect moving TFVec and TFP Integers into clash in sourcefiles related to builtin...
[matthijs/master-project/cλash.git] / cλash / CLasH / HardwareTypes.hs
index c3eaf4396ef0eb2c65c991cfabdeef9eacd2a986..2912e50fe75bf98ab63bb4f31ba6ab421581656c 100644 (file)
@@ -2,14 +2,15 @@
 
 module CLasH.HardwareTypes
   ( module Types
-  , module Data.Param.TFVec
-  , module Data.RangedWord
-  , module Data.SizedInt
-  , module Data.SizedWord
+  , module Data.Param.Vector
+  , module Data.Param.Index
+  , module Data.Param.Signed
+  , module Data.Param.Unsigned
   , module Prelude
   , Bit(..)
   , State(..)
-  , Vector
+  , resizeInt
+  , resizeWord
   , hwand
   , hwor
   , hwxor
@@ -24,24 +25,29 @@ import Prelude hiding (
   null, length, head, tail, last, init, take, drop, (++), map, foldl, foldr,
   zipWith, zip, unzip, concat, reverse, iterate )
 import Types
-import qualified Data.Param.TFVec as TFVec
-import Data.Param.TFVec hiding (TFVec)
-import Data.RangedWord
-import Data.SizedInt
-import Data.SizedWord 
+import Data.Param.Vector
+import Data.Param.Index
+import qualified Data.Param.Signed as Signed
+import Data.Param.Signed hiding (resize)
+import qualified Data.Param.Unsigned as Unsigned
+import Data.Param.Unsigned hiding (resize) 
 
 import Language.Haskell.TH.Lift
 import Data.Typeable
 
 newtype State s = State s deriving (P.Show)
 
-type Vector = TFVec.TFVec
+resizeInt :: (NaturalT nT, NaturalT nT') => Signed nT -> Signed nT'
+resizeInt = Signed.resize
+
+resizeWord :: (NaturalT nT, NaturalT nT') => Unsigned nT -> Unsigned nT'
+resizeWord = Unsigned.resize
 
 -- The plain Bit type
 data Bit = High | Low
   deriving (P.Show, P.Eq, P.Read, Typeable)
 
-$(deriveLift1 ''Bit)
+deriveLift ''Bit
 
 hwand :: Bit -> Bit -> Bit
 hwor  :: Bit -> Bit -> Bit
@@ -72,15 +78,16 @@ blockRAM ::
   ,((s :+: D1) :>: s) ~ True ) =>
   (MemState s a) -> 
   a ->
-  RangedWord s ->
-  RangedWord s ->
-  Bit -> 
+  Index s ->
+  Index s ->
+  Bool -> 
   ((MemState s a), a )
 blockRAM (State mem) data_in rdaddr wraddr wrenable = 
   ((State mem'), data_out)
   where
     data_out  = mem!rdaddr
     -- Only write data_in to memory if write is enabled
-    mem' = case wrenable of
-      Low   ->  mem
-      High  ->  replace mem wraddr data_in
+    mem' =  if wrenable then
+              replace mem wraddr data_in
+            else
+              mem