Skip to content

Commit

Permalink
Merge pull request #22 from ErickOF/feature-filter_module
Browse files Browse the repository at this point in the history
Improving filter module code
  • Loading branch information
ErickOF authored Jul 6, 2024
2 parents 169886d + 3da0ea0 commit f90aa09
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions modules/filter/include/ips_filter_at_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ void Filter<IN, OUT, N>::exec_filter()
wait(this->event);

// Default value for the result depending on the output datatype
result_tmp = (OUT) 0;
result_tmp = static_cast<OUT >(0);

// Getting the image window to filter
IN* img_window_tmp = this->img_window.read();

// Perform the convolution
for (i = 0; i < N; ++i)
for (j = 0; j < N; ++j)
result_tmp += this->kernel[i * N + j] * ((OUT) img_window_tmp[i * N + j]);
result_tmp += this->kernel[i * N + j] * static_cast<OUT >(img_window_tmp[i * N + j]);

this->result.write(result_tmp);
}
Expand All @@ -128,7 +128,7 @@ void Filter<IN, OUT, N>::init()
{
// Init a kernel of N x N with default value of 1 / (N * N)
this->kernel = new OUT[N * N];
std::fill_n(this->kernel, N * N, ((OUT) 1) / ((OUT) N * N));
std::fill_n(this->kernel, N * N, static_cast<OUT >(1) / static_cast<OUT >(N * N));

#ifdef IPS_DEBUG_EN
// Print the initialized kernel
Expand Down
6 changes: 3 additions & 3 deletions modules/filter/include/ips_filter_lt_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void Filter<IN, OUT, N>::exec_filter()
wait(this->event);

// Default value for the result depending on the output datatype
*(this->result_ptr) = (OUT) 0;
*(this->result_ptr) = static_cast<OUT >(0);

// Perform the convolution
for (i = 0; i < N; ++i)
Expand All @@ -118,7 +118,7 @@ void Filter<IN, OUT, N>::filter(IN* img_window, OUT* result)
// Perform the convolution
for (i = 0; i < N; ++i)
for (j = 0; j < N; ++j)
this->img_window_tmp[i * N + j] = (OUT) img_window[i * N + j];
this->img_window_tmp[i * N + j] = static_cast<OUT >(img_window[i * N + j]);

this->event.notify(DELAY_TIME, SC_NS);
}
Expand All @@ -132,7 +132,7 @@ void Filter<IN, OUT, N>::init()
{
// Init a kernel of N x N with default value of 1 / (N * N)
this->kernel = new OUT[N * N];
std::fill_n(this->kernel, N * N, ((OUT) 1) / ((OUT) N * N));
std::fill_n(this->kernel, N * N, static_cast<OUT >(1) / static_cast<OUT > (N * N));
// Init image window of N x N with default value of 1 / (N * N)
this->img_window_tmp = new OUT[N * N];
#ifdef IPS_DEBUG_EN
Expand Down
6 changes: 3 additions & 3 deletions modules/filter/include/ips_filter_pv_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ void Filter<IN, OUT, N>::filter(IN* img_window, OUT& result)
size_t j;

// Default value for the result depending on the output datatype
result = (OUT) 0;
result = static_cast<OUT >(0);

// Perform the convolution
for (i = 0; i < N; ++i)
for (j = 0; j < N; ++j)
result += this->kernel[i * N + j] * ((OUT) img_window[i * N + j]);
result += this->kernel[i * N + j] * static_cast<OUT >(img_window[i * N + j]);
}

/**
Expand All @@ -90,7 +90,7 @@ void Filter<IN, OUT, N>::init_kernel()
{
// Init a kernel of N x N with default value of 1 / (N * N)
this->kernel = new OUT[N * N];
std::fill_n(this->kernel, N * N, ((OUT) 1) / ((OUT) N * N));
std::fill_n(this->kernel, N * N, static_cast<OUT >(1) / static_cast<OUT >(N * N));
#ifdef IPS_DEBUG_EN
// Print the initialized kernel
SC_REPORT_INFO(this->name(), "init_kernel result");
Expand Down

0 comments on commit f90aa09

Please sign in to comment.