update image processor to merge 3 chanels color into a RGB image

This commit is contained in:
SikongJueluo 2024-05-11 17:43:26 +08:00
parent 9fc9627fc8
commit f3f01c1c51
No known key found for this signature in database
GPG Key ID: D2D3D29A993716EA
4 changed files with 64 additions and 2 deletions

View 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

View 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
View File

@ -0,0 +1,5 @@
module RGB_to_RAM (
ports
);
endmodule

5
isp.v
View File

@ -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
) (
// 基本信号