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

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

课程:CPLD与FPGA设计及应用

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

学号:*********

姓名:**

专业:信号与信息处理

学院:电子与信息学院

2011年12月

基于VHDL语言的数字时钟设计一:主要功能

1:具有时、分、秒计数显示功能,以24小时循环计时。

2:具有日期和星期显示功能。

3:具有秒表功能

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

5:具有定时和闹铃的功能。

二:结构框图

三:RTL图

四:功能实现

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)

else c<=0;clk_out1<='0';

end if;

end if;

end process;

process(clk_in)

begin

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 微秒计时模块

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

输入:clk为1/60hz,reset为清零复位键

输出:ensecond为秒模块的进位信号

Daout为微妙输出显示信号

源代码如下:

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity msecond is

port(clk,reset:in std_logic;

ensecond:out std_logic;

daout:out std_logic_vector(6 downto 0));

end entity msecond;

architecture fun of msecond is

signal count:std_logic_vector(6 downto 0);

signal enmin_1:std_logic;

begin

process(clk,reset)

begin

if(reset='0')then count<="0000000";

elsif(clk 'event and clk='1')then

if(count(3 downto 0)="1001")then

if(count<16#60#)then

if(count="1011001")then

enmin_1<='1';count<="0000000";

else

count<=count+7;

end if;

else

count<="0000000";

end if;

elsif(count<16#60#)then

count<=count+1 ;

enmin_1<='0' ;

else

count<="0000000";

end if;

end if;

end process;

daout<=count;

ensecond<=enmin_1 ;

end fun;

4.2.2 秒计时模块

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

输入:clk为秒进位信号,reset为清零复位键,setmin为调分信号,setclk为消抖时钟输出:enmin为分模块的进位信号

daout为秒输出显示信号

源代码如下:

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity second is

port(clk,setclk,reset,setmin:in std_logic;

enmin:out std_logic;

daout:out std_logic_vector(6 downto 0));

end entity second;

architecture fun of second is

signal count:std_logic_vector(6 downto 0);

signal enmin_1,enmin_2:std_logic;

begin

process(clk,reset,setmin)

begin

if(reset='0')then count<="0000000";

elsif(clk 'event and clk='1')then

if(count(3 downto 0)="1001")then

if(count<16#60#)then

if(count="1011001")then

enmin_1<='1';count<="0000000";

else

count<=count+7;

end if;

else

count<="0000000";

end if;

elsif(count<16#60#)then

count<=count+1 ;

enmin_1<='0' ;

else

count<="0000000";

end if;

end if;

end process;

process(setclk,setmin)

相关文档
最新文档