---------------------------------------------------------------------------------- -- Company: -- Engineer: -- -- Create Date: 30.11.2021 10:35:30 -- Design Name: -- Module Name: Gene_Snake - Behavioral -- Project Name: -- Target Devices: -- Tool Versions: -- Description: -- -- Dependencies: -- -- Revision: -- Revision 0.01 - File Created -- Additional Comments: -- ---------------------------------------------------------------------------------- -- a faire: -- - faire bouger le snake -- - ajouter une clk 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; library ourTypes; use ourTypes.types.all; -- Uncomment the following library declaration if instantiating -- any Xilinx leaf cells in this code. --library UNISIM; --use UNISIM.VComponents.all; entity Gene_Snake is generic( addressSize : integer:=10); Port ( X : in unsigned (9 downto 0); Y : in unsigned (8 downto 0); clk: in std_logic; reset: in std_logic; currentSnake : in pos; updateOrder : in std_logic; listRef : in unsigned(addressSize-1 downto 0); snakePresent : out std_logic; currentAddress : out unsigned(addressSize-1 downto 0); matAddress : out unsigned(addressSize-1 downto 0) ); end Gene_Snake; architecture Behavioral of Gene_Snake is -- D???claration des signaux signal snakeHere: std_logic; --1 si on doit afficher le pixel 0 sinon signal dx : signed(2 downto 0); signal dy : signed(2 downto 0); signal running : std_logic; begin -- Process de calcul d'affichage process(X,Y,clk,reset,running,dx,dy,updateOrder,currentSnake,snakeHere) begin --if(updateOrder'event and updateOrder = '1') then -- running <= '1'; -- snakeHere <= '0'; -- dx <= to_signed(-1,3); -- dy <= to_signed(-1,3); --end if; --if(reset = '0') then -- dx <= to_signed(-1,3); -- dy <= to_signed(-1,3); -- running <= '0'; -- snakeHere <= '0'; --elsif(clk'event and clk = '1') then -- if(running = '1') then -- dx <= dx + 1; -- if(dx = 2) then -- dx <= to_signed(-1,3); -- dy <= dy + 1; -- end if; -- end if; --end if; if(clk'event and clk = '1') then if(currentSnake.isDefined = '1') then --if(X>=currentSnake.X-8 and X<=currentSnake.X+8 and Y>=currentSnake.Y-8 and Y<=currentSnake.Y+8) then snakeHere <= '1'; --end if; else snakeHere <= '0'; end if; end if; --if(dy = 2) then -- dy <= to_signed(-1,3); -- running <= '0'; --end if; end process; --matAddress <= resize(shift_right(to_unsigned(to_integer(Y)+to_integer(dy),9),4)*40+shift_right(to_unsigned(to_integer(X)+to_integer(dx),10),4),SNAKE_ADDRESS_SIZE); --on resize parce qu'il as décidé que le resultat faisait 18bits au lieu des 11 attendus matAddress <= resize(shift_right(Y,4)*40+shift_right(X,4),SNAKE_ADDRESS_SIZE); currentAddress <= listRef; snakePresent <= snakeHere; end Behavioral;