呵呵,今天比较忙,所以废话不多说了,干活吧。
按我个人感觉这么多个模块中控制led灯的模块应该最简单,因为电路简单,却较独立,所以我们就来编一编ledmove.vhd吧
ledmove.vdh:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all; --这里不用说了吧声明相关的库
entity ledmove is --注意这里的名字要和文件名一样哦
port(en,clk:in std_logic; --定义二个输入端口,en为使能端,clk为时钟
leds:out std_logic_vector(7 downto 0) --定义了八个输出端口主要用于控制实验板上的八个led灯
);
end entity ledmove;
architecture archer of ledmove is
type state is (st0,st1,st2,st3,st4,st5,st6,st7,st8,st9); --定义了十个状态,因此此程序很明显就是用状态机的思想编写的
signal current_state,next_state:state; --定义现在状态,将来状态
begin
p1:process(clk,en) --p1为进程,负责每一个时钟信号上升沿就读入新的状态
begin --en使能信号为‘1'的时候电路才输出东西,不然灯就全灭
if clk'event and clk='1' then
if en='1' then
current_state<=next_state;
else
current_state<=st0;
end if ;
end if;
end process p1 ;
p2:process(current_state,en) --辅助进程,用于当前状态得到下一个状态,并每不同状态输出不同信号
begin
if en='1' then
case current_state is --led灯的花式,st0为全灭。
when s
VHDL之基于层次化设计的数字钟(二)【原创】
最新推荐文章于 2025-07-09 15:35:58 发布
本文介绍了使用VHDL进行层次化设计的数字钟中LED显示控制模块的实现。通过状态机设计,实现了LED灯的动态显示效果。在每个时钟上升沿,根据使能信号更新状态,并输出相应的LED灯控制信号。文章提供了详细的代码及仿真结果,以展示九种不同的LED显示状态。

最低0.47元/天 解锁文章
607

被折叠的 条评论
为什么被折叠?



