{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ExplicitNamespaces #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE Trustworthy #-}
{-# OPTIONS_HADDOCK show-extensions #-}
module Clash.Signal
(
Signal
, BiSignalIn
, BiSignalOut
, BiSignalDefault(..)
, Domain
, sameDomain
, KnownDomain(..)
, KnownConfiguration
, ActiveEdge(..)
, SActiveEdge(..)
, InitBehavior(..)
, SInitBehavior(..)
, ResetKind(..)
, SResetKind(..)
, ResetPolarity(..)
, SResetPolarity(..)
, DomainConfiguration(..)
, SDomainConfiguration(..)
, DomainPeriod
, DomainActiveEdge
, DomainResetKind
, DomainInitBehavior
, DomainResetPolarity
, HasSynchronousReset
, HasAsynchronousReset
, HasDefinedInitialValues
, Seconds
, Milliseconds
, Microseconds
, Nanoseconds
, Picoseconds
, DomainToHz
, HzToPeriod
, PeriodToHz
, PeriodToCycles
, ClockDivider
, System
, XilinxSystem
, IntelSystem
, vSystem
, vIntelSystem
, vXilinxSystem
, VDomainConfiguration(..)
, vDomain
, createDomain
, knownVDomain
, clockPeriod
, activeEdge
, resetKind
, initBehavior
, resetPolarity
, Clock
, DiffClock
, periodToHz
, hzToPeriod
, Reset
, unsafeToReset
, unsafeFromReset
, unsafeToActiveHigh
, unsafeToActiveLow
, unsafeFromActiveHigh
, unsafeFromActiveLow
, resetSynchronizer
, resetGlitchFilter
, holdReset
, Enable
, toEnable
, fromEnable
, E.enableGen
, HiddenClock
, hideClock
, exposeClock
, withClock
, hasClock
, HiddenReset
, hideReset
, exposeReset
, withReset
, hasReset
, HiddenEnable
, hideEnable
, exposeEnable
, withEnable
, hasEnable
, HiddenClockResetEnable
, hideClockResetEnable
, exposeClockResetEnable
, withClockResetEnable
, SystemClockResetEnable
, andEnable
, dflipflop
, delay
, delayMaybe
, delayEn
, register
, regMaybe
, regEn
, mux
, clockGen
, resetGen
, resetGenN
, systemClockGen
, systemResetGen
, (.&&.), (.||.)
, Bundle(..)
, EmptyTuple(..)
, TaggedEmptyTuple(..)
, simulate
, simulateB
, simulateN
, simulateWithReset
, simulateWithResetN
, runUntil
, simulate_lazy
, simulateB_lazy
, signalAutomaton
, sample
, sampleN
, sampleWithReset
, sampleWithResetN
, fromList
, fromListWithReset
, sample_lazy
, sampleN_lazy
, fromList_lazy
, testFor
, (.==.), (./=.)
, (.<.), (.<=.), (.>=.), (.>.)
, veryUnsafeToBiSignalIn
, readFromBiSignal
, writeToBiSignal
, mergeBiSignalOuts
, HiddenClockName
, HiddenResetName
, HiddenEnableName
, unsafeFromHighPolarity
, unsafeFromLowPolarity
, unsafeToHighPolarity
, unsafeToLowPolarity
)
where
import Control.Arrow.Transformer.Automaton (Automaton)
import GHC.TypeLits (type (<=))
import Data.List (uncons)
import Data.Proxy (Proxy(..))
import Prelude
import Test.QuickCheck (Property, property)
import qualified Clash.Explicit.Signal as E
import qualified Clash.Explicit.Reset as E
import Clash.Explicit.Reset (resetSynchronizer, resetGlitchFilter)
import Clash.Explicit.Signal (systemClockGen, systemResetGen)
import Clash.Hidden
import Clash.Promoted.Nat (SNat (..), snatToNum)
import Clash.Signal.Bundle
(Bundle (..), EmptyTuple(..), TaggedEmptyTuple(..))
import Clash.Signal.BiSignal
import Clash.Signal.Internal hiding
(sample, sample_lazy, sampleN, sampleN_lazy, simulate, simulate_lazy, testFor,
signalAutomaton)
import Clash.Signal.Internal.Ambiguous
(knownVDomain, clockPeriod, activeEdge, resetKind, initBehavior, resetPolarity)
import Clash.XException (NFDataX, ShowX)
type HiddenClockName (dom :: Domain) = "clock"
type HiddenResetName (dom :: Domain) = "reset"
type HiddenEnableName (dom :: Domain) = "enable"
type HiddenClock dom =
( Hidden (HiddenClockName dom) (Clock dom)
, KnownDomain dom )
type HiddenReset dom =
( Hidden (HiddenResetName dom) (Reset dom)
, KnownDomain dom )
type HiddenEnable dom =
( Hidden (HiddenEnableName dom) (Enable dom)
, KnownDomain dom )
type HiddenClockResetEnable dom =
( HiddenClock dom
, HiddenReset dom
, HiddenEnable dom
)
type SystemClockResetEnable =
( Hidden (HiddenClockName System) (Clock System)
, Hidden (HiddenResetName System) (Reset System)
, Hidden (HiddenEnableName System) (Enable System)
)
exposeClock
:: forall dom r
. (HiddenClock dom => r)
-> (KnownDomain dom => Clock dom -> r)
exposeClock :: (HiddenClock dom => r) -> KnownDomain dom => Clock dom -> r
exposeClock = \HiddenClock dom => r
f Clock dom
clk -> (Hidden (HiddenClockName dom) (Clock dom) => r) -> Clock dom -> r
forall (x :: Symbol) a r. (Hidden x a => r) -> a -> r
expose @(HiddenClockName dom) Hidden (HiddenClockName dom) (Clock dom) => r
HiddenClock dom => r
f Clock dom
clk
{-# INLINE exposeClock #-}
hideClock
:: forall dom r
. HiddenClock dom
=> (Clock dom -> r)
-> r
hideClock :: (Clock dom -> r) -> r
hideClock = \Clock dom -> r
f -> Clock dom -> r
f (forall a. Hidden (HiddenClockName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
{-# INLINE hideClock #-}
withClock
:: forall dom r
. KnownDomain dom
=> Clock dom
-> (HiddenClock dom => r)
-> r
withClock :: Clock dom -> (HiddenClock dom => r) -> r
withClock = \Clock dom
clk HiddenClock dom => r
f -> (Hidden (HiddenClockName dom) (Clock dom) => r) -> Clock dom -> r
forall (x :: Symbol) a r. (Hidden x a => r) -> a -> r
expose @(HiddenClockName dom) Hidden (HiddenClockName dom) (Clock dom) => r
HiddenClock dom => r
f Clock dom
clk
{-# INLINE withClock #-}
hasClock
:: forall dom
. HiddenClock dom
=> Clock dom
hasClock :: Clock dom
hasClock = forall a. Hidden (HiddenClockName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenClockName dom)
{-# INLINE hasClock #-}
exposeReset
:: forall dom r
. (HiddenReset dom => r)
-> (KnownDomain dom => Reset dom -> r)
exposeReset :: (HiddenReset dom => r) -> KnownDomain dom => Reset dom -> r
exposeReset = \HiddenReset dom => r
f Reset dom
rst -> (Hidden (HiddenResetName dom) (Reset dom) => r) -> Reset dom -> r
forall (x :: Symbol) a r. (Hidden x a => r) -> a -> r
expose @(HiddenResetName dom) Hidden (HiddenResetName dom) (Reset dom) => r
HiddenReset dom => r
f Reset dom
rst
{-# INLINE exposeReset #-}
hideReset
:: forall dom r
. HiddenReset dom
=> (Reset dom -> r)
-> r
hideReset :: (Reset dom -> r) -> r
hideReset = \Reset dom -> r
f -> Reset dom -> r
f (forall a. Hidden (HiddenResetName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenResetName dom))
{-# INLINE hideReset #-}
withReset
:: forall dom r
. KnownDomain dom
=> Reset dom
-> (HiddenReset dom => r)
-> r
withReset :: Reset dom -> (HiddenReset dom => r) -> r
withReset = \Reset dom
rst HiddenReset dom => r
f -> (Hidden (HiddenResetName dom) (Reset dom) => r) -> Reset dom -> r
forall (x :: Symbol) a r. (Hidden x a => r) -> a -> r
expose @(HiddenResetName dom) Hidden (HiddenResetName dom) (Reset dom) => r
HiddenReset dom => r
f Reset dom
rst
{-# INLINE withReset #-}
hasReset
:: forall dom
. HiddenReset dom
=> Reset dom
hasReset :: Reset dom
hasReset = forall a. Hidden (HiddenResetName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenResetName dom)
{-# INLINE hasReset #-}
exposeEnable
:: forall dom r
. (HiddenEnable dom => r)
-> (KnownDomain dom => Enable dom -> r)
exposeEnable :: (HiddenEnable dom => r) -> KnownDomain dom => Enable dom -> r
exposeEnable = \HiddenEnable dom => r
f Enable dom
gen -> (Hidden (HiddenEnableName dom) (Enable dom) => r)
-> Enable dom -> r
forall (x :: Symbol) a r. (Hidden x a => r) -> a -> r
expose @(HiddenEnableName dom) Hidden (HiddenEnableName dom) (Enable dom) => r
HiddenEnable dom => r
f Enable dom
gen
{-# INLINE exposeEnable #-}
hideEnable
:: forall dom r
. HiddenEnable dom
=> (Enable dom -> r)
-> r
hideEnable :: (Enable dom -> r) -> r
hideEnable = \Enable dom -> r
f -> Enable dom -> r
f (forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenEnableName dom))
{-# INLINE hideEnable #-}
withEnable
:: forall dom r
. KnownDomain dom
=> Enable dom
-> (HiddenEnable dom => r)
-> r
withEnable :: Enable dom -> (HiddenEnable dom => r) -> r
withEnable = \Enable dom
gen HiddenEnable dom => r
f -> (Hidden (HiddenEnableName dom) (Enable dom) => r)
-> Enable dom -> r
forall (x :: Symbol) a r. (Hidden x a => r) -> a -> r
expose @(HiddenEnableName dom) Hidden (HiddenEnableName dom) (Enable dom) => r
HiddenEnable dom => r
f Enable dom
gen
{-# INLINE withEnable #-}
hasEnable
:: forall dom
. HiddenEnable dom
=> Enable dom
hasEnable :: Enable dom
hasEnable = forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenEnableName dom)
{-# INLINE hasEnable #-}
andEnable
:: forall dom r
. HiddenEnable dom
=> Signal dom Bool
-> (HiddenEnable dom => r)
-> r
andEnable :: Signal dom Bool -> (HiddenEnable dom => r) -> r
andEnable = \Signal dom Bool
en HiddenEnable dom => r
f -> Enable dom -> Signal dom Bool -> (HiddenEnable dom => r) -> r
andEnable0 Enable dom
forall (dom :: Symbol). HiddenEnable dom => Enable dom
hasEnable Signal dom Bool
en HiddenEnable dom => r
f
where
andEnable0
:: Enable dom
-> Signal dom Bool
-> (HiddenEnable dom => r)
-> r
andEnable0 :: Enable dom -> Signal dom Bool -> (HiddenEnable dom => r) -> r
andEnable0 Enable dom
gen Signal dom Bool
en HiddenEnable dom => r
f =
let en0 :: Enable dom
en0 = Enable dom -> Signal dom Bool -> Enable dom
forall (dom :: Symbol). Enable dom -> Signal dom Bool -> Enable dom
E.andEnable Enable dom
gen Signal dom Bool
en
in Enable dom -> (HiddenEnable dom => r) -> r
forall (dom :: Symbol) r.
KnownDomain dom =>
Enable dom -> (HiddenEnable dom => r) -> r
withEnable @dom Enable dom
en0 HiddenEnable dom => r
f
{-# INLINE andEnable #-}
exposeClockResetEnable
:: forall dom r .
(HiddenClockResetEnable dom => r)
-> (KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r)
exposeClockResetEnable :: (HiddenClockResetEnable dom => r)
-> KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
exposeClockResetEnable =
\HiddenClockResetEnable dom => r
f Clock dom
clk Reset dom
rst Enable dom
en ->
(HiddenClock dom => Reset dom -> Enable dom -> r)
-> Clock dom -> Reset dom -> Enable dom -> r
forall (dom :: Symbol) r.
(HiddenClock dom => r) -> KnownDomain dom => Clock dom -> r
exposeClock ((HiddenReset dom => Enable dom -> r)
-> KnownDomain dom => Reset dom -> Enable dom -> r
forall (dom :: Symbol) r.
(HiddenReset dom => r) -> KnownDomain dom => Reset dom -> r
exposeReset ((HiddenEnable dom => r) -> KnownDomain dom => Enable dom -> r
forall (dom :: Symbol) r.
(HiddenEnable dom => r) -> KnownDomain dom => Enable dom -> r
exposeEnable HiddenEnable dom => r
HiddenClockResetEnable dom => r
f)) Clock dom
clk Reset dom
rst Enable dom
en
{-# INLINE exposeClockResetEnable #-}
hideClockResetEnable
:: forall dom r
. HiddenClockResetEnable dom
=> (KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r)
-> r
hideClockResetEnable :: (KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r) -> r
hideClockResetEnable =
\KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
f ->
Clock dom -> Reset dom -> Enable dom -> r
KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
f
(forall a. Hidden (HiddenClockName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
(forall a. Hidden (HiddenResetName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenResetName dom))
(forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenEnableName dom))
{-# INLINE hideClockResetEnable #-}
withClockResetEnable
:: forall dom r
. KnownDomain dom
=> Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom => r)
-> r
withClockResetEnable :: Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom => r)
-> r
withClockResetEnable =
\Clock dom
clk Reset dom
rst Enable dom
en HiddenClockResetEnable dom => r
f -> Clock dom -> (HiddenClock dom => r) -> r
forall (dom :: Symbol) r.
KnownDomain dom =>
Clock dom -> (HiddenClock dom => r) -> r
withClock Clock dom
clk (Reset dom -> (HiddenReset dom => r) -> r
forall (dom :: Symbol) r.
KnownDomain dom =>
Reset dom -> (HiddenReset dom => r) -> r
withReset Reset dom
rst (Enable dom -> (HiddenEnable dom => r) -> r
forall (dom :: Symbol) r.
KnownDomain dom =>
Enable dom -> (HiddenEnable dom => r) -> r
withEnable Enable dom
en HiddenEnable dom => r
HiddenClockResetEnable dom => r
f))
{-# INLINE withClockResetEnable #-}
dflipflop
:: forall dom a
. ( HiddenClock dom
, NFDataX a )
=> Signal dom a
-> Signal dom a
dflipflop :: Signal dom a -> Signal dom a
dflipflop =
Clock dom -> Signal dom a -> Signal dom a
forall (dom :: Symbol) a.
(KnownDomain dom, NFDataX a) =>
Clock dom -> Signal dom a -> Signal dom a
E.dflipflop (forall a. Hidden (HiddenClockName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
{-# INLINE dflipflop #-}
delay
:: forall dom a
. ( NFDataX a
, HiddenClock dom
, HiddenEnable dom )
=> a
-> Signal dom a
-> Signal dom a
delay :: a -> Signal dom a -> Signal dom a
delay = \a
dflt Signal dom a
i ->
Clock dom -> Enable dom -> a -> Signal dom a -> Signal dom a
forall (dom :: Symbol) a.
(KnownDomain dom, NFDataX a) =>
Clock dom -> Enable dom -> a -> Signal dom a -> Signal dom a
delay#
(forall a. Hidden (HiddenClockName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
(forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenEnableName dom))
a
dflt
Signal dom a
i
{-# INLINE delay #-}
delayMaybe
:: forall dom a
. ( NFDataX a
, HiddenClock dom
, HiddenEnable dom )
=> a
-> Signal dom (Maybe a)
-> Signal dom a
delayMaybe :: a -> Signal dom (Maybe a) -> Signal dom a
delayMaybe = \a
dflt Signal dom (Maybe a)
i ->
Clock dom
-> Enable dom -> a -> Signal dom (Maybe a) -> Signal dom a
forall (dom :: Symbol) a.
(KnownDomain dom, NFDataX a) =>
Clock dom
-> Enable dom -> a -> Signal dom (Maybe a) -> Signal dom a
E.delayMaybe
(forall a. Hidden (HiddenClockName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
(forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenEnableName dom))
a
dflt
Signal dom (Maybe a)
i
{-# INLINE delayMaybe #-}
delayEn
:: forall dom a
. ( NFDataX a
, HiddenClock dom
, HiddenEnable dom )
=> a
-> Signal dom Bool
-> Signal dom a
-> Signal dom a
delayEn :: a -> Signal dom Bool -> Signal dom a -> Signal dom a
delayEn = \a
dflt Signal dom Bool
en Signal dom a
i ->
Clock dom
-> Enable dom
-> a
-> Signal dom Bool
-> Signal dom a
-> Signal dom a
forall (dom :: Symbol) a.
(KnownDomain dom, NFDataX a) =>
Clock dom
-> Enable dom
-> a
-> Signal dom Bool
-> Signal dom a
-> Signal dom a
E.delayEn
(forall a. Hidden (HiddenClockName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
(forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenEnableName dom))
a
dflt
Signal dom Bool
en
Signal dom a
i
{-# INLINE delayEn #-}
register
:: forall dom a
. ( HiddenClockResetEnable dom
, NFDataX a )
=> a
-> Signal dom a
-> Signal dom a
register :: a -> Signal dom a -> Signal dom a
register = \a
i Signal dom a
s ->
Clock dom
-> Reset dom -> Enable dom -> a -> Signal dom a -> Signal dom a
forall (dom :: Symbol) a.
(KnownDomain dom, NFDataX a) =>
Clock dom
-> Reset dom -> Enable dom -> a -> Signal dom a -> Signal dom a
E.register
(forall a. Hidden (HiddenClockName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
(forall a. Hidden (HiddenResetName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenResetName dom))
(forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenEnableName dom))
a
i
Signal dom a
s
{-# INLINE register #-}
infixr 3 `register`
regMaybe
:: forall dom a
. ( HiddenClockResetEnable dom
, NFDataX a )
=> a
-> Signal dom (Maybe a)
-> Signal dom a
regMaybe :: a -> Signal dom (Maybe a) -> Signal dom a
regMaybe = \a
initial Signal dom (Maybe a)
iM ->
Clock dom
-> Reset dom
-> Enable dom
-> a
-> Signal dom (Maybe a)
-> Signal dom a
forall (dom :: Symbol) a.
(KnownDomain dom, NFDataX a) =>
Clock dom
-> Reset dom
-> Enable dom
-> a
-> Signal dom (Maybe a)
-> Signal dom a
E.regMaybe
(forall a. Hidden (HiddenClockName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
(forall a. Hidden (HiddenResetName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenResetName dom))
(forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenEnableName dom))
a
initial
Signal dom (Maybe a)
iM
{-# INLINE regMaybe #-}
infixr 3 `regMaybe`
regEn
:: forall dom a
. ( HiddenClockResetEnable dom
, NFDataX a )
=> a
-> Signal dom Bool
-> Signal dom a
-> Signal dom a
regEn :: a -> Signal dom Bool -> Signal dom a -> Signal dom a
regEn = \a
initial Signal dom Bool
en Signal dom a
i ->
Clock dom
-> Reset dom
-> Enable dom
-> a
-> Signal dom Bool
-> Signal dom a
-> Signal dom a
forall (dom :: Symbol) a.
(KnownDomain dom, NFDataX a) =>
Clock dom
-> Reset dom
-> Enable dom
-> a
-> Signal dom Bool
-> Signal dom a
-> Signal dom a
E.regEn
(forall a. Hidden (HiddenClockName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
(forall a. Hidden (HiddenResetName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenResetName dom))
(forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Symbol) a. Hidden x a => a
fromLabel @(HiddenEnableName dom))
a
initial
Signal dom Bool
en
Signal dom a
i
{-# INLINE regEn #-}
sample
:: forall dom a
. ( KnownDomain dom
, NFDataX a )
=> (HiddenClockResetEnable dom => Signal dom a)
-> [a]
sample :: (HiddenClockResetEnable dom => Signal dom a) -> [a]
sample HiddenClockResetEnable dom => Signal dom a
s =
Signal dom a -> [a]
forall (f :: Type -> Type) a. (Foldable f, NFDataX a) => f a -> [a]
E.sample ((HiddenClockResetEnable dom => Signal dom a)
-> Clock dom -> Reset dom -> Enable dom -> Signal dom a
forall (dom :: Symbol) r.
(HiddenClockResetEnable dom => r)
-> KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
exposeClockResetEnable @dom HiddenClockResetEnable dom => Signal dom a
s Clock dom
forall (dom :: Symbol). KnownDomain dom => Clock dom
clockGen Reset dom
forall (dom :: Symbol). KnownDomain dom => Reset dom
resetGen Enable dom
forall (dom :: Symbol). Enable dom
enableGen)
{-# CLASH_OPAQUE sample #-}
sampleN
:: forall dom a
. ( KnownDomain dom
, NFDataX a )
=> Int
-> (HiddenClockResetEnable dom => Signal dom a)
-> [a]
sampleN :: Int -> (HiddenClockResetEnable dom => Signal dom a) -> [a]
sampleN Int
n HiddenClockResetEnable dom => Signal dom a
s0 =
let s1 :: Signal dom a
s1 = (HiddenClockResetEnable dom => Signal dom a)
-> Clock dom -> Reset dom -> Enable dom -> Signal dom a
forall (dom :: Symbol) r.
(HiddenClockResetEnable dom => r)
-> KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
exposeClockResetEnable @dom HiddenClockResetEnable dom => Signal dom a
s0 Clock dom
forall (dom :: Symbol). KnownDomain dom => Clock dom
clockGen Reset dom
forall (dom :: Symbol). KnownDomain dom => Reset dom
resetGen Enable dom
forall (dom :: Symbol). Enable dom
enableGen in
Int -> Signal dom a -> [a]
forall (f :: Type -> Type) a.
(Foldable f, NFDataX a) =>
Int -> f a -> [a]
E.sampleN Int
n Signal dom a
s1
{-# CLASH_OPAQUE sampleN #-}
sampleWithReset
:: forall dom a m
. ( KnownDomain dom
, NFDataX a
, 1 <= m )
=> SNat m
-> (HiddenClockResetEnable dom => Signal dom a)
-> [a]
sampleWithReset :: SNat m -> (HiddenClockResetEnable dom => Signal dom a) -> [a]
sampleWithReset SNat m
nReset HiddenClockResetEnable dom => Signal dom a
f0 =
let f1 :: Signal dom a
f1 = (HiddenClockResetEnable dom => Signal dom a)
-> Clock dom -> Reset dom -> Enable dom -> Signal dom a
forall (dom :: Symbol) r.
(HiddenClockResetEnable dom => r)
-> KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
exposeClockResetEnable HiddenClockResetEnable dom => Signal dom a
f0 Clock dom
forall (dom :: Symbol). KnownDomain dom => Clock dom
clockGen (SNat m -> Reset dom
forall (dom :: Symbol) (n :: Nat).
(KnownDomain dom, 1 <= n) =>
SNat n -> Reset dom
resetGenN @dom SNat m
nReset) Enable dom
forall (dom :: Symbol). Enable dom
enableGen in
Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
drop (SNat m -> Int
forall a (n :: Nat). Num a => SNat n -> a
snatToNum SNat m
nReset) (Signal dom a -> [a]
forall (f :: Type -> Type) a. (Foldable f, NFDataX a) => f a -> [a]
E.sample Signal dom a
f1)
{-# CLASH_OPAQUE sampleWithReset #-}
sampleWithResetN
:: forall dom a m
. ( KnownDomain dom
, NFDataX a
, 1 <= m )
=> SNat m
-> Int
-> (HiddenClockResetEnable dom => Signal dom a)
-> [a]
sampleWithResetN :: SNat m
-> Int -> (HiddenClockResetEnable dom => Signal dom a) -> [a]
sampleWithResetN SNat m
nReset Int
nSamples HiddenClockResetEnable dom => Signal dom a
f =
Int -> [a] -> [a]
forall a. Int -> [a] -> [a]
take Int
nSamples (SNat m -> (HiddenClockResetEnable dom => Signal dom a) -> [a]
forall (dom :: Symbol) a (m :: Nat).
(KnownDomain dom, NFDataX a, 1 <= m) =>
SNat m -> (HiddenClockResetEnable dom => Signal dom a) -> [a]
sampleWithReset SNat m
nReset HiddenClockResetEnable dom => Signal dom a
f)
sample_lazy
:: forall dom a
. KnownDomain dom
=> (HiddenClockResetEnable dom => Signal dom a)
-> [a]
sample_lazy :: (HiddenClockResetEnable dom => Signal dom a) -> [a]
sample_lazy HiddenClockResetEnable dom => Signal dom a
s =
Signal dom a -> [a]
forall (f :: Type -> Type) a. Foldable f => f a -> [a]
E.sample_lazy ((HiddenClockResetEnable dom => Signal dom a)
-> Clock dom -> Reset dom -> Enable dom -> Signal dom a
forall (dom :: Symbol) r.
(HiddenClockResetEnable dom => r)
-> KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
exposeClockResetEnable @dom HiddenClockResetEnable dom => Signal dom a
s Clock dom
forall (dom :: Symbol). KnownDomain dom => Clock dom
clockGen Reset dom
forall (dom :: Symbol). KnownDomain dom => Reset dom
resetGen Enable dom
forall (dom :: Symbol). Enable dom
enableGen)
{-# CLASH_OPAQUE sample_lazy #-}
sampleN_lazy
:: forall dom a
. KnownDomain dom
=> Int
-> (HiddenClockResetEnable dom => Signal dom a)
-> [a]
sampleN_lazy :: Int -> (HiddenClockResetEnable dom => Signal dom a) -> [a]
sampleN_lazy Int
n HiddenClockResetEnable dom => Signal dom a
s =
Int -> Signal dom a -> [a]
forall (f :: Type -> Type) a. Foldable f => Int -> f a -> [a]
E.sampleN_lazy Int
n ((HiddenClockResetEnable dom => Signal dom a)
-> Clock dom -> Reset dom -> Enable dom -> Signal dom a
forall (dom :: Symbol) r.
(HiddenClockResetEnable dom => r)
-> KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
exposeClockResetEnable @dom HiddenClockResetEnable dom => Signal dom a
s Clock dom
forall (dom :: Symbol). KnownDomain dom => Clock dom
clockGen Reset dom
forall (dom :: Symbol). KnownDomain dom => Reset dom
resetGen Enable dom
forall (dom :: Symbol). Enable dom
enableGen)
{-# CLASH_OPAQUE sampleN_lazy #-}
simulate
:: forall dom a b
. ( KnownDomain dom
, NFDataX a
, NFDataX b )
=> (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a]
-> [b]
simulate :: (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a] -> [b]
simulate HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f [a]
as = SNat 1
-> a
-> (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a]
-> [b]
forall (dom :: Symbol) a b (m :: Nat).
(KnownDomain dom, NFDataX a, NFDataX b, 1 <= m) =>
SNat m
-> a
-> (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a]
-> [b]
simulateWithReset (KnownNat 1 => SNat 1
forall (n :: Nat). KnownNat n => SNat n
SNat @1) a
rval HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f [a]
as
where
rval :: a
rval = a -> ((a, [a]) -> a) -> Maybe (a, [a]) -> a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ([Char] -> a
forall a. HasCallStack => [Char] -> a
error [Char]
"simulate: no stimuli") (a, [a]) -> a
forall a b. (a, b) -> a
fst ([a] -> Maybe (a, [a])
forall a. [a] -> Maybe (a, [a])
uncons [a]
as)
{-# INLINE simulate #-}
simulateN
:: forall dom a b
. ( KnownDomain dom
, NFDataX a
, NFDataX b )
=> Int
-> (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a]
-> [b]
simulateN :: Int
-> (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a]
-> [b]
simulateN Int
n HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f [a]
as = SNat 1
-> a
-> Int
-> (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a]
-> [b]
forall (dom :: Symbol) a b (m :: Nat).
(KnownDomain dom, NFDataX a, NFDataX b, 1 <= m) =>
SNat m
-> a
-> Int
-> (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a]
-> [b]
simulateWithResetN (KnownNat 1 => SNat 1
forall (n :: Nat). KnownNat n => SNat n
SNat @1) a
rval Int
n HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f [a]
as
where
rval :: a
rval = a -> ((a, [a]) -> a) -> Maybe (a, [a]) -> a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ([Char] -> a
forall a. HasCallStack => [Char] -> a
error [Char]
"simulate: no stimuli") (a, [a]) -> a
forall a b. (a, b) -> a
fst ([a] -> Maybe (a, [a])
forall a. [a] -> Maybe (a, [a])
uncons [a]
as)
{-# INLINE simulateN #-}
simulateWithReset
:: forall dom a b m
. ( KnownDomain dom
, NFDataX a
, NFDataX b
, 1 <= m )
=> SNat m
-> a
-> (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a]
-> [b]
simulateWithReset :: SNat m
-> a
-> (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a]
-> [b]
simulateWithReset SNat m
n a
resetVal HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f [a]
as =
SNat m
-> a
-> (KnownDomain dom =>
Clock dom
-> Reset dom -> Enable dom -> Signal dom a -> Signal dom b)
-> [a]
-> [b]
forall (dom :: Symbol) a b (m :: Nat).
(KnownDomain dom, NFDataX a, NFDataX b, 1 <= m) =>
SNat m
-> a
-> (KnownDomain dom =>
Clock dom
-> Reset dom -> Enable dom -> Signal dom a -> Signal dom b)
-> [a]
-> [b]
E.simulateWithReset SNat m
n a
resetVal ((HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> KnownDomain dom =>
Clock dom
-> Reset dom -> Enable dom -> Signal dom a -> Signal dom b
forall (dom :: Symbol) r.
(HiddenClockResetEnable dom => r)
-> KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
exposeClockResetEnable HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f) [a]
as
{-# INLINE simulateWithReset #-}
simulateWithResetN
:: forall dom a b m
. ( KnownDomain dom
, NFDataX a
, NFDataX b
, 1 <= m )
=> SNat m
-> a
-> Int
-> (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a]
-> [b]
simulateWithResetN :: SNat m
-> a
-> Int
-> (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a]
-> [b]
simulateWithResetN SNat m
nReset a
resetVal Int
nSamples HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f [a]
as =
SNat m
-> a
-> Int
-> (KnownDomain dom =>
Clock dom
-> Reset dom -> Enable dom -> Signal dom a -> Signal dom b)
-> [a]
-> [b]
forall (dom :: Symbol) a b (m :: Nat).
(KnownDomain dom, NFDataX a, NFDataX b, 1 <= m) =>
SNat m
-> a
-> Int
-> (KnownDomain dom =>
Clock dom
-> Reset dom -> Enable dom -> Signal dom a -> Signal dom b)
-> [a]
-> [b]
E.simulateWithResetN SNat m
nReset a
resetVal Int
nSamples ((HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> KnownDomain dom =>
Clock dom
-> Reset dom -> Enable dom -> Signal dom a -> Signal dom b
forall (dom :: Symbol) r.
(HiddenClockResetEnable dom => r)
-> KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
exposeClockResetEnable HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f) [a]
as
{-# INLINE simulateWithResetN #-}
simulate_lazy
:: forall dom a b
. KnownDomain dom
=> (HiddenClockResetEnable dom =>
Signal dom a -> Signal dom b)
-> [a]
-> [b]
simulate_lazy :: (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a] -> [b]
simulate_lazy HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f0 =
let f1 :: Signal dom a -> Signal dom b
f1 = (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> Clock dom
-> Reset dom
-> Enable dom
-> Signal dom a
-> Signal dom b
forall (dom :: Symbol) r.
(HiddenClockResetEnable dom => r)
-> KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
exposeClockResetEnable @dom HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f0 Clock dom
forall (dom :: Symbol). KnownDomain dom => Clock dom
clockGen Reset dom
forall (dom :: Symbol). KnownDomain dom => Reset dom
resetGen Enable dom
forall (dom :: Symbol). Enable dom
enableGen in
Int -> [b] -> [b]
forall a. Int -> [a] -> [a]
drop Int
1 ([b] -> [b]) -> ([a] -> [b]) -> [a] -> [b]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Signal dom a -> Signal dom b) -> [a] -> [b]
forall (dom1 :: Symbol) a (dom2 :: Symbol) b.
(Signal dom1 a -> Signal dom2 b) -> [a] -> [b]
E.simulate_lazy Signal dom a -> Signal dom b
f1 ([a] -> [b]) -> ([a] -> [a]) -> [a] -> [b]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> [a]
forall a. [a] -> [a]
dup1
{-# CLASH_OPAQUE simulate_lazy #-}
simulateB
:: forall dom a b
. ( KnownDomain dom
, Bundle a
, Bundle b
, NFDataX a
, NFDataX b
)
=> (HiddenClockResetEnable dom =>
Unbundled dom a -> Unbundled dom b)
-> [a]
-> [b]
simulateB :: (HiddenClockResetEnable dom => Unbundled dom a -> Unbundled dom b)
-> [a] -> [b]
simulateB HiddenClockResetEnable dom => Unbundled dom a -> Unbundled dom b
f0 =
Int -> [b] -> [b]
forall a. Int -> [a] -> [a]
drop Int
1 ([b] -> [b]) -> ([a] -> [b]) -> [a] -> [b]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Unbundled dom a -> Unbundled dom b) -> [a] -> [b]
forall a b (dom1 :: Symbol) (dom2 :: Symbol).
(Bundle a, Bundle b, NFDataX a, NFDataX b) =>
(Unbundled dom1 a -> Unbundled dom2 b) -> [a] -> [b]
E.simulateB Unbundled dom a -> Unbundled dom b
f1 ([a] -> [b]) -> ([a] -> [a]) -> [a] -> [b]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> [a]
forall a. [a] -> [a]
dup1
where
f1 :: Unbundled dom a -> Unbundled dom b
f1 =
Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom =>
Proxy dom -> Unbundled dom a -> Unbundled dom b)
-> Proxy dom
-> Unbundled dom a
-> Unbundled dom b
forall (dom :: Symbol) r.
KnownDomain dom =>
Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom => r)
-> r
withClockResetEnable
Clock dom
forall (dom :: Symbol). KnownDomain dom => Clock dom
clockGen
Reset dom
forall (dom :: Symbol). KnownDomain dom => Reset dom
resetGen
Enable dom
forall (dom :: Symbol). Enable dom
enableGen
((Unbundled dom a -> Unbundled dom b)
-> Proxy dom -> Unbundled dom a -> Unbundled dom b
forall a b. a -> b -> a
const HiddenClockResetEnable dom => Unbundled dom a -> Unbundled dom b
Unbundled dom a -> Unbundled dom b
f0)
(Proxy dom
forall k (t :: k). Proxy t
Proxy @dom)
{-# CLASH_OPAQUE simulateB #-}
simulateB_lazy
:: forall dom a b
. ( KnownDomain dom
, Bundle a
, Bundle b )
=> (HiddenClockResetEnable dom =>
Unbundled dom a -> Unbundled dom b)
-> [a]
-> [b]
simulateB_lazy :: (HiddenClockResetEnable dom => Unbundled dom a -> Unbundled dom b)
-> [a] -> [b]
simulateB_lazy HiddenClockResetEnable dom => Unbundled dom a -> Unbundled dom b
f0 =
Int -> [b] -> [b]
forall a. Int -> [a] -> [a]
drop Int
1 ([b] -> [b]) -> ([a] -> [b]) -> [a] -> [b]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Unbundled dom a -> Unbundled dom b) -> [a] -> [b]
forall a b (dom1 :: Symbol) (dom2 :: Symbol).
(Bundle a, Bundle b) =>
(Unbundled dom1 a -> Unbundled dom2 b) -> [a] -> [b]
E.simulateB_lazy Unbundled dom a -> Unbundled dom b
f1 ([a] -> [b]) -> ([a] -> [a]) -> [a] -> [b]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> [a]
forall a. [a] -> [a]
dup1
where
f1 :: Unbundled dom a -> Unbundled dom b
f1 =
Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom =>
Proxy dom -> Unbundled dom a -> Unbundled dom b)
-> Proxy dom
-> Unbundled dom a
-> Unbundled dom b
forall (dom :: Symbol) r.
KnownDomain dom =>
Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom => r)
-> r
withClockResetEnable
Clock dom
forall (dom :: Symbol). KnownDomain dom => Clock dom
clockGen
Reset dom
forall (dom :: Symbol). KnownDomain dom => Reset dom
resetGen
Enable dom
forall (dom :: Symbol). Enable dom
enableGen
((Unbundled dom a -> Unbundled dom b)
-> Proxy dom -> Unbundled dom a -> Unbundled dom b
forall a b. a -> b -> a
const HiddenClockResetEnable dom => Unbundled dom a -> Unbundled dom b
Unbundled dom a -> Unbundled dom b
f0)
(Proxy dom
forall k (t :: k). Proxy t
Proxy @dom)
{-# CLASH_OPAQUE simulateB_lazy #-}
dup1 :: [a] -> [a]
dup1 :: [a] -> [a]
dup1 (a
x:[a]
xs) = a
xa -> [a] -> [a]
forall a. a -> [a] -> [a]
:a
xa -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
xs
dup1 [a]
_ = [Char] -> [a]
forall a. HasCallStack => [Char] -> a
error [Char]
"empty list"
runUntil
:: forall dom a
. (KnownDomain dom, NFDataX a, ShowX a)
=> (a -> Bool)
-> (HiddenClockResetEnable dom => Signal dom a)
-> IO ()
runUntil :: (a -> Bool)
-> (HiddenClockResetEnable dom => Signal dom a) -> IO ()
runUntil a -> Bool
check HiddenClockResetEnable dom => Signal dom a
s =
(a -> Bool) -> Signal dom a -> IO ()
forall (dom :: Symbol) a.
(KnownDomain dom, NFDataX a, ShowX a) =>
(a -> Bool) -> Signal dom a -> IO ()
E.runUntil a -> Bool
check (Signal dom a -> IO ()) -> Signal dom a -> IO ()
forall a b. (a -> b) -> a -> b
$ (HiddenClockResetEnable dom => Signal dom a)
-> Clock dom -> Reset dom -> Enable dom -> Signal dom a
forall (dom :: Symbol) r.
(HiddenClockResetEnable dom => r)
-> KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
exposeClockResetEnable @dom HiddenClockResetEnable dom => Signal dom a
s Clock dom
forall (dom :: Symbol). KnownDomain dom => Clock dom
clockGen Reset dom
forall (dom :: Symbol). KnownDomain dom => Reset dom
resetGen Enable dom
forall (dom :: Symbol). Enable dom
enableGen
testFor
:: KnownDomain dom
=> Int
-> (HiddenClockResetEnable dom => Signal dom Bool)
-> Property
testFor :: Int -> (HiddenClockResetEnable dom => Signal dom Bool) -> Property
testFor Int
n HiddenClockResetEnable dom => Signal dom Bool
s = Bool -> Property
forall prop. Testable prop => prop -> Property
property ([Bool] -> Bool
forall (t :: Type -> Type). Foldable t => t Bool -> Bool
and (Int -> (HiddenClockResetEnable dom => Signal dom Bool) -> [Bool]
forall (dom :: Symbol) a.
(KnownDomain dom, NFDataX a) =>
Int -> (HiddenClockResetEnable dom => Signal dom a) -> [a]
Clash.Signal.sampleN Int
n HiddenClockResetEnable dom => Signal dom Bool
s))
holdReset
:: forall dom m
. HiddenClockResetEnable dom
=> SNat m
-> Reset dom
holdReset :: SNat m -> Reset dom
holdReset SNat m
m =
(KnownDomain dom =>
Clock dom -> Reset dom -> Enable dom -> Reset dom)
-> Reset dom
forall (dom :: Symbol) r.
HiddenClockResetEnable dom =>
(KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r) -> r
hideClockResetEnable (\Clock dom
clk Reset dom
rst Enable dom
en -> Clock dom -> Enable dom -> SNat m -> Reset dom -> Reset dom
forall (dom :: Symbol) (n :: Nat).
KnownDomain dom =>
Clock dom -> Enable dom -> SNat n -> Reset dom -> Reset dom
E.holdReset Clock dom
clk Enable dom
en SNat m
m Reset dom
rst)
fromListWithReset
:: forall dom a
. (HiddenReset dom, NFDataX a)
=> a
-> [a]
-> Signal dom a
fromListWithReset :: a -> [a] -> Signal dom a
fromListWithReset = (Reset dom -> a -> [a] -> Signal dom a) -> a -> [a] -> Signal dom a
forall (dom :: Symbol) r. HiddenReset dom => (Reset dom -> r) -> r
hideReset Reset dom -> a -> [a] -> Signal dom a
forall (dom :: Symbol) a.
(KnownDomain dom, NFDataX a) =>
Reset dom -> a -> [a] -> Signal dom a
E.fromListWithReset
{-# INLINE fromListWithReset #-}
signalAutomaton
:: forall dom a b
. KnownDomain dom
=> (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> Automaton (->) a b
signalAutomaton :: (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> Automaton (->) a b
signalAutomaton HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f0 =
let f1 :: Signal dom a -> Signal dom b
f1 = (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> Clock dom
-> Reset dom
-> Enable dom
-> Signal dom a
-> Signal dom b
forall (dom :: Symbol) r.
(HiddenClockResetEnable dom => r)
-> KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
exposeClockResetEnable @dom HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f0 Clock dom
forall (dom :: Symbol). KnownDomain dom => Clock dom
clockGen Reset dom
forall (dom :: Symbol). KnownDomain dom => Reset dom
resetGen Enable dom
forall (dom :: Symbol). Enable dom
enableGen in
(Signal dom a -> Signal dom b) -> Automaton (->) a b
forall (dom :: Symbol) a b.
(Signal dom a -> Signal dom b) -> Automaton (->) a b
E.signalAutomaton Signal dom a -> Signal dom b
f1
{-# CLASH_OPAQUE signalAutomaton #-}