finish reconstruction
This commit is contained in:
		@@ -4,9 +4,9 @@
 | 
			
		||||
module ColorBlender #(
 | 
			
		||||
    parameter reg [ 4:0] IN_DEPTH    = 12,   // 输入图像的色深
 | 
			
		||||
    parameter reg [ 4:0] OUT_DEPTH   = 8,    // 输出图像的色深
 | 
			
		||||
    parameter reg [12:0] GAIN_RED    = 120,  // 红色增益系数(除以10^小数位数)
 | 
			
		||||
    parameter reg [12:0] GAIN_GREEN  = 50,   // 绿色增益系数
 | 
			
		||||
    parameter reg [12:0] GAIN_BLUE   = 95,   // 蓝色增益系数
 | 
			
		||||
    parameter reg [16:0] GAIN_RED    = 120,  // 红色增益系数
 | 
			
		||||
    parameter reg [16:0] GAIN_GREEN  = 50,   // 绿色增益系数
 | 
			
		||||
    parameter reg [16:0] GAIN_BLUE   = 95,   // 蓝色增益系数
 | 
			
		||||
    parameter reg [ 4:0] GAIN_OFFSET = 7
 | 
			
		||||
) (
 | 
			
		||||
    input clk,
 | 
			
		||||
@@ -21,7 +21,7 @@ module ColorBlender #(
 | 
			
		||||
    input in_ready,
 | 
			
		||||
    input in_receive,
 | 
			
		||||
    output out_en,
 | 
			
		||||
    output [3 * OUT_DEPTH - 1:0] data_out,
 | 
			
		||||
    output [3 * OUT_DEPTH - 1:0] out_data,
 | 
			
		||||
 | 
			
		||||
    // 颜色校正
 | 
			
		||||
    input wire color_correction
 | 
			
		||||
@@ -45,7 +45,7 @@ module ColorBlender #(
 | 
			
		||||
    case (state)
 | 
			
		||||
      READ_DATA: nextState = (in_en) ? (color_correction ? CALC_DATA : SEND_DATA) : READ_DATA;
 | 
			
		||||
      CALC_DATA: nextState = SEND_DATA;
 | 
			
		||||
      SEND_DATA: nextState = READ_DATA;
 | 
			
		||||
      SEND_DATA: nextState = (in_receive) ? READ_DATA : SEND_DATA;
 | 
			
		||||
      default: nextState = READ_DATA;
 | 
			
		||||
    endcase
 | 
			
		||||
  end
 | 
			
		||||
@@ -63,19 +63,25 @@ module ColorBlender #(
 | 
			
		||||
    end else begin
 | 
			
		||||
      case (state)
 | 
			
		||||
        READ_DATA: begin
 | 
			
		||||
 | 
			
		||||
          if (in_en) begin
 | 
			
		||||
            data_cal[0] <= ({{(32 - IN_DEPTH){1'b0}}, data_in[0]} >> (IN_DEPTH - OUT_DEPTH));
 | 
			
		||||
            data_cal[1] <= ({{(32 - IN_DEPTH){1'b0}}, data_in[1]} >> (IN_DEPTH - OUT_DEPTH));
 | 
			
		||||
            data_cal[2] <= ({{(32 - IN_DEPTH){1'b0}}, data_in[2]} >> (IN_DEPTH - OUT_DEPTH));
 | 
			
		||||
            data_cal[0] <= ({16'b0, data_in[0]} << 8;
 | 
			
		||||
            data_cal[1] <= ({16'b0, data_in[1]} << 8;
 | 
			
		||||
            data_cal[2] <= ({16'b0, data_in[2]} << 8;
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        CALC_DATA: begin
 | 
			
		||||
          data_cal[0] <=  data_cal[0] * (GAIN_RED << 8)
 | 
			
		||||
          data_cal[1] <=  data_cal[1] * (GAIN_GREEN << 8)
 | 
			
		||||
          data_cal[2] <=  data_cal[2] * (GAIN_BLUE << 8)
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        SEND_DATA: begin
 | 
			
		||||
 | 
			
		||||
          if (in_ready) begin
 | 
			
		||||
            out_data[0] <= data_cal[0] >> (8 + IN_DEPTH - OUT_DEPTH)
 | 
			
		||||
            out_data[1] <= data_cal[1] >> (8 + IN_DEPTH - OUT_DEPTH)
 | 
			
		||||
            out_data[2] <= data_cal[2] >> (8 + IN_DEPTH - OUT_DEPTH)
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        default: ;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										56
									
								
								isp.v
									
									
									
									
									
								
							
							
						
						
									
										56
									
								
								isp.v
									
									
									
									
									
								
							@@ -26,13 +26,12 @@ module isp #(
 | 
			
		||||
  localparam BAYER_WIDTH = IN_WIDTH - 2;
 | 
			
		||||
  localparam BAYER_HEIGHT = IN_HEIGHT - 2;
 | 
			
		||||
  // 三通道合成RGB图像
 | 
			
		||||
  wire rgb_en;
 | 
			
		||||
  wire [15:0] im_red, im_green, im_blue;
 | 
			
		||||
  wire blender_en, blender_ready, blender_receive;
 | 
			
		||||
  wire [15:0] blender_r, blender_g, blender_b;
 | 
			
		||||
 | 
			
		||||
  // 任意比例缩放图像
 | 
			
		||||
  reg                          scale_in_en;
 | 
			
		||||
  wire                         scale_in_que;  // scaler 请求数据
 | 
			
		||||
  reg  [3 * COLOR_DEPTH - 1:0] scale_in_data;
 | 
			
		||||
  wire                         crop_en, crop_ready, crop_receive;  // scaler 请求数据
 | 
			
		||||
  reg  [3 * COLOR_DEPTH - 1:0] crop_data;
 | 
			
		||||
 | 
			
		||||
  // 写入RAM
 | 
			
		||||
  // wire RAM_in_en;
 | 
			
		||||
@@ -48,13 +47,19 @@ module isp #(
 | 
			
		||||
  ) CFA (
 | 
			
		||||
      .clk(clk),
 | 
			
		||||
      .reset(reset),
 | 
			
		||||
      .data_en(data_en),
 | 
			
		||||
      .data_in(data_in),
 | 
			
		||||
      .data_que(data_que),
 | 
			
		||||
      .out_en(rgb_en),
 | 
			
		||||
      .out_r(im_red),
 | 
			
		||||
      .out_g(im_green),
 | 
			
		||||
      .out_b(im_blue)
 | 
			
		||||
      
 | 
			
		||||
      .in_en(data_en),
 | 
			
		||||
      .in_data(data_in),
 | 
			
		||||
      .out_ready(data_que),
 | 
			
		||||
      .out_en(blender_en),
 | 
			
		||||
      .out_receive(),
 | 
			
		||||
 | 
			
		||||
      .out_en(blender_en),
 | 
			
		||||
      .in_ready(blender_ready),
 | 
			
		||||
      .in_receive(blender_receive),
 | 
			
		||||
      .out_r(blender_r),
 | 
			
		||||
      .out_g(blender_g),
 | 
			
		||||
      .out_b(blender_b)
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  ColorBlender #(
 | 
			
		||||
@@ -64,16 +69,20 @@ module isp #(
 | 
			
		||||
      .GAIN_RED(120),
 | 
			
		||||
      .GAIN_GREEN(50),
 | 
			
		||||
      .GAIN_BLUE(95),
 | 
			
		||||
      .DECIMAL(2)
 | 
			
		||||
  ) blender (
 | 
			
		||||
      .clk(clk),
 | 
			
		||||
      .reset(reset),
 | 
			
		||||
      .in_en(rgb_en),
 | 
			
		||||
      .data_in({im_blue, im_green, im_red}),
 | 
			
		||||
 | 
			
		||||
      .out_que(scale_in_que),
 | 
			
		||||
      .out_en(scale_in_en),
 | 
			
		||||
      .data_out(scale_in_data),
 | 
			
		||||
      .in_en(blender_en),
 | 
			
		||||
      .in_data({blender_r, blender_g, blender_b}),
 | 
			
		||||
      .out_ready(blender_ready),
 | 
			
		||||
      .out_receive(blender_receive),
 | 
			
		||||
 | 
			
		||||
      .in_ready(crop_ready),
 | 
			
		||||
      .in_receive(crop_receive)
 | 
			
		||||
      .out_en(crop_en),
 | 
			
		||||
      .data_out(crop_data),
 | 
			
		||||
 | 
			
		||||
      .color_correction(color_correction)
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
@@ -87,12 +96,15 @@ module isp #(
 | 
			
		||||
      .clk  (clk),
 | 
			
		||||
      .reset(reset),
 | 
			
		||||
 | 
			
		||||
      .in_en  (scale_in_en),
 | 
			
		||||
      .in_que (scale_in_que),
 | 
			
		||||
      .data_in(scale_in_data),
 | 
			
		||||
      .in_en  (crop_en),
 | 
			
		||||
      .out_ready (crop_ready),
 | 
			
		||||
      .out_receive(crop_receive)
 | 
			
		||||
      .in_data(crop_data),
 | 
			
		||||
 | 
			
		||||
      .out_en  (out_en),
 | 
			
		||||
      .data_out(data_out)
 | 
			
		||||
      .in_ready(),
 | 
			
		||||
      .in_receive(),
 | 
			
		||||
      .out_data(data_out)
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  // RGB_to_RAM write_to_RAM (
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user