8 parameter ROW_BITS = 5,
9 parameter COL_BITS = 7,
10 parameter ADDR_BITS = 11
23 input [COL_BITS-1:0] cursor_x,
24 input [ROW_BITS-1:0] cursor_y,
25 input cursor_blink_on,
27 input [ADDR_BITS-1:0] first_char,
29 output wire [ADDR_BITS-1:0] char_buffer_address,
30 input [7:0] char_buffer_data,
32 output wire [11:0] char_rom_address,
33 input [7:0] char_rom_data,
34 input graphic_mode_state
36 localparam PAST_LAST_ROW = ROWS * COLS;
41 localparam hbits = 10;
42 localparam hpixels = 800;
44 localparam hvisible = 640;
46 localparam hpulse = 96;
50 localparam vlines = 449;
51 localparam vbp = 35 + 8;
52 localparam vvisible = 400 - 16;
53 localparam vfp = 12 + 8;
54 localparam vpulse = 2;
56 localparam hsync_on = 1'b0;
57 localparam vsync_on = 1'b1;
58 localparam hsync_off = ~hsync_on;
59 localparam vsync_off = ~vsync_on;
61 localparam video_on = 1'b1;
62 localparam video_off = ~video_on;
71 reg [hbits-1:0] hc, next_hc;
72 reg [vbits-1:0] vc, next_vc;
74 reg next_hblank, next_vblank, next_hsync, next_vsync;
76 reg [ROW_BITS-1:0] row, next_row;
77 reg [COL_BITS-1:0] col, next_col;
79 reg [2:0] colc, next_colc;
80 reg [3:0] rowc, next_rowc;
82 reg [ADDR_BITS-1:0] char, next_char;
86 assign char_buffer_address = next_char;
90 assign char_rom_address = { char_buffer_data, rowc };
95 always @(posedge clk) begin
109 hblank <= next_hblank;
110 vblank <= next_vblank;
115 if (hc == hpixels) begin
117 next_vc = (vc == vlines)? 0 : vc + 1;
123 next_hsync = (next_hc >= hbp + hvisible + hfp)? hsync_on : hsync_off;
124 next_vsync = (next_vc >= vbp + vvisible + vfp)? vsync_on : vsync_off;
125 next_hblank = (next_hc < hbp || next_hc >= hbp + hvisible);
126 next_vblank = (next_vc < vbp || next_vc >= vbp + vvisible);
132 always @(posedge clk) begin
155 next_char = first_char;
159 else if (next_hblank) begin
168 if (hblank == 0) begin
169 if (rowc == 15) begin
175 if (
char == PAST_LAST_ROW) begin
182 next_char =
char - COLS;
183 next_rowc = rowc + 1;
211 always @(posedge clk) begin
212 if (reset) video <= video_off;
213 else video <= combined_pixel;
218 is_under_cursor = (cursor_x == col) & (cursor_y == row);
219 cursor_pixel = is_under_cursor & cursor_blink_on;
222 char_pixel = char_rom_data[7 - colc];
224 combined_pixel = (next_hblank || next_vblank)?
226 char_pixel ^ cursor_pixel;
module video_generator(input clk, input reset, output reg hsync, output reg vsync, output reg video, output reg hblank, output reg vblank, input[COL_BITS-1:0] cursor_x, input[ROW_BITS-1:0] cursor_y, input cursor_blink_on, input[ADDR_BITS-1:0] first_char, output wire< ADDR_BITS-1:0 > char_buffer_address, input[8] char_buffer_data, output wire< 11:0 > char_rom_address, input[8] char_rom_data, input graphic_mode_state)
80x24 char generator (8x16 char size) & sync generator