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] - 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_line_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
  wire [13:0] cl_pixel_counter;
43
  wire [15:0] cl_frame_x;
44
  wire [15:0] cl_frame_y;
45
  wire        cl_fval_fall;
46
  wire        cl_fval_rise;
47
  wire        cl_lval_fall;
48
  wire        cl_lval_rise;
49
  wire        cl_data_en;
50
  reg         cl_base_format = 0;
51
  reg         cl_full_format = 0;
52
 
53
  cl_util
54
    util
55
    (
56
      .cl_fval(cl_fval),
57
      .cl_lval(cl_lval),
58
      .cl_dval(cl_dval),
59
      .cl_data(cl_data),
60
      .cl_clk(cl_clk),
61
 
62
      .cl_base_format(cl_base_format),
63
      .cl_full_format(cl_full_format),
64
 
65
      .cl_fval_fall(cl_fval_fall),
66
      .cl_fval_rise(cl_fval_rise),
67
      .cl_lval_fall(cl_lval_fall),
68
      .cl_lval_rise(cl_lval_rise),
69
      .cl_data_en(cl_data_en),
70
 
71
      .cl_pixel_counter(cl_pixel_counter),
72
      .cl_frame_x(cl_frame_x),
73
      .cl_frame_y(cl_frame_y),
74
 
75
      .cl_reset(cl_reset)
76
    );
77
 
78
 
79
  // --------------------------------------------------------------------
80
  //
81
  reg [15:0]  cl_base_data_lenght;
82
  reg [15:0]  cl_base_eod_index;
83
  reg [15:0]  cl_base_id_index;
84
 
85
  task init;
86
  input integer fpa_outputs;
87
  input reg [15:0]  data_lenght;
88
  input reg [15:0]  eod_index;
89
  input reg [15:0]  id_index;
90
    begin
91
 
92
      cl_base_format = 0;
93
      cl_full_format = 0;
94
 
95
      if( (fpa_outputs == 1) | (fpa_outputs == 2) )
96
        begin
97
          $display( "-!- %16.t | %m: FPA with %0d outputs. Assuming Base CameraLink Format", $time, fpa_outputs );
98
          cl_base_format = 1;
99
        end
100
      else if( (fpa_outputs == 4) | (fpa_outputs == 8) )
101
        begin
102
          $display( "-!- %16.t | %m: FPA with %0d outputs. Assuming Full CameraLink Format", $time, fpa_outputs );
103
          cl_full_format = 1;
104
        end
105
      else
106
        begin
107
          $display( "-!- %16.t | %m: FPA with %0d not supported.", $time, fpa_outputs );
108
          $stop();
109
        end
110
 
111
      cl_base_data_lenght = data_lenght;
112
      cl_base_eod_index   = eod_index;
113
      cl_base_id_index    = id_index;
114
 
115
    end
116
  endtask
117
 
118
  task disable_checker;
119
    begin
120
 
121
      cl_base_format = 0;
122
      cl_full_format = 0;
123
 
124
    end
125
  endtask
126
 
127
 
128
  // --------------------------------------------------------------------
129
  //
130
  task checker;
131
  input integer frame_x;
132
    begin
133
 
134
      if( frame_x < cl_base_data_lenght )
135
        if( cl_data[15:0] != frame_x )
136
          begin
137
            log.inc_fail_count;
138
            $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 );
139
          end
140
      else if((cl_base_eod_index == frame_x) | ( (cl_base_eod_index + 1) == frame_x ))
141
        if(cl_data[15:0] != FPA_EOD)
142
          begin
143
            log.inc_fail_count;
144
            $display( "-!- %16.t | %m: EOD error at pixel %x.", $time, frame_x );
145
          end
146
      else if( cl_base_id_index <= frame_x )
147
        if( cl_data[15:0] != ( (frame_x - cl_base_id_index) + 16'h0e00 ) )
148
          begin
149
            log.inc_fail_count;
150
            $display( "-!- %16.t | %m: EOD error at pixel %x.", $time, frame_x );
151
          end
152
 
153
   end
154
  endtask
155
 
156
 
157
  // --------------------------------------------------------------------
158
  //
159
  always @(negedge cl_clk)
160
    if( cl_data_en )
161
      checker( cl_frame_x );
162
 
163
 
164
 
165
endmodule
166
 
167
 
168
 

powered by: WebSVN 2.1.0

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