| Copyright | (C) 2013-2016 University of Twente |
|---|---|
| License | BSD2 (see the file LICENSE) |
| Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |
| Safe Haskell | Safe |
| Language | Haskell2010 |
| Extensions |
|
Clash.Class.Num
Contents
Description
Synopsis
- class ExtendingNum a b where
- data SaturationMode
- class (Bounded a, Num a) => SaturatingNum a where
- boundedPlus :: SaturatingNum a => a -> a -> a
- boundedMin :: SaturatingNum a => a -> a -> a
- boundedMult :: SaturatingNum a => a -> a -> a
Arithmetic functions for arguments and results of different precision
class ExtendingNum a b where #
Adding, subtracting, and multiplying values of two different (sub-)types.
Associated Types
Type of the result of the addition or subtraction
Type of the result of the multiplication
Methods
plus :: a -> b -> AResult a b #
Add values of different (sub-)types, return a value of a (sub-)type that is potentially different from either argument.
minus :: a -> b -> AResult a b #
Subtract values of different (sub-)types, return a value of a (sub-)type that is potentially different from either argument.
times :: a -> b -> MResult a b #
Multiply values of different (sub-)types, return a value of a (sub-)type that is potentially different from either argument.
Instances
| (KnownNat m, KnownNat n) => ExtendingNum (BitVector m) (BitVector n) # | |
| ExtendingNum (Index m) (Index n) # | |
Defined in Clash.Sized.Internal.Index | |
| (KnownNat m, KnownNat n) => ExtendingNum (Unsigned m) (Unsigned n) # | |
| ExtendingNum (Signed m) (Signed n) # | |
Defined in Clash.Sized.Internal.Signed | |
| ENumFixedC rep int1 frac1 int2 frac2 => ExtendingNum (Fixed rep int1 frac1) (Fixed rep int2 frac2) # | When used in a polymorphic setting, use the following Constraint synonyms for less verbose type signatures:
|
Defined in Clash.Sized.Fixed Associated Types type AResult (Fixed rep int1 frac1) (Fixed rep int2 frac2) :: * # type MResult (Fixed rep int1 frac1) (Fixed rep int2 frac2) :: * # Methods plus :: Fixed rep int1 frac1 -> Fixed rep int2 frac2 -> AResult (Fixed rep int1 frac1) (Fixed rep int2 frac2) # minus :: Fixed rep int1 frac1 -> Fixed rep int2 frac2 -> AResult (Fixed rep int1 frac1) (Fixed rep int2 frac2) # times :: Fixed rep int1 frac1 -> Fixed rep int2 frac2 -> MResult (Fixed rep int1 frac1) (Fixed rep int2 frac2) # | |
Saturating arithmetic functions
data SaturationMode #
Determine how overflow and underflow are handled by the functions in
SaturatingNum
Constructors
| SatWrap | Wrap around on overflow and underflow |
| SatBound | |
| SatZero | Become |
| SatSymmetric | Become |
Instances
| Eq SaturationMode # | |
Defined in Clash.Class.Num Methods (==) :: SaturationMode -> SaturationMode -> Bool # (/=) :: SaturationMode -> SaturationMode -> Bool # | |
class (Bounded a, Num a) => SaturatingNum a where #
Num operators in which overflow and underflow behaviour can be specified
using SaturationMode.
Methods
satPlus :: SaturationMode -> a -> a -> a #
Addition with parametrisable over- and underflow behaviour
satMin :: SaturationMode -> a -> a -> a #
Subtraction with parametrisable over- and underflow behaviour
satMult :: SaturationMode -> a -> a -> a #
Multiplication with parametrisable over- and underflow behaviour
Instances
| KnownNat n => SaturatingNum (BitVector n) # | |
Defined in Clash.Sized.Internal.BitVector | |
| (KnownNat n, 1 <= n) => SaturatingNum (Index n) # | |
Defined in Clash.Sized.Internal.Index | |
| KnownNat n => SaturatingNum (Unsigned n) # | |
Defined in Clash.Sized.Internal.Unsigned | |
| KnownNat n => SaturatingNum (Signed n) # | |
Defined in Clash.Sized.Internal.Signed | |
| NumFixedC rep int frac => SaturatingNum (Fixed rep int frac) # | |
Defined in Clash.Sized.Fixed | |
boundedPlus :: SaturatingNum a => a -> a -> a #
boundedMin :: SaturatingNum a => a -> a -> a #
boundedMult :: SaturatingNum a => a -> a -> a #