123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
-
-
-
- use IEEE.NUMERIC_STD.ALL;
-
-
-
-
-
-
- entity VGACompass is
- Port ( DRX : in STD_LOGIC_VECTOR (15 downto 0);
- DRY : in STD_LOGIC_VECTOR (15 downto 0);
- Reset : in STD_LOGIC;
- Clk : in STD_LOGIC;
- V_R : out STD_LOGIC_VECTOR (4 downto 0);
- V_G : out STD_LOGIC_VECTOR (5 downto 0);
- V_B : out STD_LOGIC_VECTOR (4 downto 0);
- H_SYNC : out STD_LOGIC;
- V_SYNC : out STD_LOGIC);
- end VGACompass;
-
- architecture Behavioral of VGACompass is
- constant h_pulse : integer := 80;
- constant h_bp : integer := 160;
- constant h_pixels : integer := 800;
- constant h_fp : integer := 16;
- constant h_pol : STD_LOGIC := '1';
- constant v_pulse : integer := 3;
- constant v_bp : integer := 21;
- constant v_pixels : integer := 600;
- constant v_fp : integer := 1;
- constant v_pol : STD_LOGIC := '1';
- constant h_period : integer := h_pulse + h_bp + h_pixels + h_fp;
- constant v_period : integer := v_pulse + v_bp + v_pixels + v_fp;
-
- signal disp_ena : STD_LOGIC;
- signal column : integer;
- signal row : integer;
-
- signal DataX : signed (15 downto 0) := signed(DRX);
- signal DataY : signed (15 downto 0) := signed(DRY);
- signal Color : unsigned (15 downto 0) := unsigned((abs(DataX) + abs(DataY)) / 2);
-
- begin
- process(Clk, Reset)
- variable h_count : integer range 0 to h_period - 1 := 0;
- variable v_count : integer range 0 to v_period - 1 := 0;
-
- begin
- if rising_edge(Clk) then
- if(Reset = '1') then
- h_count := 0;
- v_count := 0;
- H_SYNC <= not h_pol;
- V_SYNC <= not v_pol;
- disp_ena <= '0';
- column <= 0;
- row <= 0;
- end if;
-
-
- if(h_count < h_period - 1) then
-
- h_count := h_count + 1;
- else
- h_count := 0;
- if(v_count < v_period - 1) then
-
- v_count := v_count + 1;
- else
- v_count := 0;
- end if;
- end if;
-
-
- if(h_count < h_pixels + h_fp or h_count >= h_pixels + h_fp + h_pulse) then
- H_SYNC <= not h_pol;
- else
- H_SYNC <= h_pol;
- end if;
-
-
- if(v_count < v_pixels + v_fp or v_count >= v_pixels + v_fp + v_pulse) then
- V_SYNC <= not v_pol;
- else
- V_SYNC <= v_pol;
- end if;
-
-
- if(h_count < h_pixels) then
- column <= h_count;
- end if;
- if(v_count < v_pixels) then
- row <= v_count;
- end if;
-
-
- if(h_count < h_pixels and v_count < v_pixels) then
-
- disp_ena <= '1';
- else
-
- disp_ena <= '0';
- end if;
- end if;
- end process;
-
- process(disp_ena, row, column, DataX, DataY, Color)
- begin
- if(disp_ena = '1') then
-
- if(row > 295 - shift_right(DataX, 3) and column > 395 - shift_right(DataY, 3) and row < 305 - shift_right(DataX, 3) and column < 405 - shift_right(DataY, 3)) then
-
- V_R <= (others => '1');
- V_G <= STD_LOGIC_VECTOR(Color(10 downto 5));
- V_B <= (others => '0');
- elsif(row > 295 + shift_right(DataX, 3) and column > 395 + shift_right(DataY, 3) and row < 305 + shift_right(DataX, 3) and column < 405 + shift_right(DataY, 3)) then
-
- V_R <= (others => '0');
- V_G <= STD_LOGIC_VECTOR(Color(10 downto 5));
- V_B <= (others => '1');
- elsif(row = 300 or column = 400) then
-
- V_R <= (others => '1');
- V_G <= (others => '1');
- V_B <= (others => '0');
- else
-
- V_R <= (others => '0');
- V_G <= (others => '0');
- V_B <= (others => '0');
- end if;
- else
-
- V_R <= (others => '0');
- V_G <= (others => '0');
- V_B <= (others => '0');
- end if;
- end process;
- end Behavioral;
|