数字时钟显示实验报告.doc_第1页
数字时钟显示实验报告.doc_第2页
数字时钟显示实验报告.doc_第3页
数字时钟显示实验报告.doc_第4页
数字时钟显示实验报告.doc_第5页
已阅读5页,还剩19页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

实验名称:数字时钟设计实验仪器及软件:计算机,quartas。实验目的:1全面了解如何应用该硬件描述语言进行高速集成电路设计;2.通过对数字时钟软件设计环节与仿真环节熟悉quartus ii设计与仿真环境;3. 通过对数字时钟的设计,掌握硬件系统设计方法(自底向上或自顶向下),熟悉vhdl语言三种设计风格,熟悉其芯片硬件实现的过程。4 体会硬件设计语言在工程中的重要性。全面掌握设计方法和过程。实验要求:设计一个数字时钟,并输出到数码管显示时,分,秒。实验原理:a 整体系统实行自顶下的原则,通过顶层实体分别串接各个设计部件,各个部件接口通过端口映射的方式进行串接,从而达到设计目的。b 整个程序中涉及的部件有:(1)分频器,对输入时钟40mhz进行40000000分频,得到1hz信号,作为计数器的计数时钟;对输入时钟40mhz进行400000分频,得到100hz信号,作为数码显示管位扫描信号(2)计数器,用24进制计数器作为小时位的计数,用60进制计数器作为分位,秒位的计数。(3)位选程序,实现六个数码显示管动态扫描显示,(4)led显示程序:用于显示信号在数码管。(5)顶层模块实体部分,指明了输入输出端口,各部分的联系和链接,以及通过端口映射连接各部分,实现整个程序功能。c 关于动态显示,扫描频率设置为100hz,这个频率大于要求的50hz,利用人眼的视觉暂留效果,则看不到闪烁现象,可以实现动态显示功能。d 在计数器的时钟选择上,选择的是1hz频率,满足了每秒一次的要求。设计思路及vhdl代码e两个模60的计数器来代表时钟的秒针,分针,再用一个模23的计数器来代替时针。外部基础时钟信号作为秒针计数器的时钟信号,秒针计数器的近进位信号作为分针计数器的时钟信号,分针计数器的进位信号有作为时针计数器的时钟信号,最后在统一输出。需要注意的是到23时59分59秒后下次跳动清零,从头开始。基础时钟信号选择1hz最为简单。我们做了以40mhz为基础时钟信号的时钟,主要要点在将40mhz分频到1hz。下面通过原理结构图描述系统m=3计数器 数码管译码器时钟信号进位信号m=10计数器 数码管译码器时钟信号进位信号m=6计数器 数码管译码器进位信号时钟信号m=10计数器 数码管译码器m=10计数器 数码管译码器秒针个位显示信号秒针计数器m=6计数器 数码管译码器时钟信号进位信号秒针十位显示信号时钟信号进位信号分针个位显示信号分针十位显示信号时针个位显示信号时针十位显示信号分针计数器时针计数器s110=s110+1s110=”0101”?时钟信号时钟上升沿?s220=”1001”?s220=s220+1s220=”0000”s110=”0000”输出上升沿脉冲外部基础时钟信号yny nym110=m110+1m110=”0101”?时钟信号时钟上升沿?m220=”1001”?m220=m220+1m220=”0000”m110=”0000”输出上升沿脉冲y ny ny秒针计数器提供 h110=h110+1h110=”0101”?时钟信号时钟上升沿?h220=”1001”?h220=h220+1h220=”0000”h110=”0000”输出上升沿脉冲分针计数器提供y ny ny一,顶层实体模块源代码数字钟的顶层模块程序 clock.vhd library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity clock isport(clk :in std_logic; set :in std_logic; qin_s_1 : in std_logic_vector(3 downto 0); -秒钟的低位调整输入端 qin_s_2 : in std_logic_vector(3 downto 0); -秒钟的高位调整输入端 qin_m_1 : in std_logic_vector(3 downto 0); -分钟的低位调整输入端 qin_m_2 : in std_logic_vector(3 downto 0); -分钟的高位调整输入端 qin_h_1 : in std_logic_vector(3 downto 0); -时钟的低位调整输入端 qin_h_2 : in std_logic_vector(3 downto 0); -时钟的高位调整输入端 qout : out std_logic_vector(6 downto 0); -7段码输出 sel : out std_logic_vector(5 downto 0) -位选输出端 );end clock;architecture behave of clock iscomponent cnt24 is port(clk : in std_logic; set : in std_logic; din1 : in std_logic_vector(3 downto 0); din2 : in std_logic_vector(3 downto 0); qout1 : out std_logic_vector(3 downto 0); qout2 : out std_logic_vector(3 downto 0);end component cnt24;component cnt60 is port(clk : in std_logic; set : in std_logic; din1 : in std_logic_vector(3 downto 0); din2 : in std_logic_vector(3 downto 0); qout1 : out std_logic_vector(3 downto 0); qout2 : out std_logic_vector(3 downto 0); carry : out std_logic);end component cnt60;component fen1 is port(clk:in std_logic; qout:out std_logic);end component fen1;component fen100 is port(clk:in std_logic; qout:out std_logic);end component fen100;component weixuan is port(clk : in std_logic; qin1 : in std_logic_vector(3 downto 0); qin2 : in std_logic_vector(3 downto 0); qin3 : in std_logic_vector(3 downto 0); qin4 : in std_logic_vector(3 downto 0); qin5 : in std_logic_vector(3 downto 0); qin6 : in std_logic_vector(3 downto 0); qout : out std_logic_vector(3 downto 0); sel : out std_logic_vector(5 downto 0); end component weixuan;component led_driv is port(qin : in std_logic_vector(3 downto 0); qout : out std_logic_vector(6 downto 0);end component led_driv;signal carry1: std_logic;signal carry2: std_logic;signal qout1 : std_logic;signal qout100 : std_logic;signal qout_s_1:std_logic_vector(3 downto 0);signal qout_s_2:std_logic_vector(3 downto 0);signal qout_m_1:std_logic_vector(3 downto 0);signal qout_m_2:std_logic_vector(3 downto 0);signal qout_h_1:std_logic_vector(3 downto 0);signal qout_h_2:std_logic_vector(3 downto 0);signal qouti:std_logic_vector(3 downto 0);beginu0:fen1 port map(clk=clk,qout=qout1);u1:fen100 port map(clk=clk,qout=qout100);u2:cnt60 port map(clk=qout1,set=set,din1=qin_s_1,din2=qin_s_2,qout1=qout_s_1,qout2=qout_s_2,carry=carry1);u3:cnt60 port map(clk=carry1,set=set,din1=qin_m_1,din2=qin_m_2,qout1=qout_m_1,qout2=qout_m_2,carry=carry2);u4:cnt24 port map(clk=carry2,set=set,din1=qin_h_1,din2=qin_h_2,qout1=qout_h_1,qout2=qout_h_2);u5:weixuan port map(clk=qout100,qin1=qout_s_1,qin2=qout_s_2,qin3=qout_m_1,qin4=qout_m_2,qin5=qout_h_1,qin6=qout_h_2,qout=qouti,sel=sel);u6:led_driv port map(qin=qouti,qout=qout);end behave;这部分实现的是顶层实体,它是程序的核心,通过端口映射把其他各部件程序端口连接为一个整体,指明系统的输入端口,输出端口,输入型号,输出信号。二,分频部分1,功 能:对输入时钟40mhz进行40000000分频,得到1hz信号接 口:clk -时钟输入 qout-秒输出信号library ieee;use ieee.std_logic_1164.all;entity fen1 isport(clk:in std_logic; qout:out std_logic);end fen1;architecture behave of fen1 isconstant counter_len:integer:=10#39999999#;signal cnt:integer range 0 to counter_len;begin process(clk) begin if clkevent and clk=1 then case cnt is when 0 to counter_len/2=qoutqout=1; end case; if cnt=counter_len then cnt=0; else cntqoutqout=1; end case; if cnt=counter_len then cnt=0; else cntqout=qin1; selqout=qin2; selqout=qin3; selqout=qin4; selqout=qin5; selqout=qin6; selqout=0000; sel=111111; end case; if cnt=5 then cnt:=0; else cnt:=cnt+1; end if; end if; end process;end behave; 这部分程序实现的是位选功能,用于动态显示,调整秒位,分位,时位。四,计数器的设计功 能:24进制计数器-接 口:clk -时钟输入- set -时间使能端- din1 -个位数据预置输入- din2 -十位数据预置输入- qout1-个位bcd输出- qout2-十位bcd输出library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity cnt24 is port(clk : in std_logic; set : in std_logic; din1 : in std_logic_vector(3 downto 0); din2 : in std_logic_vector(3 downto 0); qout1 : out std_logic_vector(3 downto 0); qout2 : out std_logic_vector(3 downto 0);end cnt24;architecture behave of cnt24 issignal tem1:std_logic_vector(3 downto 0);signal tem2:std_logic_vector(3 downto 0);begin process(clk,set,din1,din2) begin if set=1 then tem1=din1; tem2=din2; elsif clkevent and clk=1 then if (tem2=0010 and tem1=0011) then tem1=0000; tem2=0000; elsif(tem2/=0010 and tem1=1001) then tem2=tem2+1; tem1=0000; else tem2=tem2; tem1=tem1+1; end if; end if; end process; qout1=tem1; qout2=tem2;end behave;这部分设计了一个24进制计数器,用于小时位的计数,解决了时钟位显示的问题。-功 能:24进制计数器-接 口:clk -时钟输入- set -时间使能端- din1 -个位数据预置输入- din2 -十位数据预置输入- qout1-个位bcd输出- qout2-十位bcd输出-library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity cnt24 is port(clk : in std_logic; set : in std_logic; din1 : in std_logic_vector(3 downto 0); din2 : in std_logic_vector(3 downto 0); qout1 : out std_logic_vector(3 downto 0); qout2 : out std_logic_vector(3 downto 0);end cnt24;architecture behave of cnt24 issignal tem1:std_logic_vector(3 downto 0);signal tem2:std_logic_vector(3 downto 0);begin process(clk,set,din1,din2) begin if set=1 then tem1=din1; tem2=din2; elsif clkevent and clk=1 then if (tem2=0010 and tem1=0011) then tem1=0000; tem2=0000; elsif(tem2/=0010 and tem1=1001) then tem2=tem2+1; tem1=0000; else tem2=tem2; tem1=tem1+1; end if; end if; end process; qout1=tem1; qout2qoutqoutqoutqoutqoutqoutqoutqoutqoutqoutnull; end case; end process;end behave; -这部分的设计用于数码管上的显示,动态扫描的频率用100hz,这个频率是分频得到的。解决了数字显示的问题。实验结果和分析数字时钟显示仿真图整体输入输出数字时钟显示仿真如上图所示,clk1为外部输入时钟信号为,qout依次为时钟各位对应数码管的信号.图二所示数码管上显示。二十四进制计数器仿真图六十进制计数器仿真图100hz分频器仿真图 位选部分仿真图led显示仿真图故障排除及问题分析1, 开始时,分频器没有设计,直接将现有频率加入,没有显示出结果,后反复思考,加入了分频器部分,重新将端口调整,成功显示出了结果。2, 在老师的指导下,有加入了报时功能,事先选择的是将到12:00:00直接送一个信号给输出端,事先报时,设计程序如下library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity baoshi isport( qin_s_1 : in std_logic_vector(3 downto 0); -秒钟的低位调整输入端 qin_s_2 : in std_logic_vector(3 downto 0); -秒钟的高位调整输入端 qin_m_1 : in std_logic_vector(3 downto 0); -分钟的低位调整输入端 qin_m_2 : in std_logic_vector(3 downto 0); -分钟的高位调整输入端 qin_h_1 : in std_logic_vector(3 downto 0); -时钟的低位调整输入端 qin_h_2 : in std_logic_vector(3 downto 0); -时钟的高位调整输入端 qout : out std_logic_vector(3 downto 0) );end baoshi;architecture behave of baoshi issignal tem1:std_logic_vector(3 downto

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论