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 #pragma GCC diagnostic push
12 #pragma GCC diagnostic ignored "-Wpedantic"
13 #include <xrt.h>
14 #include <xrt/xrt_device.h>
15 #pragma GCC diagnostic pop
16 
17 #include <cstdint>
18 #include <cynq/dma/datamover.hpp>
19 #include <cynq/enums.hpp>
20 #include <cynq/hardware.hpp>
21 #include <cynq/mmio/accelerator.hpp>
22 #include <cynq/status.hpp>
23 #include <memory>
24 #include <string>
25 #include <vector>
26 
27 namespace cynq {
33  inline static constexpr int max_clocks = 4;
35  std::array<bool, max_clocks> pl_active = {false};
37  std::array<bool, max_clocks> pl_valid = {false};
39  std::array<float, max_clocks> src_freq = {0.f};
41  std::array<uint32_t, max_clocks> pl_reg;
43  std::array<uint32_t, max_clocks> src_reg;
45  std::array<float, 4> target_clocks_mhz = {-1.f};
47  std::array<float, 4> current_clocks_mhz = {-1.f};
48 };
49 
56  xrt::device device_;
58  xrt::xclbin xclbin_;
62  virtual ~UltraScaleParameters() = default;
63 };
64 
73 class UltraScale : public IHardware {
74  public:
87  UltraScale(const std::string &bitstream_file, const std::string &xclbin_file);
91  UltraScale() = delete;
96  virtual ~UltraScale();
103  Status Reset() override;
115  std::shared_ptr<IDataMover> GetDataMover(const uint64_t address) override;
126  std::shared_ptr<IAccelerator> GetAccelerator(
127  const std::string &kernelname) override;
128 
141  std::shared_ptr<IAccelerator> GetAccelerator(const uint64_t address) override;
158 
168  std::vector<float> GetClocks() noexcept override;
178  Status SetClocks(const std::vector<float> &clocks) override;
179 
180  private:
182  std::shared_ptr<HardwareParameters> parameters_;
192  Status LoadBitstream(const std::string &bitstream_file);
201  Status ConfigureBuses();
210  Status GetClocksInformation(const uint number_pl_clocks = 1);
218  Status ConfigureClocks();
229  Status LoadXclBin(const std::string &xclbin_file, const int device_idx = 0);
230 };
231 } // namespace cynq
Interface for standardising the API of Hardware Devices:
Definition: hardware.hpp:39
UltraScale class Provides an interface to access IP Cores in Xilinx FPGAs, the compatible devices are...
Definition: hardware.hpp:73
std::shared_ptr< IAccelerator > GetAccelerator(const std::string &kernelname) override
GetAccelerator method (overload - not implemented) Do not use this method since it is not implemented...
Definition: hardware.cpp:409
Status KernelQuery()
Queries the kernels available in the design.
std::vector< float > GetClocks() noexcept override
Get clocks from the PL.
Definition: hardware.cpp:352
UltraScale()=delete
std::shared_ptr< IDataMover > GetDataMover(const uint64_t address) override
GetDataMover method Used for accessing the IDataMover instance of the UltraScale object.
Definition: hardware.cpp:400
Status DeviceQuery()
Queries the device looking for its characteristics.
virtual ~UltraScale()
~UltraScale destructor method Destroy the UltraScale object.
Definition: hardware.cpp:414
Status SetClocks(const std::vector< float > &clocks) override
Set clocks to the PL.
Definition: hardware.cpp:363
Status Reset() override
Reset method Sets the UltraScale instance to its initial state.
Definition: hardware.cpp:398
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
Contains the information about the registers used for the clocks.
Definition: hardware.hpp:32
std::array< float, max_clocks > src_freq
Definition: hardware.hpp:39
std::array< bool, max_clocks > pl_valid
Definition: hardware.hpp:37
std::array< uint32_t, max_clocks > src_reg
Definition: hardware.hpp:43
std::array< bool, max_clocks > pl_active
Definition: hardware.hpp:35
std::array< float, 4 > current_clocks_mhz
Definition: hardware.hpp:47
std::array< float, 4 > target_clocks_mhz
Definition: hardware.hpp:45
std::array< uint32_t, max_clocks > pl_reg
Definition: hardware.hpp:41
Specialisation of the parameters given by the UltraScale. It is based on the PYNQ and XRT.
Definition: hardware.hpp:54
xrt::device device_
Definition: hardware.hpp:56
virtual ~UltraScaleParameters()=default
UltraScaleClocks clocks_
Definition: hardware.hpp:60
xrt::xclbin xclbin_
Definition: hardware.hpp:58