simuhw.float package

Subpackages

Module contents

simuhw.float.is_available() bool

Checks whether float subpackage is available or not.

Returns:

True if float subpackage is available.

Note

float subpackage is available only when an appropriate version of softfloatpy module is found. The least version can be retrieved using get_required_softfloatpy_least_version()

simuhw.float.get_required_softfloatpy_least_version() str

Retrieves the least version of softfloatpy module required for float subpackage.

Returns:

The least version of softfloatpy module required for float subpackage.

class simuhw.float.TininessMode(value)

Bases: IntFlag

The tininess detection modes.

  • BEFORE_ROUNDING: Detecting tininess before rounding.

  • AFTER_ROUNDING: Detecting tininess after rounding.

BEFORE_ROUNDING = 0
AFTER_ROUNDING = 1
class simuhw.float.RoundingMode(value)

Bases: IntFlag

The rounding modes.

  • NEAR_EVEN: Rounding to nearest, with ties to even.

  • NEAR_MAX_MAG: Rounding to nearest, with ties to maximum magnitude (away from zero).

  • MIN_MAG: Rounding to minimum magnitude (toward zero).

  • MIN: Rounding to minimum (down).

  • MAX: Rounding to maximum (up).

NEAR_EVEN = 0
MIN_MAG = 1
MIN = 2
MAX = 3
NEAR_MAX_MAG = 4
class simuhw.float.ExceptionFlag(value)

Bases: IntFlag

The floating-point exception flags.

  • INEXACT: The exception set if the rounded value is different from the mathematically exact result of the operation.

  • UNDERFLOW: The exception set if the rounded value is tiny and inexact.

  • OVERFLOW: The exception set if the absolute value of the rounded value is too large to be represented.

  • INFINITE: The exception set if the result is infinite given finite operands.

  • INVALID: The exception set if a finite or infinite result cannot be returned.

INEXACT = 1
UNDERFLOW = 2
OVERFLOW = 4
INFINITE = 8
INVALID = 16
class simuhw.float.UInt32

Bases: object

A 32-bit unsigned integer.

The object is immutable.

The following operators are supported:

  • unary operators: +, ~.

  • binary operators: +, -, *, //, %, <<, >>, &, |, ^, <, <=, >, >=, ==, !=, +=, -=, *=, //=, %=, <<=, >>=, &=, |=, ^=.

The following operators are unsupported:

  • unary operators: -.

  • binary operators: **, /, **=, /=.

classmethod from_bytes(cls, bytes src) UInt32

Creates a new instance from the specified byte sequence.

Parameters:

src – The byte sequence representing the native data with big endian. The length must be 4.

Returns:

A new instance created from the specified byte sequence.

Raises:

ValueError – If the length of bytes is not 4.

