if ROM_DATA2=\ imag_RGB<=\ else
imag_RGB<=\ end if; else
imag_RGB<=\ end if; end if; end if; End process;
PROCESS(VS) begin
if (VS'EVENT AND VS= '1') then --以帧同步信号作为工作时钟 if(pause='1')then
if(movedown='0')then--图像块下移
if(imag_Y + imag_height = \刚好移到下边沿,imag_Y + imag_height = 480
movedown<='1'; --移动方向改为向上 imag_Y<=imag_Y - V_Step;--向上移动“V_Step”个点
elsif(imag_Y + imag_height + V_Step > \超过下边沿,imag_Y + imag_height > 480
imag_Y<=\移动到下边沿 else
imag_Y<=imag_Y + V_Step; --向下移动“V_Step”个点 end if;
ELSE--图像块上移
if(imag_Y = \刚好移到上边沿,imag_Y = 0 movedown<='0';--移动方向改为向下
imag_Y<=\向下移动“V_Step”个点 elsif(imag_Y < V_Step)then--超过上边沿 imag_Y<=\移动到上边沿 else
imag_Y<=imag_Y - V_Step; end if; end if;
if(moveright='0')then--图像块右移
if(imag_X + imag_width = \刚好移到右边沿 moveright<='1';--移动方向改为向左
imag_X<=imag_X - H_Step;--向左移动“H_Step”个点
15
elsif(imag_X + imag_width + H_Step > \超过右边沿 imag_X<=\移动到右边沿 else
imag_X<=imag_X+ H_Step;--向右移动“H_Step”个点 end if;
ELSE--图像块左移
if(imag_X = \刚好移到左边沿 moveright<='0';--移动方向改为向右
imag_X<=\向右移动“H_Step”个点 elsif(imag_X < H_Step)then--超过左边沿 imag_X<=\移动到左边沿 else
imag_X<=imag_X - H_Step; end if; end if; end if; end if; End process;
END imagController_architecture;
“Keyboard_Manage”模块
LIBRARY ieee;
USE ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all;
ENTITY Keyboard_Manage IS PORT (
clk : IN STD_LOGIC;
Key : IN STD_LOGIC_VECTOR(4 downto 0);--按键值 KEY_State : IN STD_LOGIC;--按键指示
H_Step,V_Step : buffer STD_LOGIC_VECTOR(3 downto 0);--水平(垂直)移动点数 Pause : buffer STD_LOGIC;--0暂停(1移动)
SEL : out STD_LOGIC_VECTOR(1 downto 0)--四个图像ROM选通信号 );
END Keyboard_Manage;
ARCHITECTURE Keyboard_Manage_architecture OF Keyboard_Manage IS
16
signal LAST_KEY_State : std_logic; --上一刻的按键状态 BEGIN
process(clk) begin
if rising_edge(clk) then
LAST_KEY_State<=KEY_State;--存储上一刻的按键状态
if(KEY_State='1' and LAST_KEY_State='0') then--键盘按下时读取键值 case key is
when \按键“2”,增大垂直移动速度V_Step if(V_Step < 15)then
V_Step<=V_Step + 1; end if;
when \按键“8”,减小垂直移动速度V_Step if(V_Step > 0)then
V_Step<=V_Step - 1; end if;
when \按键“6”,增大水平移动速度H_Step if(H_Step < 15)then H_Step<=H_Step + 1; end if;
when \按键“4”,减小水平移动速度H_Step if(H_Step > 0)then H_Step<=H_Step - 1; end if;
when \按键“*”,暂停(继续),Pause取反 pause<='0';
pause<= not pause;
when \按键“#”,恢复设置 pause<='0';
V_Step<=(others=>'0'); H_Step<=(others=>'0'); SEL<=\
when \按键“A”,选第一副图片 SEL<=\
when \按键“B”,选第二副图片 SEL<=\
when \按键“C”,选第三副图片 SEL<=\
when \按键“D”,选第四副图片 SEL<=\ when others => null; end case; end if; end if; end process;
END Keyboard_Manage_architecture;
17