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

Safe HaskellNone
LanguageHaskell2010

CLaSH.Sized.Signed

Synopsis

Documentation

data 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 satN2 function in CLaSH.Sized.Fixed.

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.

KnownNat n => Bounded (Signed n) 
KnownNat n => Enum (Signed n) 
Eq (Signed n) 
KnownNat n => Integral (Signed n) 
KnownNat n => Num (Signed n)

Operators do wrap-around on overflow

Ord (Signed n) 
KnownNat n => Real (Signed n) 
Show (Signed n) 
KnownNat n => Bits (Signed n) 
KnownNat n => FiniteBits (Signed n) 
KnownNat n => Default (Signed n) 
KnownNat n => Lift (Signed n) 
BitVector (Signed n) 
Pack (Signed n) 
CPack (Signed n) 
KnownNat ((+) m n) => Mult (Signed m) (Signed n) 
KnownNat (Max m n) => Add (Signed m) (Signed n) 
Typeable (Nat -> *) Signed 
type CSignalP clk (Signed n) = CSignal clk (Signed n) 
type BitSize (Signed n) = n 
type SignalP (Signed n) = Signal (Signed n) 
type MResult (Signed m) (Signed n) = Signed ((+) m n) 
type AResult (Signed m) (Signed n) = Signed (Max m n) 

resizeS_wrap :: KnownNat m => Signed n -> Signed m Source

A resize operation that is sign-preserving on extension, but wraps on truncation.

Increasing the size of the number replicates the sign bit to the left. Truncating a number of length N to a length L just removes the leftmost N-L bits.