Implement basic ascii framebuffer (read only for now)

This commit is contained in:
Klemens Schölhorn 2018-01-23 03:02:06 +01:00
parent 0e298a6380
commit ad8b39a4ce
4 changed files with 221 additions and 7 deletions

View File

@ -44,10 +44,6 @@
<file xil_pn:name="main.ucf" xil_pn:type="FILE_UCF"> <file xil_pn:name="main.ucf" xil_pn:type="FILE_UCF">
<association xil_pn:name="Implementation" xil_pn:seqID="0"/> <association xil_pn:name="Implementation" xil_pn:seqID="0"/>
</file> </file>
<file xil_pn:name="image_generator.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="154"/>
<association xil_pn:name="Implementation" xil_pn:seqID="7"/>
</file>
<file xil_pn:name="keyboard.vhd" xil_pn:type="FILE_VHDL"> <file xil_pn:name="keyboard.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="153"/> <association xil_pn:name="BehavioralSimulation" xil_pn:seqID="153"/>
<association xil_pn:name="Implementation" xil_pn:seqID="4"/> <association xil_pn:name="Implementation" xil_pn:seqID="4"/>
@ -56,6 +52,10 @@
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="154"/> <association xil_pn:name="BehavioralSimulation" xil_pn:seqID="154"/>
<association xil_pn:name="Implementation" xil_pn:seqID="1"/> <association xil_pn:name="Implementation" xil_pn:seqID="1"/>
</file> </file>
<file xil_pn:name="font_rom.vhd" xil_pn:type="FILE_VHDL">
<association xil_pn:name="BehavioralSimulation" xil_pn:seqID="155"/>
<association xil_pn:name="Implementation" xil_pn:seqID="7"/>
</file>
</files> </files>
<properties> <properties>

129
font.hex Normal file
View File

@ -0,0 +1,129 @@
# IBM, Marcel Sondaar, Daniel Hepper bitmap font (public domain, https://github.com/dhepper/font8x8)
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000000000000000
00180018183C3C18
0000000000003636
0036367F367F3636
000C1F301E033E0C
0063660C18336300
006E333B6E1C361C
0000000000030606
00180C0606060C18
00060C1818180C06
0000663CFF3C6600
00000C0C3F0C0C00
060C0C0000000000
000000003F000000
000C0C0000000000
000103060C183060
003E676F7B73633E
003F0C0C0C0C0E0C
003F33061C30331E
001E33301C30331E
0078307F33363C38
001E3330301F033F
001E33331F03061C
000C0C0C1830333F
001E33331E33331E
000E18303E33331E
000C0C00000C0C00
060C0C00000C0C00
00180C0603060C18
00003F00003F0000
00060C1830180C06
000C000C1830331E
001E037B7B7B633E
0033333F33331E0C
003F66663E66663F
003C66030303663C
001F36666666361F
007F46161E16467F
000F06161E16467F
007C66730303663C
003333333F333333
001E0C0C0C0C0C1E
001E333330303078
006766361E366667
007F66460606060F
0063636B7F7F7763
006363737B6F6763
001C36636363361C
000F06063E66663F
00381E3B3333331E
006766363E66663F
001E33380E07331E
001E0C0C0C0C2D3F
003F333333333333
000C1E3333333333
0063777F6B636363
0063361C1C366363
001E0C0C1E333333
007F664C1831637F
001E06060606061E
00406030180C0603
001E18181818181E
0000000063361C08
FF00000000000000
0000000000180C0C
006E333E301E0000
003B66663E060607
001E3303331E0000
006E33333e303038
001E033f331E0000
000F06060f06361C
1F303E33336E0000
006766666E360607
001E0C0C0C0E000C
1E33333030300030
0067361E36660607
001E0C0C0C0C0C0E
00636B7F7F330000
00333333331F0000
001E3333331E0000
0F063E66663B0000
78303E33336E0000
000F06666E3B0000
001F301E033E0000
00182C0C0C3E0C08
006E333333330000
000C1E3333330000
00367F7F6B630000
0063361C36630000
1F303E3333330000
003F260C193F0000
00380C0C070C0C38
0018181800181818
00070C0C380C0C07
0000000000003B6E
0000000000000000

87
font_rom.vhd Normal file
View File

@ -0,0 +1,87 @@
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
use std.textio.all;
use ieee.std_logic_textio.all;
entity font_rom is
generic (
input_clk: integer
);
port (
clk: in std_logic;
x, y: in std_logic_vector(9 downto 0);
rgb: out std_logic_vector(23 downto 0)
);
end font_rom;
architecture logic of font_rom is
type rom_type is array(0 to 127) of std_logic_vector(63 downto 0);
type framebuffer_type is array(0 to 59, 0 to 79) of std_logic_vector(7 downto 0);
impure function read_font(filename: in string) return rom_type is
file rom_file: text is in filename;
variable rom_line: line;
variable rom: rom_type;
begin
-- skip comment in first line
readline(rom_file, rom_line);
for i in rom_type'range loop
readline(rom_file, rom_line);
hread(rom_line, rom(i));
end loop;
return rom;
end function;
constant font: rom_type := read_font("font.hex");
constant framebuffer: framebuffer_type := (
0 => (x"48", x"61", x"6C", x"6c", x"6f", others => x"00"),
1 to 59 => (others => x"00")
);
signal char_x: integer range 0 to 79;
signal char_y: integer range 0 to 59;
signal current_char: std_logic_vector(7 downto 0);
signal current_glyph: std_logic_vector(63 downto 0);
signal current_glyph_pos: integer range 0 to 127;
signal glyph_pos_raw: std_logic_vector(5 downto 0);
signal glyph_pos: integer range 0 to 63;
begin
char_x <= to_integer(unsigned(x(9 downto 3)));
char_y <= to_integer(unsigned(y(9 downto 3)));
process(clk) is
begin
if rising_edge(clk) then
current_char <= framebuffer(char_y, char_x);
end if;
end process;
current_glyph_pos <= to_integer(unsigned(current_char));
process(clk) is
begin
if rising_edge(clk) then
current_glyph <= font(current_glyph_pos);
end if;
end process;
glyph_pos_raw <= y(2 downto 0) & x(2 downto 0);
glyph_pos <= to_integer(unsigned(glyph_pos_raw));
-- actually currently BRG
rgb <=
"111111111111111111111111" when current_glyph(glyph_pos) = '1' else
"000000000000000000000000";
end logic;

View File

@ -85,14 +85,12 @@ begin
dvi_de => de dvi_de => de
); );
image_generator_i: entity work.image_generator generic map ( framebuffer: entity work.font_rom generic map (
input_clk => 48_000_000 input_clk => 48_000_000
) port map ( ) port map (
clk => clk_vga, clk => clk_vga,
x => image_x, x => image_x,
y => image_y, y => image_y,
ctrl_up => rotary_up,
ctrl_down => rotary_down,
rgb => pixel_rgb rgb => pixel_rgb
); );