{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ExplicitNamespaces #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE Trustworthy #-}
#if __GLASGOW_HASKELL__ < 806
{-# LANGUAGE TypeInType #-}
#endif
{-# OPTIONS_HADDOCK show-extensions #-}
module Clash.Signal
(
Signal
, BiSignalIn
, BiSignalOut
, BiSignalDefault(..)
, Domain
, KnownDomain(..)
, KnownConfiguration
, ActiveEdge(..)
, SActiveEdge(..)
, InitBehavior(..)
, SInitBehavior(..)
, ResetKind(..)
, SResetKind(..)
, ResetPolarity(..)
, SResetPolarity(..)
, DomainConfiguration(..)
, SDomainConfiguration(..)
, DomainPeriod
, DomainActiveEdge
, DomainResetKind
, DomainInitBehavior
, DomainResetPolarity
, System
, XilinxSystem
, IntelSystem
, vSystem
, vIntelSystem
, vXilinxSystem
, VDomainConfiguration(..)
, vDomain
, createDomain
, knownVDomain
, clockPeriod
, activeEdge
, resetKind
, initBehavior
, resetPolarity
, Clock
, periodToHz
, hzToPeriod
#ifdef CLASH_MULTIPLE_HIDDEN
, unsafeSynchronizer
#endif
, Reset
, unsafeToReset
, unsafeFromReset
, unsafeToHighPolarity
, unsafeToLowPolarity
, unsafeFromHighPolarity
, unsafeFromLowPolarity
#ifdef CLASH_MULTIPLE_HIDDEN
, convertReset
#endif
, resetSynchronizer
, holdReset
, Enable
, toEnable
, fromEnable
, S.enableGen
, HiddenClock
, hideClock
, exposeClock
, withClock
#ifdef CLASH_MULTIPLE_HIDDEN
, exposeSpecificClock
, withSpecificClock
#endif
, hasClock
, HiddenReset
, hideReset
, exposeReset
, withReset
#ifdef CLASH_MULTIPLE_HIDDEN
, exposeSpecificReset
, withSpecificReset
#endif
, hasReset
, HiddenEnable
, hideEnable
, exposeEnable
, withEnable
#ifdef CLASH_MULTIPLE_HIDDEN
, exposeSpecificEnable
, withSpecificEnable
#endif
, hasEnable
, HiddenClockResetEnable
, hideClockResetEnable
, exposeClockResetEnable
, withClockResetEnable
#ifdef CLASH_MULTIPLE_HIDDEN
, exposeSpecificClockResetEnable
, withSpecificClockResetEnable
#endif
, SystemClockResetEnable
, dflipflop
, delay
, delayMaybe
, delayEn
, register
, regMaybe
, regEn
, mux
, clockGen
, resetGen
, resetGenN
, systemClockGen
, systemResetGen
, (.&&.), (.||.)
, Bundle(..)
, EmptyTuple(..)
, TaggedEmptyTuple(..)
, simulate
, simulateB
, simulateN
, simulateWithReset
, simulateWithResetN
, simulate_lazy
, simulateB_lazy
, sample
, sampleN
, sampleWithReset
, sampleWithResetN
, fromList
, fromListWithReset
, sample_lazy
, sampleN_lazy
, fromList_lazy
, testFor
, (.==.), (./=.)
, (.<.), (.<=.), (.>=.), (.>.)
, veryUnsafeToBiSignalIn
, readFromBiSignal
, writeToBiSignal
, mergeBiSignalOuts
)
where
import GHC.TypeLits (type (<=))
import Data.Proxy (Proxy(..))
import Prelude
import Test.QuickCheck (Property, property)
#ifdef CLASH_MULTIPLE_HIDDEN
import GHC.TypeLits (AppendSymbol)
import Clash.Class.HasDomain (WithSingleDomain)
#endif
import Clash.Class.HasDomain (WithSpecificDomain)
import qualified Clash.Explicit.Signal as E
import Clash.Explicit.Signal
(resetSynchronizer, systemClockGen, systemResetGen)
import qualified Clash.Explicit.Signal as S
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)
import Clash.Signal.Internal.Ambiguous
(knownVDomain, clockPeriod, activeEdge, resetKind, initBehavior, resetPolarity)
import Clash.XException (NFDataX)
#ifdef CLASH_MULTIPLE_HIDDEN
type HiddenClockName dom = AppendSymbol dom "_clk"
type HiddenResetName dom = AppendSymbol dom "_rst"
type HiddenEnableName dom = AppendSymbol dom "_en"
#else
type HiddenClockName (dom :: Domain) = "clock"
type HiddenResetName (dom :: Domain) = "reset"
type HiddenEnableName (dom :: Domain) = "enable"
#endif
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)
)
#ifdef CLASH_MULTIPLE_HIDDEN
#endif
exposeClock
:: forall dom r
.
#ifdef CLASH_MULTIPLE_HIDDEN
WithSingleDomain dom r =>
#endif
(HiddenClock dom => r)
-> (KnownDomain dom => Clock dom -> r)
exposeClock :: (HiddenClock dom => r) -> KnownDomain dom => Clock dom -> r
exposeClock = \f :: HiddenClock dom => r
f clk :: Clock dom
clk -> (HiddenClock dom => Proxy dom -> r) -> Clock dom -> Proxy dom -> r
forall (dom :: Domain) r.
WithSpecificDomain dom r =>
(HiddenClock dom => r) -> KnownDomain dom => Clock dom -> r
exposeSpecificClock (r -> Proxy dom -> r
forall a b. a -> b -> a
const r
HiddenClock dom => r
f) Clock dom
clk (Proxy dom
forall k (t :: k). Proxy t
Proxy @dom)
{-# INLINE exposeClock #-}
exposeSpecificClock
:: forall dom r
. WithSpecificDomain dom r
=> (HiddenClock dom => r)
-> (KnownDomain dom => Clock dom -> r)
exposeSpecificClock :: (HiddenClock dom => r) -> KnownDomain dom => Clock dom -> r
exposeSpecificClock = \f :: HiddenClock dom => r
f clk :: Clock dom
clk -> (Hidden (HiddenClockName dom) (Clock dom) => r) -> Clock dom -> r
forall (x :: Domain) 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 exposeSpecificClock #-}
hideClock
:: forall dom r
. HiddenClock dom
=> (Clock dom -> r)
-> r
hideClock :: (Clock dom -> r) -> r
hideClock = \f :: Clock dom -> r
f -> Clock dom -> r
f (forall a. Hidden (HiddenClockName dom) a => a
forall (x :: Domain) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
{-# INLINE hideClock #-}
#ifdef CLASH_MULTIPLE_HIDDEN
#endif
withClock
:: forall dom r
.
#ifdef CLASH_MULTIPLE_HIDDEN
WithSingleDomain dom r =>
#endif
KnownDomain dom
=> Clock dom
-> (HiddenClock dom => r)
-> r
withClock :: Clock dom -> (HiddenClock dom => r) -> r
withClock clk :: Clock dom
clk f :: HiddenClock dom => r
f = Clock dom -> (HiddenClock dom => Proxy dom -> r) -> Proxy dom -> r
forall (dom :: Domain) r.
(KnownDomain dom, WithSpecificDomain dom r) =>
Clock dom -> (HiddenClock dom => r) -> r
withSpecificClock Clock dom
clk (r -> Proxy dom -> r
forall a b. a -> b -> a
const r
HiddenClock dom => r
f) (Proxy dom
forall k (t :: k). Proxy t
Proxy @dom)
{-# INLINE withClock #-}
withSpecificClock
:: forall dom r
. (KnownDomain dom, WithSpecificDomain dom r)
=> Clock dom
-> (HiddenClock dom => r)
-> r
withSpecificClock :: Clock dom -> (HiddenClock dom => r) -> r
withSpecificClock = \clk :: Clock dom
clk f :: HiddenClock dom => r
f -> (Hidden (HiddenClockName dom) (Clock dom) => r) -> Clock dom -> r
forall (x :: Domain) 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 withSpecificClock #-}
hasClock
:: forall dom
. HiddenClock dom
=> Clock dom
hasClock :: Clock dom
hasClock = forall a. Hidden (HiddenClockName dom) a => a
forall (x :: Domain) a. Hidden x a => a
fromLabel @(HiddenClockName dom)
{-# INLINE hasClock #-}
#ifdef CLASH_MULTIPLE_HIDDEN
#endif
exposeReset
:: forall dom r
.
#ifdef CLASH_MULTIPLE_HIDDEN
WithSingleDomain dom r =>
#endif
(HiddenReset dom => r)
-> (KnownDomain dom => Reset dom -> r)
exposeReset :: (HiddenReset dom => r) -> KnownDomain dom => Reset dom -> r
exposeReset = \f :: HiddenReset dom => r
f rst :: Reset dom
rst -> (HiddenReset dom => Proxy dom -> r) -> Reset dom -> Proxy dom -> r
forall (dom :: Domain) r.
WithSpecificDomain dom r =>
(HiddenReset dom => r) -> KnownDomain dom => Reset dom -> r
exposeSpecificReset (r -> Proxy dom -> r
forall a b. a -> b -> a
const r
HiddenReset dom => r
f) Reset dom
rst (Proxy dom
forall k (t :: k). Proxy t
Proxy @dom)
{-# INLINE exposeReset #-}
exposeSpecificReset
:: forall dom r
. WithSpecificDomain dom r
=> (HiddenReset dom => r)
-> (KnownDomain dom => Reset dom -> r)
exposeSpecificReset :: (HiddenReset dom => r) -> KnownDomain dom => Reset dom -> r
exposeSpecificReset = \f :: HiddenReset dom => r
f rst :: Reset dom
rst -> (Hidden (HiddenResetName dom) (Reset dom) => r) -> Reset dom -> r
forall (x :: Domain) 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 exposeSpecificReset #-}
hideReset
:: forall dom r
. HiddenReset dom
=> (Reset dom -> r)
-> r
hideReset :: (Reset dom -> r) -> r
hideReset = \f :: Reset dom -> r
f -> Reset dom -> r
f (forall a. Hidden (HiddenResetName dom) a => a
forall (x :: Domain) a. Hidden x a => a
fromLabel @(HiddenResetName dom))
{-# INLINE hideReset #-}
#ifdef CLASH_MULTIPLE_HIDDEN
#endif
withReset
:: forall dom r
.
#ifdef CLASH_MULTIPLE_HIDDEN
WithSingleDomain dom r =>
#endif
KnownDomain dom
=> Reset dom
-> (HiddenReset dom => r)
-> r
withReset :: Reset dom -> (HiddenReset dom => r) -> r
withReset = \rst :: Reset dom
rst f :: HiddenReset dom => r
f -> (Hidden (HiddenResetName dom) (Reset dom) => r) -> Reset dom -> r
forall (x :: Domain) 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 #-}
withSpecificReset
:: forall dom r
. (KnownDomain dom, WithSpecificDomain dom r)
=> Reset dom
-> (HiddenReset dom => r)
-> r
withSpecificReset :: Reset dom -> (HiddenReset dom => r) -> r
withSpecificReset = \rst :: Reset dom
rst f :: HiddenReset dom => r
f -> (Hidden (HiddenResetName dom) (Reset dom) => r) -> Reset dom -> r
forall (x :: Domain) 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 withSpecificReset #-}
hasReset
:: forall dom
. HiddenReset dom
=> Reset dom
hasReset :: Reset dom
hasReset = forall a. Hidden (HiddenResetName dom) a => a
forall (x :: Domain) a. Hidden x a => a
fromLabel @(HiddenResetName dom)
{-# INLINE hasReset #-}
#ifdef CLASH_MULTIPLE_HIDDEN
#endif
exposeEnable
:: forall dom r .
#ifdef CLASH_MULTIPLE_HIDDEN
WithSingleDomain dom r =>
#endif
(HiddenEnable dom => r)
-> (KnownDomain dom => Enable dom -> r)
exposeEnable :: (HiddenEnable dom => r) -> KnownDomain dom => Enable dom -> r
exposeEnable = \f :: HiddenEnable dom => r
f gen :: Enable dom
gen -> (HiddenEnable dom => Proxy dom -> r)
-> Enable dom -> Proxy dom -> r
forall (dom :: Domain) r.
WithSpecificDomain dom r =>
(HiddenEnable dom => r) -> KnownDomain dom => Enable dom -> r
exposeSpecificEnable (r -> Proxy dom -> r
forall a b. a -> b -> a
const r
HiddenEnable dom => r
f) Enable dom
gen (Proxy dom
forall k (t :: k). Proxy t
Proxy @dom)
{-# INLINE exposeEnable #-}
exposeSpecificEnable
:: forall dom r
. WithSpecificDomain dom r
=> (HiddenEnable dom => r)
-> (KnownDomain dom => Enable dom -> r)
exposeSpecificEnable :: (HiddenEnable dom => r) -> KnownDomain dom => Enable dom -> r
exposeSpecificEnable = \f :: HiddenEnable dom => r
f gen :: Enable dom
gen -> (Hidden (HiddenEnableName dom) (Enable dom) => r)
-> Enable dom -> r
forall (x :: Domain) 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 exposeSpecificEnable #-}
hideEnable
:: forall dom r
. HiddenEnable dom
=> (Enable dom -> r)
-> r
hideEnable :: (Enable dom -> r) -> r
hideEnable = \f :: Enable dom -> r
f -> Enable dom -> r
f (forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Domain) a. Hidden x a => a
fromLabel @(HiddenEnableName dom))
{-# INLINE hideEnable #-}
#ifdef CLASH_MULTIPLE_HIDDEN
#endif
withEnable
:: forall dom r
. KnownDomain dom
#ifdef CLASH_MULTIPLE_HIDDEN
=> WithSingleDomain dom r
#endif
=> Enable dom
-> (HiddenEnable dom => r)
-> r
withEnable :: Enable dom -> (HiddenEnable dom => r) -> r
withEnable = \gen :: Enable dom
gen f :: HiddenEnable dom => r
f -> (Hidden (HiddenEnableName dom) (Enable dom) => r)
-> Enable dom -> r
forall (x :: Domain) 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 #-}
withSpecificEnable
:: forall dom r
. (KnownDomain dom, WithSpecificDomain dom r)
=> Enable dom
-> (HiddenEnable dom => r)
-> r
withSpecificEnable :: Enable dom -> (HiddenEnable dom => r) -> r
withSpecificEnable = \gen :: Enable dom
gen f :: HiddenEnable dom => r
f -> (Hidden (HiddenEnableName dom) (Enable dom) => r)
-> Enable dom -> r
forall (x :: Domain) 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 withSpecificEnable #-}
hasEnable
:: forall dom
. HiddenEnable dom
=> Enable dom
hasEnable :: Enable dom
hasEnable = forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Domain) a. Hidden x a => a
fromLabel @(HiddenEnableName dom)
{-# INLINE hasEnable #-}
#ifdef CLASH_MULTIPLE_HIDDEN
#endif
exposeClockResetEnable
:: forall dom r .
#ifdef CLASH_MULTIPLE_HIDDEN
WithSingleDomain dom r =>
#endif
(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 =
\f :: HiddenClockResetEnable dom => r
f clk :: Clock dom
clk rst :: Reset dom
rst en :: Enable dom
en ->
(HiddenClock dom => Reset dom -> Enable dom -> r)
-> Clock dom -> Reset dom -> Enable dom -> r
forall (dom :: Domain) r.
WithSpecificDomain dom r =>
(HiddenClock dom => r) -> KnownDomain dom => Clock dom -> r
exposeSpecificClock ((HiddenReset dom => Enable dom -> r)
-> KnownDomain dom => Reset dom -> Enable dom -> r
forall (dom :: Domain) r.
WithSpecificDomain dom r =>
(HiddenReset dom => r) -> KnownDomain dom => Reset dom -> r
exposeSpecificReset ((HiddenEnable dom => r) -> KnownDomain dom => Enable dom -> r
forall (dom :: Domain) r.
WithSingleDomain dom 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 #-}
#ifdef CLASH_MULTIPLE_HIDDEN
exposeSpecificClockResetEnable
:: forall dom r
. WithSpecificDomain dom r
=> (HiddenClockResetEnable dom => r)
-> (KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r)
exposeSpecificClockResetEnable :: (HiddenClockResetEnable dom => r)
-> KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
exposeSpecificClockResetEnable =
\f :: HiddenClockResetEnable dom => r
f clk :: Clock dom
clk rst :: Reset dom
rst en :: Enable dom
en ->
(HiddenClock dom => Reset dom -> Enable dom -> r)
-> Clock dom -> Reset dom -> Enable dom -> r
forall (dom :: Domain) r.
WithSpecificDomain dom r =>
(HiddenClock dom => r) -> KnownDomain dom => Clock dom -> r
exposeSpecificClock ((HiddenReset dom => Enable dom -> r)
-> KnownDomain dom => Reset dom -> Enable dom -> r
forall (dom :: Domain) r.
WithSpecificDomain dom r =>
(HiddenReset dom => r) -> KnownDomain dom => Reset dom -> r
exposeSpecificReset ((HiddenEnable dom => r) -> KnownDomain dom => Enable dom -> r
forall (dom :: Domain) r.
WithSpecificDomain dom r =>
(HiddenEnable dom => r) -> KnownDomain dom => Enable dom -> r
exposeSpecificEnable HiddenEnable dom => r
HiddenClockResetEnable dom => r
f)) Clock dom
clk Reset dom
rst Enable dom
en
{-# INLINE exposeSpecificClockResetEnable #-}
#endif
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 =
\f :: 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 :: Domain) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
(forall a. Hidden (HiddenResetName dom) a => a
forall (x :: Domain) a. Hidden x a => a
fromLabel @(HiddenResetName dom))
(forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Domain) a. Hidden x a => a
fromLabel @(HiddenEnableName dom))
{-# INLINE hideClockResetEnable #-}
#ifdef CLASH_MULTIPLE_HIDDEN
#endif
withClockResetEnable
:: forall dom r
. KnownDomain dom
#ifdef CLASH_MULTIPLE_HIDDEN
=> WithSingleDomain dom r
#endif
=> Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom => r)
-> r
withClockResetEnable :: Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom => r)
-> r
withClockResetEnable =
\clk :: Clock dom
clk rst :: Reset dom
rst en :: Enable dom
en f :: HiddenClockResetEnable dom => r
f -> Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom => Proxy dom -> r)
-> Proxy dom
-> r
forall (dom :: Domain) r.
(KnownDomain dom, WithSpecificDomain dom r) =>
Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom => r)
-> r
withSpecificClockResetEnable Clock dom
clk Reset dom
rst Enable dom
en (r -> Proxy dom -> r
forall a b. a -> b -> a
const r
HiddenClockResetEnable dom => r
f) (Proxy dom
forall k (t :: k). Proxy t
Proxy @dom)
{-# INLINE withClockResetEnable #-}
withSpecificClockResetEnable
:: forall dom r
. (KnownDomain dom, WithSpecificDomain dom r)
=> Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom => r)
-> r
withSpecificClockResetEnable :: Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom => r)
-> r
withSpecificClockResetEnable =
\clk :: Clock dom
clk rst :: Reset dom
rst en :: Enable dom
en f :: HiddenClockResetEnable dom => r
f -> Clock dom -> (HiddenClock dom => r) -> r
forall (dom :: Domain) r.
(KnownDomain dom, WithSpecificDomain dom r) =>
Clock dom -> (HiddenClock dom => r) -> r
withSpecificClock Clock dom
clk (Reset dom -> (HiddenReset dom => r) -> r
forall (dom :: Domain) r.
(KnownDomain dom, WithSpecificDomain dom r) =>
Reset dom -> (HiddenReset dom => r) -> r
withSpecificReset Reset dom
rst (Enable dom -> (HiddenEnable dom => r) -> r
forall (dom :: Domain) r.
(KnownDomain dom, WithSpecificDomain dom r) =>
Enable dom -> (HiddenEnable dom => r) -> r
withSpecificEnable Enable dom
en HiddenEnable dom => r
HiddenClockResetEnable dom => r
f))
{-# INLINE withSpecificClockResetEnable #-}
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 :: Domain) a.
(KnownDomain dom, NFDataX a) =>
Clock dom -> Signal dom a -> Signal dom a
E.dflipflop (forall a. Hidden (HiddenClockName dom) a => a
forall (x :: Domain) 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 dflt :: a
dflt i :: Signal dom a
i =
Clock dom -> Enable dom -> a -> Signal dom a -> Signal dom a
forall (dom :: Domain) 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 :: Domain) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
(forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Domain) 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 dflt :: a
dflt i :: Signal dom (Maybe a)
i =
Clock dom
-> Enable dom -> a -> Signal dom (Maybe a) -> Signal dom a
forall (dom :: Domain) 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 :: Domain) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
(forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Domain) 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 dflt :: a
dflt en :: Signal dom Bool
en i :: Signal dom a
i =
Clock dom
-> Enable dom
-> a
-> Signal dom Bool
-> Signal dom a
-> Signal dom a
forall (dom :: Domain) 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 :: Domain) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
(forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Domain) 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 i :: a
i s :: Signal dom a
s =
Clock dom
-> Reset dom -> Enable dom -> a -> Signal dom a -> Signal dom a
forall (dom :: Domain) 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 :: Domain) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
(forall a. Hidden (HiddenResetName dom) a => a
forall (x :: Domain) a. Hidden x a => a
fromLabel @(HiddenResetName dom))
(forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Domain) 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 initial :: a
initial iM :: Signal dom (Maybe a)
iM =
Clock dom
-> Reset dom
-> Enable dom
-> a
-> Signal dom (Maybe a)
-> Signal dom a
forall (dom :: Domain) 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 :: Domain) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
(forall a. Hidden (HiddenResetName dom) a => a
forall (x :: Domain) a. Hidden x a => a
fromLabel @(HiddenResetName dom))
(forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Domain) 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 initial :: a
initial en :: Signal dom Bool
en i :: Signal dom a
i =
Clock dom
-> Reset dom
-> Enable dom
-> a
-> Signal dom Bool
-> Signal dom a
-> Signal dom a
forall (dom :: Domain) 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 :: Domain) a. Hidden x a => a
fromLabel @(HiddenClockName dom))
(forall a. Hidden (HiddenResetName dom) a => a
forall (x :: Domain) a. Hidden x a => a
fromLabel @(HiddenResetName dom))
(forall a. Hidden (HiddenEnableName dom) a => a
forall (x :: Domain) 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 s :: HiddenClockResetEnable dom => Signal dom a
s =
Signal dom a -> [a]
forall (f :: Type -> Type) a. (Foldable f, NFDataX a) => f a -> [a]
S.sample ((HiddenClockResetEnable dom => Signal dom a)
-> Clock dom -> Reset dom -> Enable dom -> Signal dom a
forall (dom :: Domain) r.
WithSingleDomain dom 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 :: Domain). KnownDomain dom => Clock dom
clockGen Reset dom
forall (dom :: Domain). KnownDomain dom => Reset dom
resetGen Enable dom
forall (dom :: Domain). Enable dom
enableGen)
{-# NOINLINE 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 n :: Int
n s0 :: 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 :: Domain) r.
WithSingleDomain dom 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 :: Domain). KnownDomain dom => Clock dom
clockGen Reset dom
forall (dom :: Domain). KnownDomain dom => Reset dom
resetGen Enable dom
forall (dom :: Domain). Enable dom
enableGen in
Int -> Signal dom a -> [a]
forall (f :: Type -> Type) a.
(Foldable f, NFDataX a) =>
Int -> f a -> [a]
S.sampleN Int
n Signal dom a
s1
{-# NOINLINE 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 nReset :: SNat m
nReset f0 :: 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 :: Domain) r.
WithSingleDomain dom r =>
(HiddenClockResetEnable dom => r)
-> KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r
exposeClockResetEnable HiddenClockResetEnable dom => Signal dom a
f0 Clock dom
forall (dom :: Domain). KnownDomain dom => Clock dom
clockGen (SNat m -> Reset dom
forall (dom :: Domain) (n :: Nat).
(KnownDomain dom, 1 <= n) =>
SNat n -> Reset dom
resetGenN @dom SNat m
nReset) Enable dom
forall (dom :: Domain). 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]
S.sample Signal dom a
f1)
{-# NOINLINE 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 nReset :: SNat m
nReset nSamples :: Int
nSamples f :: 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 :: Domain) 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 s :: HiddenClockResetEnable dom => Signal dom a
s =
Signal dom a -> [a]
forall (f :: Type -> Type) a. Foldable f => f a -> [a]
S.sample_lazy ((HiddenClockResetEnable dom => Signal dom a)
-> Clock dom -> Reset dom -> Enable dom -> Signal dom a
forall (dom :: Domain) r.
WithSingleDomain dom 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 :: Domain). KnownDomain dom => Clock dom
clockGen Reset dom
forall (dom :: Domain). KnownDomain dom => Reset dom
resetGen Enable dom
forall (dom :: Domain). Enable dom
enableGen)
{-# NOINLINE 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 n :: Int
n s :: HiddenClockResetEnable dom => Signal dom a
s =
Int -> Signal dom a -> [a]
forall (f :: Type -> Type) a. Foldable f => Int -> f a -> [a]
S.sampleN_lazy Int
n ((HiddenClockResetEnable dom => Signal dom a)
-> Clock dom -> Reset dom -> Enable dom -> Signal dom a
forall (dom :: Domain) r.
WithSingleDomain dom 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 :: Domain). KnownDomain dom => Clock dom
clockGen Reset dom
forall (dom :: Domain). KnownDomain dom => Reset dom
resetGen Enable dom
forall (dom :: Domain). Enable dom
enableGen)
{-# NOINLINE 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 f :: HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f as :: [a]
as = SNat 1
-> a
-> (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a]
-> [b]
forall (dom :: Domain) 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] -> a
forall a. [a] -> a
head [a]
as) HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f [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 n :: Int
n f :: HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f as :: [a]
as = SNat 1
-> a
-> Int
-> (HiddenClockResetEnable dom => Signal dom a -> Signal dom b)
-> [a]
-> [b]
forall (dom :: Domain) 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] -> a
forall a. [a] -> a
head [a]
as) Int
n HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f [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 n :: SNat m
n resetVal :: a
resetVal f :: HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f as :: [a]
as =
SNat m
-> a
-> (KnownDomain dom =>
Clock dom
-> Reset dom -> Enable dom -> Signal dom a -> Signal dom b)
-> [a]
-> [b]
forall (dom :: Domain) 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]
S.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 :: Domain) r.
WithSingleDomain dom 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 nReset :: SNat m
nReset resetVal :: a
resetVal nSamples :: Int
nSamples f :: HiddenClockResetEnable dom => Signal dom a -> Signal dom b
f as :: [a]
as =
SNat m
-> a
-> Int
-> (KnownDomain dom =>
Clock dom
-> Reset dom -> Enable dom -> Signal dom a -> Signal dom b)
-> [a]
-> [b]
forall (dom :: Domain) 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]
S.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 :: Domain) r.
WithSingleDomain dom 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 f0 :: 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 :: Domain) r.
WithSingleDomain dom 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 :: Domain). KnownDomain dom => Clock dom
clockGen Reset dom
forall (dom :: Domain). KnownDomain dom => Reset dom
resetGen Enable dom
forall (dom :: Domain). Enable dom
enableGen in
[b] -> [b]
forall a. [a] -> [a]
tail ([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 :: Domain) a (dom2 :: Domain) b.
(Signal dom1 a -> Signal dom2 b) -> [a] -> [b]
S.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
{-# NOINLINE 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 f0 :: HiddenClockResetEnable dom => Unbundled dom a -> Unbundled dom b
f0 =
[b] -> [b]
forall a. [a] -> [a]
tail ([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 :: Domain) (dom2 :: Domain).
(Bundle a, Bundle b, NFDataX a, NFDataX b) =>
(Unbundled dom1 a -> Unbundled dom2 b) -> [a] -> [b]
S.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 :: Domain) r.
(KnownDomain dom, WithSpecificDomain dom r) =>
Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom => r)
-> r
withSpecificClockResetEnable
@dom
Clock dom
forall (dom :: Domain). KnownDomain dom => Clock dom
clockGen
Reset dom
forall (dom :: Domain). KnownDomain dom => Reset dom
resetGen
Enable dom
forall (dom :: Domain). 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)
{-# NOINLINE 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 f0 :: HiddenClockResetEnable dom => Unbundled dom a -> Unbundled dom b
f0 =
[b] -> [b]
forall a. [a] -> [a]
tail ([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 :: Domain) (dom2 :: Domain).
(Bundle a, Bundle b) =>
(Unbundled dom1 a -> Unbundled dom2 b) -> [a] -> [b]
S.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 :: Domain) r.
(KnownDomain dom, WithSpecificDomain dom r) =>
Clock dom
-> Reset dom
-> Enable dom
-> (HiddenClockResetEnable dom => r)
-> r
withSpecificClockResetEnable
@dom
Clock dom
forall (dom :: Domain). KnownDomain dom => Clock dom
clockGen
Reset dom
forall (dom :: Domain). KnownDomain dom => Reset dom
resetGen
Enable dom
forall (dom :: Domain). 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)
{-# NOINLINE simulateB_lazy #-}
dup1 :: [a] -> [a]
dup1 :: [a] -> [a]
dup1 (x :: a
x:xs :: [a]
xs) = a
xa -> [a] -> [a]
forall a. a -> [a] -> [a]
:a
xa -> [a] -> [a]
forall a. a -> [a] -> [a]
:[a]
xs
dup1 _ = [Char] -> [a]
forall a. HasCallStack => [Char] -> a
error "empty list"
testFor
:: KnownDomain dom
=> Int
-> (HiddenClockResetEnable dom => Signal dom Bool)
-> Property
testFor :: Int -> (HiddenClockResetEnable dom => Signal dom Bool) -> Property
testFor n :: Int
n s :: 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 :: Domain) a.
(KnownDomain dom, NFDataX a) =>
Int -> (HiddenClockResetEnable dom => Signal dom a) -> [a]
Clash.Signal.sampleN Int
n HiddenClockResetEnable dom => Signal dom Bool
s))
#ifdef CLASH_MULTIPLE_HIDDEN
unsafeSynchronizer
:: forall dom1 dom2 a
. ( HiddenClock dom1
, HiddenClock dom2 )
=> Signal dom1 a
-> Signal dom2 a
unsafeSynchronizer :: Signal dom1 a -> Signal dom2 a
unsafeSynchronizer =
(Clock dom2 -> Signal dom1 a -> Signal dom2 a)
-> Signal dom1 a -> Signal dom2 a
forall (dom :: Domain) r. HiddenClock dom => (Clock dom -> r) -> r
hideClock ((Clock dom1 -> Clock dom2 -> Signal dom1 a -> Signal dom2 a)
-> Clock dom2 -> Signal dom1 a -> Signal dom2 a
forall (dom :: Domain) r. HiddenClock dom => (Clock dom -> r) -> r
hideClock Clock dom1 -> Clock dom2 -> Signal dom1 a -> Signal dom2 a
forall (dom1 :: Domain) (dom2 :: Domain) a.
(KnownDomain dom1, KnownDomain dom2) =>
Clock dom1 -> Clock dom2 -> Signal dom1 a -> Signal dom2 a
S.unsafeSynchronizer)
#endif
holdReset
:: forall dom m
. HiddenClockResetEnable dom
=> SNat m
-> Reset dom
holdReset :: SNat m -> Reset dom
holdReset m :: SNat m
m =
(KnownDomain dom =>
Clock dom -> Reset dom -> Enable dom -> Reset dom)
-> Reset dom
forall (dom :: Domain) r.
HiddenClockResetEnable dom =>
(KnownDomain dom => Clock dom -> Reset dom -> Enable dom -> r) -> r
hideClockResetEnable (\clk :: Clock dom
clk rst :: Reset dom
rst en :: Enable dom
en -> Clock dom -> Enable dom -> SNat m -> Reset dom -> Reset dom
forall (dom :: Domain) (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 :: Domain) r. HiddenReset dom => (Reset dom -> r) -> r
hideReset Reset dom -> a -> [a] -> Signal dom a
forall (dom :: Domain) a.
(KnownDomain dom, NFDataX a) =>
Reset dom -> a -> [a] -> Signal dom a
E.fromListWithReset
{-# INLINE fromListWithReset #-}
#ifdef CLASH_MULTIPLE_HIDDEN
convertReset
:: forall domA domB
. ( HiddenClock domA
, HiddenClock domB
)
=> Reset domA
-> Reset domB
convertReset :: Reset domA -> Reset domB
convertReset =
Clock domA -> Clock domB -> Reset domA -> Reset domB
forall (domA :: Domain) (domB :: Domain).
(KnownDomain domA, KnownDomain domB) =>
Clock domA -> Clock domB -> Reset domA -> Reset domB
E.convertReset Clock domA
forall (dom :: Domain). HiddenClock dom => Clock dom
hasClock Clock domB
forall (dom :: Domain). HiddenClock dom => Clock dom
hasClock
#endif