classmethod from_f128(cls, Float128 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt32

Creates a new instance from the specified IEEE 754 binary128 floating point.

The result is the same as that of f128_to_ui32().

Parameters:
  • src – The IEEE 754 binary128 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary128 floating point.

classmethod from_f16(cls, Float16 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt32

Creates a new instance from the specified IEEE 754 binary16 floating point.

The result is the same as that of f16_to_ui32().

Parameters:
  • src – The IEEE 754 binary16 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary16 floating point.

classmethod from_f32(cls, Float32 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt32

Creates a new instance from the specified IEEE 754 binary32 floating point.

The result is the same as that of f32_to_ui32().

Parameters:
  • src – The IEEE 754 binary32 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary32 floating point.

classmethod from_f64(cls, Float64 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt32

Creates a new instance from the specified IEEE 754 binary64 floating point.

The result is the same as that of f64_to_ui32().

Parameters:
  • src – The IEEE 754 binary64 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary64 floating point.

classmethod from_int(cls, src) UInt32

Creates a new instance from the specified integer.

Parameters:

src – The integer from which a new instance is created.

Returns:

A new instance created from the specified integer.

classmethod size(cls) int

Returns the native data size in bits.

Returns:

The native data size in bits, i.e. 32.

to_bytes(self) bytes

Returns the native data as a byte sequence.

Returns:

A byte sequence representing the native data with big endian. The length is 4.

to_f128(self) Float128

Converts the 32-bit unsigned integer to an IEEE 754 binary128 floating point.

The result is the same as that of ui32_to_f128().

Returns:

The IEEE 754 binary128 floating point.

to_f16(self) Float16

Converts the 32-bit unsigned integer to an IEEE 754 binary16 floating point.

The result is the same as that of ui32_to_f16().

Returns:

The IEEE 754 binary16 floating point.

to_f32(self) Float32

Converts the 32-bit unsigned integer to an IEEE 754 binary32 floating point.

The result is the same as that of ui32_to_f32().

Returns:

The IEEE 754 binary32 floating point.

to_f64(self) Float64

Converts the 32-bit unsigned integer to an IEEE 754 binary64 floating point.

The result is the same as that of ui32_to_f64().

Returns:

The IEEE 754 binary64 floating point.

to_int(self)

Returns the native data as an integer.

Returns:

An integer that represents the native data.

class simuhw.float.UInt64

Bases: object

A 64-bit unsigned integer.

The object is immutable.

The following operators are supported:

  • unary operators: +, ~.

  • binary operators: +, -, *, //, %, <<, >>, &, |, ^, <, <=, >, >=, ==, !=, +=, -=, *=, //=, %=, <<=, >>=, &=, |=, ^=.

The following operators are unsupported:

  • unary operators: -.

  • binary operators: **, /, **=, /=.

classmethod from_bytes(cls, bytes src) UInt64

Creates a new instance from the specified byte sequence.

Parameters:

src – The byte sequence representing the native data with big endian. The length must be 8.

Returns:

A new instance created from the specified byte sequence.

Raises:

ValueError – If the length of bytes is not 8.

classmethod from_f128(cls, Float128 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt64

Creates a new instance from the specified IEEE 754 binary128 floating point.

The result is the same as that of f128_to_ui64().

Parameters:
  • src – The IEEE 754 binary128 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary128 floating point.

classmethod from_f16(cls, Float16 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt64

Creates a new instance from the specified IEEE 754 binary16 floating point.

The result is the same as that of f16_to_ui64().

Parameters:
  • src – The IEEE 754 binary16 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary16 floating point.

classmethod from_f32(cls, Float32 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt64

Creates a new instance from the specified IEEE 754 binary32 floating point.

The result is the same as that of f32_to_ui64().

Parameters:
  • src – The IEEE 754 binary32 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary32 floating point.

classmethod from_f64(cls, Float64 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt64

Creates a new instance from the specified IEEE 754 binary64 floating point.

The result is the same as that of f64_to_ui64().

Parameters:
  • src – The IEEE 754 binary64 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary64 floating point.

classmethod from_int(cls, src) UInt64

Creates a new instance from the specified integer.

Parameters:

src – The integer from which a new instance is created.

Returns:

A new instance created from the specified integer.

classmethod size(cls) int

Returns the native data size in bits.

Returns:

The native data size in bits, i.e. 64.

to_bytes(self) bytes

Returns the native data as a byte sequence.

Returns:

A byte sequence representing the native data with big endian. The length is 8.

to_f128(self) Float128

Converts the 64-bit unsigned integer to an IEEE 754 binary128 floating point.

The result is the same as that of ui64_to_f128().

Returns:

The IEEE 754 binary128 floating point.

to_f16(self) Float16

Converts the 64-bit unsigned integer to an IEEE 754 binary16 floating point.

The result is the same as that of ui64_to_f16().

Returns:

The IEEE 754 binary16 floating point.

to_f32(self) Float32

Converts the 64-bit unsigned integer to an IEEE 754 binary32 floating point.

The result is the same as that of ui64_to_f32().

Returns:

The IEEE 754 binary32 floating point.

to_f64(self) Float64

Converts the 64-bit unsigned integer to an IEEE 754 binary64 floating point.

The result is the same as that of ui64_to_f64().

Returns:

The IEEE 754 binary64 floating point.

to_int(self)

Returns the native data as an integer.

Returns:

An integer that represents the native data.

class simuhw.float.Int32

Bases: object

A 32-bit signed integer.

The object is immutable.

The following operators are supported:

  • unary operators: +, -, ~.

  • binary operators: +, -, *, //, %, <<, >>, &, |, ^, <, <=, >, >=, ==, !=, +=, -=, *=, //=, %=, <<=, >>=, &=, |=, ^=.

The following operators are unsupported:

  • binary operators: **, /, **=, /=.

classmethod from_bytes(cls, bytes src) Int32

Creates a new instance from the specified byte sequence.

Parameters:

src – The byte sequence representing the native data with big endian. The length must be 4.

Returns:

A new instance created from the specified byte sequence.

Raises:

ValueError – If the length of bytes is not 4.

classmethod from_f128(cls, Float128 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int32

Creates a new instance from the specified IEEE 754 binary128 floating point.

The result is the same as that of f128_to_i32().

Parameters:
  • src – The IEEE 754 binary128 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary128 floating point.

classmethod from_f16(cls, Float16 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int32

Creates a new instance from the specified IEEE 754 binary16 floating point.

The result is the same as that of f16_to_i32().

Parameters:
  • src – The IEEE 754 binary16 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary16 floating point.

classmethod from_f32(cls, Float32 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int32

Creates a new instance from the specified IEEE 754 binary32 floating point.

The result is the same as that of f32_to_i32().

Parameters:
  • src – The IEEE 754 binary32 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary32 floating point.

classmethod from_f64(cls, Float64 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int32

Creates a new instance from the specified IEEE 754 binary64 floating point.

The result is the same as that of f64_to_i32().

Parameters:
  • src – The IEEE 754 binary64 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary64 floating point.

classmethod from_int(cls, src) Int32

Creates a new instance from the specified integer.

Parameters:

src – The integer from which a new instance is created.

Returns:

A new instance created from the specified integer.

classmethod size(cls) int

Returns the native data size in bits.

Returns:

The native data size in bits, i.e. 32.

to_bytes(self) bytes

Returns the native data as a byte sequence.

Returns:

A byte sequence representing the native data with big endian. The length is 4.

to_f128(self) Float128

Converts the 32-bit signed integer to an IEEE 754 binary128 floating point.

The result is the same as that of i32_to_f128().

Returns:

The IEEE 754 binary128 floating point.

to_f16(self) Float16

Converts the 32-bit signed integer to an IEEE 754 binary16 floating point.

The result is the same as that of i32_to_f16().

Returns:

The IEEE 754 binary16 floating point.

to_f32(self) Float32

Converts the 32-bit signed integer to an IEEE 754 binary32 floating point.

The result is the same as that of i32_to_f32().

Returns:

The IEEE 754 binary32 floating point.

to_f64(self) Float64

Converts the 32-bit signed integer to an IEEE 754 binary64 floating point.

The result is the same as that of i32_to_f64().

Returns:

The IEEE 754 binary64 floating point.

to_int(self)

Returns the native data as an integer.

Returns:

An integer that represents the native data.

class simuhw.float.Int64

Bases: object

A 64-bit signed integer.

The object is immutable.

The following operators are supported:

  • unary operators: +, -, ~.

  • binary operators: +, -, *, //, %, <<, >>, &, |, ^, <, <=, >, >=, ==, !=, +=, -=, *=, //=, %=, <<=, >>=, &=, |=, ^=.

The following operators are unsupported:

  • binary operators: **, /, **=, /=.

classmethod from_bytes(cls, bytes src) Int64

Creates a new instance from the specified byte sequence.

Parameters:

src – The byte sequence representing the native data with big endian. The length must be 8.

Returns:

A new instance created from the specified byte sequence.

Raises:

ValueError – If the length of bytes is not 8.

classmethod from_f128(cls, Float128 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int64

Creates a new instance from the specified IEEE 754 binary128 floating point.

The result is the same as that of f128_to_i64().

Parameters:
  • src – The IEEE 754 binary128 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary128 floating point.

classmethod from_f16(cls, Float16 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int64

Creates a new instance from the specified IEEE 754 binary16 floating point.

The result is the same as that of f16_to_i64().

Parameters:
  • src – The IEEE 754 binary16 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary16 floating point.

classmethod from_f32(cls, Float32 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int64

Creates a new instance from the specified IEEE 754 binary32 floating point.

The result is the same as that of f32_to_i64().

Parameters:
  • src – The IEEE 754 binary32 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary32 floating point.

classmethod from_f64(cls, Float64 src, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int64

Creates a new instance from the specified IEEE 754 binary64 floating point.

The result is the same as that of f64_to_i64().

Parameters:
  • src – The IEEE 754 binary64 floating point from which a new instance is created.

  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

A new instance created from the specified IEEE 754 binary64 floating point.

classmethod from_int(cls, src) Int64

Creates a new instance from the specified integer.

Parameters:

src – The integer from which a new instance is created.

Returns:

A new instance created from the specified integer.

classmethod size(cls) int

Returns the native data size in bits.

Returns:

The native data size in bits, i.e. 64.

to_bytes(self) bytes

Returns the native data as a byte sequence.

Returns:

A byte sequence representing the native data with big endian. The length is 8.

to_f128(self) Float128

Converts the 64-bit signed integer to an IEEE 754 binary128 floating point.

The result is the same as that of i64_to_f128().

Returns:

The IEEE 754 binary128 floating point.

to_f16(self) Float16

Converts the 64-bit signed integer to an IEEE 754 binary16 floating point.

The result is the same as that of i64_to_f16().

Returns:

The IEEE 754 binary16 floating point.

to_f32(self) Float32

Converts the 64-bit signed integer to an IEEE 754 binary32 floating point.

The result is the same as that of i64_to_f32().

Returns:

The IEEE 754 binary32 floating point.

to_f64(self) Float64

Converts the 64-bit signed integer to an IEEE 754 binary64 floating point.

The result is the same as that of i64_to_f64().

Returns:

The IEEE 754 binary64 floating point.

to_int(self)

Returns the native data as an integer.

Returns:

An integer that represents the native data.

class simuhw.float.BFloat16

Bases: object

A 16-bit brain floating point.

The object is immutable.

No operators are supported.

classmethod from_bytes(cls, bytes src) BFloat16

Creates a new instance from the specified byte sequence.

Parameters:

src – The byte sequence representing the native data with big endian. The length must be 2.

Returns:

A new instance created from the specified byte sequence.

Raises:

ValueError – If the length of bytes is not 2.

classmethod from_f32(cls, Float32 src) BFloat16

Creates a new instance from the specified IEEE 754 binary32 floating point.

The result is the same as that of f32_to_bf16().

Parameters:

src – The IEEE 754 binary32 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary32 floating point.

classmethod from_float(cls, double src) BFloat16

Creates a new instance from the specified floating point.

Parameters:

src – The floating point from which a new instance is created.

Returns:

A new instance created from the specified floating point.

is_inf(self) bool

Tests if the 16-bit brain floating point is an infinity.

The result is the same as that of bf16_is_inf().

Returns:

True if the floating point is an infinity, False otherwise.

is_nan(self) bool

Tests if the 16-bit brain floating point is a NaN.

The result is the same as that of bf16_is_nan().

Returns:

True if the floating point is a NaN, False otherwise.

is_signaling_nan(self) bool

Tests if the 16-bit brain floating point is a signaling NaN.

The result is the same as that of bf16_is_signaling_nan().

Returns:

True if the floating point is a signaling NaN, False otherwise.

classmethod size(cls) int

Returns the native data size in bits.

Returns:

The native data size in bits, i.e. 16.

to_bytes(self) bytes

Returns the native data as a byte sequence.

Returns:

A byte sequence representing the native data with big endian. The length is 2.

to_f32(self) Float32

Converts the 16-bit brain floating point to an IEEE 754 binary32 floating point.

The result is the same as that of bf16_to_f32().

Returns:

The IEEE 754 binary32 floating point.

to_float(self) double

Returns the native data as a floating point.

Returns:

A floating point that represents the native data.

class simuhw.float.Float16

Bases: object

An IEEE 754 binary16 floating point.

The object is immutable.

The following operators are supported:

  • unary operators: +, -.

  • binary operators: +, -, *, /, //, %, <, <=, >, >=, ==, !=, +=, -=, *=, /=, //=, %=.

The following operators are unsupported:

  • unary operator: ~.

  • binary operators: <<, >>, &, |, ^, **, <<=, >>=, &=, |=, ^=, **=.

classmethod add(cls, Float16 x, Float16 y) Float16

Adds the IEEE 754 binary16 floating points.

The result is the same as that of f16_add().

Parameters:
  • x – The floating point to be added.

  • y – The floating point to add.

Returns:

The resulted number (x + y).

classmethod div(cls, Float16 x, Float16 y) Float16

Divides the IEEE 754 binary16 floating points.

The result is the same as that of f16_div().

Parameters:
  • x – The floating point to be divided.

  • y – The floating point to divide.

Returns:

The resulted number (x / y).

classmethod eq(cls, Float16 x, Float16 y) bool

Tests if the first one is equal to the second one expressed as IEEE 754 binary16 floating points.

The result is the same as that of f16_eq().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is equal to the second one, False otherwise (x == y).

classmethod eq_signaling(cls, Float16 x, Float16 y) bool

Tests if the first one is equal to the second one expressed as IEEE 754 binary16 floating points.

The invalid exception flag is set for any NaN input, not just for signaling NaNs.

The result is the same as that of f16_eq_signaling().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is equal to the second one, False otherwise (x == y).

classmethod from_bytes(cls, bytes src) Float16

Creates a new instance from the specified byte sequence.

Parameters:

src – The byte sequence representing the native data with big endian. The length must be 2.

Returns:

A new instance created from the specified byte sequence.

Raises:

ValueError – If the length of bytes is not 2.

classmethod from_f128(cls, Float128 src) Float16

Creates a new instance from the specified IEEE 754 binary128 floating point.

The result is the same as that of f128_to_f16().

Parameters:

src – The IEEE 754 binary128 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary128 floating point.

classmethod from_f16(cls, Float16 src) Float16

Creates a new instance from the specified IEEE 754 binary16 floating point.

The result is a copy of the specified instance.

Parameters:

src – The IEEE 754 binary16 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary16 floating point.

classmethod from_f32(cls, Float32 src) Float16

Creates a new instance from the specified IEEE 754 binary32 floating point.

The result is the same as that of f32_to_f16().

Parameters:

src – The IEEE 754 binary32 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary32 floating point.

classmethod from_f64(cls, Float64 src) Float16

Creates a new instance from the specified IEEE 754 binary64 floating point.

The result is the same as that of f64_to_f16().

Parameters:

src – The IEEE 754 binary64 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary64 floating point.

classmethod from_float(cls, double src) Float16

Creates a new instance from the specified floating point.

Parameters:

src – The floating point from which a new instance is created.

Returns:

A new instance created from the specified floating point.

classmethod from_i32(cls, Int32 src) Float16

Creates a new instance from the specified 32-bit signed integer.

The result is the same as that of i32_to_f16().

Parameters:

src – The 32-bit signed integer from which a new instance is created.

Returns:

A new instance created from the specified 32-bit signed integer.

classmethod from_i64(cls, Int64 src) Float16

Creates a new instance from the specified 64-bit signed integer.

The result is the same as that of i64_to_f16().

Parameters:

src – The 64-bit signed integer from which a new instance is created.

Returns:

A new instance created from the specified 64-bit signed integer.

classmethod from_ui32(cls, UInt32 src) Float16

Creates a new instance from the specified 32-bit unsigned integer.

The result is the same as that of ui32_to_f16().

Parameters:

src – The 32-bit unsigned integer from which a new instance is created.

Returns:

A new instance created from the specified 32-bit unsigned integer.

classmethod from_ui64(cls, UInt64 src) Float16

Creates a new instance from the specified 64-bit unsigned integer.

The result is the same as that of ui64_to_f16().

Parameters:

src – The 64-bit unsigned integer from which a new instance is created.

Returns:

A new instance created from the specified 64-bit unsigned integer.

is_inf(self) bool

Tests if the IEEE 754 binary16 floating point is an infinity.

The result is the same as that of f16_is_inf().

Returns:

True if the floating point is an infinity, False otherwise.

is_nan(self) bool

Tests if the IEEE 754 binary16 floating point is a NaN.

The result is the same as that of f16_is_nan().

Returns:

True if the floating point is a NaN, False otherwise.

is_signaling_nan(self) bool

Tests if the IEEE 754 binary16 floating point is a signaling NaN.

The result is the same as that of f16_is_signaling_nan().

Returns:

True if the floating point is a signaling NaN, False otherwise.

classmethod le(cls, Float16 x, Float16 y) bool

Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary16 floating points.

The result is the same as that of f16_le().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than or equal to the second one, False otherwise (x <= y).

classmethod le_quiet(cls, Float16 x, Float16 y) bool

Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary16 floating points.

The invalid exception flag is not set for quiet NaNs.

The result is the same as that of f16_le_quiet().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than or equal to the second one, False otherwise (x <= y).

classmethod lt(cls, Float16 x, Float16 y) bool

Tests if the first one is less than the second one expressed as IEEE 754 binary16 floating points.

The result is the same as that of f16_lt().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than the second one, False otherwise (x < y).

classmethod lt_quiet(cls, Float16 x, Float16 y) bool

Tests if the first one is less than the second one expressed as IEEE 754 binary16 floating points.

The invalid exception flag is not set for quiet NaNs.

The result is the same as that of f16_lt_quiet().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than the second one, False otherwise (x < y).

classmethod mul(cls, Float16 x, Float16 y) Float16

Multiplies the IEEE 754 binary16 floating points.

The result is the same as that of f16_mul().

Parameters:
  • x – The floating point to be multiplied.

  • y – The floating point to multiply.

Returns:

The resulted number (x * y).

classmethod mul_add(cls, Float16 x, Float16 y, Float16 z) Float16

Multiplies and Adds the IEEE 754 binary16 floating points.

The result is the same as that of f16_mul_add().

Parameters:
  • x – The floating point to be multiplied.

  • y – The floating point to multiply.

  • z – The floating point to add.

Returns:

The resulted number (x * y + z).

neg(self) Float16

Negates the IEEE 754 binary16 floating point.

The result is the same as that of f16_neg().

Returns:

The resulted number (-x).

classmethod rem(cls, Float16 x, Float16 y) Float16

Calculates a remainder by dividing the IEEE 754 binary16 floating points.

The result is the same as that of f16_rem().

Parameters:
  • x – The floating point to be divided.

  • y – The floating point to divide.

Returns:

The resulted number (x % y).

round_to_int(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Float16

Rounds the number.

The result is the same as that of f16_round_to_int().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact rounding is unable.

Returns:

The resulted integer.

classmethod size(cls) int

Returns the native data size in bits.

Returns:

The native data size in bits, i.e. 16.

sqrt(self) Float16

Calculates a square root of the IEEE 754 binary16 floating point.

The result is the same as that of f16_sqrt().

Returns:

The resulted number (sqrt(x)).

classmethod sub(cls, Float16 x, Float16 y) Float16

Subtracts the IEEE 754 binary16 floating points.

The result is the same as that of f16_sub().

Parameters:
  • x – The floating point to be subtracted.

  • y – The floating point to subtract.

Returns:

The resulted number (x - y).

to_bytes(self) bytes

Returns the native data as a byte sequence.

Returns:

A byte sequence representing the native data with big endian. The length is 2.

to_f128(self) Float128

Converts the IEEE 754 binary16 floating point to a binary128 floating point.

The result is the same as that of f16_to_f128().

Returns:

The IEEE 754 binary128 floating point.

to_f16(self) Float16

Converts the IEEE 754 binary16 floating point to a binary16 floating point.

The result is a copy.

Returns:

The IEEE 754 binary16 floating point.

to_f32(self) Float32

Converts the IEEE 754 binary16 floating point to a binary32 floating point.

The result is the same as that of f16_to_f32().

Returns:

The IEEE 754 binary32 floating point.

to_f64(self) Float64

Converts the IEEE 754 binary16 floating point to a binary64 floating point.

The result is the same as that of f16_to_f64().

Returns:

The IEEE 754 binary64 floating point.

to_float(self) double

Returns the native data as a floating point.

Returns:

A floating point that represents the native data.

to_i32(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int32

Converts the IEEE 754 binary16 floating point to a 32-bit signed integer.

The result is the same as that of f16_to_i32().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 32-bit signed integer.

to_i64(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int64

Converts the IEEE 754 binary16 floating point to a 64-bit signed integer.

The result is the same as that of f16_to_i64().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 64-bit signed integer.

to_ui32(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt32

Converts the IEEE 754 binary16 floating point to a 32-bit unsigned integer.

The result is the same as that of f16_to_ui32().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 32-bit unsigned integer.

to_ui64(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt64

Converts the IEEE 754 binary16 floating point to a 64-bit unsigned integer.

The result is the same as that of f16_to_ui64().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 64-bit unsigned integer.

class simuhw.float.Float32

Bases: object

An IEEE 754 binary32 floating point.

The object is immutable.

The following operators are supported:

  • unary operators: +, -.

  • binary operators: +, -, *, /, //, %, <, <=, >, >=, ==, !=, +=, -=, *=, /=, //=, %=.

The following operators are unsupported:

  • unary operator: ~.

  • binary operators: <<, >>, &, |, ^, **, <<=, >>=, &=, |=, ^=, **=.

classmethod add(cls, Float32 x, Float32 y) Float32

Adds the IEEE 754 binary32 floating points.

The result is the same as that of f32_add().

Parameters:
  • x – The floating point to be added.

  • y – The floating point to add.

Returns:

The resulted number (x + y).

classmethod div(cls, Float32 x, Float32 y) Float32

Divides the IEEE 754 binary32 floating points.

The result is the same as that of f32_div().

Parameters:
  • x – The floating point to be divided.

  • y – The floating point to divide.

Returns:

The resulted number (x / y).

classmethod eq(cls, Float32 x, Float32 y) bool

Tests if the first one is equal to the second one expressed as IEEE 754 binary32 floating points.

The result is the same as that of f32_eq().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is equal to the second one, False otherwise (x == y).

classmethod eq_signaling(cls, Float32 x, Float32 y) bool

Tests if the first one is equal to the second one expressed as IEEE 754 binary32 floating points.

The invalid exception flag is set for any NaN input, not just for signaling NaNs.

The result is the same as that of f32_eq_signaling().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is equal to the second one, False otherwise (x == y).

classmethod from_bf16(cls, BFloat16 src) Float32

Creates a new instance from the 16-bit brain floating point.

The result is the same as that of bf16_to_f32().

Parameters:

src – The 16-bit brain floating point from which a new instance is created.

Returns:

A new instance created from the specified 16-bit brain floating point.

classmethod from_bytes(cls, bytes src) Float32

Creates a new instance from the specified byte sequence.

Parameters:

src – The byte sequence representing the native data with big endian. The length must be 4.

Returns:

A new instance created from the specified byte sequence.

Raises:

ValueError – If the length of bytes is not 4.

classmethod from_f128(cls, Float128 src) Float32

Creates a new instance from the specified IEEE 754 binary128 floating point.

The result is the same as that of f128_to_f32().

Parameters:

src – The IEEE 754 binary128 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary128 floating point.

classmethod from_f16(cls, Float16 src) Float32

Creates a new instance from the specified IEEE 754 binary16 floating point.

The result is the same as that of f16_to_f32().

Parameters:

src – The IEEE 754 binary16 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary16 floating point.

classmethod from_f32(cls, Float32 src) Float32

Creates a new instance from the specified IEEE 754 binary32 floating point.

The result is a copy of the specified instance.

Parameters:

src – The IEEE 754 binary32 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary32 floating point.

classmethod from_f64(cls, Float64 src) Float32

Creates a new instance from the specified IEEE 754 binary64 floating point.

The result is the same as that of f64_to_f32().

Parameters:

src – The IEEE 754 binary64 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary64 floating point.

classmethod from_float(cls, double src) Float32

Creates a new instance from the specified floating point.

Parameters:

src – The floating point from which a new instance is created.

Returns:

A new instance created from the specified floating point.

classmethod from_i32(cls, Int32 src) Float32

Creates a new instance from the specified 32-bit signed integer.

The result is the same as that of i32_to_f32().

Parameters:

src – The 32-bit signed integer from which a new instance is created.

Returns:

A new instance created from the specified 32-bit signed integer.

classmethod from_i64(cls, Int64 src) Float32

Creates a new instance from the specified 64-bit signed integer.

The result is the same as that of i64_to_f32().

Parameters:

src – The 64-bit signed integer from which a new instance is created.

Returns:

A new instance created from the specified 64-bit signed integer.

classmethod from_ui32(cls, UInt32 src) Float32

Creates a new instance from the specified 32-bit unsigned integer.

The result is the same as that of ui32_to_f32().

Parameters:

src – The 32-bit unsigned integer from which a new instance is created.

Returns:

A new instance created from the specified 32-bit unsigned integer.

classmethod from_ui64(cls, UInt64 src) Float32

Creates a new instance from the specified 64-bit unsigned integer.

The result is the same as that of ui64_to_f32().

Parameters:

src – The 64-bit unsigned integer from which a new instance is created.

Returns:

A new instance created from the specified 64-bit unsigned integer.

is_inf(self) bool

Tests if the IEEE 754 binary32 floating point is an infinity.

The result is the same as that of f32_is_inf().

Returns:

True if the floating point is an infinity, False otherwise.

is_nan(self) bool

Tests if the IEEE 754 binary32 floating point is a NaN.

The result is the same as that of f32_is_nan().

Returns:

True if the floating point is a NaN, False otherwise.

is_signaling_nan(self) bool

Tests if the IEEE 754 binary32 floating point is a signaling NaN.

The result is the same as that of f32_is_signaling_nan().

Returns:

True if the floating point is a signaling NaN, False otherwise.

classmethod le(cls, Float32 x, Float32 y) bool

Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary32 floating points.

The result is the same as that of f32_le().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than or equal to the second one, False otherwise (x <= y).

classmethod le_quiet(cls, Float32 x, Float32 y) bool

Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary32 floating points.

The invalid exception flag is not set for quiet NaNs.

The result is the same as that of f32_le_quiet().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than or equal to the second one, False otherwise (x <= y).

classmethod lt(cls, Float32 x, Float32 y) bool

Tests if the first one is less than the second one expressed as IEEE 754 binary32 floating points.

The result is the same as that of f32_lt().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than the second one, False otherwise (x < y).

classmethod lt_quiet(cls, Float32 x, Float32 y) bool

Tests if the first one is less than the second one expressed as IEEE 754 binary32 floating points.

The invalid exception flag is not set for quiet NaNs.

The result is the same as that of f32_lt_quiet().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than the second one, False otherwise (x < y).

classmethod mul(cls, Float32 x, Float32 y) Float32

Multiplies the IEEE 754 binary32 floating points.

The result is the same as that of f32_mul().

Parameters:
  • x – The floating point to be multiplied.

  • y – The floating point to multiply.

Returns:

The resulted number (x * y).

classmethod mul_add(cls, Float32 x, Float32 y, Float32 z) Float32

Multiplies and Adds the IEEE 754 binary32 floating points.

The result is the same as that of f32_mul_add().

Parameters:
  • x – The floating point to be multiplied.

  • y – The floating point to multiply.

  • z – The floating point to add.

Returns:

The resulted number (x * y + z).

neg(self) Float32

Negates the IEEE 754 binary32 floating point.

The result is the same as that of f32_neg().

Returns:

The resulted number (-x).

classmethod rem(cls, Float32 x, Float32 y) Float32

Calculates a remainder by dividing the IEEE 754 binary32 floating points.

The result is the same as that of f32_rem().

Parameters:
  • x – The floating point to be divided.

  • y – The floating point to divide.

Returns:

The resulted number (x % y).

round_to_int(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Float32

Rounds the number.

The result is the same as that of f32_round_to_int().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact rounding is unable.

Returns:

The resulted integer.

classmethod size(cls) int

Returns the native data size in bits.

Returns:

The native data size in bits, i.e. 32.

sqrt(self) Float32

Calculates a square root of the IEEE 754 binary32 floating point.

The result is the same as that of f32_sqrt().

Returns:

The resulted number (sqrt(x)).

classmethod sub(cls, Float32 x, Float32 y) Float32

Subtracts the IEEE 754 binary32 floating points.

The result is the same as that of f32_sub().

Parameters:
  • x – The floating point to be subtracted.

  • y – The floating point to subtract.

Returns:

The resulted number (x - y).

to_bf16(self) BFloat16

Converts the IEEE 754 binary32 floating point to a 16-bit brain floating point.

The result is the same as that of f32_to_bf16().

Returns:

The 16-bit brain floating point.

to_bytes(self) bytes

Returns the native data as a byte sequence.

Returns:

A byte sequence representing the native data with big endian. The length is 4.

to_f128(self) Float128

Converts the IEEE 754 binary32 floating point to a binary128 floating point.

The result is the same as that of f32_to_f128().

Returns:

The IEEE 754 binary128 floating point.

to_f16(self) Float16

Converts the IEEE 754 binary32 floating point to a binary16 floating point.

The result is the same as that of f32_to_f16().

Returns:

The IEEE 754 binary16 floating point.

to_f32(self) Float32

Converts the IEEE 754 binary32 floating point to a binary32 floating point.

The result is a copy.

Returns:

The IEEE 754 binary32 floating point.

to_f64(self) Float64

Converts the IEEE 754 binary32 floating point to a binary64 floating point.

The result is the same as that of f32_to_f64().

Returns:

The IEEE 754 binary64 floating point.

to_float(self) double

Returns the native data as a floating point.

Returns:

A floating point that represents the native data.

to_i32(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int32

Converts the IEEE 754 binary32 floating point to a 32-bit signed integer.

The result is the same as that of f32_to_i32().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 32-bit signed integer.

to_i64(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int64

Converts the IEEE 754 binary32 floating point to a 64-bit signed integer.

The result is the same as that of f32_to_i64().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 64-bit signed integer.

to_ui32(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt32

Converts the IEEE 754 binary32 floating point to a 32-bit unsigned integer.

The result is the same as that of f32_to_ui32().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 32-bit unsigned integer.

to_ui64(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt64

Converts the IEEE 754 binary32 floating point to a 64-bit unsigned integer.

The result is the same as that of f32_to_ui64().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 64-bit unsigned integer.

class simuhw.float.Float64

Bases: object

An IEEE 754 binary64 floating point.

The object is immutable.

The following operators are supported:

  • unary operators: +, -.

  • binary operators: +, -, *, /, //, %, <, <=, >, >=, ==, !=, +=, -=, *=, /=, //=, %=.

The following operators are unsupported:

  • unary operator: ~.

  • binary operators: <<, >>, &, |, ^, **, <<=, >>=, &=, |=, ^=, **=.

classmethod add(cls, Float64 x, Float64 y) Float64

Adds the IEEE 754 binary64 floating points.

The result is the same as that of f64_add().

Parameters:
  • x – The floating point to be added.

  • y – The floating point to add.

Returns:

The resulted number (x + y).

classmethod div(cls, Float64 x, Float64 y) Float64

Divides the IEEE 754 binary64 floating points.

The result is the same as that of f64_div().

Parameters:
  • x – The floating point to be divided.

  • y – The floating point to divide.

Returns:

The resulted number (x / y).

classmethod eq(cls, Float64 x, Float64 y) bool

Tests if the first one is equal to the second one expressed as IEEE 754 binary64 floating points.

The result is the same as that of f64_eq().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is equal to the second one, False otherwise (x == y).

classmethod eq_signaling(cls, Float64 x, Float64 y) bool

Tests if the first one is equal to the second one expressed as IEEE 754 binary64 floating points.

The invalid exception flag is set for any NaN input, not just for signaling NaNs.

The result is the same as that of f64_eq_signaling().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is equal to the second one, False otherwise (x == y).

classmethod from_bytes(cls, bytes src) Float64

Creates a new instance from the specified byte sequence.

Parameters:

src – The byte sequence representing the native data with big endian. The length must be 8.

Returns:

A new instance created from the specified byte sequence.

Raises:

ValueError – If the length of bytes is not 8.

classmethod from_f128(cls, Float128 src) Float64

Creates a new instance from the specified IEEE 754 binary128 floating point.

The result is the same as that of f128_to_f64().

Parameters:

src – The IEEE 754 binary128 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary128 floating point.

classmethod from_f16(cls, Float16 src) Float64

Creates a new instance from the specified IEEE 754 binary16 floating point.

The result is the same as that of f16_to_f64().

Parameters:

src – The IEEE 754 binary16 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary16 floating point.

classmethod from_f32(cls, Float32 src) Float64

Creates a new instance from the specified IEEE 754 binary32 floating point.

The result is the same as that of f32_to_f64().

Parameters:

src – The IEEE 754 binary32 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary32 floating point.

classmethod from_f64(cls, Float64 src) Float64

Creates a new instance from the specified IEEE 754 binary64 floating point.

The result is a copy of the specified instance.

Parameters:

src – The IEEE 754 binary64 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary64 floating point.

classmethod from_float(cls, double src) Float64

Creates a new instance from the specified floating point.

Parameters:

src – The floating point from which a new instance is created.

Returns:

A new instance created from the specified floating point.

classmethod from_i32(cls, Int32 src) Float64

Creates a new instance from the specified 32-bit signed integer.

The result is the same as that of i32_to_f64().

Parameters:

src – The 32-bit signed integer from which a new instance is created.

Returns:

A new instance created from the specified 32-bit signed integer.

classmethod from_i64(cls, Int64 src) Float64

Creates a new instance from the specified 64-bit signed integer.

The result is the same as that of i64_to_f64().

Parameters:

src – The 64-bit signed integer from which a new instance is created.

Returns:

A new instance created from the specified 64-bit signed integer.

classmethod from_ui32(cls, UInt32 src) Float64

Creates a new instance from the specified 32-bit unsigned integer.

The result is the same as that of ui32_to_f64().

Parameters:

src – The 32-bit unsigned integer from which a new instance is created.

Returns:

A new instance created from the specified 32-bit unsigned integer.

classmethod from_ui64(cls, UInt64 src) Float64

Creates a new instance from the specified 64-bit unsigned integer.

The result is the same as that of ui64_to_f64().

Parameters:

src – The 64-bit unsigned integer from which a new instance is created.

Returns:

A new instance created from the specified 64-bit unsigned integer.

is_inf(self) bool

Tests if the IEEE 754 binary64 floating point is an infinity.

The result is the same as that of f64_is_inf().

Returns:

True if the floating point is an infinity, False otherwise.

is_nan(self) bool

Tests if the IEEE 754 binary64 floating point is a NaN.

The result is the same as that of f64_is_nan().

Returns:

True if the floating point is a NaN, False otherwise.

is_signaling_nan(self) bool

Tests if the IEEE 754 binary64 floating point is a signaling NaN.

The result is the same as that of f64_is_signaling_nan().

Returns:

True if the floating point is a signaling NaN, False otherwise.

classmethod le(cls, Float64 x, Float64 y) bool

Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary64 floating points.

The result is the same as that of f64_le().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than or equal to the second one, False otherwise (x <= y).

classmethod le_quiet(cls, Float64 x, Float64 y) bool

Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary64 floating points.

The invalid exception flag is not set for quiet NaNs.

The result is the same as that of f64_le_quiet().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than or equal to the second one, False otherwise (x <= y).

classmethod lt(cls, Float64 x, Float64 y) bool

Tests if the first one is less than the second one expressed as IEEE 754 binary64 floating points.

The result is the same as that of f64_lt().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than the second one, False otherwise (x < y).

classmethod lt_quiet(cls, Float64 x, Float64 y) bool

Tests if the first one is less than the second one expressed as IEEE 754 binary64 floating points.

The invalid exception flag is not set for quiet NaNs.

The result is the same as that of f64_lt_quiet().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than the second one, False otherwise (x < y).

classmethod mul(cls, Float64 x, Float64 y) Float64

Multiplies the IEEE 754 binary64 floating points.

The result is the same as that of f64_mul().

Parameters:
  • x – The floating point to be multiplied.

  • y – The floating point to multiply.

Returns:

The resulted number (x * y).

classmethod mul_add(cls, Float64 x, Float64 y, Float64 z) Float64

Multiplies and Adds the IEEE 754 binary64 floating points.

The result is the same as that of f64_mul_add().

Parameters:
  • x – The floating point to be multiplied.

  • y – The floating point to multiply.

  • z – The floating point to add.

Returns:

The resulted number (x * y + z).

neg(self) Float64

Negates the IEEE 754 binary64 floating point.

The result is the same as that of f64_neg().

Returns:

The resulted number (-x).

classmethod rem(cls, Float64 x, Float64 y) Float64

Calculates a remainder by dividing the IEEE 754 binary64 floating points.

The result is the same as that of f64_rem().

Parameters:
  • x – The floating point to be divided.

  • y – The floating point to divide.

Returns:

The resulted number (x % y).

round_to_int(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Float64

Rounds the number.

The result is the same as that of f64_round_to_int().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact rounding is unable.

Returns:

The resulted integer.

classmethod size(cls) int

Returns the native data size in bits.

Returns:

The native data size in bits, i.e. 64.

sqrt(self) Float64

Calculates a square root of the IEEE 754 binary64 floating point.

The result is the same as that of f64_sqrt().

Returns:

The resulted number (sqrt(x)).

classmethod sub(cls, Float64 x, Float64 y) Float64

Subtracts the IEEE 754 binary64 floating points.

The result is the same as that of f64_sub().

Parameters:
  • x – The floating point to be subtracted.

  • y – The floating point to subtract.

Returns:

The resulted number (x - y).

to_bytes(self) bytes

Returns the native data as a byte sequence.

Returns:

A byte sequence representing the native data with big endian. The length is 8.

to_f128(self) Float128

Converts the IEEE 754 binary64 floating point to a binary128 floating point.

The result is the same as that of f64_to_f128().

Returns:

The IEEE 754 binary128 floating point.

to_f16(self) Float16

Converts the IEEE 754 binary64 floating point to a binary16 floating point.

The result is the same as that of f64_to_f16().

Returns:

The IEEE 754 binary16 floating point.

to_f32(self) Float32

Converts the IEEE 754 binary64 floating point to a binary32 floating point.

The result is the same as that of f64_to_f32().

Returns:

The IEEE 754 binary32 floating point.

to_f64(self) Float64

Converts the IEEE 754 binary64 floating point to a binary64 floating point.

The result is a copy.

Returns:

The IEEE 754 binary64 floating point.

to_float(self) double

Returns the native data as a floating point.

Returns:

A floating point that represents the native data.

to_i32(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int32

Converts the IEEE 754 binary64 floating point to a 32-bit signed integer.

The result is the same as that of f64_to_i32().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 32-bit signed integer.

to_i64(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int64

Converts the IEEE 754 binary64 floating point to a 64-bit signed integer.

The result is the same as that of f64_to_i64().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 64-bit signed integer.

to_ui32(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt32

Converts the IEEE 754 binary64 floating point to a 32-bit unsigned integer.

The result is the same as that of f64_to_ui32().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 32-bit unsigned integer.

to_ui64(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt64

Converts the IEEE 754 binary64 floating point to a 64-bit unsigned integer.

The result is the same as that of f64_to_ui64().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 64-bit unsigned integer.

class simuhw.float.Float128

Bases: object

An IEEE 754 binary128 floating point.

The object is immutable.

The following operators are supported:

  • unary operators: +, -.

  • binary operators: +, -, *, /, //, %, <, <=, >, >=, ==, !=, +=, -=, *=, /=, //=, %=.

The following operators are unsupported:

  • unary operator: ~.

  • binary operators: <<, >>, &, |, ^, **, <<=, >>=, &=, |=, ^=, **=.

Note

Currently, cannot represent the exact number as a string if the number is unable to be expressed as an IEEE 754 binary64 floating point.

classmethod add(cls, Float128 x, Float128 y) Float128

Adds the IEEE 754 binary128 floating points.

The result is the same as that of f128_add().

Parameters:
  • x – The floating point to be added.

  • y – The floating point to add.

Returns:

The resulted number (x + y).

classmethod div(cls, Float128 x, Float128 y) Float128

Divides the IEEE 754 binary128 floating points.

The result is the same as that of f128_div().

Parameters:
  • x – The floating point to be divided.

  • y – The floating point to divide.

Returns:

The resulted number (x / y).

classmethod eq(cls, Float128 x, Float128 y) bool

Tests if the first one is equal to the second one expressed as IEEE 754 binary128 floating points.

The result is the same as that of f128_eq().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is equal to the second one, False otherwise (x == y).

classmethod eq_signaling(cls, Float128 x, Float128 y) bool

Tests if the first one is equal to the second one expressed as IEEE 754 binary128 floating points.

The invalid exception flag is set for any NaN input, not just for signaling NaNs.

The result is the same as that of f128_eq_signaling().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is equal to the second one, False otherwise (x == y).

classmethod from_bytes(cls, bytes src) Float128

Creates a new instance from the specified byte sequence.

Parameters:

src – The byte sequence representing the native data with big endian. The length must be 16.

Returns:

A new instance created from the specified byte sequence.

Raises:

ValueError – If the length of bytes is not 16.

classmethod from_f128(cls, Float128 src) Float128

Creates a new instance from the specified IEEE 754 binary128 floating point.

The result is a copy of the specified instance.

Parameters:

src – The IEEE 754 binary128 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary128 floating point.

classmethod from_f16(cls, Float16 src) Float128

Creates a new instance from the specified IEEE 754 binary16 floating point.

The result is the same as that of f16_to_f128().

Parameters:

src – The IEEE 754 binary16 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary16 floating point.

classmethod from_f32(cls, Float32 src) Float128

Creates a new instance from the specified IEEE 754 binary32 floating point.

The result is the same as that of f32_to_f128().

Parameters:

src – The IEEE 754 binary32 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary32 floating point.

classmethod from_f64(cls, Float64 src) Float128

Creates a new instance from the specified IEEE 754 binary64 floating point.

The result is the same as that of f64_to_f128().

Parameters:

src – The IEEE 754 binary64 floating point from which a new instance is created.

Returns:

A new instance created from the specified IEEE 754 binary64 floating point.

classmethod from_float(cls, double src) Float128

Creates a new instance from the specified floating point.

Parameters:

src – The floating point from which a new instance is created.

Returns:

A new instance created from the specified floating point.

Note

Cannot create an instance with a number that an IEEE 754 binary64 floating point is unable to express.

classmethod from_i32(cls, Int32 src) Float128

Creates a new instance from the specified 32-bit signed integer.

The result is the same as that of i32_to_f128().

Parameters:

src – The 32-bit signed integer from which a new instance is created.

Returns:

A new instance created from the specified 32-bit signed integer.

classmethod from_i64(cls, Int64 src) Float128

Creates a new instance from the specified 64-bit signed integer.

The result is the same as that of i64_to_f128().

Parameters:

src – The 64-bit signed integer from which a new instance is created.

Returns:

A new instance created from the specified 64-bit signed integer.

classmethod from_ui32(cls, UInt32 src) Float128

Creates a new instance from the specified 32-bit unsigned integer.

The result is the same as that of ui32_to_f128().

Parameters:

src – The 32-bit unsigned integer from which a new instance is created.

Returns:

A new instance created from the specified 32-bit unsigned integer.

classmethod from_ui64(cls, UInt64 src) Float128

Creates a new instance from the specified 64-bit unsigned integer.

The result is the same as that of ui64_to_f128().

Parameters:

src – The 64-bit unsigned integer from which a new instance is created.

Returns:

A new instance created from the specified 64-bit unsigned integer.

is_inf(self) bool

Tests if the IEEE 754 binary128 floating point is an infinity.

The result is the same as that of f128_is_inf().

Returns:

True if the floating point is an infinity, False otherwise.

is_nan(self) bool

Tests if the IEEE 754 binary128 floating point is a NaN.

The result is the same as that of f128_is_nan().

Returns:

True if the floating point is a NaN, False otherwise.

is_signaling_nan(self) bool

Tests if the IEEE 754 binary128 floating point is a signaling NaN.

The result is the same as that of f128_is_signaling_nan().

Returns:

True if the floating point is a signaling NaN, False otherwise.

classmethod le(cls, Float128 x, Float128 y) bool

Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary128 floating points.

The result is the same as that of f128_le().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than or equal to the second one, False otherwise (x <= y).

classmethod le_quiet(cls, Float128 x, Float128 y) bool

Tests if the first one is less than or equal to the second one expressed as IEEE 754 binary128 floating points.

The invalid exception flag is not set for quiet NaNs.

The result is the same as that of f128_le_quiet().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than or equal to the second one, False otherwise (x <= y).

classmethod lt(cls, Float128 x, Float128 y) bool

Tests if the first one is less than the second one expressed as IEEE 754 binary128 floating points.

The result is the same as that of f128_lt().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than the second one, False otherwise (x < y).

classmethod lt_quiet(cls, Float128 x, Float128 y) bool

Tests if the first one is less than the second one expressed as IEEE 754 binary128 floating points.

The invalid exception flag is not set for quiet NaNs.

The result is the same as that of f128_lt_quiet().

Parameters:
  • x – The first floating point to be compared.

  • y – The second floating point to be compared.

Returns:

True if the first one is less than the second one, False otherwise (x < y).

classmethod mul(cls, Float128 x, Float128 y) Float128

Multiplies the IEEE 754 binary128 floating points.

The result is the same as that of f128_mul().

Parameters:
  • x – The floating point to be multiplied.

  • y – The floating point to multiply.

Returns:

The resulted number (x * y).

classmethod mul_add(cls, Float128 x, Float128 y, Float128 z) Float128

Multiplies and Adds the IEEE 754 binary128 floating points.

The result is the same as that of f128_mul_add().

Parameters:
  • x – The floating point to be multiplied.

  • y – The floating point to multiply.

  • z – The floating point to add.

Returns:

The resulted number (x * y + z).

neg(self) Float128

Negates the IEEE 754 binary128 floating point.

The result is the same as that of f128_neg().

Returns:

The resulted number (-x).

classmethod rem(cls, Float128 x, Float128 y) Float128

Calculates a remainder by dividing the IEEE 754 binary128 floating points.

The result is the same as that of f128_rem().

Parameters:
  • x – The floating point to be divided.

  • y – The floating point to divide.

Returns:

The resulted number (x % y).

round_to_int(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Float128

Rounds the number.

The result is the same as that of f128_round_to_int().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact rounding is unable.

Returns:

The resulted integer.

classmethod size(cls) int

Returns the native data size in bits.

Returns:

The native data size in bits, i.e. 128.

sqrt(self) Float128

Calculates a square root of the IEEE 754 binary128 floating point.

The result is the same as that of f128_sqrt().

Returns:

The resulted number (sqrt(x)).

classmethod sub(cls, Float128 x, Float128 y) Float128

Subtracts the IEEE 754 binary128 floating points.

The result is the same as that of f128_sub().

Parameters:
  • x – The floating point to be subtracted.

  • y – The floating point to subtract.

Returns:

The resulted number (x - y).

to_bytes(self) bytes

Returns the native data as a byte sequence.

Returns:

A byte sequence representing the native data with big endian. The length is 16.

to_f128(self) Float128

Converts the IEEE 754 binary128 floating point to a binary128 floating point.

The result is a copy.

Returns:

The IEEE 754 binary128 floating point.

to_f16(self) Float16

Converts the IEEE 754 binary128 floating point to a binary16 floating point.

The result is the same as that of f128_to_f16().

Returns:

The IEEE 754 binary16 floating point.

to_f32(self) Float32

Converts the IEEE 754 binary128 floating point to a binary32 floating point.

The result is the same as that of f128_to_f32().

Returns:

The IEEE 754 binary32 floating point.

to_f64(self) Float64

Converts the IEEE 754 binary128 floating point to a binary64 floating point.

The result is the same as that of f128_to_f64().

Returns:

The IEEE 754 binary64 floating point.

to_float(self) double

Returns the native data as a floating point.

Returns:

A floating point that represents the native data.

Note

Cannot return the exact number if it is unable to be expressed as an IEEE 754 binary64 floating point.

to_i32(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int32

Converts the IEEE 754 binary128 floating point to a 32-bit signed integer.

The result is the same as that of f128_to_i32().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 32-bit signed integer.

to_i64(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) Int64

Converts the IEEE 754 binary128 floating point to a 64-bit signed integer.

The result is the same as that of f128_to_i64().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 64-bit signed integer.

to_ui32(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt32

Converts the IEEE 754 binary128 floating point to a 32-bit unsigned integer.

The result is the same as that of f128_to_ui32().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 32-bit unsigned integer.

to_ui64(self, RoundingMode rounding_mode=get_rounding_mode(), bool exact=True) UInt64

Converts the IEEE 754 binary128 floating point to a 64-bit unsigned integer.

The result is the same as that of f128_to_ui64().

Parameters:
  • rounding_mode – The rounding mode.

  • exact – If True is specified, the floating-point exception flags are to be set when exact conversion is unable.

Returns:

The 64-bit unsigned integer.

simuhw.float.set_tininess_mode(TininessMode mode) void

Sets the tininess detection mode.

Parameters:

mode – The tininess detection mode to be set.

simuhw.float.get_tininess_mode() TininessMode

Returns the current tininess detection mode.

Returns:

The current tininess detection mode.

simuhw.float.set_rounding_mode(RoundingMode mode) void

Sets the rounding mode.

Parameters:

mode – The rounding mode to be set.

simuhw.float.get_rounding_mode() RoundingMode

Returns the current rounding mode.

Returns:

The current rounding mode.

simuhw.float.set_exception_flags(flags) void

Sets the floating-point exception flags.

Parameters:

flags – The floating-point exception flags to be set.

simuhw.float.get_exception_flags()

Returns the current floating-point exception flags.

Returns:

The current floating-point exception flags.

simuhw.float.test_exception_flags(flags) bool

Tests the floating-point exception flags.

Parameters:

flags – The floating-point exception flags to be tested.

Returns:

True if any of the specified exception flags is nonzero, False otherwise.

class simuhw.float.FPState

Bases: object

A class that manipulates the floating-point states.

__init__() None

Creates a class that manipulates the floating-point states.

apply_states() None

Applies the floating-point states from the input ports after saving the current ones.

property port_fe_i: InputPort

The input port to set the floating-point exception flags.

property port_fe_o: OutputPort

The output port to get the floating-point exception flags.

property port_fr: InputPort

The input port to set the rounding mode.

property port_ft: InputPort

The input port to set the tininess detection mode.

reset() None

Resets the states.

restore_states(time: float, none: bool) None

Restores the floating-point states after posting the current ones to the output port.

Parameters:

time – The current device time in seconds.

width_fe: int = 5

The bit width of the input and output ports to set and get floating-point exception flags.

width_fr: int = 3

The bit width of the input port to set rounding mode.

width_ft: int = 1

The bit width of the input port to set tininess detection mode.

class simuhw.float.FPUnaryOperator(dtype: type[Float16 | Float32 | Float64 | Float128])

Bases: UnaryOperator, FPState

The super class for all floating-point unary operators.

__init__(dtype: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point unary operators.

Parameters:

dtype – The floating-point type.

reset() None

Resets the states.

class simuhw.float.FPBinaryOperator(dtype: type[Float16 | Float32 | Float64 | Float128])

Bases: BinaryOperator, FPState

The super class for all floating-point binary operators.

__init__(dtype: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point binary operators.

Parameters:

dtype – The floating-point type.

reset() None

Resets the states.

class simuhw.float.FPTernaryOperator(dtype: type[Float16 | Float32 | Float64 | Float128])

Bases: TernaryOperator, FPState

The super class for all floating-point ternary operators.

__init__(dtype: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point ternary operators.

Parameters:

dtype – The floating-point type.

reset() None

Resets the states.

class simuhw.float.SIMD_FPUnaryOperator(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]])

Bases: SIMD_UnaryOperator, FPState

The super class for all SIMD floating-point unary operators.

__init__(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]]) None

Creates a SIMD floating-point unary operators.

Parameters:
  • width – The data word width in bits.

  • dtype – The selectable floating-point type or types.

reset() None

Resets the states.

class simuhw.float.SIMD_FPBinaryOperator(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]])

Bases: SIMD_BinaryOperator, FPState

The super class for all SIMD floating-point binary operators.

__init__(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]]) None

Creates a SIMD floating-point binary operators.

Parameters:
  • width – The data word width in bits.

  • dtype – The selectable floating-point type or types.

reset() None

Resets the states.

class simuhw.float.SIMD_FPTernaryOperator(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]])

Bases: SIMD_TernaryOperator, FPState

The super class for all SIMD floating-point ternary operators.

__init__(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]]) None

Creates a SIMD floating-point ternary operators.

Parameters:
  • width – The data word width in bits.

  • dtype – The selectable floating-point type or types.

reset() None

Resets the states.

class simuhw.float.FPNegator(dtype: type[Float16 | Float32 | Float64 | Float128])

Bases: FPUnaryOperator

A floating-point negator.

This device negates the floating-point value.

Available only if an appropriate version of softfloatpy module is found.

__init__(dtype: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point negator.

Parameters:

dtype – The floating-point type.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPNegator(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]])

Bases: SIMD_FPUnaryOperator

A SIMD floating-point negator.

This device negates the respective sign of multiple floating-point values simultaneously.

Available only if an appropriate version of softfloatpy module is found.

__init__(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]]) None

Creates a SIMD floating-point negator.

Parameters:
  • width – The data word width in bits.

  • dtype – The selectable floating-point type or types.

Raises:

ValueError – If width is not divisible by any of dtype sizes.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPAdder(dtype: type[Float16 | Float32 | Float64 | Float128])

Bases: FPBinaryOperator

A floating-point adder.

This device calculates an addition of two floating-point values.

Available only if an appropriate version of softfloatpy module is found.

__init__(dtype: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point adder.

Parameters:

dtype – The floating-point type.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPAdder(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]])

Bases: SIMD_FPBinaryOperator

A SIMD floating-point adder.

This device calculates respective additions of multiple pairs of floating-point values simultaneously.

Available only if an appropriate version of softfloatpy module is found.

__init__(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]]) None

Creates a SIMD floating-point adder.

Parameters:
  • width – The data word width in bits.

  • dtype – The selectable floating-point type or types.

Raises:

ValueError – If width is not divisible by any of dtype sizes.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPSubtractor(dtype: type[Float16 | Float32 | Float64 | Float128])

Bases: FPBinaryOperator

A floating-point subtractor.

This device calculates a subtraction of two floating-point values.

Available only if an appropriate version of softfloatpy module is found.

__init__(dtype: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point subtractor.

Parameters:

dtype – The floating-point type.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPSubtractor(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]])

Bases: SIMD_FPBinaryOperator

A SIMD floating-point subtractor.

This device calculates respective subtractions of multiple pairs of floating-point values simultaneously.

Available only if an appropriate version of softfloatpy module is found.

__init__(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]]) None

Creates a SIMD floating-point subtractor.

Parameters:
  • width – The data word width in bits.

  • dtype – The selectable floating-point type or types.

Raises:

ValueError – If width is not divisible by any of dtype sizes.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPMultiplier(dtype: type[Float16 | Float32 | Float64 | Float128])

Bases: FPBinaryOperator

A floating-point multiplier.

This device calculates a multiplication of two floating-point values.

Available only if an appropriate version of softfloatpy module is found.

__init__(dtype: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point multiplier.

Parameters:

dtype – The floating-point type.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPMultiplier(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]])

Bases: SIMD_FPBinaryOperator

A SIMD floating-point multiplier.

This device calculates respective multiplications of multiple pairs of floating-point values simultaneously.

Available only if an appropriate version of softfloatpy module is found.

__init__(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]]) None

Creates a SIMD floating-point multiplier.

Parameters:
  • width – The data word width in bits.

  • dtype – The selectable floating-point type or types.

Raises:

ValueError – If width is not divisible by any of dtype sizes.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPMultiplyAdder(dtype: type[Float16 | Float32 | Float64 | Float128])

Bases: FPTernaryOperator

A floating-point fused multiply-adder.

This device calculates a fused multiply-add of three floating-point values (x * y + z).

Available only if an appropriate version of softfloatpy module is found.

__init__(dtype: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point fused multiply-adder.

Parameters:

dtype – The floating-point type.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPMultiplyAdder(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]])

Bases: SIMD_FPTernaryOperator

A SIMD floating-point fused multiply-adder.

This device calculates respective fused multiply-add of multiple couples of floating-point values simultaneously (x * y + z).

Available only if an appropriate version of softfloatpy module is found.

__init__(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]]) None

Creates a SIMD floating-point fused multiply-adder.

Parameters:
  • width – The data word width in bits.

  • dtype – The selectable floating-point type or types.

Raises:

ValueError – If width is not divisible by any of dtype sizes.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPDivider(dtype: type[Float16 | Float32 | Float64 | Float128])

Bases: FPBinaryOperator

A floating-point divider.

This device calculates a division of two floating-point values.

Available only if an appropriate version of softfloatpy module is found.

__init__(dtype: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point divider.

Parameters:

dtype – The floating-point type.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPDivider(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]])

Bases: SIMD_FPBinaryOperator

A SIMD floating-point divider.

This device calculates respective divisions of multiple pairs of floating-point values simultaneously.

Available only if an appropriate version of softfloatpy module is found.

__init__(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]]) None

Creates a SIMD floating-point divider.

Parameters:
  • width – The data word width in bits.

  • dtype – The selectable floating-point type or types.

Raises:

ValueError – If width is not divisible by any of dtype sizes.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPRemainder(dtype: type[Float16 | Float32 | Float64 | Float128])

Bases: FPBinaryOperator

A floating-point remainder calculator.

This device calculates a remainder of two floating-point values.

Available only if an appropriate version of softfloatpy module is found.

__init__(dtype: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point remainder calculator.

Parameters:

dtype – The floating-point type.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPRemainder(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]])

Bases: SIMD_FPBinaryOperator

A SIMD floating-point remainder calculator.

This device calculates respective remainders of multiple pairs of floating-point values simultaneously.

Available only if an appropriate version of softfloatpy module is found.

__init__(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]]) None

Creates a SIMD floating-point remainder calculator.

Parameters:
  • width – The data word width in bits.

  • dtype – The selectable floating-point type or types.

Raises:

ValueError – If width is not divisible by any of dtype sizes.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPSquareRoot(dtype: type[Float16 | Float32 | Float64 | Float128])

Bases: FPUnaryOperator

A floating-point square root calculator.

This device calculates the square root of the floating-point value.

Available only if an appropriate version of softfloatpy module is found.

__init__(dtype: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point square root calculator.

Parameters:

dtype – The floating-point type.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPSquareRoot(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]])

Bases: SIMD_FPUnaryOperator

A SIMD floating-point square root calculator.

This device calculates the respective square root of multiple floating-point values simultaneously.

Available only if an appropriate version of softfloatpy module is found.

__init__(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]]) None

Creates a SIMD floating-point square root calculator.

Parameters:
  • width – The data word width in bits.

  • dtype – The selectable floating-point type or types.

Raises:

ValueError – If width is not divisible by any of dtype sizes.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPComparator(dtype: type[Float16 | Float32 | Float64 | Float128])

Bases: FPBinaryOperator

A floating-point comparator.

This device compares two floating-point values. The result is an integer -1 if the first value is less than the second one, 1 if the first value is greater than the second one, or 0 otherwise. The result integer has the same number of bits as the input floating-points.

Available only if an appropriate version of softfloatpy module is found.

__init__(dtype: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point comparator.

Parameters:

dtype – The floating-point type.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPComparator(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]])

