基于VHDL语言的数字时钟设计 下载本文

内容发布更新时间 : 2024/5/4 6:02:32星期一 下面是文章的全部内容请认真阅读。

课程:CPLD与FPGA设计及应用

实验:基于

VHDL语言的数字时钟设计

学号:092030030 姓名: 朱 峰

专业:信号与信息处理 学院:电子与信息学院

2011年12月

基于VHDL语言的数字时钟设计

一:主要功能

1:具有时、分、秒计数显示功能,以24小时循环计时。 2:具有日期和星期显示功能。 3:具有秒表功能

4:具有调节日期,星期,小时,分钟,清零的功能。 5:具有定时和闹铃的功能。

二:结构框图

控制单元 数 字 时 输出信号 LED显示 使能信号 报警(闹铃)信号 扬声器 CLK时钟信号 钟 复位信号

三:RTL图

div:u1clk_insetstopclk_insetstopclk_out1clk_out2clkresetmsecond:u2enseconddaout[6..0]clkresetsetclksetminsecond:u3clkenmindaout[6..0]speaksec[6..0]speakmin[6..0]speaker:u9speakspeakminute:u4clkresetsethoursetminresetsetclksethourenhourdaout[6..0]hour:u5clkresetsetclkenweekdaout[6..0]clk1resetshowweekms[6..0]sec[6..0]seltime:u8setweeksetweekdpled[6..0]sel[7..0]date:u7clkresetmonthout[4..0]dateout[5..0]min[6..0]hour[6..0]month[4..0]date[5..0]week[3..0]dpled[6..0]sel[7..0]weeker:u6clkresetweekout[3..0]showweek 四:功能实现

4.1分频模块设计

本设计使用的输入时钟信号为50Mhz,经过分频产生两路时钟信号,其中一路为微秒计数时钟信号,一路为动态扫描时钟信号。同时模块有一输入控制信号,其功能是停止微秒计数时钟信号,以实现定时的功能。

输入:clk_in 为50Mhz,setstop为微秒计数时能信号 输出:clk_out1为1/60hz clk_out2为1khz

源代码如下: library ieee;

use ieee.std_logic_1164.all; entity div is

port(clk_in,setstop: in std_logic;

clk_out1,clk_out2: out std_logic); end entity div;

architecture fun of div is constant a:integer:=8333333; constant b:integer:=49999; signal c:integer range 0 to a; signal d:integer range 0 to b; begin

process(clk_in,setstop) begin

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

if(( c+7500000)

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

if d<=b then d<=d+1; clk_out2<='1'; else d<=0;clk_out2<='0'; end if; end if; end process; end fun;

4.2计时模块设计

4.2.1 微秒计时模块

计数器的第一个模块为微秒计时模块,其实质为一个六十进制计数器。