ImageVerifierCode 换一换
格式:DOCX , 页数:13 ,大小:339.16KB ,
资源ID:8627501      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/8627501.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(多功能秒表计数器.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

多功能秒表计数器.docx

1、多功能秒表计数器深 圳 大 学 实 验 报 告 课程名称: 基于VHDL编程的FPGA设计 实验名称: 多功能秒表计数器 学院: 信息工程学院 专业: 电子信息工程 班级: 2010级电子2班 组号: 指导教师: 报告人: 学号: 实验时间: 2012 年 11 月 16 日 星期 三 实验地点 南区N411 实验报告提交时间: 2012.11.28 实验要求:题目、多功能秒表计数器基本要求(必选):设计一个秒表,它具有计时功能。此秒表有两个按键(reset, start)按下reset键后,秒表清零,按下start键后,开始计时, 再次按下start键后, 停止计时, 用FPGA开发板上的两

2、个七段数码管显示时间(以秒为单位),计时由0 到 99 循环。高级要求(可选):实现基本要求的前提下,增加一个按键(select),用于轮流切换两个七段数码管分别显示百分之一秒,秒,或对于Nexys2 和 Nexy3开发板,按下select键之后,四个七段数码管同时显示秒和百分之一秒。规格说明:1. 通过按下reset键,将秒表清零,准备计时,等检测到start键按下并松开后,开始计时 。如果再次检测到start键按下并松开后,停止计时。通过不断检测start键,来确定秒表是否开始计时。2. 在秒表计时时,七段数码管能够循环的由0099,0099。3. 开始默认两个七段数码管显示秒, 在检测到

3、select键按下并松开后,数码管切换到显示百分之一秒,当再次检测到select键按下并松开后,数码管切换到重新显示秒。4. 在秒表停止时,数码管依然能够正常切换显示秒,百分之一秒。5. 本实验使用FPGA开发板:Nexys2 或 Nexys3或旧板(建project时,需要选择该芯片的型号)。实验内容:A.VHDL程序代码library IEEE;use IEEE.STD_LOGIC_1164.ALL;entity Counter is Generic(N : integer := 250000); Port (clk,reset,start,sel:in std_logic; ANO :o

4、ut std_logic_vector(3 downto 0); digit :out std_logic_vector(7 downto 0);end Counter;architecture Behavioral of Counter is signal Clk_1hz :std_logic :=0;signal Clk_1Hhz :std_logic :=0; signal Clk_1Khz :std_logic :=0;signal digit3:integer range 0 to 10 :=0;signal digit2:integer range 0 to 10 :=0;sign

5、al digit1:integer range 0 to 10 :=0;signal digit0:integer range 0 to 10 :=0;signal R_flag:integer range 0 to 10 :=0;signal S_flag:integer range 0 to 10 :=0;signal X_flag:integer range 0 to 10 :=0;begin-分频器- process(clk) variable count0:integer range 0 to 25000000 :=0; variable count1:integer range 0

6、 to 25000000 :=0; variable count2:integer range 0 to 25000000 :=0; begin if(clkevent and clk = 1) then count0 := count0+1; count1 := count1+1; count2 := count2+1; -频率_秒- if(count0 = 24999999) then Clk_1hz = not Clk_1hz; count0 := 0; end if;-频率_秒-频率_白分秒- if(count1 = 249999) then Clk_1Hhz = not Clk_1H

7、hz; count1 := 0; end if;-频率_白分秒-频率_数码管- if(count2 = 24999) then Clk_1Khz = not Clk_1Khz; count2 := 0; end if; -频率_数码管- end if; end process;-分频器-reset按键- process(clk,reset) variable count:integer range 0 to 25000000 :=0; begin if(clkevent and clk = 1) then if(reset = 1) then -消抖处理 if(count = N) then

8、count := 0; else count := count+1; end if; if(count = N-1)then -消抖处理 if(reset = 1) then R_flag = 1 ; end if; end if; else R_flag = 0 ; end if; end if; end process;-reset按键-start按键- process(clk,start) begin if(startevent and start = 0) then S_flag = S_flag+1; if(S_flag = 2) then S_flag = 0; end if; e

9、nd if; end process;-start按键-select按键- process(clk,sel) begin if(selevent and sel = 0) then X_flag = X_flag+1; if(X_flag = 1) then X_flag digit3 = 0; digit2 = 0; digit1 = 0; digit0 digit3 = digit3; digit2 = digit2; digit1 = digit1; digit0 digit0 = digit0+1; if(digit0 = 9) then digit0 = 0; digit1 = di

10、git1+1; if(digit1 = 9) then digit1 = 0; digit2 = digit2+1; if(digit2 = 9) then digit2 = 0; digit3 = digit3+1; if(digit3 = 9) then digit3 NULL; end case; end if; end process; -按键处理-数码管显示处理- process(Clk_1Khz) variable Tdigit:std_logic_vector(7 downto 0):=00000011; variable D_flag:integer range 0 to 3

11、:=0; variable TANO :std_logic_vector(3 downto 0) :=0011; variable Temp :integer range 0 to 10 :=0; begin if(Clk_1Khzevent and Clk_1Khz = 1) then if(X_flag = 0) then if(D_flag = 3) then D_flag := 2; case Temp is when 0 = Tdigit := 00000011; when 1 = Tdigit := 10011111; when 2 = Tdigit := 00100101; wh

12、en 3 = Tdigit := 00001101; when 4 = Tdigit := 10011001; when 5 = Tdigit := 01001001; when 6 = Tdigit := 01000001; when 7 = Tdigit := 00011111; when 8 = Tdigit := 00000001; when 9 = Tdigit := 00001001; when others = NULL; end case; end if; ANO = TANO; digit clk, reset = reset, start = start, sel = se

13、l, ANO = ANO, digit = digit ); - Clock process definitions clk_process :process begin clk = 0; wait for clk_period/2; clk = 1; wait for clk_period/2; end process; - reset process definitions reset_process :process start : IN std_logic; sel : IN std_logic; ANO : OUT std_logic_vector(3 downto 0); digi

14、t : OUT std_logic_vector(7 downto 0) ); END COMPONENT; begin reset = 0; wait for reset_period/2; reset = 1; wait for reset_period/2; end process; - start process definitions start_process :process begin start = 0; wait for start_period/2; start = 1; wait for start_period/2; end process; - sel proces