Bases: SIMD_FPBinaryOperator

A SIMD floating-point comparator.

This device compares multiple respective pairs of floating-point values simultaneously. Each result is an integer -1 if the first value is less than the second one, 1 if the first value is greater than the second one, or 0 otherwise. Each result integer has the same number of bits as the input floating-points.

Available only if an appropriate version of softfloatpy module is found.

__init__(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]]) None

Creates a SIMD floating-point comparator.

Parameters:
  • width – The data word width in bits.

  • dtype – The selectable floating-point type or types.

Raises:

ValueError – If width is not divisible by any of dtype sizes.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPClassifier(dtype: type[Float16 | Float32 | Float64 | Float128])

Bases: FPUnaryOperator

A floating-point classifier.

This device classifies the floating-point value. The result is an integer 1 if the value is an infinity, 2 if the value is a signaling NaN, 3 if the value is a quiet NaN, or 0 otherwise. The result integer has the same number of bits as the input floating-points.

Available only if an appropriate version of softfloatpy module is found.

__init__(dtype: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point classifier.

Parameters:

dtype – The floating-point type.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPClassifier(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]])

Bases: SIMD_FPUnaryOperator

A SIMD floating-point classifier.

This device classifies multiple respective floating-point values simultaneously. Each result is an integer 1 if the value is an infinity, 2 if the value is a signaling NaN, 3 if the value is a quiet NaN, or 0 otherwise. Each result integer has the same number of bits as the input floating-points.

