OpenCores
URL https://opencores.org/ocsvn/s80186/s80186/trunk

Subversion Repositories s80186

[/] [s80186/] [trunk/] [fpga/] [VGA/] [FontColorLUT.sv] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jamieiles
// Copyright Jamie Iles, 2017
2
//
3
// This file is part of s80x86.
4
//
5
// s80x86 is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
9
//
10
// s80x86 is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with s80x86.  If not, see .
17
 
18
`ifndef FONT_ROM_PATH
19
`define FONT_ROM_PATH "."
20
`endif
21
 
22
module FontColorLUT(input logic clk,
23
                    input logic render_cursor,
24
                    input logic [7:0] glyph,
25
                    input logic [2:0] glyph_row,
26
                    input logic [2:0] glyph_col,
27
                    input logic [3:0] foreground,
28
                    input logic [3:0] background,
29
                    output logic [3:0] r,
30
                    output logic [3:0] g,
31
                    output logic [3:0] b);
32
 
33
// 64 bits per character, 256 characters
34
logic font_rom[16384];
35
initial $readmemb({{`FONT_ROM_PATH, "/font.bin"}}, font_rom);
36
 
37
logic font_bit;
38
 
39
wire [13:0] font_mem_addr = {glyph, glyph_row[2:0], glyph_col[2:0]};
40
 
41
wire [11:0] foreground_rgb;
42
wire [11:0] background_rgb;
43
 
44
reg [11:0] color_lut [0:15] = '{
45
    12'h0_0_0, // black
46
    12'h0_0_a, // blue
47
    12'h0_a_0, // green
48
    12'h0_a_a, // cyan
49
    12'ha_0_0, // red
50
    12'ha_0_a, // magenta
51
    12'ha_5_0, // brown
52
    12'ha_a_a, // white
53
    12'h5_5_5, // gray
54
    12'h5_5_f, // bright blue
55
    12'h5_f_5, // bright green
56
    12'h5_f_f, // bright cyan
57
    12'hf_5_5, // bright red
58
    12'hf_5_f, // bright magenta
59
    12'hf_f_5, // yellow
60
    12'hf_f_f  // bright white
61
};
62
 
63
always_ff @(posedge clk) begin
64
    foreground_rgb <= color_lut[foreground];
65
    background_rgb <= color_lut[background];
66
end
67
 
68
assign {r, g, b} = font_bit ^ render_cursor ? foreground_rgb : background_rgb;
69
 
70
always_ff @(posedge clk)
71
    font_bit <= font_rom[font_mem_addr];
72
 
73
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.