-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol_data_driven_df.cpp
56 lines (52 loc) · 1.44 KB
/
control_data_driven_df.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "control_data_driven_df.hpp"
static void load_stream(
int ab[2][512],
hls::stream<int> &out) {
for (auto i = 0; i < 2; ++i) {
for (auto j = 0; j < 512; ++j) {
out.write(ab[i][j]);
}
}
};
static void store_stream(
hls::stream<int> &in,
int out[512],
unsigned int count
) {
for (auto i = 0; i < 1024; ++i) {
int temp = in.read();
out[i] = temp; //This temp should be buffered for burst writes automatically! as most of the time the bottle neck is memory access...
if (temp == -1) {
break;
}
}
};
static void count_divisible_by_two(
hls::stream<int> &in_stream,
hls::stream<int> &out_stream,
unsigned int &count
) {
for (auto i = 0; i < 1024; ++i) {
int temp = in_stream.read();
if (temp % 2 == 0) {
out_stream.write(temp);
++count;
}
}
out_stream.write(-1); //eos marker
};
extern "C"
void control_data_driven_df(
int ab[2][512],
int out[512]
) {
#pragma HLS INTERFACE mode=m_axi bundle=gmem0 max_read_burst_length=64 port=ab
#pragma HLS INTERFACE mode=m_axi bundle=gmem0 max_write_burst_length=64 port=out
#pragma HLS DATAFLOW
hls::stream<int> stream_local_0;
hls::stream<int> stream_local_1;
unsigned int count = 0;
load_stream(ab, stream_local_0);
count_divisible_by_two(stream_local_0, stream_local_1, count);
store_stream(stream_local_1, out, count);
};