Available only if an appropriate version of softfloatpy module is found.

__init__(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]]) None

Creates a SIMD floating-point classifier.

Parameters:
  • width – The data word width in bits.

  • dtype – The selectable floating-point type or types.

Raises:

ValueError – If width is not divisible by any of dtype sizes.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPToIntegerRounder(dtype: type[Float16 | Float32 | Float64 | Float128])

Bases: FPUnaryOperator

A floating-point to integer rounder.

This device rounds the floating-point value to an integer value as the same floating-point type.

Available only if an appropriate version of softfloatpy module is found.

__init__(dtype: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point to integer rounder.

Parameters:

dtype – The floating-point type.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPToIntegerRounder(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]])

Bases: SIMD_FPUnaryOperator

A SIMD floating-point to integer rounder.

This device rounds the respective floating-point values to integer values as the same floating-point type simultaneously.

Available only if an appropriate version of softfloatpy module is found.

__init__(width: int, dtype: type[Float16 | Float32 | Float64 | Float128] | Iterable[type[Float16 | Float32 | Float64 | Float128]]) None

Creates a SIMD floating-point to integer rounder.

Parameters:
  • width – The data word width in bits.

  • dtype – The selectable floating-point type or types.

Raises:

ValueError – If width is not divisible by any of dtype sizes.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPToIntegerConverter(dtype_i: type[Float16 | Float32 | Float64 | Float128], width_o: int)

