vrt::Kernel
-
class Kernel
Class representing a kernel.
Subclassed by vrt::QdmaLogic
Public Functions
-
Kernel(const std::string &name, uint64_t baseAddr, uint64_t range, const std::vector<Register> ®isters, const std::vector<FunctionalArg> &functionalArgs = {})
Constructor for Kernel.
- Parameters:
name – The name of the kernel.
baseAddr – The base address of the kernel.
range – The address range of the kernel.
registers – The list of registers in the kernel.
functionalArgs – Parsed function-argument metadata from system_map.xml.
-
Kernel(vrt::Device device, const std::string &kernelName)
Constructor for Kernel using a Device object.
- Parameters:
device – The Device object.
kernelName – The name of the kernel.
-
void setVrtdBar(const std::optional<vrtd::Bar> &bar)
Sets the vrtd BAR handle for hardware access.
- Parameters:
bar – The vrtd BAR handle.
Sets the ZeroMQ server for emulation and simulation.
- Parameters:
server – The ZeroMQ server handle.
-
void write(uint32_t offset, uint32_t value)
Writes a value to a register.
- Parameters:
offset – The offset of the register.
value – The value to write.
-
uint32_t read(uint32_t offset)
Reads a value from a register.
- Parameters:
offset – The offset of the register.
- Returns:
The value read from the register.
-
void wait()
Waits for the kernel to complete.
-
void startKernel(bool autorestart = false)
Starts the kernel.
- Parameters:
autorestart – Flag indicating whether to enable autorestart.
-
void setPlatform(Platform platform)
Sets the platform for the kernel.
- Parameters:
platform – The platform to set.
-
void setFunctionalArgs(const std::vector<FunctionalArg> &args)
Sets parsed function argument metadata.
-
bool hasFunctionalArgs() const
Returns true when function argument metadata is available.
-
const std::vector<FunctionalArg> &getFunctionalArgs() const
Get information about the functional arguments.
-
void setEmuCallArgKinds(const std::vector<std::string> &kinds)
Sets EMU call argument kinds loaded from emu_manifest.json. Index corresponds to argN in EMU call JSON.
-
void setEmuFetchScalarArgByOffset(const std::map<uint32_t, std::string> &routes)
Sets EMU scalar fetch routing keyed by register offset. Used by Kernel::read() in EMULATION mode.
-
void setConnections(const std::map<std::string, std::string> &conns)
Sets port-to-target memory connection mappings from system_map.xml.
-
MemoryConfig portMemoryConfig(std::string_view portName) const
Returns the memory configuration for a named AXI port.
Looks up the port in the kernel’s connection map (populated from system_map.xml) and returns a MemoryConfig that can be passed directly to the Buffer constructor.
- Parameters:
portName – The AXI port name (e.g. “m_axi_gmem0”).
- Throws:
std::runtime_error – if the port has no connection entry.
-
MemoryConfig argMemoryConfig(std::string_view argName) const
Returns the memory configuration for a named kernel argument.
Resolves the argument to its AXI port via functional_args metadata and then delegates to portMemoryConfig(). The returned MemoryConfig can be passed directly to the Buffer constructor.
- Parameters:
argName – The argument name from functional_args metadata.
- Throws:
std::runtime_error – if the argument is not found or has no AXI port.
-
template<typename T>
inline void setArg(int idx, T &&value) Set argument value by argument index from functional_args metadata.
-
template<typename T>
inline void setArg(std::string_view argName, T &&value) Set argument value by argument name from functional_args metadata.
-
void writeBatch()
Writes batch register to PCIe BAR.
-
template<typename ...Args>
inline void call(Args&&... args) Calls the kernel and waits for it to complete.
- Parameters:
args – The arguments to pass to the kernel.
-
void start()
Starts the kernel.
-
template<typename ...Args>
inline void start(Args&&... args) Starts the kernel with arguments.
- Parameters:
args – The arguments to pass to the kernel.
-
template<typename T>
inline void processArg(T &&arg) Helper method which processes an argument.
- Template Parameters:
T – The type of the argument.
- Parameters:
arg – The argument to process.
-
template<typename T>
inline void processSimArg(T &&arg) Helper method which processes an argument for simulation.
- Template Parameters:
T – The type of the argument.
- Parameters:
arg – The argument to process.
-
template<typename T>
inline void processEmuArg(T &&arg, Json::Value &command) Helper method which processes an argument for emulation.
- Template Parameters:
T – The type of the argument.
- Parameters:
arg – The argument to process.
command – The JSON command to update.
-
std::string getName() const
Getter for the kernel name.
- Returns:
The name of the kernel.
-
uint64_t getPhysAddr() const
Getter for the kernel base physical address.
- Returns:
The physical base address of the kernel.
-
Kernel(const std::string &name, uint64_t baseAddr, uint64_t range, const std::vector<Register> ®isters, const std::vector<FunctionalArg> &functionalArgs = {})