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

Copyright(C) 2013-2016 University of Twente
2016 Myrtle Software Ltd
LicenseBSD2 (see the file LICENSE)
MaintainerChristiaan Baaij <christiaan.baaij@gmail.com>
Safe HaskellUnsafe
LanguageHaskell2010
Extensions
  • UndecidableInstances
  • MonoLocalBinds
  • TemplateHaskell
  • TemplateHaskellQuotes
  • ScopedTypeVariables
  • TypeFamilies
  • DataKinds
  • DeriveDataTypeable
  • ConstrainedClassMethods
  • MultiParamTypeClasses
  • MagicHash
  • KindSignatures
  • GeneralizedNewtypeDeriving
  • TypeOperators
  • ExplicitNamespaces
  • ExplicitForAll
  • TypeApplications

Clash.Sized.Internal.Signed

Contents

Description

 
Synopsis

Datatypes

newtype Signed (n :: Nat) 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
>>> read (show (minBound :: Signed 3)) :: 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 # 
Instance details

Methods

resize :: (KnownNat a, KnownNat b) => Signed a -> Signed b Source #

extend :: (KnownNat a, KnownNat b) => Signed a -> Signed (b + a) Source #

zeroExtend :: (KnownNat a, KnownNat b) => Signed a -> Signed (b + a) Source #

signExtend :: (KnownNat a, KnownNat b) => Signed a -> Signed (b + a) Source #

truncateB :: KnownNat a => Signed (a + b) -> Signed a Source #

KnownNat n => Bounded (Signed n) Source # 
Instance details

Methods

minBound :: Signed n #

maxBound :: Signed n #

KnownNat n => Enum (Signed n) Source #

The functions: enumFrom, enumFromThen, enumFromTo, and enumFromThenTo, are not synthesisable.

Instance details

Methods

succ :: Signed n -> Signed n #

pred :: Signed n -> Signed n #

toEnum :: Int -> Signed n #

fromEnum :: Signed n -> Int #

enumFrom :: Signed n -> [Signed n] #

enumFromThen :: Signed n -> Signed n -> [Signed n] #

enumFromTo :: Signed n -> Signed n -> [Signed n] #

enumFromThenTo :: Signed n -> Signed n -> Signed n -> [Signed n] #

Eq (Signed n) Source # 
Instance details

Methods

(==) :: Signed n -> Signed n -> Bool #

(/=) :: Signed n -> Signed n -> Bool #

KnownNat n => Integral (Signed n) Source # 
Instance details

Methods

quot :: Signed n -> Signed n -> Signed n #

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

div :: Signed n -> Signed n -> Signed n #

mod :: Signed n -> Signed n -> Signed n #

quotRem :: Signed n -> Signed n -> (Signed n, Signed n) #

divMod :: Signed n -> Signed n -> (Signed n, Signed n) #

toInteger :: Signed n -> Integer #

KnownNat n => Data (Signed n) Source # 
Instance details

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Signed n -> c (Signed n) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Signed n) #

toConstr :: Signed n -> Constr #

dataTypeOf :: Signed n -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Signed n)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Signed n)) #

gmapT :: (forall b. Data b => b -> b) -> Signed n -> Signed n #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Signed n -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Signed n -> r #

gmapQ :: (forall d. Data d => d -> u) -> Signed n -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Signed n -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Signed n -> m (Signed n) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Signed n -> m (Signed n) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Signed n -> m (Signed n) #

KnownNat n => Num (Signed n) Source #

Operators do wrap-around on overflow

Instance details

Methods

(+) :: Signed n -> Signed n -> Signed n #

(-) :: Signed n -> Signed n -> Signed n #

(*) :: Signed n -> Signed n -> Signed n #

negate :: Signed n -> Signed n #

abs :: Signed n -> Signed n #

signum :: Signed n -> Signed n #

fromInteger :: Integer -> Signed n #

Ord (Signed n) Source # 
Instance details

Methods

compare :: Signed n -> Signed n -> Ordering #

(<) :: Signed n -> Signed n -> Bool #

(<=) :: Signed n -> Signed n -> Bool #

(>) :: Signed n -> Signed n -> Bool #

(>=) :: Signed n -> Signed n -> Bool #

max :: Signed n -> Signed n -> Signed n #

min :: Signed n -> Signed n -> Signed n #

KnownNat n => Read (Signed n) Source #

None of the Read class' methods are synthesisable.

Instance details
KnownNat n => Real (Signed n) Source # 
Instance details

Methods

toRational :: Signed n -> Rational #

Show (Signed n) Source # 
Instance details

Methods