Bases: UnaryOperator, FPState

A floating-point to integer converter.

This device converts the floating-point to an unsigned integer.

__init__(dtype_i: type[Float16 | Float32 | Float64 | Float128], width_o: int) None

Creates a floating-point to integer converter.

Parameters:
  • dtype_i – The input floating-point type.

  • width_o – The output data word width in bits. Must be less than or equal to 64.

Raises:

ValueError – If width_o is greater than 64.

reset() None

Resets the states.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPToIntegerConverter(multi: int, dtype_i: type[Float16 | Float32 | Float64 | Float128], dsize_o: int)

Bases: SIMD_UnaryOperator, FPState

A SIMD floating-point to integer converter.

This device converts the respective floating-points to unsigned integers simultaneously.

__init__(multi: int, dtype_i: type[Float16 | Float32 | Float64 | Float128], dsize_o: int) None

Creates a SIMD floating-point to integer converter.

Parameters:
  • multi – The number of SIMD elements.

  • dtype_i – The input floating-point type.

  • dsize_o – The output data word width in bits.

reset() None

Resets the states.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPFromIntegerConverter(width_i: int, dtype_o: type[Float16 | Float32 | Float64 | Float128])

Bases: UnaryOperator, FPState

A integer to floating-point converter.

This device converts the unsigned integer to a floating-point.

