From: Christiaan Baaij Date: Fri, 3 Jul 2009 19:41:04 +0000 (+0200) Subject: Made Bit an instance of Lift so it can be used in vectorTH X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=8d8e5446f4558cd5bfbd78f3378e6cf96a9c3fc8;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Made Bit an instance of Lift so it can be used in vectorTH vectorTH works now, but you will need the latest version of TFVec --- diff --git a/Adders.hs b/Adders.hs index 9e78fcf..67d7d95 100644 --- a/Adders.hs +++ b/Adders.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module Adders where import Bits import qualified Sim @@ -174,8 +176,8 @@ highordtest = \x -> xand a b = hwand a b -functiontest :: TFVec D4 (TFVec D3 Bit) -> (TFVec D12 Bit, TFVec D3 Bit, TFVec D3 (TFVec D3 Bit)) -functiontest = \v -> let r = (concat v, head v, tail v) in r +functiontest :: TFVec D4 Bit -> TFVec D8 Bit +functiontest = \v -> let r = v ++ $(vectorTH ([High,Low,High,Low] :: [Bit])) in r xhwnot x = hwnot x diff --git a/Bits.hs b/Bits.hs index b50430a..435b04e 100644 --- a/Bits.hs +++ b/Bits.hs @@ -1,9 +1,10 @@ -{-# LANGUAGE FlexibleContexts,GADTs,ExistentialQuantification,LiberalTypeSynonyms #-} +{-# LANGUAGE FlexibleContexts,GADTs,ExistentialQuantification,LiberalTypeSynonyms,TemplateHaskell #-} module Bits where import qualified Data.Param.TFVec as TFVec import qualified Types +import Language.Haskell.TH.Lift --class Signal a where -- hwand :: a -> a -> a @@ -46,6 +47,8 @@ displaysig Low = "0" data Bit = High | Low deriving (Show, Eq, Read) +$(deriveLift1 ''Bit) + -- A function to prettyprint a bitvector --displaysigs :: (Signal s) => [s] -> String