Align delays in the font_rom to fix rendering
This commit is contained in:
		
							
								
								
									
										35
									
								
								font_rom.vhd
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								font_rom.vhd
									
									
									
									
									
								
							| @@ -21,7 +21,6 @@ end font_rom; | |||||||
|  |  | ||||||
| architecture logic of font_rom is | architecture logic of font_rom is | ||||||
|     type rom_type is array(0 to 127) of std_logic_vector(63 downto 0); |     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 |     impure function read_font(filename: in string) return rom_type is | ||||||
|         file rom_file: text is in filename; |         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"); |     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 := ( |     constant framebuffer: framebuffer_type := ( | ||||||
|         0 => (x"48", x"61", x"6C", x"6c", x"6f", others => x"00"), |         0 => (x"48", x"61", x"6C", x"6c", x"6f", others => x"00"), | ||||||
|         1 to 59 => (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_char: std_logic_vector(7 downto 0); | ||||||
|  |  | ||||||
|     signal current_glyph: std_logic_vector(63 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); |     -- delay by 2 cycles to match the delay of x/y -> rgb | ||||||
|     signal glyph_pos: integer range 0 to 63; |     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 | begin | ||||||
|  |  | ||||||
|     char_x <= to_integer(unsigned(x(9 downto 3))); |     char_x <= to_integer(unsigned(x(9 downto 3))); | ||||||
|     char_y <= to_integer(unsigned(y(9 downto 3))); |     char_y <= to_integer(unsigned(y(9 downto 3))); | ||||||
|  |  | ||||||
|     process(clk) is |     process(clk) | ||||||
|     begin |     begin | ||||||
|         if rising_edge(clk) then |         if rising_edge(clk) then | ||||||
|             current_char <= framebuffer(char_y, char_x); |             current_char <= framebuffer(char_y, char_x); | ||||||
|         end if; |         end if; | ||||||
|     end process; |     end process; | ||||||
|  |  | ||||||
|     current_glyph_pos <= to_integer(unsigned(current_char)); |     process(clk) | ||||||
|  |         variable current_glyph_pos: integer range 0 to 127; | ||||||
|     process(clk) is |  | ||||||
|     begin |     begin | ||||||
|         if rising_edge(clk) then |         if rising_edge(clk) then | ||||||
|  |             current_glyph_pos := to_integer(unsigned(current_char)); | ||||||
|             current_glyph <= font(current_glyph_pos); |             current_glyph <= font(current_glyph_pos); | ||||||
|         end if; |         end if; | ||||||
|     end process; |     end process; | ||||||
|  |  | ||||||
|     glyph_pos_raw <= y(2 downto 0) & x(2 downto 0); |     delay_glyph_pos: | ||||||
|     glyph_pos <= to_integer(unsigned(glyph_pos_raw)); |     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 |     -- actually currently BRG | ||||||
|     rgb <= |     rgb <= | ||||||
|         "111111111111111111111111" when current_glyph(glyph_pos) = '1' else |         "111111111111111111111111" when current_glyph(glyph_pos(1)) = '1' else | ||||||
|         "000000000000000000000000"; |         "000000000000000000000000"; | ||||||
|  |  | ||||||
| end logic; | end logic; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user