Copyright | (C) 2013-2016 University of Twente 2024 Google LLC |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |
Safe Haskell | Safe |
Language | Haskell2010 |
Extensions |
|
Synopsis
- class ExtendingNum a b where
- data SaturationMode
- class (Bounded a, Num a) => SaturatingNum a where
- satAdd :: SaturationMode -> a -> a -> a
- satSub :: SaturationMode -> a -> a -> a
- satMul :: SaturationMode -> a -> a -> a
- satSucc :: SaturationMode -> a -> a
- satPred :: SaturationMode -> a -> a
- boundedAdd :: SaturatingNum a => a -> a -> a
- boundedSub :: SaturatingNum a => a -> a -> a
- boundedMul :: SaturatingNum a => a -> a -> a
Arithmetic functions for arguments and results of different precision
class ExtendingNum a b where Source #
Adding, subtracting, and multiplying values of two different (sub-)types.
Type of the result of the addition or subtraction
Type of the result of the multiplication
add :: a -> b -> AResult a b infixl 6 Source #
Add values of different (sub-)types, return a value of a (sub-)type that is potentially different from either argument.
sub :: a -> b -> AResult a b infixl 6 Source #
Subtract values of different (sub-)types, return a value of a (sub-)type that is potentially different from either argument.
mul :: a -> b -> MResult a b infixl 7 Source #
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) Source # | |
Defined in Clash.Sized.Internal.BitVector | |
ExtendingNum (Index m) (Index n) Source # | |
Defined in Clash.Sized.Internal.Index | |
(KnownNat m, KnownNat n) => ExtendingNum (Unsigned m) (Unsigned n) Source # | |
Defined in Clash.Sized.Internal.Unsigned | |
ExtendingNum (Signed m) (Signed n) Source # | |
Defined in Clash.Sized.Internal.Signed | |
ENumFixedC rep int1 frac1 int2 frac2 => ExtendingNum (Fixed rep int1 frac1) (Fixed rep int2 frac2) Source # | When used in a polymorphic setting, use the following Constraint synonyms for less verbose type signatures:
|
Defined in Clash.Sized.Fixed type AResult (Fixed rep int1 frac1) (Fixed rep int2 frac2) Source # type MResult (Fixed rep int1 frac1) (Fixed rep int2 frac2) Source # add :: Fixed rep int1 frac1 -> Fixed rep int2 frac2 -> AResult (Fixed rep int1 frac1) (Fixed rep int2 frac2) Source # sub :: Fixed rep int1 frac1 -> Fixed rep int2 frac2 -> AResult (Fixed rep int1 frac1) (Fixed rep int2 frac2) Source # mul :: Fixed rep int1 frac1 -> Fixed rep int2 frac2 -> MResult (Fixed rep int1 frac1) (Fixed rep int2 frac2) Source # |
Saturating arithmetic functions
data SaturationMode Source #
Determine how overflow and underflow are handled by the functions in
SaturatingNum
SatWrap | Wrap around on overflow and underflow |
SatBound | |
SatZero | Become |
SatSymmetric | Become |
SatError | Become an XException on overflow and underflow |
Instances
Bounded SaturationMode Source # | |
Defined in Clash.Class.Num | |
Enum SaturationMode Source # | |
Defined in Clash.Class.Num succ :: SaturationMode -> SaturationMode Source # pred :: SaturationMode -> SaturationMode Source # toEnum :: Int -> SaturationMode Source # fromEnum :: SaturationMode -> Int Source # enumFrom :: SaturationMode -> [SaturationMode] Source # enumFromThen :: SaturationMode -> SaturationMode -> [SaturationMode] Source # enumFromTo :: SaturationMode -> SaturationMode -> [SaturationMode] Source # enumFromThenTo :: SaturationMode -> SaturationMode -> SaturationMode -> [SaturationMode] Source # | |
Eq SaturationMode Source # | |
Defined in Clash.Class.Num (==) :: SaturationMode -> SaturationMode -> Bool Source # (/=) :: SaturationMode -> SaturationMode -> Bool Source # | |
Show SaturationMode Source # | |
Defined in Clash.Class.Num |
class (Bounded a, Num a) => SaturatingNum a where Source #
Num
operators in which overflow and underflow behavior can be specified
using SaturationMode
.
satAdd :: SaturationMode -> a -> a -> a infixl 6 Source #
Addition with parameterizable over- and underflow behavior
satSub :: SaturationMode -> a -> a -> a infixl 6 Source #
Subtraction with parameterizable over- and underflow behavior
satMul :: SaturationMode -> a -> a -> a infixl 7 Source #
Multiplication with parameterizable over- and underflow behavior
satSucc :: SaturationMode -> a -> a Source #
Get successor of (or in other words, add 1 to) given number
satPred :: SaturationMode -> a -> a Source #
Get predecessor of (or in other words, subtract 1 from) given number
Instances
boundedAdd :: SaturatingNum a => a -> a -> a infixl 6 Source #
boundedSub :: SaturatingNum a => a -> a -> a infixl 6 Source #
boundedMul :: SaturatingNum a => a -> a -> a infixl 7 Source #