M
marcin00022
Hello
I want to draw squere 50 x 50 pixel on the screen (640 x 480) begining in mouse position
but it change size .. somtimes it is (20 x 50) or (50 x 30) or (30 x 30) and i don't have slightest idea what is wrong ...
code:
librarposy IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.ALL;
entitposy ACursor is
port (
clk: in STD_LOGIC;
posy: in STD_LOGIC_VECTOR (9 downto 0);
posx: in STD_LOGIC_VECTOR (9 downto 0) ;
cursor_posy_in: in STD_LOGIC_VECTOR (7 downto 0);
cursor_posx_in: in STD_LOGIC_VECTOR (7 downto 0) ;
ro : out STD_LOGIC_VECTOR (2 downto 0);
go : out STD_LOGIC_VECTOR (2 downto 0);
bo : out STD_LOGIC_VECTOR (2 downto 0);
ri : in STD_LOGIC_VECTOR (2 downto 0);
gi : in STD_LOGIC_VECTOR (2 downto 0);
bi : in STD_LOGIC_VECTOR (2 downto 0)
);
end ACursor;
architecture behaviour of ACursor is
signal cursor_posy: unsigned (9 downto 0);
signal cursor_posx: unsigned (9 downto 0) ;
begin
cursor_posy <= unsigned(cursor_posy_in(6 downto 0) & "000");
cursor_posx <= unsigned(cursor_posx_in(6 downto 0) & "000");
process(posx,posy)
begin
if(rising_edge(clk)) then
if (unsigned(posx) < 4) or (unsigned(posx) > 636) or (unsigned(posy) < 5) or (unsigned(posy) > 477) then
ro <= "000";
go <= "000";
bo <= "000";
elsif (( unsigned(posx) = cursor_posx) OR (unsigned(posx) = ((cursor_posx) + x"32")) or (unsigned(posy) = cursor_posy) OR (unsigned(posy) = ((cursor_posy)+ x"32" ))) and
(( unsigned(posx) >= cursor_posx) and (unsigned(posx) <= ((cursor_posx) + x"33")) and (unsigned(posy) >= cursor_posy) and (unsigned(posy) <= ((cursor_posy)+ x"33" ))) then
ro <= "111";
go <= "000";
bo <= "000";
else
ro <= ri;
go <= gi;
bo <= bi;
end if;
end if;
end process;
end behaviour;
It feels like it's not adding properly
I want to draw squere 50 x 50 pixel on the screen (640 x 480) begining in mouse position
but it change size .. somtimes it is (20 x 50) or (50 x 30) or (30 x 30) and i don't have slightest idea what is wrong ...
code:
librarposy IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.ALL;
entitposy ACursor is
port (
clk: in STD_LOGIC;
posy: in STD_LOGIC_VECTOR (9 downto 0);
posx: in STD_LOGIC_VECTOR (9 downto 0) ;
cursor_posy_in: in STD_LOGIC_VECTOR (7 downto 0);
cursor_posx_in: in STD_LOGIC_VECTOR (7 downto 0) ;
ro : out STD_LOGIC_VECTOR (2 downto 0);
go : out STD_LOGIC_VECTOR (2 downto 0);
bo : out STD_LOGIC_VECTOR (2 downto 0);
ri : in STD_LOGIC_VECTOR (2 downto 0);
gi : in STD_LOGIC_VECTOR (2 downto 0);
bi : in STD_LOGIC_VECTOR (2 downto 0)
);
end ACursor;
architecture behaviour of ACursor is
signal cursor_posy: unsigned (9 downto 0);
signal cursor_posx: unsigned (9 downto 0) ;
begin
cursor_posy <= unsigned(cursor_posy_in(6 downto 0) & "000");
cursor_posx <= unsigned(cursor_posx_in(6 downto 0) & "000");
process(posx,posy)
begin
if(rising_edge(clk)) then
if (unsigned(posx) < 4) or (unsigned(posx) > 636) or (unsigned(posy) < 5) or (unsigned(posy) > 477) then
ro <= "000";
go <= "000";
bo <= "000";
elsif (( unsigned(posx) = cursor_posx) OR (unsigned(posx) = ((cursor_posx) + x"32")) or (unsigned(posy) = cursor_posy) OR (unsigned(posy) = ((cursor_posy)+ x"32" ))) and
(( unsigned(posx) >= cursor_posx) and (unsigned(posx) <= ((cursor_posx) + x"33")) and (unsigned(posy) >= cursor_posy) and (unsigned(posy) <= ((cursor_posy)+ x"33" ))) then
ro <= "111";
go <= "000";
bo <= "000";
else
ro <= ri;
go <= gi;
bo <= bi;
end if;
end if;
end process;
end behaviour;
It feels like it's not adding properly