clash-shockwaves
Copyright(C) 2025-2026 QBayLogic B.V.
LicenseBSD2 (see the file LICENSE)
MaintainerQBayLogic B.V. <devops@qbaylogic.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Shockwaves.BitList

Description

Various functions for dealing with dynamically sized binary representations of data.

Synopsis

Documentation

data BitList Source #

A type like BitVector, but with a dynamic size. It is meant to make type-independent handling of binary representations possible.

Instances

Instances details
ToJSON BitList Source # 
Instance details

Defined in Clash.Shockwaves.Internal.BitList

ToJSONKey BitList Source # 
Instance details

Defined in Clash.Shockwaves.Internal.BitList

Semigroup BitList Source # 
Instance details

Defined in Clash.Shockwaves.Internal.BitList

Bits BitList Source # 
Instance details

Defined in Clash.Shockwaves.Internal.BitList

IsString BitList Source #

When converting from a string, `0` and `1` are interpreted as bits, and `_` is treated as a spacer (is ignored). Any other characters are interpreted as undefined bits.

Instance details

Defined in Clash.Shockwaves.Internal.BitList

Methods

fromString :: String -> BitList #

Show BitList Source # 
Instance details

Defined in Clash.Shockwaves.Internal.BitList

Eq BitList Source # 
Instance details

Defined in Clash.Shockwaves.Internal.BitList

Methods

(==) :: BitList -> BitList -> Bool #

(/=) :: BitList -> BitList -> Bool #

Ord BitList Source # 
Instance details

Defined in Clash.Shockwaves.Internal.BitList

Modifying BitLists

take :: Int -> BitList -> BitList Source #

Take only the n most significant bits.

drop :: Int -> BitList -> BitList Source #

Discard the n most significant bits.

split :: Int -> BitList -> (BitList, BitList) Source #

Split a BitList into the n most significant bits, and the rest of the bits

concat :: BitList -> BitList -> BitList Source #

Concatenate two BitLists.

slice :: (Int, Int) -> BitList -> BitList Source #

Take a range (exclusive) of a BitList.

length :: BitList -> Int Source #

Return the length of the BitList.

Using BitList with BitVector

bvToBl :: forall (n :: Nat). KnownNat n => BitVector n -> BitList Source #

Convert a BitVector into a BitList.

blToBv :: forall (n :: Nat). KnownNat n => BitList -> BitVector n Source #

Convert a BitList into a BitVector, provided that is has the right number of bits

pack :: BitPack a => a -> BitList Source #

Pack a value into a BitList.

unpack :: BitPack a => BitList -> a Source #

Unpack a value from a BitList.

Using BitList as a number

toInteger :: BitList -> Maybe Integer Source #

Convert a BitList into an Integer if it has no undefined bits.

Rest