- 1、本文档共9页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
百进制计数器
正文:
设计要求:在数码管上实现0-99的递增与递减循环计数。
设计目的:通过实验更透彻的掌握编写程序的能力,并且拓展VHDL语言的应用。
设计原理:
硬件要求:主芯片EMP240T100C5, 1个拨码开关,数码管
设计步骤:
使用Quartus Ⅱ 新建一个工程ybjz, 输入源程序后,进行编译。
进行仿真测试。
进行引脚分配:
下载结果到EMP240开发板,以及通过数码管验证结果是否正确。
原理图:
源程序:
-------------库---------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
-------------实体--------------
entity ybjz2 is
port(clk:in std_logic;
reset:in std_logic;------加法,减法计数的控制---------
dis:out std_logic_vector(6 downto 0)---数码管的段选--
r:out std_logic_vector(5 downto 0));--数码管的位选--
end ybjz2;
-------------结构体-------------
architecture one of ybjz2 is
signal m,n,z:integer range 0 to 9;
signal clk1:std_logic;
signal clk2:std_logic;
signal led:integer range 0 to 5;
begin
-------------1000分频与100分频程序-------------
process(clk)
variable cnt1:integer range 0 to 25000;
variable cnt2:integer range 0 to 1000;
begin
if rising_edge(clk) then
if cnt1=25000 then
cnt1:=0;
clk1=not clk1;
if cnt2=1000 then
cnt2:=0;
clk2=not clk2;
else
cnt2:=cnt2+1;
end if;
else
cnt1:=cnt1+1;
end if;
end if;
end process;
--------------计数---------------
process (clk2,reset)
begin
if clk2event and clk2=1 then
if reset=1 then
if m=9 then
m=0;
if n=9 then
n=0;
else
n=n+1;
end if;
else
m=m+1;
end if;
end if;
if reset=0 then
if m=0 then
m=9;
if n=0 then
n=9;
else
n=n-1;
end if;
else
m=m-1;
end if;
end if;
end if;
end process;
--------------数码管地址扫描--------------
process(clk1)
begin
if rising_edge(clk1) then
if led=1 then
led=0;
else
led=led+1;
end if;
end if;
end process;
--------------选择--------------
process(clk1)
begi
文档评论(0)