playground/haskell/clash-unsorted/TimeMealy.hs

30 lines
686 B
Haskell

module TimeMealy where
import Clash.Prelude
-- | Transition function to be used for time TeSSLa operation
timefn
:: Int -- ^ state: current time
-> a -- ^ input: irrelevant
-> (Int, Int) -- ^ nextstate,output. output is current state itself
timefn t _ = (t+1, t)
timeS
:: HiddenClockResetEnable dom
=> Signal dom a
-> Signal dom Int
timeS = mealy timefn 0
topEntity
:: Clock System
-> Reset System
-> Enable System
-> Signal System (Maybe (Signed 8))
-> Signal System Int
topEntity = exposeClockResetEnable timeS
-- import qualified Data.List as L
-- *TimeMealy L> L.take 4 $ simulate @System timeS [1::Int, 2, 3, 4]
-- [0,1,2,3]