OpenCores
URL https://opencores.org/ocsvn/graphicsaccelerator/graphicsaccelerator/trunk

Subversion Repositories graphicsaccelerator

[/] [graphicsaccelerator/] [trunk/] [Pointer.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 OmarMokhta
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.numeric_std.all;
4
use IEEE.std_logic_unsigned.all;
5
entity Pointer is
6
         Generic (initX : STD_LOGIC_VECTOR (9 downto 0);
7
                                 initY : STD_LOGIC_VECTOR (8 downto 0));
8
    Port ( MoveUp : in  STD_LOGIC;
9
           MoveDown : in  STD_LOGIC;
10
                          MoveLeft : in  STD_LOGIC;
11
                          MoveRight : in  STD_LOGIC;
12
           Move : in  STD_LOGIC;
13
           Clk : in  STD_LOGIC;
14
           Here : out  STD_LOGIC;
15
                          X : out  STD_LOGIC_VECTOR (9 downto 0);
16
                          Y : out  STD_LOGIC_VECTOR (8 downto 0);
17
           syncX : in  STD_LOGIC_VECTOR (9 downto 0);
18
           syncY : in  STD_LOGIC_VECTOR (8 downto 0));
19
end Pointer;
20
architecture Behavioral of Pointer is
21
signal rX : STD_LOGIC_VECTOR (9 downto 0) := initX;
22
signal rY : STD_LOGIC_VECTOR (8 downto 0) := initY;
23
begin
24
Here <= '1' when syncX(9 downto 3)=rX(9 downto 3) and
25
                                          syncY(8 downto 3)=rY(8 downto 3) else '0';
26
X <= rX;
27
Y <= rY;
28
process (Clk) begin
29
        if (rising_edge(Clk)) then
30
                if (Move = '1') then
31
                        if (MoveLeft = '1' and MoveRight = '0') then
32
                                if not (rX = "0000000000") then
33
                                        rX <= rX - 1;
34
                                end if;
35
                        elsif (MoveLeft = '0' and MoveRight = '1') then
36
                                if not (rX = "1001111111") then
37
                                        rX <= rX + 1;
38
                                end if;
39
                        end if;
40
                        if (MoveUp = '1' and MoveDown = '0') then
41
                                if not (rY = "000000000") then
42
                                        rY <= rY - 1;
43
                                end if;
44
                        elsif (MoveUp = '0' and MoveDown = '1') then
45
                                if not (rY = "111011111") then
46
                                        rY <= rY + 1;
47
                                end if;
48
                        end if;
49
                end if;
50
        end if;
51
end process;
52
end Behavioral;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.