__init__(width_i: int, dtype_o: type[Float16 | Float32 | Float64 | Float128]) None

Creates a integer to floating-point converter.

Parameters:
  • width_i – The input data word width in bits.

  • dtype_o – The output floating-point type.

reset() None

Resets the states.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPFromIntegerConverter(multi: int, dsize_i: int, dtype_o: type[Float16 | Float32 | Float64 | Float128])

Bases: SIMD_UnaryOperator, FPState

A SIMD integer to floating-point converter.

This device converts the respective unsigned integers to floating-points simultaneously.

__init__(multi: int, dsize_i: int, dtype_o: type[Float16 | Float32 | Float64 | Float128]) None

Creates a SIMD integer to floating-point converter.

Parameters:
  • multi – The number of SIMD elements.

  • dsize_i – The input data word width in bits.

  • dtype_o – The output floating-point type.

reset() None

Resets the states.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPToSignedIntegerConverter(dtype_i: type[Float16 | Float32 | Float64 | Float128], width_o: int)

Bases: FPToIntegerConverter

A floating-point to signed-integer converter.

This device converts the floating-point to a signed integer.

__init__(dtype_i: type[Float16 | Float32 | Float64 | Float128], width_o: int) None

Creates a floating-point to signed-integer converter.

Parameters:
  • dtype_i – The input floating-point type.

  • width_o – The output data word width in bits.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPToSignedIntegerConverter(multi: int, dtype_i: type[Float16 | Float32 | Float64 | Float128], dsize_o: int)

