{-# LANGUAGE Trustworthy #-}
{-# OPTIONS_HADDOCK show-extensions #-}
module Clash.Sized.BitVector
(
Bit
, high
, low
, BitVector
, size#
, maxIndex#
, bLit
, hLit
, oLit
, (++#)
, (+>>.)
, (.<<+)
, bitPattern
)
where
import Clash.Sized.Internal.BitVector
import Clash.Promoted.Nat (natToNum)
import Data.Bits (shiftL, shiftR)
import GHC.TypeNats (KnownNat)
infixr 4 +>>.
(+>>.) :: forall n. KnownNat n => Bit -> BitVector n -> BitVector n
Bit
b +>>. :: Bit -> BitVector n -> BitVector n
+>>. BitVector n
bv = BitVector n -> Int -> Bit -> BitVector n
forall (n :: Nat).
KnownNat n =>
BitVector n -> Int -> Bit -> BitVector n
replaceBit# (BitVector n -> Int -> BitVector n
forall a. Bits a => a -> Int -> a
shiftR BitVector n
bv Int
1) (forall a. (Num a, KnownNat n) => a
forall (n :: Nat) a. (Num a, KnownNat n) => a
natToNum @n Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) Bit
b
infixr 4 .<<+
(.<<+) :: forall n. KnownNat n => BitVector n -> Bit -> BitVector n
BitVector n
bv .<<+ :: BitVector n -> Bit -> BitVector n
.<<+ Bit
b = BitVector n -> Int -> Bit -> BitVector n
forall (n :: Nat).
KnownNat n =>
BitVector n -> Int -> Bit -> BitVector n
replaceBit# (BitVector n -> Int -> BitVector n
forall a. Bits a => a -> Int -> a
shiftL BitVector n
bv Int
1) Int
0 Bit
b