Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 image1 is
- port
- (
- clk : in std_logic;
- x : in std_logic_vector(10 downto 0);
- y : in std_logic_vector(9 downto 0);
- datardy : in std_logic;
- b1_stat : in std_logic_vector(7 downto 0);
- b_x : in std_logic_vector(7 downto 0);
- b_y : in std_logic_vector(7 downto 0);
- rgb : out std_logic_vector(2 downto 0)
- );
- end image1;
- architecture image1_arch of image1 is
- signal x_position : std_logic_vector (29 downto 0) := "000110010001001011000111110100";
- signal y_position : std_logic_vector (29 downto 0) := "000110010000011001000001100100";
- signal colors : std_logic_vector(5 downto 0);
- signal counter: integer range 0 to 2 := 0;
- signal xint : integer range 0 to 800;
- signal yint : integer range 0 to 600;
- signal ofset_x : integer range -127 to 127;
- signal ofset_y : integer range -127 to 127;
- signal rgb_mysz : std_logic_vector(2 downto 0) := "000";
- signal prawy : std_logic;
- signal lewy : std_logic;
- signal srodek : std_logic;
- signal x_tmp : integer range 0 to 800 := 0;
- signal y_tmp : integer range 0 to 600 := 0;
- signal c_tmp : std_logic_vector(2 downto 0) := "000";
- signal mouse_x_tmp : std_logic_vector(9 downto 0);
- signal mouse_y_tmp : std_logic_vector(9 downto 0);
- signal kx : integer range 0 to 800 := 395;
- signal ky : integer range 0 to 600 := 295;
- type rom_type is array (0 to 15)
- of std_logic_vector(0 to 15);
- -- ROM definition
- constant MOUSE_ROM: rom_type :=
- (
- "1000000000000000",
- "1100000000000000",
- "1110000000000000",
- "1111000000000000",
- "1111100000000000",
- "1111110000000000",
- "1111111000000000",
- "1111111100000000",
- "1111100000000000",
- "1101100000000000",
- "1000110000000000",
- "0000110000000000",
- "0000011000000000",
- "0000011000000000",
- "0000000000000000",
- "0000000000000000");
- signal rom_addr, rom_col: unsigned(3 downto 0);
- signal rom_data: std_logic_vector(15 downto 0);
- signal rom_bit: std_logic;
- begin
- process (x, y)
- begin
- if xint > kx and xint < kx+10 and yint > ky and yint < ky+10 then
- rgb(2) <= rgb_mysz(2);
- rgb(1) <= rgb_mysz(1);
- rgb(0) <= rgb_mysz(0);
- else
- rgb(2) <= '1';
- rgb(1) <= '1';
- rgb(0) <= '1';
- --generowanie ksztaltu
- --for I in 0 to 2 loop
- --if x_position(9+(I*10) downto 0+(I*10)) /= "0000000000" then
- --x_tmp <= to_integer(unsigned(x_position(9+(I*10) downto 0+(I*10))));
- --y_tmp <= to_integer(unsigned(y_position(9+(I*10) downto 0+(I*10))));
- x_tmp <= to_integer(unsigned(x_position(19 downto 10)));
- y_tmp <= to_integer(unsigned(y_position(19 downto 10)));
- if xint >= x_tmp and xint < x_tmp+50 and yint >=y_tmp and yint < y_tmp+50 then
- rgb(2) <= rgb_mysz(2);
- rgb(1) <= rgb_mysz(1);
- rgb(0) <= rgb_mysz(0);
- end if;
- --end if;
- --if xint >= 100+(I*100) and xint < 150+(I*100) and yint >=50 and yint < 100 then
- -- rgb(2) <= rgb_mysz(2);
- -- rgb(1) <= rgb_mysz(1);
- -- rgb(0) <= rgb_mysz(0);
- --end if;
- --end loop;
- --if x_tmp /= 0 and y_tmp /= 0 then
- --when counter = 0
- -- if xint >= 0 and xint < 100 and yint >=60 and yint < 80 then
- -- rgb(2) <= '0';
- -- rgb(1) <= '1';
- -- rgb(0) <= '0';
- -- end if;
- --if xint >= x_tmp and xint < x_tmp+50 and yint >=y_tmp and yint < y_tmp+50 then
- -- rgb(2) <= c_tmp(2);
- -- rgb(1) <= c_tmp(1);
- -- rgb(0) <= c_tmp(0);
- --end if;
- --end if;
- --generowanie palety
- if xint >= 0 and xint < 100 and yint >=0 and yint < 20 then
- rgb(2) <= '0';
- rgb(1) <= '0';
- rgb(0) <= '0';
- end if;
- if xint >= 100 and xint < 200 and yint >=0 and yint < 20 then
- rgb(2) <= '0';
- rgb(1) <= '0';
- rgb(0) <= '1';
- end if;
- if xint >= 200 and xint < 300 and yint >=0 and yint < 20 then
- rgb(2) <= '0';
- rgb(1) <= '1';
- rgb(0) <= '0';
- end if;
- if xint >= 300 and xint < 400 and yint >=0 and yint < 20 then
- rgb(2) <= '0';
- rgb(1) <= '1';
- rgb(0) <= '1';
- end if;
- if xint >= 400 and xint < 500 and yint >=0 and yint < 20 then
- rgb(2) <= '1';
- rgb(1) <= '0';
- rgb(0) <= '0';
- end if;
- if xint >= 500 and xint < 600 and yint >=0 and yint < 20 then
- rgb(2) <= '1';
- rgb(1) <= '0';
- rgb(0) <= '1';
- end if;
- if xint >= 600 and xint < 700 and yint >=0 and yint < 20 then
- rgb(2) <= '1';
- rgb(1) <= '1';
- rgb(0) <= '0';
- end if;
- if xint >= 700 and xint <= 800 and yint >=0 and yint < 20 then
- rgb(2) <= '1';
- rgb(1) <= '1';
- rgb(0) <= '1';
- end if;
- end if;
- end process;
- --rysuj : process (kx,ky)
- --begin
- -- if kx >= 0 and kx <= 800 and ky >= 20 and ky <= 600 and b1_stat(0) = '1' then
- -- x_tmp <= kx;
- -- y_tmp <= ky;
- -- c_tmp(2) <= rgb_mysz(2);
- -- c_tmp(1) <= rgb_mysz(1);
- -- c_tmp(0) <= rgb_mysz(0);
- -- end if;
- --end process;
- pickcolor : process (kx,ky)
- begin
- if kx >= 0 and b1_stat(0) = '1' and kx < 100 and ky >=0 and ky < 10 then
- rgb_mysz(2) <= '0';
- rgb_mysz(1) <= '0';
- rgb_mysz(0) <= '0';
- end if;
- if kx >= 100 and b1_stat(0) = '1' and kx < 200 and ky >=0 and ky < 10 then
- rgb_mysz(2) <= '0';
- rgb_mysz(1) <= '0';
- rgb_mysz(0) <= '1';
- end if;
- if kx >= 200 and b1_stat(0) = '1' and kx < 300 and ky >=0 and ky < 10 then
- rgb_mysz(2) <= '0';
- rgb_mysz(1) <= '1';
- rgb_mysz(0) <= '0';
- end if;
- if kx >= 300 and b1_stat(0) = '1' and kx < 400 and ky >=0 and ky < 10 then
- rgb_mysz(2) <= '0';
- rgb_mysz(1) <= '1';
- rgb_mysz(0) <= '1';
- end if;
- if kx >= 400 and b1_stat(0) = '1' and kx < 500 and ky >=0 and ky < 10 then
- rgb_mysz(2) <= '1';
- rgb_mysz(1) <= '0';
- rgb_mysz(0) <= '0';
- end if;
- if kx >= 500 and b1_stat(0) = '1' and kx < 600 and ky >=0 and ky < 10 then
- rgb_mysz(2) <= '1';
- rgb_mysz(1) <= '0';
- rgb_mysz(0) <= '1';
- end if;
- if kx >= 600 and b1_stat(0) = '1' and kx < 700 and ky >=0 and ky < 10 then
- rgb_mysz(2) <= '1';
- rgb_mysz(1) <= '1';
- rgb_mysz(0) <= '0';
- end if;
- if kx >= 700 and b1_stat(0) = '1' and kx <= 800 and ky >=0 and ky < 10 then
- rgb_mysz(2) <= '1';
- rgb_mysz(1) <= '1';
- rgb_mysz(0) <= '1';
- end if;
- end process;
- mysz : process (datardy)
- begin
- if b1_stat(0) = '1' and rising_edge(clk) and datardy='1' then --lewy
- mouse_x_tmp <= std_logic_vector(to_unsigned(kx, mouse_x_tmp'length));
- mouse_y_tmp <= std_logic_vector(to_unsigned(ky, mouse_y_tmp'length));
- x_position(19 downto 10) <= mouse_x_tmp;
- y_position(19 downto 10) <= mouse_y_tmp;
- --x_position(9+(counter*10) downto 0+(counter*10)) <= mouse_x_tmp;
- --y_position(9+(counter*10) downto 0+(counter*10)) <= mouse_y_tmp;
- --counter <= counter + 1;
- end if;
- if b1_stat(2) = '1' then --srodek
- --TODO
- end if;
- if b1_stat(1) = '1' then --prawy
- --TODO
- end if;
- if rising_edge(clk) and datardy='1' then
- kx <= kx + ofset_x;
- ky <= ky - ofset_y;
- end if;
- end process;
- xint <= to_integer(unsigned(x));
- yint <= to_integer(unsigned(y));
- ofset_x <= to_integer(signed(b_x));
- ofset_y <= to_integer(signed(b_y));
- end image1_arch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement