EDA课程设计数字时钟 - 图文

更新时间:2023-10-06 12:07:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

序号

优秀( )良好( ) 综合成绩 中等( )及格( ) 不及格( ) 教师(签名) 批改日期

《EDA技术》课程设计报告

课题: 数字电子钟逻辑电路设计

院系 电子与电气工程学院 专业 电气工程及其自动化 班级 学号

姓名

指导教师 杨银贤、王文杰、叶晓婷、王晓辉

起止日期 2014-12-18至2014-12-19

2014年 12 月

目录

一、课程设计任务及要求............................................................................................ 1

1.1实验目的.......................................................................................................... 1 1.2功能设计.......................................................................................................... 1 二、整体设计思想........................................................................................................ 1

2.1性能指标及功能设计...................................................................................... 1 2.2总体方框.......................................................................................................... 2 2.3FPGA芯片介绍 ............................................................................................... 2 三、编译与调试............................................................................................................ 3

3.1数字钟的基本工作原理:.............................................................................. 3

3.1.1调时、调分信号的产生....................................................................... 3 3.1.2计数显示电路....................................................................................... 4 3.2设计思路.......................................................................................................... 4 3.3设计步骤.......................................................................................................... 5

3.3.1工程建立及存盘................................................................................... 5 3.3.2工程项目的编译................................................................................... 5 3.3.3时序仿真............................................................................................... 6 3.3.4引脚锁定............................................................................................... 6 3.3.5硬件测试............................................................................................. 6 3.3.6实验结果............................................................................................... 7

四、程序设计................................................................................................................ 8 五、实验电路图.......................................................................................................... 16

5.1实验原理图.................................................................................................... 16 5.2 PCB图 ................................................................................ 16 六、心得体会.............................................................................................................. 17 七、 参考文献............................................................................................................ 18

一、课程设计任务及要求

1.1实验目的

1)掌握VHDL语言的基本运用

2)掌握QuartusII的简单操作并会使用EDA实验箱 3)掌握一个基本EDA课程设计的操作

1.2功能设计

要求显示格式为小时-分钟-秒钟,整点报时,报时时间为5 秒,即从整点前5 秒钟开始进行报时提示,LED 开始闪烁,过整点后,停止闪烁。调整时间的按键用按键模块的S1 和S2,S1 调节小时,每按下一次,小时增加一个小时,S2 调整分钟,每按下一次,分钟增加一分钟。另外用S8 按键作为系统时钟复位,复位后全部显示00-00-00。

二、整体设计思想

2.1性能指标及功能设计

1)时、分、秒计时器

时计时器为一个24进制计数器,分、秒计时器均为60进制计数器。当秒计时器接受到一个秒脉冲时,秒计数器开始从00计数到59,此时秒显示器将显示00、01、02、...、59、00;每当秒计数器数到00时,就会产生一个脉冲输出送至分计时器,此时分计数器数值在原有基础上加1,其显示器将显示00、01、02、...、59、00;每当分计数器数到00时,就会产生一个脉冲输出送至时计时器,此时时计数器数值在原有基础上加1,其显示器将显示00、01、02、...、23、00。 2)校时电路

当开关拨至校时档时,电子钟秒计时工作,通过时、分校时开关分别对时、分进行校对,开关每按1次,与开关对应的时或分计数器加1,当调至需要的时与分时,拨动reset开关,电子钟从设置的时间开始往后计时。

1

2.2总体方框

2.3FPGA芯片介绍

SOPC-NIOSII EDA/SOPC实验开发系统是根据现代电子发展的方向,集EDA和SOPC系统开发为一体的综合性实验开发系统,除了满足高校专、本科生和研究生的SOPC教学实验开发之外,也是电子设计和电子项目开发的理想工具。整个开发系统由核心板SOPC-NiosII-EP2C35、系统板和扩展板构成,根据用户不同的需求配置成不同的开发系统。

