|
gy=module jz_filter
(
input [7:0]p00,
input [7:0]p01,
input [7:0]p02,
input [7:0]p10,
input [7:0]p11,
input [7:0]p12,
input [7:0]p20,
input [7:0]p21,
input [7:0]p22,
output [7:0]oval
);
/*
1 2 1
2 4 2
1 2 1
*/
/*
wire signed[10:0]gx,gy;
assign gx= (-{3'b000,p00[7:0]}) + (+{3'b000,p02 }) +
(-{3'b000,(p10[7:0]<<1)}) + (+{3'b000,(p12<<1) }) +
(-{3'b000,p20[7:0]}) + (+{3'b000,p22 }) ;
assign gy= (-{3'b000,p00[7:0]}) + (-{3'b000,(p01[7:0]<<1)}) + (-{3'b000,p02[7:0]}) +
(+{3'b000,p20[7:0]}) + (+{3'b000,(p21[7:0]<<1)}) + (+{3'b000,p22[7:0]}) ;
wire [10:0]gx_abs,gy_abs;
assign gx_abs=gx[10]?~gx+1'b1:gx;
assign gy_abs=gy[10]?~gy+1'b1:gy;
wire [10:0]d;
assign d=gx_abs+gy_abs;
assign oval=d[10:3];
*/
wire [10:0]sub;
assign sub=p00+p01+p02 +p10+ p12 +p20+p21+p22;
wire signed [11:0] chaz;
assign chaz=sub-({3'b000,p11[7:0]}<<3);
wire [11:0]abs_chaz;
assign abs_chaz=chaz[11]?~chaz+1'b1:chaz;
assign oval=abs_chaz[10:3];
//assign oval=sub[11:4];//取高8位
/*
wire [11:0]sub;
assign sub=p00+p01+p02 + p10+p11+p12 + p20+p21+p22;
always @(*)begin
oval=sub/12'd9;
end
*/
endmodule |
|