change a little thing
This commit is contained in:
parent
5f19fdf275
commit
242f3527f8
|
@ -3,8 +3,7 @@
|
|||
// 三通道图像合成一个RGB图像
|
||||
module ColorBlender #(
|
||||
parameter reg [4:0] IN_DEPTH = 12, // 输入图像的色深
|
||||
parameter reg [4:0] OUT_DEPTH = 8, // 输出图像的色深
|
||||
parameter reg [8:0] BUFF_SIZE = 32
|
||||
parameter reg [4:0] OUT_DEPTH = 8 // 输出图像的色深
|
||||
) (
|
||||
input wire clk,
|
||||
input wire reset,
|
||||
|
@ -32,7 +31,7 @@ module ColorBlender #(
|
|||
localparam reg [2:0] SEND_DATA = 3;
|
||||
|
||||
reg [2:0] state, nextState;
|
||||
reg [BUFF_SIZE - 1:0] data_cal[3]; // 用于保存运算结果,防止溢出
|
||||
reg [32 - 1:0] data_cal[3]; // 用于保存运算结果,防止溢出
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (reset) begin
|
||||
|
@ -70,17 +69,17 @@ module ColorBlender #(
|
|||
case (state)
|
||||
READ_DATA: begin
|
||||
if (in_en) begin
|
||||
data_cal[0] <= ({{(BUFF_SIZE - 16){1'b0}}, in_data[0]}) << (8 - (IN_DEPTH - OUT_DEPTH));
|
||||
data_cal[1] <= ({{(BUFF_SIZE - 16){1'b0}}, in_data[1]}) << (8 - (IN_DEPTH - OUT_DEPTH));
|
||||
data_cal[2] <= ({{(BUFF_SIZE - 16){1'b0}}, in_data[2]}) << (8 - (IN_DEPTH - OUT_DEPTH));
|
||||
data_cal[0] <= ({16'b0, in_data[0]}) << (8 - (IN_DEPTH - OUT_DEPTH));
|
||||
data_cal[1] <= ({16'b0, in_data[1]}) << (8 - (IN_DEPTH - OUT_DEPTH));
|
||||
data_cal[2] <= ({16'b0, in_data[2]}) << (8 - (IN_DEPTH - OUT_DEPTH));
|
||||
end
|
||||
end
|
||||
|
||||
CALC_DATA: begin
|
||||
if (enable) begin
|
||||
data_cal[0] <= (data_cal[0] * {{(BUFF_SIZE - 16) {1'b0}}, gain_red}) >> 16;
|
||||
data_cal[1] <= (data_cal[1] * {{(BUFF_SIZE - 16) {1'b0}}, gain_green}) >> 16;
|
||||
data_cal[2] <= (data_cal[2] * {{(BUFF_SIZE - 16) {1'b0}}, gain_blue}) >> 16;
|
||||
data_cal[0] <= (data_cal[0] * {16'b0, gain_red}) >> 16;
|
||||
data_cal[1] <= (data_cal[1] * {16'b0, gain_green}) >> 16;
|
||||
data_cal[2] <= (data_cal[2] * {16'b0, gain_blue}) >> 16;
|
||||
end else begin
|
||||
data_cal[0] <= data_cal[0] >> 8;
|
||||
data_cal[1] <= data_cal[1] >> 8;
|
||||
|
@ -89,9 +88,9 @@ module ColorBlender #(
|
|||
end
|
||||
|
||||
SATI_DATA: begin
|
||||
data_cal[0] <= |data_cal[0][BUFF_SIZE-1 : OUT_DEPTH] ? {BUFF_SIZE{1'b1}} : data_cal[0];
|
||||
data_cal[1] <= |data_cal[0][BUFF_SIZE-1 : OUT_DEPTH] ? {BUFF_SIZE{1'b1}} : data_cal[1];
|
||||
data_cal[2] <= |data_cal[0][BUFF_SIZE-1 : OUT_DEPTH] ? {BUFF_SIZE{1'b1}} : data_cal[2];
|
||||
data_cal[0] <= |data_cal[0][31 : OUT_DEPTH] ? {32{1'b1}} : data_cal[0];
|
||||
data_cal[1] <= |data_cal[0][31 : OUT_DEPTH] ? {32{1'b1}} : data_cal[1];
|
||||
data_cal[2] <= |data_cal[0][31 : OUT_DEPTH] ? {32{1'b1}} : data_cal[2];
|
||||
end
|
||||
|
||||
SEND_DATA: begin
|
||||
|
|
54
isp.sv
54
isp.sv
|
@ -130,10 +130,32 @@ module isp #(
|
|||
.out_receive(crop_receive),
|
||||
.in_data({crop_data[2], crop_data[1], crop_data[0]}),
|
||||
|
||||
.out_en(gamma_en),
|
||||
.out_en(white_en),
|
||||
.in_ready(white_ready),
|
||||
.in_receive(white_receive),
|
||||
.out_data({white_data[2], white_data[1], white_data[0]})
|
||||
);
|
||||
|
||||
GreyWorld #(
|
||||
.COLOR_DEPTH(COLOR_DEPTH),
|
||||
.IM_SIZE({16'b0, OUT_WIDTH} * {16'b0, OUT_HEIGHT})
|
||||
) inst_whitebalance (
|
||||
.clk (clk),
|
||||
.reset(reset),
|
||||
|
||||
.in_en(white_en),
|
||||
.in_data(white_data),
|
||||
.out_ready(white_ready),
|
||||
.out_receive(white_receive),
|
||||
|
||||
.in_ready(gamma_ready),
|
||||
.in_receive(gamma_receive),
|
||||
.out_data({gamma_data[2], gamma_data[1], gamma_data[0]})
|
||||
.out_en(gamma_en),
|
||||
.out_data(gamma_data),
|
||||
|
||||
.enable(white_enable),
|
||||
.flame_rate(flame_rate),
|
||||
.white_gain(white_gain)
|
||||
);
|
||||
|
||||
// 查找表型Gamma校正
|
||||
|
@ -168,37 +190,17 @@ module isp #(
|
|||
.out_receive(saturation_receive),
|
||||
.in_data(saturation_data),
|
||||
|
||||
.in_ready(white_ready),
|
||||
.in_receive(white_receive),
|
||||
.out_en(white_en),
|
||||
.out_data(white_data),
|
||||
|
||||
.saturation_inc(saturation_inc),
|
||||
.enable(saturation_enable)
|
||||
);
|
||||
|
||||
GreyWorld #(
|
||||
.COLOR_DEPTH(COLOR_DEPTH),
|
||||
.IM_SIZE({16'b0, OUT_WIDTH} * {16'b0, OUT_HEIGHT})
|
||||
) inst_whitebalance (
|
||||
.clk (clk),
|
||||
.reset(reset),
|
||||
|
||||
.in_en(white_en),
|
||||
.in_data(white_data),
|
||||
.out_ready(white_ready),
|
||||
.out_receive(white_receive),
|
||||
|
||||
.in_ready(in_ready),
|
||||
.in_receive(in_receive),
|
||||
.out_en(out_en),
|
||||
.out_data(w_out_data),
|
||||
|
||||
.enable(white_enable),
|
||||
.flame_rate(flame_rate),
|
||||
.white_gain(white_gain)
|
||||
.saturation_inc(saturation_inc),
|
||||
.enable(saturation_enable)
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
endmodule
|
||||
|
|
Loading…
Reference in New Issue