FltPt

FltPt[G,E] represents an arbitrary precision, IEEE-754-like representation. FltPt values are always assumed to be signed.

The type parameters for FltPt are:

G INT Number of significand bits, including sign bit (_2 - _64)
E INT Number of exponent bits (_1 - _64)

Note that numbers of bits use the underscore prefix as integers cannot be used as type parameters in Scala.


Type Aliases

Specific types of FltPt values can be managed using type aliases. New type aliases can be created using::

type MyType = FltPt[_##,_##]

Spatial defines the following type aliases by default:

type Half FltPt[_11,_5] IEEE-754 half precision
type Float FltPt[_24,_8] IEEE-754 single precision
type Double FltPt[_53,_11] IEEE-754 double precision

Note that the Float and Double types shadow their respective unstaged Scala types. In the case where an unstaged type is required, use the full scala.* name.


Infix methods

class FltPt[G,E]
def unary_-(): FltPt[G,E]
Returns the negation of this floating point value.
def + (that: FltPt[G,E]): FltPt[G,E]
Floating point addition.
def - (that: FltPt[G,E]): FltPt[G,E]
Floating point subtraction.
def * (that: FltPt[G,E]): FltPt[G,E]
Floating point multiplication.
def / (that: FltPt[G,E]): FltPt[G,E]
Floating point division.
def \*\*(exp: scala.Int): FltPt[G,E]
Integer exponentiation, implemented in hardware as a reduction tree with exp inputs.
def < (that: FltPt[G,E]): MBoolean
Less than comparison.

Returns true if this value is less than that value. Otherwise returns false.
def <=(that: FltPt[G,E]): MBoolean
Less than or equal comparison.

Returns true if this value is less than or equal to that value. Otherwise returns false.
def > (that: FltPt[G,E]): MBoolean
Greater than comparison.

Returns true if this value is greater than that value. Otherwise returns false.
def >=(that: FltPt[G,E]): MBoolean
Greater than or equal comparison.

Returns true if this value is less than that value. Otherwise returns false.
def !=(that: FltPt[G,E]): Boolean
Value inequality comparison.
Returns true if this value is not equal to the right hand side. Otherwise returns false.
def !=(that: FltPt[G,E]): Boolean
Value equality comparison.
Returns true if this value is equal to the right hand side. Otherwise returns false.
def as[T:Type:Bits]: T
Re-interprets this value’s bits as the given type, without conversion.
def apply(i: scala.Int): Bit
Returns the given bit in this value.
0 corresponds to the least significant bit (LSB).
def apply(range: Range): Vector[Bit]
Returns a vector of bits based on the given range.
The range must be statically determinable values.
def reverse: FltPt[G,E]
Returns a floating point value with this value’s bits in reverse order.
def to[T:Type:Bits]: T
Converts this value to the given type.

Currently supported types are FixPt, FltPt, and String.
def toString: String
Creates a printable String representation of this value.

NOTE: This method is unsynthesizable, and can be used only on the CPU or in simulation.