CYNQ  0.3.0
Framework to develop FPGA applications in C++ with the easiness of PYNQ
cynq::XRTAccelerator Class Reference

XRTAccelerator class This class provides the api to operate the accelerator. More...

#include <accelerator.hpp>

Inheritance diagram for cynq::XRTAccelerator:
Collaboration diagram for cynq::XRTAccelerator:

Public Member Functions

 XRTAccelerator ()=delete
 Delete the default constructor since address is needed.
 
 XRTAccelerator (const std::string &kernelname, const std::shared_ptr< HardwareParameters > hwparams)
 Construct a new XRTAccelerator object. More...
 
virtual ~XRTAccelerator ()
 ~XRTAccelerator destructor method Destroy the XRTAccelerator object
 
Status Start (const StartMode mode) override
 Start method This method starts the accelerator in either once or continuous mode (with the autorestart). Under the hood, this writes the control register to turn on the accelerator with/without the autorestart bit. More...
 
Status Stop () override
 Stop method This asynchronously turns off the accelerator by removing the autorestart and start bits from the control registers. Please, note that the accelerator will turn off once it finishes its current task. More...
 
Status Sync () override
 Sync method Forces to wait until the accelerator execution is "done". More...
 
int GetMemoryBank (const uint pos) override
 Get the memory bank ID. More...
 
DeviceStatus GetStatus () override
 GetStatus method This returns the accelerator state by using the DeviceStatus. This reads the control register flags. More...
 
Status Attach (const uint64_t index, std::shared_ptr< IMemory > mem) override
 Attach a memory argument Performs an attachment of the argument and the respective pointer. The use of this overload for IMemory buffers is highly recommended. More...
 
- Public Member Functions inherited from cynq::IAccelerator
virtual ~IAccelerator ()=default
 ~IAccelerator destructor method Destroy the IAccelerator object.
 
virtual Status Start (std::shared_ptr< IExecutionGraph > graph, const StartMode mode)
 Start method (asynchronous) Please, refer to IAccelerator::Start for reference. This overload performs an asynchronous execution of the function based on a graph of operations. It returns as soon as the operation is scheduled. More...
 
virtual Status Stop (std::shared_ptr< IExecutionGraph > graph)
 Stop method (asynchronous) Please, refer to IAccelerator::Stop for reference. This overload performs an asynchronous execution of the function based on a graph of operations. It returns as soon as the operation is scheduled. More...
 
virtual Status Sync (std::shared_ptr< IExecutionGraph > graph)
 Sync method (asynchronous) Please, refer to IAccelerator::Sync for reference. This overload performs an asynchronous execution of the function based on a graph of operations. It returns as soon as the operation is scheduled. More...
 
template<typename T >
Status Write (const uint64_t address, const T *data, const size_t elements=1)
 Write method Performs a write operation to the accelerator through a register. More...
 
template<typename T >
Status Write (std::shared_ptr< IExecutionGraph > graph, const uint64_t address, const T *data, const size_t elements=1)
 Write method (asynchronous) Performs a write operation to the accelerator through a register in an execution graph. It returns as soon as the instruction is scheduled. More...
 
template<typename T >
Status Read (const uint64_t address, T *data, const size_t elements=1)
 Read method Performs a write operation to the accelerator through a register. More...
 
template<typename T >
Status Read (std::shared_ptr< IExecutionGraph > graph, const uint64_t address, T *data, const size_t elements=1)
 Read method (asynchronous) Performs a write operation to the accelerator through a register in an execution graph. It returns as soon as the instruction is scheduled. More...
 
template<typename T >
Status Attach (const uint64_t index, T *data, const RegisterAccess access=RegisterAccess::WO, const size_t elements=1)
 Attach an argument Performs an attachment of the argument and the respective pointer. If the index/address to attach receives a nullptr, it gets detached. More...
 
template<typename T >
Status Attach (const uint64_t index, T *data, const size_t elements, const RegisterAccess access=RegisterAccess::WO)
 Overload of the Attach<T>() More...
 

Protected Member Functions

Status WriteRegister (const uint64_t address, const uint8_t *data, const size_t size) override
 Write Register method (it behaves differently from MMIO) More...
 
Status ReadRegister (const uint64_t address, uint8_t *data, const size_t size) override
 Read Register method (it behaves differently from MMIO) More...
 
Status AttachRegister (const uint64_t index, uint8_t *data, const RegisterAccess access, const size_t size) override
 Implementation of the Attach Register method. More...
 
- Protected Member Functions inherited from cynq::IAccelerator
virtual Status WriteRegister (std::shared_ptr< IExecutionGraph > graph, const uint64_t address, const uint8_t *data, const size_t size)
 Write Register method (asynchronous) More...
 
virtual Status ReadRegister (std::shared_ptr< IExecutionGraph > graph, const uint64_t address, uint8_t *data, const size_t size)
 Read Register method (asynchronous) More...
 

