|
3 | 3 |
|
4 | 4 | #include <assert.h> |
5 | 5 |
|
6 | | -void canny(hls::FIFO<hls::ap_uint<1>> &switch_fifo_0, |
7 | | - hls::FIFO<hls::ap_uint<1>> &switch_fifo_1, |
8 | | - hls::FIFO<hls::ap_uint<1>> &switch_fifo_2, |
9 | | - hls::FIFO<hls::ap_uint<1>> &switch_fifo_3, |
| 6 | +void canny(bool switch_0, |
| 7 | + bool switch_1, |
| 8 | + bool switch_2, |
| 9 | + bool switch_3, |
10 | 10 | hls::FIFO<unsigned char> &input_fifo, |
11 | 11 | hls::FIFO<unsigned char> &output_fifo) { |
12 | 12 | #pragma HLS function top |
| 13 | +#pragma HLS function dataflow |
13 | 14 |
|
14 | 15 | hls::FIFO<unsigned char> output_fifo_gf(/* depth = */ 2); |
15 | 16 | hls::FIFO<unsigned short> output_fifo_sf(/* depth = */ 2); |
16 | 17 | hls::FIFO<unsigned char> output_fifo_nm(/* depth = */ 2); |
17 | 18 |
|
18 | | - gaussian_filter(switch_fifo_0, input_fifo, output_fifo_gf); |
19 | | - sobel_filter(switch_fifo_1, output_fifo_gf, output_fifo_sf); |
20 | | - nonmaximum_suppression(switch_fifo_2, output_fifo_sf, output_fifo_nm); |
21 | | - hysteresis_filter(switch_fifo_3, output_fifo_nm, output_fifo); |
| 19 | + gaussian_filter(switch_0, input_fifo, output_fifo_gf); |
| 20 | + sobel_filter(switch_1, output_fifo_gf, output_fifo_sf); |
| 21 | + nonmaximum_suppression(switch_2, output_fifo_sf, output_fifo_nm); |
| 22 | + hysteresis_filter(switch_3, output_fifo_nm, output_fifo); |
22 | 23 | } |
23 | 24 |
|
24 | 25 | int main() { |
25 | 26 | unsigned int i, j; |
26 | 27 |
|
27 | | - hls::FIFO<hls::ap_uint<1>> switch_fifo_0(/* depth = */ WIDTH * HEIGHT * 2); |
28 | | - hls::FIFO<hls::ap_uint<1>> switch_fifo_1(/* depth = */ WIDTH * HEIGHT * 2); |
29 | | - hls::FIFO<hls::ap_uint<1>> switch_fifo_2(/* depth = */ WIDTH * HEIGHT * 2); |
30 | | - hls::FIFO<hls::ap_uint<1>> switch_fifo_3(/* depth = */ WIDTH * HEIGHT * 2); |
| 28 | + bool switch_0; |
| 29 | + bool switch_1; |
| 30 | + bool switch_2; |
| 31 | + bool switch_3; |
31 | 32 | hls::FIFO<unsigned char> input_fifo(/* depth = */ WIDTH * HEIGHT * 2); |
32 | 33 | hls::FIFO<unsigned char> output_fifo(/* depth = */ WIDTH * HEIGHT * 2); |
33 | 34 |
|
@@ -74,33 +75,32 @@ int main() { |
74 | 75 | nm_sw(sobel_output, nonmaximum_suppression_output); |
75 | 76 | hf_sw(nonmaximum_suppression_output, hysteresis_output_golden); |
76 | 77 |
|
77 | | - const hls::ap_uint<1> on = 1; |
78 | 78 | // Write test input pixels. |
79 | 79 | for (i = 0; i < HEIGHT; i++) { |
80 | 80 | for (j = 0; j < WIDTH; j++) { |
81 | | - switch_fifo_0.write(on); |
82 | | - switch_fifo_1.write(on); |
83 | | - switch_fifo_2.write(on); |
84 | | - switch_fifo_3.write(on); |
| 81 | + switch_0 = true; |
| 82 | + switch_1 = true; |
| 83 | + switch_2 = true; |
| 84 | + switch_3 = true; |
85 | 85 | unsigned char r = input_channel->r; |
86 | 86 | unsigned char g = input_channel->g; |
87 | 87 | unsigned char b = input_channel->b; |
88 | 88 | unsigned grayscale = (r + g + b) / 3; |
89 | 89 | input_fifo.write(grayscale); |
90 | | - canny(switch_fifo_0, switch_fifo_1, switch_fifo_2, switch_fifo_3, |
| 90 | + canny(switch_0, switch_1, switch_2, switch_3, |
91 | 91 | input_fifo, output_fifo); |
92 | 92 | input_channel++; |
93 | 93 | } |
94 | 94 | } |
95 | 95 |
|
96 | 96 | // Give more inputs to flush out all pixels. |
97 | 97 | for (i = 0; i < GF_KERNEL_SIZE * WIDTH + GF_KERNEL_SIZE; i++) { |
98 | | - switch_fifo_0.write(on); |
99 | | - switch_fifo_1.write(on); |
100 | | - switch_fifo_2.write(on); |
101 | | - switch_fifo_3.write(on); |
| 98 | + switch_0 = true; |
| 99 | + switch_1 = true; |
| 100 | + switch_2 = true; |
| 101 | + switch_3 = true; |
102 | 102 | input_fifo.write(0); |
103 | | - canny(switch_fifo_0, switch_fifo_1, switch_fifo_2, switch_fifo_3, |
| 103 | + canny(switch_0, switch_1, switch_2, switch_3, |
104 | 104 | input_fifo, output_fifo); |
105 | 105 | } |
106 | 106 |
|
|
0 commit comments