EDA实验报告60S电子闹钟

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

EDA实验报告
题目 60秒电子闹钟
学院电子工程学院
专业
学生姓名
导师姓名初秀琴
一功能描述
电路上电后自动计时,到达预置的闹响时刻后,由扬声器发出音乐报警。

闹响时刻可利用DIP开关设置,两位数:0~59。

二设计思路
电路主要由分频器、M60计数器、闹铃电路、显示电路等部分组成。

秒信号脉冲可由分频器产生,用DIP开关设置闹响时刻,当M60计数器的输出与设置的闹响时刻相等时,闹铃电路输出脉冲驱动扬声器发出音乐报警。

总体设计思路如图1所示:
图1 总体设计思路
三功能模块
1 分频器
程序代码如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity devide is
port(
clk :in std_logic; --输入时钟
clk_out :out std_logic --输出信号
);
end devide;
architecture arc_devide of devide is
signal count:std_logic_vector (14 downto 0); --定义内部信号
begin
process
begin
wait until clk'event and clk='1';
if(count<32767)then --改变最大计数值即可得到不同的分频系数count<=count+1;
clk_out<='1';
end if;
end process;
end architecture arc_devide;
符号图如图2所示:
图2 分频器符号图
2 M60计数器
程序代码如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity bcd_m60 is
port (
CLK :in std_logic;
EN :in std_logic;
CR :in std_logic;
QL,QH :out std_logic_vector(3 downto 0) --8421BCD码个位、十位输出
);
end bcd_m60;
architecture behav of bcd_m60 is
signal couL,couH:std_logic_vector(3 downto 0);
begin
process(CR,CLK)
begin
if CR='0' then --异步复位
couL<="0000";
couH<="0000";
elsif clk'event and clk='1' then
if EN='1' then
if (couL=9 and couH=5) then --个位计到9十位计到5回零
couL<="0000";
couH<="0000";
elsif couL=9 then --个位计到9回零十位加1
couL<="0000";
couH<=couH+1;
else
couL<=couL+1; --否则个位加1
end if;
end if;
end if;
end process;
QL<=couL;
QH<=couH;
end behav;
符号图如图3所示:
图3 M60计数器符号图
仿真波形如图4所示:
图4 M60计数器仿真波形
经分析,M60计数器仿真波形正确。

3 闹铃电路
程序代码如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity alert is
port (
STOP :in std_logic; --控制是否响铃
CLK :in std_logic;
DIPL,DIPH :in std_logic_vector(3 downto 0);
QL,QH :in std_logic_vector(3 downto 0);
SPEAK :out std_logic
);
end alert;
architecture behav of alert is
begin
process(STOP,CLK,QL,QH)
begin
if STOP='0' then
SPEAK<='0';
elsif QL=DIPL and QH=DIPH then --输出脉冲驱动扬声器SPEAK<=CLK;
end if;
end process;
end behav;
符号图如图5所示:
图5 闹铃电路符号图4 显示电路
程序代码如下:
library ieee;
use ieee.std_logic_1164.all;
entity seg7 is
port(dat:in std_logic_vector(3 downto 0);
a,b,c,d,e,f,g:out std_logic);
end seg7;
architecture arc of seg7 is
signal tmp:std_logic_vector(6 downto 0);
begin
process(dat)
begin
case dat is
when "0000"=> tmp <="0111111";
when "0001"=> tmp <="0000110";
when "0010"=> tmp <="1011011";
when "0011"=> tmp <="1001111";
when "0100"=> tmp <="1100110";
when "0101"=> tmp <="1101101";
when "0110"=> tmp <="1111101";
when "0111"=> tmp <="0000111";
when "1000"=> tmp <="1111111";
when "1001"=> tmp <="1101111";
when "1010"=> tmp <="1110111";
when "1011"=> tmp <="1111100";
when "1100"=> tmp <="0111001";
when "1101"=> tmp <="1011110";
when "1110"=> tmp <="1111001";
when "1111"=> tmp <="1110001";
when others =>null;
end case;
end process;
a<=tmp(6);
b<=tmp(5);
c<=tmp(4);
d<=tmp(3);
e<=tmp(2);
f<=tmp(1);
g<=tmp(0);
end arc;
符号图如图6所示:
图6 显示电路符号图
四总体仿真
顶层文件原理图如图7所示:
图7 顶层文件原理图仿真波形如图8所示:
如图8所示,当M60计数器计数与置入时刻相等时,SPEAKOUT为脉冲,驱动扬声器发声,从而实现报警。

五心得体会
学习quartus II 的使用花了相当长的时间,虽然最后做出来的电路比较简单,但感觉很有成就感,因为这是我慢慢摸索得到的成果。

相关文档
最新文档