playground/haskell/clash-unsorted/SevenSegment.hs

44 lines
1.3 KiB
Haskell

module SevenSegment where
import Clash.Prelude
foo
:: KnownNat n
=> BitVector n
-> Vec 7 Bool
foo inp =
case (toInteger inp) of
0 -> (True :> True :> True :> True :> True :> True :> True :> Nil) -- 0
1 -> (False :> True :> True :> False :> False :> False :> False :> Nil) -- 1
_ -> (True :> True :> False :> False :> True :> False :> True :> Nil) -- Unknown
bar
:: (KnownNat n,
Functor f)
=> f (BitVector n)
-> f (Vec 7 Bool)
bar inp = foo <$> inp
topEntity
:: Clock System
-> Reset System
-> Enable System
-> Signal System (BitVector 7)
-> Signal System (Vec 7 Bool)
topEntity = exposeClockResetEnable bar
{-
GHC: Setting up GHC took: 0.006s
GHC: Compiling and loading modules took: 0.227s
Clash: Parsing and compiling primitives took 0.205s
GHC+Clash: Loading modules cumulatively took 0.553s
Clash: Compiling SevenSegment.topEntity
Clash: Normalization took 0.027s
[WARNING] Dubious primitive instantiation for GHC.Integer.Type.eqInteger#: GHC.Integer.Type.eqInteger#: Integers are dynamically sized in simulation, but fixed-length after synthesis. Use carefully. (disable with -fclash-no-prim-warn)
Clash: Netlist generation took 0.001s
Clash: Compiling SevenSegment.topEntity took 0.031s
Clash: Total compilation took 0.585s
-}
-- XXX: std.textio is imported in the vhdl generated. That's not synthesisable, right?