@@ -45,6 +45,7 @@ outbuf = allocate(shape=(output_elements,), dtype=np.uint16)
45
45
# Run
46
46
dma.sendchannel.transfer(inbuf)
47
47
accel.write(accel.register_map.CTRL .address, 0x 81 )
48
+ accel.write(accel.register_map.n_elements.address, input_elements)
48
49
dma.recvchannel.transfer(outbuf)
49
50
dma.recvchannel.wait()
50
51
@@ -53,7 +54,7 @@ del input_hw
53
54
del output_hw
54
55
```
55
56
56
- With CYNQ:
57
+ With CYNQ for Xilinx Ultrascale+ :
57
58
58
59
``` c++
59
60
#include < cynq/cynq.hpp>
@@ -62,7 +63,7 @@ using namespace cynq;
62
63
63
64
// Configure the FPGA
64
65
auto kArch = HardwareArchitecture::UltraScale;
65
- auto platform = IHardware::Create(kArch , " design.bit" , " default.xclbin " );
66
+ auto platform = IHardware::Create(kArch , " design.bit" );
66
67
67
68
// Extract the accelerator (IP Core) and DMA
68
69
// Addresses are given by the design
@@ -72,17 +73,57 @@ auto accel = platform->GetAccelerator(accel_addr);
72
73
auto dma = platform->GetDataMover(dma_addr);
73
74
74
75
// Allocate buffers and get the pointers
75
- auto inbuf = mover->GetBuffer(input_size);
76
- auto outbuf = mover->GetBuffer(output_size);
76
+ auto inbuf = mover->GetBuffer(input_size, accel->GetMemoryBank(0) );
77
+ auto outbuf = mover->GetBuffer(output_size, accel->GetMemoryBank(1) );
77
78
uint16_t* input_ptr = inbuf->HostAddress<uint16_t>().get();
78
79
uint16_t* output_ptr = outbuf->HostAddress<uint16_t>().get();
79
80
81
+ // Configure data - Bus: AXI4 Stream is handled by DMA
82
+ const uint32_t num_elements = 4096;
83
+ const uint64_t addr_num_elements = 0x20;
84
+ accel->Write(addr_num_elements, num_elements);
85
+
80
86
// Run
87
+ mover->Upload(in_mem, infbuf->Size(), 0, ExecutionType::Async);
81
88
accel->Start(StartMode::Continuous);
82
- inbuf->Sync(SyncType::HostToDevice);
83
- mover->Upload(in_mem, infbuf->Size(), 0, ExecutionType::Sync);
84
89
mover->Download(out_mem, outbuf->Size(), 0, ExecutionType::Sync);
85
- outbuf->Sync(SyncType::DeviceToHost);
90
+ accel->Stop();
91
+
92
+ // Dispose? We use RAII
93
+ ```
94
+
95
+ With CYNQ for Alveo
96
+
97
+ ```c++
98
+ #include <cynq/cynq.hpp>
99
+
100
+ using namespace cynq;
101
+
102
+ // Configure the FPGA
103
+ auto kArch = HardwareArchitecture::Alveo;
104
+ auto platform = IHardware::Create(kArch, "design.xclbin");
105
+
106
+ // Extract the accelerator (IP Core) and DMA
107
+ // Addresses are given by the design
108
+ auto accel = platform->GetAccelerator("vadd");
109
+ auto dma = platform->GetDataMover(0);
110
+
111
+ // Allocate buffers and get the pointers
112
+ auto inbuf = mover->GetBuffer(input_size, accel->GetMemoryBank(0));
113
+ auto outbuf = mover->GetBuffer(output_size, accel->GetMemoryBank(1));
114
+ uint16_t* input_ptr = inbuf->HostAddress<uint16_t>().get();
115
+ uint16_t* output_ptr = outbuf->HostAddress<uint16_t>().get();
116
+
117
+ // Configure the accel - memory mapped
118
+ const uint32_t num_elements = 4096;
119
+ accel->Attach(0, bo_0);
120
+ accel->Attach(1, bo_1);
121
+ accel->Attach(2, &num_elements);
122
+
123
+ // Run
124
+ mover->Upload(in_mem, infbuf->Size(), 0, ExecutionType::Async);
125
+ accel->Start(StartMode::Once);
126
+ mover->Download(out_mem, outbuf->Size(), 0, ExecutionType::Sync);
86
127
87
128
// Dispose? We use RAII
88
129
```
@@ -92,6 +133,7 @@ outbuf->Sync(SyncType::DeviceToHost);
92
133
So far, we have tested CYNQ on:
93
134
94
135
1 . Xilinx KV26-based with Ubuntu 2022.04
136
+ 2 . Xilinx Alveo U250 (it should be compatible with other similar Alveo cards) - Shell: xilinx_u250_gen3x16_xdma_4_1_202210_1
95
137
96
138
## Links & References:
97
139
@@ -106,8 +148,8 @@ Cite Us:
106
148
AND Ávila-Torres, Diego
107
149
AND Castro-Godínez, Jorge
108
150
}},
109
- title = {{CYNQ (v0.1 )}},
110
- year = {2023 },
151
+ title = {{CYNQ (v0.2 )}},
152
+ year = {2024 },
111
153
url = {https://github.com/ECASLab/cynq},
112
154
}
113
155
```
0 commit comments