rom_labirint.vhd

来自「这个是国外大学的项目代码」· VHDL 代码 · 共 191 行

VHD
191
字号
------------------------------------------------------------------------
--  rom_labirint.vhd -- 
------------------------------------------------------------------------
--  Authors : Albert Zemba & Mihai Cucicea
------------------------------------------------------------------------
-- Software version: Xilinx ISE 7.1i 
--                   WebPack
------------------------------------------------------------------------
-- This source file contains the rom_labirint component
------------------------------------------------------------------------
--  Behavioral description
-- It works like a matrix with the indexes row and col 
-- The selected element is the character(the code of the character) 
-- to be generated
-- The matrix represents the labirinth map formed by 
-- 16x16 pixels characters
-- The vga is viewed at 640x480 pixel resolution, wich means we'll have
-- 40x30 characters(each 16x16 pixels) 
------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity rom_labirint is
	port(row, col : in std_logic_vector(5 downto 0);
			char : out std_logic_vector(2 downto 0)
	);
end rom_labirint;

architecture Behavioral of rom_labirint is

type matrice is array(0 to 39) of std_logic_vector(2 downto 0);
type memorie is array (0 to 29) of matrice; 
constant mem : memorie :=
	(  ("001","001","001","001","001","001","001","001","001","001",
			"001","001","001","001","001","001","001","001","001","001",
			"001","001","001","001","001","001","001","001","001","001",
			"001","001","001","001","001","001","001","001","001","001"),    

		("001","000","000","000","001","000","000","000","001","000",
			"000","000","001","000","000","000","001","000","000","000",
			"001","000","000","000","000","000","000","000","000","001",
			"000","000","000","000","000","001","001","001","001","001"),

		("001","001","001","000","001","000","001","000","001","000",
			"001","000","001","000","001","000","001","000","001","000",
			"000","000","000","001","000","000","000","000","001","001",
			"000","000","000","001","000","001","001","001","001","001"),

		("001","000","000","000","000","000","001","000","001","000",
			"001","000","001","000","001","000","001","000","001","000",
			"000","000","000","000","001","001","000","000","000","000",
			"001","000","000","000","000","001","001","001","001","001"),

		("001","000","000","000","000","000","001","000","000","000",
			"001","000","000","000","001","000","000","000","001","001",
			"001","000","000","000","000","000","000","001","000","001",
			"000","000","001","000","000","001","001","001","001","001"),

		("001","001","000","000","001","001","001","001","001","000",
			"001","001","001","001","001","001","001","001","001","000",
			"000","000","001","001","000","000","000","000","000","000",
			"000","000","001","000","000","001","001","001","001","001"),
		
		("001","001","000","000","000","000","000","000","000","000",
			"000","000","000","000","000","001","000","000","001","000",
			"001","000","000","000","000","001","000","001","001","000",
			"000","001","000","001","001","001","001","001","001","001"),

		("001","001","000","001","001","001","001","001","000","001",
			"001","001","001","001","001","001","001","000","001","000",
			"000","000","000","001","000","001","000","000","000","001",
			"000","000","000","000","000","001","000","001","000","001"),

		("001","001","000","000","001","000","001","000","000","000",
			"000","000","000","001","000","000","000","000","001","000",
			"001","000","000","000","000","000","000","000","001","000",
			"000","001","000","001","000","001","001","001","000","001"),

		("001","000","000","000","001","000","001","000","000","000",
			"001","000","000","000","000","001","000","001","001","000",
			"001","000","001","000","001","000","000","000","000","001",
			"000","000","000","001","000","001","000","000","000","001"),

		("001","000","000","001","000","000","000","000","001","000",
			"000","001","000","000","001","001","000","000","001","000",
			"001","000","000","000","001","001","000","001","000","001",
			"000","000","000","001","000","000","000","000","001","001"),

		("001","000","000","000","000","000","001","001","000","001",
			"000","001","001","000","000","001","000","000","000","000",
			"000","001","000","001","001","001","000","001","000","000",
			"000","000","000","001","001","001","001","000","000","001"),

		("001","000","001","001","000","000","000","001","000","000",
			"001","001","000","000","000","001","000","001","001","001",
			"001","001","000","001","000","000","000","000","001","001",
			"000","001","001","000","000","000","000","000","000","001"),

		("001","000","000","000","001","000","000","001","000","001",
			"001","000","000","000","001","000","000","000","001","000",
			"000","000","000","001","001","001","001","000","001","000",
			"000","001","000","000","001","000","000","000","001","001"),

		("001","000","000","000","000","000","000","000","000","000",
			"000","001","000","000","000","001","001","001","000","000",
			"000","000","000","000","000","001","000","001","001","001",
			"000","001","000","001","000","000","000","000","000","001"),

		("001","001","001","001","000","001","000","001","001","000",
			"001","001","001","001","001","001","000","000","001","000",
			"000","000","000","000","001","000","001","000","001","000",
			"001","001","001","001","001","000","001","000","000","001"),

		("001","000","000","000","000","000","000","000","000","001",
			"000","000","000","001","000","000","000","000","000","000",
			"000","000","000","000","000","000","000","000","001","000",
			"000","000","000","000","001","000","000","001","001","001"),

		("001","000","000","001","001","001","000","001","001","001",
			"000","001","000","001","001","001","001","001","001","001",
			"001","000","001","000","000","001","000","001","000","001",
			"001","000","001","000","001","000","001","000","000","001"),

		("001","000","000","000","000","000","000","000","000","000",
			"001","000","000","000","000","001","000","000","000","000",
			"000","000","000","000","000","000","000","000","000","000",
			"001","000","001","000","001","000","000","001","000","001"),

   	("001","000","001","001","000","001","001","001","001","001",
			"000","001","000","000","000","001","001","000","000","000",
			"001","000","000","000","000","000","001","000","000","000",
			"001","000","000","000","001","000","000","001","000","001"),

		("001","000","001","001","001","000","000","000","001","000",
			"000","000","000","000","001","000","000","000","000","000",
			"000","000","000","000","000","000","000","001","000","000",
			"000","001","001","001","001","000","000","000","000","001"),

		("001","000","000","000","001","000","000","000","000","000",
			"000","000","001","001","001","001","001","001","001","000",
			"000","000","000","001","000","000","000","000","001","001",
			"001","000","000","001","001","000","001","000","001","001"),

		("001","001","000","000","001","000","001","000","000","001",
			"000","000","001","001","000","000","000","000","001","001",
			"000","001","000","000","001","000","001","000","000","000",
			"000","000","000","000","000","000","000","000","000","001"),

		("001","000","000","000","000","000","000","000","000","000",
			"000","001","001","000","000","001","001","000","000","001",
			"001","000","001","001","000","000","000","001","000","000",
			"001","001","001","001","001","000","000","000","000","001"),

		("001","000","001","000","001","000","000","001","001","001",
			"000","001","000","000","001","001","001","001","000","000",
			"000","001","000","000","000","000","000","000","001","001",
			"000","000","000","000","001","000","001","000","000","001"),

		("001","000","001","001","001","000","000","000","000","001",
			"000","000","000","001","001","000","000","001","001","001",
			"000","001","000","001","001","000","001","000","000","001",
			"000","000","000","000","000","000","001","001","000","001"),

		("001","000","000","000","001","001","000","001","000","000",
			"000","001","001","001","001","000","000","001","000","000",
			"000","000","000","001","000","000","000","001","001","000",
			"000","000","000","001","000","001","000","000","000","001"),

		("001","000","000","000","000","000","000","000","000","000",
			"001","000","000","000","000","000","000","001","000","000",
			"000","001","000","000","001","000","000","000","000","000",
			"001","000","000","000","001","000","000","000","000","001"),

		("001","001","001","001","001","001","001","001","000","000",
			"000","000","000","000","000","001","000","000","000","000",
			"000","000","000","000","000","001","000","001","000","000",
			"000","000","000","000","000","000","000","000","010","001"),

		("001","001","001","001","001","001","001","001","001","001",
			"001","001","001","001","001","001","001","001","001","001",
			"001","001","001","001","001","001","001","001","001","001",
			"001","001","001","001","001","001","001","001","001","001")
	);
 
begin
	char <= mem(conv_integer(row))(conv_integer(col)); 

end Behavioral;

⌨️ 快捷键说明

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