⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newpositions.vhd

📁 这个是国外大学的项目代码
💻 VHD
字号:
------------------------------------------------------------------------
--  new_positions.vhd -- 
------------------------------------------------------------------------
--  Authors : Albert Zemba & Mihai Cucicea
------------------------------------------------------------------------
-- Software version: Xilinx ISE 7.1i 
--                   WebPack
------------------------------------------------------------------------
-- This source file contains the new_positions component
------------------------------------------------------------------------
--  Behavioral description
-- 	Returns the new position(NR, NC) of the player in the rom_labirint
--  relative to the key pressed
------------------------------------------------------------------------
library IEEE;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity new_positions is
	port(	clk:in std_logic;
			R,C:in std_logic_vector (5 downto 0);
			key:in std_logic_vector (7 downto 0);
			RDY:in std_logic;
			NR,NC:out std_logic_vector (5 downto 0);
			new_c:out std_logic);
end new_positions;

architecture Behavioral of new_positions is

begin

	process (clk)
	variable o:std_logic:='0';
	begin
		if (clk'event and clk='1') then
			o:='0';
			if (RDY = '1') then
				if (key =	"01110101") then --up (75)
					NR<=R-1;
					NC<=C;
					o:='1';
				end if;	
				if (key =	"01101011") then --left (6B)
					NR<=R;
					NC<=C-1;
					o:='1';
				end if;	
				if (key =	"01110010") then --down	(72)
					NR<=R+1;
					NC<=C;
					o:='1';
				end if;	
				if (key =	"01110100") then --right (74)
					NR<=R;
					NC<=C+1;
					o:='1';
				end if;
			end if;
		end if;
		new_c<=o;	--determins if there are new positions 
	end process;

end Behavioral;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -