{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE Unsafe #-}
{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}
{-# OPTIONS_HADDOCK show-extensions, not-home #-}
module Clash.Explicit.Prelude
(
mealy
, mealyB
, moore
, mooreB
, registerB
, dualFlipFlopSynchronizer
, asyncFIFOSynchronizer
, asyncRom
, asyncRomPow2
, rom
, romPow2
, asyncRomFile
, asyncRomFilePow2
, romFile
, romFilePow2
, asyncRam
, asyncRamPow2
, blockRam
, blockRamPow2
, blockRamU
, blockRam1
, ResetStrategy(..)
, blockRamFile
, blockRamFilePow2
, readNew
, window
, windowD
, isRising
, isFalling
, riseEvery
, oscillate
, assert
, stimuliGenerator
, outputVerifier'
, traceSignal1
, traceVecSignal1
, traceSignal
, traceVecSignal
, dumpVCD
, module Clash.Explicit.Signal
, module Clash.Explicit.Signal.Delayed
, module Clash.Prelude.DataFlow
, module Clash.Sized.BitVector
, module Clash.Prelude.BitIndex
, module Clash.Prelude.BitReduction
, module Clash.Sized.Signed
, module Clash.Sized.Unsigned
, module Clash.Sized.Index
, module Clash.Sized.Fixed
, module Clash.Sized.Vector
, module Clash.Sized.RTree
, module Clash.Annotations.TopEntity
, Generic
, Generic1
, module GHC.TypeLits
, module GHC.TypeLits.Extra
, module Clash.Promoted.Nat
, module Clash.Promoted.Nat.Literals
, module Clash.Promoted.Nat.TH
, module Clash.Promoted.Symbol
, Lift (..)
, module Clash.Class.AutoReg
, module Clash.Class.BitPack
, module Clash.Class.Exp
, module Clash.Class.Num
, module Clash.Class.Resize
, module Control.Applicative
, module Data.Bits
, module Data.Default.Class
, module Clash.XException
, module Clash.NamedTypes
, module Clash.Magic
, module Clash.HaskellPrelude
)
where
import Control.Applicative
import Data.Bits
import Data.Default.Class
import GHC.TypeLits
import GHC.TypeLits.Extra
import Language.Haskell.TH.Syntax (Lift(..))
import Clash.HaskellPrelude
import Clash.Annotations.TopEntity
import Clash.Class.AutoReg
import Clash.Class.BitPack
import Clash.Class.Exp
import Clash.Class.Num
import Clash.Class.Resize
import Clash.Magic
import Clash.NamedTypes
import Clash.Explicit.BlockRam
import Clash.Explicit.BlockRam.File
import Clash.Explicit.Mealy
import Clash.Explicit.Moore
import Clash.Explicit.RAM
import Clash.Explicit.ROM
import Clash.Explicit.ROM.File
import Clash.Explicit.Prelude.Safe
import Clash.Explicit.Signal
import Clash.Explicit.Signal.Delayed
import Clash.Explicit.Testbench
import Clash.Prelude.BitIndex
import Clash.Prelude.BitReduction
import Clash.Prelude.DataFlow
import Clash.Prelude.ROM.File (asyncRomFile, asyncRomFilePow2)
import Clash.Promoted.Nat
import Clash.Promoted.Nat.TH
import Clash.Promoted.Nat.Literals
import Clash.Promoted.Symbol
import Clash.Signal.Trace
import Clash.Sized.BitVector
import Clash.Sized.Fixed
import Clash.Sized.Index
import Clash.Sized.RTree
import Clash.Sized.Signed
import Clash.Sized.Unsigned
import Clash.Sized.Vector
import Clash.XException
window
:: ( KnownNat n
, KnownDomain dom
, NFDataX a
, Default a
)
=> Clock dom
-> Reset dom
-> Enable dom
-> Signal dom a
-> Vec (n + 1) (Signal dom a)
window :: Clock dom
-> Reset dom
-> Enable dom
-> Signal dom a
-> Vec (n + 1) (Signal dom a)
window Clock dom
clk Reset dom
rst Enable dom
en Signal dom a
x = Vec (n + 1) (Signal dom a)
res
where
res :: Vec (n + 1) (Signal dom a)
res = Signal dom a
x Signal dom a -> Vec n (Signal dom a) -> Vec (n + 1) (Signal dom a)
forall a (n :: Nat). a -> Vec n a -> Vec (n + 1) a
:> Vec n (Signal dom a)
prev
prev :: Vec n (Signal dom a)
prev = case Proxy n -> Integer
forall (n :: Nat) (proxy :: Nat -> Type).
KnownNat n =>
proxy n -> Integer
natVal (Vec n (Signal dom a) -> Proxy n
forall (n :: Nat) a. Vec n a -> Proxy n
asNatProxy Vec n (Signal dom a)
prev) of
Integer
0 -> Signal dom a -> Vec n (Signal dom a)
forall (n :: Nat) a. KnownNat n => a -> Vec n a
repeat Signal dom a
forall a. Default a => a
def
Integer
_ -> let next :: Vec n (Signal dom a)
next = Signal dom a
x Signal dom a -> Vec n (Signal dom a) -> Vec n (Signal dom a)
forall (n :: Nat) a. KnownNat n => a -> Vec n a -> Vec n a
+>> Vec n (Signal dom a)
prev
in Clock dom
-> Reset dom
-> Enable dom
-> Vec n a
-> Unbundled dom (Vec n a)
-> Unbundled dom (Vec n a)
forall (dom :: Domain) a.
(KnownDomain dom, NFDataX a, Bundle a) =>
Clock dom
-> Reset dom
-> Enable dom
-> a
-> Unbundled dom a
-> Unbundled dom a
registerB Clock dom
clk Reset dom
rst Enable dom
en (a -> Vec n a
forall (n :: Nat) a. KnownNat n => a -> Vec n a
repeat a
forall a. Default a => a
def) Vec n (Signal dom a)
Unbundled dom (Vec n a)
next
{-# INLINABLE window #-}
windowD
:: ( KnownNat n
, NFDataX a
, Default a
, KnownDomain dom )
=> Clock dom
-> Reset dom
-> Enable dom
-> Signal dom a
-> Vec (n + 1) (Signal dom a)
windowD :: Clock dom
-> Reset dom
-> Enable dom
-> Signal dom a
-> Vec (n + 1) (Signal dom a)
windowD Clock dom
clk Reset dom
rst Enable dom
en Signal dom a
x =
let prev :: Vec (n + 1) (Signal dom a)
prev = Clock dom
-> Reset dom
-> Enable dom
-> Vec (n + 1) a
-> Unbundled dom (Vec (n + 1) a)
-> Unbundled dom (Vec (n + 1) a)
forall (dom :: Domain) a.
(KnownDomain dom, NFDataX a, Bundle a) =>
Clock dom
-> Reset dom
-> Enable dom
-> a
-> Unbundled dom a
-> Unbundled dom a
registerB Clock dom
clk Reset dom
rst Enable dom
en (a -> Vec (n + 1) a
forall (n :: Nat) a. KnownNat n => a -> Vec n a
repeat a
forall a. Default a => a
def) Vec (n + 1) (Signal dom a)
Unbundled dom (Vec (n + 1) a)
next
next :: Vec (n + 1) (Signal dom a)
next = Signal dom a
x Signal dom a
-> Vec (n + 1) (Signal dom a) -> Vec (n + 1) (Signal dom a)
forall (n :: Nat) a. KnownNat n => a -> Vec n a -> Vec n a
+>> Vec (n + 1) (Signal dom a)
prev
in Vec (n + 1) (Signal dom a)
prev
{-# INLINABLE windowD #-}