Skip to content

untested median filter#1

Draft
DonnyC123 wants to merge 11 commits into
mainfrom
Jacobs_Branch
Draft

untested median filter#1
DonnyC123 wants to merge 11 commits into
mainfrom
Jacobs_Branch

Conversation

@DonnyC123
Copy link
Copy Markdown
Owner

No description provided.

pixel_t input_buffer_q [PIXELS_NEEDED- 1 : 0];
pixel_t input_buffer_d [PIXELS_NEEDED- 1 : 0];
logic [$clog2(PIXELS_NEEDED) - 1 : 0] pixel_ins_counter_q, pixel_ins_counter_d;
logic [$clog2(IMAGE_LEN) - 1 : 0] calculate_counter_q, calculate_counter_d;
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Remove spaces here between - 1 : 0, etc

pixel_t input_buffer_d [PIXELS_NEEDED- 1 : 0];
logic [$clog2(PIXELS_NEEDED) - 1 : 0] pixel_ins_counter_q, pixel_ins_counter_d;
logic [$clog2(IMAGE_LEN) - 1 : 0] calculate_counter_q, calculate_counter_d;
logic [$clog2(IMAGE_HEIGHT) - 1 : 0] current_row_q, current_row_d;
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Make this a parameter

pixel_ins_counter_q <= '0;
input_buffer_q <= '0;
calculate_counter_q <= '0;
current_row_q <= '0;
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Spacing

pixel_ins_counter_d = pixel_ins_counter_q + 1;
state_d = READ; // so go to read

if(pixel_ins_counter_d >= PIXELS_NEEDED) begin // if we have enough pixels
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

nit: Use previous counter == PIXELS_NEEDED-1 && pixel_valid_if_i.pixel

CALCULATE : begin
// can only run this image len-1 time before we need to wait kernal_length cycles
// 2 x 2 = indexes: 0, 1, oldest, 2nd oldest
middle_value_r = get_middle_values(input_buffer_q[input_buffer_q.high()].red,
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This will become a latch. Just move outside your case statement

end
end

CALCULATE : begin
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Can't handle recieving and processing Data at the same time.



// Outputs
pixel_valid_if_o.pixel.red = get_adverage(middle_value_r);
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Spelling

// Takes: two logic values of PIXEL_W {a,b}
// Function: swaps if a > b
// Returns: the potentially swapped values {a,b} || {b,a}
function automatic logic [2*PIXEL_W-1:0] swap(
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Good job

logic [2*PIXEL_W-1:0] swapped_vals;

// start
a = value1; b = value2; c = value3; d = value4;
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Style Guide

// start
a = value1; b = value2; c = value3; d = value4;
// (a,b)
swapped_vals = swap(a,b);
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Should do 4 swaps:

low_1 high_1 = Swap(a, b)
low_2 high_2 = Swap(c, d)

mid1, ignore = Swap(high_1, high_2)
ignore, mid2 = Swap(low_1, low_2)

// Takes: two pixel values rgb values appended together
// Function: does the adverage
// Returns: the adverage
function automatic logic [PIXEL_W-1:0] get_adverage (logic [PIXEL_W*2-1:0] values);
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Dont do weird packing stuff

// Takes: 4 logic values of PIXEL_W (r || g || b)
// Function: Sorts those values
// Returns: the middle two of those sorted values appended together
function automatic logic [2*PIXEL_W-1:0] get_middle_values (logic [PIXEL_W-1:0] value1, logic [PIXEL_W-1:0] value2,
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Use an unpacked type [PIXEL_W-1:0] get_middle_values [2]

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