98 lines
2.4 KiB
Verilog
98 lines
2.4 KiB
Verilog
`timescale 1ns/1ps
|
||
|
||
module isp #(
|
||
parameter IN_WIDTH = 1936,
|
||
parameter IN_HEIGHT = 1088,
|
||
parameter OUT_WIDTH = 640,
|
||
parameter OUT_HEIGHT = 480,
|
||
parameter COLOR_DEPTH = 8,
|
||
parameter RAW_TYPE = 3 // 0:grbg 1:rggb 2:bggr 3:gbrg
|
||
) (
|
||
// 基本信号
|
||
input clk,
|
||
input reset,
|
||
|
||
// 数据输入信号
|
||
input data_en,
|
||
input [15:0] data_in [2:0], // 数据输入线,0、1、2分别表示第一、二、三行
|
||
output reg data_que, // 数据请求线,高电平:请求三个数据,直到读取完才拉低
|
||
output reg data_line, // 新一行请求数据线,高电平:请求九个数据,直到读取完才拉低
|
||
|
||
output out_clk,
|
||
output out_en,
|
||
output [31:0] data_out
|
||
);
|
||
// 三通道合成RGB图像
|
||
wire rgb_en;
|
||
wire [15:0] im_red, im_green, im_blue;
|
||
|
||
// 任意比例缩放图像
|
||
reg scale_in_en;
|
||
wire scale_in_que; // scaler 请求数据
|
||
reg [3 * COLOR_DEPTH - 1:0] scale_in_data;
|
||
|
||
// 写入RAM
|
||
wire RAM_in_en;
|
||
wire RAM_in_que; // RAM 请求数据
|
||
wire [3 * COLOR_DEPTH - 1:0] RAM_in_data;
|
||
|
||
assign out_clk = clk;
|
||
|
||
demosaic2 #(
|
||
.IM_WIDTH(1936),
|
||
.IM_HEIGHT(1088),
|
||
) CFA (
|
||
.clk(clk),
|
||
.reset(reset),
|
||
.data_en(data_en),
|
||
.data_in(data_in),
|
||
.data_que(data_que),
|
||
.data_line(data_line),
|
||
.out_en(rgb_en),
|
||
.out_r(im_red),
|
||
.out_g(im_green),
|
||
.out_b(im_blue)
|
||
);
|
||
|
||
chanels_to_RGB merge_toRGB(
|
||
.clk(clk),
|
||
.reset(reset),
|
||
.in_en(rgb_en),
|
||
.data_in({im_red[11:0], im_green[11:0], im_red[11:0]}),
|
||
// .data_in[0](im_red[11:0]),
|
||
// .data_in[1](im_green[11:0]),
|
||
// .data_in[2](im_red[11:0]),
|
||
|
||
.data_que(scale_in_que),
|
||
.out_en(scale_in_en),
|
||
.data_out(scale_in_data)
|
||
);
|
||
|
||
crop crop_process (
|
||
.clk(clk),
|
||
.reset(reset),
|
||
|
||
.in_en(scale_in_en),
|
||
.in_que(scale_in_que),
|
||
.data_in(scale_in_data),
|
||
|
||
.out_en(RAM_in_en),
|
||
.out_que(RAM_in_que),
|
||
.data_out(RAM_in_data)
|
||
);
|
||
|
||
// RGB_to_RAM write_to_RAM (
|
||
// .clk(clk),
|
||
// .reset(reset),
|
||
|
||
// .in_en(RAM_in_en),
|
||
// .in_que(RAM_in_que),
|
||
// .data_in(RAM_in_data),
|
||
|
||
// .write_que(out_que),
|
||
// .write_en(out_en),
|
||
// .data_write(data_out)
|
||
// );
|
||
|
||
endmodule
|