15、s definitions sel_process :process begin sel = 0; wait for sel_period/2; sel = 1; wait for sel_period/2; end process; - Stimulus process stim_proc: process begin - hold reset state for 100 ns. wait for 100 ns; wait for clk_period*10; - insert stimulus here wait; end process;END;综合后的仿真波形:仿真波形布局布线后的仿真

16、波形:仿真波形实验图片: - ASM图实验过程分析:一、代码分析I. 时钟分频器分析。秒表共用到两个时钟频率:100hz和1000hz。FPGA板子上提供的是50Mhz的时钟频率,采用分频器的 思想可将其分为100hz和1000hz,供时钟计数和数码管扫描使用。II. 按键标志分析。 对“复位键”,“开始_停止键”,“选择键”进行状态标志,以便在另一个Process中对标志进行处理。III.按键处理分析。对于按键标志的状态进行处理,分别列出不同状态下的Model值,再采用case语句进行条件分析,并 作出不同的功能操作。IV. 数码管显示处理分析。采用1000hz的频率对数码管进行扫描输出,其

17、中包括对“选择键”的判断,即数码管以两位显示,还是以四位显示。V. 按键消抖分析。 通过计数延时的方法进行按键消抖操作。2、仿真分析与实验结果对照通过仿真图像的分析以及实验结果的对照,满足了设计的要求,做到了通过按下reset键,将秒表清零,准备计时,等检测到start键按下并松开后,开始计时 。如果再次检测到start键按下并松开后,停止计时。通过不断检测start键,来确定秒表是否开始计时。在秒表计时时,七段数码管能够循环的由0099,0099。开始默认两个七段数码管显示秒, 在检测到select键按下并松开后,数码管切换到显示百分之一秒,当再次检测到select键按下并松开后,数码管切换到重新显示秒。在秒表停止时,数码管依然能够正常切换显示秒,百分之一秒。 实验心得总结:通过这一次的实验,设计秒表程序的规模明显比之前的要大很多,也要难好多。这个过程,我采用了控制变量法不断对自己的猜想不断进行验证,并且学会了多process进程的使用,包括process之间的关系,process之间的信号传递等等。另一点则是对数码管的位选,段选有了更透彻的理解以及按键如何实现消抖操作,使其系统更加稳定。指导教师批阅意见:成绩评定: 指导教师签字: 年 月 日备注:注:1、报告内的项目或内容设置,可根据实际情况加以调整和补充。 2、教师批改学生实验报告时间应在学生提交实验报告时间后10日内。

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1