数字逻辑之数字时钟显示与校时
数字逻辑课程设计报告
设计题目:多功能数字电子钟设计
姓 名:
所学专业: 软件工程
班 级:
指导教师:
日 期:2014.06.26
一.设计内容 4
1.设计要求 4
二.设计方案即总体功能 4
三.各部分具体设计 5
1.显示模块 5
(1).秒部分 5
(2).分钟部分 7
(3)小时部分 9
(4)模八部分 11
(5)八选一部分 12
(6)时钟显示部分 14
2.校时模块 15
(1)按键校正按键的设置 15
(2)按键控制时分秒 17
四.总结 21
(1)具有以24小时制计时的功能。
(2)以24小时显示的功能。
(3)具有校时的功能
(4)设计精度为1S。
设计方案即总体功能
系统输入:系统状态及校时,时钟信号CLK,采用1024HZ,输入信号有按键K1,K2,K3产生,分别用来改变时分秒的大小。
系统输出:七段数码管显示时分秒输出。
时钟CLK需要1HZ,但输入的时钟信号为1024HZ,所以我们用到了分频器来改变频率的大小,达到我们所需要的频率1HZ时才输出。
VHDL程序代码如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity miao is
port (clk,en,clr:in std_logic;
m1,m0:out std_logic_vector(3 downto 0);———m1,m0高低位
co:out std_logic);————co进位
end miao;
architecture m of miao is
signal cnt1,cnt0:std_logic_vector(3 downto 0);
begin
process(clk)
begin
if(clr='0')then
cnt0<="0000";
cnt1<="0000";
elsif(clk'event and clk='1')then
if en='1' then
if cnt1="0101" and cnt0="1001" then 到59时产生进位
co<='1';
cnt0<="0000";
cnt1<="0000";
elsif cnt0<"1001" then
cnt0<=(cnt0+1);
else
cnt0<="0000";
cnt1<=cnt1+1;
co<='0';
end if;
end if;
end if;
m1<=cnt1;
m0<=cnt0;
end process;
end m;
当秒满59时产生一个进位信号,通过CO传给分钟,使得分钟加一。分钟为60进制,分钟到达59时产生进位一,传给时。
生成的器件图如下:
VHDL语言代码如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity fenzhong is
port (clk,en:in std_logic;
f1,f0:out std_logic_vector(3 downto 0);————f1,f0高低位
co:out std_logic);——-CO进位
end fenzhong;
architecture f of fenzhong is
SIGNAL cnt1,cnt0:std_logic_vector(3 downto 0);
begin
process(clk)
begin
if(clk'event and clk='1')then
if en='1' then
if cnt1="0101" and cnt0="1001" then————分钟从00到59,到59时产生进位信号,传给CO
co<='1';
cnt0<="0000";
cnt1<="0000";
elsif cnt0<"1001" then
cnt0<=(cnt0+1);
else
cnt0<="0000";
cnt1<=cnt1+1;
co<='0';
end if;
end if;
end if;
f1<=cnt1;
f0<=cnt0;
end process;
end f;
小时接受分钟传来的进位信号,加一。小时为24进制,所以从00到23循环,23后变为00,以此循环计时。
器件图如下:
VHDL语言代码如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity xiaoshi is
port(clk,en:in std_logic;
a1,a0:out std_logic_vector(3 downto 0));
end xiaoshi;
architecture beha of xiaoshi is
signal cnt1,cnt0:std_logic_vector(3 downto 0);
begin
process(clk)
begin
if(clk'event and clk='1') then
if en='1' then
if cnt1="0010" and cnt0="0011" then--设置从00到23循环
cnt1<="0000";
cnt0<="0000";
elsif cnt0<"1001" then
cnt0<=cnt0+1;
else
cnt0<="0000";
cnt1<=cnt1+1;
end if;
end if;
end if;
a1<=cnt1;
a0<=cnt0;
end process;
end beha;
数码管有八个,我们需要用到6个来显示时间,来达到00—00—00(23—59—59)的效果。所以用到了模八,用来循环时间。此时需要1024HZ的频率,所以直接连接输入的CLK即可。
VHDL语言代码如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity mo8 is
port(clr,clk,en:in std_logic;
y:out std_logic_vector(2 downto 0));
end mo8;
architecture beha of mo8 is
signal p:std_logic_vector(2 downto 0);
begin
process(clk)
begin
if clk'event and clk='1' then
if en='1' then
if p="111" then--设置从0到7循环
p<="000";
elsif p<"111" then
p<=p+1;
end if;
end if;
end if;
y<=p;
end process;
end beha;
八个数码管选择显示
生成的器件图如下:
VHDL语言源代码如下:
library ieee;
use ieee.std_logic_1164.all;
entity mux8_1 is
port(m0,m1,m2,m3,m4,m5,m6,m7:in std_logic_vector(3 downto 0);
sel:in std_logic_vector(2 downto 0);
y:out std_logic_vector(3 downto 0));
end mux8_1;
architecture arc of mux8_1 is
begin
process(sel)
begin
case sel is
when"000"=>y<=m0;---0到7的八个数分别赋给MO到M7
when"001"=>y<=m1;
when"010"=>y<=m2;
when"011"=>y<=m3;
when"100"=>y<=m4;
when"101"=>y<=m5;
when"110"=>y<=m6;
when"111"=>y<=m7;
when others=>y<="XXXX";
end case;
end process;
end arc;
此模块是用来数码管显示数字,七段显示管(abcdefg),
来显示0到9的数字。
VHDL语言代码:
library ieee;
use ieee.std_logic_1164.all;
entity shizhong is
port(num:in std_logic_vector(3 downto 0);
y: out std_logic_vector(6 downto 0));
end shizhong;
architecture beha of shizhong is
begin
process(num)
begin
case num is
when"0000"=>y<="1111110";--0到9对应的显示
when"0001"=>y<="0110000";
when"0010"=>y<="1101101";
when"0011"=>y<="1111001";
when"0100"=>y<="0110011";
when"0101"=>y<="1011011";
when"0110"=>y<="1011111";
when"0111"=>y<="1110000";
when"1000"=>y<="1111111";
when"1001"=>y<="1111011";
when others=>y<="0000001";
end case;
end process;
end beha;
校时模块用来调整时分秒的大小,K1来控制时的调整,按一下,时间增加一,K2,用来调整分钟的大小,按一下加一,K3用来调整秒的大小,按一下秒归0.1)按键校正按键的设置
三个按键的设置,此时需要256HZ的频率,所以用到了分频器来改变频率使其累计达到要求输出。
代码:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity debounce is
port(clk,reset:in std_logic; --256HZ
din:in std_logic;
dout:out std_logic);
end debounce;
architecture a of debounce is
type state is(s0,s1,s2);
signal current:state;
begin
process(clk,reset,din)
begin
if(reset='1')then
current<=s0;
dout<='1';
elsif (clk'event and clk='1')then
case current is
when s0=>dout<='1';
if(din='0')then
current<=s1;
else
current<=s0;
end if;
when s1=>dout<='1';
if(din='0')then
current<=s2;
else
current<=s0;
end if;
when s2=>dout<='0';
if(din='0')then
current<=s2;
else
current<=s0;
end if;
when others=>dout<='1';
current<=s0;
end case;
end if;
end process;
end a;
代码:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity ctr1 is
port(clk:in std_logic; --10HZ
key1,key2,key3,key4:in std_logic;
led1,led2,led3,led4:out std_logic);
end ctr1;
architecture a of ctr1 is
begin
process (clk)
begin
if(clk'event and clk='1')then
if(key1='0')then
led1<='1';led2<='0';led3<='0';led4<='0';--按下为高有效,使得led输出为1,所以用到了非门,使1变为0,让0传给miao的clr.
elsif(key2='0')then
led1<='0';led2<='1';led3<='0';led4<='0';
elsif(key3='0')then
led1<='0';led2<='0';led3<='1';led4<='0';
elsif(key4='0')then
led1<='0';led2<='0';led3<='0';led4<='1';
else
led1<='0';led2<='0';led3<='0';led4<='0';
end if;
end if;
end process;
end a;
四.总结
通过这次课程设计,我们学到了很多东西,总结如下:
1.这次的课程设计加强了我们动手、思考和解决问题的能力,在整个设计过程中,我们通过设计数字时钟,熟练的掌握了24进制,60进制等VHDL程序语言,对硬件语言有了更深刻的理解。
2.搞清楚了一些器件的作用与特点,例如模八,八选一,分频器等,了解了或非门的应用。会按要求和所需的功能连接电路图,继而可以完成完整的顶层图。
3.这次的学习让我们更加明白了团结合作的重要性,在设计电路的时候,我们遇到了一些困难,但是和伙伴们一起讨论,积极思考,就会有思路,就可以找到解决的办法。如果只是自己一个人在那里想总是解决不了问题,而且还会耗费在这上面的很多时间,所以集体的力量是伟大的,要团结合作。
每一次的学习都会让我们有收获,这次的课程设计对我们很有意义!
数字逻辑之数字时钟显示与校时相关推荐
- 数字逻辑与数字系统设计实验大作业——4位密码锁
课程名称:数字逻辑与数字系统设计 任课教师:李琼 作业题目:4位电子密码锁 完成人:HIT的柯小信 报告日期:2020年 12月 13日 设计要求 计一个开锁密码至少为4位数字(或更多)的密码锁. 当 ...
- 象棋快棋赛电子裁判计时器的设计——《数字逻辑与数字系统设计》实验大作业设计报告
数电Github资源 <数字逻辑与数字系统设计>实验大作业设计报告 实验题目 象棋快棋赛电子裁判计时器的设计 实验难度 ★★ 成员 姓名 班号 学号 1 郭茁宁 1837101 11837 ...
- 利用ESP8266+OLED(I2C)打造智能时钟(网络校时+实时天气+天气预报)
从零开始使用ESP8266+OLED打造智能时钟(网络校时+实时天气+天气预报) 目录 零.前言 一.材料准备 1.ESP8266(NodeMCU V3) 2.OLED(SSD1306)(四针脚,利用 ...
- 数字逻辑之数字时钟课程设计(含proteus仿真图及代码)
一.设计要求 1.设计一个能显示日期.小时.分钟.秒的数字电子钟,并具有整点报时的功能. 2.可手动校正时.分时间和日期值,时间以24小时为一个周期,有校时功能,可以分别对时及分进行单独校时,使其校 ...
- 数电实验 数字电子钟设计 基于quartus 实现计时校时闹钟秒表稍复杂音频 分享电路图设计以及工程文件
数字电子钟设计 本文主要完成数字电子钟的以下功能 1.计时功能(24小时) 2.秒表功能(一个按键实现开始暂停,另一个按键实现清零功能) 3.闹钟功能(设置闹钟以及到时响10秒) 4.校时功能 5.其 ...
- 数字逻辑与数字系统设计——初识数字逻辑
初识数字逻辑 1.何为数字逻辑 实现各子系统的逻辑功能 将各功能模块互联 2.模拟信号与数字信号 模拟信号 数值变化连续 数字信号 数值变化离散 3.数字系统中的0和1 表示两种状态 开关电路中 0 ...
- 计算机专业数字逻辑考试题,数字逻辑试卷及答案.doc
PAGE PAGE 36 武汉大学计算机学院 2006~2007学年第二学期2006级<数字逻辑> 期未考试试卷 A卷 学号 班级 姓名 成绩 一.填空(每空1分,共14分) 1.(21. ...
- 数字逻辑与数字系统(第五版)课后习题答案
(519条消息) 数字逻辑与数字电路指导(课后题)_Half-up的博客-CSDN博客 转载,仅供学习方便查阅
- 【数字逻辑与数字系统设计】应对期末考(更新于2022/4/15)
目录 第一章 绪论 1.1 数字信号与数字电路 一.模拟量/模拟信号/数字量/数字电路 二.数字电路的表示方法 1.2 数制和码制 一.数制基础概念 二.重要的数制 三.不同数制之间的转换(考点) 四 ...
最新文章
- rails2.3.5 添加jquery ui 找不到images
- Unicode字段也有collation
- js函数重写php,深入讲解js覆盖原有方法 提供重写方法
- element 输入框怎么加单位_抖音上的人声配音怎么制作?
- 恒大紧急辟谣“资金链断裂”,股价止跌回升
- 新款iPhone SE预购好于预期,新款iPhone SE Plus可能要因此延迟了
- Keras 报错:An operation has `None` for gradient.
- 学习笔记之搜索引擎—原理、技术与系统
- HP打印机自动双面打印故障排除
- 车机没有carlife可以自己下载吗_视频实测:苹果CarPlay和百度CarLife到底哪个更好用...
- 路由器刷机突破校园网限制
- IDEA中配置类提示Spring Boot Configuration Annotation Processor not configured
- 2018年中高级前端面试题目小结
- DS18B20温度传感器arduino程序
- 春节假期和幺儿一起玩xbox360的体感游戏
- 信号傅里叶变换后的实数和虚数部分理解
- 日记侠:你对微信关键词是如何理解的?
- uniapp离线打包
- 量子竞赛下一步:在应用中体现量子优势
- 用python生成excel文件_python通过openpyxl生成Excel文件的方法
热门文章
- 如何解决批处理文件一闪而过的现象
- Android 获取设备开机时间
- VS2010下载|官网|Microsoft Visual Studio 2010 (VS2010)旗舰版下载地址
- MATLAB的polt的使用中的小问题
- python topk
- 方舟服务器端口修改,【论坛首发】方舟:生存进化正版开服教程 附端口映射教程 附后台命令...
- 云上MongoDB常见索引问题及最优索引规则大全
- oracle导出文件报12154,EXPDP导出时报错ORA-12154
- 什么牌子的蓝牙耳机好用?盘点五款性价比超高的蓝牙耳机品牌
- 金行健:别看不上土味元宇宙