MLIR-AIE 1.4.5.dev
test_utils::ParameterScratchpad Class Reference

#include "/home/runner/work/mlir-aie/mlir-aie/runtime_lib/test_lib/parameter_scratchpad.h"

Public Member Functions

 ParameterScratchpad (uint32_t *buffer, size_t bufferSizeBytes, const std::string &paramsPath, const std::string &command="")
 Construct from a raw buffer and its size in bytes (Python bindings / testing).
void writeBytes (const std::string &name, const void *data, size_t len)
 Write raw bytes (up to 4) by name, interpreted as a little-endian uint32.
void writeBits (const std::string &name, uint32_t bits)
 Write a raw 32-bit value by name.
template<typename T>
void write (const std::string &name, T value)
 Write a typed parameter value.
void validate () const
 Check the written values of each offset and length parameter pair that one DMA transfer uses.
std::vector< std::string > names () const
 The parameters this scratchpad holds: its command's.
uint32_t read (const std::string &name) const
 Read back a parameter's current encoded value (for debugging).

Detailed Description

Definition at line 54 of file parameter_scratchpad.h.

Constructor & Destructor Documentation

◆ ParameterScratchpad()

test_utils::ParameterScratchpad::ParameterScratchpad ( uint32_t * buffer,
size_t bufferSizeBytes,
const std::string & paramsPath,
const std::string & command = "" )
inline

Construct from a raw buffer and its size in bytes (Python bindings / testing).

The size is required: clear() and every write index off scratchpadSizeBytes, which parseParams derives from the params file, not from the buffer.

Definition at line 79 of file parameter_scratchpad.h.

Member Function Documentation

◆ names()

std::vector< std::string > test_utils::ParameterScratchpad::names ( ) const
inline

The parameters this scratchpad holds: its command's.

Definition at line 195 of file parameter_scratchpad.h.

◆ read()

uint32_t test_utils::ParameterScratchpad::read ( const std::string & name) const
inline

Read back a parameter's current encoded value (for debugging).

Definition at line 200 of file parameter_scratchpad.h.

◆ validate()

void test_utils::ParameterScratchpad::validate ( ) const
inline

Check the written values of each offset and length parameter pair that one DMA transfer uses.

Throws std::invalid_argument if they take the transfer past the end of its buffer.

Definition at line 169 of file parameter_scratchpad.h.

◆ write()

template<typename T>
void test_utils::ParameterScratchpad::write ( const std::string & name,
T value )
inline

Write a typed parameter value.

For core-kind parameters, the raw bits are left-shifted by 2 as required by the firmware's UPDATE_REG Incr mode, and the core right-shifts (unsigned) by 2 after reading. The round trip therefore zeroes the top 2 bits of the value (the bottom 2 bits are preserved). Types that fit in 30 bits (e.g. uint16_t, int16_t, std::bfloat16_t, and uint32_t values < 2^30) round-trip losslessly. float is not supported as a core-kind parameter (the verifier in --aie-lower-scratchpad-parameters rejects it).

Definition at line 159 of file parameter_scratchpad.h.

References writeBits().

◆ writeBits()

void test_utils::ParameterScratchpad::writeBits ( const std::string & name,
uint32_t bits )
inline

Write a raw 32-bit value by name.

For core-kind parameters, the bits are left-shifted by 2 (firmware requirement); for repeat-kind ones, by 16 (into the task queue's repeat field). For addr-kind parameters, the value is written directly (no shift). A DMA offset or length parameter's value, read as an int32, must lie in the range the compiler gave it, which keeps its transfers within their buffers; a repeat parameter's, at most its task's repeat count.

Definition at line 111 of file parameter_scratchpad.h.

Referenced by write(), and writeBytes().

◆ writeBytes()

void test_utils::ParameterScratchpad::writeBytes ( const std::string & name,
const void * data,
size_t len )
inline

Write raw bytes (up to 4) by name, interpreted as a little-endian uint32.

For core-kind parameters, the bits are left-shifted by 2 (firmware requirement); for repeat-kind ones, by 16 (into the task queue's repeat field). For addr-kind parameters, the value is written raw (no shift).

Definition at line 98 of file parameter_scratchpad.h.

References writeBits().


The documentation for this class was generated from the following file: