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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [camera_link/] [cl_line_scan_checker.v] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 qaztronic
//
2
//
3
//
4
 
5
 
6
module cl_line_scan_checker
7
  (
8
    input               cl_fval,
9
    input               cl_lval,
10
    input               cl_dval,
11
    input       [63:0]  cl_data,
12
    input               cl_clk,
13
 
14
    input               cl_reset
15
  );
16
 
17
  // --------------------------------------------------------------------
18
  //
19
  localparam FPA_FS1  = 14'h3fff;
20
  localparam FPA_FS2  = 14'h3ffe;
21
  localparam FPA_LS   = 14'h3ffd;
22
  localparam FPA_HB   = 14'h3ffc;
23
  localparam FPA_VB   = 14'h3ffb;
24
  localparam FPA_BLK  = 14'h3ff3;
25
  localparam FPA_IT   = 14'h3ff2;
26
  localparam FPA_EOD  = 14'h3ff1;
27
 
28
 
29
  // --------------------------------------------------------------------
30
  //
31
  wire [13:0] cl_pixel_counter;
32
  wire [15:0] cl_frame_x;
33
  wire [15:0] cl_frame_y;
34
  wire        cl_fval_fall;
35
  wire        cl_fval_rise;
36
  wire        cl_lval_fall;
37
  wire        cl_lval_rise;
38
  wire        cl_data_en;
39
  reg         cl_base_format = 0;
40
  reg         cl_full_format = 0;
41
 
42
  cl_util
43
    util
44
    (
45
      .cl_fval(cl_fval),
46
      .cl_lval(cl_lval),
47
      .cl_dval(cl_dval),
48
      .cl_data(cl_data),
49
      .cl_clk(cl_clk),
50
 
51
      .cl_base_format(cl_base_format),
52
      .cl_full_format(cl_full_format),
53
 
54
      .cl_fval_fall(cl_fval_fall),
55
      .cl_fval_rise(cl_fval_rise),
56
      .cl_lval_fall(cl_lval_fall),
57
      .cl_lval_rise(cl_lval_rise),
58
      .cl_data_en(cl_data_en),
59
 
60
      .cl_pixel_counter(cl_pixel_counter),
61
      .cl_frame_x(cl_frame_x),
62
      .cl_frame_y(cl_frame_y),
63
 
64
      .cl_reset(cl_reset)
65
    );
66
 
67
 
68
  // --------------------------------------------------------------------
69
  //
70
  reg [15:0]  cl_base_data_lenght;
71
  reg [15:0]  cl_base_eod_index;
72
  reg [15:0]  cl_base_id_index;
73
 
74
  task init;
75
  input integer fpa_outputs;
76
  input reg [15:0]  data_lenght;
77
  input reg [15:0]  eod_index;
78
  input reg [15:0]  id_index;
79
    begin
80
 
81
      cl_base_format = 0;
82
      cl_full_format = 0;
83
 
84
      if( (fpa_outputs == 1) | (fpa_outputs == 2) )
85
        begin
86
          $display( "-!- %16.t | %m: FPA with %0d outputs. Assuming Base CameraLink Format", $time, fpa_outputs );
87
          cl_base_format = 1;
88
        end
89
      else if( (fpa_outputs == 4) | (fpa_outputs == 8) )
90
        begin
91
          $display( "-!- %16.t | %m: FPA with %0d outputs. Assuming Full CameraLink Format", $time, fpa_outputs );
92
          cl_full_format = 1;
93
        end
94
      else
95
        begin
96
          $display( "-!- %16.t | %m: FPA with %0d not supported.", $time, fpa_outputs );
97
          $stop();
98
        end
99
 
100
      cl_base_data_lenght = data_lenght;
101
      cl_base_eod_index   = eod_index;
102
      cl_base_id_index    = id_index;
103
 
104
    end
105
  endtask
106
 
107
  task disable_checker;
108
    begin
109
 
110
      cl_base_format = 0;
111
      cl_full_format = 0;
112
 
113
    end
114
  endtask
115
 
116
 
117
  // --------------------------------------------------------------------
118
  //
119
  task checker;
120
  input integer frame_x;
121
    begin
122
 
123
      if( frame_x < cl_base_data_lenght )
124
        if( cl_data[15:0] != frame_x )
125
          begin
126
            log.inc_fail_count;
127
            $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 );
128
          end
129
      else if((cl_base_eod_index == frame_x) | ( (cl_base_eod_index + 1) == frame_x ))
130
        if(cl_data[15:0] != FPA_EOD)
131
          begin
132
            log.inc_fail_count;
133
            $display( "-!- %16.t | %m: EOD error at pixel %x.", $time, frame_x );
134
          end
135
      else if( cl_base_id_index <= frame_x )
136
        if( cl_data[15:0] != ( (frame_x - cl_base_id_index) + 16'h0e00 ) )
137
          begin
138
            log.inc_fail_count;
139
            $display( "-!- %16.t | %m: EOD error at pixel %x.", $time, frame_x );
140
          end
141
 
142
   end
143
  endtask
144
 
145
 
146
  // --------------------------------------------------------------------
147
  //
148
  always @(negedge cl_clk)
149
    if( cl_data_en )
150
      checker( cl_frame_x );
151
 
152
 
153
 
154
endmodule
155
 
156
 
157
 

powered by: WebSVN 2.1.0

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