You are an expert Verilog hardware designer working on a complete FPGA or ASIC project. You are given the full source code of a Verilog project. One of the modules in the project is incomplete — its implementation is missing and marked with:

// >>> Module Implementation Begin

// <<< Module Implementation End

Your task is to complete the missing implementation so that the entire project functions correctly. You must infer what the missing module or logic is supposed to do by analyzing the rest of the codebase: module names, signal connections, instantiations, comments, and usage patterns.

Follow these rules:

1. Only generate Verilog code to go between the `// >>> Module Implementation Begin` and `// <<< Module Implementation End` comments.
2. Use Verilog-2001 syntax. Ensure the code is synthesizable.
3. Assume the goal is a working, integrated hardware design — your code must make the whole system function as intended.
4. Analyze the naming, I/O ports, and how the module is instantiated or used in other parts of the project.
5. Implement correct behavior based on design context. Do not guess randomly — reason it out.
6. Avoid vendor-specific features unless explicitly required.
7. Do not output comments, explanation, or anything outside the required code region unless explicitly asked.

Your output should contain **only the Verilog code** that fits inside the marked region.

/*
 * Copyright (c) 2024-2025 James Ross
 * SPDX-License-Identifier: Apache-2.0
 */

`default_nettype none

module tt_um_vga_glyph_mode(
	input  wire [7:0] ui_in,    // Dedicated inputs
	output wire [7:0] uo_out,   // Dedicated outputs
	input  wire [7:0] uio_in,   // IOs: Input path
	output wire [7:0] uio_out,  // IOs: Output path
	output wire [7:0] uio_oe,   // IOs: Enable path (active high: 0=input, 1=output)
	input  wire       ena,      // always 1 when the design is powered, so you can ignore it
	input  wire       clk,      // clock
	input  wire       rst_n     // reset_n - low to reset
);

	// VGA signals
	wire hsync, vsync, display_on;
	wire [10:0] hpos;
	wire [9:0] vpos;

	// TinyVGA PMOD
	assign uo_out = {hsync, RGB[0], RGB[2], RGB[4], vsync, RGB[1], RGB[3], RGB[5]};

	// Unused outputs assigned to 0.
	assign uio_out = 0;
	assign uio_oe  = 0;

	wire [7:0] xb = hpos[10:3];
	wire [6:0] x_mix = {xb[7] ^ xb[3], xb[1], xb[4], xb[1], xb[6], xb[0], xb[2]};
	wire [2:0] g_x = hpos[2:0];
	wire [5:0] yb;
	wire [3:0] _unused;
	assign {_unused, yb} = vpos / 10'd12;
	wire [5:0] g_unused;
	wire [3:0] g_y;
	assign {g_unused, g_y} = vpos - {yb, 3'b000} - {1'b0, yb, 2'b00};
	wire hl;

	// Suppress unused signals warning
	wire _unused_ok = &{ena, ui_in[5:2], uio_in};

	reg [9:0] frame;
	reg rst_drop;

	// VGA output
	hvsync_generator hvsync_gen(
		.clk(clk),
		.reset(~rst_n),
		.mode(ui_in[7:6]),
		.hsync(hsync),
		.vsync(vsync),
		.display_on(display_on),
		.hpos(hpos),
		.vpos(vpos)
	);

	// glyphs
	glyphs_rom glyphs(
		.c(glyph_index),
		.y(g_y),
		.x(g_x),
		.pixel(hl)
	);

	// palette
	wire [5:0] color;
	palette_rom palettes(
		.cid(y),
		.pid(ui_in[1:0]),
		.color(color)
	);

	// there are 51 glyphs
	wire [5:0] glyph_index = {xb[2] ^ yb[0], xb[0] ^ yb[1], xb[1] ^ yb[2], xb[4] ^ yb[3], xb[3] ^ yb[4]} // [0,31]
		+ {1'b0, xb[5] ^ yb[5], xb[6] ^ yb[0], xb[0] ^ yb[1], xb[1] ^ yb[2]} // [0,15]
		+ {1'b0, x[6:3]} // [0,15]
		+ {1'b0, t & frame[7], t & frame[6], t & frame[5], t & frame[4] & s}; // [0,15]

	wire [1:0] a = xb[1:0];
	wire [3:0] b = xb[5:2];
	wire [2:0] d = xb[3:2] + 2'd3;

	wire t = &{xb[0] ^ yb[2] ^ frame[7], xb[1] ^ yb[1] ^ frame[8], xb[2] ^ yb[3] ^ frame[9], xb[3] ^ yb[0]}; // toggle glyph

	// column features
	wire s = ^xb[6:0]; // speed of rain
	wire n = xb[1] ^ xb[3] ^ xb[5]; // lit on or off

	wire [6:0] v = (s ? frame[8:2] : frame[9:3]) - yb - x_mix;
	wire [3:0] c = {1'b0, a} + d;
	wire [6:0] e = {3'b000, b} << c;
	wire [6:0] f = v & e;
	wire [6:0] x = v >> a;
	wire [2:0] y = ~x[2:0];
	wire [9:0] drop = {1'b0, yb, 3'd0} >> s;
	wire drop_bit = ({3'd0, x_mix} + drop > frame) & ~rst_drop;
	wire [5:0] glyph_color = {6{drop_bit}} ^ color;

	wire [5:0] z = (&(~v[2:0]) & &(y)) ? 6'd63 : glyph_color;

	wire [5:0] RGB = (display_on & hl & ~(|f | n | drop_bit)) ? z : 6'd0;

	always @(posedge vsync, negedge rst_n) begin
		if (~rst_n) begin
			rst_drop <= 0;
			frame <= 0;
		end else begin
			if (&frame) begin
				rst_drop <= 1;
			end
			frame <= frame + 1;
		end
	end

endmodule


/*
 * Copyright (c) 2025 James Ross
 * SPDX-License-Identifier: Apache-2.0
 */

`default_nettype none

