data_specification package

Submodules

data_specification.constants module

Constants used by the Data Structure Generator (DSG) and the Spec Executor

data_specification.data_specification_executor module

class data_specification.data_specification_executor.DataSpecificationExecutor(spec_reader, memory_space)[source]

Bases: object

Used to execute a data specification language file to produce a memory image

Parameters:
  • spec_reader (data_specification.abstract_data_reader.                    AbstractDataReader) – The object to read the specification language file from
  • memory_space (int) – memory available on the destination architecture
Raises:
  • spinn_storage_handlers.exceptions.DataReadException – If a read from external storage fails
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
dsef
execute()[source]

Executes the specification

Returns:

The number of bytes used by the image and the number of bytes written by the image

Return type:

int

Raises:
  • spinn_storage_handlers.exceptions.DataReadException – If a read from external storage fails
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions.DataSpecificationException – If there is an error when executing the specification
  • data_specification.exceptions. DataSpecificationTablePointerOutOfMemory – If the table pointer generated as data header exceeds the size of the available memory
get_constructed_data_size()[source]

Return the size of the data that will be written to memory

Returns:size of the data that will be written to memory
Return type:unsigned int
get_header()[source]

Get the header of the data as a numpy array

get_pointer_table(start_address)[source]

Get the pointer table as a numpy array

Parameters:start_address – The base address of the data to be written
get_region(region_id)[source]

Get a region with a given id

Parameters:region_id (int) – The id of the region to get
Returns:The region, or None if the region was not allocated
spec_reader

data_specification.data_specification_executor_functions module

class data_specification.data_specification_executor_functions.DataSpecificationExecutorFunctions(spec_reader, memory_space)[source]

Bases: object

This class includes the function related to each of the commands of the data specification file.

Parameters:
  • spec_reader (data_specification.abstract_data_reader.            AbstractDataReader) – The object to read the specification language file from
  • memory_space (int) – Memory space available for the data to be generated
current_region
data_len
dest_reg
execute_align_wr_ptr(cmd)[source]
execute_arith_op(cmd)[source]
execute_block_copy(cmd)[source]
execute_break(cmd)[source]
This command raises an exception to stop the execution of the data spec
executor (DSE)
Parameters:cmd (int) – the command which triggered the function call
Returns:No value returned
Return type:None
Raises:data_specification.exceptions.ExecuteBreakInstruction – Raises the exception to break the execution of the DSE
execute_break_loop(cmd)[source]
execute_construct(cmd)[source]
execute_copy_param(cmd)[source]
execute_copy_struct(cmd)[source]
execute_declare_rng(cmd)[source]
execute_else(cmd)[source]
execute_end_constructor(cmd)[source]
execute_end_if(cmd)[source]
execute_end_loop(cmd)[source]
execute_end_spec(cmd)[source]

Return the value which terminates the data spec executor

Parameters:cmd (int) – the command which triggered the function call
Returns:constants.END_SPEC_EXECUTOR
Return type:int
Raises:data_specification.exceptions.DataSpecificationSyntaxError – If command END_SPEC != -1
execute_end_struct(cmd)[source]
execute_free(cmd)[source]
execute_get_random_rumber(cmd)[source]
execute_get_wr_ptr(cmd)[source]
execute_if(cmd)[source]
execute_logic_op(cmd)[source]
execute_loop(cmd)[source]
execute_mv(cmd)[source]

This command moves an immediate value to a register or copies the value of a register to another register

Parameters:cmd (int) – the command which triggered the function call
Returns:No value returned
Return type:None
Raises:data_specification.exceptions.DataSpecificationSyntaxError – if the destination register is not correctly specified - the destination must be a register and the appropriate bit needs to be set in the specification
execute_nop(cmd)[source]

This command executes no operation

Parameters:cmd (int) – the command which triggered the function call
Returns:No value returned
Return type:None
execute_print_struct(cmd)[source]
execute_print_txt(cmd)[source]
execute_print_val(cmd)[source]
execute_random_dist(cmd)[source]
execute_read(cmd)[source]
execute_read_param(cmd)[source]
execute_reformat(cmd)[source]
execute_reserve(cmd)[source]

This command reserves a region and assigns some memory space to it

Parameters:

cmd (int) – the command which triggered the function call

Returns:

No value returned

Return type:

None

Raises:
execute_reset_wr_ptr(cmd)[source]
execute_set_wr_ptr(cmd)[source]
execute_start_constructor(cmd)[source]
execute_start_struct(cmd)[source]
execute_struct_elem(cmd)[source]
execute_switch_focus(cmd)[source]

This command switches the focus to the desired, already allocated, memory region

Parameters:cmd (int) – the command which triggered the function call
Returns:No value returned
Return type:None
Raises:data_specification.exceptions. DataSpecificationRegionUnfilledException – If the focus is being switched to a region of memory which has been declared to be kept unfilled
execute_write(cmd)[source]

This command writes the given value in the specified region a number of times as identified by either a value in the command or a register value

Parameters:cmd (int) – the command which triggered the function call
Returns:No value returned
Return type:None
Raises:data_specification.exceptions.DataSpecificationSyntaxError – If there is an error in the command syntax
execute_write_array(cmd)[source]

This command writes an array of values in the specified region

Parameters:cmd (int) – the command which triggered the function call
Returns:No value returned
Return type:None
execute_write_param(cmd)[source]
execute_write_param_component(cmd)[source]
execute_write_struct(cmd)[source]
mem_regions
mem_writer
memory_space
opcode
registers
space_allocated
spec_reader
src1_reg
src2_reg
struct_slots
use_dest_reg
use_src1_reg
use_src2_reg

data_specification.data_specification_generator module

class data_specification.data_specification_generator.DataSpecificationGenerator(spec_writer, report_writer=None)[source]

Bases: object

Used to generate a data specification language file that can be executed to produce a memory image

Parameters:
  • spec_writer (Implementation of data_specification.abstract_data_writer.AbstractDataWriter) – The object to write the specification to
  • report_writer (Implementation of data_specification.abstract_data_writer.AbstractDataWriter) – Determines if a text version of the specification is to be written
Raises:

spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails

MAGIC_NUMBER = 2903706326
VERSION = 1
align_write_pointer(log_block_size, log_block_size_is_register=False, return_register_id=None)[source]

Insert command to align the write pointer against a power-of-2 block size in bytes. Zeros are inserted in the intervening space

Parameters:
  • log_block_size (int) –
    • If log_block_size_is_register is False, log to base 2 of the block size (e.g. The write pointer will be moved so that it is a multiple of 2^(log_block_size)), between 0 and 32
    • If log_block_size_is_register is True, the id of the register containing log to the base 2 of the block size, between 0 and 15
  • log_block_size_is_register (bool) – Indicates if log_block_size is a register id
  • return_register_id (int) – The id of a register where the write pointer will be written to once it has been updated, between 0 and 15or None if no such writing is to be done
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If log_block_size_is_register is False, and log_block_size is not within the allowed range
    • If log_block_size_is_register is True and log_block_size is not a valid register id
  • data_specification.exceptions. DataSpecificationRegionOutOfBoundsException – If the move of the pointer would put it outside of the current region
  • data_specification.exceptions. DataSpecificationNoRegionSelectedException – If no region has been selected
break_loop()[source]

