§ Код видеоадаптера
Разрешение: 640 x 400
Частота: 69.5 Hz
Опорная частота: 25 Mhz
vt_visible = 400
vt_front = 12,
vt_sync = 2,
vt_back = 35,
vt_whole = 449;
Разрешение: 640 x 480
Частота: 60.0 Hz
Опорная частота: 25 Mhz
vt_visible = 480
vt_front = 10,
vt_sync = 2,
vt_back = 33,
vt_whole = 525;
1module cga
2(
3
4 input wire clock_25,
5
6
7 output reg [3:0] R,
8 output reg [3:0] G,
9 output reg [3:0] B,
10 output wire HS,
11 output wire VS
12);
13
14
15
16
17
18parameter
19 hz_visible = 640, vt_visible = 400,
20 hz_front = 16, vt_front = 12,
21 hz_sync = 96, vt_sync = 2,
22 hz_back = 48, vt_back = 35,
23 hz_whole = 800, vt_whole = 449;
24
25assign HS = x < (hz_back + hz_visible + hz_front);
26assign VS = y >= (vt_back + vt_visible + vt_front);
27
28wire xmax = (x == hz_whole - 1);
29wire ymax = (y == vt_whole - 1);
30reg [10:0] x = 0;
31reg [10:0] y = 0;
32wire [10:0] X = x - hz_back;
33wire [ 9:0] Y = y - vt_back;
34
35
36always @(posedge clock_25) begin
37
38
39 x <= xmax ? 0 : x + 1;
40 y <= xmax ? (ymax ? 0 : y + 1) : y;
41
42
43 if (x >= hz_back && x < hz_visible + hz_back &&
44 y >= vt_back && y < vt_visible + vt_back)
45 begin
46 {R, G, B} <= 12'hFFF;
47 end
48 else {R, G, B} <= 12'h000;
49
50end
51
52endmodule
§ Верхний уровень
1cga CGA
2(
3 .clock_25 (clock_25),
4 .R (VGA_R),
5 .G (VGA_G),
6 .B (VGA_B),
7 .HS (VGA_HS),
8 .VS (VGA_VS),
9);