-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vga.v
executable file
·103 lines (89 loc) · 2.4 KB
/
Vga.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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 18:44:07 10/25/2019
// Design Name:
// Module Name: Vga
// Project Name:
// Target Devices:
// Tool versions:
// Description: Vga sync singal and the pixel's balayage position producer
// Need improvement, should add a port called valid to informe the modules succeed
// And resolve all the out of scream probleme in this module
//
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module Vga(
input reset,
input enable,
input clk,
output reg Hsync,
output reg Vsync,
output [10:0] Hpos,
output [10:0] Vpos
);
wire carry;
wire NoUsed;
reg [1:0] divid;
localparam HsyncPulseTime=800;
//localparam HsyncPulseTime=10;
localparam HDisplayTime=640;
localparam HVSpulseWidth=96;
//localparam HVSpulseWidth=2;
localparam HVSfrontPorch=16;
localparam HVSbackPorch=48;
localparam VsyncPulseTime=521;
//localparam VsyncPulseTime=10;
localparam VDisplayTime=480;
localparam VVSpulseWidth=2;
localparam VVSfrontPorch=10;
localparam VVSbackPorch=29;
/*Counter #(.UPPER(HsyncPulseTime)) HsyncCnt(.clk(clk),.reset(reset),.enable(enable),.cnt(Hpos),.carry(carry));
//Counter #(.UPPER(HsyncPulseTime*2)) Vsub(.clk(clk),.reset(reset),.enable(enable),.cnt(),.carry(carry));
Counter #(.UPPER(VsyncPulseTime)) VsyncCnt(.clk(clk),.reset(reset),.enable(carry),.cnt(Vpos),.carry());
*/
reg [10:0] regHCnt;
reg [10:0] regVCnt;
assign Vpos=regVCnt;
assign Hpos=regHCnt;
always@(posedge enable)begin
if(reset)
regHCnt<=0;
else if(regHCnt == HsyncPulseTime-1)
regHCnt<=0;
else
regHCnt<=regHCnt+1;
end
always@(posedge enable)begin
if(reset)
regVCnt<=0;
else if(regVCnt == VsyncPulseTime-1)
regVCnt<=0;
else if(regHCnt == HsyncPulseTime-1)
regVCnt<=regVCnt+1;
else
regVCnt<=regVCnt;
end
/* assign Hsync = (regHCnt < HVSpulseWidth) ? 1'b0: 1'b1;
assign Vsync = (regVCnt < VVSpulseWidth) ? 1'b0:1'b1;*/
always@(*) begin
if (Hpos<HVSpulseWidth)
Hsync=0;
else
Hsync=1;
end
always@(*) begin
if (Vpos<VVSpulseWidth)
Vsync=0;
else
Vsync=1;
end
endmodule