VHDL led闪烁程序 功能没有实现 10
--分频程序,1hz,48Mlibraryieee;useieee.std_logic_1164.all;useieee.std_logic_arith.all;usei...
--分频程序,1hz,48M
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity fenpin is
port(clk:in std_logic;
reset:in std_logic;
clk_out:out std_logic);
end entity;
architecture behave of fenpin is
signal clk_temp:std_logic;
begin
process(clk,reset,clk_temp)
variable cnt1:integer range 0 to 2000;
variable cnt2:integer range 0 to 24000;
begin
clk_out<=clk_temp;
if reset='1' then
cnt1:=0;
cnt2:=0;
elsif clk'event and clk='1' then
if cnt1<=2000 then
cnt1:=cnt1+1;
else
cnt1:=0;
end if;
if cnt2<=24000 then
cnt2:=cnt2+1;
clk_temp<=not clk_temp;
else cnt2:=0;
end if;
end if;
end process;
end behave;
--程序目的是通过一个分频程序让led在复位时全亮,在时钟上升沿以1s闪烁。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity ledshanshuo1s is
port(clk_in:in std_logic; --主时钟输入
reset_in:in std_logic; --复位输入
led:out std_logic_vector(2 downto 0)); --led输出
end entity;
architecture behave of ledshanshuo1s is
signal clk_temp1:std_logic; --分频后时钟连接到clk_temp1
signal led_temp: std_logic_vector(2 downto 0);
component fenpin is
port(clk:in std_logic; --元件声明
reset:in std_logic;
clk_out:out std_logic);
end component;
begin
led<=led_temp;
U1:fenpin port map (clk=>clk_in,reset=>reset_in,clk_out=>clk_temp1);--元件映射
process(reset_in,clk_temp1)
variable cnt:integer range 0 to 2;
begin
if reset_in='0' then --复位到来,全亮
led_temp<="000";
elsif clk_temp1'event and clk_temp1='1' then --时钟上升沿到来LED闪烁
if cnt<=2 then
led_temp<=led_temp(1 downto 0)&'0';
else
led_temp<="001";
cnt:=0;
end if;
end if;
end process;
end behave; 展开
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity fenpin is
port(clk:in std_logic;
reset:in std_logic;
clk_out:out std_logic);
end entity;
architecture behave of fenpin is
signal clk_temp:std_logic;
begin
process(clk,reset,clk_temp)
variable cnt1:integer range 0 to 2000;
variable cnt2:integer range 0 to 24000;
begin
clk_out<=clk_temp;
if reset='1' then
cnt1:=0;
cnt2:=0;
elsif clk'event and clk='1' then
if cnt1<=2000 then
cnt1:=cnt1+1;
else
cnt1:=0;
end if;
if cnt2<=24000 then
cnt2:=cnt2+1;
clk_temp<=not clk_temp;
else cnt2:=0;
end if;
end if;
end process;
end behave;
--程序目的是通过一个分频程序让led在复位时全亮,在时钟上升沿以1s闪烁。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity ledshanshuo1s is
port(clk_in:in std_logic; --主时钟输入
reset_in:in std_logic; --复位输入
led:out std_logic_vector(2 downto 0)); --led输出
end entity;
architecture behave of ledshanshuo1s is
signal clk_temp1:std_logic; --分频后时钟连接到clk_temp1
signal led_temp: std_logic_vector(2 downto 0);
component fenpin is
port(clk:in std_logic; --元件声明
reset:in std_logic;
clk_out:out std_logic);
end component;
begin
led<=led_temp;
U1:fenpin port map (clk=>clk_in,reset=>reset_in,clk_out=>clk_temp1);--元件映射
process(reset_in,clk_temp1)
variable cnt:integer range 0 to 2;
begin
if reset_in='0' then --复位到来,全亮
led_temp<="000";
elsif clk_temp1'event and clk_temp1='1' then --时钟上升沿到来LED闪烁
if cnt<=2 then
led_temp<=led_temp(1 downto 0)&'0';
else
led_temp<="001";
cnt:=0;
end if;
end if;
end process;
end behave; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询