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

Copyright(C) 2013-2015, University of Twente
LicenseBSD2 (see the file LICENSE)
MaintainerChristiaan Baaij <christiaan.baaij@gmail.com>
Safe HaskellUnsafe
LanguageHaskell2010
Extensions
  • UndecidableInstances
  • MonoLocalBinds
  • TemplateHaskell
  • TypeFamilies
  • DataKinds
  • FlexibleContexts
  • MultiParamTypeClasses
  • MagicHash
  • KindSignatures
  • TypeOperators
  • ExplicitNamespaces

CLaSH.Sized.Internal.Signed

Contents

Description

 

Synopsis

Datatypes

newtype 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

Constructors

S

The constructor, S, and the field, unsafeToInteger, are not synthesisable.

Instances

Resize Signed 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 => Bits (Signed n) Source 
KnownNat n => 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 

Accessors

Length information

Type classes

BitConvert

eq# :: Signed n -> Signed n -> Bool Source

Ord

lt# :: Signed n -> Signed n -> Bool Source

ge# :: Signed n -> Signed n -> Bool Source

gt# :: Signed n -> Signed n -> Bool Source

le# :: Signed n -> Signed n -> Bool Source

Enum (not synthesisable)

Bounded

Num

(+#) :: KnownNat n => Signed n -> Signed n -> Signed n Source

(-#) :: KnownNat n => Signed n -> Signed n -> Signed n Source

(*#) :: KnownNat n => Signed n -> Signed n -> Signed n Source

ExtendingNum

plus# :: KnownNat (1 + Max m n) => Signed m -> Signed n -> Signed (1 + Max m n) Source

minus# :: KnownNat (1 + Max m n) => Signed m -> Signed n -> Signed (1 + Max m n) Source

times# :: KnownNat (m + n) => Signed m -> Signed n -> Signed (m + n) Source

Integral

rem# :: Signed n -> Signed n -> Signed n Source

div# :: KnownNat n => Signed n -> Signed n -> Signed n Source

mod# :: KnownNat n => Signed n -> Signed n -> Signed n Source

Bits

and# :: KnownNat n => Signed n -> Signed n -> Signed n Source

or# :: KnownNat n => Signed n -> Signed n -> Signed n Source

xor# :: KnownNat n => Signed n -> Signed n -> Signed n Source

Resize

SaturatingNum