Copyright | © Edward Kmett 2010-2015 © Eric Mertens 2014 Johan Kiviniemi 2013 |
---|---|
License | BSD3 |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Bit1
.. Bit8
represent fixed length bit vectors.
The most significant bit comes first.
Bit1
and Bit2
have modular arithmetic
(the result has the same width as the arguments, overflow is ignored).
Bits
is an arbitrary length natural number type.
The least significant bit comes first.
Bits
has full arithmetic
(the result has large enough width so that there is no overflow).
Synopsis
- newtype Bit1 = Bit1 Bit
- data Bit2 = Bit2 !Bit !Bit
- data Bit3 = Bit3 !Bit !Bit !Bit
- data Bit4 = Bit4 !Bit !Bit !Bit !Bit
- data Bit5 = Bit5 !Bit !Bit !Bit !Bit !Bit
- data Bit6 = Bit6 !Bit !Bit !Bit !Bit !Bit !Bit
- data Bit7 = Bit7 !Bit !Bit !Bit !Bit !Bit !Bit !Bit
- data Bit8 = Bit8 !Bit !Bit !Bit !Bit !Bit !Bit !Bit !Bit
- newtype Bits = Bits [Bit]
- class HasBits a where
- isEven :: HasBits b => b -> Bit
- isOdd :: HasBits b => b -> Bit
- sumBit :: Foldable t => t Bit -> Bits
- sumBits :: (Foldable t, HasBits a) => t a -> Bits
- fullAdder :: Bit -> Bit -> Bit -> (Bit, Bit)
- halfAdder :: Bit -> Bit -> (Bit, Bit)
Fixed length bit vectors
Instances
Generic Bit1 Source # | |
Num Bit1 Source # | This instance provides modular arithmetic (overflow is ignored). |
Show Bit1 Source # | |
Boolean Bit1 Source # | |
Defined in Ersatz.Bits (&&) :: Bit1 -> Bit1 -> Bit1 Source # (||) :: Bit1 -> Bit1 -> Bit1 Source # (==>) :: Bit1 -> Bit1 -> Bit1 Source # and :: Foldable t => t Bit1 -> Bit1 Source # or :: Foldable t => t Bit1 -> Bit1 Source # nand :: Foldable t => t Bit1 -> Bit1 Source # nor :: Foldable t => t Bit1 -> Bit1 Source # all :: Foldable t => (a -> Bit1) -> t a -> Bit1 Source # any :: Foldable t => (a -> Bit1) -> t a -> Bit1 Source # | |
HasBits Bit1 Source # | |
Codec Bit1 Source # | |
Equatable Bit1 Source # | |
Orderable Bit1 Source # | |
Variable Bit1 Source # | |
type Rep Bit1 Source # | |
Defined in Ersatz.Bits | |
type Decoded Bit1 Source # | |
Defined in Ersatz.Bits |
Instances
Instances
Instances
Instances
Instances
Instances
Instances
Variable length bit vectors
A container of Bit
s that is suitable for comparisons and arithmetic. Bits are stored
with least significant bit first to enable phantom false
values
to be truncated.
Instances
Num Bits Source # | This instance provides full arithmetic. The result has large enough width so that there is no overflow. Subtraction is modified: Width of
|
Show Bits Source # | |
HasBits Bits Source # | |
Codec Bits Source # | |
Equatable Bits Source # | |
Orderable Bits Source # | |
type Decoded Bits Source # | |
Defined in Ersatz.Bits |
class HasBits a where Source #
HasBits
provides the bits
method for embedding
fixed with numeric encoding types into the arbitrary width
Bits
type.
sumBits :: (Foldable t, HasBits a) => t a -> Bits Source #
Compute the sum of a source of Bits
values.
Adders
Compute the sum and carry bit from adding three bits.