Hypex.Register behaviour (Hypex v2.1.0)

View Source

This module defines the behaviour required by all internal Hypex registers.

There are no requirements for the underlying storage of a register, only that it conforms to this behaviour and provides a correct implementation.

Summary

Types

t()

Register implementations currently available in the core of the Hypex library.

Callbacks

Retrieve a specific bit from a register.

Initialize an empty register of a given width.

Merge together two registers of the same width and type.

Set a specific bit in a register.

Run a reduction over the inner bits of a register.

Types

t()

@opaque t()

Register implementations currently available in the core of the Hypex library.

Callbacks

get(register, index, width)

@callback get(register :: Register.t(), index :: number(), width :: number()) ::
  result :: number()

Retrieve a specific bit from a register.

init(width)

@callback init(width :: number()) :: register :: Register.t()

Initialize an empty register of a given width.

The width parameter supplied here will have been pre-validated by the main Hypex interface. Calls to init/1 should always return a fresh register.

merge(left, right)

@callback merge(left :: Register.t(), right :: Register.t()) :: Register.t()

Merge together two registers of the same width and type.

put(register, index, width, value)

@callback put(
  register :: Register.t(),
  index :: number(),
  width :: number(),
  value :: number()
) ::
  register :: Register.t()

Set a specific bit in a register.

reduce(register, width, acc, function)

@callback reduce(register :: Register.t(), width :: number(), acc :: any(), (number(),
                                                                   any() ->
                                                                     any())) ::
  acc :: any()

Run a reduction over the inner bits of a register.