Bases: SIMD_FPToIntegerConverter

A SIMD floating-point to signed-integer converter.

This device converts the respective floating-points to signed integers simultaneously.

__init__(multi: int, dtype_i: type[Float16 | Float32 | Float64 | Float128], dsize_o: int) None

Creates a SIMD floating-point to signed-integer converter.

Parameters:
  • multi – The number of SIMD elements.

  • dtype_i – The input floating-point type.

  • dsize_o – The output data word width in bits.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPFromSignedIntegerConverter(width_i: int, dtype_o: type[Float16 | Float32 | Float64 | Float128])

Bases: FPFromIntegerConverter

A signed-integer to floating-point converter.

This device converts the signed integer to a floating-point.

__init__(width_i: int, dtype_o: type[Float16 | Float32 | Float64 | Float128]) None

Creates a signed-integer to floating-point converter.

Parameters:
  • width_i – The input data word width in bits.

  • dtype_o – The output floating-point type.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPFromSignedIntegerConverter(multi: int, dsize_i: int, dtype_o: type[Float16 | Float32 | Float64 | Float128])

Bases: SIMD_FPFromIntegerConverter

A SIMD signed-integer to floating-point converter.

This device converts the respective signed integers to floating-points simultaneously.

__init__(multi: int, dsize_i: int, dtype_o: type[Float16 | Float32 | Float64 | Float128]) None

