CYNQ  0.3.0
Framework to develop FPGA applications in C++ with the easiness of PYNQ
datamover.hpp
1 /*
2  * See LICENSE for more information about licensing
3  *
4  * Copyright 2023
5  * Author: Luis G. Leon-Vega <luis.leon@ieee.org>
6  * Diego Arturo Avila Torres <diego.avila@uned.cr>
7  *
8  */
9 #pragma once
10 #include <cynq/execution-graph.hpp>
11 #include <memory>
12 
13 #include "cynq/enums.hpp"
14 #include "cynq/memory.hpp"
15 #include "cynq/status.hpp"
16 
17 namespace cynq {
18 
19 struct HardwareParameters;
20 
27  std::shared_ptr<HardwareParameters> hw_params_;
29  virtual ~DataMoverParameters() = default;
30 };
31 
32 struct HardwareParameters;
33 
40 class IDataMover {
41  public:
47  virtual ~IDataMover() = default;
53  enum Type {
55  None = 0,
57  DMA,
59  XRT
60  };
80  virtual std::shared_ptr<IMemory> GetBuffer(
81  const size_t size, const int memory_bank = 0,
82  const MemoryType type = MemoryType::Dual) = 0;
101  virtual Status Upload(const std::shared_ptr<IMemory> mem, const size_t size,
102  const size_t offset, const ExecutionType exetype) = 0;
103 
127  virtual Status Upload(std::shared_ptr<IExecutionGraph> graph,
128  const std::shared_ptr<IMemory> mem, const size_t size,
129  const size_t offset, const ExecutionType exetype);
130 
146  virtual Status Download(const std::shared_ptr<IMemory> mem, const size_t size,
147  const size_t offset, const ExecutionType exetype) = 0;
148 
172  virtual Status Download(std::shared_ptr<IExecutionGraph> graph,
173  const std::shared_ptr<IMemory> mem, const size_t size,
174  const size_t offset, const ExecutionType exetype);
175 
183  virtual Status Sync(const SyncType type) = 0;
184 
198  virtual Status Sync(std::shared_ptr<IExecutionGraph> graph,
199  const SyncType type);
200 
208  virtual DeviceStatus GetStatus() = 0;
209 
234  static std::shared_ptr<IDataMover> Create(
235  IDataMover::Type impl, const uint64_t addr,
236  std::shared_ptr<HardwareParameters> hwparams);
237 };
238 } // namespace cynq
Interface for standardising the API of DataMover for a specific device: XRTDataMover.
Definition: datamover.hpp:40
Type
Type Type of runtime supported by the IDataMover.
Definition: datamover.hpp:53
@ XRT
Definition: datamover.hpp:59
@ DMA
Definition: datamover.hpp:57
@ None
Definition: datamover.hpp:55
virtual Status Upload(const std::shared_ptr< IMemory > mem, const size_t size, const size_t offset, const ExecutionType exetype)=0
Upload method This method moves the data from the host to the device using a DMA engine....
virtual std::shared_ptr< IMemory > GetBuffer(const size_t size, const int memory_bank=0, const MemoryType type=MemoryType::Dual)=0
GetBuffer method This method allocates a memory buffer. Depending on the MemoryType,...
static std::shared_ptr< IDataMover > Create(IDataMover::Type impl, const uint64_t addr, std::shared_ptr< HardwareParameters > hwparams)
Create method Factory method used for creating specific subclasses of IDataMover.
Definition: datamover.cpp:15
virtual Status Sync(const SyncType type)=0
Sync method Synchronizes data movements in case of asynchronous Upload/Download.
virtual DeviceStatus GetStatus()=0
GetStatus method Returns the status of the data mover in terms of transactions.
virtual ~IDataMover()=default
~IDataMover destructor method Destroy the IDataMover object.
virtual Status Download(const std::shared_ptr< IMemory > mem, const size_t size, const size_t offset, const ExecutionType exetype)=0
Download method.
Define an abstract representation of the data mover parameters with some prefilled fields.
Definition: datamover.hpp:25
std::shared_ptr< HardwareParameters > hw_params_
Definition: datamover.hpp:27
virtual ~DataMoverParameters()=default
Define an abstract representation of the hardware parameters with some prefilled fields.
Definition: hardware.hpp:26
Structure to define the return characteristics of each function.
Definition: status.hpp:19