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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [camera_link/] [cl_util.v] - Blame information for rev 30

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_util
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_base_format,
15
    input               cl_full_format,
16
 
17
    output              cl_fval_fall,
18
    output              cl_fval_rise,
19
    output              cl_lval_fall,
20
    output              cl_lval_rise,
21
    output              cl_data_en,
22
 
23
    output reg  [13:0]  cl_pixel_counter,
24
    output reg  [15:0]  cl_frame_x,
25
    output reg  [15:0]  cl_frame_y,
26
 
27
    input               cl_reset
28
  );
29
 
30
  // --------------------------------------------------------------------
31
  //
32
  task get_frames;
33
  input integer count;
34
    begin
35
 
36
      repeat(count) @(negedge cl_fval);
37
 
38
      $display( "-!- %16.t | %m: got %0d frames.", $time, count );
39
 
40
   end
41
  endtask
42
 
43
 
44
  // --------------------------------------------------------------------
45
  //  cl_fval & cl_lval edge detector
46
  reg     cl_fval_r;
47
  assign  cl_fval_fall = ~cl_fval & cl_fval_r;
48
  assign  cl_fval_rise = cl_fval & ~cl_fval_r;
49
 
50
  always @(posedge cl_clk)
51
    cl_fval_r <= cl_fval;
52
 
53
  reg     cl_lval_r;
54
  assign  cl_lval_fall = ~cl_lval & cl_lval_r;
55
  assign  cl_lval_rise = cl_lval & ~cl_lval_r;
56
 
57
  always @(posedge cl_clk)
58
    cl_lval_r <= cl_lval;
59
 
60
 
61
  // --------------------------------------------------------------------
62
  //  pixel counter
63
  always @(posedge cl_clk)
64
    if( ~cl_fval | cl_reset | (cl_pixel_counter > 14'h3ff0) )
65
      cl_pixel_counter <= 0;
66
    else if( cl_data_en )
67
      if( cl_base_format )
68
        cl_pixel_counter <= cl_pixel_counter + 1;
69
      else if( cl_full_format )
70
        cl_pixel_counter <= cl_pixel_counter + 4;
71
 
72
 
73
  // --------------------------------------------------------------------
74
  //  frame x coordinate
75
  always @(posedge cl_clk)
76
    if( ~cl_fval | ~cl_lval | cl_reset )
77
      cl_frame_x <= 0;
78
    else if( cl_data_en )
79
      if( cl_base_format )
80
        cl_frame_x <= cl_frame_x + 1;
81
      else if( cl_full_format )
82
        cl_frame_x <= cl_frame_x + 4;
83
 
84
 
85
  // --------------------------------------------------------------------
86
  //  frame y coordinate
87
  always @(posedge cl_clk)
88
    if( ~cl_fval | cl_reset )
89
      cl_frame_y <= 0;
90
    else if( cl_lval_fall )
91
      cl_frame_y <= cl_frame_y + 1;
92
 
93
 
94
  // --------------------------------------------------------------------
95
  //
96
  integer cl_line_width;
97
  integer cl_height;
98
  integer cl_width;
99
 
100
  always @(posedge cl_clk)
101
    if( cl_fval_rise | cl_reset )
102
      cl_line_width <= 0;
103
    else if( cl_lval_fall )
104
      cl_line_width <= cl_frame_x;
105
 
106
  always @(posedge cl_clk)
107
    if( cl_fval_fall )
108
      cl_height <= cl_frame_y;
109
 
110
  always @(posedge cl_clk)
111
    if( cl_fval_fall )
112
      cl_width <= cl_line_width;
113
 
114
  task display_frame_size;
115
    begin
116
 
117
      $display( "-!- %16.t | %m: last frame size was %0dX%0d.", $time, cl_width, cl_height );
118
 
119
   end
120
  endtask
121
 
122
  task validate_frame_size;
123
  input integer width;
124
  input integer height;
125
    begin
126
 
127
      if( (height != cl_height) | (width != cl_width) )
128
        begin
129
          log.inc_fail_count;
130
          $display( "-!- %16.t | %m: last frame size should be %0dX%0d but was %0dX%0d", $time, width, height, cl_width, cl_height );
131
        end
132
 
133
   end
134
  endtask
135
 
136
 
137
  // --------------------------------------------------------------------
138
  //  outputs
139
  assign cl_data_en = cl_dval & cl_lval & cl_fval;
140
 
141
 
142
endmodule
143
 
144
 
145
 

powered by: WebSVN 2.1.0

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