update image processor to merge 3 chanels color into a RGB image
This commit is contained in:
		
							
								
								
									
										36
									
								
								IM_PROCESS/chanels_to_RGB.v
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								IM_PROCESS/chanels_to_RGB.v
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
`timescale 1ns/1ps
 | 
			
		||||
 | 
			
		||||
// 三通道图像合成一个RGB图像
 | 
			
		||||
module chanels_to_RGB #(
 | 
			
		||||
    parameter IN_DEPTH = 12,        // 输入图像的色深
 | 
			
		||||
    parameter OUT_DEPTH = 8         // 输出图像的色深
 | 
			
		||||
) (
 | 
			
		||||
    input clk,
 | 
			
		||||
    input reset,
 | 
			
		||||
 | 
			
		||||
    input in_en,
 | 
			
		||||
    input [IN_DEPTH - 1:0] data_in [2:0], // 0:R 1:G 2:B
 | 
			
		||||
 | 
			
		||||
    output reg out_en,
 | 
			
		||||
    output reg [3 * OUT_DEPTH - 1:0] data_out
 | 
			
		||||
);
 | 
			
		||||
    reg [31:0] data_cal [2:0]; // 用于保存运算结果,防止溢出
 | 
			
		||||
 | 
			
		||||
    always @(posedge clk or posedge reset) begin
 | 
			
		||||
        if (reset) begin
 | 
			
		||||
            // 初始化
 | 
			
		||||
            out_en <= 0;
 | 
			
		||||
            data_out <= 0;
 | 
			
		||||
        end
 | 
			
		||||
        else begin
 | 
			
		||||
            if (in_en) begin
 | 
			
		||||
                data_cal[0] <= data_in[0] * OUT_DEPTH / IN_DEPTH;
 | 
			
		||||
                data_cal[1] <= data_in[1] * OUT_DEPTH / IN_DEPTH;
 | 
			
		||||
                data_cal[2] <= data_in[2] * OUT_DEPTH / IN_DEPTH;
 | 
			
		||||
 | 
			
		||||
                data_out <= {data_cal[0][OUT_DEPTH - 1:0], data_cal[1][OUT_DEPTH - 1:0],data_cal[2][OUT_DEPTH - 1:0]};
 | 
			
		||||
            end
 | 
			
		||||
            out_en <= in_en;
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
endmodule
 | 
			
		||||
							
								
								
									
										20
									
								
								IM_PROCESS/scale_down_nearest.v
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								IM_PROCESS/scale_down_nearest.v
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
module scale_down_nearest #(
 | 
			
		||||
    parameter IN_WIDTH = 1920,
 | 
			
		||||
    parameter IN_HEIGHT = 1080,
 | 
			
		||||
    parameter OUT_WIDTH = 640,
 | 
			
		||||
    parameter OUT_HEIGHT = 480,
 | 
			
		||||
    parameter COLOR_DEPTH = 8
 | 
			
		||||
) (
 | 
			
		||||
    input clk,
 | 
			
		||||
    input reset,
 | 
			
		||||
 | 
			
		||||
    input in_en,
 | 
			
		||||
    input [3 * COLOR_DEPTH - 1:0] data_in,
 | 
			
		||||
    
 | 
			
		||||
    output out_en,
 | 
			
		||||
    output [3 * COLOR_DEPTH - 1:0] data_out
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
    localparam 
 | 
			
		||||
    
 | 
			
		||||
endmodule
 | 
			
		||||
							
								
								
									
										5
									
								
								RAM/RGB_to_RAM.v
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								RAM/RGB_to_RAM.v
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
module RGB_to_RAM (
 | 
			
		||||
    ports
 | 
			
		||||
);
 | 
			
		||||
    
 | 
			
		||||
endmodule
 | 
			
		||||
							
								
								
									
										5
									
								
								isp.v
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								isp.v
									
									
									
									
									
								
							@@ -3,8 +3,9 @@
 | 
			
		||||
module isp #(
 | 
			
		||||
    parameter IN_WIDTH = 1936,
 | 
			
		||||
    parameter IN_HEIGHT = 1088,
 | 
			
		||||
    // parameter OUT_WIDTH = 1936 - 2,
 | 
			
		||||
    // parameter OUT_HEIGHT = 1088 - 2,
 | 
			
		||||
    parameter OUT_WIDTH = 640,
 | 
			
		||||
    parameter OUT_HEIGHT = 480,
 | 
			
		||||
    parameter COLOR_DEPTH = 8,
 | 
			
		||||
    parameter RAW_TYPE = 3          // 0:grbg 1:rggb 2:bggr 3:gbrg
 | 
			
		||||
) (
 | 
			
		||||
    // 基本信号
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user