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

Subversion Repositories vga_lcd

[/] [vga_lcd/] [trunk/] [bench/] [verilog/] [sync_check.v] - Blame information for rev 62

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 rudi
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  Top Level Test Bench                                       ////
4
////                                                             ////
5
////                                                             ////
6
////  Author: Rudolf Usselmann                                   ////
7
////          rudi@asics.ws                                      ////
8
////                                                             ////
9
////                                                             ////
10
////  Downloaded from: http://www.opencores.org/cores/vga_lcd/   ////
11
////                                                             ////
12
/////////////////////////////////////////////////////////////////////
13
////                                                             ////
14
//// Copyright (C) 2001 Rudolf Usselmann                         ////
15
////                    rudi@asics.ws                            ////
16
////                                                             ////
17
//// This source file may be used and distributed without        ////
18
//// restriction provided that this copyright statement is not   ////
19
//// removed from the file and that any derivative work contains ////
20
//// the original copyright notice and the associated disclaimer.////
21
////                                                             ////
22
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
23
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
24
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
25
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
26
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
27
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
28
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
29
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
30
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
31
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
32
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
33
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
34
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
35
////                                                             ////
36
/////////////////////////////////////////////////////////////////////
37
 
38
//  CVS Log
39
//
40 60 markom
//  $Id: sync_check.v,v 1.5 2003-09-23 13:09:25 markom Exp $
41 16 rudi
//
42 60 markom
//  $Date: 2003-09-23 13:09:25 $
43
//  $Revision: 1.5 $
44
//  $Author: markom $
45 16 rudi
//  $Locker:  $
46
//  $State: Exp $
47
//
48
// Change History:
49
//               $Log: not supported by cvs2svn $
50 60 markom
//               Revision 1.4  2003/05/07 09:45:28  rherveille
51
//               Numerous updates and added checks
52
//
53 52 rherveille
//               Revision 1.3  2003/03/19 12:20:53  rherveille
54
//               Changed timing section in VGA core, changed testbench accordingly.
55
//               Fixed bug in 'timing check' test.
56
//
57 44 rherveille
//               Revision 1.2  2001/11/15 07:04:15  rherveille
58
//               Updated testbench for VGA/LCD Core version 2.0
59 16 rudi
//
60
//
61
//
62 44 rherveille
//
63 52 rherveille
//
64 16 rudi
 
65
`timescale 1ns / 10ps
66 52 rherveille
`include "vga_defines.v"
67 16 rudi
 
68
module sync_check(      pclk, rst, enable, hsync, vsync, csync, blanc,
69
                        hpol, vpol, cpol, bpol,
70
                        thsync, thgdel, thgate, thlen,
71
                        tvsync, tvgdel, tvgate, tvlen);
72
 
73
input           pclk, rst, enable, hsync, vsync, csync, blanc;
74
input           hpol, vpol, cpol, bpol;
75
input   [7:0]    thsync, thgdel;
76
input   [15:0]   thgate, thlen;
77
input   [7:0]    tvsync, tvgdel;
78
input   [15:0]   tvgate, tvlen;
79
 
80
 
81
time            last_htime;
82
reg             hvalid;
83
time            htime;
84
time            hhtime;
85
 
86
time            last_vtime;
87
reg             vvalid;
88
time            vtime;
89
time            vhtime;
90
 
91
wire    [31:0]   htime_exp;
92
wire    [31:0]   hhtime_exp;
93
wire    [31:0]   vtime_exp;
94
wire    [31:0]   vhtime_exp;
95
 
96
wire            hcheck;
97
wire            vcheck;
98
 
99
wire    [31:0]   bh_start;
100
wire    [31:0]   bh_end;
101
wire    [31:0]   bv_start;
102
wire    [31:0]   bv_end;
103
 
104
integer         bdel1;
105
reg             bval1;
106
reg             bval;
107
integer         bdel2;
108
wire            bcheck;
109
 
110 24 rherveille
//initial hvalid=0;
111
//initial vvalid=0;
112
 
113 16 rudi
parameter       clk_time = 40;
114
 
115
assign hcheck = enable;
116
assign vcheck = enable;
117 44 rherveille
assign hhtime_exp = (thsync +1) * clk_time;
118
assign htime_exp  = (thlen +1) * clk_time;
119
assign vhtime_exp = (htime_exp * (tvsync +1));
120
assign vtime_exp  = htime_exp * (tvlen +1);
121 16 rudi
 
122
always @(posedge pclk)
123
        if(!rst | !enable)
124
           begin
125
                hvalid = 0;
126
                vvalid = 0;
