📄 char_generator.vhd
字号:
------------------------------------------------------------------------
-- char_generator.vhd --
------------------------------------------------------------------------
-- Authors : Albert Zemba & Mihai Cucicea
------------------------------------------------------------------------
-- Software version: Xilinx ISE 7.1i
-- WebPack
------------------------------------------------------------------------
-- This source file contains the char_generator component
------------------------------------------------------------------------
-- Behavioral description
-- The main view of this component is that at a certain position,
-- defined by pixel_row, pixel_col(the pixel coordinates on vga)
-- it returns the RBG which is transmitted to the vga(640x480 pixels)
-- Each of the "rom_char" components (16x16 pixels) returns an RGB,
-- and the correct one is selected with char
-- The mux8_1_3bits uses only 4 of 8 inputs the other ones
-- are left for later developement (more characters)
------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity char_generator is
port(
posR, posC: in std_logic_vector(5 downto 0);
char:in std_logic_vector(2 downto 0);
pixel_row,pixel_col:in std_logic_vector(9 downto 0);
RGB:out std_logic_vector (2 downto 0)
);
end char_generator;
architecture Behavioral of char_generator is
------------------------------------------------------------------------
-- A representation of a door
------------------------------------------------------------------------
component rom_door_char is
port(line, col : in std_logic_vector(3 downto 0);
color : out std_logic_vector(2 downto 0)
);
end component rom_door_char;
------------------------------------------------------------------------
-- A representation of an empty spot(black on vga)
------------------------------------------------------------------------
component rom_empty_char is
port(line, col : in std_logic_vector(3 downto 0);
color : out std_logic_vector(2 downto 0)
);
end component rom_empty_char;
------------------------------------------------------------------------
-- A representation of wall
------------------------------------------------------------------------
component rom_wall_char is
port(line, col : in std_logic_vector(3 downto 0);
color : out std_logic_vector(2 downto 0)
);
end component rom_wall_char;
------------------------------------------------------------------------
-- A representation of the actual player(a happy face on vga)
------------------------------------------------------------------------
component rom_human_char is
port(line, col : in std_logic_vector(3 downto 0);
color : out std_logic_vector(2 downto 0)
);
end component rom_human_char;
------------------------------------------------------------------------
-- The mux
------------------------------------------------------------------------
component mux8_1_3bits is
port(a,b,c,d,e,f,g,h:in std_logic_vector(2 downto 0);
s:in std_logic_vector(2 downto 0);
o:out std_logic_vector(2 downto 0)
);
end component mux8_1_3bits;
signal p_r_mod8,p_c_mod8:std_logic_vector(3 downto 0);
signal s_mux,empty_out,full_out:std_logic_vector(2 downto 0);
signal people_out,door_out:std_logic_vector(2 downto 0);
begin
empty : rom_empty_char
port map (line=>p_r_mod8, col=>p_c_mod8, color=>empty_out);
wall : rom_wall_char
port map (line=>p_r_mod8, col=>p_c_mod8, color=>full_out);
human : rom_human_char
port map (line=>p_r_mod8, col=>p_c_mod8, color=>people_out);
door : rom_door_char
port map (line=>p_r_mod8, col=>p_c_mod8, color=>door_out);
mux : mux8_1_3bits port map (a=>empty_out, b=>full_out,
c=>door_out, d=>people_out, e=>"000",
f=>"000", g=>"000", h=>"000", s=>s_mux, o=>RGB
);
process (pixel_row,pixel_col)
variable p_r_div8,p_c_div8:std_logic_vector(6 downto 0);
begin
------------------------------------------------------------------------
-- Because each character is 16x16 pixels, the current pixel
-- in a character is determined by (pixel_row mod 16, pixel_col mod 16)
------------------------------------------------------------------------
p_r_mod8 <=
conv_std_logic_vector(conv_integer(pixel_row) mod 16,4);
p_c_mod8 <=
conv_std_logic_vector(conv_integer(pixel_col) mod 16,4);
p_r_div8 :=
conv_std_logic_vector(conv_integer(pixel_row) / 16,7);
p_c_div8 :=
conv_std_logic_vector(conv_integer(pixel_col) / 16,7);
------------------------------------------------------------------------
-- if posR, posC (the current position of the player) corespond
-- to the current pixel position, than the rom_human_char is
-- selected on mux
------------------------------------------------------------------------
if ((p_r_div8=posR) and (p_c_div8=posC)) then s_mux<="011";
else s_mux<=char;
end if;
end process;
end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -