//
|
//
|
//
|
//
|
//
|
//
|
|
|
|
|
module cl_area_scan_checker
|
module cl_area_scan_checker
|
(
|
(
|
input cl_fval,
|
input cl_fval,
|
input cl_lval,
|
input cl_lval,
|
input cl_dval,
|
input cl_dval,
|
input [63:0] cl_data,
|
input [63:0] cl_data,
|
input cl_clk,
|
input cl_clk,
|
|
|
input cl_reset
|
input cl_reset
|
);
|
);
|
|
|
// --------------------------------------------------------------------
|
|
//
|
|
localparam FPA_FS1 = 14'h3fff;
|
|
localparam FPA_FS2 = 14'h3ffe;
|
|
localparam FPA_LS = 14'h3ffd;
|
|
localparam FPA_HB = 14'h3ffc;
|
|
localparam FPA_VB = 14'h3ffb;
|
|
localparam FPA_BLK = 14'h3ff3;
|
|
localparam FPA_IT = 14'h3ff2;
|
|
localparam FPA_EOD = 14'h3ff1;
|
|
|
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
//
|
//
|
wire [13:0] cl_pixel_counter;
|
wire [13:0] cl_pixel_counter;
|
wire [15:0] cl_frame_x;
|
wire [15:0] cl_frame_x;
|
wire [15:0] cl_frame_y;
|
wire [15:0] cl_frame_y;
|
wire cl_fval_fall;
|
wire cl_fval_fall;
|
wire cl_fval_rise;
|
wire cl_fval_rise;
|
wire cl_lval_fall;
|
wire cl_lval_fall;
|
wire cl_lval_rise;
|
wire cl_lval_rise;
|
wire cl_data_en;
|
wire cl_data_en;
|
reg cl_base_format = 0;
|
reg cl_base_format = 0;
|
reg cl_full_format = 0;
|
reg cl_full_format = 0;
|
|
|
cl_util
|
cl_util
|
util
|
util
|
(
|
(
|
.cl_fval(cl_fval),
|
.cl_fval(cl_fval),
|
.cl_lval(cl_lval),
|
.cl_lval(cl_lval),
|
.cl_dval(cl_dval),
|
.cl_dval(cl_dval),
|
.cl_data(cl_data),
|
.cl_data(cl_data),
|
.cl_clk(cl_clk),
|
.cl_clk(cl_clk),
|
|
|
.cl_base_format(cl_base_format),
|
.cl_base_format(cl_base_format),
|
.cl_full_format(cl_full_format),
|
.cl_full_format(cl_full_format),
|
|
|
.cl_fval_fall(cl_fval_fall),
|
.cl_fval_fall(cl_fval_fall),
|
.cl_fval_rise(cl_fval_rise),
|
.cl_fval_rise(cl_fval_rise),
|
.cl_lval_fall(cl_lval_fall),
|
.cl_lval_fall(cl_lval_fall),
|
.cl_lval_rise(cl_lval_rise),
|
.cl_lval_rise(cl_lval_rise),
|
.cl_data_en(cl_data_en),
|
.cl_data_en(cl_data_en),
|
|
|
.cl_pixel_counter(cl_pixel_counter),
|
.cl_pixel_counter(cl_pixel_counter),
|
.cl_frame_x(cl_frame_x),
|
.cl_frame_x(cl_frame_x),
|
.cl_frame_y(cl_frame_y),
|
.cl_frame_y(cl_frame_y),
|
|
|
.cl_reset(cl_reset)
|
.cl_reset(cl_reset)
|
);
|
);
|
|
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
//
|
//
|
|
|
task init;
|
task init;
|
input integer fpa_outputs;
|
input integer fpa_outputs;
|
begin
|
begin
|
|
|
cl_base_format = 0;
|
cl_base_format = 0;
|
cl_full_format = 0;
|
cl_full_format = 0;
|
|
|
if( (fpa_outputs == 1) | (fpa_outputs == 2) )
|
if( (fpa_outputs == 1) | (fpa_outputs == 2) )
|
begin
|
begin
|
$display( "-!- %16.t | %m: FPA with %0d outputs. Assuming Base CameraLink Format", $time, fpa_outputs );
|
$display( "-!- %16.t | %m: FPA with %0d outputs. Assuming Base CameraLink Format", $time, fpa_outputs );
|
cl_base_format = 1;
|
cl_base_format = 1;
|
end
|
end
|
else if( (fpa_outputs == 4) | (fpa_outputs == 8) )
|
else if( (fpa_outputs == 4) | (fpa_outputs == 8) )
|
begin
|
begin
|
$display( "-!- %16.t | %m: FPA with %0d outputs. Assuming Full CameraLink Format", $time, fpa_outputs );
|
$display( "-!- %16.t | %m: FPA with %0d outputs. Assuming Full CameraLink Format", $time, fpa_outputs );
|
cl_full_format = 1;
|
cl_full_format = 1;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
$display( "-!- %16.t | %m: FPA with %0d not supported.", $time, fpa_outputs );
|
$display( "-!- %16.t | %m: FPA with %0d not supported.", $time, fpa_outputs );
|
$stop();
|
$stop();
|
end
|
end
|
|
|
end
|
end
|
endtask
|
endtask
|
|
|
task disable_checker;
|
task disable_checker;
|
begin
|
begin
|
|
|
cl_base_format = 0;
|
cl_base_format = 0;
|
cl_full_format = 0;
|
cl_full_format = 0;
|
|
|
end
|
end
|
endtask
|
endtask
|
|
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
//
|
//
|
task checker;
|
task checker;
|
input integer pixel_counter;
|
input integer pixel_counter;
|
begin
|
begin
|
|
|
if( cl_base_format )
|
if( cl_base_format )
|
begin
|
begin
|
if( cl_data[15:0] != pixel_counter )
|
if( cl_data[15:0] != pixel_counter )
|
begin
|
begin
|
log.inc_fail_count;
|
log.inc_fail_count;
|
$display( "-!- %16.t | %m: data error at pixel 0x%4x. Pixel is 0x%4x and should be 0x%4x", $time, pixel_counter, cl_data[15:0], pixel_counter );
|
$display( "-!- %16.t | %m: data error at pixel 0x%4x. Pixel is 0x%4x and should be 0x%4x", $time, pixel_counter, cl_data[15:0], pixel_counter );
|
end
|
end
|
end
|
end
|
else if( cl_full_format )
|
else if( cl_full_format )
|
begin
|
begin
|
if( (cl_data[15:0] != pixel_counter) | (cl_data[31:16] != (pixel_counter + 1)) | (cl_data[47:32] != (pixel_counter + 2)) | (cl_data[63:48] != (pixel_counter + 3)) )
|
if( (cl_data[15:0] != pixel_counter) | (cl_data[31:16] != (pixel_counter + 1)) | (cl_data[47:32] != (pixel_counter + 2)) | (cl_data[63:48] != (pixel_counter + 3)) )
|
begin
|
begin
|
log.inc_fail_count;
|
log.inc_fail_count;
|
$display( "-!- %16.t | %m: data error somewhere between pixel 0x%4x and 0x%4x.", $time, pixel_counter, pixel_counter + 4 );
|
$display( "-!- %16.t | %m: data error somewhere between pixel 0x%4x and 0x%4x.", $time, pixel_counter, pixel_counter + 4 );
|
end
|
end
|
end
|
end
|
|
|
end
|
end
|
endtask
|
endtask
|
|
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
//
|
//
|
always @(negedge cl_clk)
|
always @(negedge cl_clk)
|
if( cl_data_en )
|
if( cl_data_en )
|
checker( cl_pixel_counter );
|
checker( cl_pixel_counter );
|
|
|
|
|
|
|
endmodule
|
endmodule
|
|
|
|
|