{-# LANGUAGE TypeFamilies #-}
module Clash.Prelude.Synchronizer
(
dualFlipFlopSynchronizer
, asyncFIFOSynchronizer
) where
import qualified Clash.Explicit.Synchronizer as E
import Clash.Promoted.Nat (SNat)
import Clash.Signal
(HiddenClockResetEnable, HiddenClock, Signal, hasClock, hasReset, hasEnable)
import Clash.XException (NFDataX)
import GHC.TypeLits (type (<=))
dualFlipFlopSynchronizer
:: ( NFDataX a
, HiddenClock dom1
, HiddenClockResetEnable dom2
)
=> a
-> Signal dom1 a
-> Signal dom2 a
dualFlipFlopSynchronizer :: a -> Signal dom1 a -> Signal dom2 a
dualFlipFlopSynchronizer =
Clock dom1
-> Clock dom2
-> Reset dom2
-> Enable dom2
-> a
-> Signal dom1 a
-> Signal dom2 a
forall a (dom1 :: Domain) (dom2 :: Domain).
(NFDataX a, KnownDomain dom1, KnownDomain dom2) =>
Clock dom1
-> Clock dom2
-> Reset dom2
-> Enable dom2
-> a
-> Signal dom1 a
-> Signal dom2 a
E.dualFlipFlopSynchronizer Clock dom1
forall (dom :: Domain). HiddenClock dom => Clock dom
hasClock Clock dom2
forall (dom :: Domain). HiddenClock dom => Clock dom
hasClock Reset dom2
forall (dom :: Domain). HiddenReset dom => Reset dom
hasReset Enable dom2
forall (dom :: Domain). HiddenEnable dom => Enable dom
hasEnable
asyncFIFOSynchronizer
:: ( HiddenClockResetEnable rdom
, HiddenClockResetEnable wdom
, 2 <= addrSize )
=> SNat addrSize
-> Signal rdom Bool
-> Signal wdom (Maybe a)
-> (Signal rdom a, Signal rdom Bool, Signal wdom Bool)
asyncFIFOSynchronizer :: SNat addrSize
-> Signal rdom Bool
-> Signal wdom (Maybe a)
-> (Signal rdom a, Signal rdom Bool, Signal wdom Bool)
asyncFIFOSynchronizer addrSize :: SNat addrSize
addrSize =
SNat addrSize
-> Clock wdom
-> Clock rdom
-> Reset wdom
-> Reset rdom
-> Enable wdom
-> Enable rdom
-> Signal rdom Bool
-> Signal wdom (Maybe a)
-> (Signal rdom a, Signal rdom Bool, Signal wdom Bool)
forall (wdom :: Domain) (rdom :: Domain) (addrSize :: Nat) a.
(KnownDomain wdom, KnownDomain rdom, 2 <= addrSize) =>
SNat addrSize
-> Clock wdom
-> Clock rdom
-> Reset wdom
-> Reset rdom
-> Enable wdom
-> Enable rdom
-> Signal rdom Bool
-> Signal wdom (Maybe a)
-> (Signal rdom a, Signal rdom Bool, Signal wdom Bool)
E.asyncFIFOSynchronizer
SNat addrSize
addrSize
Clock wdom
forall (dom :: Domain). HiddenClock dom => Clock dom
hasClock
Clock rdom
forall (dom :: Domain). HiddenClock dom => Clock dom
hasClock
Reset wdom
forall (dom :: Domain). HiddenReset dom => Reset dom
hasReset
Reset rdom
forall (dom :: Domain). HiddenReset dom => Reset dom
hasReset
Enable wdom
forall (dom :: Domain). HiddenEnable dom => Enable dom
hasEnable
Enable rdom
forall (dom :: Domain). HiddenEnable dom => Enable dom
hasEnable