OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [camera_link/] [sim/] [src/] [cl_line_scan_checker.v] - Rev 41

Go to most recent revision | Compare with Previous | Blame | View Log

//////////////////////////////////////////////////////////////////////
////                                                              ////
//// Copyright (C) 2013 Authors and OPENCORES.ORG                 ////
////                                                              ////
//// This source file may be used and distributed without         ////
//// restriction provided that this copyright statement is not    ////
//// removed from the file and that any derivative work contains  ////
//// the original copyright notice and the associated disclaimer. ////
////                                                              ////
//// This source file is free software; you can redistribute it   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any   ////
//// later version.                                               ////
////                                                              ////
//// This source is distributed in the hope that it will be       ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// details.                                                     ////
////                                                              ////
//// You should have received a copy of the GNU Lesser General    ////
//// Public License along with this source; if not, download it   ////
//// from http://www.opencores.org/lgpl.shtml                     ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
 
 
module cl_line_scan_checker
  (
    input               cl_fval,
    input               cl_lval,
    input               cl_dval,
    input       [63:0]  cl_data,
    input               cl_clk,
 
    input               cl_reset
  );
 
  // --------------------------------------------------------------------
  //
  wire [13:0] cl_pixel_counter;
  wire [15:0] cl_frame_x;
  wire [15:0] cl_frame_y;
  wire        cl_fval_fall;
  wire        cl_fval_rise;
  wire        cl_lval_fall;
  wire        cl_lval_rise;
  wire        cl_data_en;
  reg         cl_base_format = 0;
  reg         cl_full_format = 0;
 
  cl_util
    util
    (
      .cl_fval(cl_fval),
      .cl_lval(cl_lval),
      .cl_dval(cl_dval),
      .cl_data(cl_data),
      .cl_clk(cl_clk),
 
      .cl_base_format(cl_base_format),
      .cl_full_format(cl_full_format),
 
      .cl_fval_fall(cl_fval_fall),
      .cl_fval_rise(cl_fval_rise),
      .cl_lval_fall(cl_lval_fall),
      .cl_lval_rise(cl_lval_rise),
      .cl_data_en(cl_data_en),
 
      .cl_pixel_counter(cl_pixel_counter),
      .cl_frame_x(cl_frame_x),
      .cl_frame_y(cl_frame_y),
 
      .cl_reset(cl_reset)
    );
 
 
  // --------------------------------------------------------------------
  //
  reg [15:0]  cl_base_data_lenght;
  reg [15:0]  cl_base_eod_index;
  reg [15:0]  cl_base_id_index;
 
  task init;
  input integer fpa_outputs;
  input reg [15:0]  data_lenght;
  input reg [15:0]  eod_index;
  input reg [15:0]  id_index;
    begin
 
      cl_base_format = 0;
      cl_full_format = 0;
 
      if( (fpa_outputs == 1) | (fpa_outputs == 2) )
        begin
          $display( "-!- %16.t | %m: FPA with %0d outputs. Assuming Base CameraLink Format", $time, fpa_outputs );
          cl_base_format = 1;
        end
      else if( (fpa_outputs == 4) | (fpa_outputs == 8) )
        begin
          $display( "-!- %16.t | %m: FPA with %0d outputs. Assuming Full CameraLink Format", $time, fpa_outputs );
          cl_full_format = 1;
        end
      else
        begin
          $display( "-!- %16.t | %m: FPA with %0d not supported.", $time, fpa_outputs );
          $stop();
        end
 
      cl_base_data_lenght = data_lenght;
      cl_base_eod_index   = eod_index;
      cl_base_id_index    = id_index;
 
    end
  endtask
 
  task disable_checker;
    begin
 
      cl_base_format = 0;
      cl_full_format = 0;
 
    end
  endtask
 
 
  // --------------------------------------------------------------------
  //
  task checker;
  input integer frame_x;
    begin
 
      if( frame_x < cl_base_data_lenght )
        if( cl_data[15:0] != frame_x )
          begin
            log.inc_fail_count;
            $display( "-!- %16.t | %m: data error at pixel %x. Pixel is %x and should be %x", $time, frame_x, cl_data[15:0], frame_x );
          end
      else if((cl_base_eod_index == frame_x) | ( (cl_base_eod_index + 1) == frame_x ))
        if(cl_data[15:0] != FPA_EOD)
          begin
            log.inc_fail_count;
            $display( "-!- %16.t | %m: EOD error at pixel %x.", $time, frame_x );
          end
      else if( cl_base_id_index <= frame_x )
        if( cl_data[15:0] != ( (frame_x - cl_base_id_index) + 16'h0e00 ) )
          begin
            log.inc_fail_count;
            $display( "-!- %16.t | %m: EOD error at pixel %x.", $time, frame_x );
          end
 
   end
  endtask
 
 
  // --------------------------------------------------------------------
  //
  always @(negedge cl_clk)
    if( cl_data_en )
      checker( cl_frame_x );
 
 
 
endmodule
 
 
 
 

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.