Insert command to break out of a loop before it has completed

Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationInvalidCommandException – If there is no loop in operation at this point
call_arithmetic_operation(register_id, operand_1, operation, operand_2, signed, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform an arithmetic operation on two signed or unsigned values and store the result in a register

Parameters:
  • register_id (int) – The id of the register to store the result in
  • operand_1 (int) –
    • If operand_1_is_register is True, the id of a register where the first operand can be found, between 0 and 15
    • If operand_1_is_register is False, a 32-bit value
  • operation (ArithmeticOperation) – The operation to perform
  • operand_2 (int) –
    • If operand_2_is_register is True, the id of a register where the second operand can be found, between 0 and 15
    • If operand_2_is_register is False, a 32-bit value
  • signed (bool) – Indicates if the values should be considered signed
  • operand_1_is_register (bool) – Indicates if operand_1 is a register id
  • operand_2_is_register (bool) – Indicates if operand_2 is a register id
Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If operand_1_is_register is True and operand_1 is not a valid register id
    • If operand_2_is_register is True and operand_2 is not a valid register id
  • data_specification.exceptions. DataSpecificationUnknownTypeException – If operation is not a known operation
call_function(function_id, structure_ids)[source]

Insert command to call a function

Parameters:
  • function_id (int) – The id of a previously defined function, between 0 and 31
  • structure_ids (list of int) – A list of structure_ids that will be passed into the function, each between 0 and 15
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If the function id is not valid
    • If any of the structure ids are not valid
  • data_specification.exceptions. DataSpecificationNotAllocatedException
    • If a function has not been defined with the given id
    • If no structure has been defined with one of the ids in structure_ids
  • data_specification.exceptions. DataSpecificationWrongParameterNumberException – If a function is called with a wrong number of parameters
  • data_specification.exceptions. DataSpecificationDuplicateParameterException – If a function is called with duplicate parameters
call_random_distribution(distribution_id, register_id)[source]

Insert command to get the next random number from a random distribution, placing the result in a register to be used in a future call

Parameters:
  • distribution_id (int) – The id of the random distribution to call between 0 and 63
  • register_id (int) – The id of the register to store the result in between 0 and 15
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationNotAllocatedException – If the random distribution id was not previously declared
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If the distribution_id or register_id specified was out of range
comment(comment)[source]

Write a comment to the text version of the specification. Note that this is ignored by the binary file

Parameters:

comment (str) – The comment to write

Returns:

Nothing is returned

Raises:
conditionals
copy_structure(source_structure_id, destination_structure_id, source_id_is_register=False, destination_id_is_register=False)[source]

Insert command to copy a structure, possibly overwriting another structure

Parameters:
  • source_structure_id (int) –
    • If source_id_is_register is True, the id of the register holding the source structure id, between 0 and 15
    • Otherwise, the id of the source structure, between 0 and 15
  • destination_structure_id (int) –
    • If destination_id_is_register is True, the id of the register holding the destination structure id, between 0 and 15
    • If destination_id_is_register is False, the id of the destination structure, between 0 and 15
  • source_id_is_register (bool) – Indicates if source_structure_id is a register id
  • destination_id_is_register (bool) – Indicates if destination_structure_id is a register id
Returns:

The id of the copied structure, between 0 and 15

Return type:

int

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If source_id_is_register is True and source_structure_id is not a valid register id
    • If destination_id_is_register is True and destination_structure_id is not a valid register id
    • If source_id_is_register is False and source_structure_id is not a valid structure id
    • If destination_id_is_register is False and destination_structure_id is not a valid structure id
  • data_specification.exceptions. DataSpecificationNotAllocatedException
    • If no structure with id source_structure_id has been allocated
copy_structure_parameter(source_structure_id, source_parameter_index, destination_id, destination_parameter_index=None, destination_is_register=False)[source]

Insert command to copy the value of a parameter from one structure to another

Parameters:
  • source_structure_id (int) – The id of the source structure, between 0 and 15
  • source_parameter_index (int) – The index of the parameter in the source structure
  • destination_id (int) – The id of the destination structure, or the id of the destination register, between 0 and 15
  • destination_parameter_index (int) – The index of the parameter in the destination structure. Ignored when writing to a register.
  • destination_is_register (boolean) – Indicates whether the destination is a structure or a register.
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If source_structure_id is not a valid structure id
    • If destination_id is not a valid structure id
    • If source_parameter_index is not a valid parameter index in the source structure
    • If destination_parameter_index is not a valid parameter index in the destination structure
  • data_specification.exceptions. DataSpecificationNotAllocatedException
    • If no structure with id destination_id has been allocated
    • If no structure with id source_structure_id has been allocated
current_region
declare_random_number_generator(rng_id, rng_type, seed)[source]

Insert command to declare a random number generator

Parameters:
  • rng_id (int) – The id of the random number generator
  • rng_type (RandomNumberGenerator) – The type of the random number generator
  • seed (int) – The seed of the random number generator >= 0
Returns:

The id of the created random number generator, between 0 and 15

Return type:

int

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions.DataSpecification – If there is no more space for a new generator
  • data_specification.exceptions. DataSpecificationUnknownTypeException – If the rng_type is not one of the allowed values
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If the seed is too big or too small
    • If the rng_id is not in the allowed range
  • data_specification.exceptions .DataSpecificationRNGInUseException – If the random number generator with the given id has already been defined
declare_uniform_random_distribution(distribution_id, structure_id, rng_id, min_value, max_value)[source]

Insert commands to declare a uniform random distribution

Parameters:
  • distribution_id – id of the distribution being set up
  • distribution_id – int
  • structure_id (int) – id of an empty structure slot to fill with the uniform random distribution data
  • rng_id (int) – The id of the random number generator, between 0 and 15
  • min_value (float) – The minimum value that should be returned from the distribution between -32768.0 and max_value
  • max_value (float) – The maximum value that should be returned from the distribution between min_value and 32767.9999847
Returns:

The id of the created uniform random distribution to be used in future calls of the distribution between 0 and 63

Return type:

int

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions.DataSpecificationNoMoreException – If there is no more space for a new random distribution
  • data_specification.exceptions. DataSpecificationNotAllocatedException – If the requested rng_id has not been allocated
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If rng_id, structure_id, min_value or max_value is out of range
  • data_specification.exceptions. DataSpecificationStructureInUseException – If structure structure_id is already defined
define_break()[source]

Insert command to stop execution with an exception (for debugging)

Returns:

Nothing is returned

Return type:

None

Raises:
define_structure(structure_id, parameters)[source]

Insert commands to define a data structure

Parameters:
  • structure_id (int) – the id of the structure to create, between 0 and 15
  • parameters (list of (str, DataType, float)) – A list of between 1 and 255 tuples of (label, data_type, value) where: * label is the label of the element (for debugging) * data_type is the data type of the element * value is the value of the element, or None if no value is to be assigned
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions.DataSpecificationNoMoreException – If there are no more spaces for new structures
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If there are an incorrect number of parameters
    • If the size of one of the tuples is incorrect
    • If one of the values to be assigned has an integer data_type but has a fractional part
    • If one of the values to be assigned would overflow its data_type
  • data_specification.exceptions. DataSpecificationUnknownTypeException – If one of the data types in the structure is unknown
else_conditional()[source]

Insert command for the else of an if…then…else construct. If the condition of the conditional evaluates to false, the statements up between the conditional and the insertion of this “else” are skipped, and the statements from this point until the end of the conditional are executed.

Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationInvalidCommandException – If there is no conditional in operation at this point
end_conditional()[source]

Insert command to mark the end of an if…then…else construct

Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationInvalidCommandException – If there is no conditional in operation at this point
end_function()[source]

Insert command to mark the end of a function definition

Returns:Nothing is returned
Return type:None
Raises:data_specification.exceptions. DataSpecificationInvalidCommandException – If there is no function being defined at this point
end_loop()[source]

Insert command to indicate that this is the end of the loop. Commands between the start of the loop and this command will be repeated.

Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationInvalidCommandException – If there is no loop in operation at this point
end_specification(close_writer=True)[source]

Insert a command to indicate that the specification has finished and finish writing

Parameters:

close_writer (bool) – Indicates whether to close the underlying writer(s)

Returns:

Nothing is returned

Return type:

None

Raises:
free_memory_region(region)[source]

Insert command to free a previously reserved memory region

Parameters:

region (int) – The number of the region to free, from 0 to 15

Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationNotAllocatedException – If the region was not reserved
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If the region requested was out of the allowed range
function
get_structure_value(destination_id, structure_id, parameter_index, parameter_index_is_register=False)[source]

Insert command to get a value from a structure. The value is copied in a register.

Parameters:
  • destination_id (int) – The id of the destination register
  • structure_id (int) – The id of the source structure
  • parameter_index (int) – The id of the parameter/element to copy
  • parameter_index_is_register (bool) – True if the index of the structure is contained in a register
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If structure_id is not in the allowed range
    • If parameter_index is larger than the number of parameters declared in the original structure
    • If destination_id is not the id of a valid register
    • If parameter_index_is_register is True and parameter_index is not a valid register id
  • data_specification.exceptions. DataSpecificationNotAllocatedException – If the structure requested has not been declared
instruction_counter
logical_and(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical AND operation, using the _call_logic_operation.

Parameters:
  • register_id (int) – The id of the register to store the result in
  • operand_1 (int) –
    • If operand_1_is_register is True, the id of a register where the first operand can be found, between 0 and 15
    • If operand_1_is_register is False, a 32-bit value
  • operand_2 (int) –
    • If operand_2_is_register is True, the id of a register where the second operand can be found. between 0 and 15
    • If operand_2_is_register is False, a 32-bit value
  • operand_1_is_register (bool) – Indicates if operand_1 is a register id
  • operand_2_is_register (bool) – Indicates if operand_2 is a register id
Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If operand_1_is_register is True and operand_1 is not a valid register id
    • If operand_2_is_register is True and operand_2 is not a valid register id
logical_left_shift(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical left shift operation, using the _call_logic_operation.

Parameters:
  • register_id (int) – The id of the register to store the result in
  • operand_1 (int) –
    • If operand_1_is_register is True, the id of a register where the first operand can be found, between 0 and 15
    • If operand_1_is_register is False, a 32-bit value
  • operand_2 (int) –
    • If operand_2_is_register is True, the id of a register where the second operand can be found. between 0 and 15
    • If operand_2_is_register is False, a 32-bit value
  • operand_1_is_register (bool) – Indicates if operand_1 is a register id
  • operand_2_is_register (bool) – Indicates if operand_2 is a register id
Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If operand_1_is_register is True and operand_1 is not a valid register id
    • If operand_2_is_register is True and operand_2 is not a valid register id
logical_not(register_id, operand, operand_is_register=False)[source]
Insert command to perform a logical xor operation, using
the _call_logic_operation.
Parameters:
  • register_id (int) – The id of the register to store the result in
  • operand (int) –
    • If operand_is_register is True, the id of a register where the first operand can be found, between 0 and 15
    • If operand_is_register is False, a 32-bit value
  • operand_is_register (bool) – Indicates if operand_1 is a register id
Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If operand_is_register is True and operand_1 is not a valid register id
logical_or(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical OR operation, using the _call_logic_operation.

Parameters:
  • register_id (int) – The id of the register to store the result in
  • operand_1 (int) –
    • If operand_1_is_register is True, the id of a register where the first operand can be found, between 0 and 15
    • If operand_1_is_register is False, a 32-bit value
  • operand_2 (int) –
    • If operand_2_is_register is True, the id of a register where the second operand can be found. between 0 and 15
    • If operand_2_is_register is False, a 32-bit value
  • operand_1_is_register (bool) – Indicates if operand_1 is a register id
  • operand_2_is_register (bool) – Indicates if operand_2 is a register id
Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If operand_1_is_register is True and operand_1 is not a valid register id
    • If operand_2_is_register is True and operand_2 is not a valid register id
logical_right_shift(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical right shift operation, using the _call_logic_operation.

Parameters:
  • register_id (int) – The id of the register to store the result in
  • operand_1 (int) –
    • If operand_1_is_register is True, the id of a register where the first operand can be found, between 0 and 15
    • If operand_1_is_register is False, a 32-bit value
  • operand_2 (int) –
    • If operand_2_is_register is True, the id of a register where the second operand can be found. between 0 and 15
    • If operand_2_is_register is False, a 32-bit value
  • operand_1_is_register (bool) – Indicates if operand_1 is a register id
  • operand_2_is_register (bool) – Indicates if operand_2 is a register id
Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If operand_1_is_register is True and operand_1 is not a valid register id
    • If operand_2_is_register is True and operand_2 is not a valid register id
logical_xor(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]
Insert command to perform a logical xor operation, using
the _call_logic_operation.
Parameters:
  • register_id (int) – The id of the register to store the result in
  • operand_1 (int) –
    • If operand_1_is_register is True, the id of a register where the first operand can be found, between 0 and 15
    • If operand_1_is_register is False, a 32-bit value
  • operand_2 (int) –
    • If operand_2_is_register is True, the id of a register where the second operand can be found. between 0 and 15
    • If operand_2_is_register is False, a 32-bit value
  • operand_1_is_register (bool) – Indicates if operand_1 is a register id
  • operand_2_is_register (bool) – Indicates if operand_2 is a register id
Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If operand_1_is_register is True and operand_1 is not a valid register id
    • If operand_2_is_register is True and operand_2 is not a valid register id
mem_slot
no_operation()[source]

Insert command to execute nothing

Returns:

Nothing is returned

Return type:

None

Raises:
ongoing_function_definition
ongoing_loop
print_struct(structure_id, structure_id_is_register=False)[source]

Insert command to print out a structure (for debugging)

Parameters:
  • structure_id (int) –
    • If structure_id_is_register is True, the id of the register containing the id of the structure to print, between 0 and 15
    • If structure_id_is_register is False, the id of the structure to print, between 0 and 15
  • structure_id_is_register (bool) – Indicates if the structure_id is a register
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If structure_id_is_register is True and structure_id is not a valid register id
    • If structure_id_is_register is False and structure_id is not a valid structure id
  • data_specification.exceptions. DataSpecificationNotAllocatedException – If structure_id_is_register is False and structure_id is the id of a structure that has not been allocated
print_text(text)[source]

Insert command to print some text (for debugging)

Parameters:

text (str) – The text to write (max 12 characters)

Returns:

Nothing is returned

Return type:

None

Raises:
print_value(value, value_is_register=False, data_type=<DataType.UINT32: 2>)[source]

Insert command to print out a value (for debugging)

Parameters:
  • value (float) –
    • If value_is_register is True, the id of the register containing the value to print
    • If value_is_register is False, the value to print as a float
  • value_is_register (bool) – Indicates if the value is a register
  • data_type (DataType) – The type of the data to be printed
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If value_is_register is True and value is not a valid register id
    • If value_is_register is False, the data_type is an integer type and value has a fractional part
    • If value_is_register is False and the value would overflow the data type
  • data_specification.exceptions. DataSpecificationUnknownTypeException
    • If data_type is not a valid data type
random_distribution
read_value(dest_id, data_type)[source]

Insert command to read a value from the current write pointer, causing the write pointer to move by the number of bytes read. The data is stored in a register passed as argument.

Parameters:
  • dest_id (int) – The id of the destination register.
  • data_type (DataType) – The type of the data to be read.
Returns:

Nothing is returned

Return type:

None

region_sizes

A list of sizes of each region that has been reserved. Note that the list will include 0s for each non-reserved region.

report_writer
reserve_memory_region(region, size, label=None, empty=False, shrink=True)[source]

Insert command to reserve a memory region

Parameters:
  • region (int) – The number of the region to reserve, from 0 to 15
  • size (int) – The size to reserve for the region in bytes
  • label (str) – An optional label for the region
  • empty (bool) – Specifies if the region will be left empty
  • shrink (bool) – Specifies if the region will be compressed
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationRegionInUseException – If the region was already reserved
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If the region requested was out of the allowed range, or that the size was too big to fit in SDRAM
rng
save_write_pointer(register_id)[source]

Insert command to save the write pointer to a register

Parameters:

register_id (int) – The id of the register to assign, between 0 and 15

Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If the register_id is not a valid register id
  • data_specification.exceptions. DataSpecificationNoRegionSelectedException – If no region has been selected
set_register_value(register_id, data, data_is_register=False, data_type=<DataType.UINT32: 2>)[source]

Insert command to set the value of a register

Parameters:
  • register_id (int) – The id of the register to assign, between 0 and 15
  • data (float) –
    • If data_is_register is True, the register id containing the data to set, between 0 and 15
    • If data_is_register is False, the data as a float
  • data_is_register (bool) – Indicates if data is a register id
  • data_type (DataType) – The type of the data to be assigned
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If register_id is not a valid register_id
    • If data_is_register is True, and data is not a valid register id
    • If data_is_register is False, data_type is an integer type and data has a fractional part
    • If data_is_register if False, and data would overflow the data type
  • data_specification.exceptions. DataSpecificationUnknownTypeException – If the data type is not known
set_structure_value(structure_id, parameter_index, value, data_type, value_is_register=False)[source]

Insert command to set a value in a structure

Parameters:
  • structure_id (int) –
    • If called outside of a function, the id of the structure between 0 and 15
    • If called within a function, the id of the structure argument, between 0 and 4
  • parameter_index (int) – The index of the value to assign in the structure, between 0 and the number of parameters declared in the structure
  • value (float) –
    • If value_is_register is False, the value to assign at the selected position as a float
    • If value_is_register is True, the id of the register containing the value to assign to the position, between 0 and 15
  • data_type (DataType) – type of the data to be stored in the structure. If parameter value_is_register is set to true, this variable is disregarded
  • value_is_register (bool) – Identifies if value identifies a register
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If structure_id is not in the allowed range
    • If parameter_index is larger than the number of parameters declared in the original structure
    • If value_is_register is False, and the data type of the structure value is an integer, and the value has a fractional part
    • If value_is_register is False, and value would overflow the position in the structure
    • If value_is_register is True, and value is not a valid register id
  • data_specification.exceptions. DataSpecificationNotAllocatedException – If the structure requested has not been declared
set_write_pointer(address, address_is_register=False, relative_to_current=False)[source]

Insert command to set the position of the write pointer within the current region

Parameters:
  • address (int) –
    • If address_is_register is True, the id of the register containing the address to move to
    • If address_is_register is False, the address to move the write pointer to
  • address_is_register (bool) – Indicates if the the address is a register id
  • relative_to_current (bool) – Indicates if the address is to be added to the current address, or used as an absolute address from the start of the current region
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If the address_is_register is True and address is not a valid register id
  • data_specification.exceptions. DataSpecificationNoRegionSelectedException – If no region has been selected
spec_writer
start_conditional(register_id, condition, value, value_is_register=False)[source]

Insert command to start a conditional if…then…else construct. If the condition evaluates to true, the statement is executed up to the next else statement, or the end of the conditional, whichever comes first.

Parameters:
  • register_id (int) – The id of a register to compare the value of
  • condition (Condition) – The condition which must be true to execute the following commands
  • value (int) –
    • If value_is_register is False, the value to compare to the value in the register
    • If value_is_register is True, the id of the register containing the value to compare, between 0 and 15
  • value_is_register (bool) – Indicates if value is a register id
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If the register_id is not a valid register id
    • if value_is_register is True and value is not a valid register id
  • data_specification.exceptions. DataSpecificationUnknownTypeException – If the condition is not a valid condition
start_function(function_id, argument_by_value)[source]

Insert command to start a function definition, with up to 5 arguments, which are the ids of structures to be used within the function, each of which can be passed by reference or by value. In the commands following this command up to the end_function command, structures can only be referenced using the numbers 1 to 5 which address the arguments, rather than the original structure ids

Parameters:
  • function_id (int) – The id of the function currently defined.
  • argument_by_value (list of bool) – A list of up to 5 booleans indicating if the structure to be passed as an argument is to be passed by reference (i.e. changes made within the function are persisted) or by value (i.e. changes made within the function are lost when the function exits. The number of arguments is determined by the length of this list.
Returns:

The id of the function, between 0 and 31

Return type:

int

Raises:
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If there are too many items in the list of arguments
  • data_specification.exceptions. DataSpecificationInvalidCommandException – If there is already a function being defined at this point
  • data_specification.exceptions. DataSpecificationFunctionInUse – If the function is already defined
start_loop(counter_register_id, start, end, increment=1, start_is_register=False, end_is_register=False, increment_is_register=False)[source]

Insert command to start a loop

Parameters:
  • counter_register_id (int) – The id of the register to use as the loop counter, between 0 and 15
  • start (int) –
    • If start_is_register is False, the number at which to start the loop counter, >= 0
    • If start_is_register is True, the id of the register containing the number at which to start the loop counter, between 0 and 15
  • end (int) –
    • If end_is_register is False, the number which the loop counter must reach to stop the loop i.e. the loop will run while the contents of counter_register < end, >= 0
    • If end_is_register is True, the id of the register containing the number at which to stop the loop, between 0 and 15
  • increment (int) –
    • If increment_is_register is False, the amount by which to increment the loop counter on each run of the loop, >= 0
    • If increment_is_register is True, the id of the register containing the amount by which to increment the loop counter on each run of the loop, between 0 and 15
  • start_is_register (bool) – Indicates if start is a register id
  • end_is_register (bool) – Indicates if end is a register id
  • increment_is_register (bool) – Indicates if increment is a register id
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If counter_register_id is not a valid register id
    • If start_is_register is True and increment is not a valid register_id
    • If end_is_register is True and increment is not a valid register_id
    • If increment_is_register is True, and increment is not a valid register_id
    • If start_is_register is False and start is not in the allowed range
    • If end_is_register is False and end is not in the allowed range
    • If increment_is_register is False and increment is not in the allowed range
struct_slot
switch_write_focus(region)[source]

Insert command to switch the region being written to

Parameters:

region (int) – The id of the region to switch to, between 0 and 15

Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If the region identifier is not valid
  • data_specification.exceptions. DataSpecificationNotAllocatedException – If the region has not been allocated
  • data_specification.exceptions. DataSpecificationRegionUnfilledException – If the selected region should not be filled
txt_indent
write_array(array_values, data_type=<DataType.UINT32: 2>)[source]

Insert command to write an array, causing the write pointer to move on by (data type size * the array size), in bytes.

Parameters:
Returns:

The position of the write pointer within the current region, in bytes from the start of the region

Return type:

int

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationNoRegionSelectedException – If no region has been previously selected
write_command_to_files(cmd_word_list, cmd_string, indent=False, outdent=False, no_instruction_number=False)[source]

Writes the binary command to the binary output file and, if the user has requested a text output for debug purposes, also write the text version to the text file. Setting the optional parameter ‘indent’ to True causes subsequent commands to be indented by two spaces relative to this one. Similarly, setting ‘outdent’ to True, reverses this spacing.

Parameters:
  • cmd_word_list (bytearray) – list of binary words to be added to the binary data specification file
  • cmd_string (str) – string describing the command to be added to the report for the data specification file
  • indent (bool) – if the following lines need to be indented
  • outdent (bool) – if the following lines need to be out-dented
  • no_instruction_number – if each report line should include also the address of the command in the file
  • no_instruction_number – bool
Returns:

Nothing is returned

Return type:

None

Raises:
write_structure(structure_id, repeats=1, repeats_is_register=False)[source]

Insert command to write a structure to the current write pointer, causing the current write pointer to move on by the number of bytes needed to represent the structure

Parameters:
  • structure_id (int) –
    • If called within a function, the id of the structure to write, between 0 and 15
    • If called outside of a function, the id of the structure argument, between 0 and 5
  • repeats (int) –
    • If repeats_is_register is True, the id of the register containing the number of repeats, between 0 and 15
    • If repeats_is_register is False, the number of repeats to write, between 0 and 255
  • repeats_is_register (bool) – Identifies if repeats identifies a register
Returns:

No value returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If repeats_is_register is False and structure_id is not a valid id
    • If repeats_is_register is True and structure_id
    • If the number of repeats is out of range
  • data_specification.exceptions. DataSpecificationNoRegionSelectedException – If no region has been selected to write to
  • data_specification.exceptions. DataSpecificationRegionExhaustedException – If the selected region has no more space
write_value(data, repeats=1, repeats_is_register=False, data_type=<DataType.UINT32: 2>)[source]

Insert command to write a value one or more times to the current write pointer, causing the write pointer to move on by the number of bytes required to represent the data type. The data is passed as a parameter to this function

Parameters:
  • data (float) – the data to write as a float.
  • repeats (int) –
    • If repeats_is_register is False, this parameter identifies the number of times to repeat the data, between 1 and 255 (default 1)
    • If repeats_is_register is True, this parameter identifies the register that contains the number of repeats.
  • repeats_is_register (bool) – Indicates if the parameter repeats identifies the register containing the number of repeats of the value to write
  • data_type (DataType) – the type to convert data to
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If repeats_register is None, and repeats is out of range
    • If repeats_register is not a valid register id
    • If data_type is an integer type, and data has a fractional part
    • If data would overflow the data type
  • data_specification.exceptions. DataSpecificationUnknownTypeException – If the data type is not known
  • data_specification.exceptions. DataSpecificationInvalidSizeException – If the data size is invalid
  • data_specification.exceptions. DataSpecificationNoRegionSelectedException – If no region has been selected to write to
write_value_from_register(data_register, repeats=1, repeats_is_register=False, data_type=<DataType.UINT32: 2>)[source]

Insert command to write a value one or more times at the write pointer of the current memory region, causing it to move. The data is contained in a register whose id is passed to the function

Parameters:
  • data_register (int) – Identifies the register in which the data is stored.
  • repeats (int) –
    • If repeats_register is None, this parameter identifies the number of times to repeat the data, between 1 and 255 (default 1)
    • If repeats_register is not None (i.e. has an integer value), the content of this parameter is disregarded
  • repeats_is_register (None or int) – Identifies the register containing the number of repeats of the value to write
  • data_type (DataType) – the type of the data held in the register
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If repeats_register is None, and repeats is out of range
    • If repeats_register is not a valid register id
    • If data_register is not a valid register id
  • data_specification.exceptions. DataSpecificationUnknownTypeException – If the data type is not known
  • data_specification.exceptions. DataSpecificationNoRegionSelectedException – If no region has been selected to write to
  • data_specification.exceptions. DataSpecificationRegionExhaustedException – If the selected region has no more space

data_specification.exceptions module

exception data_specification.exceptions.DataSpecificationDuplicateParameterException(command, parameters)[source]

Bases: data_specification.exceptions.DataSpecificationException

And exception that indicates that a command has been called with a duplicate parameter, which shouldn’t be allowed.

Parameters:
  • command (int) – The command called with duplicate parameters
  • parameters (list) – The parameters used to call the function
exception data_specification.exceptions.DataSpecificationException(message)[source]

Bases: exceptions.Exception

A general purpose exception indicating that something went wrong when interacting with a Data Specification

Parameters:message (str) – message reporting the exception occurred
exception data_specification.exceptions.DataSpecificationFunctionInUse(function_id)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that a function is already defined

Parameters:function_id (int) – The id of the function
exception data_specification.exceptions.DataSpecificationInvalidCommandException(command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that the command being requested cannot be executed at this point in the specification

Parameters:command (str) – The command being executed
exception data_specification.exceptions.DataSpecificationInvalidOperationException(operation_type, requested_operation_id, command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that the operation of the type given type is not available

Parameters:
  • operation_type (str) – The type of operation requested (i.e. arithmetic or logic)
  • requested_operation_id (int) – The id of the requested operation
  • command (str) – The command being executed
exception data_specification.exceptions.DataSpecificationInvalidSizeException(type_name, type_size, command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that the size of the requested type is invalid

Parameters:
  • type_name (str) – The name of the requested type
  • type_size (int) – The size of the requested variable
  • command (str) – The command being executed
exception data_specification.exceptions.DataSpecificationNoMoreException(space_available, space_required, region)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that there is no more space for the requested item

Parameters:
  • space_available (int) – The space available in the region
  • space_required (int) – The space requested by the write command
exception data_specification.exceptions.DataSpecificationNoRegionSelectedException(command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that a memory region has not been selected

Parameters:command (str) – The command being executed
exception data_specification.exceptions.DataSpecificationNotAllocatedException(item_type, item_id, command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that an item is being used that has not been allocated

Parameters:
  • item_type (str) – The type of the item being used
  • item_id (int) – The id of the item being used
  • command (str) – The command being executed
exception data_specification.exceptions.DataSpecificationParameterOutOfBoundsException(parameter, value, range_min, range_max, command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that a parameter value was outside of the allowed bounds

Parameters:
  • parameter (str) – The parameter that is out of bounds
  • value (float) – The value specified
  • range_min (float) – The minimum allowed value
  • range_max (float) – The maximum allowed value
  • command (str) – The command being executed
exception data_specification.exceptions.DataSpecificationRNGInUseException(rng_id)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that a random number generator is already defined

Parameters:rng_id (int) – The id of the rng
exception data_specification.exceptions.DataSpecificationRandomNumberDistributionInUseException(rng_id)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that a random number distribution is already defined

Parameters:rng_id (int) – The id of the random number distribution
exception data_specification.exceptions.DataSpecificationRegionExhaustedException(region, region_size, allocated_size, command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that a region has run out of memory whilst some data is being written

Parameters:
  • region (int) – The region that was being written to
  • region_size (int) – The originally requested size of the region that has run out of space, in bytes
  • allocated_size (int) – The amount of the originally requested space that has already been allocated, in bytes
  • command (str) – The command being executed
exception data_specification.exceptions.DataSpecificationRegionInUseException(region)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that a region has already been allocated

Parameters:region (int) – The region that was already allocated
exception data_specification.exceptions.DataSpecificationRegionNotAllocated(region, command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception which occurs when trying to write to an unallocated region of memory

Parameters:
  • region
  • command
exception data_specification.exceptions.DataSpecificationRegionOutOfBoundsException(region, region_size, requested_offset, command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that an offset into a region is out of bounds for that region

Parameters:
  • region (int) – The region that was being offset into
  • region_size (int) – The originally requested size of the region in question, in bytes
  • requested_offset (int) – The offset being requested, in bytes
  • command (str) – The command being executed
exception data_specification.exceptions.DataSpecificationRegionUnfilledException(region, command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that a memory region is being used that was originally requested to be unfilled

Parameters:
  • region (int) – The region that was requested as unfilled
  • command (str) – The command being executed
exception data_specification.exceptions.DataSpecificationStructureInUseException(structure)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that a structure has already been defined

Parameters:structure (int) – The structure that was already allocated
exception data_specification.exceptions.DataSpecificationSyntaxError(message)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception which occurs when a command read from the data specification file shows an inconsistency in the binary content

Parameters:message (str) – message describing the error occurred
exception data_specification.exceptions.DataSpecificationTablePointerOutOfMemory(memory_available, memory_required)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception which occurs when building the table pointer as header of the data generated by the spec executor. This message is printed in case the memory available is not enough to contain the pointer table for each of the allocated regions

Parameters:
  • memory_available (int) – on-chip memory available
  • memory_required (int) – on-chip memory required to complete the execution of the specification file
exception data_specification.exceptions.DataSpecificationTypeMismatchException(command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that a type mismatch has occurred

Parameters:command (int) – The command that generated the exception
exception data_specification.exceptions.DataSpecificationUnknownConditionException(condition_id, command)[source]

Bases: data_specification.exceptions.DataSpecificationException

And exception which is triggered in case the condition in an IF test does not exist in the list of possible conditions

Parameters:
  • condition_id (int) – id of the condition being requested
  • command (str) – The command being executed
exception data_specification.exceptions.DataSpecificationUnknownTypeException(type_id, command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that the value of the requested type is unknown

Parameters:
  • type_id (int) – The id of the requested type
  • command (str) – The command being executed
exception data_specification.exceptions.DataSpecificationUnknownTypeLengthException(data_length, command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that the value of the requested type is unknown

Parameters:
  • data_length (int) – the length of the requested type
  • command (str) – The command being executed
exception data_specification.exceptions.DataSpecificationWrongParameterNumberException(function_id, no_of_parameters_required, parameters)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that a function has been called with a wrong number of parameters.

Parameters:
  • function_id (int) – The id of the function
  • parameters (list) – The parameters used in the function call
  • no_of_parameters_required – The number of parameters required by the function
exception data_specification.exceptions.DataUndefinedWriterException(message)[source]

Bases: exceptions.Exception

an exception that indicates that the file data writer has not been initialised

Parameters:message (str) – A message to indicate what when wrong
exception data_specification.exceptions.ExecuteBreakInstruction(address, filename)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception which occurs when a BREAK instruction is found in the data specification

Parameters:
  • address (int) – address of the data specification being executed at the time of breakpoint
  • filename – file being parsed
  • filename – str
exception data_specification.exceptions.NestedFunctionException[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception that indicates that a function is being defined within the context of another function definition

exception data_specification.exceptions.UnimplementedDSECommand(command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception which occurs when trying to execute an unimplemented command

Parameters:command (str) – Command attempted to be executed by the DSE
exception data_specification.exceptions.UnimplementedDSGCommand(command)[source]

Bases: data_specification.exceptions.DataSpecificationException

An exception which occurs when trying to write an unimplemented command

Parameters:command (str) – Command attempted to be generated by the DSG

data_specification.memory_region module

class data_specification.memory_region.MemoryRegion(memory_pointer, unfilled, size)[source]

Bases: object

Memory region storage object

Parameters:
  • memory_pointer – the write pointer position
  • unfilled – if the region needs to be filled when written
Return type:

None

Raises:

None – this method does not raise any known exception

allocated_size

property method for the size of the region

Returns:the size of the region
Return type:int
Raises:None – this method does not raise any known exception
increment_write_pointer(n_bytes)[source]
max_write_pointer
memory_pointer

property method to retrieve memory write pointer

Returns:the memory pointer of the region
Return type:int
Raises:None – this method does not raise any known exception
region_data

the container which holds the data written in this region

Returns:the region data container
Return type:bytearray
Raises:None – this method does not raise any known exception
unfilled

property method to retrieve if the region is filled

Returns:the the
Return type:None
Raises:None – this method does not raise any known exception
write_pointer

data_specification.memory_region_collection module

class data_specification.memory_region_collection.MemoryRegionCollection(n_regions)[source]

Bases: object

Collection of memory regions.

Create a new MemoryRegionCollection with the given number of regions.

count_used_regions()[source]
is_empty(region)[source]
is_unfilled(region)[source]
needs_to_write_region(region_id)[source]

helper method which determines if a unfilled region actually needs to be written (optimisation to stop large data files)

Parameters:region_id – the region id to which the test is being ran on
Returns:a boolean stating if the region needs to be written
Return type:boolean
Raises:DataSpecificationNoRegionSelectedException – when the id is beyond the expected region range
regions

data_specification.utility_calls module

utility calls for interpreting bits of the dsg

data_specification.utility_calls.get_data_spec_and_file_writer_filename(processor_chip_x, processor_chip_y, processor_id, hostname, report_directory, write_text_specs, application_run_time_report_folder)[source]

Encapsulates the creation of the dsg writer and the file paths

Parameters:
  • processor_chip_x (int) – x-coordinate of the chip
  • processor_chip_y (int) – y-coordinate of the chip
  • processor_id (int) – The processor ID
  • hostname (str) – The hostname of the spinnaker machine
  • report_directory (file path) – the directory for the reports folder
  • write_text_specs (bool) – True if a textual version of the specification should be written
  • application_run_time_report_folder (str) – The folder to contain the resulting specification files
Returns:

the filename of the data writer and the data specification object

Return type:

str, data_specification.DataSpecificationGenerator

data_specification.utility_calls.get_data_spec_file_path(processor_chip_x, processor_chip_y, processor_id, hostname, application_run_time_folder)[source]

Gets the file path for storing the dsg data

Parameters:
  • processor_chip_x (int) – The x-coordinate of a chip
  • processor_chip_y – The y-coordinate of a chip :type processor_chip_y: int
  • processor_id (int) – The processor ID
  • hostname (str) – The hostname of the spinnaker machine
Returns:

the filename of the data writer and the data specification object

Return type:

str, data_specification.DataSpecificationGenerator

data_specification.utility_calls.get_region_base_address_offset(app_data_base_address, region)[source]

Find the address of the of a given region for the dsg

Parameters:
  • app_data_base_address – base address for the core
  • region – the region id we’re looking for

Module contents

Used to generate memory images from a set of instructions.

The main part of this package is the data_specification.data_specification_generator.DataSpecificationGenerator class. This is used to generate a “Data Specification”, which can then be executed to produce a memory image. This package also handles this function if required, through the data_specification.data_specification_executor.DataSpecificationExecutor class.

Functional Requirements

  • Creation of a Data Specification Language file which can be executed to produce a memory image.

    • Any errors that can be checked during the creation of the specification should throw an exception.
    • It will be impossible to detect all errors at creation time.
    • There should be no assumption of where the data specification is be stored, although a default provision of a way to write the specification to a file is acceptable.
  • Execution of a Data Specification Language file, producing a memory image.

    • This should detect any errors during execution and report them, halting the execution.
    • There should be no assumption of where the data specification is read from, although a default provision of a way to read the specification from a file is acceptable.

Use Cases

There are a number of use-cases of this library:

  •       DataSpecificationGenerator is used to create a compressed memory image which can be expanded later, to reduce the amount of data that needs to be transferred over a slow connection.
  •       DataSpecificationExecutor is used to execute a previously generated specification at the receiving end of a slow connection.
class data_specification.DataSpecificationExecutor(spec_reader, memory_space)[source]

Bases: object

Used to execute a data specification language file to produce a memory image

Parameters:
  • spec_reader (data_specification.abstract_data_reader.                    AbstractDataReader) – The object to read the specification language file from
  • memory_space (int) – memory available on the destination architecture
Raises:
  • spinn_storage_handlers.exceptions.DataReadException – If a read from external storage fails
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
dsef
execute()[source]

Executes the specification

Returns:

The number of bytes used by the image and the number of bytes written by the image

Return type:

int

Raises:
  • spinn_storage_handlers.exceptions.DataReadException – If a read from external storage fails
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions.DataSpecificationException – If there is an error when executing the specification
  • data_specification.exceptions. DataSpecificationTablePointerOutOfMemory – If the table pointer generated as data header exceeds the size of the available memory
get_constructed_data_size()[source]

Return the size of the data that will be written to memory

Returns:size of the data that will be written to memory
Return type:unsigned int
get_header()[source]

Get the header of the data as a numpy array

get_pointer_table(start_address)[source]

Get the pointer table as a numpy array

Parameters:start_address – The base address of the data to be written
get_region(region_id)[source]

Get a region with a given id

Parameters:region_id (int) – The id of the region to get
Returns:The region, or None if the region was not allocated
spec_reader
class data_specification.DataSpecificationExecutorFunctions(spec_reader, memory_space)[source]

Bases: object

This class includes the function related to each of the commands of the data specification file.

Parameters:
  • spec_reader (data_specification.abstract_data_reader.            AbstractDataReader) – The object to read the specification language file from
  • memory_space (int) – Memory space available for the data to be generated
current_region
data_len
dest_reg
execute_align_wr_ptr(cmd)[source]
execute_arith_op(cmd)[source]
execute_block_copy(cmd)[source]
execute_break(cmd)[source]
This command raises an exception to stop the execution of the data spec
executor (DSE)
Parameters:cmd (int) – the command which triggered the function call
Returns:No value returned
Return type:None
Raises:data_specification.exceptions.ExecuteBreakInstruction – Raises the exception to break the execution of the DSE
execute_break_loop(cmd)[source]
execute_construct(cmd)[source]
execute_copy_param(cmd)[source]
execute_copy_struct(cmd)[source]
execute_declare_rng(cmd)[source]
execute_else(cmd)[source]
execute_end_constructor(cmd)[source]
execute_end_if(cmd)[source]
execute_end_loop(cmd)[source]
execute_end_spec(cmd)[source]

Return the value which terminates the data spec executor

Parameters:cmd (int) – the command which triggered the function call
Returns:constants.END_SPEC_EXECUTOR
Return type:int
Raises:data_specification.exceptions.DataSpecificationSyntaxError – If command END_SPEC != -1
execute_end_struct(cmd)[source]
execute_free(cmd)[source]
execute_get_random_rumber(cmd)[source]
execute_get_wr_ptr(cmd)[source]
execute_if(cmd)[source]
execute_logic_op(cmd)[source]
execute_loop(cmd)[source]
execute_mv(cmd)[source]

This command moves an immediate value to a register or copies the value of a register to another register

Parameters:cmd (int) – the command which triggered the function call
Returns:No value returned
Return type:None
Raises:data_specification.exceptions.DataSpecificationSyntaxError – if the destination register is not correctly specified - the destination must be a register and the appropriate bit needs to be set in the specification
execute_nop(cmd)[source]

This command executes no operation

Parameters:cmd (int) – the command which triggered the function call
Returns:No value returned
Return type:None
execute_print_struct(cmd)[source]
execute_print_txt(cmd)[source]
execute_print_val(cmd)[source]
execute_random_dist(cmd)[source]
execute_read(cmd)[source]
execute_read_param(cmd)[source]
execute_reformat(cmd)[source]
execute_reserve(cmd)[source]

This command reserves a region and assigns some memory space to it

Parameters:

cmd (int) – the command which triggered the function call

Returns:

No value returned

Return type:

None

Raises:
execute_reset_wr_ptr(cmd)[source]
execute_set_wr_ptr(cmd)[source]
execute_start_constructor(cmd)[source]
execute_start_struct(cmd)[source]
execute_struct_elem(cmd)[source]
execute_switch_focus(cmd)[source]

This command switches the focus to the desired, already allocated, memory region

Parameters:cmd (int) – the command which triggered the function call
Returns:No value returned
Return type:None
Raises:data_specification.exceptions. DataSpecificationRegionUnfilledException – If the focus is being switched to a region of memory which has been declared to be kept unfilled
execute_write(cmd)[source]

This command writes the given value in the specified region a number of times as identified by either a value in the command or a register value

Parameters:cmd (int) – the command which triggered the function call
Returns:No value returned
Return type:None
Raises:data_specification.exceptions.DataSpecificationSyntaxError – If there is an error in the command syntax
execute_write_array(cmd)[source]

This command writes an array of values in the specified region

Parameters:cmd (int) – the command which triggered the function call
Returns:No value returned
Return type:None
execute_write_param(cmd)[source]
execute_write_param_component(cmd)[source]
execute_write_struct(cmd)[source]
mem_regions
mem_writer
memory_space
opcode
registers
space_allocated
spec_reader
src1_reg
src2_reg
struct_slots
use_dest_reg
use_src1_reg
use_src2_reg
class data_specification.DataSpecificationGenerator(spec_writer, report_writer=None)[source]

Bases: object

Used to generate a data specification language file that can be executed to produce a memory image

Parameters:
  • spec_writer (Implementation of data_specification.abstract_data_writer.AbstractDataWriter) – The object to write the specification to
  • report_writer (Implementation of data_specification.abstract_data_writer.AbstractDataWriter) – Determines if a text version of the specification is to be written
Raises:

spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails

MAGIC_NUMBER = 2903706326
VERSION = 1
align_write_pointer(log_block_size, log_block_size_is_register=False, return_register_id=None)[source]

Insert command to align the write pointer against a power-of-2 block size in bytes. Zeros are inserted in the intervening space

Parameters:
  • log_block_size (int) –
    • If log_block_size_is_register is False, log to base 2 of the block size (e.g. The write pointer will be moved so that it is a multiple of 2^(log_block_size)), between 0 and 32
    • If log_block_size_is_register is True, the id of the register containing log to the base 2 of the block size, between 0 and 15
  • log_block_size_is_register (bool) – Indicates if log_block_size is a register id
  • return_register_id (int) – The id of a register where the write pointer will be written to once it has been updated, between 0 and 15or None if no such writing is to be done
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If log_block_size_is_register is False, and log_block_size is not within the allowed range
    • If log_block_size_is_register is True and log_block_size is not a valid register id
  • data_specification.exceptions. DataSpecificationRegionOutOfBoundsException – If the move of the pointer would put it outside of the current region
  • data_specification.exceptions. DataSpecificationNoRegionSelectedException – If no region has been selected
break_loop()[source]

Insert command to break out of a loop before it has completed

Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationInvalidCommandException – If there is no loop in operation at this point
call_arithmetic_operation(register_id, operand_1, operation, operand_2, signed, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform an arithmetic operation on two signed or unsigned values and store the result in a register

Parameters:
  • register_id (int) – The id of the register to store the result in
  • operand_1 (int) –
    • If operand_1_is_register is True, the id of a register where the first operand can be found, between 0 and 15
    • If operand_1_is_register is False, a 32-bit value
  • operation (ArithmeticOperation) – The operation to perform
  • operand_2 (int) –
    • If operand_2_is_register is True, the id of a register where the second operand can be found, between 0 and 15
    • If operand_2_is_register is False, a 32-bit value
  • signed (bool) – Indicates if the values should be considered signed
  • operand_1_is_register (bool) – Indicates if operand_1 is a register id
  • operand_2_is_register (bool) – Indicates if operand_2 is a register id
Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If operand_1_is_register is True and operand_1 is not a valid register id
    • If operand_2_is_register is True and operand_2 is not a valid register id
  • data_specification.exceptions. DataSpecificationUnknownTypeException – If operation is not a known operation
call_function(function_id, structure_ids)[source]

Insert command to call a function

Parameters:
  • function_id (int) – The id of a previously defined function, between 0 and 31
  • structure_ids (list of int) – A list of structure_ids that will be passed into the function, each between 0 and 15
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If the function id is not valid
    • If any of the structure ids are not valid
  • data_specification.exceptions. DataSpecificationNotAllocatedException
    • If a function has not been defined with the given id
    • If no structure has been defined with one of the ids in structure_ids
  • data_specification.exceptions. DataSpecificationWrongParameterNumberException – If a function is called with a wrong number of parameters
  • data_specification.exceptions. DataSpecificationDuplicateParameterException – If a function is called with duplicate parameters
call_random_distribution(distribution_id, register_id)[source]

Insert command to get the next random number from a random distribution, placing the result in a register to be used in a future call

Parameters:
  • distribution_id (int) – The id of the random distribution to call between 0 and 63
  • register_id (int) – The id of the register to store the result in between 0 and 15
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationNotAllocatedException – If the random distribution id was not previously declared
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If the distribution_id or register_id specified was out of range
comment(comment)[source]

Write a comment to the text version of the specification. Note that this is ignored by the binary file

Parameters:

comment (str) – The comment to write

Returns:

Nothing is returned

Raises:
conditionals
copy_structure(source_structure_id, destination_structure_id, source_id_is_register=False, destination_id_is_register=False)[source]

Insert command to copy a structure, possibly overwriting another structure

Parameters:
  • source_structure_id (int) –
    • If source_id_is_register is True, the id of the register holding the source structure id, between 0 and 15
    • Otherwise, the id of the source structure, between 0 and 15
  • destination_structure_id (int) –
    • If destination_id_is_register is True, the id of the register holding the destination structure id, between 0 and 15
    • If destination_id_is_register is False, the id of the destination structure, between 0 and 15
  • source_id_is_register (bool) – Indicates if source_structure_id is a register id
  • destination_id_is_register (bool) – Indicates if destination_structure_id is a register id
Returns:

The id of the copied structure, between 0 and 15

Return type:

int

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If source_id_is_register is True and source_structure_id is not a valid register id
    • If destination_id_is_register is True and destination_structure_id is not a valid register id
    • If source_id_is_register is False and source_structure_id is not a valid structure id
    • If destination_id_is_register is False and destination_structure_id is not a valid structure id
  • data_specification.exceptions. DataSpecificationNotAllocatedException
    • If no structure with id source_structure_id has been allocated
copy_structure_parameter(source_structure_id, source_parameter_index, destination_id, destination_parameter_index=None, destination_is_register=False)[source]

Insert command to copy the value of a parameter from one structure to another

Parameters:
  • source_structure_id (int) – The id of the source structure, between 0 and 15
  • source_parameter_index (int) – The index of the parameter in the source structure
  • destination_id (int) – The id of the destination structure, or the id of the destination register, between 0 and 15
  • destination_parameter_index (int) – The index of the parameter in the destination structure. Ignored when writing to a register.
  • destination_is_register (boolean) – Indicates whether the destination is a structure or a register.
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If source_structure_id is not a valid structure id
    • If destination_id is not a valid structure id
    • If source_parameter_index is not a valid parameter index in the source structure
    • If destination_parameter_index is not a valid parameter index in the destination structure
  • data_specification.exceptions. DataSpecificationNotAllocatedException
    • If no structure with id destination_id has been allocated
    • If no structure with id source_structure_id has been allocated
current_region
declare_random_number_generator(rng_id, rng_type, seed)[source]

Insert command to declare a random number generator

Parameters:
  • rng_id (int) – The id of the random number generator
  • rng_type (RandomNumberGenerator) – The type of the random number generator
  • seed (int) – The seed of the random number generator >= 0
Returns:

The id of the created random number generator, between 0 and 15

Return type:

int

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions.DataSpecification – If there is no more space for a new generator
  • data_specification.exceptions. DataSpecificationUnknownTypeException – If the rng_type is not one of the allowed values
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If the seed is too big or too small
    • If the rng_id is not in the allowed range
  • data_specification.exceptions .DataSpecificationRNGInUseException – If the random number generator with the given id has already been defined
declare_uniform_random_distribution(distribution_id, structure_id, rng_id, min_value, max_value)[source]

Insert commands to declare a uniform random distribution

Parameters:
  • distribution_id – id of the distribution being set up
  • distribution_id – int
  • structure_id (int) – id of an empty structure slot to fill with the uniform random distribution data
  • rng_id (int) – The id of the random number generator, between 0 and 15
  • min_value (float) – The minimum value that should be returned from the distribution between -32768.0 and max_value
  • max_value (float) – The maximum value that should be returned from the distribution between min_value and 32767.9999847
Returns:

The id of the created uniform random distribution to be used in future calls of the distribution between 0 and 63

Return type:

int

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions.DataSpecificationNoMoreException – If there is no more space for a new random distribution
  • data_specification.exceptions. DataSpecificationNotAllocatedException – If the requested rng_id has not been allocated
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If rng_id, structure_id, min_value or max_value is out of range
  • data_specification.exceptions. DataSpecificationStructureInUseException – If structure structure_id is already defined
define_break()[source]

Insert command to stop execution with an exception (for debugging)

Returns:

Nothing is returned

Return type:

None

Raises:
define_structure(structure_id, parameters)[source]

Insert commands to define a data structure

Parameters:
  • structure_id (int) – the id of the structure to create, between 0 and 15
  • parameters (list of (str, DataType, float)) – A list of between 1 and 255 tuples of (label, data_type, value) where: * label is the label of the element (for debugging) * data_type is the data type of the element * value is the value of the element, or None if no value is to be assigned
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions.DataSpecificationNoMoreException – If there are no more spaces for new structures
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If there are an incorrect number of parameters
    • If the size of one of the tuples is incorrect
    • If one of the values to be assigned has an integer data_type but has a fractional part
    • If one of the values to be assigned would overflow its data_type
  • data_specification.exceptions. DataSpecificationUnknownTypeException – If one of the data types in the structure is unknown
else_conditional()[source]

Insert command for the else of an if…then…else construct. If the condition of the conditional evaluates to false, the statements up between the conditional and the insertion of this “else” are skipped, and the statements from this point until the end of the conditional are executed.

Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationInvalidCommandException – If there is no conditional in operation at this point
end_conditional()[source]

Insert command to mark the end of an if…then…else construct

Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationInvalidCommandException – If there is no conditional in operation at this point
end_function()[source]

Insert command to mark the end of a function definition

Returns:Nothing is returned
Return type:None
Raises:data_specification.exceptions. DataSpecificationInvalidCommandException – If there is no function being defined at this point
end_loop()[source]

Insert command to indicate that this is the end of the loop. Commands between the start of the loop and this command will be repeated.

Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationInvalidCommandException – If there is no loop in operation at this point
end_specification(close_writer=True)[source]

Insert a command to indicate that the specification has finished and finish writing

Parameters:

close_writer (bool) – Indicates whether to close the underlying writer(s)

Returns:

Nothing is returned

Return type:

None

Raises:
free_memory_region(region)[source]

Insert command to free a previously reserved memory region

Parameters:

region (int) – The number of the region to free, from 0 to 15

Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationNotAllocatedException – If the region was not reserved
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If the region requested was out of the allowed range
function
get_structure_value(destination_id, structure_id, parameter_index, parameter_index_is_register=False)[source]

Insert command to get a value from a structure. The value is copied in a register.

Parameters:
  • destination_id (int) – The id of the destination register
  • structure_id (int) – The id of the source structure
  • parameter_index (int) – The id of the parameter/element to copy
  • parameter_index_is_register (bool) – True if the index of the structure is contained in a register
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If structure_id is not in the allowed range
    • If parameter_index is larger than the number of parameters declared in the original structure
    • If destination_id is not the id of a valid register
    • If parameter_index_is_register is True and parameter_index is not a valid register id
  • data_specification.exceptions. DataSpecificationNotAllocatedException – If the structure requested has not been declared
instruction_counter
logical_and(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical AND operation, using the _call_logic_operation.

Parameters:
  • register_id (int) – The id of the register to store the result in
  • operand_1 (int) –
    • If operand_1_is_register is True, the id of a register where the first operand can be found, between 0 and 15
    • If operand_1_is_register is False, a 32-bit value
  • operand_2 (int) –
    • If operand_2_is_register is True, the id of a register where the second operand can be found. between 0 and 15
    • If operand_2_is_register is False, a 32-bit value
  • operand_1_is_register (bool) – Indicates if operand_1 is a register id
  • operand_2_is_register (bool) – Indicates if operand_2 is a register id
Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If operand_1_is_register is True and operand_1 is not a valid register id
    • If operand_2_is_register is True and operand_2 is not a valid register id
logical_left_shift(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical left shift operation, using the _call_logic_operation.

Parameters:
  • register_id (int) – The id of the register to store the result in
  • operand_1 (int) –
    • If operand_1_is_register is True, the id of a register where the first operand can be found, between 0 and 15
    • If operand_1_is_register is False, a 32-bit value
  • operand_2 (int) –
    • If operand_2_is_register is True, the id of a register where the second operand can be found. between 0 and 15
    • If operand_2_is_register is False, a 32-bit value
  • operand_1_is_register (bool) – Indicates if operand_1 is a register id
  • operand_2_is_register (bool) – Indicates if operand_2 is a register id
Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If operand_1_is_register is True and operand_1 is not a valid register id
    • If operand_2_is_register is True and operand_2 is not a valid register id
logical_not(register_id, operand, operand_is_register=False)[source]
Insert command to perform a logical xor operation, using
the _call_logic_operation.
Parameters:
  • register_id (int) – The id of the register to store the result in
  • operand (int) –
    • If operand_is_register is True, the id of a register where the first operand can be found, between 0 and 15
    • If operand_is_register is False, a 32-bit value
  • operand_is_register (bool) – Indicates if operand_1 is a register id
Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If operand_is_register is True and operand_1 is not a valid register id
logical_or(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical OR operation, using the _call_logic_operation.

Parameters:
  • register_id (int) – The id of the register to store the result in
  • operand_1 (int) –
    • If operand_1_is_register is True, the id of a register where the first operand can be found, between 0 and 15
    • If operand_1_is_register is False, a 32-bit value
  • operand_2 (int) –
    • If operand_2_is_register is True, the id of a register where the second operand can be found. between 0 and 15
    • If operand_2_is_register is False, a 32-bit value
  • operand_1_is_register (bool) – Indicates if operand_1 is a register id
  • operand_2_is_register (bool) – Indicates if operand_2 is a register id
Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If operand_1_is_register is True and operand_1 is not a valid register id
    • If operand_2_is_register is True and operand_2 is not a valid register id
logical_right_shift(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]

Insert command to perform a logical right shift operation, using the _call_logic_operation.

Parameters:
  • register_id (int) – The id of the register to store the result in
  • operand_1 (int) –
    • If operand_1_is_register is True, the id of a register where the first operand can be found, between 0 and 15
    • If operand_1_is_register is False, a 32-bit value
  • operand_2 (int) –
    • If operand_2_is_register is True, the id of a register where the second operand can be found. between 0 and 15
    • If operand_2_is_register is False, a 32-bit value
  • operand_1_is_register (bool) – Indicates if operand_1 is a register id
  • operand_2_is_register (bool) – Indicates if operand_2 is a register id
Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If operand_1_is_register is True and operand_1 is not a valid register id
    • If operand_2_is_register is True and operand_2 is not a valid register id
logical_xor(register_id, operand_1, operand_2, operand_1_is_register=False, operand_2_is_register=False)[source]
Insert command to perform a logical xor operation, using
the _call_logic_operation.
Parameters:
  • register_id (int) – The id of the register to store the result in
  • operand_1 (int) –
    • If operand_1_is_register is True, the id of a register where the first operand can be found, between 0 and 15
    • If operand_1_is_register is False, a 32-bit value
  • operand_2 (int) –
    • If operand_2_is_register is True, the id of a register where the second operand can be found. between 0 and 15
    • If operand_2_is_register is False, a 32-bit value
  • operand_1_is_register (bool) – Indicates if operand_1 is a register id
  • operand_2_is_register (bool) – Indicates if operand_2 is a register id
Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If operand_1_is_register is True and operand_1 is not a valid register id
    • If operand_2_is_register is True and operand_2 is not a valid register id
mem_slot
no_operation()[source]

Insert command to execute nothing

Returns:

Nothing is returned

Return type:

None

Raises:
ongoing_function_definition
ongoing_loop
print_struct(structure_id, structure_id_is_register=False)[source]

Insert command to print out a structure (for debugging)

Parameters:
  • structure_id (int) –
    • If structure_id_is_register is True, the id of the register containing the id of the structure to print, between 0 and 15
    • If structure_id_is_register is False, the id of the structure to print, between 0 and 15
  • structure_id_is_register (bool) – Indicates if the structure_id is a register
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If structure_id_is_register is True and structure_id is not a valid register id
    • If structure_id_is_register is False and structure_id is not a valid structure id
  • data_specification.exceptions. DataSpecificationNotAllocatedException – If structure_id_is_register is False and structure_id is the id of a structure that has not been allocated
print_text(text)[source]

Insert command to print some text (for debugging)

Parameters:

text (str) – The text to write (max 12 characters)

Returns:

Nothing is returned

Return type:

None

Raises:
print_value(value, value_is_register=False, data_type=<DataType.UINT32: 2>)[source]

Insert command to print out a value (for debugging)

Parameters:
  • value (float) –
    • If value_is_register is True, the id of the register containing the value to print
    • If value_is_register is False, the value to print as a float
  • value_is_register (bool) – Indicates if the value is a register
  • data_type (DataType) – The type of the data to be printed
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If value_is_register is True and value is not a valid register id
    • If value_is_register is False, the data_type is an integer type and value has a fractional part
    • If value_is_register is False and the value would overflow the data type
  • data_specification.exceptions. DataSpecificationUnknownTypeException
    • If data_type is not a valid data type
random_distribution
read_value(dest_id, data_type)[source]

Insert command to read a value from the current write pointer, causing the write pointer to move by the number of bytes read. The data is stored in a register passed as argument.

Parameters:
  • dest_id (int) – The id of the destination register.
  • data_type (DataType) – The type of the data to be read.
Returns:

Nothing is returned

Return type:

None

region_sizes

A list of sizes of each region that has been reserved. Note that the list will include 0s for each non-reserved region.

report_writer
reserve_memory_region(region, size, label=None, empty=False, shrink=True)[source]

Insert command to reserve a memory region

Parameters:
  • region (int) – The number of the region to reserve, from 0 to 15
  • size (int) – The size to reserve for the region in bytes
  • label (str) – An optional label for the region
  • empty (bool) – Specifies if the region will be left empty
  • shrink (bool) – Specifies if the region will be compressed
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationRegionInUseException – If the region was already reserved
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If the region requested was out of the allowed range, or that the size was too big to fit in SDRAM
rng
save_write_pointer(register_id)[source]

Insert command to save the write pointer to a register

Parameters:

register_id (int) – The id of the register to assign, between 0 and 15

Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If the register_id is not a valid register id
  • data_specification.exceptions. DataSpecificationNoRegionSelectedException – If no region has been selected
set_register_value(register_id, data, data_is_register=False, data_type=<DataType.UINT32: 2>)[source]

Insert command to set the value of a register

Parameters:
  • register_id (int) – The id of the register to assign, between 0 and 15
  • data (float) –
    • If data_is_register is True, the register id containing the data to set, between 0 and 15
    • If data_is_register is False, the data as a float
  • data_is_register (bool) – Indicates if data is a register id
  • data_type (DataType) – The type of the data to be assigned
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If register_id is not a valid register_id
    • If data_is_register is True, and data is not a valid register id
    • If data_is_register is False, data_type is an integer type and data has a fractional part
    • If data_is_register if False, and data would overflow the data type
  • data_specification.exceptions. DataSpecificationUnknownTypeException – If the data type is not known
set_structure_value(structure_id, parameter_index, value, data_type, value_is_register=False)[source]

Insert command to set a value in a structure

Parameters:
  • structure_id (int) –
    • If called outside of a function, the id of the structure between 0 and 15
    • If called within a function, the id of the structure argument, between 0 and 4
  • parameter_index (int) – The index of the value to assign in the structure, between 0 and the number of parameters declared in the structure
  • value (float) –
    • If value_is_register is False, the value to assign at the selected position as a float
    • If value_is_register is True, the id of the register containing the value to assign to the position, between 0 and 15
  • data_type (DataType) – type of the data to be stored in the structure. If parameter value_is_register is set to true, this variable is disregarded
  • value_is_register (bool) – Identifies if value identifies a register
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If structure_id is not in the allowed range
    • If parameter_index is larger than the number of parameters declared in the original structure
    • If value_is_register is False, and the data type of the structure value is an integer, and the value has a fractional part
    • If value_is_register is False, and value would overflow the position in the structure
    • If value_is_register is True, and value is not a valid register id
  • data_specification.exceptions. DataSpecificationNotAllocatedException – If the structure requested has not been declared
set_write_pointer(address, address_is_register=False, relative_to_current=False)[source]

Insert command to set the position of the write pointer within the current region

Parameters:
  • address (int) –
    • If address_is_register is True, the id of the register containing the address to move to
    • If address_is_register is False, the address to move the write pointer to
  • address_is_register (bool) – Indicates if the the address is a register id
  • relative_to_current (bool) – Indicates if the address is to be added to the current address, or used as an absolute address from the start of the current region
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If the address_is_register is True and address is not a valid register id
  • data_specification.exceptions. DataSpecificationNoRegionSelectedException – If no region has been selected
spec_writer
start_conditional(register_id, condition, value, value_is_register=False)[source]

Insert command to start a conditional if…then…else construct. If the condition evaluates to true, the statement is executed up to the next else statement, or the end of the conditional, whichever comes first.

Parameters:
  • register_id (int) – The id of a register to compare the value of
  • condition (Condition) – The condition which must be true to execute the following commands
  • value (int) –
    • If value_is_register is False, the value to compare to the value in the register
    • If value_is_register is True, the id of the register containing the value to compare, between 0 and 15
  • value_is_register (bool) – Indicates if value is a register id
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If the register_id is not a valid register id
    • if value_is_register is True and value is not a valid register id
  • data_specification.exceptions. DataSpecificationUnknownTypeException – If the condition is not a valid condition
start_function(function_id, argument_by_value)[source]

Insert command to start a function definition, with up to 5 arguments, which are the ids of structures to be used within the function, each of which can be passed by reference or by value. In the commands following this command up to the end_function command, structures can only be referenced using the numbers 1 to 5 which address the arguments, rather than the original structure ids

Parameters:
  • function_id (int) – The id of the function currently defined.
  • argument_by_value (list of bool) – A list of up to 5 booleans indicating if the structure to be passed as an argument is to be passed by reference (i.e. changes made within the function are persisted) or by value (i.e. changes made within the function are lost when the function exits. The number of arguments is determined by the length of this list.
Returns:

The id of the function, between 0 and 31

Return type:

int

Raises:
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If there are too many items in the list of arguments
  • data_specification.exceptions. DataSpecificationInvalidCommandException – If there is already a function being defined at this point
  • data_specification.exceptions. DataSpecificationFunctionInUse – If the function is already defined
start_loop(counter_register_id, start, end, increment=1, start_is_register=False, end_is_register=False, increment_is_register=False)[source]

Insert command to start a loop

Parameters:
  • counter_register_id (int) – The id of the register to use as the loop counter, between 0 and 15
  • start (int) –
    • If start_is_register is False, the number at which to start the loop counter, >= 0
    • If start_is_register is True, the id of the register containing the number at which to start the loop counter, between 0 and 15
  • end (int) –
    • If end_is_register is False, the number which the loop counter must reach to stop the loop i.e. the loop will run while the contents of counter_register < end, >= 0
    • If end_is_register is True, the id of the register containing the number at which to stop the loop, between 0 and 15
  • increment (int) –
    • If increment_is_register is False, the amount by which to increment the loop counter on each run of the loop, >= 0
    • If increment_is_register is True, the id of the register containing the amount by which to increment the loop counter on each run of the loop, between 0 and 15
  • start_is_register (bool) – Indicates if start is a register id
  • end_is_register (bool) – Indicates if end is a register id
  • increment_is_register (bool) – Indicates if increment is a register id
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If counter_register_id is not a valid register id
    • If start_is_register is True and increment is not a valid register_id
    • If end_is_register is True and increment is not a valid register_id
    • If increment_is_register is True, and increment is not a valid register_id
    • If start_is_register is False and start is not in the allowed range
    • If end_is_register is False and end is not in the allowed range
    • If increment_is_register is False and increment is not in the allowed range
struct_slot
switch_write_focus(region)[source]

Insert command to switch the region being written to

Parameters:

region (int) – The id of the region to switch to, between 0 and 15

Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException – If the region identifier is not valid
  • data_specification.exceptions. DataSpecificationNotAllocatedException – If the region has not been allocated
  • data_specification.exceptions. DataSpecificationRegionUnfilledException – If the selected region should not be filled
txt_indent
write_array(array_values, data_type=<DataType.UINT32: 2>)[source]

Insert command to write an array, causing the write pointer to move on by (data type size * the array size), in bytes.

Parameters:
Returns:

The position of the write pointer within the current region, in bytes from the start of the region

Return type:

int

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationNoRegionSelectedException – If no region has been previously selected
write_command_to_files(cmd_word_list, cmd_string, indent=False, outdent=False, no_instruction_number=False)[source]

Writes the binary command to the binary output file and, if the user has requested a text output for debug purposes, also write the text version to the text file. Setting the optional parameter ‘indent’ to True causes subsequent commands to be indented by two spaces relative to this one. Similarly, setting ‘outdent’ to True, reverses this spacing.

Parameters:
  • cmd_word_list (bytearray) – list of binary words to be added to the binary data specification file
  • cmd_string (str) – string describing the command to be added to the report for the data specification file
  • indent (bool) – if the following lines need to be indented
  • outdent (bool) – if the following lines need to be out-dented
  • no_instruction_number – if each report line should include also the address of the command in the file
  • no_instruction_number – bool
Returns:

Nothing is returned

Return type:

None

Raises:
write_structure(structure_id, repeats=1, repeats_is_register=False)[source]

Insert command to write a structure to the current write pointer, causing the current write pointer to move on by the number of bytes needed to represent the structure

Parameters:
  • structure_id (int) –
    • If called within a function, the id of the structure to write, between 0 and 15
    • If called outside of a function, the id of the structure argument, between 0 and 5
  • repeats (int) –
    • If repeats_is_register is True, the id of the register containing the number of repeats, between 0 and 15
    • If repeats_is_register is False, the number of repeats to write, between 0 and 255
  • repeats_is_register (bool) – Identifies if repeats identifies a register
Returns:

No value returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If repeats_is_register is False and structure_id is not a valid id
    • If repeats_is_register is True and structure_id
    • If the number of repeats is out of range
  • data_specification.exceptions. DataSpecificationNoRegionSelectedException – If no region has been selected to write to
  • data_specification.exceptions. DataSpecificationRegionExhaustedException – If the selected region has no more space
write_value(data, repeats=1, repeats_is_register=False, data_type=<DataType.UINT32: 2>)[source]

Insert command to write a value one or more times to the current write pointer, causing the write pointer to move on by the number of bytes required to represent the data type. The data is passed as a parameter to this function

Parameters:
  • data (float) – the data to write as a float.
  • repeats (int) –
    • If repeats_is_register is False, this parameter identifies the number of times to repeat the data, between 1 and 255 (default 1)
    • If repeats_is_register is True, this parameter identifies the register that contains the number of repeats.
  • repeats_is_register (bool) – Indicates if the parameter repeats identifies the register containing the number of repeats of the value to write
  • data_type (DataType) – the type to convert data to
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If repeats_register is None, and repeats is out of range
    • If repeats_register is not a valid register id
    • If data_type is an integer type, and data has a fractional part
    • If data would overflow the data type
  • data_specification.exceptions. DataSpecificationUnknownTypeException – If the data type is not known
  • data_specification.exceptions. DataSpecificationInvalidSizeException – If the data size is invalid
  • data_specification.exceptions. DataSpecificationNoRegionSelectedException – If no region has been selected to write to
write_value_from_register(data_register, repeats=1, repeats_is_register=False, data_type=<DataType.UINT32: 2>)[source]

Insert command to write a value one or more times at the write pointer of the current memory region, causing it to move. The data is contained in a register whose id is passed to the function

Parameters:
  • data_register (int) – Identifies the register in which the data is stored.
  • repeats (int) –
    • If repeats_register is None, this parameter identifies the number of times to repeat the data, between 1 and 255 (default 1)
    • If repeats_register is not None (i.e. has an integer value), the content of this parameter is disregarded
  • repeats_is_register (None or int) – Identifies the register containing the number of repeats of the value to write
  • data_type (DataType) – the type of the data held in the register
Returns:

Nothing is returned

Return type:

None

Raises:
  • data_specification.exceptions.DataUndefinedWriterException – If the binary specification file writer has not been initialised
  • spinn_storage_handlers.exceptions.DataWriteException – If a write to external storage fails
  • data_specification.exceptions. DataSpecificationParameterOutOfBoundsException
    • If repeats_register is None, and repeats is out of range
    • If repeats_register is not a valid register id
    • If data_register is not a valid register id
  • data_specification.exceptions. DataSpecificationUnknownTypeException – If the data type is not known
  • data_specification.exceptions. DataSpecificationNoRegionSelectedException – If no region has been selected to write to
  • data_specification.exceptions. DataSpecificationRegionExhaustedException – If the selected region has no more space
class data_specification.MemoryRegion(memory_pointer, unfilled, size)[source]

Bases: object

Memory region storage object

Parameters:
  • memory_pointer – the write pointer position
  • unfilled – if the region needs to be filled when written
Return type:

None

Raises:

None – this method does not raise any known exception

allocated_size

property method for the size of the region

Returns:the size of the region
Return type:int
Raises:None – this method does not raise any known exception
increment_write_pointer(n_bytes)[source]
max_write_pointer
memory_pointer

property method to retrieve memory write pointer

Returns:the memory pointer of the region
Return type:int
Raises:None – this method does not raise any known exception
region_data

the container which holds the data written in this region

Returns:the region data container
Return type:bytearray
Raises:None – this method does not raise any known exception
unfilled

property method to retrieve if the region is filled

Returns:the the
Return type:None
Raises:None – this method does not raise any known exception
write_pointer
class data_specification.MemoryRegionCollection(n_regions)[source]

Bases: object

Collection of memory regions.

Create a new MemoryRegionCollection with the given number of regions.

count_used_regions()[source]
is_empty(region)[source]
is_unfilled(region)[source]
needs_to_write_region(region_id)[source]

helper method which determines if a unfilled region actually needs to be written (optimisation to stop large data files)

Parameters:region_id – the region id to which the test is being ran on
Returns:a boolean stating if the region needs to be written
Return type:boolean
Raises:DataSpecificationNoRegionSelectedException – when the id is beyond the expected region range
regions