---------------------------------------------------------------------------------- -- Company: Hall/ock Electronic Alligator-Based Game Systems, Incorperated -- Engineer: Lexa Hall & Michael Hallock -- -- Create Date: 12/03/2016 09:24:24 PM -- Design Name: Game Logic -- Module Name: GameLogic - Behavioral -- Project Name: Wacky Gator -- Target Devices: Basys3 -- Description: Game logic for Wacky Gator Game -- Activates LEDs which represent alligators -- which are "whacked" by flipping a switch -- Drives LEDs and outputs game score ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.NUMERIC_STD.ALL; entity GameLogic is Port ( GameClk : in STD_LOGIC; Start : in STD_LOGIC; Switch : in STD_LOGIC_VECTOR (15 downto 0); RandomNumber : in STD_LOGIC_VECTOR (3 downto 0); LED : out STD_LOGIC_VECTOR (15 downto 0); Phase : in STD_LOGIC_VECTOR (2 downto 0); Score : out STD_LOGIC_VECTOR(15 downto 0)); end GameLogic; architecture Behavioral of GameLogic is signal Q, currentscore : STD_LOGIC_VECTOR (15 downto 0); begin LED <= Q; process (GameClk) is variable count : unsigned (1 downto 0) := "00"; variable gators : std_logic_vector (15 downto 0) := x"0000"; variable rand : integer; variable gamescore : unsigned (15 downto 0) := x"0000"; variable gamestarted : std_logic := '0'; begin if (rising_edge(GameClk)) then if(Start = '1') then gators := x"0000"; gamescore := x"0000"; gamestarted := '1'; end if; if (gamestarted = '1') then if (count = "00" and not((phase = "000") or (phase = "110"))) then rand := to_integer(unsigned(RandomNumber)); gators := x"0000"; gators(rand) := '1'; end if; if (count = "01" and phase = "111" ) then rand := to_integer(unsigned(RandomNumber)); gators(rand) := '1'; end if; if (count = "10" and not((phase = "000") or (phase = "110") or (phase = "001")) ) then rand := to_integer(unsigned(RandomNumber)); gators(rand) := '1'; end if; for i in 0 to 15 loop if((switch(i) = '1') and (gators(i) = '1') ) then gators(i) := '0'; gamescore := gamescore + 1; end if; end loop; end if; Q <= gators; currentscore <= std_logic_vector(gamescore); Score <= currentscore; count := count + 1; end if; end process; end Behavioral;