|
2#
樓主 |
發表於 2009-6-11 12:43:50
|
只看該作者
ODDR2 #(8 I0 `" f. U$ v; r# q: i
.DDR_ALIGNMENT("NONE"), // Sets output alignment to "NONE", "C0" or "C1"
: J* s& ?9 k. k! @8 s) K2 t .INIT(1'b0), // Sets initial state of the Q output to 1'b0 or 1'b1- t) y3 c2 r4 b, i" Y
.SRTYPE("SYNC") // Specifies "SYNC" or "ASYNC" set/reset
9 m% l+ ~7 c4 p; c4 i! N ) ODDR2_inst (
3 o- p9 X2 p+ i/ I( C7 W& \/ ] .Q(oVGA_CLOCK), // 1-bit DDR output data
2 [* T+ m8 ~) p5 z) } .C0(clk), // 1-bit clock input
, Y. N, {* L. v .C1(~clk), // 1-bit clock input
" i, Q5 Q8 R" U- t9 T .CE(1'b1), // 1-bit clock enable input
4 f* [0 u* s: Y .D0(1'b0), // 1-bit data input (associated with C0)# G! v' ?7 t- {5 q8 {
.D1(1'b1), // 1-bit data input (associated with C1). V4 Q p0 |$ H) E. f. k9 B8 m
.R(1'b0), // 1-bit reset input' h+ C3 Z# Q. i/ x6 j( y; ?
.S(1'b0) // 1-bit set input
4 J a2 ]2 C! ~: c. @$ n );
' p- M- [7 Q9 N8 u- k% O
# s9 w k! [8 k! [) u' g' q qalways @(posedge clk)* [' w+ |2 j3 g3 t/ F) N S8 v
begin% N: C5 K4 O0 U* n* _
oVGA_SYNC <= oRequest;" I7 g' Q. t, P8 B( t. J# V
end
W# t! H+ f7 N% k' @5 S3 j
4 j& F! V- g8 F" L: Ealways @(posedge clk)) G6 l0 H* W1 T( D5 P& S' h- `+ W
begin
( @& ?* B$ D' o" x9 Z# H) P if (rst)7 b! K# R6 w, P6 \ \
oRequest <= 1'b0;
2 ]9 W! L `- q2 T! y" _& J else begin# C, @8 k& r3 i/ t- g0 l* o
if (h_cnt >= (X_START-2) && h_cnt< (X_START+H_SYNC_ACT-2) && v_cnt>=Y_START && v_cnt<(Y_START+V_SYNC_ACT))
$ t# z" l7 i* e1 E; r3 H8 o! g2 O! k: X oRequest <= 1'b1;: B( ^# a& V& H1 k/ [
else, G* e$ `; g s0 l( p, K, p
oRequest <= 1'b0;- D+ U; _% @9 C- g" h9 h* @
end1 z' g( q# K, R1 e2 G
end+ |9 X2 L7 p- ]5 @: G6 L' F* {( r
3 Z$ O+ Q6 q7 p1 q
// H_Sync Generator, Ref. 25.175 MHz Clock
' I* G; `7 l" m% h# h# walways @(posedge clk)% X! q9 k( T- f5 L& i4 [ u( G
begin
- n7 z8 C( k8 t7 e5 F if (rst) begin2 P/ \, f: P7 c( b- D
h_cnt <= 12'd0;1 Y& x" d0 h# T
oVGA_H_SYNC <= 1'b0;' C6 Z9 c* \$ I2 i# ]; J; p0 h
end9 j0 J% w4 }% G+ p* Q! X0 O4 l
else begin0 z0 e C9 X& F$ X! B
// H_Sync Counter5 P4 O4 f$ ~/ r' y; j
if (h_cnt < (H_SYNC_TOTAL-1) )
' I( ^$ o% `0 A1 b5 Q6 @$ ] h_cnt <= h_cnt + 12'd1;1 ]9 |) ?- u; ?( @9 h* j
else
r& g2 R# _ x) }9 N h_cnt <= 12'd0;/ b* U3 i& A ~' k" |6 M
( Q) e0 e% ^& @$ c3 l
// H_Sync Generator% S" s9 l: x, l% l- ` L2 o* ]
if( h_cnt < H_SYNC_CYC )
4 Q0 Z' ~3 Y5 @7 ?& _) s oVGA_H_SYNC <= 0;) B3 ~' d$ t9 I
else
' ]# M7 w ?: x3 D: c oVGA_H_SYNC <= 1;
$ W* N- O+ z4 S; i" Z" J2 E end
& G; F0 S1 k" t7 A$ }$ gend" g& q# O; z. ~. R- [
V. N& j F! P" L
always @(posedge clk)( P! X* Q/ i2 p' v8 `) u& {' A8 i
begin
; [7 e7 l8 r; Z c2 i% H if (rst) begin
6 S$ d1 [7 x7 Q/ z2 f" s d4 M. n v_cnt <= 12'd0;% \% A8 w% A5 B& o2 Y& n
oVGA_V_SYNC <= 1'b0;
7 h4 Y0 U/ F8 |8 }# [. [6 a* b end
2 k$ j0 T) Y! d0 w else
# s% e& H9 G e' ~" }1 G if (h_cnt == 0 )
/ u+ J0 J+ v) a8 k- K/ D begin! r9 `. T4 n1 k1 W" ^$ V
// V_Sync Counter
9 r* P! q$ G! V% p5 U' Y if (v_cnt < (V_SYNC_TOTAL-1))! m& H2 q1 N) z: L3 v) X. I
v_cnt <= v_cnt + 12'd1;
* F- ^( w1 Q$ J _. q1 b$ Y else9 I2 K- _1 L4 i k: U: J' C
v_cnt <= 12'd0;
% [' Q& e6 y4 D X- z5 {/ Z // V_Sync Generator
5 r3 J' c2 X3 F& ]$ H8 b& L) I( ? if (v_cnt < V_SYNC_CYC)' h' Y) w: p- U8 E4 A
oVGA_V_SYNC <= 1'b0;4 X3 t- z: g7 e$ j/ t* R* D
else
, t- H9 A* _7 B2 z% n oVGA_V_SYNC <= 1'b1;
, Q' w m* `% a/ K end
+ e" G! @( d9 B$ Fend
. M. ], @& Z H' d* S0 Q
, L5 ]. g& B4 B+ C7 Q' a, c! n! H# K( ?7 Z
endmodule |
|