{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE Trustworthy #-}
{-# OPTIONS_HADDOCK show-extensions #-}
module Clash.Prelude.BitReduction where
import GHC.TypeLits (KnownNat)
import Clash.Class.BitPack (BitPack (..))
import Clash.Sized.Internal.BitVector (Bit, reduceAnd#, reduceOr#, reduceXor#)
{-# INLINE reduceAnd #-}
reduceAnd :: (BitPack a, KnownNat (BitSize a)) => a -> Bit
reduceAnd :: a -> Bit
reduceAnd v :: a
v = BitVector (BitSize a) -> Bit
forall (n :: Nat). KnownNat n => BitVector n -> Bit
reduceAnd# (a -> BitVector (BitSize a)
forall a. BitPack a => a -> BitVector (BitSize a)
pack a
v)
{-# INLINE reduceOr #-}
reduceOr :: (BitPack a, KnownNat (BitSize a)) => a -> Bit
reduceOr :: a -> Bit
reduceOr v :: a
v = BitVector (BitSize a) -> Bit
forall (n :: Nat). KnownNat n => BitVector n -> Bit
reduceOr# (a -> BitVector (BitSize a)
forall a. BitPack a => a -> BitVector (BitSize a)
pack a
v)
{-# INLINE reduceXor #-}
reduceXor :: (BitPack a, KnownNat (BitSize a)) => a -> Bit
reduceXor :: a -> Bit
reduceXor v :: a
v = BitVector (BitSize a) -> Bit
forall (n :: Nat). KnownNat n => BitVector n -> Bit
reduceXor# (a -> BitVector (BitSize a)
forall a. BitPack a => a -> BitVector (BitSize a)
pack a
v)