Creates a SIMD signed-integer to floating-point converter.

Parameters:
  • multi – The number of SIMD elements.

  • dsize_i – The input data word width in bits.

  • dtype_o – The output floating-point type.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.FPConverter(dtype_i: type[Float16 | Float32 | Float64 | Float128], dtype_o: type[Float16 | Float32 | Float64 | Float128])

Bases: UnaryOperator, FPState

A floating-point converter.

This device converts the floating-point to that of another type.

__init__(dtype_i: type[Float16 | Float32 | Float64 | Float128], dtype_o: type[Float16 | Float32 | Float64 | Float128]) None

Creates a floating-point converter.

Parameters:
  • dtype_i – The input floating-point type.

  • dtype_o – The output floating-point type.

reset() None

Resets the states.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.

class simuhw.float.SIMD_FPConverter(multi: int, dtype_i: type[Float16 | Float32 | Float64 | Float128], dtype_o: type[Float16 | Float32 | Float64 | Float128])

Bases: SIMD_UnaryOperator, FPState

A SIMD floating-point converter.

This device converts the respective floating-points to those of another type simultaneously.

__init__(multi: int, dtype_i: type[Float16 | Float32 | Float64 | Float128], dtype_o: type[Float16 | Float32 | Float64 | Float128]) None

Creates a SIMD floating-point converter.

Parameters:
  • multi – The number of SIMD elements.

  • dtype_i – The input floating-point type.

  • dtype_o – The output floating-point type.

reset() None

Resets the states.

work(time: float | None) tuple[list[InputPort], float | None]

Makes the device work.

Parameters:

time – The current time in seconds. None when starting to make the device work.

Returns:

A tuple of the list of the input ports that are to be watched receive a data word, and the next resuming time in seconds. The next resuming time can be None if resumable anytime.