127
           end
128
 
129
// Verify HSYNC Timing
130
always @(hsync)
131
   if(hcheck)
132
      begin
133
        if(hsync == ~hpol)
134
           begin
135
                htime = $time - last_htime;
136 24 rherveille
                //if(hvalid)    $display("HSYNC length time: %0t", htime);
137 16 rudi
                if(hvalid & (htime != htime_exp))
138
                        $display("HSYNC length ERROR: Expected: %0d Got: %0d (%0t)",
139
                                htime_exp, htime, $time);
140
                last_htime = $time;
141
                hvalid = 1;
142
           end
143
 
144
        if(hsync == hpol)
145
           begin
146
                hhtime = $time - last_htime;
147 24 rherveille
                //if(hvalid)    $display("HSYNC pulse time: %0t", hhtime);
148 16 rudi
                if(hvalid & (hhtime != hhtime_exp))
149
                        $display("HSYNC Pulse ERROR: Expected: %0d Got: %0d (%0t)",
150
                                hhtime_exp, hhtime, $time);
151
           end
152
      end
153
 
154 24 rherveille
 
155 16 rudi
// Verify VSYNC Timing
156
always @(vsync)
157
   if(vcheck)
158
      begin
159
        if(vsync == ~vpol)
160
           begin
161
                vtime = $time - last_vtime;
162 24 rherveille
                //if(vvalid)    $display("VSYNC length time: %0t", vtime);
163 16 rudi
                if(vvalid & (vtime != vtime_exp))
164
                        $display("VSYNC length ERROR: Expected: %0d Got: %0d (%0t)",
165
                                vtime_exp, vtime, $time);
166
                last_vtime = $time;
167
                vvalid = 1;
168
           end
169
 
170
        if(vsync == vpol)
171
           begin
172
                vhtime = $time - last_vtime;
173 24 rherveille
                //if(vvalid)    $display("VSYNC pulse time: %0t", vhtime);
174 16 rudi
                if(vvalid & (vhtime != vhtime_exp))
175
                        $display("VSYNC Pulse ERROR: Expected: %0d Got: %0d (%0t)",
176
                                vhtime_exp, vhtime, $time);
177
           end
178
      end
179
 
180 60 markom
`ifdef VGA_12BIT_DVI
181
`else
182 16 rudi
// Verify BLANC Timing
183 44 rherveille
//assign bv_start = tvsync   + tvgdel + 2;
184
//assign bv_end   = bv_start + tvgate + 2;
185
 
186
//assign bh_start = thsync   + thgdel + 1;
187
//assign bh_end   = bh_start + thgate + 2;
188
assign bv_start = tvsync   + tvgdel + 1;
189 16 rudi
assign bv_end   = bv_start + tvgate + 2;
190
 
191
assign bh_start = thsync   + thgdel + 1;
192
assign bh_end   = bh_start + thgate + 2;
193
 
194
assign bcheck = enable;
195
 
196
always @(vsync)
197
        if(vsync == ~vpol)
198
                bdel1 = 0;
199
 
200
always @(hsync)
201
        if(hsync == ~hpol)
202
                bdel1 = bdel1 + 1;
203
 
204
always @(bdel1)
205
        bval1 = (bdel1 > bv_start) & (bdel1 < bv_end);
206
 
207
always @(hsync)
208
        if(hsync == ~hpol)
209
                bdel2 = 0;
210
 
211
always @(posedge pclk)
212
        bdel2 = bdel2 + 1;
213
 
214
initial bval = 1;
215
always @(bdel2)
216 24 rherveille
        bval = #1 !(bval1 & (bdel2 > bh_start) & (bdel2 < bh_end));
217 16 rudi
 
218
always @(bval or blanc)
219 24 rherveille
        #0.01
220 16 rudi
        if(enable)
221 52 rherveille
        if(( (blanc ^ bpol) != bval) & bcheck)
222 16 rudi
                $display("BLANK ERROR: Expected: %0d Got: %0d (%0t)",
223
                        bval, (blanc ^ bpol), $time);
224
 
225
// verify CSYNC
226
always @(csync or vsync or hsync)
227
        if(enable)
228
        if( (csync ^ cpol) != ( (vsync ^ vpol) | (hsync ^ hpol) ) )
229
                $display("CSYNC ERROR: Expected: %0d Got: %0d (%0t)",
230
                ( (vsync ^ vpol) | (hsync ^ hpol) ), (csync ^ cpol), $time);
231 60 markom
`endif
232 16 rudi
 
233
endmodule
234
 

powered by: WebSVN 2.1.0

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