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

Safe HaskellNone
LanguageHaskell2010

CLaSH.Class.Num

Synopsis

Documentation

class Add a b where Source

Implicitly adding or subtracting values of two different (sub-)types.

Associated Types

type AResult a b Source

Methods

plus :: a -> b -> AResult a b Source

minus :: a -> b -> AResult a b Source

Instances

KnownNat (Max m n) => Add (Signed m) (Signed n) 
KnownNat (Max m n) => Add (Unsigned m) (Unsigned n) 
AddFixed rep frac1 frac2 size1 size2 => Add (Fixed frac1 rep size1) (Fixed frac2 rep size2)

When used in a polymorphic setting, use the following Constraint synonyms for less verbose type signatures:

class Mult a b where Source

Implicitly multiplying values of two different (sub-)types.

Associated Types

type MResult a b Source

Methods

mult :: a -> b -> MResult a b Source

Instances

KnownNat ((+) m n) => Mult (Signed m) (Signed n) 
KnownNat ((+) m n) => Mult (Unsigned m) (Unsigned n) 
MultFixed rep frac1 frac2 size1 size2 => Mult (Fixed frac1 rep size1) (Fixed frac2 rep size2)

When used in a polymorphic setting, use the following Constraint synonyms for less verbose type signatures:

class Resize f where Source

Coerce a value to be represented by a different number of bits

Methods

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

Instances

Resize Signed

A sign-preserving resize operation

Increasing the size of the number replicates the sign bit to the left. Truncating a number to length L keeps the sign bit and the rightmost L-1 bits.

Resize Unsigned

A resize operation that zero-extends on extension, and wraps on truncation.

Increasing the size of the number extends with zeros to the left. Truncating a number of length N to a length L just removes the left (most significant) N-L bits.