diff --git a/dvi_test.xise b/dvi_test.xise index 0710c9c..99cc276 100644 --- a/dvi_test.xise +++ b/dvi_test.xise @@ -17,7 +17,7 @@ - + @@ -27,34 +27,38 @@ - + - + - + - + - + - + - + + + + + diff --git a/font_rom.vhd b/font_rom.vhd index 91fe24d..3ba5a50 100644 --- a/font_rom.vhd +++ b/font_rom.vhd @@ -13,7 +13,8 @@ entity font_rom is ); port ( clk: in std_logic; - x, y: in std_logic_vector(9 downto 0); + x: in std_logic_vector(9 downto 0); + y: in std_logic_vector(8 downto 0); rgb: out std_logic_vector(23 downto 0) ); @@ -40,14 +41,6 @@ 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") - ); - - 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); @@ -56,17 +49,53 @@ architecture logic of font_rom is 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; + + signal write_x: unsigned(6 downto 0); + signal write_y: unsigned(5 downto 0); + signal write_value: std_logic_vector(7 downto 0); + + signal ra: std_logic_vector(12 downto 0); + signal wa: std_logic_vector(12 downto 0); begin - char_x <= to_integer(unsigned(x(9 downto 3))); - char_y <= to_integer(unsigned(y(9 downto 3))); + ra <= x(9 downto 3) & y(8 downto 3); + wa <= std_logic_vector(write_x) & std_logic_vector(write_y); + write_value <= "0" & std_logic_vector(write_x + 32); + + cycle_write_location: process(clk) + constant max_delay: integer := 2000000; + variable delay: integer range 0 to max_delay; begin if rising_edge(clk) then - current_char <= framebuffer(char_y, char_x); + if delay = max_delay then + delay := 0; + + if write_x = 79 then + write_x <= (others => '0'); + if write_y = 59 then + write_y <= (others => '0'); + else + write_y <= write_y + 1; + end if; + else + write_x <= write_x + 1; + end if; + else + delay := delay + 1; + end if; end if; - end process; + end process cycle_write_location; + + terminal_buffer: entity work.terminal_buffer port map ( + clk => clk, + ra => ra, + do => current_char, + we => '1', + wa => wa, + di => write_value + ); process(clk) variable current_glyph_pos: integer range 0 to 127; diff --git a/main.vhd b/main.vhd index 5f2970d..4fa49b0 100644 --- a/main.vhd +++ b/main.vhd @@ -41,7 +41,7 @@ end main; architecture Behavioral of main is signal clk_vga: std_logic; signal image_x: std_logic_vector(9 downto 0); - signal image_y: std_logic_vector(9 downto 0); + signal image_y: std_logic_vector(8 downto 0); signal pixel_rgb: std_logic_vector(23 downto 0); signal dvi_clk: std_logic; -- connect vga_sync to dvi_clk_ds -- tmp diff --git a/terminal_buffer.vhd b/terminal_buffer.vhd new file mode 100644 index 0000000..796e22e --- /dev/null +++ b/terminal_buffer.vhd @@ -0,0 +1,37 @@ +library ieee; + +use ieee.std_logic_1164.all; +use ieee.std_logic_unsigned.all; +use ieee.numeric_std.all; + +entity terminal_buffer is + port ( + clk: in std_logic; + we: in std_logic; + wa: in std_logic_vector(12 downto 0); + ra: in std_logic_vector(12 downto 0); + di: in std_logic_vector(7 downto 0); + do: out std_logic_vector(7 downto 0) + ); +end terminal_buffer; + +architecture syn of terminal_buffer is + type ram_type is array((2**13 - 1) downto 0) of std_logic_vector(7 downto 0); + signal RAM: ram_type; + signal read_a: std_logic_vector(ra'range); +begin + + process(clk) + begin + if rising_edge(clk) then + if we = '1' then + RAM(to_integer(unsigned(wa))) <= di; + end if; + + read_a <= ra; + end if; + end process; + + do <= RAM(to_integer(unsigned(read_a))); + +end syn; diff --git a/vga.vhd b/vga.vhd index 62219da..8ccdc76 100644 --- a/vga.vhd +++ b/vga.vhd @@ -7,7 +7,8 @@ entity vga is port( clk: in std_logic; - x, y: out std_logic_vector(9 downto 0); + x: out std_logic_vector(9 downto 0); + y: out std_logic_vector(8 downto 0); pixel_rgb: in std_logic_vector(23 downto 0); dvi_d: out std_logic_vector(11 downto 0); @@ -21,7 +22,7 @@ end vga; architecture behavioral of vga is signal second_batch: std_logic := '0'; signal hcount: std_logic_vector(9 downto 0) := (others => '0'); - signal vcount: std_logic_vector(9 downto 0) := (others => '0'); + signal vcount: std_logic_vector(8 downto 0) := (others => '0'); signal data_enabled: std_logic; begin dvi_clk <= clk; @@ -37,7 +38,7 @@ begin '1'; x <= hcount when data_enabled = '1' and hcount < 640 else std_logic_vector(to_unsigned(639, 10)); - y <= vcount when data_enabled = '1' and vcount < 480 else std_logic_vector(to_unsigned(479, 10)); + y <= vcount when data_enabled = '1' and vcount < 480 else std_logic_vector(to_unsigned(479, 9)); data_output: process(clk) begin