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

Subversion Repositories numbert_sort_device

[/] [numbert_sort_device/] [trunk/] [utility/] [VGA_Ctrl.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 leshabiruk
module  VGA_Ctrl        (       //      Host Side
2
                                                iRed,
3
                                                iGreen,
4
                                                iBlue,
5
                                                oCurrent_X,
6
                                                oCurrent_Y,
7
                                                //      VGA Side
8
                                                oVGA_R,
9
                                                oVGA_G,
10
                                                oVGA_B,
11
                                                oVGA_HS,
12
                                                oVGA_VS,
13
                                                oVGA_SYNC,
14
                                                oVGA_BLANK,
15
                                                oVGA_CLOCK,
16
                                                //      Control Signal
17
                                                iCLK,
18
                                                iRST_N,
19
 
20
                                                les_btn );
21
input wire les_btn;
22
//      Host Side
23
input           [9:0]    iRed;
24
input           [9:0]    iGreen;
25
input           [9:0]    iBlue;
26
output          [10:0]   oCurrent_X;
27
output          [10:0]   oCurrent_Y;
28
//      VGA Side
29
output          [9:0]    oVGA_R;
30
output          [9:0]    oVGA_G;
31
output          [9:0]    oVGA_B;
32
output  reg                     oVGA_HS;
33
output  reg                     oVGA_VS;
34
output                          oVGA_SYNC;
35
output                          oVGA_BLANK;
36
output                          oVGA_CLOCK;
37
//      Control Signal
38
input                           iCLK;
39
input                           iRST_N;
40
//      Internal Registers
41
reg                     [10:0]   H_Cont;
42
reg                     [10:0]   V_Cont;
43
////////////////////////////////////////////////////////////
44
 
45
//      Horizontal      Parameter
46
parameter       H_FRONT =       16;
47
parameter       H_SYNC  =       96;
48
parameter       H_BACK  =       48;
49
parameter       H_ACT   =       640;
50
//      Vertical Parameter
51
parameter       V_FRONT =       10;
52
parameter       V_SYNC  =       2;
53
parameter       V_BACK  =       33;
54
parameter       V_ACT   =       480;
55
////////////////////////////////////////////////////////////
56
parameter       H_BLANK =       H_FRONT+H_SYNC+H_BACK;
57
parameter       H_TOTAL =       H_FRONT+H_SYNC+H_BACK+H_ACT;
58
parameter       V_BLANK =       V_FRONT+V_SYNC+V_BACK;
59
parameter       V_TOTAL =       V_FRONT+V_SYNC+V_BACK+V_ACT;
60
////////////////////////////////////////////////////////////
61
assign  oVGA_SYNC       =       1'b1;                   //      This pin is unused.
62
assign  oVGA_BLANK      =       ~((H_Cont<H_BLANK)||(V_Cont<V_BLANK));
63
assign  oVGA_CLOCK      =       ~iCLK;
64
assign  oVGA_R          =       (oCurrent_X > 0) ?       iRed : 0 ;
65
assign  oVGA_G          =       (oCurrent_X > 0) ?       iGreen : 0 ;
66
assign  oVGA_B          =       (oCurrent_X > 0) ?       iBlue : 0 ;
67
 
68
assign  oCurrent_X      =       (H_Cont>=H_BLANK)       ?       H_Cont-H_BLANK  :       11'h0   ;
69
assign  oCurrent_Y      =       (V_Cont>=V_BLANK)       ?       V_Cont-V_BLANK  :       11'h0   ;
70
 
71
//reg [9:0] V_ACT;
72
//reg [9:0] V_TOTAL;
73
 
74
reg [7:0] btn_cnt;
75
 
76
always@(posedge les_btn)
77
begin
78
        btn_cnt= btn_cnt +8'h1;
79
end
80
 
81
//      Horizontal Generator: Refer to the pixel clock
82
always@(posedge iCLK or negedge iRST_N)
83
begin
84
        if(!iRST_N)
85
        begin
86
                H_Cont          <=      0;
87
                oVGA_HS         <=      1;
88
//              V_ACT   <=      480 +btn_cnt;
89
        //      V_TOTAL =       V_FRONT+V_SYNC+V_BACK+V_ACT;
90
        end
91
        else
92
        begin
93
//              if(H_Cont<H_TOTAL)
94
                if(H_Cont<H_TOTAL-1)
95
                H_Cont  <=      H_Cont+1'b1;
96
                else
97
                H_Cont  <=      0;
98
                //      Horizontal Sync
99
                if(H_Cont==H_FRONT-1)                   //      Front porch end
100
                oVGA_HS <=      1'b0;
101
                else if(H_Cont==H_FRONT+H_SYNC-1)       //      Sync pulse end
102
                oVGA_HS <=      1'b1;
103
        end
104
end
105
 
106
//      Vertical Generator: Refer to the horizontal sync
107
always@(posedge oVGA_HS or negedge iRST_N)
108
begin
109
        if(!iRST_N)
110
        begin
111
                V_Cont          <=      0;
112
                oVGA_VS         <=      1;
113
        end
114
        else
115
        begin
116
//              if(V_Cont<V_TOTAL)
117
                if(V_Cont<V_TOTAL-1)
118
                        V_Cont  <=      V_Cont+1'b1;
119
                else
120
                        V_Cont  <=      0;
121
                //      Vertical Sync
122
                if(V_Cont==V_FRONT-1)                   //      Front porch end
123
                        oVGA_VS <=      1'b0;
124
                if(V_Cont==V_FRONT+V_SYNC-1)    //      Sync pulse end
125
                        oVGA_VS <=      1'b1;
126
        end
127
end
128
 
129
 
130
endmodule

powered by: WebSVN 2.1.0

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