lib_xs1#

lib_xs1 is a system library that provides low level tools for accessing the XCORE hardware. Primarily, this is useful for accessing processor and system registers.

For other types of hardware access, such as channels and locks, see lib_xcore.

lib_xs1 is automatically linked, so to use it, just include the header:

//Note: <xs1.h> is still the correct header, even if using an xs2 or xs3 architecture
#include <xs1.h>

A collection of macros and constants are defined in this header depending on the underlying hardware.

Platform Defines

API details#

These functions can be used in conjunction with the Platform Defines to access the underlying registers.

xs1.h#

XS1 Hardware routines.

This file contains functions to access XS1 hardware.

Functions

unsigned getps(unsigned reg)#

Gets the value of a processor state register.

This corresponds with the GETPS instruction. An exception is raised if the argument is not a legal processor state register.

Parameters:
  • reg – The processor state register to read.

Returns:

The value of the processor state register.

void setps(unsigned reg, unsigned value)#

Sets the value of a processor state register.

Corresponds with the SETPS instruction. An exception is raised if the argument is not a legal processor state register.

Parameters:
  • reg – The processor state register to write.

  • value – The value to set the processor state register to.

int read_pswitch_reg(unsigned tileid, unsigned reg, unsigned *data)#

Reads the value of a processor switch register.

The read is of the processor switch which is local to the specified tile id. On success 1 is returned and the value of the register is assigned to data. If an error acknowledgement is received or if the register number or tile identifier is too large to fit in the read packet then 0 is returned.

See also

read_sswitch_reg

Parameters:
  • tileid – The tile identifier.

  • reg – The number of the register.

  • data[out] The value read from the register.

Returns:

Whether the read was successful.

int read_sswitch_reg(unsigned tileid, unsigned reg, unsigned *data)#

Reads the value of a system switch register.

The read is of the system switch which is local to the specified tile id. On success 1 is returned and the value of the register is assigned to data. If an error acknowledgement is received or if the register number or tile identifier is too large to fit in the read packet then 0 is returned.

See also

read_pswitch_reg

Parameters:
  • tileid – The tile identifier.

  • reg – The number of the register.

  • data[out] The value read from the register.

Returns:

Whether the read was successful.

int write_pswitch_reg(unsigned tileid, unsigned reg, unsigned data)#

Writes a value to a processor switch register.

The write is of the processor switch which is local to the specified tile id. If a successful acknowledgement is received then 1 is returned. If an error acknowledgement is received or if the register number or tile identifier is too large to fit in the write packet then 0 is returned.

See also

read_pswitch_reg

See also

read_sswitch_reg

Parameters:
  • tileid – The tile identifier.

  • reg – The number of the register.

  • data – The value to write to the register.

Returns:

Whether the write was successful.

int write_pswitch_reg_no_ack(unsigned tileid, unsigned reg, unsigned data)#

Writes a value to a processor switch register without acknowledgement.

The write is of the processor switch which is local to the specified tile id. Unlike write_pswitch_reg() this function does not wait until the write has been performed. If the register number or tile identifier is too large to fit in the write packet 0 is returned, otherwise 1 is returned. Because no acknowledgement is requested the return value does not reflect whether the write succeeded.

See also

read_pswitch_reg

See also

read_sswitch_reg

Parameters:
  • tileid – The tile identifier.

  • reg – The number of the register.

  • data – The value to write to the register.

Returns:

Whether the parameters are valid.

int write_sswitch_reg(unsigned tileid, unsigned reg, unsigned data)#

Writes a value to a system switch register.

The write is of the system switch which is local to the specified tile id. If a successful acknowledgement is received then 1 is returned. If an error acknowledgement is received or if the register number or tile identifier is too large to fit in the write packet then 0 is returned.

See also

read_pswitch_reg

See also

read_sswitch_reg

Parameters:
  • tileid – The tile identifier.

  • reg – The number of the register.

  • data – The value to write to the register.

Returns:

Whether the write was successful.

int write_sswitch_reg_no_ack(unsigned tileid, unsigned reg, unsigned data)#

Writes a value to a system switch register without acknowledgement.

The write is of the system switch which is local to the specified tile id. Unlike write_sswitch_reg() this function does not wait until the write has been performed. If the register number or tile identifier is too large to fit in the write packet 0 is returned, otherwise 1 is returned. Because no acknowledgement is requested the return value does not reflect whether the write succeeded.

See also

read_pswitch_reg

See also

read_sswitch_reg

Parameters:
  • tileid – The tile identifier.

  • reg – The number of the register.

  • data – The value to write to the register.

Returns:

Whether the parameters are valid.

unsigned get_local_tile_id(void)#

Returns the routing ID of the tile on which the caller is running.

The routing ID uniquely identifies a tile on the network.

See also

get_tile_id

Returns:

The tile identifier.

unsigned get_logical_core_id(void)#

Returns the identifier of the logical core on which the caller is running.

The identifier uniquely identifies a logical core on the current tile.

Returns:

The logical core identifier.