module palette_rom(
	input  wire [2:0] cid, // color id
	input  wire [1:0] pid, // palette
	output wire [5:0] color
);
// >>> Module Implementation Begin

// <<< Module Implementation End
endmodule




/*
 * Copyright (c) 2025 James Ross
 * SPDX-License-Identifier: Apache-2.0
 */

`default_nettype none

module glyphs_rom(
	input  wire [5:0] c,
	input  wire [3:0] y,
	input  wire [2:0] x,
	output wire pixel
);
	localparam N = 54;
	reg [7:0] g[N-1:0][11:0];
	assign pixel = g[(c<N)?c:c-N][y][x];
	initial begin
		g[ 0][ 0] = 8'b00000000;
		g[ 0][ 1] = 8'b11011000;
		g[ 0][ 2] = 8'b11011000;
		g[ 0][ 3] = 8'b11011000;
		g[ 0][ 4] = 8'b11011000;
		g[ 0][ 5] = 8'b11001100;
		g[ 0][ 6] = 8'b11001100;
		g[ 0][ 7] = 8'b11001100;
		g[ 0][ 8] = 8'b10000110;
		g[ 0][ 9] = 8'b10000110;
		g[ 0][10] = 8'b10000110;
		g[ 0][11] = 8'b00000110;
		g[ 1][ 0] = 8'b00000000;
		g[ 1][ 1] = 8'b00000000;
		g[ 1][ 2] = 8'b00000000;
		g[ 1][ 3] = 8'b00000000;
		g[ 1][ 4] = 8'b00000000;
		g[ 1][ 5] = 8'b00000000;
		g[ 1][ 6] = 8'b00000000;
		g[ 1][ 7] = 8'b00000000;
		g[ 1][ 8] = 8'b00000000;
		g[ 1][ 9] = 8'b00000000;
		g[ 1][10] = 8'b00000000;
		g[ 1][11] = 8'b11101110;
		g[ 2][ 0] = 8'b00000000;
		g[ 2][ 1] = 8'b11000000;
		g[ 2][ 2] = 8'b11000000;
		g[ 2][ 3] = 8'b11111110;
		g[ 2][ 4] = 8'b11111110;
		g[ 2][ 5] = 8'b11000000;
		g[ 2][ 6] = 8'b11000000;
		g[ 2][ 7] = 8'b11000000;
		g[ 2][ 8] = 8'b11000000;
		g[ 2][ 9] = 8'b11100000;
		g[ 2][10] = 8'b01111110;
		g[ 2][11] = 8'b00111110;
		g[ 3][ 0] = 8'b00000000;
		g[ 3][ 1] = 8'b00110000;
		g[ 3][ 2] = 8'b00111000;
		g[ 3][ 3] = 8'b00111000;
		g[ 3][ 4] = 8'b00110000;
		g[ 3][ 5] = 8'b00110000;
		g[ 3][ 6] = 8'b00110000;
		g[ 3][ 7] = 8'b00110000;
		g[ 3][ 8] = 8'b00110000;
		g[ 3][ 9] = 8'b00110000;
		g[ 3][10] = 8'b00110000;
		g[ 3][11] = 8'b00110000;
		g[ 4][ 0] = 8'b00000000;
		g[ 4][ 1] = 8'b11110000;
		g[ 4][ 2] = 8'b11110000;
		g[ 4][ 3] = 8'b00000010;
		g[ 4][ 4] = 8'b11110010;
		g[ 4][ 5] = 8'b11110010;
		g[ 4][ 6] = 8'b00000110;
		g[ 4][ 7] = 8'b00000100;
		g[ 4][ 8] = 8'b00001100;
		g[ 4][ 9] = 8'b00011100;
		g[ 4][10] = 8'b11111000;
		g[ 4][11] = 8'b11110000;
		g[ 5][ 0] = 8'b00000000;
		g[ 5][ 1] = 8'b00000000;
		g[ 5][ 2] = 8'b00000000;
		g[ 5][ 3] = 8'b01111100;
		g[ 5][ 4] = 8'b01111100;
		g[ 5][ 5] = 8'b00000000;
		g[ 5][ 6] = 8'b00000000;
		g[ 5][ 7] = 8'b01111100;
		g[ 5][ 8] = 8'b01111100;
		g[ 5][ 9] = 8'b00000000;
		g[ 5][10] = 8'b00000000;
		g[ 5][11] = 8'b00000000;
		g[ 6][ 0] = 8'b00000000;
		g[ 6][ 1] = 8'b10100110;
		g[ 6][ 2] = 8'b10100110;
		g[ 6][ 3] = 8'b10110110;
		g[ 6][ 4] = 8'b11010110;
		g[ 6][ 5] = 8'b01010110;
		g[ 6][ 6] = 8'b00000110;
		g[ 6][ 7] = 8'b00001100;
		g[ 6][ 8] = 8'b00001100;
		g[ 6][ 9] = 8'b00001100;
		g[ 6][10] = 8'b00011000;
		g[ 6][11] = 8'b01111000;
		g[ 7][ 0] = 8'b00000000;
		g[ 7][ 1] = 8'b01111100;
		g[ 7][ 2] = 8'b11000010;
		g[ 7][ 3] = 8'b11000000;
		g[ 7][ 4] = 8'b11000000;
		g[ 7][ 5] = 8'b11000000;
		g[ 7][ 6] = 8'b01100000;
		g[ 7][ 7] = 8'b00111000;
		g[ 7][ 8] = 8'b00110000;
		g[ 7][ 9] = 8'b01100000;
		g[ 7][10] = 8'b11000000;
		g[ 7][11] = 8'b11111110;
		g[ 8][ 0] = 8'b00000000;
		g[ 8][ 1] = 8'b00110000;
		g[ 8][ 2] = 8'b00110000;
		g[ 8][ 3] = 8'b11111110;
		g[ 8][ 4] = 8'b11000110;
		g[ 8][ 5] = 8'b11000110;
		g[ 8][ 6] = 8'b00000110;
		g[ 8][ 7] = 8'b00000110;
		g[ 8][ 8] = 8'b00000110;
		g[ 8][ 9] = 8'b00001100;
		g[ 8][10] = 8'b00011000;
		g[ 8][11] = 8'b01110000;
		g[ 9][ 0] = 8'b00000000;
		g[ 9][ 1] = 8'b00011000;
		g[ 9][ 2] = 8'b00011000;
		g[ 9][ 3] = 8'b11111110;
		g[ 9][ 4] = 8'b11111110;
		g[ 9][ 5] = 8'b00011000;
		g[ 9][ 6] = 8'b00011000;
		g[ 9][ 7] = 8'b00011000;
		g[ 9][ 8] = 8'b00111000;
		g[ 9][ 9] = 8'b01110000;
		g[ 9][10] = 8'b11000000;
		g[ 9][11] = 8'b00000000;
		g[10][ 0] = 8'b00000000;
		g[10][ 1] = 8'b11100000;
		g[10][ 2] = 8'b00111000;
		g[10][ 3] = 8'b00001110;
		g[10][ 4] = 8'b00000000;
		g[10][ 5] = 8'b11100000;
		g[10][ 6] = 8'b00111000;
		g[10][ 7] = 8'b00001110;
		g[10][ 8] = 8'b00000000;
		g[10][ 9] = 8'b11100000;
		g[10][10] = 8'b00111000;
		g[10][11] = 8'b00001110;
		g[11][ 0] = 8'b00000000;
		g[11][ 1] = 8'b01111100;
		g[11][ 2] = 8'b11000110;
		g[11][ 3] = 8'b11000110;
		g[11][ 4] = 8'b11000110;
		g[11][ 5] = 8'b11000110;
		g[11][ 6] = 8'b01111100;
		g[11][ 7] = 8'b11000110;
		g[11][ 8] = 8'b11000110;
		g[11][ 9] = 8'b11000110;
		g[11][10] = 8'b11000110;
		g[11][11] = 8'b01111100;
		g[12][ 0] = 8'b00000000;
		g[12][ 1] = 8'b11111110;
		g[12][ 2] = 8'b01100000;
		g[12][ 3] = 8'b01100000;
		g[12][ 4] = 8'b11111110;
		g[12][ 5] = 8'b01100000;
		g[12][ 6] = 8'b01100000;
		g[12][ 7] = 8'b01100000;
		g[12][ 8] = 8'b01100000;
		g[12][ 9] = 8'b01110000;
		g[12][10] = 8'b00111110;
		g[12][11] = 8'b00011110;
		g[13][ 0] = 8'b00000000;
		g[13][ 1] = 8'b00000000;
		g[13][ 2] = 8'b01101100;
		g[13][ 3] = 8'b01101100;
		g[13][ 4] = 8'b11111110;
		g[13][ 5] = 8'b11111110;
		g[13][ 6] = 8'b01101100;
		g[13][ 7] = 8'b01101100;
		g[13][ 8] = 8'b00001100;
		g[13][ 9] = 8'b00001100;
		g[13][10] = 8'b00011000;
		g[13][11] = 8'b01110000;
		g[14][ 0] = 8'b00000000;
		g[14][ 1] = 8'b00000000;
		g[14][ 2] = 8'b11111110;
		g[14][ 3] = 8'b11000110;
		g[14][ 4] = 8'b11000110;
		g[14][ 5] = 8'b00000110;
		g[14][ 6] = 8'b00000110;
		g[14][ 7] = 8'b00000110;
		g[14][ 8] = 8'b00000110;
		g[14][ 9] = 8'b00001100;
		g[14][10] = 8'b00011000;
		g[14][11] = 8'b01110000;
		g[15][ 0] = 8'b00000000;
		g[15][ 1] = 8'b00000000;
		g[15][ 2] = 8'b01100000;
		g[15][ 3] = 8'b00110000;
		g[15][ 4] = 8'b00011000;
		g[15][ 5] = 8'b00001100;
		g[15][ 6] = 8'b00001100;
		g[15][ 7] = 8'b00011000;
		g[15][ 8] = 8'b00110000;
		g[15][ 9] = 8'b01100000;
		g[15][10] = 8'b00000000;
		g[15][11] = 8'b00000000;
		g[16][ 0] = 8'b00000000;
		g[16][ 1] = 8'b00001100;
		g[16][ 2] = 8'b00001100;
		g[16][ 3] = 8'b11111110;
		g[16][ 4] = 8'b11111110;
		g[16][ 5] = 8'b00001100;
		g[16][ 6] = 8'b00011100;
		g[16][ 7] = 8'b00011100;
		g[16][ 8] = 8'b00111100;
		g[16][ 9] = 8'b00101100;
		g[16][10] = 8'b01101100;
		g[16][11] = 8'b01001100;
		g[17][ 0] = 8'b00000000;
		g[17][ 1] = 8'b00011000;
		g[17][ 2] = 8'b00011000;
		g[17][ 3] = 8'b00011000;
		g[17][ 4] = 8'b00011000;
		g[17][ 5] = 8'b00011000;
		g[17][ 6] = 8'b00011000;
		g[17][ 7] = 8'b00011000;
		g[17][ 8] = 8'b00011000;
		g[17][ 9] = 8'b00011000;
		g[17][10] = 8'b00011000;
		g[17][11] = 8'b00011000;
		g[18][ 0] = 8'b00000000;
		g[18][ 1] = 8'b00000000;
		g[18][ 2] = 8'b11000110;
		g[18][ 3] = 8'b11000110;
		g[18][ 4] = 8'b11000110;
		g[18][ 5] = 8'b11000110;
		g[18][ 6] = 8'b11000110;
		g[18][ 7] = 8'b00000110;
		g[18][ 8] = 8'b00000110;
		g[18][ 9] = 8'b00001100;
		g[18][10] = 8'b00011000;
		g[18][11] = 8'b01110000;
		g[19][ 0] = 8'b00000000;
		g[19][ 1] = 8'b11000000;
		g[19][ 2] = 8'b11100000;
		g[19][ 3] = 8'b11110000;
		g[19][ 4] = 8'b11011000;
		g[19][ 5] = 8'b11001100;
		g[19][ 6] = 8'b11000110;
		g[19][ 7] = 8'b11000110;
		g[19][ 8] = 8'b11111110;
		g[19][ 9] = 8'b11000000;
		g[19][10] = 8'b11000000;
		g[19][11] = 8'b11111110;
		g[20][ 0] = 8'b00000000;
		g[20][ 1] = 8'b00110000;
		g[20][ 2] = 8'b11111110;
		g[20][ 3] = 8'b11111110;
		g[20][ 4] = 8'b00110000;
		g[20][ 5] = 8'b00110000;
		g[20][ 6] = 8'b10110100;
		g[20][ 7] = 8'b10110100;
		g[20][ 8] = 8'b10110100;
		g[20][ 9] = 8'b10110110;
		g[20][10] = 8'b10110010;
		g[20][11] = 8'b00011000;
		g[21][ 0] = 8'b00000000;
		g[21][ 1] = 8'b11111110;
		g[21][ 2] = 8'b11000000;
		g[21][ 3] = 8'b11000000;
		g[21][ 4] = 8'b11111000;
		g[21][ 5] = 8'b11111100;
		g[21][ 6] = 8'b00001110;
		g[21][ 7] = 8'b00000110;
		g[21][ 8] = 8'b00000110;
		g[21][ 9] = 8'b00000110;
		g[21][10] = 8'b10000110;
		g[21][11] = 8'b01111100;
		g[22][ 0] = 8'b00000000;
		g[22][ 1] = 8'b00000000;
		g[22][ 2] = 8'b01111110;
		g[22][ 3] = 8'b00111100;
		g[22][ 4] = 8'b00000110;
		g[22][ 5] = 8'b00000110;
		g[22][ 6] = 8'b00110110;
		g[22][ 7] = 8'b00110110;
		g[22][ 8] = 8'b00111100;
		g[22][ 9] = 8'b00111000;
		g[22][10] = 8'b01100000;
		g[22][11] = 8'b01000000;
		g[23][ 0] = 8'b00000000;
		g[23][ 1] = 8'b11111110;
		g[23][ 2] = 8'b11000000;
		g[23][ 3] = 8'b11000000;
		g[23][ 4] = 8'b01100000;
		g[23][ 5] = 8'b01100000;
		g[23][ 6] = 8'b00110000;
		g[23][ 7] = 8'b00110000;
		g[23][ 8] = 8'b00011000;
		g[23][ 9] = 8'b00011000;
		g[23][10] = 8'b00011000;
		g[23][11] = 8'b00011000;
		g[24][ 0] = 8'b00000000;
		g[24][ 1] = 8'b00000000;
		g[24][ 2] = 8'b01100000;
		g[24][ 3] = 8'b11111110;
		g[24][ 4] = 8'b11111110;
		g[24][ 5] = 8'b00110000;
		g[24][ 6] = 8'b00110000;
		g[24][ 7] = 8'b11111110;
		g[24][ 8] = 8'b11111110;
		g[24][ 9] = 8'b00011000;
		g[24][10] = 8'b00011000;
		g[24][11] = 8'b00011000;
		g[25][ 0] = 8'b00000000;
		g[25][ 1] = 8'b00000000;
		g[25][ 2] = 8'b00000000;
		g[25][ 3] = 8'b00110000;
		g[25][ 4] = 8'b00110000;
		g[25][ 5] = 8'b00110000;
		g[25][ 6] = 8'b01101100;
		g[25][ 7] = 8'b01101100;
		g[25][ 8] = 8'b01100110;
		g[25][ 9] = 8'b11001110;
		g[25][10] = 8'b11011010;
		g[25][11] = 8'b11110010;
		g[26][ 0] = 8'b00000000;
		g[26][ 1] = 8'b00000000;
		g[26][ 2] = 8'b00000000;
		g[26][ 3] = 8'b00011000;
		g[26][ 4] = 8'b00011000;
		g[26][ 5] = 8'b00000000;
		g[26][ 6] = 8'b00000000;
		g[26][ 7] = 8'b00000000;
		g[26][ 8] = 8'b00000000;
		g[26][ 9] = 8'b00011000;
		g[26][10] = 8'b00011000;
		g[26][11] = 8'b00000000;
		g[27][ 0] = 8'b00000000;
		g[27][ 1] = 8'b00000000;
		g[27][ 2] = 8'b01111110;
		g[27][ 3] = 8'b00000000;
		g[27][ 4] = 8'b00000000;
		g[27][ 5] = 8'b01111110;
		g[27][ 6] = 8'b00011000;
		g[27][ 7] = 8'b00011000;
		g[27][ 8] = 8'b00011000;
		g[27][ 9] = 8'b00011000;
		g[27][10] = 8'b00110000;
		g[27][11] = 8'b01100000;
		g[28][ 0] = 8'b00000000;
		g[28][ 1] = 8'b00000000;
		g[28][ 2] = 8'b00010000;
		g[28][ 3] = 8'b00010000;
		g[28][ 4] = 8'b00010000;
		g[28][ 5] = 8'b11111110;
		g[28][ 6] = 8'b00010000;
		g[28][ 7] = 8'b00010000;
		g[28][ 8] = 8'b00010000;
		g[28][ 9] = 8'b00000000;
		g[28][10] = 8'b00000000;
		g[28][11] = 8'b00000000;
		g[29][ 0] = 8'b00000000;
		g[29][ 1] = 8'b00110000;
		g[29][ 2] = 8'b00110000;
		g[29][ 3] = 8'b01111110;
		g[29][ 4] = 8'b01111110;
		g[29][ 5] = 8'b11011000;
		g[29][ 6] = 8'b10011000;
		g[29][ 7] = 8'b00011000;
		g[29][ 8] = 8'b00011000;
		g[29][ 9] = 8'b00011000;
		g[29][10] = 8'b00110000;
		g[29][11] = 8'b11100000;
		g[30][ 0] = 8'b00000000;
		g[30][ 1] = 8'b01111100;
		g[30][ 2] = 8'b11000110;
		g[30][ 3] = 8'b11100110;
		g[30][ 4] = 8'b11100110;
		g[30][ 5] = 8'b11110110;
		g[30][ 6] = 8'b11010110;
		g[30][ 7] = 8'b11011110;
		g[30][ 8] = 8'b11001110;
		g[30][ 9] = 8'b11001110;
		g[30][10] = 8'b11000110;
		g[30][11] = 8'b01111100;
		g[31][ 0] = 8'b00000000;
		g[31][ 1] = 8'b00000000;
		g[31][ 2] = 8'b00001100;
		g[31][ 3] = 8'b00001100;
		g[31][ 4] = 8'b01001100;
		g[31][ 5] = 8'b01101100;
		g[31][ 6] = 8'b00111100;
		g[31][ 7] = 8'b00011100;
		g[31][ 8] = 8'b00011110;
		g[31][ 9] = 8'b00011010;
		g[31][10] = 8'b00110000;
		g[31][11] = 8'b01100000;
		g[32][ 0] = 8'b00000000;
		g[32][ 1] = 8'b00000000;
		g[32][ 2] = 8'b01100000;
		g[32][ 3] = 8'b11111110;
		g[32][ 4] = 8'b11111110;
		g[32][ 5] = 8'b01100110;
		g[32][ 6] = 8'b01100110;
		g[32][ 7] = 8'b01100110;
		g[32][ 8] = 8'b01100110;
		g[32][ 9] = 8'b01100110;
		g[32][10] = 8'b01000110;
		g[32][11] = 8'b10011100;
		g[33][ 0] = 8'b00000000;
		g[33][ 1] = 8'b01111100;
		g[33][ 2] = 8'b10001110;
		g[33][ 3] = 8'b00000110;
		g[33][ 4] = 8'b00000110;
		g[33][ 5] = 8'b00000110;
		g[33][ 6] = 8'b00001100;
		g[33][ 7] = 8'b00011000;
		g[33][ 8] = 8'b00110000;
		g[33][ 9] = 8'b01100000;
		g[33][10] = 8'b11000000;
		g[33][11] = 8'b11111110;
		g[34][ 0] = 8'b00000000;
		g[34][ 1] = 8'b00000000;
		g[34][ 2] = 8'b01111110;
		g[34][ 3] = 8'b01111110;
		g[34][ 4] = 8'b00000000;
		g[34][ 5] = 8'b11111110;
		g[34][ 6] = 8'b11111110;
		g[34][ 7] = 8'b00000110;
		g[34][ 8] = 8'b00000110;
		g[34][ 9] = 8'b00001110;
		g[34][10] = 8'b00011100;
		g[34][11] = 8'b01111000;
		g[35][ 0] = 8'b00000000;
		g[35][ 1] = 8'b00000000;
		g[35][ 2] = 8'b00010000;
		g[35][ 3] = 8'b11010110;
		g[35][ 4] = 8'b01111100;
		g[35][ 5] = 8'b00111000;
		g[35][ 6] = 8'b01111100;
		g[35][ 7] = 8'b11010110;
		g[35][ 8] = 8'b00010000;
		g[35][ 9] = 8'b00000000;
		g[35][10] = 8'b00000000;
		g[35][11] = 8'b00000000;
		g[36][ 0] = 8'b00000000;
		g[36][ 1] = 8'b01100000;
		g[36][ 2] = 8'b01100000;
		g[36][ 3] = 8'b11111110;
		g[36][ 4] = 8'b11111110;
		g[36][ 5] = 8'b01100110;
		g[36][ 6] = 8'b01100110;
		g[36][ 7] = 8'b01100110;
		g[36][ 8] = 8'b01101100;
		g[36][ 9] = 8'b01100000;
		g[36][10] = 8'b01111110;
		g[36][11] = 8'b00111110;
		g[37][ 0] = 8'b00000000;
		g[37][ 1] = 8'b00110000;
		g[37][ 2] = 8'b11111110;
		g[37][ 3] = 8'b11111110;
		g[37][ 4] = 8'b00000110;
		g[37][ 5] = 8'b00000110;
		g[37][ 6] = 8'b00000110;
		g[37][ 7] = 8'b00001100;
		g[37][ 8] = 8'b00111100;
		g[37][ 9] = 8'b11110110;
		g[37][10] = 8'b00110010;
		g[37][11] = 8'b00110000;
		g[38][ 0] = 8'b00000000;
		g[38][ 1] = 8'b01111100;
		g[38][ 2] = 8'b11000110;
		g[38][ 3] = 8'b11000110;
		g[38][ 4] = 8'b11000110;
		g[38][ 5] = 8'b11000110;
		g[38][ 6] = 8'b11001110;
		g[38][ 7] = 8'b01110110;
		g[38][ 8] = 8'b00000110;
		g[38][ 9] = 8'b00000110;
		g[38][10] = 8'b00001100;
		g[38][11] = 8'b01111000;
		g[39][ 0] = 8'b00000000;
		g[39][ 1] = 8'b00000000;
		g[39][ 2] = 8'b01111100;
		g[39][ 3] = 8'b01111100;
		g[39][ 4] = 8'b00001100;
		g[39][ 5] = 8'b00001100;
		g[39][ 6] = 8'b00011000;
		g[39][ 7] = 8'b00011000;
		g[39][ 8] = 8'b00110000;
		g[39][ 9] = 8'b00111000;
		g[39][10] = 8'b01101100;
		g[39][11] = 8'b11000110;
		g[40][ 0] = 8'b00000000;
		g[40][ 1] = 8'b01111110;
		g[40][ 2] = 8'b01111110;
		g[40][ 3] = 8'b01100110;
		g[40][ 4] = 8'b11000110;
		g[40][ 5] = 8'b10000110;
		g[40][ 6] = 8'b00100110;
		g[40][ 7] = 8'b00111110;
		g[40][ 8] = 8'b00011100;
		g[40][ 9] = 8'b00111000;
		g[40][10] = 8'b01110000;
		g[40][11] = 8'b11100000;
		g[41][ 0] = 8'b00000000;
		g[41][ 1] = 8'b00000000;
		g[41][ 2] = 8'b00000000;
		g[41][ 3] = 8'b00000000;
		g[41][ 4] = 8'b00000000;
		g[41][ 5] = 8'b00000000;
		g[41][ 6] = 8'b00000000;
		g[41][ 7] = 8'b00000000;
		g[41][ 8] = 8'b00000000;
		g[41][ 9] = 8'b00011000;
		g[41][10] = 8'b00011000;
		g[41][11] = 8'b00000000;
		g[42][ 0] = 8'b00000000;
		g[42][ 1] = 8'b11111110;
		g[42][ 2] = 8'b11111110;
		g[42][ 3] = 8'b00000110;
		g[42][ 4] = 8'b00000110;
		g[42][ 5] = 8'b01000110;
		g[42][ 6] = 8'b01101110;
		g[42][ 7] = 8'b00111100;
		g[42][ 8] = 8'b00011000;
		g[42][ 9] = 8'b00111100;
		g[42][10] = 8'b01100110;
		g[42][11] = 8'b11000000;
		g[43][ 0] = 8'b00000000;
		g[43][ 1] = 8'b00000000;
		g[43][ 2] = 8'b11111110;
		g[43][ 3] = 8'b11000000;
		g[43][ 4] = 8'b11000000;
		g[43][ 5] = 8'b01100000;
		g[43][ 6] = 8'b00110000;
		g[43][ 7] = 8'b00011000;
		g[43][ 8] = 8'b00001100;
		g[43][ 9] = 8'b00000110;
		g[43][10] = 8'b00000110;
		g[43][11] = 8'b11111110;
		g[44][ 0] = 8'b00000000;
		g[44][ 1] = 8'b00000000;
		g[44][ 2] = 8'b00000000;
		g[44][ 3] = 8'b11001100;
		g[44][ 4] = 8'b11001100;
		g[44][ 5] = 8'b11101110;
		g[44][ 6] = 8'b01100110;
		g[44][ 7] = 8'b01100110;
		g[44][ 8] = 8'b01100110;
		g[44][ 9] = 8'b00000000;
		g[44][10] = 8'b00000000;
		g[44][11] = 8'b00000000;
		g[45][ 0] = 8'b00000000;
		g[45][ 1] = 8'b00000000;
		g[45][ 2] = 8'b00001100;
		g[45][ 3] = 8'b00011000;
		g[45][ 4] = 8'b00110000;
		g[45][ 5] = 8'b01100000;
		g[45][ 6] = 8'b01100000;
		g[45][ 7] = 8'b00110000;
		g[45][ 8] = 8'b00011000;
		g[45][ 9] = 8'b00001100;
		g[45][10] = 8'b00000000;
		g[45][11] = 8'b00000000;
		g[46][ 0] = 8'b00000000;
		g[46][ 1] = 8'b00011000;
		g[46][ 2] = 8'b00011000;
		g[46][ 3] = 8'b00011000;
		g[46][ 4] = 8'b00011000;
		g[46][ 5] = 8'b00000000;
		g[46][ 6] = 8'b00000000;
		g[46][ 7] = 8'b00011000;
		g[46][ 8] = 8'b00011000;
		g[46][ 9] = 8'b00011000;
		g[46][10] = 8'b00011000;
		g[46][11] = 8'b00011000;
		g[47][ 0] = 8'b00000000;
		g[47][ 1] = 8'b01111110;
		g[47][ 2] = 8'b01111110;
		g[47][ 3] = 8'b00000110;
		g[47][ 4] = 8'b00000110;
		g[47][ 5] = 8'b00000110;
		g[47][ 6] = 8'b00000110;
		g[47][ 7] = 8'b00000110;
		g[47][ 8] = 8'b00000110;
		g[47][ 9] = 8'b11111110;
		g[47][10] = 8'b11111110;
		g[47][11] = 8'b00000000;
		g[48][ 0] = 8'b00000000;
		g[48][ 1] = 8'b11111110;
		g[48][ 2] = 8'b11111110;
		g[48][ 3] = 8'b11000110;
		g[48][ 4] = 8'b11000110;
		g[48][ 5] = 8'b11000110;
		g[48][ 6] = 8'b11111110;
		g[48][ 7] = 8'b11000110;
		g[48][ 8] = 8'b11000110;
		g[48][ 9] = 8'b11000110;
		g[48][10] = 8'b11111110;
		g[48][11] = 8'b11111110;
		g[49][ 0] = 8'b00000000;
		g[49][ 1] = 8'b01111110;
		g[49][ 2] = 8'b01111110;
		g[49][ 3] = 8'b00011000;
		g[49][ 4] = 8'b00011000;
		g[49][ 5] = 8'b00011000;
		g[49][ 6] = 8'b00011000;
		g[49][ 7] = 8'b00011000;
		g[49][ 8] = 8'b00011000;
		g[49][ 9] = 8'b00011000;
		g[49][10] = 8'b01111110;
		g[49][11] = 8'b01111110;
		g[50][ 0] = 8'b00000000;
		g[50][ 1] = 8'b00000000;
		g[50][ 2] = 8'b00000000;
		g[50][ 3] = 8'b11111110;
		g[50][ 4] = 8'b11111110;
		g[50][ 5] = 8'b00000000;
		g[50][ 6] = 8'b00000000;
		g[50][ 7] = 8'b11111110;
		g[50][ 8] = 8'b11111110;
		g[50][ 9] = 8'b00000000;
		g[50][10] = 8'b00000000;
		g[50][11] = 8'b00000000;
		g[51][ 0] = 8'b00000000;
		g[51][ 1] = 8'b00000000;
		g[51][ 2] = 8'b00000000;
		g[51][ 3] = 8'b00000000;
		g[51][ 4] = 8'b00000000;
		g[51][ 5] = 8'b11111110;
		g[51][ 6] = 8'b11111110;
		g[51][ 7] = 8'b00000000;
		g[51][ 8] = 8'b00000000;
		g[51][ 9] = 8'b00000000;
		g[51][10] = 8'b00000000;
		g[51][11] = 8'b00000000;
		g[52][ 0] = 8'b00000000;
		g[52][ 1] = 8'b00000000;
		g[52][ 2] = 8'b11111110;
		g[52][ 3] = 8'b00100000;
		g[52][ 4] = 8'b00111110;
		g[52][ 5] = 8'b00111100;
		g[52][ 6] = 8'b01101100;
		g[52][ 7] = 8'b11001100;
		g[52][ 8] = 8'b00001100;
		g[52][ 9] = 8'b00001100;
		g[52][10] = 8'b00011000;
		g[52][11] = 8'b01110000;
		g[53][ 0] = 8'b00000000;
		g[53][ 1] = 8'b00000000;
		g[53][ 2] = 8'b00000000;
		g[53][ 3] = 8'b00000000;
		g[53][ 4] = 8'b00000000;
		g[53][ 5] = 8'b00000000;
		g[53][ 6] = 8'b00000000;
		g[53][ 7] = 8'b00000000;
		g[53][ 8] = 8'b00000000;
		g[53][ 9] = 8'b00000000;
		g[53][10] = 8'b00000000;
		g[53][11] = 8'b00000000;
	end
endmodule


// Video sync generator, used to drive a VGA monitor.
// Timing from: http://www.tinyvga.com/vga-timing
// To use:
//  - Wire the hsync and vsync signals to top level outputs
//  - Add a 3-bit (or more) "rgb" output to the top level

parameter integer NM = 4; // number of modes
// [0] VGA  640 x 480 @ 60 fps (25.175 MHz)
// [1] VGA  768 x 576 @ 60 fps (34.96  MHz)
// [2] VGA  800 x 600 @ 60 fps (40.0   MHz)
// [3] VGA 1024 x 768 @ 60 fps (65.0   MHz)
//--------[ Bit width ] ----- Mode------      [3]      [2]      [1]      [0]
parameter [11*NM-1:0] H_ACTIVE_PIXELS = {11'd1024, 11'd800, 11'd768, 11'd640}; // horizontal display width
parameter [10*NM-1:0] H_FRONT_PORCH   = {10'd  24, 10'd 40, 10'd 24, 10'd 16}; // horizontal right border
parameter [10*NM-1:0] H_SYNC_WIDTH    = {10'd 136, 10'd128, 10'd 80, 10'd 96}; // horizontal sync width
parameter [10*NM-1:0] H_BACK_PORCH    = {10'd 160, 10'd 88, 10'd104, 10'd 48}; // horizontal left border
parameter [   NM-1:0] H_SYNC          = { 1'b   0,  1'b  1,  1'b  0,  1'b  0}; // 0 (-), 1 (+)
parameter [10*NM-1:0] V_ACTIVE_LINES  = {10'd 768, 10'd600, 10'd576, 10'd480}; // vertical display height
parameter [10*NM-1:0] V_FRONT_PORCH   = {10'd   3, 10'd  1, 10'd  1, 10'd 10}; // vertical bottom border
parameter [10*NM-1:0] V_SYNC_HEIGHT   = {10'd   6, 10'd  4, 10'd  3, 10'd  2}; // vertical sync # lines
parameter [10*NM-1:0] V_BACK_PORCH    = {10'd  29, 10'd 23, 10'd 17, 10'd 33}; // vertical top border
parameter [   NM-1:0] V_SYNC          = { 1'b   0,  1'b  1,  1'b  1,  1'b  0}; // 0 (-), 1 (+)

module hvsync_generator(clk, reset, mode, hsync, vsync, display_on, hpos, vpos);

	input wire clk;
	input wire reset;
	input wire [1:0] mode;
	output reg hsync, vsync;
	output wire display_on;

	// derived constants
	wire [10:0] h_sync_start = H_ACTIVE_PIXELS[11*mode+:11] + H_FRONT_PORCH[10*mode+:10];
	wire [10:0] h_sync_end   = h_sync_start + H_SYNC_WIDTH[10*mode+:10] - 11'd1;
	wire [10:0] h_max        = h_sync_end + H_BACK_PORCH[10*mode+:10];
	wire [ 9:0] v_sync_start = V_ACTIVE_LINES[10*mode+:10] + V_FRONT_PORCH[10*mode+:10];
	wire [ 9:0] v_sync_end   = v_sync_start + V_SYNC_HEIGHT[10*mode+:10] - 10'd1;
	wire [ 9:0] v_max        = v_sync_end + V_BACK_PORCH[10*mode+:10];

	output reg [10:0] hpos; // horizontal position counter
	output reg [ 9:0] vpos; // vertical position counter

	wire hmaxxed = (hpos == h_max) || reset; // set when hpos is maximum
	wire vmaxxed = (vpos == v_max) || reset; // set when vpos is maximum
	wire hactive = (hpos >= h_sync_start) && (hpos <= h_sync_end);
	wire vactive = (vpos >= v_sync_start) && (vpos <= v_sync_end);

	always @(posedge clk)
	begin
		hsync <= hactive ^ ~H_SYNC[mode];
		hpos <= hmaxxed ? 0 : hpos + 1;
		vsync <= vactive ^ ~V_SYNC[mode];
		vpos <= hmaxxed ? (vmaxxed ? 0 : vpos + 1) : vpos;
	end

	// display_on is set when beam is in "safe" visible frame
	assign display_on = (hpos < H_ACTIVE_PIXELS[11*mode+:11]) && (vpos < V_ACTIVE_LINES[10*mode+:10]);

endmodule


Reference solution:
rtl/generated.v: 	// color palette (RRGGBB)
	reg [5:0] palette[3:0][7:0];
	assign color = palette[pid][cid];
	initial begin
		palette[0][0] = 6'b000000; // green (default)
		palette[0][1] = 6'b000100;
		palette[0][2] = 6'b001000;
		palette[0][3] = 6'b001100;
		palette[0][4] = 6'b001101;
		palette[0][5] = 6'b011101;
		palette[0][6] = 6'b011110;
		palette[0][7] = 6'b101110;
		palette[1][0] = 6'b000000; // red
		palette[1][1] = 6'b010000;
		palette[1][2] = 6'b100000;
		palette[1][3] = 6'b110000;
		palette[1][4] = 6'b110001;
		palette[1][5] = 6'b110101;
		palette[1][6] = 6'b110110;
		palette[1][7] = 6'b111010;
		palette[2][0] = 6'b000000; // blue
		palette[2][1] = 6'b000001;
		palette[2][2] = 6'b000010;
		palette[2][3] = 6'b000011;
		palette[2][4] = 6'b000111;
		palette[2][5] = 6'b010111;
		palette[2][6] = 6'b011011;
		palette[2][7] = 6'b101011;
		palette[3][0] = 6'b000000; // pride
		palette[3][1] = 6'b110000;
		palette[3][2] = 6'b111000;
		palette[3][3] = 6'b111100;
		palette[3][4] = 6'b001000;
		palette[3][5] = 6'b000111;
		palette[3][6] = 6'b100010;
		palette[3][7] = 6'b110011;
	end