|
| 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 |
0 commit comments