Skip to content

Commit 1863ed6

Browse files
committed
Add default construction to the UltraScale configuration
The idea is to avoid reconfiguring the FPGA in already configured devices
1 parent a4ddeda commit 1863ed6

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

include/cynq/hardware.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,5 +208,22 @@ class IHardware {
208208
*/
209209
static std::shared_ptr<IHardware> Create(const HardwareArchitecture hw,
210210
const std::string &config);
211+
212+
/**
213+
* @brief Create method
214+
* Factory method to create a hardware-specific subclasses for accelerators
215+
* and data movers. The configuration of the FPGA is not performed by using
216+
* this constructor, since this assumes that there is none bitstream to load.
217+
*
218+
* @param hw One of the values in the HardwareArchitecture enum class
219+
* present in the enums.hpp file that should correspond to the device being
220+
* used.
221+
*
222+
* @return std::shared_ptr<IHardware>
223+
* Returns an IAccelerator pointer with reference counting. It should be
224+
* thread-safe.
225+
*
226+
*/
227+
static std::shared_ptr<IHardware> Create(const HardwareArchitecture hw);
211228
};
212229
} // namespace cynq

include/cynq/ultrascale/hardware.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,12 @@ class UltraScale : public IHardware {
8686
*/
8787
UltraScale(const std::string &bitstream_file, const std::string &xclbin_file);
8888
/**
89-
* No default constructor required
89+
* @brief Construct a new UltraScale object
90+
*
91+
* Configure the hardware platform without loading a bitstream nor xclbin.
92+
* This is useful for already configured FPGAs.
9093
*/
91-
UltraScale() = delete;
94+
UltraScale();
9295
/**
9396
* @brief ~UltraScale destructor method
9497
* Destroy the UltraScale object.

src/cynq/hardware.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ std::shared_ptr<IHardware> IHardware::Create(const HardwareArchitecture hw,
3838
}
3939
}
4040

41+
std::shared_ptr<IHardware> IHardware::Create(const HardwareArchitecture hw) {
42+
switch (hw) {
43+
case HardwareArchitecture::UltraScale:
44+
return std::make_shared<UltraScale>();
45+
default:
46+
return nullptr;
47+
}
48+
}
49+
4150
std::shared_ptr<IExecutionGraph> IHardware::GetExecutionStream(
4251
const std::string& name, const IExecutionGraph::Type type,
4352
const std::shared_ptr<ExecutionGraphParameters> params) {

src/cynq/ultrascale/hardware.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,23 @@ UltraScale::UltraScale(const std::string &bitstream_file,
126126
GetClocksInformation();
127127
}
128128

129+
UltraScale::UltraScale()
130+
: parameters_{std::make_shared<UltraScaleParameters>()} {
131+
/* For the UltraScale, there is only a single device. It is possible to
132+
load either a bitstream or a xclbin. */
133+
Status st{};
134+
135+
/* Configure the buses accordingly to the default design */
136+
st = LoadXclBin(EXAMPLE_KRIA_DEFAULT_XCLBIN_LOCATION);
137+
if (st.code != Status::OK) {
138+
std::string msg = "Error while configuring the buses: ";
139+
msg += st.msg;
140+
throw std::runtime_error(msg);
141+
}
142+
143+
GetClocksInformation();
144+
}
145+
129146
Status UltraScale::LoadBitstream(const std::string &bitstream_file) {
130147
/* FIXME: This is a temporal implementation while we are coding our own
131148
implementation. Use with caution */

0 commit comments

Comments
 (0)