求VHDL跑马灯程序,要求:1从左到右亮2从右到左亮3两边向中间亮4中间向两...
发布网友
发布时间:2024-03-23 07:32
我来回答
共1个回答
热心网友
时间:2024-03-24 08:00
library ieee;
use ieee.std_logic_1164.all;
entity paoma is
port(clk,reset:in std_logic;
output:out std_logic_vector(7 downto 0));
end entity;
architecture art of paoma is
begin
process(clk,reset)
variable data:std_logic_vector(7 downto 0);
begin
if reset='1' then
data:="00000000";
elsif clk'event and clk='1' then
if data="00000000" then
data:="00000001";
else data:=data(6 downto 0)&data(7);--右到左
(data:=data(0)&data(7 downto 1);)--左到右
end if;
end if;
output<=data;
end process;
end art;
library ieee;
use ieee.std_logic_1164.all;
entity paoma is
port(clk,reset:in std_logic;
output:out std_logic_vector(7 downto 0));
end entity;
architecture art of paoma is
begin
process(clk,reset)
variable data:std_logic_vector(7 downto 0);
begin
if reset='1' then
data:="00000000";
elsif clk'event and clk='1' then
if data="00000000" then
data:="00011000" ;中间到两边
(data:="10000001";)-两边到中间
else
data:="data(6 downto 4)&data(7)&data(0)&data(3 downto 0);-从中间到两边
(data:="data(4)&data(7 downto 5)&data(2 downto 0)&data(3);)从两边到中间
end if;
end fi;
output<=data;
end process;
end art;