📄 ball.vhd
字号:
--乒乓球灯模块
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ball is
port(clk:in std_logic;--乒乓球灯前进时钟
clr:in std_logic;--乒乓球灯清零
way:in std_logic;--乒乓球灯前进方向
en:in std_logic;--乒乓球灯使能
ballout:out std_logic_vector(7 downto 0));--乒乓球灯
end ball;
architecture ful of ball is
signal lamp:std_logic_vector(9 downto 0);
begin
process(clk,clr,en)
begin
if(clr='1') then--清零
lamp<="1000000001";
elsif en='0' then
elsif (clk'event and clk='1') then--使能允许,乒乓球灯前进时钟上升沿
if(way='1') then--乒乓球灯右移
lamp(9 downto 1)<=lamp(8 downto 0);
lamp(0)<='0';
else--乒乓球灯左移
lamp(8 downto 0)<=lamp(9 downto 1);
lamp(9)<='0';
end if;
end if;
ballout<=lamp(8 downto 1);
end process;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -