35 lines
780 B
Haskell
35 lines
780 B
Haskell
module TimeSState where
|
|
|
|
import Clash.Prelude
|
|
|
|
newtype SState a = SState a deriving Show
|
|
|
|
instance Functor SState where
|
|
-- fmap :: (a -> b) -> SState a -> SState b
|
|
fmap f (SState x) = SState (f x)
|
|
-- *TimeMealy L> (\x -> x + 1) <$> (SState 3)
|
|
-- SState 4
|
|
|
|
|
|
instance Applicative SState where
|
|
-- pure :: a -> SState a
|
|
pure x = SState x
|
|
|
|
-- (<*>) :: SState (a -> b) -> SState a -> SState b
|
|
(SState f) <*> (SState x) = SState (f x)
|
|
-- *TimeMealy L> (+) <$> (SState 3) <*> (SState 2)
|
|
-- SState 5
|
|
|
|
|
|
instance Monad SState where
|
|
-- (>>=) :: SState a -> (a -> SState b) -> SState b
|
|
(SState x) >>= f = f x
|
|
|
|
topEntity
|
|
:: Clock System
|
|
-> Reset System
|
|
-> Enable System
|
|
-> Signal System (Maybe (Signed 8))
|
|
-> Signal System Int
|
|
topEntity = exposeClockResetEnable timeS
|