Как кодировать модуль, который определяет горизонтальные и вертикальные координаты монитора в VHDL - PullRequest
0 голосов
/ 27 мая 2019

Я пишу игру с VHDL для школьного проекта, мне нужно написать модуль для определить горизонтальное и вертикальное положение экрана, я написал один, но он не работает правильно. Я думаю, что проблема в граничных числах, но я не знаю, как исправить это, вы можете помочь?

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity Sync_To_Row_And_Column is
port(
    vga_clk : in std_logic;
    global_reset : in std_logic;
    hdisp : in std_logic;
    vdisp : in std_logic;
    hpos : out integer;
    vpos : out integer
);
end Sync_To_Row_And_Column;

architecture Behavioral of Sync_To_Row_And_Column is

begin
    process(vga_clk,hdisp,vdisp,global_reset) 
        variable hpos_temp : integer range 1 to 640 := 1 ;
        variable vpos_temp : integer range 1 to 480 := 1 ;
        variable counter : integer := 0;
    begin 
        if(global_reset = '1') then
            hpos_temp := 1;
            vpos_temp := 1;
            counter := 0;
        elsif (vga_clk'event and vga_clk='1') then
            if (vdisp ='1' and hdisp = '1') then 
                counter := counter + 1;
                if(counter >= 639)then
                    vpos_temp := vpos_temp + 1;
                    counter := 0;
                end if;
                hpos_temp := hpos_temp + 1;
            end if; 
        end if;
        hpos <= hpos_temp;
        vpos <= vpos_temp;
    end process;
end Behavioral;
...