{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE Safe #-}
{-# OPTIONS_HADDOCK show-extensions #-}
module Clash.Prelude.RAM
(
asyncRam
, asyncRamPow2
)
where
import GHC.TypeLits (KnownNat)
import GHC.Stack (HasCallStack, withFrozenCallStack)
import qualified Clash.Explicit.RAM as E
import Clash.Promoted.Nat (SNat)
import Clash.Signal
import Clash.Sized.Unsigned (Unsigned)
asyncRam
:: (Enum addr, HiddenClock domain gated, HasCallStack)
=> SNat n
-> Signal domain addr
-> Signal domain (Maybe (addr, a))
-> Signal domain a
asyncRam = \sz rd wrM -> withFrozenCallStack
(hideClock (\clk -> E.asyncRam clk clk sz rd wrM))
{-# INLINE asyncRam #-}
asyncRamPow2
:: (KnownNat n, HiddenClock domain gated, HasCallStack)
=> Signal domain (Unsigned n)
-> Signal domain (Maybe (Unsigned n, a))
-> Signal domain a
asyncRamPow2 = \rd wrM -> withFrozenCallStack
(hideClock (\clk -> E.asyncRamPow2 clk clk rd wrM))
{-# INLINE asyncRamPow2 #-}