EDA实验报告数字钟

alumni1  南昌大学实验报告

学生姓名:      刘光林          学    号:  6100209064         专业班级:卓越(3+1               

实验类型:□ 验证 □ 综合 ■ 设计 □ 创新   实验日期:         实验成绩:            

  实验四   多功能数字钟设计

一、实验设计

1、数字显示当前的小时、分钟;

2、闹钟和24小时计时显示;

3、一个调节键,用于调节目标数位的数字。对调节的内容敏感,如调节分钟或秒时,保持按下时自动计数,否则以脉冲计数;

4、一个功能键,用于切换不同状态:计时、调时、调分、调秒。

二、实验步骤

根据实验要求可以将该工程设计几个模块:

1、秒计时模块

  

代码:

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity second is

port(clk,reset,setmin:in std_logic;

enmin:out std_logic;

sout:out std_logic_vector(7 downto 0));

end second;

architecture bhv of second is

signal count:std_logic_vector(7 downto 0);

signal enmin1,enmin2:std_logic;

begin

sout<=count;

enmin2<=(setmin and clk);

enmin<=(enmin1 or enmin2);

process(clk,reset,setmin)

begin

if reset='0' then count<="00000000";

elsif clk'event and clk='1' then

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

if count<16#60# then

if count="01011001" then

enmin1<='1';count<="00000000";

else count<=count+7;

end if;

else count<="00000000";

end if;

elsif count<16#60# then

count<=count+1;

enmin1<='0';

else count<="00000000";

end if;

end if;

end process;

end bhv;

   其中,CLK是时钟信号,RESET是复位信号,SETMIN为分钟设置信号,ENMIN作为下一模块分钟设计的时钟信号,sout输出信号最后接在动态译管码芯片上,得出实验要求的秒显示。

2、分计时模块

  

代码:

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity minute is

port(clk,enmin,reset,sethour:in std_logic;

enhour,speak:out std_logic;

mout:out std_logic_vector(7 downto 0));

end minute;

architecture bhv of minute is

signal count:std_logic_vector(7 downto 0);

signal enhour1,enhour2:std_logic;

begin

mout<=count;

enhour2<=(sethour and clk);

enhour<=(enhour1 or enhour2);

process(clk,reset,sethour)

begin

if reset='0' then

count<="00000000";

elsif enmin'event and enmin='1' then

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

if count<16#60# then

if count="01011001" then

enhour1<='1';count<="00000000";

else count<=count+7;

end if;

else count<="00000000";

end if;

elsif count<16#60# then

count<=count+1;

enhour1<='0';

else count<="00000000";

end if;

end if;

if count="00000000" then

speak<='1';

else speak<='0';

end if;

end process;

end bhv;

    其中,CLK接秒模块中的ENMIN信号,RESET同样是复位信号,ENHOUR作为下一模块小时的时钟信号,mout输出信号最后接在动态译码管芯片上.得出实验要求得分显示,sehour为调时信号。

3、小时模块

 

代码:

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity hour is

port(enhour,reset:in std_logic;

hout:out std_logic_vector(7 downto 0));

end hour;

architecture bhv of hour is

signal count:std_logic_vector(7 downto 0);

begin

hout<=count;

process(enhour,reset)

begin

if reset='0' then

count<="00000000";

elsif enhour'event and enhour='1' then

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

if count<16#23# then

count<=count+7;

else count<="00000000";

end if;

elsif count<16#23# then

count<=count+1;

else count<="00000000";

end if;

end if;

end process;

end bhv;

  

4、闹钟功能模块

代码:

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity clock is

port(clk:in std_logic;

setclk:in std_logic_vector(1 downto 0);

hour,minute:in std_logic_vector(7 downto 0);

minute1,hour1:buffer std_logic_vector(7 downto 0);

co:out std_logic);

end clock;

architecture bhv of clock is

signal count1,count2:std_logic_vector(7 downto 0);

begin

minute1<=count1;

hour1<=count2;

process(clk,setclk)

begin

if clk'event and clk='1' then

if setclk="01" then

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

if count1<16#60# then

if count1="01011001" then

count1<="00000000";

else count1<=count1+7;

end if;

else count1<="00000000";

end if;

elsif count1<16#60# then

count1<=count1+1;

else count1<="00000000";

end if;

elsif setclk="10" then

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

if count2<16#23# then

count2<=count2+7;

else count2<="00000000";

end if;

elsif count2<16#23# then

count2<=count2+1;

else count2<="00000000";

end if;

end if;

end if;

if hour1=hour then

if minute1=minute then

co<='1';

else co<='0';

end if;

else co<='0';

end if;

end process;

end bhv;

5、时间和闹钟时间(动态数码管)显示模块

  

   代码:

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity scan is

port(clk,reset:in std_logic;

setclk:std_logic_vector(1 downto 0);

second,minute,hour,minute1,hour1:in std_logic_vector(7 downto 0);

cout:out std_logic_vector(3 downto 0);

c:out std_logic_vector(7 downto 0);

sel:out std_logic_vector(2 downto 0));

end scan;

architecture bhv of scan is

signal count:std_logic_vector(2 downto 0);

signal dout:std_logic_vector(3 downto 0);

begin

sel<=count;

process(clk,reset,setclk)

begin

if reset='0' then

count<="000";

elsif clk'event and clk='1' then

if count>="101" then

count<="000";

else

count<=count+1;

end if;

end if;

if setclk="00" then

case count is

when "101" =>dout<=second(3 downto 0);

when "100" =>dout<=second(7 downto 4);

when "011" =>dout<=minute(3 downto 0);

when "010" =>dout<=minute(7 downto 4);

when "001" =>dout<=hour(3 downto 0);

when "000" =>dout<=hour(7 downto 4);

when others =>null;

end case;

else

case count is

when "101" =>dout<="0000";

when "100" =>dout<="0000";

when "011" =>dout<=minute1(3 downto 0);

when "010" =>dout<=minute1(7 downto 4);

when "001" =>dout<=hour1(3 downto 0);

when "000" =>dout<=hour1(7 downto 4);

when others =>null;

end case;

end if;

cout<=dout;

case dout is

when "0000"=>c<="00111111";

when "0001"=>c<="00000110";

when "0010"=>c<="01011011";

when "0011"=>c<="01001111";

when "0100"=>c<="01100110";

when "0101"=>c<="01101101";

when "0110"=>c<="01111101";

when "0111"=>c<="00000111";

when "1000"=>c<="01111111";

when "1001"=>c<="01101111";

when others=>null;

end case;

end process;

end bhv;

应用以上模块设计数字钟电路原理图如下

三、实验步骤

1、建立工作库文件夹,输入设计项目原理图或VHDL代码并存盘。

2、选目标器件并编译

3、建立仿真波形文件,进行波形仿真

  

4、引脚锁定

(具体管脚锁定情况如下图所示)

这里面由于蜂鸣器没有,所以引脚没有锁

5、程序下载,并通过检测

        点击Start下载.

四、实验结果

数字钟可以正常的计时,且经过分频之后时间很准,可以就是调时调分都比较好用,我用的是分钟调时,也就是调时一次一秒的信号,总的结果都非常的好!

 

第二篇:多功能数字钟(EDA设计)实验报告

多功能数字钟

一、     实验原理分析

通过晶振产生的50MHz的脉冲,用分频器进行分频产生1Hz的脉冲信号,即作为时钟的1s的信号进行计数。

秒钟每计数60秒后产生进位使分钟显示加1,分钟满60循环至0。

为实现手动校准时间功能,可以对分和秒计数器进行加减。

为实现校准时间时候的闪烁,对数码管使用消隐,把数码管的接地端口接一个脉冲信号。

在实验过程中,要注意很多细节,比如进行按键消抖,手动调整时间时不会进位。

二、     逻辑分析

三、     功能模块分析

功能模块包括分频模块,时间计数及校准模块,数码管译码显示模块、判决模块和消抖模块

1.分频模块

该电路由多个70LS90经过分频将由晶振产生的50MHz分频为1Hz方波,供后续时钟电路使用。这一模块是整个电路的基础。

2.时间计数及校准模块

该模块连接至分频模块的信号输出端,以分频模块产生的1Hz方波作为基础。1Hz方波与秒同步,以秒为基础,分别实现电子钟中,分与时的运转,即1分钟=60秒,1小时=60分钟的循环运转。为了修正电子钟在运行过程中产生的一些误差或其他认为错误,另设置校准功能,可以对电子钟的计时进行调整。其中,此模块的逻辑部分需Verilog语言实现并进行封装。此模块用到3个十进制计数器、2个六进制计数器和1个三进制计数器。

3.数码管译码显示模块

本电子钟采用数码管来显示,可以简单、直观地表现出确切的时间,实现其他配套功能。且数码管易于操作。此模块中有四个数码管,每两个数码管分别显示小时与分钟。由上一模块,即时间计数及校准模块中的时间计数器产生的数值,将其对应的七段码直接传送至相应的数码管译码显示。

4.判决模块

该电路判决信号连接至开关,当开关选中数码管某位后,经过判决器令改为停止计数,并开始1秒闪烁,按动按键可实现手动调整。

5.消抖模块

通常的按键所用开关为机械弹性开关,当机械触点断开、闭合时,由于机械触点的弹性作用,一个按键开关在闭合时不会马上稳定地接通,在断开时也不会一下子断开。因而在闭合及断开的瞬间均伴随有一连串的抖动。消抖在实践中,是相当必要的。此模块采用Verilog语言消除开关打开时电平抖动,使电子钟在实际操作过程中更加稳定。

四、     实现过程分析

在这个时钟电路的综合设计之中, Verilog语言设计以及原理图设计方法是它的核心部分。这种底层语言设计和顶层原理图设计方法相结合的综合设计方法,是大多工程项目的设计思路。打开电源后,该时钟可实现较为准确的时分时间显示功能。数码管上循环显示0到23小时以及0到60分,另有一个发光二极管实现秒计时显示。另外,当时间显示不准确时,电子钟有相应的校准模块对其调整。拨动对应数码管位开关可使该位间隔1秒闪烁,调节对应开关可选择加减模式,按动按键可实现加减调节功能。该时钟电路还具有实时清零功能键。

                                   

相关推荐