SOPC-NiosII-EP2C35开发板是在经过长期用户需求考察后,结合目前市面上以及实际应用需要,同时兼顾入门学生以及资深开发工程师的应用需求而研发的。就资源而言,它已经可以组成一个高性能的嵌入式系统,可以运行目前流行的RTOS,如uC/OS、uClinux等。系统主芯片采用672引脚、BGA封装的EP2C35 FPGA,它拥有33216个LE,105个M4K片上RAM(共计483840bits),35个18×18硬件乘法器、4个高性能PLL以及多达475个用户自定义IO。板上提供了大容量的SRAM、SDRAM和Flash ROM等以及常用的RS-232、USB2.0、 RJ45接口和标准音频接口等,除去板上已经固定连接的IO,还有多达260个IO通过不同的接插件引出,供用户使用。所以,不管从性能上而言,还是从系统灵活性上而言,无论您是初学者,还是资深硬件工程师,它都会成为您的好帮手。如图2.3所示:

2

图2.3FPGA系统功能框图

三、编译与调试

3.1数字钟的基本工作原理:

3.1.1调时、调分信号的产生

由计数器的计数过程可知,正常计数时,当秒计数器(60进制)计数到59 时,再来一个脉冲,则秒计数器清零,重新开始新一轮的计数,而进位则作为分计数器的计数脉冲,使分计数器计数加1。现在我们把电路稍做变动:把秒计数器的进位脉冲和一个频率为2Hz的脉冲信号同时接到一个2选1数据选择器的两个数据输入端,而位选信号则接一个脉冲按键开关,当按键开关不按下去时(即为0),则数据选择器将秒计数器的进位脉冲送到分计数器,此时,数字钟正常工作;当按键开关按下去时(即为1),则数据选择器将另外一个2Hz 的信号作为分计数器的计数脉冲,使其计数频率加快,当达到正确时间时,松开按键开关,从而达到调时的目的。调节小时的时间也一样的实现。

3

end if;

end process; end fun;

(2)秒计数器(miao)仿真波形图

(3)秒计数器(miao)仿真分析

1、随着 clk 脉冲信号的不断到来,countmiao 记录出 clk 的脉冲个数,计数 到 59 时,在下一个 clk 脉冲信号到来时,输出端 enfen 输出高定平,即向分进 位,同时 countmiao 清零。 2、 reset 为清零端, reset 低电平时, 当 countmiao 计数从零重新开始计数。 3、setfen 为分的手动进位端,当 setfen 高定平时且 clk 脉冲到来时,输出 enfen 高电平,向分进位。 2. (1)分计数器(fen)VHDL 程序描述

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity fen is port(

imiao,clk,reset,setshi:in std_logic; enshi:out std_logic;

countfen:out std_logic_vector(7 downto 0) );

end fen;

architecture fun of fen is signal enshi_1,enshi_2:std_logic; signal count:std_logic_vector(7 downto 0); begin

countfen<=count; enshi_2<=(setshi and clk); enshi<=(enshi_1 or enshi_2); process(imiao,reset,setshi) begin

if(reset='0') then count<=\

