fix demosaic not work correctly and polish project manage
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
`timescale 1ns / 1ps
|
||||
|
||||
module DPC #(
|
||||
parameter reg [15:0] TOTAL_WIDTH = 512 + 3, // 总图像宽度
|
||||
parameter reg [15:0] TOTAL_HEIGHT = 256 + 3, // 总图像高度
|
||||
parameter reg [ 1:0] RAW_TYPE = 3, // (0,0)位置算起RAW_TYPE的值
|
||||
parameter reg [ 4:0] DATA_WIDTH = 16 // 输入/输出数据位宽
|
||||
parameter reg [15:0] TOTAL_WIDTH = 512 + 3, // 总图像宽度
|
||||
parameter reg [15:0] TOTAL_HEIGHT = 256 + 3, // 总图像高度
|
||||
parameter reg [ 1:0] RAW_TYPE = 3, // (0,0)位置算起RAW_TYPE的值
|
||||
parameter reg [ 4:0] DATA_WIDTH = 16, // 输入/输出数据位宽
|
||||
parameter reg [ 4:0] MODULE_ENABLE = 0, // 是否启用该模块,DEBUG用
|
||||
parameter reg [ 4:0] LABLE_ENABLE = 1 // 是否启动坏点标注,DEBUG用
|
||||
) (
|
||||
input wire clk,
|
||||
input wire reset,
|
||||
@@ -220,18 +221,20 @@ module DPC #(
|
||||
channel_cache_correct_final <= channel_cache_correct2[flag_which_dict];
|
||||
case (flag_which_dict)
|
||||
2'b00:
|
||||
flag_if_need_corection <= grad_h_cache2[1] > 4 * (grad_h_cache2[0] + grad_h_cache2[2]);
|
||||
flag_if_need_corection <= grad_h_cache2[1] / 4 > (grad_h_cache2[0] + grad_h_cache2[2]);
|
||||
2'b01:
|
||||
flag_if_need_corection <= grad_v_cache2[1] > 4 * (grad_v_cache2[0] + grad_v_cache2[2]);
|
||||
flag_if_need_corection <= grad_v_cache2[1] / 4 > (grad_v_cache2[0] + grad_v_cache2[2]);
|
||||
2'b10:
|
||||
flag_if_need_corection <= grad_45_cache2[1] > 3 * (grad_45_cache2[0] + grad_45_cache2[2]);
|
||||
flag_if_need_corection <= grad_45_cache2[1] / 4 > (grad_45_cache2[0] + grad_45_cache2[2]);
|
||||
2'b11:
|
||||
flag_if_need_corection <= grad_135_cache2[1] > 3*(grad_135_cache2[0] + grad_135_cache2[2]);
|
||||
flag_if_need_corection <= grad_135_cache2[1]/4 > (grad_135_cache2[0] + grad_135_cache2[2]);
|
||||
endcase
|
||||
end
|
||||
|
||||
if(pipeline_valid[7]) begin //如果是坏点,输出计算后的值;如果不是坏点,输出原值
|
||||
out_data <= (flag_if_need_corection) ? (channel_cache_correct_final) : (channel_cache4);
|
||||
if (MODULE_ENABLE)
|
||||
out_data <= (flag_if_need_corection)?((LABLE_ENABLE)?(12'hFFF):(channel_cache_correct_final)):(channel_cache4);
|
||||
else out_data <= channel_cache4;
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -296,3 +299,4 @@ module DPC #(
|
||||
|
||||
endmodule
|
||||
|
||||
|
||||
|
||||
@@ -58,7 +58,6 @@ module Demosaic_Pipeline #(
|
||||
raw_type <= RAW_TYPE;
|
||||
end else if (pipeline_running) begin
|
||||
|
||||
// First level pipeline for reading data
|
||||
pipeline_valid <= {pipeline_valid[PIPILINE-2:0], in_valid};
|
||||
|
||||
if (in_valid) begin
|
||||
@@ -107,7 +106,7 @@ module Demosaic_Pipeline #(
|
||||
end
|
||||
|
||||
if (pipeline_valid[2]) begin
|
||||
{out_data[2], out_data[1], out_data[0]} <= {red, blue, green};
|
||||
{out_data[2], out_data[1], out_data[0]} <= {red, green, blue};
|
||||
out_hsync <= (temp_pos_x2 == 0);
|
||||
out_fsync <= ((temp_pos_x2 == 0) && (temp_pos_y2 == 0));
|
||||
end
|
||||
@@ -119,3 +118,4 @@ module Demosaic_Pipeline #(
|
||||
// grg rgr bgb gbg 258
|
||||
endmodule
|
||||
|
||||
|
||||
|
||||
@@ -38,17 +38,21 @@ SHIFT_REG0 -> 1 4 7 . .
|
||||
. . .
|
||||
*/
|
||||
|
||||
reg firstframedone;
|
||||
reg [15:0] pos_x, pos_y;
|
||||
always @(posedge clk) begin
|
||||
if (reset) begin
|
||||
pos_x <= 0;
|
||||
pos_y <= 0;
|
||||
firstframedone <= 0;
|
||||
end else if (regx_out_valid[WINDOWS_WIDTH-2]) begin
|
||||
pos_x <= (pos_x >= IMAGE_WIDTH - 1) ? (0) : (pos_x + 1);
|
||||
pos_y <= (pos_x >= IMAGE_WIDTH - 1)?((pos_y >= IMAGE_HEIGHT - 1)?(0):(pos_y + 1)):(pos_y);
|
||||
firstframedone <= (pos_x >= IMAGE_WIDTH - 1 && pos_y >= IMAGE_HEIGHT - 1)?(1):(firstframedone);
|
||||
end else begin
|
||||
pos_x <= pos_x;
|
||||
pos_y <= pos_y;
|
||||
firstframedone <= firstframedone;
|
||||
end
|
||||
end
|
||||
|
||||
@@ -62,11 +66,13 @@ SHIFT_REG0 -> 1 4 7 . .
|
||||
for (j = 0; j < WINDOWS_WIDTH; j = j + 1) begin
|
||||
if (i == WINDOWS_WIDTH - 1) begin
|
||||
if (j == 0) out_data[(WINDOWS_WIDTH*i)+j] <= regx_out_data[WINDOWS_WIDTH-2];
|
||||
else out_data[(WINDOWS_WIDTH*i)+j] <= data_out_shift[j-1][2*i-1];
|
||||
else out_data[(WINDOWS_WIDTH*i)+j] <= data_out_shift[j-1][2*j-1];
|
||||
end else out_data[(WINDOWS_WIDTH*i)+j] <= out_data[(WINDOWS_WIDTH*(i+1))+j];
|
||||
end
|
||||
end
|
||||
out_valid <= ~((pos_y <= WINDOWS_WIDTH-WINDOWS_ANCHOR_Y-1 && pos_x < WINDOWS_WIDTH-WINDOWS_ANCHOR_X-1) || (pos_y < WINDOWS_WIDTH-WINDOWS_ANCHOR_Y-1));
|
||||
if (firstframedone) out_valid <= 1;
|
||||
else
|
||||
out_valid <= ~((pos_y <= WINDOWS_WIDTH-WINDOWS_ANCHOR_Y-1 && pos_x < WINDOWS_WIDTH-WINDOWS_ANCHOR_X-1) || (pos_y < WINDOWS_WIDTH-WINDOWS_ANCHOR_Y-1));
|
||||
end else begin
|
||||
for (i = 0; i < WINDOWS_WIDTH * WINDOWS_WIDTH - 1; i = i + 1) out_data[i] <= out_data[i];
|
||||
out_valid <= 0;
|
||||
|
||||
Reference in New Issue
Block a user