From 8b1a70baee8104fa9b618dad791ecedb4fc7e8f8 Mon Sep 17 00:00:00 2001 From: Leo Lemaire Date: Wed, 15 Dec 2021 18:36:50 +0000 Subject: [PATCH] Upload New File --- sources_snake/updateSnake.vhd | 75 +++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 sources_snake/updateSnake.vhd diff --git a/sources_snake/updateSnake.vhd b/sources_snake/updateSnake.vhd new file mode 100644 index 0000000..4157191 --- /dev/null +++ b/sources_snake/updateSnake.vhd @@ -0,0 +1,75 @@ +---------------------------------------------------------------------------------- +-- Company: +-- Engineer: +-- +-- Create Date: 12/15/2021 02:06:27 PM +-- Design Name: +-- Module Name: updateSnake - Behavioral +-- Project Name: +-- Target Devices: +-- Tool Versions: +-- Description: +-- +-- Dependencies: +-- +-- Revision: +-- Revision 0.01 - File Created +-- Additional Comments: +-- +---------------------------------------------------------------------------------- + + +library IEEE; +use IEEE.STD_LOGIC_1164.ALL; + +library ourTypes; +use ourTypes.types.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 leaf cells in this code. +--library UNISIM; +--use UNISIM.VComponents.all; + +entity updateSnake is + Port ( inSnake : in pos; + outSnake : out pos; + inIndex : in unsigned(10 downto 0); + outIndex : out unsigned(10 downto 0)); +end updateSnake; + +architecture Behavioral of updateSnake is +signal cSnake : pos; +begin +process(inSnake) +variable dir : direction; +begin + case inSnake.dir is + when gauche => + cSnake.X <= inSnake.X - 1; + cSnake.Y <= inSnake.Y; + cSnake.dir <= inSnake.dir; + cSnake.isDefined <= inSnake.isDefined; + when droite => + cSnake.X <= inSnake.X + 1; + cSnake.Y <= inSnake.Y; + cSnake.dir <= inSnake.dir; + cSnake.isDefined <= inSnake.isDefined; + when haut => + cSnake.X <= inSnake.X; + cSnake.Y <= inSnake.Y - 1; + cSnake.dir <= inSnake.dir; + cSnake.isDefined <= inSnake.isDefined; + when bas => + cSnake.X <= inSnake.X; + cSnake.Y <= inSnake.Y + 1; + cSnake.dir <= inSnake.dir; + cSnake.isDefined <= inSnake.isDefined; + end case; +end process; +outSnake <= cSnake; +outIndex <= inIndex + 1; +end Behavioral;