Skip to content

Haresh median filter#8

Open
HareshWed wants to merge 3 commits into
mainfrom
Haresh-Median-Filter
Open

Haresh median filter#8
HareshWed wants to merge 3 commits into
mainfrom
Haresh-Median-Filter

Conversation

@HareshWed
Copy link
Copy Markdown
Collaborator

I am a pull

localparam int WINDOW_LEN = KERNEL_LEN * KERNEL_LEN;


// BRAM signals
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small style choice, but don't use _i with your intern module code. It should look like this:

logic bram_wr_en;
....
bram #(
.DATA_W (DATA_W),
.ADDR_W (ADDR_W)
) bram_inst_prev (
.clk (clk),
.wr_en_i (bram_wr_en),
....

logic fire_s1_q;
logic [DATA_W-1:0] pix_s1_q;
logic [ADDR_W-1:0] col_s1_q;
logic [ROW_W-1:0] row_s1_q;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't define a new signal in the middle of a module. Just put them at the top of a module

end


function automatic logic [PIXEL_W-1:0] median4_chan(
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function doesn't rely on module parameters. Define in a package

end

if (fire_s1_q) begin
if (col_s1_q == 0) begin
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why set these values to 0? It doesn't matter what these values are if we never use them

upper_median = high_1 < high_2 ? high_1 : high_2;


median4_chan = (lower_median + upper_median + 1) >> 1;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice implementation of this

endfunction


function automatic logic [PIXEL_W-1:0] get_red (input logic [DATA_W-1:0] px);
Copy link
Copy Markdown
Owner

@DonnyC123 DonnyC123 Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just do px.red and store px as a pixel_t? This would save a lot of code and you could just read the structs fields



logic [DATA_W-1:0] window_q [0:WINDOW_LEN-1];
logic [DATA_W-1:0] window_d [0:WINDOW_LEN-1];
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make these logic [DATA_W-1:0] and not pixel_t?

Comment on lines +209 to +210
pixel_valid_if_o.valid = 1'b0;
pixel_valid_if_o.pixel.red = '0;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can always set our pixel values equal to [color]_out. If [color]_out is garbage, we don't care. We won't read it anyway because pixel_valid_if_o.valid = 1'b1;

ixel_valid_if_o.pixel.red = red_out;
pixel_valid_if_o.pixel.green = green_out;
pixel_valid_if_o.pixel.blue = blue_out;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

....

Copy link
Copy Markdown
Owner

@DonnyC123 DonnyC123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job on the testbench code.

The hardware looked mostly good. There are just a few small changes that I think you should make

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants