clash-prelude-0.10.5: CAES Language for Synchronous Hardware - Prelude library

Copyright (C) 2013-2015, University of Twente BSD2 (see the file LICENSE) Christiaan Baaij Trustworthy Haskell2010

CLaSH.Sized.Signed

Description

Synopsis

Documentation

data Signed n Source

Arbitrary-width signed integer represented by `n` bits, including the sign bit.

Uses standard 2-complements representation. Meaning that, given `n` bits, a `Signed` `n` number has a range of: [-(2^(`n`-1)) .. 2^(`n`-1)-1]

NB: The `Num` operators perform `wrap-around` on overflow. If you want saturation on overflow, check out the `SaturatingNum` class.

````>>> ````maxBound :: Signed 3
```3
`>>> ````minBound :: Signed 3
```-4
`>>> ````1 + 2 :: Signed 3
```3
`>>> ````2 + 3 :: Signed 3
```-3
`>>> ````(-2) + (-3) :: Signed 3
```3
`>>> ````2 * 3 :: Signed 4
```6
`>>> ````2 * 4 :: Signed 4
```-8
`>>> ````(2 :: Signed 3) `times` (4 :: Signed 4) :: Signed 7
```8
`>>> ````(2 :: Signed 3) `plus` (3 :: Signed 3) :: Signed 4
```5
`>>> ````(-2 :: Signed 3) `plus` (-3 :: Signed 3) :: Signed 4
```-5
`>>> ````satPlus SatSymmetric 2 3 :: Signed 3
```3
`>>> ````satPlus SatSymmetric (-2) (-3) :: Signed 3
```-3
```

Instances

 Source KnownNat n => Bounded (Signed n) Source KnownNat n => Enum (Signed n) Source The functions: `enumFrom`, `enumFromThen`, `enumFromTo`, and `enumFromThenTo`, are not synthesisable. Eq (Signed n) Source KnownNat n => Integral (Signed n) Source KnownNat n => Num (Signed n) Source Operators do `wrap-around` on overflow Ord (Signed n) Source KnownNat n => Real (Signed n) Source Show (Signed n) Source KnownNat n => Arbitrary (Signed n) Source KnownNat n => CoArbitrary (Signed n) Source (KnownNat n, KnownNat ((+) n 1), KnownNat ((+) n 2)) => Bits (Signed n) Source (KnownNat n, KnownNat ((+) n 1), KnownNat ((+) n 2)) => FiniteBits (Signed n) Source KnownNat n => Default (Signed n) Source KnownNat n => Ixed (Signed n) Source KnownNat n => Lift (Signed n) Source (KnownNat n, KnownNat ((+) 1 n), KnownNat ((+) n n)) => SaturatingNum (Signed n) Source KnownNat n => BitPack (Signed n) Source Bundle (Signed n) Source (KnownNat ((+) 1 (Max m n)), KnownNat ((+) m n)) => ExtendingNum (Signed m) (Signed n) Source type Unbundled' clk (Signed n) = Signal' clk (Signed n) type Index (Signed n) = Int Source type IxValue (Signed n) = Bit Source type BitSize (Signed n) = n Source type AResult (Signed m) (Signed n) = Signed ((+) 1 (Max m n)) Source type MResult (Signed m) (Signed n) = Signed ((+) m n) Source