Copyright | (C) 2013-2016 University of Twente 2016 Myrtle Software Ltd 2021-2022 QBayLogic B.V. |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | QBayLogic B.V. <devops@qbaylogic.com> |
Safe Haskell | Unsafe |
Language | Haskell2010 |
Extensions |
|
Synopsis
- newtype Unsigned (n :: Nat) = U {}
- size# :: KnownNat n => Unsigned n -> Int
- pack# :: Unsigned n -> BitVector n
- unpack# :: KnownNat n => BitVector n -> Unsigned n
- eq# :: Unsigned n -> Unsigned n -> Bool
- neq# :: Unsigned n -> Unsigned n -> Bool
- lt# :: Unsigned n -> Unsigned n -> Bool
- ge# :: Unsigned n -> Unsigned n -> Bool
- gt# :: Unsigned n -> Unsigned n -> Bool
- le# :: Unsigned n -> Unsigned n -> Bool
- toEnum# :: forall n. KnownNat n => Int -> Unsigned n
- fromEnum# :: forall n. KnownNat n => Unsigned n -> Int
- enumFrom# :: forall n. KnownNat n => Unsigned n -> [Unsigned n]
- enumFromThen# :: forall n. KnownNat n => Unsigned n -> Unsigned n -> [Unsigned n]
- enumFromTo# :: forall n. KnownNat n => Unsigned n -> Unsigned n -> [Unsigned n]
- enumFromThenTo# :: forall n. KnownNat n => Unsigned n -> Unsigned n -> Unsigned n -> [Unsigned n]
- minBound# :: Unsigned n
- maxBound# :: forall n. KnownNat n => Unsigned n
- (+#) :: forall n. KnownNat n => Unsigned n -> Unsigned n -> Unsigned n
- (-#) :: forall n. KnownNat n => Unsigned n -> Unsigned n -> Unsigned n
- (*#) :: forall n. KnownNat n => Unsigned n -> Unsigned n -> Unsigned n
- negate# :: forall n. KnownNat n => Unsigned n -> Unsigned n
- fromInteger# :: forall n. KnownNat n => Integer -> Unsigned n
- plus# :: Unsigned m -> Unsigned n -> Unsigned (Max m n + 1)
- minus# :: forall m n. (KnownNat m, KnownNat n) => Unsigned m -> Unsigned n -> Unsigned (Max m n + 1)
- times# :: Unsigned m -> Unsigned n -> Unsigned (m + n)
- quot# :: Unsigned n -> Unsigned n -> Unsigned n
- rem# :: Unsigned n -> Unsigned n -> Unsigned n
- toInteger# :: Unsigned n -> Integer
- and# :: Unsigned n -> Unsigned n -> Unsigned n
- or# :: Unsigned n -> Unsigned n -> Unsigned n
- xor# :: Unsigned n -> Unsigned n -> Unsigned n
- complement# :: forall n. KnownNat n => Unsigned n -> Unsigned n
- shiftL# :: forall n. KnownNat n => Unsigned n -> Int -> Unsigned n
- shiftR# :: forall n. KnownNat n => Unsigned n -> Int -> Unsigned n
- rotateL# :: forall n. KnownNat n => Unsigned n -> Int -> Unsigned n
- rotateR# :: forall n. KnownNat n => Unsigned n -> Int -> Unsigned n
- resize# :: forall n m. KnownNat m => Unsigned n -> Unsigned m
- unsignedToWord :: Unsigned 64 -> Word
- unsigned8toWord8 :: Unsigned 8 -> Word8
- unsigned16toWord16 :: Unsigned 16 -> Word16
- unsigned32toWord32 :: Unsigned 32 -> Word32
Datatypes
newtype Unsigned (n :: Nat) Source #
Arbitrary-width unsigned integer represented by n
bits
Given n
bits, an Unsigned
n
number has a range of: [0 .. 2^n
-1]
NB: The Num
operators perform wrap-around
on overflow. If you want
saturation on overflow, check out the SaturatingNum
class.
>>>
maxBound :: Unsigned 3
7>>>
minBound :: Unsigned 3
0>>>
read (show (maxBound :: Unsigned 3)) :: Unsigned 3
7>>>
1 + 2 :: Unsigned 3
3>>>
2 + 6 :: Unsigned 3
0>>>
1 - 3 :: Unsigned 3
6>>>
2 * 3 :: Unsigned 3
6>>>
2 * 4 :: Unsigned 3
0>>>
(2 :: Unsigned 3) `mul` (4 :: Unsigned 3) :: Unsigned 6
8>>>
(2 :: Unsigned 3) `add` (6 :: Unsigned 3) :: Unsigned 4
8>>>
satAdd SatSymmetric 2 6 :: Unsigned 3
7>>>
satSub SatSymmetric 2 3 :: Unsigned 3
0
Unsigned has the type role
>>>
:i Unsigned
type role Unsigned nominal ...
as it is not safe to coerce between different width Unsigned. To change the
width, use the functions in the Resize
class.
U | The constructor, |
Instances
Accessors
Length information
Type classes
BitPack
Eq
Ord
Enum
Enum (not synthesizable)
enumFromThenTo# :: forall n. KnownNat n => Unsigned n -> Unsigned n -> Unsigned n -> [Unsigned n] Source #
Bounded
Num
ExtendingNum
minus# :: forall m n. (KnownNat m, KnownNat n) => Unsigned m -> Unsigned n -> Unsigned (Max m n + 1) Source #
Integral
toInteger# :: Unsigned n -> Integer Source #
Bits
Resize
Conversions
unsignedToWord :: Unsigned 64 -> Word Source #
unsigned8toWord8 :: Unsigned 8 -> Word8 Source #
unsigned16toWord16 :: Unsigned 16 -> Word16 Source #
unsigned32toWord32 :: Unsigned 32 -> Word32 Source #