data_specification.enums package

Module contents

class data_specification.enums.ArithmeticOperation(value)[source]

Bases: Enum

Arithmetic Operations.

ADD = 0

Addition operation

MULTIPLY = 2

Multiplication operation

SUBTRACT = 1

Subtraction operation

class data_specification.enums.Commands(value)[source]

Bases: Enum

Set of opcodes for the spec executor.

ALIGN_WR_PTR = 101
ARITH_OP = 103
BLOCK_COPY = 69
BREAK = 0

Halts spec execution with an error.

BREAK_LOOP = 82
CONSTRUCT = 64
COPY_PARAM = 113
COPY_STRUCT = 112
DECLARE_RANDOM_DIST = 6
DECLARE_RNG = 5
ELSE = 86
END_CONSTRUCTOR = 37
END_IF = 87
END_LOOP = 83
END_SPEC = 255
END_STRUCT = 18
FREE = 3
GET_RANDOM_NUMBER = 7
GET_WR_PTR = 99
IF = 85
LOGIC_OP = 104
LOOP = 81
MV = 96

Place a value in a register, from an immediate or another register.

NOP = 1

No operation. Can be used as a filler.

PRINT_STRUCT = 130
PRINT_TXT = 129
PRINT_VAL = 128
READ = 65
READ_PARAM = 115
REFERENCE = 4
REFORMAT = 106
RESERVE = 2

Reserves a block of memory ready for filling.

SET_WR_PTR = 100

Move the write pointer to a new location, either relative to the start of this reserved memory area or relative to the current write pointer.

START_CONSTRUCTOR = 32
START_STRUCT = 16
STRUCT_ELEM = 17
SWITCH_FOCUS = 80

Swap between different reserved memory regions to work on several at the same time.

WRITE = 66

Performs a simple write or block write operation.

WRITE_ARRAY = 67

Performs a write from an array.

WRITE_PARAM = 114
WRITE_PARAM_COMPONENT = 116
WRITE_STRUCT = 68
class data_specification.enums.Condition(value)[source]

Bases: Enum

Comparison Operations.

EQUAL = 0

Compare the operands for equality

GREATER_THAN = 5

True if the first operand is > the second

GREATER_THAN_OR_EQUAL = 4

True if the first operand is >= the second

LESS_THAN = 3

True if the first operand is < the second

LESS_THAN_OR_EQUAL = 2

True if the first operand is <= the second

NOT_EQUAL = 1

Compare the operands for inequality

class data_specification.enums.DataType(value)[source]

Bases: Enum

Supported data types. Internally, these are actually tuples.

  1. an identifier for the enum class;

  2. the size in bytes of the type;

  3. the minimum possible value for the type;

  4. the maximum possible value for the type;

  5. the scale of the input value to convert it in integer;

  6. the pattern to use following the struct package encodings to convert the data in binary format;

  7. is whether to apply the scaling when converting to SpiNNaker’s binary format.

  8. the corresponding numpy type (or None to inhibit direct conversion via numpy, scaled conversion still supported);

  9. the text description of the type.

Note

Some types (notably 64-bit fixed-point and floating-point types) are not recommended for use on SpiNNaker due to complications with representability and lack of hardware/library support.

FLOAT_32 = 14

32-bit floating point number

FLOAT_64 = 15

64-bit floating point number (use not recommended: hardware/library support inadequate)

INT16 = 5

16-bit signed integer

INT32 = 6

32-bit signed integer

INT64 = 7

64-bit signed integer

INT8 = 4

8-bit signed integer

S015 = 21

0.15 signed fixed point number

S031 = 22

0.32 signed fixed point number

S063 = 23

0.63 signed fixed point number (use not recommended: representability)

S07 = 20

0.7 signed fixed point number

S1615 = 12

16.15 signed fixed point number

S3231 = 13

32.31 signed fixed point number (use not recommended: representability)

S87 = 11

8.7 signed fixed point number

U016 = 17

0.16 unsigned fixed point number

U032 = 18

0.32 unsigned fixed point number

U064 = 19

0.64 unsigned fixed point number (use not recommended: representability)

U08 = 16

0.8 unsigned fixed point number

U1616 = 9

16.16 unsigned fixed point number

U3232 = 10

32.32 unsigned fixed point number (use not recommended: representability)

U88 = 8

8.8 unsigned fixed point number

UINT16 = 1

16-bit unsigned integer

UINT32 = 2

32-bit unsigned integer

UINT64 = 3

64-bit unsigned integer

UINT8 = 0

8-bit unsigned integer

decode_array(values)[source]

Decodes a byte array into iterable of this type.

Parameters:

values – the bytes to decode into this given data type

Return type:

numpy array

decode_numpy_array(array)[source]

Decode the numpy array of SpiNNaker values according to this type.

Parameters:

array (ndarray(uint32)) –

Return type:

ndarray(uint32 or float64)

encode(value)[source]

Encode the Python value for SpiNNaker according to this type.

Parameters:

value (float or int) –

Return type:

bytes

encode_as_int(value)[source]

Returns the value as an integer, according to this type.

Parameters:

value (float or int) –

Return type:

int

encode_as_numpy_int(value)[source]

Returns the value as a numpy integer, according to this type.

Note

Only works with integer and fixed point data types.

Parameters:

value (float or int) –

Return type:

uint32

encode_as_numpy_int_array(array)[source]

Returns the numpy array as an integer numpy array, according to this type.

Parameters:

array (ndarray) –

Return type:

ndarray

property max

The maximum possible value for the type.

Return type:

Decimal

property min

The minimum possible value for the type.

Return type:

Decimal

property numpy_typename

The corresponding numpy type, if one exists.

property scale

The scale of the input value to convert it in integer.

Return type:

Decimal

property size

The size in bytes of the type.

Return type:

int

property struct_encoding

The encoding string used for struct. Scaling may also be required.

Return type:

str

class data_specification.enums.LogicOperation(value)[source]

Bases: Enum

Logic Operations

AND = 3

Logical AND

LEFT_SHIFT = 0

Shift left (with zero extension)

NOT = 5

Logical NOT (single argument)

OR = 2

Logical OR

RIGHT_SHIFT = 1

Shift right (with zero extension)

XOR = 4

Logical XOR

class data_specification.enums.RandomNumberGenerator(value)[source]

Bases: Enum

Random number generator types.

MERSENNE_TWISTER = 0

The well-known Mersenne Twister PRNG