项目四秒表设计实验报告
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
“项目四秒表设计”实验报告
专业班级:电子144 姓名:秦慧桦
学号: 2014014273 实验日期:2016.10.13
一、实验目的
1)熟悉并掌握计数器的设计;
2)熟悉数码管的设计;
3)熟悉VHDL语言的分层次设计;
二实验内容:
1)对50MHz晶振进行500000分频,得到100Hz信号;
2)对该100Hz信号进行0-9的循环计数,并用一位数码管显示;
3)在2成功的基础上进行扩展,实现100Hz信号的0-99循环计数,并用两位数码管进行显示;4)扩展内容:计数初值可以设置,计数值可以人为干预;
三、实验结果
1. 对50MHz晶振进行500000分频,得到100Hz信号的程序代码
library ieee;
use ieee.std_logic_1164.All;
use ieee.std_logic_unsigned.All;
use ieee.std_logic_arith.All;
entity div25 is
port(clkin:in std_logic;
clkout:buffer std_logic);
end;
architecture ret1 of div25 is
begin
process(clkin)
variable count:integer range 0 to 249999;
begin
if clkin' event and clkin='1' then
if count<249999 then
count:=count+1;
else
1
count:=0;clkout<=not clkout;
end if;
end if;
end process;
end;
2.对100Hz信号的0-99循环计数程序代码及仿真结果library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity cnt99 is
port (clkout:in std_logic;
gw:out std_logic_vector(3 downto 0);
sw:out std_logic_vector(3 downto 0));
end;
architecture rtl of cnt99 is
begin
process(clkout)
variable num:std_logic_vector (3 downto 0) ;
variable s:std_logic_vector (3 downto 0) ;
begin
if clkout' event and clkout='1' then
if (num<9) then
num:=num+1;
else num:="0000";s:=s+1;
if (s>9) then s:="0000";
end if;
end if ;
end if;
gw<=num;
sw<=s;
end process;
end ;
3 顶层文件的截屏、引脚锁定及实验现象截图,并对实验现象进行分析
实验现象分析:单片机数码管显示从0~99秒的计时。
四、如何实现秒表的倒计时功能?请给出程序及实验结果。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity cntd99 is
port (clkout:in std_logic;
gw:out std_logic_vector(3 downto 0);
sw:out std_logic_vector(3 downto 0));
end;
architecture rtl of cntd99 is
begin
process(clkout)
variable num:std_logic_vector (3 downto 0) ;
variable s:std_logic_vector (3 downto 0) ;
begin
if clkout' event and clkout='1' then
if (num<9) then
num:=num+1;
else num:="0000";s:=s+1;
if (s>9) then s:="0000";
end if;
end if ;
end if;
gw<=9-num;
sw<=9-s;
end process;
end ;
五、实验总结
本次实验是在上次实验的基础上进行的,上次实验中,我们做了0~59的计数,这次我们在原来的基础上增加到99的计数。
要实现0~99的循环计数,首先我们需要对50MHz的频率进行分频,使其到10Hz,满足我们对于0.1s的要求。
之后就是进行数字循环计数和数码管显示。
实验中出现的问题:在设计倒数计时的过程中,想的太过复杂,最后在同学的提醒下,找到了一种更为简单高效的办法。