找到了verilog的3×3中值滤波的程序,需要输入的3×3模板窗口应该怎么处理呢?
源程序也附上了
module median_filter(
//input
clk,
rst_n,
hs,
vs,
hde,
vde,
edge_here,
filter_sel,
mdf_a11,
mdf_a12,
mdf_a13,
mdf_a21,
mdf_a22,
mdf_a23,
mdf_a31,
mdf_a32,
mdf_a33,
//output
des_data_y,
des_data_uv,
hs_out,
vs_out,
hde_out,
vde_out
);
// Internal Declarations
input clk;
input rst_n;
input hs;
input vs;
input hde;
input vde;
input edge_here;
input [1:0] filter_sel;
input [15:0] mdf_a11;
input [15:0] mdf_a12;
input [15:0] mdf_a13;
input [15:0] mdf_a21;
input [15:0] mdf_a22;
input [15:0] mdf_a23;
input [15:0] mdf_a31;
input [15:0] mdf_a32;
input [15:0] mdf_a33;
output [7:0] des_data_y;
output [7:0] des_data_uv;
output hs_out;
output vs_out;
output hde_out;
output vde_out;
wire clk;
wire rst_n;
wire hs;
wire vs;
wire hde;
wire vde;
wire edge_here;
wire [1:0] filter_sel;
wire [15:0] mdf_a11;
wire [15:0] mdf_a12;
wire [15:0] mdf_a13;
wire [15:0] mdf_a21;
wire [15:0] mdf_a22;
wire [15:0] mdf_a23;
wire [15:0] mdf_a31;
wire [15:0] mdf_a32;
wire [15:0] mdf_a33;
wire [7:0] des_data_y;
wire [7:0] des_data_uv;
reg hs_out;
reg vs_out;
reg hde_out;
reg vde_out;
// ### Please start your Verilog code here ###
reg [15:0] mdf_a22_d1, mdf_a22_d2, mdf_a22_d3;
reg [15:0] mdf_a22_d4, mdf_a22_d5, mdf_a22_d6;
wire [7:0] max_1_y, max_2_y, max_3_y;
wire [7:0] min_1_y, min_2_y, min_3_y;
wire [7:0] median_1_y, median_2_y, median_3_y;
wire [7:0] max_1_uv, max_2_uv, max_3_uv;
wire [7:0] min_1_uv, min_2_uv, min_3_uv;
wire [7:0] median_1_uv, median_2_uv, median_3_uv;
wire [7:0] max_y, min_y;
wire [7:0] max_uv, min_uv;
wire [7:0] des_data_y_tmp;
wire [7:0] des_data_uv_tmp;
wire noise_here_y;
wire noise_here_uv;
reg hs_d1, hs_d2, hs_d3, hs_d4, hs_d5;
reg vs_d1, vs_d2, vs_d3, vs_d4, vs_d5;
reg hde_d1, hde_d2, hde_d3, hde_d4, hde_d5;
reg vde_d1, vde_d2, vde_d3, vde_d4, vde_d5;
comparator_mdf comparator_3x3_1_y(
.clk (clk),
.rst_n (rst_n),
.filter_sel (filter_sel),
.input_1 (mdf_a11[15:8]),
.input_2 (mdf_a12[15:8]),
.input_3 (mdf_a13[15:8]),
.max (max_1_y),
.min (min_1_y),
.median (median_1_y)
);
comparator_mdf comparator_3x3_2_y(
.clk (clk),
.rst_n (rst_n),
.filter_sel (filter_sel),
.input_1 (mdf_a21[15:8]),