{-# LANGUAGE CPP #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE Unsafe #-}
{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}
{-# OPTIONS_HADDOCK show-extensions, not-home #-}
module Clash.Explicit.Prelude
(
mealy
, mealyS
, mealyB
, mealySB
, moore
, mooreB
, registerB
, dualFlipFlopSynchronizer
, asyncFIFOSynchronizer
, asyncRom
, asyncRomPow2
, rom
, romPow2
, asyncRomBlob
, asyncRomBlobPow2
, romBlob
, romBlobPow2
, asyncRomFile
, asyncRomFilePow2
, romFile
, romFilePow2
, asyncRam
, asyncRamPow2
, blockRam
, blockRamPow2
, blockRamU
, blockRam1
, ResetStrategy(..)
, blockRamBlob
, blockRamBlobPow2
, MemBlob
, createMemBlob
, memBlobTH
, unpackMemBlob
, blockRamFile
, blockRamFilePow2
, readNew
, trueDualPortBlockRam
, RamOp(..)
, window
, windowD
, isRising
, isFalling
, riseEvery
, oscillate
, assert
, stimuliGenerator
, outputVerifier'
, traceSignal1
, traceVecSignal1
, traceSignal
, traceVecSignal
, dumpVCD
, module Clash.Explicit.Reset
, module Clash.Explicit.Signal
, module Clash.Explicit.Signal.Delayed
, module Clash.Sized.BitVector
, 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
#if MIN_VERSION_base(4,18,0)
hiding (SNat, SSymbol, fromSNat)
#endif
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.Blob
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.Blob
import Clash.Explicit.ROM.File
import Clash.Explicit.Prelude.Safe
import Clash.Explicit.Reset
import Clash.Explicit.Signal
import Clash.Explicit.Signal.Delayed
import Clash.Explicit.Testbench
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 hiding (fromList, unsafeFromList)
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 clk rst en x = res
where
res = x :> prev
prev = case natVal (asNatProxy prev) of
0 -> repeat def
_ -> let next = x +>> prev
in registerB clk rst en (repeat def) 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 clk rst en x =
let prev = registerB clk rst en (repeat def) next
next = x +>> prev
in prev
{-# INLINABLE windowD #-}