2 * Copyright 2018 Jacob Lifshay
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 `timescale 1ns / 100ps
33 output vga_pixel_clock,
41 vga_clock_generator clock_generator(clk, pixel_clock);
43 wire location_generator_hsync;
44 wire location_generator_vsync;
45 wire location_generator_blank;
46 wire [15:0] location_generator_x;
47 wire [15:0] location_generator_y;
48 wire location_generator_xy_in_active;
50 vga_location_generator location_generator(pixel_clock,
51 location_generator_hsync,
52 location_generator_vsync,
53 location_generator_blank,
56 location_generator_xy_in_active);
58 wire [7:0] text_buffer_screen_char;
59 reg text_buffer_hsync;
60 reg text_buffer_vsync;
61 reg text_buffer_blank;
62 reg [15:0] text_buffer_x;
63 reg [15:0] text_buffer_y;
64 reg text_buffer_xy_in_active;
66 initial text_buffer_hsync = 0;
67 initial text_buffer_vsync = 0;
68 initial text_buffer_blank = 0;
69 initial text_buffer_x = 0;
70 initial text_buffer_y = 0;
71 initial text_buffer_xy_in_active = 0;
73 always @(posedge pixel_clock) text_buffer_hsync <= location_generator_hsync;
74 always @(posedge pixel_clock) text_buffer_vsync <= location_generator_vsync;
75 always @(posedge pixel_clock) text_buffer_blank <= location_generator_blank;
76 always @(posedge pixel_clock) text_buffer_x <= location_generator_x;
77 always @(posedge pixel_clock) text_buffer_y <= location_generator_y;
78 always @(posedge pixel_clock) text_buffer_xy_in_active <= location_generator_xy_in_active;
80 vga_text_buffer text_buffer(pixel_clock,
83 location_generator_xy_in_active,
84 text_buffer_screen_char,
90 wire [7:0] font_generator_r;
91 wire [7:0] font_generator_g;
92 wire [7:0] font_generator_b;
94 vga_font_generator font_generator(
98 text_buffer_xy_in_active,
99 text_buffer_screen_char,
104 reg font_generator_hsync;
105 reg font_generator_vsync;
106 reg font_generator_blank;
108 initial font_generator_hsync = 0;
109 initial font_generator_vsync = 0;
110 initial font_generator_blank = 0;
112 always @(posedge pixel_clock) font_generator_hsync <= text_buffer_hsync;
113 always @(posedge pixel_clock) font_generator_vsync <= text_buffer_vsync;
114 always @(posedge pixel_clock) font_generator_blank <= text_buffer_blank;
116 assign vga_pixel_clock = ~pixel_clock;
125 initial output_hsync = 0;
126 initial output_vsync = 0;
127 initial output_blank = 0;
128 initial output_r = 0;
129 initial output_g = 0;
130 initial output_b = 0;
132 always @(posedge pixel_clock) output_hsync = font_generator_hsync;
133 always @(posedge pixel_clock) output_vsync = font_generator_vsync;
134 always @(posedge pixel_clock) output_blank = font_generator_blank;
135 always @(posedge pixel_clock) output_r = font_generator_r;
136 always @(posedge pixel_clock) output_g = font_generator_g;
137 always @(posedge pixel_clock) output_b = font_generator_b;
139 assign vga_r = output_r;
140 assign vga_g = output_g;
141 assign vga_b = output_b;
147 initial final_hsync = 0;
148 initial final_vsync = 0;
149 initial final_blank = 0;
151 always @(posedge pixel_clock) final_hsync = output_hsync;
152 always @(posedge pixel_clock) final_vsync = output_vsync;
153 always @(posedge pixel_clock) final_blank = font_generator_blank;
155 assign vga_hsync = final_hsync;
156 assign vga_vsync = final_vsync;
157 assign vga_blank = font_generator_blank;