URL
https://opencores.org/ocsvn/s80186/s80186/trunk
Subversion Repositories s80186
[/] [s80186/] [trunk/] [fpga/] [VGA/] [FontColorLUT.sv] - Rev 2
Compare with Previous | Blame | View Log
// Copyright Jamie Iles, 2017//// This file is part of s80x86.//// s80x86 is free software: you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation, either version 3 of the License, or// (at your option) any later version.//// s80x86 is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with s80x86. If not, see <http://www.gnu.org/licenses/>.`ifndef FONT_ROM_PATH`define FONT_ROM_PATH "."`endifmodule FontColorLUT(input logic clk,input logic render_cursor,input logic [7:0] glyph,input logic [2:0] glyph_row,input logic [2:0] glyph_col,input logic [3:0] foreground,input logic [3:0] background,output logic [3:0] r,output logic [3:0] g,output logic [3:0] b);// 64 bits per character, 256 characterslogic font_rom[16384];initial $readmemb({{`FONT_ROM_PATH, "/font.bin"}}, font_rom);logic font_bit;wire [13:0] font_mem_addr = {glyph, glyph_row[2:0], glyph_col[2:0]};wire [11:0] foreground_rgb;wire [11:0] background_rgb;reg [11:0] color_lut [0:15] = '{12'h0_0_0, // black12'h0_0_a, // blue12'h0_a_0, // green12'h0_a_a, // cyan12'ha_0_0, // red12'ha_0_a, // magenta12'ha_5_0, // brown12'ha_a_a, // white12'h5_5_5, // gray12'h5_5_f, // bright blue12'h5_f_5, // bright green12'h5_f_f, // bright cyan12'hf_5_5, // bright red12'hf_5_f, // bright magenta12'hf_f_5, // yellow12'hf_f_f // bright white};always_ff @(posedge clk) beginforeground_rgb <= color_lut[foreground];background_rgb <= color_lut[background];endassign {r, g, b} = font_bit ^ render_cursor ? foreground_rgb : background_rgb;always_ff @(posedge clk)font_bit <= font_rom[font_mem_addr];endmodule
