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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [camera_link/] [sim/] [src/] [cl_area_scan_checker.v] - Blame information for rev 27

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2013 Authors and OPENCORES.ORG                 ////
4
////                                                              ////
5
//// This source file may be used and distributed without         ////
6
//// restriction provided that this copyright statement is not    ////
7
//// removed from the file and that any derivative work contains  ////
8
//// the original copyright notice and the associated disclaimer. ////
9
////                                                              ////
10
//// This source file is free software; you can redistribute it   ////
11
//// and/or modify it under the terms of the GNU Lesser General   ////
12
//// Public License as published by the Free Software Foundation; ////
13
//// either version 2.1 of the License, or (at your option) any   ////
14
//// later version.                                               ////
15
////                                                              ////
16
//// This source is distributed in the hope that it will be       ////
17
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
18
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
19
//// PURPOSE.  See the GNU Lesser General Public License for more ////
20
//// details.                                                     ////
21
////                                                              ////
22
//// You should have received a copy of the GNU Lesser General    ////
23
//// Public License along with this source; if not, download it   ////
24
//// from http://www.opencores.org/lgpl.shtml                     ////
25
////                                                              ////
26
//////////////////////////////////////////////////////////////////////
27
 
28
 
29
module cl_area_scan_checker
30
  (
31
    input               cl_fval,
32
    input               cl_lval,
33
    input               cl_dval,
34
    input       [63:0]  cl_data,
35
    input               cl_clk,
36
 
37
    input               cl_reset
38
  );
39
 
40
 
41
  // --------------------------------------------------------------------
42
  //
43
  wire [13:0] cl_pixel_counter;
44
  wire [15:0] cl_frame_x;
45
  wire [15:0] cl_frame_y;
46
  wire        cl_fval_fall;
47
  wire        cl_fval_rise;
48
  wire        cl_lval_fall;
49
  wire        cl_lval_rise;
50
  wire        cl_data_en;
51
  reg         cl_base_format = 0;
52
  reg         cl_full_format = 0;
53
 
54
  cl_util
55
    util
56
    (
57
      .cl_fval(cl_fval),
58
      .cl_lval(cl_lval),
59
      .cl_dval(cl_dval),
60
      .cl_data(cl_data),
61
      .cl_clk(cl_clk),
62
 
63
      .cl_base_format(cl_base_format),
64
      .cl_full_format(cl_full_format),
65
 
66
      .cl_fval_fall(cl_fval_fall),
67
      .cl_fval_rise(cl_fval_rise),
68
      .cl_lval_fall(cl_lval_fall),
69
      .cl_lval_rise(cl_lval_rise),
70
      .cl_data_en(cl_data_en),
71
 
72
      .cl_pixel_counter(cl_pixel_counter),
73
      .cl_frame_x(cl_frame_x),
74
      .cl_frame_y(cl_frame_y),
75
 
76
      .cl_reset(cl_reset)
77
    );
78
 
79
 
80
  // --------------------------------------------------------------------
81
  //
82
 
83
  task init;
84
  input integer fpa_outputs;
85
    begin
86
 
87
      cl_base_format = 0;
88
      cl_full_format = 0;
89
 
90
      if( (fpa_outputs == 1) | (fpa_outputs == 2) )
91
        begin
92
          $display( "-!- %16.t | %m: FPA with %0d outputs. Assuming Base CameraLink Format", $time, fpa_outputs );
93
          cl_base_format = 1;
94
        end
95
      else if( (fpa_outputs == 4) | (fpa_outputs == 8) )
96
        begin
97
          $display( "-!- %16.t | %m: FPA with %0d outputs. Assuming Full CameraLink Format", $time, fpa_outputs );
98
          cl_full_format = 1;
99
        end
100
      else
101
        begin
102
          $display( "-!- %16.t | %m: FPA with %0d not supported.", $time, fpa_outputs );
103
          $stop();
104
        end
105
 
106
    end
107
  endtask
108
 
109
  task disable_checker;
110
    begin
111
 
112
      cl_base_format = 0;
113
      cl_full_format = 0;
114
 
115
    end
116
  endtask
117
 
118
 
119
  // --------------------------------------------------------------------
120
  //
121
  task checker;
122
  input integer pixel_counter;
123
    begin
124
 
125
      if( cl_base_format )
126
        begin
127
          if( cl_data[15:0] != pixel_counter )
128
            begin
129
              log.inc_fail_count;
130
              $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 );
131
            end
132
        end
133
      else if( cl_full_format )
134
        begin
135
          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)) )
136
            begin
137
              log.inc_fail_count;
138
              $display( "-!- %16.t | %m: data error somewhere between pixel 0x%4x and 0x%4x.", $time, pixel_counter, pixel_counter + 4 );
139
            end
140
        end
141
 
142
   end
143
  endtask
144
 
145
 
146
  // --------------------------------------------------------------------
147
  //
148
  always @(negedge cl_clk)
149
    if( cl_data_en )
150
      checker( cl_pixel_counter );
151
 
152
 
153
 
154
endmodule
155
 

powered by: WebSVN 2.1.0

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