-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdvi_decoder.v
242 lines (209 loc) · 8.15 KB
/
dvi_decoder.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
//////////////////////////////////////////////////////////////////////////////
//
// Xilinx, Inc. 2010 www.xilinx.com
//
// XAPPxxx
//
//////////////////////////////////////////////////////////////////////////////
//
// File name : dvi_decoder.v
//
// Description : Spartan-6 DVI decoder top module
//
//
// Author : Bob Feng
//
// Disclaimer: LIMITED WARRANTY AND DISCLAMER. These designs are
// provided to you "as is". Xilinx and its licensors makeand you
// receive no warranties or conditions, express, implied,
// statutory or otherwise, and Xilinx specificallydisclaims any
// implied warranties of merchantability, non-infringement,or
// fitness for a particular purpose. Xilinx does notwarrant that
// the functions contained in these designs will meet your
// requirements, or that the operation of these designswill be
// uninterrupted or error free, or that defects in theDesigns
// will be corrected. Furthermore, Xilinx does not warrantor
// make any representations regarding use or the results ofthe
// use of the designs in terms of correctness, accuracy,
// reliability, or otherwise.
//
// LIMITATION OF LIABILITY. In no event will Xilinx or its
// licensors be liable for any loss of data, lost profits,cost
// or procurement of substitute goods or services, or forany
// special, incidental, consequential, or indirect damages
// arising from the use or operation of the designs or
// accompanying documentation, however caused and on anytheory
// of liability. This limitation will apply even if Xilinx
// has been advised of the possibility of such damage. This
// limitation shall apply not-withstanding the failure ofthe
// essential purpose of any limited remedies herein.
//
// Copyright © 2004 Xilinx, Inc.
// All rights reserved
//
//////////////////////////////////////////////////////////////////////////////
`timescale 1 ns / 1ps
module dvi_decoder (
input wire tmdsclk_p, // tmds clock
input wire tmdsclk_n, // tmds clock
input wire blue_p, // Blue data in
input wire green_p, // Green data in
input wire red_p, // Red data in
input wire blue_n, // Blue data in
input wire green_n, // Green data in
input wire red_n, // Red data in
input wire exrst, // external reset input, e.g. reset button
output wire reset, // rx reset
output wire pclk, // regenerated pixel clock
output wire pclkx2, // double rate pixel clock
output wire pclkx10, // 10x pixel as IOCLK
output wire pllclk0, // send pllclk0 out so it can be fed into a different BUFPLL
output wire pllclk1, // PLL x1 output
output wire pllclk2, // PLL x2 output
output wire pll_lckd, // send pll_lckd out so it can be fed into a different BUFPLL
output wire serdesstrobe, // BUFPLL serdesstrobe output
output wire tmdsclk, // TMDS cable clock
output wire hsync, // hsync data
output wire vsync, // vsync data
output wire de, // data enable
output wire blue_vld,
output wire green_vld,
output wire red_vld,
output wire blue_rdy,
output wire green_rdy,
output wire red_rdy,
output wire psalgnerr,
output wire [29:0] sdout,
output wire [7:0] red, // pixel data out
output wire [7:0] green, // pixel data out
output wire [7:0] blue); // pixel data out
wire [9:0] sdout_blue, sdout_green, sdout_red;
/*
assign sdout = {sdout_red[9], sdout_green[9], sdout_blue[9], sdout_red[8], sdout_green[8], sdout_blue[8],
sdout_red[7], sdout_green[7], sdout_blue[7], sdout_red[6], sdout_green[6], sdout_blue[6],
sdout_red[5], sdout_green[5], sdout_blue[5], sdout_red[4], sdout_green[4], sdout_blue[4],
sdout_red[3], sdout_green[3], sdout_blue[3], sdout_red[2], sdout_green[2], sdout_blue[2],
sdout_red[1], sdout_green[1], sdout_blue[1], sdout_red[0], sdout_green[0], sdout_blue[0]} ;
*/
assign sdout = {sdout_red[9:5], sdout_green[9:5], sdout_blue[9:5],
sdout_red[4:0], sdout_green[4:0], sdout_blue[4:0]};
wire de_b, de_g, de_r;
assign de = de_b;
//wire blue_vld, green_vld, red_vld;
//wire blue_rdy, green_rdy, red_rdy;
wire blue_psalgnerr, green_psalgnerr, red_psalgnerr;
//
// Send TMDS clock to a differential buffer and then a BUFIO2
// This is a required path in Spartan-6 feed a PLL CLKIN
//
wire rxclkint;
IBUFDS #(.IOSTANDARD("TMDS_33"), .DIFF_TERM("FALSE")
) ibuf_rxclk (.I(tmdsclk_p), .IB(tmdsclk_n), .O(rxclkint));
wire rxclk;
BUFIO2 #(.DIVIDE_BYPASS("TRUE"), .DIVIDE(1))
bufio_tmdsclk (.DIVCLK(rxclk), .IOCLK(), .SERDESSTROBE(), .I(rxclkint));
BUFG tmdsclk_bufg (.I(rxclk), .O(tmdsclk));
//
// PLL is used to generate three clocks:
// 1. pclk: same rate as TMDS clock
// 2. pclkx2: double rate of pclk used for 5:10 soft gear box and ISERDES DIVCLK
// 3. pclkx10: 10x rate of pclk used as IO clock
//
PLL_BASE # (
.CLKIN_PERIOD(10),
.CLKFBOUT_MULT(10), //set VCO to 10x of CLKIN
.CLKOUT0_DIVIDE(1),
.CLKOUT1_DIVIDE(10),
.CLKOUT2_DIVIDE(5),
.COMPENSATION("INTERNAL")
) PLL_ISERDES (
.CLKFBOUT(clkfbout),
.CLKOUT0(pllclk0),
.CLKOUT1(pllclk1),
.CLKOUT2(pllclk2),
.CLKOUT3(),
.CLKOUT4(),
.CLKOUT5(),
.LOCKED(pll_lckd),
.CLKFBIN(clkfbout),
.CLKIN(rxclk),
.RST(exrst)
);
//
// Pixel Rate clock buffer
//
BUFG pclkbufg (.I(pllclk1), .O(pclk));
//////////////////////////////////////////////////////////////////
// 2x pclk is going to be used to drive IOSERDES2 DIVCLK
//////////////////////////////////////////////////////////////////
BUFG pclkx2bufg (.I(pllclk2), .O(pclkx2));
//////////////////////////////////////////////////////////////////
// 10x pclk is used to drive IOCLK network so a bit rate reference
// can be used by IOSERDES2
//////////////////////////////////////////////////////////////////
wire bufpll_lock;
BUFPLL #(.DIVIDE(5)) ioclk_buf (.PLLIN(pllclk0), .GCLK(pclkx2), .LOCKED(pll_lckd),
.IOCLK(pclkx10), .SERDESSTROBE(serdesstrobe), .LOCK(bufpll_lock));
assign reset = ~bufpll_lock;
decode dec_b (
.reset (reset),
.pclk (pclk),
.pclkx2 (pclkx2),
.pclkx10 (pclkx10),
.serdesstrobe (serdesstrobe),
.din_p (blue_p),
.din_n (blue_n),
.other_ch0_rdy(green_rdy),
.other_ch1_rdy(red_rdy),
.other_ch0_vld(green_vld),
.other_ch1_vld(red_vld),
.iamvld (blue_vld),
.iamrdy (blue_rdy),
.psalgnerr (blue_psalgnerr),
.c0 (hsync),
.c1 (vsync),
.de (de_b),
.sdout (sdout_blue),
.dout (blue)) ;
decode dec_g (
.reset (reset),
.pclk (pclk),
.pclkx2 (pclkx2),
.pclkx10 (pclkx10),
.serdesstrobe (serdesstrobe),
.din_p (green_p),
.din_n (green_n),
.other_ch0_rdy(blue_rdy),
.other_ch1_rdy(red_rdy),
.other_ch0_vld(blue_vld),
.other_ch1_vld(red_vld),
.iamvld (green_vld),
.iamrdy (green_rdy),
.psalgnerr (green_psalgnerr),
.c0 (),
.c1 (),
.de (de_g),
.sdout (sdout_green),
.dout (green)) ;
decode dec_r (
.reset (reset),
.pclk (pclk),
.pclkx2 (pclkx2),
.pclkx10 (pclkx10),
.serdesstrobe (serdesstrobe),
.din_p (red_p),
.din_n (red_n),
.other_ch0_rdy(blue_rdy),
.other_ch1_rdy(green_rdy),
.other_ch0_vld(blue_vld),
.other_ch1_vld(green_vld),
.iamvld (red_vld),
.iamrdy (red_rdy),
.psalgnerr (red_psalgnerr),
.c0 (),
.c1 (),
.de (de_r),
.sdout (sdout_red),
.dout (red)) ;
assign psalgnerr = red_psalgnerr | blue_psalgnerr | green_psalgnerr;
endmodule