Rev 498 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
134 | ddp | 1 | `include "../include/tune.v" |
2 | |||
323 | lvd | 3 | // PentEvo project (c) NedoPC 2010-2011 |
134 | ddp | 4 | // |
5 | // generates horizontal vga sync, double the rate of TV horizontal sync |
||
6 | |||
323 | lvd | 7 | module video_vga_sync_h( |
134 | ddp | 8 | |
323 | lvd | 9 | input wire clk, |
134 | ddp | 10 | |
11 | output reg vga_hsync, |
||
12 | |||
323 | lvd | 13 | output reg scanout_start, |
134 | ddp | 14 | |
15 | input wire hsync_start |
||
16 | ); |
||
17 | |||
18 | localparam HSYNC_END = 10'd106; |
||
498 | ddp | 19 | localparam SCANOUT_BEG = 10'd156; |
134 | ddp | 20 | |
21 | localparam HPERIOD = 10'd896; |
||
22 | |||
23 | |||
323 | lvd | 24 | |
134 | ddp | 25 | reg [9:0] hcount; |
26 | |||
27 | initial |
||
28 | begin |
||
29 | hcount = 9'd0; |
||
30 | vga_hsync = 1'b0; |
||
31 | end |
||
32 | |||
33 | |||
34 | |||
35 | always @(posedge clk) |
||
36 | begin |
||
37 | if( hsync_start ) |
||
38 | hcount <= 10'd2; |
||
39 | else if ( hcount==(HPERIOD-9'd1) ) |
||
40 | hcount <= 10'd0; |
||
41 | else |
||
42 | hcount <= hcount + 9'd1; |
||
43 | end |
||
44 | |||
45 | |||
46 | always @(posedge clk) |
||
47 | begin |
||
48 | if( !hcount ) |
||
49 | vga_hsync <= 1'b1; |
||
50 | else if( hcount==HSYNC_END ) |
||
51 | vga_hsync <= 1'b0; |
||
52 | end |
||
53 | |||
54 | |||
55 | always @(posedge clk) |
||
56 | begin |
||
57 | if( hcount==SCANOUT_BEG ) |
||
58 | scanout_start <= 1'b1; |
||
59 | else |
||
60 | scanout_start <= 1'b0; |
||
61 | end |
||
62 | |||
63 | |||
64 | endmodule |
||
65 |