基于VHDL的数字时钟设计Word格式文档下载.docx

上传人:b****2 文档编号:13759495 上传时间:2022-10-13 格式:DOCX 页数:22 大小:365.43KB
下载 相关 举报
基于VHDL的数字时钟设计Word格式文档下载.docx_第1页
第1页 / 共22页
基于VHDL的数字时钟设计Word格式文档下载.docx_第2页
第2页 / 共22页
基于VHDL的数字时钟设计Word格式文档下载.docx_第3页
第3页 / 共22页
基于VHDL的数字时钟设计Word格式文档下载.docx_第4页
第4页 / 共22页
基于VHDL的数字时钟设计Word格式文档下载.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

基于VHDL的数字时钟设计Word格式文档下载.docx

《基于VHDL的数字时钟设计Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《基于VHDL的数字时钟设计Word格式文档下载.docx(22页珍藏版)》请在冰豆网上搜索。

基于VHDL的数字时钟设计Word格式文档下载.docx

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitypinlvis

port(clk:

instd_logic;

--系统时钟输入端口

clk2ms:

outstd_logic;

clk500ms:

clk1s:

outstd_logic);

--各频率信号的输出端口

end;

architecturebehofpinlvis

begin

p1:

process(clk);

--进程p1

variablecount1:

integerrange0to49999999;

begin

if(clk'

eventandclk='

1'

)thencount1:

=count1+1;

--在clk的上升沿计数

ifcount1<

=24999999thenclk1s<

='

0'

;

elsifcount1<

=49999999thenclk1s<

elsecount1:

=0;

--产生周期为1s的时钟信号

clk500ms<

elsifcount3<

=24999999thenclk500ms<

elsecount3:

--产生周期为500ms的时钟信号

endif;

endif;

endprocessp1;

--结束进程p1

p2:

--进程p2

variablecount2:

integerrange0to99999;

begin

if(clk'

)thencount2:

=count2+1;

--在clk上升沿计数

ifcount2<

=49999thenclk2ms<

elsifcount2<

=99999thenclk2ms<

--产生周期为2ms的扫描信号

endprocessp2;

--结束进程p2

p3:

--进程p3

variablecount3:

integerrange0to24999999;

)thencount3:

=count3+1;

--在clk上升沿计数

ifcount3<

=12499999then

endprocessp3;

endbeh;

3.1.2按键去抖动模块qudou

本设计用到FPGA开发板上的四个按键,由于按键有反应时间、抖动的问题,可能当按键被按一次时而系统感应到几次,造成误差。

所以应该进行按键消抖的处理,让每按一次键系统只感应到一次按键。

可以采用软件延时,触发反相器等方式进行消除抖动,本设计中采用软件延时的方式。

图3.2按键去抖动模块

entityqudouis

port(clk,k1,k2,k3,k4:

o1,o2,o3,o4:

--设置按键输入信号输出端口

end;

architecturebehofqudouis

process(clk,k1,k2,k3,k4)

variablecant1:

integer;

variablecant2:

variablecant3:

variablecant4:

ifclk'

then

ifk1='

thencant1:

--设置计数初值

ifk2='

thencant2:

--设置计数初值

ifk3='

thencant3:

ifk4='

thencant4:

ifcant1>

2499999theno1<

elseo1<

--延时0.5s

ifcant2>

2499999theno2<

elseo2<

--延时0.5s

ifcant3>

2499999theno3<

elseo3<

ifcant4>

2499999theno4<

elseo4<

cant1:

=cant1+1;

--加一计数

cant2:

=cant2+1;

cant3:

=cant3+1;

cant4:

=cant4+1;

endprocess;

endbeh;

3.1.3按键控制模块self1

本设计中使用了两个按键进行对时钟的暂停和调秒操作,当ok2按下时时钟暂停,再按ok3则进行秒个位的加一计数,每按一次进行加一处理。

当调节好时间后,在按ok2键重新开始计数。

图3.3按键控制模块

entityself1is

port(

c:

ok2:

ok3:

ck:

end;

--设置端口

architecturebeaofself1is

signalm:

std_logic;

signalt:

process(ok2,ok3,c);

--ok2和ok3触发进程

ifok2'

eventandok2='

thenm<

=notm;

--由ok2的动作产生m的电平信号

ifm='

thenck<

=not(ok3);

--把按键ok3的脉冲信号给输出

elseck<

=c;

--否则把正常计数时钟给输出

endprocessp1;

--结束进程

endbea;

3.1.4秒、分六十进制模块cantsixty

本设中秒、分的六十进制是由个位的十进制和十位的六进制进行组合实现的。

当个位记到9时自动向高位进一,同时个位自动清零。

当十位记到5并且个位记到9时,自动产生一个进位脉冲,同时个位和十位分别从零开始重新计数。

图3.4六十进制模块

entitycantsixtyis

port(clk:

reset:

out1:

outstd_logic_vector(3downto0);

out2:

c:

architecturebehofcantsixtyis

signalss1,ss2:

std_logic_vector(3downto0);

process(clk,reset)

if(reset='

)thenss1<

="

0000"

ss2<

elsif(clk'

)then

ifss1="

1001"

andss2="

0101"

thenc<

--当计数到59时产生进位信号

elsec<

--否则不产生

thenss1<

ifss2="

thenss2<

elsess2<

=ss2+1;

elsess1<

=ss1+1;

--计数过程

out1<

=ss1;

out2<

=ss2;

--把信号送输出

3.1.5时计数模块hourtwenty

时计数模块是二十四进制相对复杂一点,因为当十位0或着1时个位需要记到9并产生进位信号,当十位是2时,个位记到3时,就全部从零开始重新计数。

即是在十位为不同值时个位两种计数过程。

图3.5时计数模块

3.1.6秒、分、时组合后的模块

把设计的秒、分、时模块连接起来,再通过仿真验证,各模块间的进位是否正确

连接后的原理图如下

图3.6秒、分、时组合后原理图

3.1.7数码管显示模块

本模块中包含数码管的段选和位选设计,Led灯循环设计,以及整点报时

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > IT计算机 > 计算机硬件及网络

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1