




已阅读5页,还剩12页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
EDA技术应用课程设计报告基于FPGA的数字钟设计专 业: 通信工程 班 级: 10311 姓 名: 指导教师: 2012.1.6目录1设计任务及要求11.1设计任务11.2设计要求12.设计方案以及流程22.1设计原理图22.2工程流程图23.程序设计33.1 秒钟模块33.2分钟模块43.3时钟模块63.4分频模块73.5数码管控制模块93.6七段译码显示模块113.7顶层模块124.硬件测试144.1管脚的分配144.2调试154.3实验现象165.总结166.老师点评16参考书目17基于FPGA的数字钟的设计1设计任务及要求1.1设计任务 设计并实现具有一定功能的数字钟。包括清零、置数、计数、报时等 功能。(1) 具有时、分、秒计数显示功能,且以24小时循环计时。(2) 具有清零的功能,且能够对计时系统的小时、分钟进行调整。(3) 具有整点报时功能。1.2设计要求(1) 采用VHDL语言编写程序,并在QuartusII工具平台中进行开发,下载到EDA实验箱进行验证。(2) 编写设计报告,要求包括方案选择、程序清单、调试过程、测试结果及心得体会。2.设计方案以及流程本设计由振荡器、分频器、计数器、译码器显示器和校时电路组成。振荡器提供稳定的6M脉冲信号,作为数字钟的时钟,然后经过分频器分频后输出标准1HZ脉冲。中间变量计数十次后,生成秒信号,秒计数器满60后向分计数器进位,分计数器满60后向时钟进位,时计数器满24后全部清零。此次设计的多功能数字钟主要有四部分组成:(1) 分频器部分:主要产生6MHZ的CLK的输入脉冲信号。 (2) 开关控制部分:主要实现数字钟的复位。 (3) EPM7064芯片部分:是整个数字钟的核心部分。是程序写入以及对输 入脉冲的接收与转换控制。 (4) 数码管显示部分:6位数码管动态(2000HZ)显示时、分、秒。2.1设计原理图:图1.数字钟原理图 2.2工程流程图开始新建VHDL源程序创建工程 编译程序生成模块符号文件设置顶层实体下载到硬件电路 执行程序命令执行结束 图2工程流程图创建步骤3.程序设计3.1 秒钟模块此模块主要由输入端口clk=1HZ的频率源作为计数器的时钟,当计数到59归零并且时产生进位carry=1作为分钟的时钟源。 miao_60的源代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity miao_60 is port(clk :in std_logic; -输入1HZ的频率 rst :in std_logic; -rst 复位 shi: out std_logic_vector(3 downto 0); -秒的十位、个位 ge: out std_logic_vector(3 downto 0); carry :out std_logic ); -满59s进位给分钟作频率 end entity miao_60; architecture art1 of miao_60 is signal tem1: std_logic_vector(3 downto 0); -定义与端口等宽的信号 signal tem2: std_logic_vector(3 downto 0); -位矢量 begin process(clk,rst) begin if(rst=0 ) then tem1=0000; -复位时十、个位归零 tem2=0000; elsif clkevent and clk=1 then if tem1=1001 then -个位计到9时归零tem1=0000;if tem2=0101 then -十位到5时归零 tem2=0000; carry=1; -给分钟进位作为分钟的时钟频率 else tem2=tem2+1; carry=0; end if; else tem1=tem1+1; end if; end if; shi=tem2;ge=tem1;end process; end art1;miao_60的时序仿真波形如图所示: 图3miao_60的时序仿真波形图3.2分钟模块此模块主要由输入端口clk=carry的频率源作为计数器的时钟,当计数到59归零并且时产生进位carry=1作为时钟的时钟源。fen_60的源代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity fen_60 is port(clk :in std_logic; -miao_60的进位carry作为时钟源 rst :in std_logic; - -rst 复位 shi: out std_logic_vector(3 downto 0); ge: out std_logic_vector(3 downto 0); 分钟的十、个位 carry :out std_logic ); end entity fen_60; architecture art1 of fen_60 is signal tem1: std_logic_vector(3 downto 0); -定义与端口等宽的信号 signal tem2: std_logic_vector(3 downto 0); -位矢量 begin process(clk,rst) begin if(rst=0 ) then tem1=0000; tem2=0000; elsif clkevent and clk=1 then if tem1=1001 then -当个位计数到9时,向十位进位,并tem1=0000; -且个位归零if tem2=0101 then tem2=0000; carry=1; else tem2=tem2+1;carry=0; end if; else tem1=tem1+1; end if; end if; shi=tem2;ge=tem1;end process; end art1;fen_60的时序仿真波形如图所示: 图4 .fen_60的时序仿真波形图3.3时钟模块 此模块主要由输入端口clk=carry(分钟)的频率源作为计数器的时钟,当计数到24归零。 hour_24源代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity hour_24 is port(clk :in std_logic; rst :in std_logic; shi: out std_logic_vector(3 downto 0); ge: out std_logic_vector(3 downto 0); carry :out std_logic ); end entity hour_24; architecture art3 of hour_24 is signal tem1: std_logic_vector(3 downto 0); signal tem2: std_logic_vector(3 downto 0); begin process(clk,rst) begin if(rst=0 ) then tem1=0011; -复位时时钟2位显示23 tem2=0010; elsif clkevent and clk=1 then if (tem2=0010 and tem1=0011) then tem1=0000; tem2=0000; carry=1; else carry=0; if tem1=1001 then tem1=0000; tem2=tem2+1; else tem1=tem1+1; end if; end if; end if; shi=tem2;ge=tem1;end process; end art3;hour_24的时序仿真波形如图所示:图5.hour_24的时序仿真波形图3.4分频模块 此模块主要给秒钟模块提供1HZ的时钟频率用来计时,同时分频得到200HZ用来使6个数码管动态显示。当动态显示的时钟频率大于20ZH时,由于人眼的错觉感觉6个数码管同时在显示。fenpin_1HZd的源代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity fenpin_1HZ is -对试验箱提供的6MHZ的频率分 port( clk1 : in std_logic; -频得到1HZ的频率 qout : out std_logic ); end entity; -分频常数=提供时钟频率/需要的时 architecture art7 of fenpin_1HZ is -钟频率 constant counter: integer :=5999999; -分频常数为6*106 begin process(clk1, rst) variable cnt:integer range 0 to counter; begin elsif clk1event and clk1=1 then if cnt=counter then cnt:=0; else cnt:=cnt+1; end if; case cnt is when 0 to counter/2=qout=0; -使产生的方波占空比 when others =qout=1; -等于50% end case; end if; end process; end art7;fenpin_1HZ的时序仿真波形如图所示:图6.fenpin_1HZ的时序仿真波形fenpin_2000HZ源代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity fenpin_2000HZ is -数码管动态显示的2000HZ port( clk200 : in std_logic; qout : out std_logic); end entity; architecture art6 of fenpin_2000HZ is constant counter: integer :=2999; -分频常数为20000 begin process(clk200, rst) variable cnt:integer range 0 to counter; begin elsif clk200event and clk200=1 then if cnt=counter then cnt:=0; else cnt:=cnt+1; end if; case cnt is when 0 to counter/2=qout=0; -产生均匀的方波 when others =qout=1; end case; end if; end process; end art6;fenpin_300HZ的时序仿真波形如图所示:图7.fenpin_200HZ的时序仿真波形3.5数码管控制模块 此模块是实验最关键的一个部分,主要的作用是对前面的时钟、分钟、秒钟模块的显示,实验箱对数码的位选是通过74LS138译码器来实现的。(位选为低电平有效)wei_xuan源代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity wei_xuan is port(clk: in std_logic; rst: in std_logic; se1: in std_logic_vector(3 downto 0); -第一个数码管显示的内容 se2: in std_logic_vector(3 downto 0); -第二个数码管显示的内容 se3: in std_logic_vector(3 downto 0); -第三个数码管显示的内容 se4: in std_logic_vector(3 downto 0); -第四个数码管显示的内容 se5: in std_logic_vector(3 downto 0); -第五个数码管显示的内容 se6: in std_logic_vector(3 downto 0); -第六个数码管显示的内容 qout: out std_logic_vector(3 downto 0); -作为七段数码管的输入信号 sel: out std_logic_vector(2 downto 0) ); -接74ls138的输入端 end wei_xuan; architecture art4 of wei_xuan is begin process(clk,rst) variable cnt:integer range 0 to 5; begin if(rst=0) then cnt:=0; sel=XXX; -复位时位选、输出信号(seg7)不确定 qout=XXXX; elsif clkevent and clk=1 then if cnt=5 then cnt:=0; else cnt:=cnt+1; end if; case cnt is when 0=qout=se1; sel=000; -第一个数码管的驱动信号 when 1=qout=se2;sel=001; when 2=qout=se3;sel=010; when 3=qout=se4;sel=011; when 4=qout=se5;sel=100; when 5=qout=se6;sel=101;-第六个数码管的驱动信号,罗列了case语句的所有可能,所以不需要when others、 end case; end if; end process; end art4;wei_xuan的时序仿真波形如图所示:图8.wei_xuan的时序仿真波形3.6七段译码显示模块此模块是将位选的信号译码为十进数在数码管上显示,实验箱为高电平点亮。seg7源代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity seg7 is port(qin:in std_logic_vector(3 downto 0); -数码管的输入信号 qout:out std_logic_vector(7 downto 0) ); -七段译码对应的编码 end seg7; architecture art5 of seg7 is begin with qin select qout=00000011 when 0000, - 显示09 10011111 when 0001, 00100101 when 0010, 00001101 when 0011, 10011001 when 0100, 01001001 when 0101, 01000001 when 0110, 00011111 when 0111, 00000001 when 1000, 00011001 when 1001, XXXXXXXX when others; -数码管显示不确定 end art5;seg7的时序仿真波形如图所示:图9.seg7的时序仿真波形3.7顶层模块 顶层模块主要是把各个模块通过映射连接起来,实现工程。其模块用到了元件定义和例化语句,在这里当前设计实体相当于一个较大的电路系统,所定义的例化元件相当于一个要插在这个电路系统板上的芯片,而当前设计实体中指定的端口则相当于这快电路板上准备接受此芯片的一个插座。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity shuzizhong is -顶层实体定义 port( clk :in std_logic; -外界时钟源 rest :in std_logic; -复位、开关 wei :out std_logic_vector(2 downto 0); -数码管位选 duan :out std_logic_vector(7 downto 0) ); -数码管译码 end entity; architecture art of shuzizhong is component miao_60 is -秒钟模块元件定义语句 port(clk :in std_logic; rst :in std_logic;shi: out std_logic_vector(3 downto 0);ge: out std_logic_vector(3 downto 0);carry :out std_logic ); end component miao_60; component fen_60 is -分钟模块元件定义语句 port(clk :in std_logic; rst :in std_logic;shi: out std_logic_vector(3 downto 0);ge: out std_logic_vector(3 downto 0);carry :out std_logic ); end component fen_60; component hour_24 is -小时模块元件定义语句 port(clk :in std_logic; rst :in std_logic;shi: out std_logic_vector(3 downto 0);ge: out std_logic_vector(3 downto 0);carry :out std_logic ); end component hour_24; component wei_xuan is -位选模块元件定义语句 port(clk: in std_logic; rst: in std_logic; se1: in std_logic_vector(3 downto 0); se2: in std_logic_vector(3 downto 0); se3: in std_logic_vector(3 downto 0); se4: in std_logic_vector(3 downto 0); se5: in std_logic_vector(3 downto 0); se6: in std_logic_vector(3 downto 0); qout: out std_logic_vector(3 downto 0); sel: out std_logic_vector(2 downto 0) ); end component wei_xuan; component seg7 is -七段译码模块元件定义语句port( qin:in std_logic_vector(3 downto 0); qout:out std_logic_vector(7 downto 0) ); end component seg7; component fenpin_300HZ is -20000分频模块元件定义语句 port( clk200 : in std_logic;rst : in std_logic;qout : out std_logic); end component fenpin_2000HZ; component fenpin_1HZ is -6*106分频模块元件定义语句 port( clk1 : in std_logic;rst : in std_logic;qout : out std_logic); end component fenpin_1HZ; signal c1,c2,s0,s1,s2:std_logic; -原件例化语句 signal q1,q2,q3,q4,q5,q6,s_eg: std_logic_vector(3 downto 0); -申明的中间信号 begin - 用来连接不同的模块 u0: fenpin_2000HZ port map(clk300=clk,rst=rest,qout=s0); u1: fenpin_1HZ port map(clk1=clk, rst=rest,qout=s1); u2: miao_60 port map(clk=s1,rst=rest,shi=q1,ge=q2, carry=c1 ); u3: fen_60 port map(clk=c1,rst=rest,shi=q3,ge=q4, carry=c2 ); u4: hour_24 port map(clk=c2,rst=rest,shi=q5,ge=q6); u5: wei_xuan port map(clk=s0,rst=rest,se1=q5,se2=q6, se3=q3,se4=q4,se5=q1,se6=q2,qout=s_eg,sel=wei); u6: seg7 port map(qin=s_eg,qout=duan );end art;shuzizhong的时序仿真波形如图所示:图10.shuzizhong时序仿真波形4.硬件测试4.1管脚的分配 当vhdl源程序编译没有问题时,对程序做时序仿真、
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 节假日反假知识培训课件
- 企业代缴社保及福利待遇综合服务合同
- 教师招聘之《小学教师招聘》过关检测试卷及答案详解(必刷)
- 教师招聘之《小学教师招聘》综合提升试卷含完整答案详解【典优】
- 2025年教师招聘之《幼儿教师招聘》考前冲刺模拟题库附参考答案详解(培优b卷)
- 教师招聘之《小学教师招聘》模拟题库(培优b卷)附答案详解
- 2025年六五普法测试试题及答案
- 幼儿园廉政教育月活动方案
- 部队组织生活自我评价及整改措施
- 教师招聘之《小学教师招聘》试题(得分题)【a卷】附答案详解
- 2025-2026学年湘美版(2024)小学美术二年级上册(全册)教学设计(附目录P208)
- 《竹节人 》第二课时ppt
- 社会责任程序文件
- 工程建设法规(全套课件405P)
- 新概念第一册Lesson-65-66练习题
- 固体物理(黄昆)第一章PPT
- 2023年重庆大学入学考试英语一本科
- 铁路公司招聘干部试题
- GB/T 1770-2008涂膜、腻子膜打磨性测定法
- 税务尽职调查报告(参考)
- 初中七年级上《综合实践》活动课程课件
评论
0/150
提交评论