




已阅读5页,还剩13页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
目 录摘要21设计目的 22设计内容 22.1设计任务22.2扩展 23系统方案及设计原理 33.1方案选择 33.2数字钟的基本工作原理 33.3底层元件接口 43.4数字钟设计的RTL电路 54设计步骤 55心得体会106 程序代码 10摘要:人类社会已进入到高度发达的信息化社会。信息化社会的发展离不开电子信息产品开发技术、产品品质的提高和进步。电子信息产品随着科学技术的进步,其电子器件和设计方法更新换代的速度日新月异。实现这种进步的主要原因就是电子设计技术和电子制造技术的发展,其核心就是电子设计自动化(EDA,ElectronicsDesignAutomation)技术,EDA技术的发展和推广应用又极大地推动了电子信息产业的发展。为保证电子系统设计的速度和质量,适应“第一时间推出产品”的设计要求,EDA技术正逐渐成为不可缺少的一项先进技术和重要工具。目前,在国内电子技术教学和产业界的技术推广中已形成“EDA热”,完全可以说,掌握EDA技术是电子信息类专业学生、工程技术人员所必备的基本能力和技能。EDA技术在电子系统设计领域越来越普及,本设计主要利用VHDL语言在EDA平台上设计一个电子数字钟,它的计时为24小时小时制,显示满刻度为23时59分59秒,另外还具有校时功能和闹钟功能。总的程序由几个各具不同功能的单元模块程序拼接而成,其中包括分频程序模块、时分秒计数和校时程序模块、数据选择器程序模块、显示程序模块和例化程序模块。并且使用QUARTUS II软件进行电路波形仿真,下载到EDA实验箱进行验证。关键词:数字钟 EDA VHDL语言 一、设计目的1、熟练地运用数字系统的设计方法进行数字系统设计;2、能进行较复杂的数字系统设计;3、按要求设计一个数字钟。二、设计内容2.1、设计任务:设计一台能显示时、分、秒的数字钟。具体要求如下:(1) 由实验箱上的时钟信号经分频产生秒脉冲;(2) 计时计数器用24进制计时电路;(3) 可手动校时,能分别进行时、分的校正;(4) 整点报时;22、扩展:设置闹时功能,当计时计到预定时间时,扬声器发出闹铃信号,闹铃时间为4s,并可提前终止闹铃。三、系统方案及设计原理。3.1、方案选择:数字钟无非就是分频计数,设计出60进制,24进制计数器,在这里,秒分计数是60进制,时计数是24进制,对1Hz信号进行60分频也就产生了分计数脉冲,对1Hz进行60 * 60 分频(对分60分频)也就产生了时计数脉冲,为了方便校时,系统设计时未直接采用实验箱上的1Hz作为基准时钟源,而是对65536Hz进行32768分频产生秒脉冲,8192分频作为校时与闹钟时间设置脉冲,为方便调闹钟,采用了数据选择器选择输出正常走时或闹钟时间。为节省代码,数码管译码工作直接交给了实验箱自带的译码器,选择工作模式0。3.2、数字钟的基本工作原理:数字钟以其显示时间的直观性、走时准确性作为一种计时工具,数字钟的基本组成部分离不开计数器,在控制逻辑电路的控制下完成预定的各项功能。数字钟的基本原理方框图如图1:时显示器秒显示器分显示器时译码器秒译码器分译码器报时/闹钟时计数器分计数器秒计数器校时电路 1Hz 5HZ分频器振荡器图1 数字钟的系统框图图3.1数字钟实现原理框图该系统由振荡器、分频器、“时、分、秒”计数器、译码器及显示器、校时电路、整点报时电路等组成。石英晶体振荡器和分频器产生整个系统的时基信号,它直接决定计时系统的精度。“秒计数器”采用六十进制计数器,每累计60秒向“分计数器”进位;“分计数器”采用六十进制计数器,每累计60分向“时计数器”进位;“时计数器”采用二十四进制计数器,按照“24翻1”规律计数。“时、分、秒”计数器的输出经译码器送显示器显示。校时电路用来当计时出现误差时对“时、分、秒”进行校对调整。整点报时(闹钟)电路是根据计时系统的输出状态产生一脉冲信号,然后去触发音频发生器实现报时(闹铃)。3.3、底层元件接口:component hour port(rst,carry,en : in std_logic;ADJclk,ADJEN : in std_logic;ADJ : in std_logic_vector(3 downto 0);decade,unit : out std_logic_vector(3 downto 0);end component;component minport(rst,carry,en : in std_logic;ADJclk,ADJEN : in std_logic;ADJ : in std_logic_vector(3 downto 0);carryout : out std_logic;decade,unit : out std_logic_vector(3 downto 0);end component;component secport(rst,clk,en : in std_logic;ADJEN : in std_logic;carryout : out std_logic;decade,unit : out std_logic_vector(3 downto 0);end component;component alarmport(clk,en,ADJclk : in std_logic;alarmADJ : in std_logic;AlarmEn : in std_logic;ADJ : in std_logic_vector(3 downto 0);hour_unit : in std_logic_vector(3 downto 0);hour_decade : in std_logic_vector(3 downto 0);min_unit : in std_logic_vector(3 downto 0);min_decade : in std_logic_vector(3 downto 0);ADJhour_unit : out std_logic_vector(3 downto 0);ADJhour_decade : out std_logic_vector(3 downto 0);ADJmin_unit : out std_logic_vector(3 downto 0);ADJmin_decade : out std_logic_vector(3 downto 0);sound : out std_logic);end component;component PrescalClk port(clkin : in std_logic;clkout_1Hz : out std_logic;clkout_4Hz : out std_logic);end component;3.4、数字钟设计的RTL电路: 图2从RTL电路中可以看到,通过综合后系统模块划分为分频模块、秒计数模块、分计数模块、时计数模块、闹钟模块,数据选择输出模块,由于系统设计时硬件平台选用的是模式0,显示部由硬件译码。分频模块产生正常走时的1Hz频率与校时用的5Hz频率,时分秒计数都可有外部按键清零,时分可分别进行校时,闹钟模块可根据需要设置闹铃时间,输出部分采用了数据选择器,用于选择输出正常走时或闹钟设置时间。四、设计步骤步骤1:输入设计项目和存盘打开QUARTUSII,单击“file”菜单,将鼠标移到New Project Wizard 选项单击则显示如图3 图3 建立 New Project在第一栏选择或写入工程文件名,第二、三栏中建立项目名和实体名,工程文件不能包含中文字符,项目名和实体必须保持一致,然后选择目标器件如图4 图4选择没标器件目标器件一定要与实际所用器件一致,最后点击finish完成弹出图5 图5建立VHDL文件步骤2:输入程序并运行编译;在工具栏中点击filenew,选择VHDL File,点击确定建立VHDL文件,在里面键入程序,如图6 图6 输入程序输入完程序以后点击工具栏中的保存,再点击右方一个紫色的三角符号“”,然后运行程序,如果程序出现错误在改正。编译通过后如图7 7 通过编译步骤3:时序仿真:1建立波形文件:选择File-New,在Other File里选择Vector Waveform File,单击OK建立波形文件,在Edit-End Time选项中为仿真设置仿真时间。双击Name下的空白处,弹出Insert Nod or Bus对话框,单击Node Finder如图7图7 选择添加结点设置在图8所示选定各个选择项。图8 选择结点单击OK,完成引脚输入,加上输入信号后波形文件存盘。 2运行仿真器。在Processing菜单下选择StartSimulation项,直到Simulator was successful出现,仿真结束。完成波形如图9所示。 图9 仿真波形图步骤4:引脚锁定选择AssignmentsAssignments Editor,锁定引脚,输入以后如下图,设定完成以后再运行一次程序。图10 引脚锁定步骤5:编程下载:1)首先将下载线把计算机的打印机口与目标板(如开发板或实验板)连接好,打开电源2)下载方式设定。选择ToolsProgrammer选项,跳出下图左侧所示的编程器窗口,然后选择Hardware Setup硬件设置选项,其窗口图中左侧所示。在其下拉菜单中选ByteBlaster(MV)编程方式,在Model栏选定JTAG模式。然后点击start按钮下载,进入下载模式,等待下载完成以后在试验箱上进行调试检测是否正确。五、心得体会经过两周EDA课程设计,使我受益匪浅。这不仅增强了我对EDA设计的兴趣,更巩固了基本的电路设计流程、方法以及技巧。具备了这些基本知识,为今后的自主学习奠定了良好的基础。在编写时可以相互借鉴,这样可以节省一定的时间,但在一个问题上纠结了很久,现还未明白,为什么一个变量在进程中只能被一个边沿信号触发进行修改,无奈之下选择了另一种方法,通过一个控制端来进行选频,以实现快速调时,在闹钟的处理上使用了数据选择,设置闹铃时数码管显示闹钟时间。在设计中还是需要注意一些常见的问题,比如实体名、项目名等,还有在编写VHDL文件时,一些文件名也是需要注意的;在编写程序的过程中,信号与变量的使用是一个特需要注意的,进程中一个信号不应有多个复制源,信号的复值是在进程结束之时,而变量的复值是立即的,在书写时容易出错的地方是,信号的赋值与变量的赋值符号,信号作为全局的联络线,信号往往不允许在多个进程中被赋值,因为进程之间是并行的;整个系统是由多个底层元件组成,底层元件之间的相互连接是通过信号实现。由于时间比较紧,在准备智能车比赛,就没有挑战难度高点的题了,但本人对FPGA是挺感兴趣的,在今后的学习中我会把握时间好好学学。最后感谢姚老师对我们的指导,使得实验能够顺利完成!六、程序代码:1分频:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity PrescalClk isport(clkin : in std_logic;clkout_1Hz : out std_logic;clkout_4Hz : out std_logic);end ;Architecture bhv of PrescalClk isbegin process(clkin)variable count1 : integer range 0 to 32768;variable count2 : integer range 0 to 8192;begin if clkin event and clkin=1 then count1 := count1+1;count2:=count2+1;if(count1=32768) then clkout_1Hz=1 ;else clkout_1Hz=0;end if;if(count2=8192) then clkout_4Hz=1;else clkout_4Hz=0;end if;end if;end process;end;2时计数模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity hour isport(rst,carry,en : in std_logic;ADJclk,ADJEN : in std_logic;ADJ : in std_logic_vector(3 downto 0);decade,unit : out std_logic_vector(3 downto 0);end ;architecture bhv of hour issignal clk : std_logic;beginprocess(carry,ADJ,ADJEN,ADJclk)beginif (ADJEN=1 and ADJ=1100 )then clk=ADJclk;else clk=carry;end if;end process;process(rst,en,clk)variable unitcount : std_logic_vector(3 downto 0);variable decadecount : std_logic_vector(3 downto 0); beginif (rst=1) then unitcount:=0000;decadecount:=0000;elsif(en=1) then if clk event and clk=1 thenif(unitcount10) then unitcount:=unitcount+1;else unitcount:=0000;end if;if(unitcount=10) then decadecount:=decadecount+1;unitcount:=0000;end if;if(decadecount=2 and unitcount=4) then unitcount:=0000;decadecount:=0000;end if;end if;end if;decade=decadecount;unit=unitcount; end process;end;3分计数模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity min isport(rst,carry,en : in std_logic;ADJclk,ADJEN : in std_logic;ADJ : in std_logic_vector(3 downto 0);carryout : out std_logic;decade,unit : out std_logic_vector(3 downto 0);end ;architecture bhv of min issignal clk : std_logic;beginprocess(carry,ADJ,ADJEN,ADJclk)beginif (ADJEN=1 and ADJ=0011 )then clk=ADJclk;else clk=carry;end if;end process;process(rst,en,clk,ADJEN)variable unitcount : std_logic_vector(3 downto 0);variable decadecount : std_logic_vector(3 downto 0); beginif (rst=1) then unitcount:=0000;decadecount:=0000;elsif(en=1) then if (clk event and clk=1)thenif(unitcount10) then unitcount:=unitcount+1;else unitcount:=0000;end if;if(unitcount=10) then decadecount:=decadecount+1; unitcount:=0000;end if;if(decadecount=6 and unitcount=0) then unitcount:=0000;decadecount:=0000;if ADJEN=0 then carryout=1; - when ADJEN=1,donot generate carryelse carryout=0;end if;else carryout=0;end if;end if;end if;decade=decadecount;unit=unitcount; end process;end;4秒计数模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity sec isport(rst,clk,en : in std_logic;ADJEN : in std_logic;carryout : out std_logic;decade,unit : out std_logic_vector(3 downto 0);end ;architecture bhv of sec isbeginprocess(rst,en,clk)variable unitcount : std_logic_vector(3 downto 0);variable decadecount : std_logic_vector(3 downto 0); beginif (rst=1) then unitcount:=0000;decadecount:=0000;elsif(en=1) thenif clkevent and clk=1thenif(unitcount10) then unitcount:=unitcount+1;else unitcount:=0000;end if;if(unitcount=10) then decadecount:=decadecount+1; unitcount:=0000;end if;if(decadecount=6 and unitcount=0) then unitcount:=0000;decadecount:=0000;if(ADJEN=0) then carryout=1; - when ADJEN=1, donot generate carryelse carryout=0;end if;else carryout=0;end if;end if;end if;decade=decadecount;unit=unitcount; end process;end;5闹钟模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity alarm isport(clk,en,ADJclk : in std_logic;alarmADJ : in std_logic;AlarmEn : in std_logic;ADJ : in std_logic_vector(3 downto 0);hour_unit : in std_logic_vector(3 downto 0);hour_decade : in std_logic_vector(3 downto 0);min_unit : in std_logic_vector(3 downto 0);min_decade : in std_logic_vector(3 downto 0);ADJhour_unit : out std_logic_vector(3 downto 0);ADJhour_decade : out std_logic_vector(3 downto 0);ADJmin_unit : out std_logic_vector(3 downto 0);ADJmin_decade : out std_logic_vector(3 downto 0);sound : out std_logic);end;architecture bhv of alarm issignal hour1,hour2,min1,min2 : std_logic_vector(3 downto 0);beginprocess(en,alarmADJ,ADJ,ADJclk)variable hour_decadecounnt,hour_unitcount,min_decadecount,min_unitcount : std_logic_vector(3 downto 0);begin if (en=1 and alarmADJ=1) then if ADJclk event and ADJclk=1 then if ADJ=1100 thenif(hour_unitcount10) then hour_unitcount:=hour_unitcount+1;else hour_unitcount:=0000;end if;if(hour_unitcount=10) then hour_decadecounnt:=hour_decadecounnt+1;hour_unitcount:=0000;end if;if(hour_decadecounnt=2 and hour_unitcount=4) then hour_decadecounnt:=0000;hour_unitcount:=0000;end if;elsif ADJ=0011 then if(min_unitcount10) then min_unitcount:=min_unitcount+1;else min_unitcount:=0000;end if;if(min_unitcount=10) then min_decadecount:=min_decadecount+1;min_unitcount:=0000;end if;if(min_decadecount=6 and min_unitcount=0) then min_decadecount:=0000;min_unitcount:=0000;end if;end if;end if;end if;hour1=hour_decadecounnt;hour2=hour_unitcount;min1=min_decadecount;min2=min_unitcount;end process;process(en,AlarmEn,ADJclk,clk,hour_unit,hour_decade,min_unit,min_decade,hour1,hour2,min1,min2)variable count : std_logic_vector(3 downto 0);beginif(en=1 and AlarmEn=1) then if(hour_unit=hour2 and hour_decade=hour1 and min_unit=min2 and min_decade=min1) thenif clk event and clk=1 then if (count10) then count:=count+1;else sound
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年海上风电行业人才需求与培养策略报告
- 宾馆公司合同付款管理办法
- 湖北省武汉市武珞路一校四区2024-2025学年八年级下学期期中语文试题(含答案)
- 写人写物初中范文
- 2025年A股市场前景及投资研究报告:“政策底”牛市起点
- 岩石的脚印赏析课件
- 岩土力学课件应力场
- 小黄车安全驾驶知识培训课件
- 房地产开发项目计件工资劳动合同
- 个人与公司间的土地流转借款合同
- 2025保安证考试试题及答案集合
- 2025至2030中国氯化氧锆(CAS7699436)行业发展趋势分析与未来投资战略咨询研究报告
- Unit 1 Happy Holiday 第1课时(Section A 1a-1d) 2025-2026学年人教版英语八年级下册
- 交警中队勤务管理制度
- 腰椎病护理疑难病例讨论讲课件
- 征地拆迁考试试题及答案
- 2025至2030年中国石墨双极板行业市场产销格局及发展前景研判报告
- 交投招聘笔试题及答案
- 车辆折损赔偿协议书
- 跨文化用户体验研究-全面剖析
- 《新能源技术与应用》课件
评论
0/150
提交评论