GLOBAL_CONTEXT
= None (Context)
GLOBAL_CONTEXT is a convenience variable to store fallback TTExaLens context object. If a library function needs context parameter but it isn't provided, it will use whatever is in GLOBAL_CONTEXT variable. This does not mean that TTExaLens context is a singleton, as it can be explicitly provided to library functions.
init_ttexalens(wanted_devices=None, cache_path=None, init_jtag=False, use_noc1=False) -> Context
Initializes TTExaLens internals by creating the device interface and TTExaLens context. Interfacing device is local, through pybind.
wanted_devices
(list, optional): List of device IDs we want to connect to. If None, connect to all available devices.caching_path
(str, optional): Path to the cache file to write. If None, caching is disabled.
(Context): TTExaLens context object.
init_ttexalens_remote(ip_address=localhost, port=5555, cache_path=None) -> Context
Initializes TTExaLens internals by creating the device interface and TTExaLens context. Interfacing device is done remotely through TTExaLens client.
ip_address
(str): IP address of the TTExaLens server. Default is 'localhost'.port
(int): Port number of the TTExaLens server interface. Default is 5555.cache_path
(str, optional): Path to the cache file to write. If None, caching is disabled.
(Context): TTExaLens context object.
init_ttexalens_cached(cache_path) -> None
Initializes TTExaLens internals by reading cached session data. There is no connection to the device. Only cached commands are available.
cache_path
(str): Path to the cache file.
(Context): TTExaLens context object.
get_cluster_desc_yaml(lens_ifc) -> tuple[util.YamlFile, util.YamlFile]
Get the runtime data and cluster description yamls through the TTExaLens interface.
load_context(server_ifc, use_noc1=False) -> Context
Load the TTExaLens context object with specified parameters.
set_active_context(context) -> None
Set the active TTExaLens context object.
context
(Context): TTExaLens context object.
- Every new context initialization will overwrite the currently active context.
locate_most_recent_build_output_dir() -> str | None
Try to find a default output directory.
read_word_from_device(core_loc, addr, device_id=0, context=None) -> int
Reads one word of data, from address 'addr' at core .
core_loc
(str | OnChipCoordinate): Either X-Y (noc0/translated) or X,Y (logical) location of a core in string format, dram channel (e.g. ch3), or OnChipCoordinate object.addr
(int): Memory address to read from.device_id
(int, default 0): ID number of device to read from.context
(Context, optional): TTExaLens context object used for interaction with device. If None, global context is used and potentailly initialized.
(int): Data read from the device.
read_words_from_device(core_loc, addr, device_id=0, word_count=1, context=None) -> List[int]
Reads word_count four-byte words of data, starting from address 'addr' at core .
core_loc
(str | OnChipCoordinate): Either X-Y (noc0/translated) or X,Y (logical) location of a core in string format, dram channel (e.g. ch3), or OnChipCoordinate object.addr
(int): Memory address to read from.device_id
(int, default 0): ID number of device to read from.word_count
(int, default 1): Number of 4-byte words to read.context
(Context, optional): TTExaLens context object used for interaction with device. If None, global context is used and potentailly initialized.
(List[int]): Data read from the device.
read_from_device(core_loc, addr, device_id=0, num_bytes=4, context=None) -> bytes
Reads num_bytes of data starting from address 'addr' at core .
core_loc
(str | OnChipCoordinate): Either X-Y (noc0/translated) or X,Y (logical) location of a core in string format, dram channel (e.g. ch3), or OnChipCoordinate object.addr
(int): Memory address to read from.device_id
(int, default 0): ID number of device to read from.num_bytes
(int, default 4): Number of bytes to read.context
(Context, optional): TTExaLens context object used for interaction with device. If None, global context is used and potentially initialized.
(bytes): Data read from the device.
write_words_to_device(core_loc, addr, data, device_id=0, context=None) -> int
Writes data word to address 'addr' at noc0 location x-y of the current chip.
core_loc
(str | OnChipCoordinate): Either X-Y (noc0/translated) or X,Y (logical) location of a core in string format, dram channel (e.g. ch3), or OnChipCoordinate object.addr
(int): Memory address to write to. If multiple words are to be written, the address is the starting address.data
(int | List[int]): 4-byte integer word to be written, or a list of them.device_id
(int, default 0): ID number of device to write to.context
(Context, optional): TTExaLens context object used for interaction with device. If None, global context is used and potentailly initialized.
(int): If the execution is successful, return value should be 4 (number of bytes written).
write_to_device(core_loc, addr, data, device_id=0, context=None) -> int
Writes data to address 'addr' at noc0 location x-y of the current chip.
core_loc
(str | OnChipCoordinate): Either X-Y (noc0/translated) or X,Y (logical) location of a core in string format, dram channel (e.g. ch3), or OnChipCoordinate object.addr
(int): Memory address to write to.data
(List[int] | bytes): Data to be written. Lists are converted to bytes before writing, each element a byte. Elements must be between 0 and 255.device_id
(int, default 0): ID number of device to write to.context
(Context, optional): TTExaLens context object used for interaction with device. If None, global context is used and potentailly initialized.
(int): If the execution is successful, return value should be number of bytes written.
load_elf(elf_file, core_loc, risc_id=0, device_id=0, context=None) -> None
Loads the given ELF file into the specified RISC core. RISC core must be in reset before loading the ELF.
elf_file
(os.PathLike): Path to the ELF file to run.core_loc
(str | OnChipCoordinate | List[str | OnChipCoordinate]): One of the following:
- "all" to run the ELF on all cores;
- an X-Y (noc0/translated) or X,Y (logical) location of a core in string format;
- a list of X-Y (noc0/translated), X,Y (logical) or OnChipCoordinate locations of cores, possibly mixed;
- an OnChipCoordinate object.
risc_id
(int, default 0): RiscV ID (0: brisc, 1-3 triscs).device_id
(int, default 0): ID number of device to run ELF on.context
(Context, optional): TTExaLens context object used for interaction with device. If None, global context is used and potentially initialized.
run_elf(elf_file, core_loc, risc_id=0, device_id=0, context=None) -> None
Loads the given ELF file into the specified RISC core and executes it. Similar to load_elf, but RISC core is taken out of reset after load.
elf_file
(os.PathLike): Path to the ELF file to run.core_loc
(str | OnChipCoordinate | List[str | OnChipCoordinate]): One of the following:
- "all" to run the ELF on all cores;
- an X-Y (noc0/translated) or X,Y (logical) location of a core in string format;
- a list of X-Y (noc0/translated), X,Y (logical) or OnChipCoordinate locations of cores, possibly mixed;
- an OnChipCoordinate object.
risc_id
(int, default 0): RiscV ID (0: brisc, 1-3 triscs).device_id
(int, default 0): ID number of device to run ELF on.context
(Context, optional): TTExaLens context object used for interaction with device. If None, global context is used and potentially initialized.
check_context(context=None) -> Context
Function to initialize context if not provided. By default, it starts a local TTExaLens session with no output folder and caching disabled and sets GLOBAL_CONETXT variable so that the context can be reused in calls to other functions.
arc_msg(device_id, msg_code, wait_for_done, arg0, arg1, timeout, context=None) -> List[int]
Sends an ARC message to the device.
device_id
(int): ID number of device to send message to.msg_code
(int): Message code to send.wait_for_done
(bool): If True, waits for the message to be processed.arg0
(int): First argument to the message.arg1
(int): Second argument to the message.timeout
(int): Timeout in milliseconds.context
(Context, optional): TTExaLens context object used for interaction with device. If None, global context is used and potentially initialized.
(List[int]): return code, reply0, reply1.
read_tensix_register(core_loc, register, device_id=0, context=None) -> int
Reads the value of a register from the tensix core.
core_loc
(str | OnChipCoordinate): Either X-Y (noc0/translated) or X,Y (logical) location of a core in string format, dram channel (e.g. ch3), or OnChipCoordinate object.register
(str | TensixRegisterDescription): Configuration or debug register to read from (name or instance of ConfigurationRegisterDescription or DebugRegisterDescription). ConfigurationRegisterDescription(id, mask, shift), DebugRegisterDescription(addr).device_id
(int, default 0): ID number of device to read from.context
(Context, optional): TTExaLens context object used for interaction with device. If None, global context is used and potentailly initialized.
(int): Value of the configuration or debug register specified.
write_tensix_register(core_loc, register, value, device_id=0, context=None) -> None
Writes value to a register on the tensix core.
core_loc
(str | OnChipCoordinate): Either X-Y (noc0/translated) or X,Y (logical) location of a core in string format, dram channel (e.g. ch3), or OnChipCoordinate object.register
(str | TensixRegisterDescription): Configuration or debug register to read from (name or instance of ConfigurationRegisterDescription or DebugRegisterDescription). ConfigurationRegisterDescription(id, mask, shift), DebugRegisterDescription(addr).value
(int): Value to write to the register.device_id
(int, default 0): ID number of device to read from.context
(Context, optional): TTExaLens context object used for interaction with device. If None, global context is used and potentailly initialized.
This exception is thrown when a coordinate translation fails.
This class represents a coordinate on the chip. It can be used to convert between the various coordinate systems we use.
__init__(self, x, y, input_type, device, core_type=any) -> None
Constructor for the Coordinate class.
x
(int): The x-coordinate value.y
(int): The y-coordinate value.input_type
(str): The input coordinate system type. One of the following:- noc0
: NOC routing coordinate for NOC 0. (X-Y). Also known as "physical" coordinate.- noc1
: NOC routing coordinate for NOC 1. (X-Y)- die
: Die coordinate, a location on the die grid. (X,Y)- logical
: Logical grid coordinate. Notation: qX,Y, where q represents first letter of the core type. If q is not present, it is considered as tensix core.- virtual
: Virtual NOC coordinate. Similar to noc0, but with the harvested rows removed, and the locations of functioning rows shifted down to fill in the gap. (X-Y)- translated
: Translated NOC coordinate. (X-Y)device
: The device object used for coordinate conversion.core_type
(str, optional): The core_type used for coordinate conversion. Some coordinate systems require core_type as third dimension. Defaults to "any".- If the device is not specified, coordinate conversion to other systems will not be possible.
to(self, output_type) -> None
Returns a tuple with the coordinates in the specified coordinate system.
output_type
(str): The desired output coordinate system. (tuple): The coordinates in the specified coordinate system.### to_str
to_str(self, output_type=noc0) -> None
Returns a tuple with the coordinates in the specified coordinate system.
to_user_str(self) -> None
Returns a string representation of the coordinate that is suitable for the user.
change_device(self, device) -> None
Returns coordinates for the specified device.
device
(Device): The device object representing the chip. (OnChipCoordinate): The new coordinate object for the specified device.### create
create(coord_str, device, coord_type=None) -> None
Creates a coordinate object from a string. The string can be in any of the supported coordinate systems. (OnChipCoordinate): The created coordinate object.