showsPrec :: Int -> Signed n -> ShowS #

show :: Signed n -> String #

showList :: [Signed n] -> ShowS #

KnownNat n => Lift (Signed n) Source # 
Instance details

Methods

lift :: Signed n -> Q Exp #

KnownNat n => Arbitrary (Signed n) Source # 
Instance details

Methods

arbitrary :: Gen (Signed n) #

shrink :: Signed n -> [Signed n] #

KnownNat n => CoArbitrary (Signed n) Source # 
Instance details

Methods

coarbitrary :: Signed n -> Gen b -> Gen b #

KnownNat n => Bits (Signed n) Source # 
Instance details

Methods

(.&.) :: Signed n -> Signed n -> Signed n #

(.|.) :: Signed n -> Signed n -> Signed n #

xor :: Signed n -> Signed n -> Signed n #

complement :: Signed n -> Signed n #

shift :: Signed n -> Int -> Signed n #

rotate :: Signed n -> Int -> Signed n #

zeroBits :: Signed n #

bit :: Int -> Signed n #

setBit :: Signed n -> Int -> Signed n #

clearBit :: Signed n -> Int -> Signed n #

complementBit :: Signed n -> Int -> Signed n #

testBit :: Signed n -> Int -> Bool #

bitSizeMaybe :: Signed n -> Maybe Int #

bitSize :: Signed n -> Int #

isSigned :: Signed n -> Bool #

shiftL :: Signed n -> Int -> Signed n #

unsafeShiftL :: Signed n -> Int -> Signed n #

shiftR :: Signed n -> Int -> Signed n #

unsafeShiftR :: Signed n -> Int -> Signed n #

rotateL :: Signed n -> Int -> Signed n #

rotateR :: Signed n -> Int -> Signed n #

popCount :: Signed n -> Int #

KnownNat n => FiniteBits (Signed n) Source # 
Instance details
KnownNat n => Default (Signed n) Source # 
Instance details

Methods

def :: Signed n #

NFData (Signed n) Source # 
Instance details

Methods

rnf :: Signed n -> () #

KnownNat n => Ixed (Signed n) Source # 
Instance details

Methods

ix :: Index (Signed n) -> Traversal' (Signed n) (IxValue (Signed n)) #

KnownNat n => SaturatingNum (Signed n) Source # 
Instance details
ShowX (Signed n) Source # 
Instance details
KnownNat n => BitPack (Signed n) Source # 
Instance details

Associated Types

type BitSize (Signed n) :: Nat Source #

Bundle (Signed n) Source # 
Instance details

Associated Types

type Unbundled domain (Signed n) = (res :: *) Source #

Methods

bundle :: Unbundled domain (Signed n) -> Signal domain (Signed n) Source #

unbundle :: Signal domain (Signed n) -> Unbundled domain (Signed n) Source #

ExtendingNum (Signed m) (Signed n) Source # 
Instance details

Associated Types

type AResult (Signed m) (Signed n) :: * Source #

type MResult (Signed m) (Signed n) :: * Source #

Methods

plus :: Signed m -> Signed n -> AResult (Signed m) (Signed n) Source #

minus :: Signed m -> Signed n -> AResult (Signed m) (Signed n) Source #

times :: Signed m -> Signed n -> MResult (Signed m) (Signed n) Source #

type Unbundled domain (Signed n) Source # 
Instance details
type Unbundled domain (Signed n) = Signal domain (Signed n)
type Index (Signed n) Source # 
Instance details
type Index (Signed n) = Int
type IxValue (Signed n) Source # 
Instance details
type IxValue (Signed n) = Bit
type BitSize (Signed n) Source # 
Instance details
type BitSize (Signed n) = n
type AResult (Signed m) (Signed n) Source # 
Instance details
type AResult (Signed m) (Signed n) = Signed (Max m n + 1)
type MResult (Signed m) (Signed n) Source # 
Instance details
type MResult (Signed m) (Signed n) = Signed (m + n)

Accessors

Length information

Type classes

BitConvert

pack# :: forall n. KnownNat n => Signed n -> BitVector n Source #

unpack# :: forall n. KnownNat n => BitVector n -> Signed n Source #

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

neq# :: 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

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

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

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

negate# :: forall n. KnownNat n => Signed n -> Signed n Source #

abs# :: forall n. KnownNat n => Signed n -> Signed n Source #

ExtendingNum

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

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

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

Integral

quot# :: Signed n -> Signed n -> Signed n Source #

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

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

mod# :: 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

resize# :: forall m n. (KnownNat n, KnownNat m) => Signed n -> Signed m Source #

SaturatingNum