CYNQ  0.3.0
Framework to develop FPGA applications in C++ with the easiness of PYNQ
hardware.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 
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 #include "cynq/accelerator.hpp"
16 #include "cynq/datamover.hpp"
17 #include "cynq/enums.hpp"
18 #include "cynq/execution-graph.hpp"
19 #include "cynq/status.hpp"
20 
21 namespace cynq {
28  std::string bitstream_file;
30  std::string xclbin_file;
32  virtual ~HardwareParameters() = default;
33 };
34 
39 class IHardware {
40  public:
46  virtual ~IHardware() = default;
52  enum Type {
54  None = 0,
56  XRT
57  };
64  virtual Status Reset() = 0;
81  virtual std::shared_ptr<IDataMover> GetDataMover(const uint64_t address) = 0;
97  virtual std::shared_ptr<IAccelerator> GetAccelerator(
98  const uint64_t address) = 0;
99 
114  virtual std::shared_ptr<IAccelerator> GetAccelerator(
115  const std::string &kernelname) = 0;
116 
137  virtual std::shared_ptr<IExecutionGraph> GetExecutionStream(
138  const std::string &name,
139  const IExecutionGraph::Type type = IExecutionGraph::Type::STREAM,
140  const std::shared_ptr<ExecutionGraphParameters> params = nullptr);
141 
151  virtual std::vector<float> GetClocks() noexcept;
165  virtual Status SetClocks(const std::vector<float> &clocks);
187  static std::shared_ptr<IHardware> Create(const HardwareArchitecture hw,
188  const std::string &bitstream,
189  const std::string &xclbin);
190 
209  static std::shared_ptr<IHardware> Create(const HardwareArchitecture hw,
210  const std::string &config);
211 };
212 } // namespace cynq
Type
Enum with the multiple implementations of the IExecutionGraph.
Definition: execution-graph.hpp:72
Interface for standardising the API of Hardware Devices:
Definition: hardware.hpp:39
virtual std::vector< float > GetClocks() noexcept
Get clocks from the PL.
Definition: hardware.cpp:56
virtual Status SetClocks(const std::vector< float > &clocks)
Set clocks to the PL.
Definition: hardware.cpp:60
virtual Status Reset()=0
Reset method Sets the IHardware instance to its initial state.
virtual std::shared_ptr< IAccelerator > GetAccelerator(const std::string &kernelname)=0
GetAccelerator method IAccelerator instance of IAccelerator inheritors separating the hardware logic ...
virtual std::shared_ptr< IAccelerator > GetAccelerator(const uint64_t address)=0
GetAccelerator method IAccelerator instance of IAccelerator inheritors separating the hardware logic ...
Type
Type Type of runtime supported by the IHardware.
Definition: hardware.hpp:52
@ None
Definition: hardware.hpp:54
@ XRT
Definition: hardware.hpp:56
virtual ~IHardware()=default
~IHardware destructor method Destroy the IHardware object.
static std::shared_ptr< IHardware > Create(const HardwareArchitecture hw, const std::string &bitstream, const std::string &xclbin)
Create method Factory method to create a hardware-specific subclasses for accelerators and data mover...
Definition: hardware.cpp:15
virtual std::shared_ptr< IExecutionGraph > GetExecutionStream(const std::string &name, const IExecutionGraph::Type type=IExecutionGraph::Type::STREAM, const std::shared_ptr< ExecutionGraphParameters > params=nullptr)
GetExecutionStream.
Definition: hardware.cpp:41
virtual std::shared_ptr< IDataMover > GetDataMover(const uint64_t address)=0
GetDataMover method Used for accessing the IDataMover instance of IHardware inheritors for decoupling...
Define an abstract representation of the hardware parameters with some prefilled fields.
Definition: hardware.hpp:26
std::string xclbin_file
Definition: hardware.hpp:30
virtual ~HardwareParameters()=default
std::string bitstream_file
Definition: hardware.hpp:28
Structure to define the return characteristics of each function.
Definition: status.hpp:19