Skip to content

Commit a83f679

Browse files
committed
Adding the documentation for the PV model of the filter module
1 parent 2446ae1 commit a83f679

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

modules/filter/include/ips_filter_pv_model.hpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,20 @@
77
#include <sstream>
88
#endif // IPS_DUMP_EN
99
#include <systemc.h>
10-
#include <vector>
1110

1211

12+
/**
13+
* @brief Filter module.
14+
* It takes care of filtering a image/kernel using a median filter or an
15+
* equivalent convolution like:
16+
* | 1/N^2 ... 1/N^2 | | img(row - N/2, col - N/2) ... img(row + N/2, col + N/2) |
17+
* img(row, col) = | ... ... .... | * | ... ... ... |
18+
* | 1/N^2 ... 1/N^2 | | img(row + N/2, col - N/2) ... img(row + N/2, col + N/2) |
19+
*
20+
* @tparam IN - data type of the inputs
21+
* @tparam OUT - data type of the outputs
22+
* @tparam N - size of the kernel
23+
*/
1324
template <typename IN = sc_uint<8>, typename OUT = sc_uint<8>, uint8_t N = 3>
1425
SC_MODULE(Filter)
1526
{
@@ -24,9 +35,20 @@ SC_MODULE(Filter)
2435
*/
2536
SC_CTOR(Filter);
2637
#ifdef IPS_DUMP_EN
38+
/**
39+
* @brief Construct a new Filter object
40+
*
41+
* @param name - name of the module
42+
* @param wf - waveform file pointer
43+
*/
2744
Filter(sc_core::sc_module_name name, sc_core::sc_trace_file* wf)
2845
: sc_core::sc_module(name), wf(wf)
2946
#else
47+
/**
48+
* @brief Construct a new Filter object
49+
*
50+
* @param name - name of the module
51+
*/
3052
Filter(sc_core::sc_module_name name) : sc_core::sc_module(name)
3153
#endif // IPS_DUMP_EN
3254
{
@@ -38,26 +60,39 @@ SC_MODULE(Filter)
3860
void init_kernel();
3961
};
4062

63+
/**
64+
* @brief Filtering image
65+
*
66+
* @param img_window - image window to filter
67+
* @param result - resultant pixel
68+
*/
4169
template <typename IN, typename OUT, uint8_t N>
4270
void Filter<IN, OUT, N>::filter(IN* img_window, OUT& result)
4371
{
4472
size_t i;
4573
size_t j;
4674

75+
// Default value for the result depending on the output datatype
4776
result = (OUT) 0;
4877

78+
// Perform the convolution
4979
for (i = 0; i < N; ++i)
5080
for (j = 0; j < N; ++j)
5181
result += this->kernel[i * N + j] * ((OUT) img_window[i * N + j]);
5282
}
5383

84+
/**
85+
* @brief Initializes a kernel of N x N with default value of 1 / (N^2)
86+
*
87+
*/
5488
template <typename IN, typename OUT, uint8_t N>
5589
void Filter<IN, OUT, N>::init_kernel()
5690
{
5791
// Init a kernel of N x N with default value of 1 / (N * N)
5892
this->kernel = new OUT[N * N];
5993
std::fill_n(this->kernel, N * N, ((OUT) 1) / ((OUT) N * N));
6094
#ifdef IPS_DEBUG_EN
95+
// Print the initialized kernel
6196
SC_REPORT_INFO(this->name(), "init_kernel result");
6297
size_t i, j;
6398

@@ -68,6 +103,7 @@ void Filter<IN, OUT, N>::init_kernel()
68103
std::cout << "[" << this->kernel[i * N + j] << "]";
69104

70105
#ifdef IPS_DUMP_EN
106+
// Adding the signals to the waveform
71107
std::ostringstream var_name;
72108
var_name << "kernel_" << i << "_" << j;
73109
sc_trace(this->wf, this->kernel[i * N + j], var_name.str());

0 commit comments

Comments
 (0)