elsif(imiao'event and imiao='1') then if(count(3 downto 0)=\ if(count<16#60#) then if(count=\

9

count<=\ enshi_1<='1';

else count<=count+7;

end if; else count<=\ end if;

elsif(count<16#60#) then count<=count+1; enshi_1<='0';

else count<=\ end if; end if;

end process; end fun;

(2)分计数器(fen)仿真波形图

(3)分计数器(fen)仿真分析

1、imiao 为秒计数器的 enfen 进位输出端,当 enfen(imiao)高电平到来 时, clk 高电平时, 且 countfen 开始计数。 countfen 计数到 59 时, 下一个 enfen (imiao)、clk 到来时,enshi 高电平,即向时进位,同时 countfen 清零。 2、reset 为清零端,当 reset 低电平时,countfen 计数从零重新开始计数。 3、setshi 为时的手动进位端,当 setshi 高定平时且 clk 脉冲到来时,输出 en 时高电平,向时进位。

3.(1)时计数器(shi)VHDL 程序描述

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all; entity shi is port(

ifen,reset:in std_logic;

countshi:out std_logic_vector(7 downto 0) ); end shi;

architecture fun of shi is

signal count:std_logic_vector(7 downto 0);

10

begin countshi<=count; process(ifen,reset) begin

if(reset='0') then

count<=\

elsif(ifen'event and ifen='1') then if(count(3 downto 0)=\

if(count<16#23#) then count<=count+7; else count<=\ end if;

elsif(count<16#23#) then count<=count+1;

else count<=\ end if; end if; end process; end fun;

(2)时计数器(shi)仿真扫描显示译码器(saomiao)仿真

(3)时计数器(shi)仿真分析

1、ifen 为分计数器的 enshi 进位输出端,当 enshi(ifen)为高电平时, countshi 计数。countshi 计数到 23 时,当下一个 enshi(ifen)、clk 到来时, countshi 会自动清零。 2、reset 为清零端,当 reset 低电平时,countfen 计数从零重新开始计数。 4.整点报时

(1)整点报时器(baoshi)VHDL 程序描述

library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; Entity baoshi is

port( clk:in std_logic; inputmiao,inputfen:in std_logic_vector(6 downto 0);

output:out std_logic_vector(1 downto 0) ); end baoshi;

11

architecture fun of baoshi is signal temp:std_logic_vector(1 downto 0); signal nummiao,numfen:std_logic_vector(7 downto 0); begin nummiao<=inputmiao; numfen<=inputfen; output<=temp;

process(clk,temp) begin if(clk'event and clk='1') then if(numfen=\ case nummiao is

when\ when\ when others=>temp<=\ end case; end if;

if(numfen=\

case nummiao is when\ when others=>temp<=\ end case; end if; end if; end process; end fun; 11

(2)整点报时器(baoshi)仿真波形图

(3)整点报时器(baoshi)仿真分析

input 为分计数器的输出端,当输出 58、59 和 00(十六进制)时,整点报 时器(baoshi)的输出端 output 为高电平,点亮 LED 灯。当 intput 为 58、59 时,点亮一个 LED 灯,当 input 为 00 时,点亮两个 LED 灯。其他情况时,LED 灯均不发光。

4. (1)分频器(fenpin)设计

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all; entity fenpin is

12

port( clk_5M:in std_logic; clk:out std_logic ); end fenpin;

architecture fun of fenpin is signal count:std_logic_vector(22 downto 0); begin

process(clk_5M) begin

if (clk_5M'event and clk_5M='1') then

if(count=\ count<=\ clk<='1';

else count<= count+1; clk<='0'; end if; end if;

end process; end fun;

5. (1)扫描显示译码器(saomiao))VHDL 程序描述

扫描显示译码器是用来显示时钟数值的装置,将数字时钟的高低电平信号用 数码管的数值显示出来。八个数码管中,用六个数码管显示时、分和秒,另外两 个可做为时和分、分和秒之间的间隔,始终不显示。 首先对八个数码管进行扫描,每一时刻都只有一个数码管处于扫描状态,并 将此时的数字时钟的高低电平通过十六进制的 BCD 码转换为数码管显示数值。

library ieee;

use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity saomiao is port(

clk_smxs:in std_logic;

shi:in std_logic_vector(7 downto 0); fen:in std_logic_vector(7 downto 0); miao:in std_logic_vector(7 downto 0); selout:out std_logic_vector(7 downto 0); segout:out std_logic_vector(6 downto 0) ); end saomiao;

architecture fun of saomiao is

signal temp:std_logic_vector(2 downto 0); signal seg:std_logic_vector(6 downto 0); signal sel:std_logic_vector(7 downto 0); begin

selout<=sel; segout<=seg;

13

本文来源:https://www.bwwdw.com/article/nrgd.html

Top