Copyright | (C) 2013-2016 University of Twente 2021 QBayLogic B.V. |
---|---|

License | BSD2 (see the file LICENSE) |

Maintainer | QBayLogic B.V. <devops@qbaylogic.com> |

Safe Haskell | Safe-Inferred |

Language | Haskell2010 |

Deprecated: Use Clash.Class.BitPack instead. This module will be removed in Clash 1.8.

## Synopsis

- (!) :: (BitPack a, Enum i) => a -> i -> Bit
- slice :: (BitPack a, BitSize a ~ ((m + 1) + i)) => SNat m -> SNat n -> a -> BitVector ((m + 1) - n)
- split :: (BitPack a, BitSize a ~ (m + n), KnownNat n) => a -> (BitVector m, BitVector n)
- replaceBit :: (BitPack a, Enum i) => i -> Bit -> a -> a
- setSlice :: (BitPack a, BitSize a ~ ((m + 1) + i)) => SNat m -> SNat n -> BitVector ((m + 1) - n) -> a -> a
- msb :: BitPack a => a -> Bit
- lsb :: BitPack a => a -> Bit

# Documentation

(!) :: (BitPack a, Enum i) => a -> i -> Bit Source #

Get the bit at the specified bit index.

**NB:** Bit indices are **DESCENDING**.

`>>>`

0b00_0111`pack (7 :: Unsigned 6)`

`>>>`

1`(7 :: Unsigned 6) ! 1`

`>>>`

0`(7 :: Unsigned 6) ! 5`

`>>>`

*** Exception: (!): 6 is out of range [5..0] ...`(7 :: Unsigned 6) ! 6`

slice :: (BitPack a, BitSize a ~ ((m + 1) + i)) => SNat m -> SNat n -> a -> BitVector ((m + 1) - n) Source #

Get a slice between bit index `m`

and and bit index `n`

.

**NB:** Bit indices are **DESCENDING**.

`>>>`

0b00_0111`pack (7 :: Unsigned 6)`

`>>>`

0b001`slice d4 d2 (7 :: Unsigned 6)`

`>>>`

<interactive>:... • Couldn't match type ‘7 + i0’ with ‘6’ arising from a use of ‘slice’ The type variable ‘i0’ is ambiguous • In the expression: slice d6 d4 (7 :: Unsigned 6) In an equation for ‘it’: it = slice d6 d4 (7 :: Unsigned 6)`slice d6 d4 (7 :: Unsigned 6)`

split :: (BitPack a, BitSize a ~ (m + n), KnownNat n) => a -> (BitVector m, BitVector n) Source #

Split a value of a bit size `m + n`

into a tuple of values with size `m`

and size `n`

.

`>>>`

0b00_0111`pack (7 :: Unsigned 6)`

`>>>`

(0b00,0b0111)`split (7 :: Unsigned 6) :: (BitVector 2, BitVector 4)`

replaceBit :: (BitPack a, Enum i) => i -> Bit -> a -> a Source #

Set the bit at the specified index

**NB:** Bit indices are **DESCENDING**.

`>>>`

0b11_1011`pack (-5 :: Signed 6)`

`>>>`

-21`replaceBit 4 0 (-5 :: Signed 6)`

`>>>`

0b10_1011`pack (-21 :: Signed 6)`

`>>>`

27`replaceBit 5 0 (-5 :: Signed 6)`

`>>>`

0b01_1011`pack (27 :: Signed 6)`

`>>>`

*** Exception: replaceBit: 6 is out of range [5..0] ...`replaceBit 6 0 (-5 :: Signed 6)`

setSlice :: (BitPack a, BitSize a ~ ((m + 1) + i)) => SNat m -> SNat n -> BitVector ((m + 1) - n) -> a -> a Source #

Set the bits between bit index `m`

and bit index `n`

.

**NB:** Bit indices are **DESCENDING**.

`>>>`

0b11_1011`pack (-5 :: Signed 6)`

`>>>`

-29`setSlice d4 d3 0 (-5 :: Signed 6)`

`>>>`

0b10_0011`pack (-29 :: Signed 6)`

`>>>`

<interactive>:... • Couldn't match type ‘7 + i0’ with ‘6’ arising from a use of ‘setSlice’ The type variable ‘i0’ is ambiguous • In the expression: setSlice d6 d5 0 (- 5 :: Signed 6) In an equation for ‘it’: it = setSlice d6 d5 0 (- 5 :: Signed 6)`setSlice d6 d5 0 (-5 :: Signed 6)`