Additional Inherited Members

- Public Types inherited from cynq::IAccelerator
enum  Type { None = 0 , MMIO , XRT }
 Type Type of runtime supported by the IAccelerator. More...
 
- Static Public Member Functions inherited from cynq::IAccelerator
static std::shared_ptr< IAcceleratorCreate (IAccelerator::Type impl, const uint64_t addr)
 Create method Factory method used for creating specific subclasses of IAccelerator. More...
 
static std::shared_ptr< IAcceleratorCreate (IAccelerator::Type impl, const std::string &kernelname, const std::shared_ptr< HardwareParameters > hwparams)
 Create method (overload) Factory method used for creating specific subclasses of IAccelerator. More...
 

Detailed Description

XRTAccelerator class This class provides the api to operate the accelerator.

Constructor & Destructor Documentation

◆ XRTAccelerator()

cynq::XRTAccelerator::XRTAccelerator ( const std::string &  kernelname,
const std::shared_ptr< HardwareParameters hwparams 
)

Construct a new XRTAccelerator object.

It constructs an accessor to the a kernel accelerator in the PL design according to its kernel name. The kernel is built with exclusive access

Parameters
kernelnamestring containing the kernel name
hwparamsparameters corresponding to the platform linked to the kernel

Member Function Documentation

◆ Attach()

Status cynq::XRTAccelerator::Attach ( const uint64_t  index,
std::shared_ptr< IMemory mem 
)
overridevirtual

Attach a memory argument Performs an attachment of the argument and the respective pointer. The use of this overload for IMemory buffers is highly recommended.

Parameters
indexArgument position of the argument to set
memMemory buffer to attach to the argument
Returns
Status

Implements cynq::IAccelerator.

◆ AttachRegister()

Status cynq::XRTAccelerator::AttachRegister ( const uint64_t  index,
uint8_t *  data,
const RegisterAccess  access,
const size_t  size 
)
overrideprotectedvirtual

Implementation of the Attach Register method.

Parameters
indexindex of the argument to set
dataa pointer to an unsigned 8 bits variable which holds the data to read from the register.
accessAccess type of the register (unused)
sizesize in bytes of the data to read.
Returns
Status

Implements cynq::IAccelerator.

◆ GetMemoryBank()

int cynq::XRTAccelerator::GetMemoryBank ( const uint  pos)
overridevirtual

Get the memory bank ID.

It corresponds to the argument memory argument for affinity. It is useful for assigning memory banks to the DataMovers before requesting any memory.

It is only used by Vitis and Alveo workflows

Parameters
posAXI Memory Mapped argument position within the kernel (argument number)
Returns
integer number corresponding to the memory bank ID

Implements cynq::IAccelerator.

◆ GetStatus()

DeviceStatus cynq::XRTAccelerator::GetStatus ( )
overridevirtual

GetStatus method This returns the accelerator state by using the DeviceStatus. This reads the control register flags.

Returns
DeviceStatus

Implements cynq::IAccelerator.

◆ ReadRegister()

Status cynq::XRTAccelerator::ReadRegister ( const uint64_t  address,
uint8_t *  data,
const size_t  size 
)
overrideprotectedvirtual

Read Register method (it behaves differently from MMIO)

Reads from the register of the accelerator

Parameters
addressan unsigned integer of 64 bits representing an address.
dataa pointer to an unsigned 8 bits variable which holds the data to read from the register.
sizesize in bytes of the data to read.
Returns
Status

Implements cynq::IAccelerator.

◆ Start()

Status cynq::XRTAccelerator::Start ( const StartMode  mode)
overridevirtual

Start method This method starts the accelerator in either once or continuous mode (with the autorestart). Under the hood, this writes the control register to turn on the accelerator with/without the autorestart bit.

Parameters
modeOne of the values in the StartMode enum class present in the enums.hpp file.
Returns
Status

Implements cynq::IAccelerator.

◆ Stop()

Status cynq::XRTAccelerator::Stop ( )
overridevirtual

Stop method This asynchronously turns off the accelerator by removing the autorestart and start bits from the control registers. Please, note that the accelerator will turn off once it finishes its current task.

Returns
Status

Implements cynq::IAccelerator.

◆ Sync()

Status cynq::XRTAccelerator::Sync ( )
overridevirtual

Sync method Forces to wait until the accelerator execution is "done".

Returns
Status

Implements cynq::IAccelerator.

◆ WriteRegister()

Status cynq::XRTAccelerator::WriteRegister ( const uint64_t  address,
const uint8_t *  data,
const size_t  size 
)
overrideprotectedvirtual

Write Register method (it behaves differently from MMIO)

Writes to the register of the accelerator.

Parameters
addressan unsigned integer of 64 bits representing an address.
dataa pointer to an unsigned 8 bits variable which holds the data to write to the register.
sizesize in bytes of the data to write.
Returns
Status

Implements cynq::IAccelerator.


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