Hypex v1.1.0 Hypex.Register behaviour
This module defines the behaviour required by all internal Hypex register structures.
Assuming all of the function callbacks defined in this module are implemented correctly, it should be possible to use as an implementation inside a Hypex. This makes it possible to provide custom implementations of the underlying register without having to modify the actual source of Hypex.
Summary
Callbacks
Invoked after operating on registers on a bit level
Invoked to retrieve a specific bit register
Invoked to initialize a set of registers
Invoked when there’s a need to iterate/accumulate a register
Invoked to set a bit register with a given value
Invoked when operating on registers on a bit level
Types
t
Register implementations currently available
Callbacks
Specs
from_list([bit :: number]) :: register :: Register.t
Invoked after operating on registers on a bit level.
This function will receive a list of bits as created by the to_list/1
callback.
The result of calling this should return a register set in the same form as when
first being initialized.
Specs
get_value(register :: Register.t, idx :: number, width :: number) :: result :: number
Invoked to retrieve a specific bit register.
idx
refers to the head of the hashes value, and width
refers to the width
of the register. The get_value/3
callback should use these values when finding
the required register.
Specs
init(width :: number) :: register :: Register.t
Invoked to initialize a set of registers.
width
is the desired width of the registers and should be used to determine
how large the register set should be. Calls to init/1
should always return
a new register set.
Specs
reduce(register :: Register.t, width :: number, acc :: any, (number, any -> any)) :: acc :: any
Invoked when there’s a need to iterate/accumulate a register.
Specs
set_value(register :: Register.t, idx :: number, width :: number, value :: number) :: register :: Register.t
Invoked to set a bit register with a given value.
Similar to the get_value/3
callback, we supply idx
and width
to allow the
callback to determine where the value should be written.