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

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

#include <accelerator.hpp>

Inheritance diagram for cynq::MMIOAccelerator:
Collaboration diagram for cynq::MMIOAccelerator:

Public Member Functions

 MMIOAccelerator ()=delete
 Delete the default constructor since address is needed.
 
 MMIOAccelerator (const uint64_t addr)
 Construct a new MMIOAccelerator object. More...
 
virtual ~MMIOAccelerator ()
 ~MMIOAccelerator destructor method Destroy the MMIOAccelerator object
 
Status Start (const StartMode mode) override
 Start method. More...
 
Status Stop () override
 Stop method. More...
 
Status Sync () override
 Sync method. More...
 
int GetMemoryBank (const uint pos) override
 Get the memory bank ID (not implemented) 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. 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 Writes to the register of the accelerator. More...
 
Status ReadRegister (const uint64_t address, uint8_t *data, const size_t size) override
 Read Register method. 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

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

Constructor & Destructor Documentation

◆ MMIOAccelerator()

cynq::MMIOAccelerator::MMIOAccelerator ( const uint64_t  addr)
explicit

Construct a new MMIOAccelerator object.

It constructs an accessor to the accelerator in the PL design according to the AXI-lite memory mapping. This is widely compatible with AXI4-lite controlled HLS designs.

Parameters
addr64-bit address in the physical memory space

Member Function Documentation

◆ Attach()

Status cynq::MMIOAccelerator::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::MMIOAccelerator::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
sizesize in bytes of the data to read.
Returns
Status

Implements cynq::IAccelerator.

◆ GetMemoryBank()

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

Get the memory bank ID (not implemented)

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
posmemory bank position within the kernel
Returns
0

Implements cynq::IAccelerator.

◆ GetStatus()

DeviceStatus cynq::MMIOAccelerator::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::MMIOAccelerator::ReadRegister ( const uint64_t  address,
uint8_t *  data,
const size_t  size 
)
overrideprotectedvirtual

Read Register method.

Parameters
addressa unsiged integer of 64 bits representing an address.
dataa pointer to a 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::MMIOAccelerator::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.

It also synchronises the registers, writing them if attached.

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

Implements cynq::IAccelerator.

◆ Stop()

Status cynq::MMIOAccelerator::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.

It also synchronises the registers, reading them if attached.

Returns
Status

Implements cynq::IAccelerator.

◆ Sync()

Status cynq::MMIOAccelerator::Sync ( )
overridevirtual

Sync method.

Forces to wait until the accelerator execution is different from "DeviceStatus::Running"

It also synchronises the registers, reading them if attached.

Returns
Status

Implements cynq::IAccelerator.

◆ WriteRegister()

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

Write Register method Writes to the register of the accelerator.

Parameters
addressa unsigned integer of 64 bits representing an address.
dataa pointer to a 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: