Align delays in the font_rom to fix rendering

This commit is contained in:
Klemens Schölhorn 2018-01-24 23:43:41 +01:00
parent ad8b39a4ce
commit a8191387ec
1 changed files with 24 additions and 11 deletions

View File

@ -21,7 +21,6 @@ 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;
@ -41,6 +40,7 @@ architecture logic of font_rom is
constant font: rom_type := read_font("font.hex");
type framebuffer_type is array(0 to 59, 0 to 79) of std_logic_vector(7 downto 0);
constant framebuffer: framebuffer_type := (
0 => (x"48", x"61", x"6C", x"6c", x"6f", others => x"00"),
1 to 59 => (others => x"00")
@ -51,37 +51,50 @@ architecture logic of font_rom is
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;
-- delay by 2 cycles to match the delay of x/y -> rgb
constant glyph_pos_length: integer := 2;
type glyph_pos_type is array(1 to glyph_pos_length) of integer range 0 to 63;
signal glyph_pos: glyph_pos_type;
begin
char_x <= to_integer(unsigned(x(9 downto 3)));
char_y <= to_integer(unsigned(y(9 downto 3)));
process(clk) is
process(clk)
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
process(clk)
variable current_glyph_pos: integer range 0 to 127;
begin
if rising_edge(clk) then
current_glyph_pos := to_integer(unsigned(current_char));
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));
delay_glyph_pos:
process(clk)
variable combined: std_logic_vector(5 downto 0);
begin
if rising_edge(clk) then
combined := y(2 downto 0) & x(2 downto 0);
glyph_pos(glyph_pos_length) <= to_integer(unsigned(combined));
-- move all elements one index down
for i in 1 to glyph_pos_length - 1 loop
glyph_pos(i) <= glyph_pos(i + 1);
end loop;
end if;
end process delay_glyph_pos;
-- actually currently BRG
rgb <=
"111111111111111111111111" when current_glyph(glyph_pos) = '1' else
"111111111111111111111111" when current_glyph(glyph_pos(1)) = '1' else
"000000000000000000000000";
end logic;