Skip to content

Commit b3dffbd

Browse files
committed
First approach to HLS, Simplified Filter/TB
1 parent 0bbd49b commit b3dffbd

File tree

5 files changed

+477
-1
lines changed

5 files changed

+477
-1
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,10 @@ tools/datagen/src/imgs/*_sobel_*
233233
*.vcd
234234
test
235235
*.zst
236-
.vscode
236+
.vscode
237+
238+
#Ignore VIVADO project
239+
HLS/IpsFilterHLS/.apc
240+
HLS/IpsFilterHLS/.settings
241+
HLS/IpsFilterHLS/solution1
242+
HLS/IpsFilterHLS/*
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#ifndef IPS_FILTER_CPP
2+
#define IPS_FILTER_CPP
3+
4+
#include "ips_filter.hpp"
5+
6+
void Filter::filter()
7+
{
8+
while (true) {
9+
wait();
10+
sc_uint<8> result = 0;
11+
result = result + input_window_0.read();
12+
result = result + input_window_1.read();
13+
result = result + input_window_2.read();
14+
result = result + input_window_3.read();
15+
result = result + input_window_4.read();
16+
result = result + input_window_5.read();
17+
result = result + input_window_6.read();
18+
result = result + input_window_7.read();
19+
result = result + input_window_8.read();
20+
21+
#ifndef __SYNTHESIS__
22+
cout << "Step: " << 1 << " Window Input = " << input_window_0 << " Result = " << (float) result/(N*N) << endl;
23+
cout << "Step: " << 2 << " Window Input = " << input_window_1 << " Result = " << (float) result/(N*N) << endl;
24+
cout << "Step: " << 3 << " Window Input = " << input_window_2 << " Result = " << (float) result/(N*N) << endl;
25+
cout << "Step: " << 4 << " Window Input = " << input_window_3 << " Result = " << (float) result/(N*N) << endl;
26+
cout << "Step: " << 5 << " Window Input = " << input_window_4 << " Result = " << (float) result/(N*N) << endl;
27+
cout << "Step: " << 6 << " Window Input = " << input_window_5 << " Result = " << (float) result/(N*N) << endl;
28+
cout << "Step: " << 7 << " Window Input = " << input_window_6 << " Result = " << (float) result/(N*N) << endl;
29+
cout << "Step: " << 8 << " Window Input = " << input_window_7 << " Result = " << (float) result/(N*N) << endl;
30+
cout << "Step: " << 9 << " Window Input = " << input_window_8 << " Result = " << (float) result/(N*N) << endl;
31+
#endif //__SYNTHESIS__
32+
33+
// // Perform the convolution
34+
// for (int i = 0; i < N; ++i) {
35+
// for (int j = 0; j < N; ++j) {
36+
// result += input_window[i * N + j];
37+
// #ifndef __SYNTHESIS__
38+
// cout << "Step: " << i * N + j << " Window Input = " << (int) input_window[i * N + j] << " Result = " << (float) result << endl;
39+
// #endif //__SYNTHESIS__
40+
// }
41+
// }
42+
result = result / (N*N);
43+
44+
output.write(result);
45+
}
46+
}
47+
48+
49+
#endif // IPS_FILTER_CPP
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#ifndef IPS_FILTER_HPP
2+
#define IPS_FILTER_HPP
3+
4+
#include <systemc.h>
5+
6+
#define N 3 //Filter Kernel
7+
8+
SC_MODULE (Filter) {
9+
//-----------------------------Local Variables-----------------------------
10+
// float kernel[N*N];
11+
sc_in<sc_uint<8> > input_window_0;
12+
sc_in<sc_uint<8> > input_window_1;
13+
sc_in<sc_uint<8> > input_window_2;
14+
sc_in<sc_uint<8> > input_window_3;
15+
sc_in<sc_uint<8> > input_window_4;
16+
sc_in<sc_uint<8> > input_window_5;
17+
sc_in<sc_uint<8> > input_window_6;
18+
sc_in<sc_uint<8> > input_window_7;
19+
sc_in<sc_uint<8> > input_window_8;
20+
sc_out<sc_uint<8> > output;
21+
22+
sc_in<bool> clk;
23+
24+
25+
void filter();
26+
void init_kernel();
27+
28+
SC_HAS_PROCESS(Filter);
29+
Filter(sc_module_name Filter)
30+
: sc_module(Filter)
31+
{
32+
SC_CTHREAD(filter, clk.pos());
33+
//sensitive << input_window_0 << input_window_1 << input_window_2 << input_window_3 << input_window_4 << input_window_5 << input_window_6 << input_window_7 << input_window_8;
34+
// for (int i = 0; i < N*N; i++){
35+
// kernel[i] = 1/N;
36+
// }
37+
}
38+
};
39+
40+
#endif // IPS_FILTER_HPP

0 commit comments

Comments
 (0)