北邮数电实验走马灯预习
![preview](https://dl-preview.csdnimg.cn/19386743/0001-5ab104cb3344a7143cfe37b68ce85d30_thumbnail-wide.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
北邮数电实验走马灯预习 一、实验名称与任务要求 本实验的名称是发光二极管走马灯电路设计与实现,任务要求是设计并实现一个控制16个发光二极管亮灭的电路,仿真验证其功能,并下载到实验板测试。实验任务可以分为三个部分:单点移动模式、幕布式模式和按键切换模式。 二、单点移动模式 在单点移动模式中,要求从左至右依次循环点亮16个发光二极管,每个发光二极管的点亮时间为0.5秒。这需要设计一个计数器来控制发光二极管的亮灭。 三、幕布式模式 在幕布式模式中,要求从中间两个发光二极管开始点亮,向两边每次增加点亮2个发光二极管,直至点亮16个发光二极管;然后再从两边开始每次灭掉2个发光二极管,直至所有发光二极管灭掉,依次往复,每个状态持续时间为0.5秒。 四、按键切换模式 在按键切换模式中,要求使用按键来切换单点移动模式和幕布式模式,需要设计一个防抖动电路来实现按键的按下和释放。 五、模块划分及总体框图 整个电路可以分为四个模块:分频器、计数器、按键消抖电路和译码电路。总体框图如下: 按键消抖分频器译码电路计数器 六、VHDL代码 VLC代码共有四个模块:分频器、计数器、按键消抖电路和译码电路。 1. 分频器VHDL代码: Library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; entity l is port(clk:in std_logic; clk_out:out std_logic); end l; architecture gg of l is signal tmp: integer range 0 to 24; signal clktmp: std_logic; begin process (clk) begin if clk'event and clk='1' then if tmp=24 then tmp<=0; clktmp<=not clktmp; else tmp<=tmp+1; end if; end if; end process; clk_out<=clktmp; end gg; 2. 计数器VHDL代码: LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_SIGNED.ALL; ENTITY s IS PORT(clk:in STD_LOGIC; y :OUT STD_LOGIC_VECTOR(3 downto 0)); END s; ARCHITECTURE one of s is signal q:STD_LOGIC_VECTOR(3 downto 0); begin process(clk) begin if (clk'EVENT and clk = '1') then if q="1111" then q<="0000"; else q<=q+1; end if; end if; y<=q; end process; end one; 3. 按键消抖电路VHDL代码: library ieee; use ieee.std_logic_1164.all; entity xd is port(clk:in std_logic; input:in std_logic; output:out std_logic); end xd; architecture one of xd is signal a:std_logic; signal count:integer range 0 to 9; begin process (clk) begin if input='0' then count<=0; elsif clk'event and clk='1' then if count=8 then count<=count; else count<=count+1; end if; end if; --for elsif if count=8 then a<='1'; else a<='0'; end if; end process; output<=a; end one; 4. 译码电路VHDL代码: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity horse is port(zt:STD_LOGIC_VECTOR(3 downto 0); sel:in std_logic; output:out std_logic_vector(15 downto 0)); end horse; architecture gg of horse is signal t: std_logic; begin process(zt,sel) begin if sel'event and sel='1' then t<=not t ; end if; if t='0' then case zt is when "0000"=> output<="1000000000000000"; when "0001"=> output<="01000000"; ... end case; end if; end process; end gg; 七、实验总结 本实验的目的是设计并实现一个控制16个发光二极管亮灭的电路,仿真验证其功能,并下载到实验板测试。实验中需要设计四个模块:分频器、计数器、按键消抖电路和译码电路,并使用VHDL语言编写对应的代码。
![](https://csdnimg.cn/release/download_crawler_static/19386743/bg1.jpg)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![avatar](https://profile-avatar.csdnimg.cn/2a27758dbfed447499774c0c3f646e80_qq_52474706.jpg!1)
- 粉丝: 0
- 资源: 5
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)
评论0