智能抢答器VHDL设计.doc_第1页
智能抢答器VHDL设计.doc_第2页
智能抢答器VHDL设计.doc_第3页
智能抢答器VHDL设计.doc_第4页
智能抢答器VHDL设计.doc_第5页
已阅读5页,还剩28页未读 继续免费阅读

下载本文档

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

文档简介

电子科技大学光电信息学院课程设计论文 课程名称 现代电子技术综合实验 题目名称 基于vhdl语言的fpga智能抢答器设计论文 学 号 姓 名 指导老师 陈学英 起止时间 11月11日-11月22日 2013年 11月 21日摘要 智力抢答器作为一种快速准确判断选手抢答先后的比赛工具,现如今经常出现各类智力抢答,竞猜类比赛中。本文利用fpga开发平台为基础,以vhdl语言进行编程,在ise软件上进行开发,实现电视中比赛选手抢答器的各项功能。其中,第二章简单介绍fpga开发平台的特点、vhdl语言的特点,以及大体的开发流程。第三章主要介绍了开发软件ise和仿真软件modelsim的使用。第四章主要介绍智力抢答器的具体设计过程、原理设计、模块化设计。第五章主要对各个模块进行仿真测试,以及对最后的整个系统进行仿真测试。最后第六章,在基于整个系统仿真无误的前提下进行硬件编程下载,在实验硬件平台上测试设计结果和智力抢答器的实用性。并对这次试验进行总结。目录一、实验目的二、实验任务与要求三、实验原理、设计思路与方案四、单元模块设计与仿真模块功能、模块符号及端口说明、模块程序、仿真程序、仿真波形五、系统模块设计 顶层模块设计、系统管脚适配表、编程文件、下载成功标志、硬件调试说明六、结论 1、 实验目的 在许多比赛活动中,为了准确、公正、直观地判断出第一抢答者,通常设置一台抢答器。通过抢答器的数显,灯光和音响等手段指示出第一抢答者。同时还可以设置定时、记分犯规及奖惩等多种功能。本设计采用手动抢答的方式,有人抢答后,系统自动封锁其他人的抢答按钮,使其不能再抢答,从而实现抢答功能。2、 实验任务与要求1.基本要求(1)、编号16号的选手在规定的时间内按键抢答(2)、抢中编号锁定显示,其他无效(3)、主持按键控制清零和开始(4)、具有报警提示功能,分别提示抢答开始,有人抢答,定时时间到2.参数要求(1)、显示组数:6组(2)、报警延时:300ms(3)、抢答时间:20s3、 实验原理、设计思路与方案 抢答信号输入系统后,系统必须对最先抢到的选手进行编码,而后锁存这个编码,并将这个编码显示输出,所以需要用到编码器、锁存器和译码显示电路。而选手抢答的有效时间为20s,而且系统在有人抢中,主持人按下开关以及20s计时到但无人抢答时这三种情况下要发出警报,且警报时间延迟300ms后自动停止,故需定时电路来确定这些时限,报警电路产生时延,并用时序控制电路来协调各个部分的工作,计时时间也要显示出来。 当主持人按键为启动开始状态时,警报器发出警报,抢答编码电路进入工作状态,选手可以进行抢答。同时抢答定时电路开始从20s递减,显示器显示递减,显示器显示递减的时间,当时间未减少到0s时,有选手抢答,报警电路发出警报,显示器显示选手编号,并锁存该选手的号码直到主持人清零为止,此时抢答器的时间不再递减;当时间减到0s时,无选手抢答,报警电路发出警报,提示选手不能再抢答,显示器显示抢答时间0s不动,选手号码为无效号码或者f。当主持人按下清零信号,系统显示为初始状态。四、单元模块设计与仿真1.单元电路的划分 根据抢答器所需要实现的功能,将整体电路划分为:编码锁存电路(bmsc)、抢答定时电路(dsq)、报警器电路(bjq)、扫描显示电路(scan)、译码电路(ymq)和按键消抖(xd)六个单元电路。2.1编码锁存电路(bmsc):(1) 该电路主要实现的功能是:当主持人启动开始键,系统进入工作状态,同时48mhz时钟上升沿持续扫描6个选手的按键端口。当倒计时未到0,有选手抢答时,则对该选手的按键进行编码,并锁存该选手编码并将其输出,同时其他选手的按键抢答无效。若无选手抢答,则持续扫描,直至下一轮抢答开始。本电路共有6个端口。4个输入端口:系统时钟、开始按键信号、定时时间到信号、选手抢答按键信号。2个输出端口:选手按键编码信号、有选手抢中信号。(2) 模块程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;- uncomment the following library declaration if instantiating- any xilinx primitives in this code.-library unisim;-use unisim.vcomponents.all;entity bmsc is port ( clk : in std_logic; start : in std_logic; sjd : in std_logic; xs : in std_logic_vector (5 downto 0); s : out std_logic_vector (3 downto 0); qz : out std_logic );end bmsc;architecture behavioral of bmsc issignal q_z:std_logic;signal en:std_logic:=0;signal q:std_logic_vector(3 downto 0):=0000;beginstate:process(start) begin if start event and start =0 then en q = 0001; q_z q = 0010; q_z q = 0011; q_z q = 0100; q_z q = 0101; q_z q = 0110; q_z q =0000; end case; end if ; else q =0000; q_z =1; end if ; end if ; end process; s = q; qz 0);-outputssignal s : std_logic_vector(3 downto 0);signal qz : std_logic;begin- instantiate the unit under test (uut)uut: bmsc port map(clk = clk,start = start,sjd = sjd,xs = xs,s = s,qz = qz);tb : processbegin clk=0; wait for 100 ps;clk=1; wait for 100 ps;end process; stm: process begin start=1; xs=111111; sjd=1; wait for 50 ns ;start=0;wait for 100 ns;start=1;wait for 200 ns;xs=111101;wait for 200 ns;xs=110111;wait for 300 ns;start=0;wait for 100 ns;start=1;xs=111111;wait for 500 ns ;start=0;wait for 200 ns;start=1;wait for 100 ns;sjd=0;wait for 300 ns;xs=011111;wait for 200 ns;end process;end; bmsc仿真波形 2.2定时电路(dsq)(1)该电路主要实现的功能是:规定20秒倒计时时间。本模块共有5个端口,3个输入端口:基准时间源,开始键信号,选手抢中信号;两个输出端口:时间到报警信号和实时计数输出端口。 为了实现按秒计时,首先要设计一个分频器来计算1hz的标准时间信号。(2) 模块程序- company: - engineer: - - create date: 20:53:24 11/13/2013 - design name: - module name: dsp - behavioral - project name: - target devices: - tool versions: - description: - dependencies: - revision: - revision 0.01 - file created- additional comments: -library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;- uncomment the following library declaration if instantiating- any xilinx primitives in this code.-library unisim;-use unisim.vcomponents.all;entity dsp isport(clk:in std_logic; qz:in std_logic; start:in std_logic; sjd:out std_logic; t10:out std_logic_vector(3 downto 0); t0:out std_logic_vector(3 downto 0);end dsp;architecture behavioral of dsp issignal cnt:integer range 1 to 24000000:=1;signal clk_1hz:std_logic:=1;signal en:std_logic:=0;signal m10,m0:std_logic_vector(3 downto 0);beginfp:process(clk) is begin if clk event and clk=1 then if cnt=24000000 then cnt =1;clk_1hz =not clk_1hz;else cnt =cnt+1;end if; end if;end process;state:process(start) begin if start event and start=0 then en = not en;end if;end process;jsq:process(en,qz,clk_1hz) is begin if en=0 then m10 =0010;m0=0000;sjd=1;elsif clk_1hz event and clk_1hz=1 then if qz=1 then if m10=0 and m0=0 then m10=0000;m0=0000; sjd=0; else if m0=0 and m10/=0 then m0=1001;m10 =m10-1; else m0 = m0-1;end if;end if;end if;end if;end process;t0 = m0;t10 clk,qz = qz,start = start,sjd = sjd,t10 = t10,t0 = t0);tb : processbegin clk=0; wait for 10 ns;clk=1; wait for 10 ns;end process; stim : processbegin start=1;qz=1; wait for 100 ns; start=0; wait for 100 ns; start=1; wait for 1100 us; start=0; wait for 100 ns; start=1; wait for 100 us; start=0; wait for 100 ns; start=1; wait for 200 us; qz=0; wait for 100 us; start=0; wait for 100 ns; start=1; wait for 100 us; end process;end; dsq仿真波形2.3报警电路(bjq)(1)该电路主要实现的功能是:在开始键按下、有选手抢答、计时时间到这三种情况下,报警器发出警报,警报延时(学号+300)ms后结束。 本电路共有5个端口。4个输入端口:基准时间源信号、开始键信号、选手抢中信号、时间到信号。1个输出端口:报警信号。三路报警触发信号最终要通过一个与门来进行整合。(2)模块程序- company: - engineer: - - create date: 20:55:37 11/13/2013 - design name: - module name: bjq - behavioral - project name: - target devices: - tool versions: - description: - dependencies: - revision: - revision 0.01 - file created- additional comments: -library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;- uncomment the following library declaration if instantiating- any xilinx primitives in this code.-library unisim;-use unisim.vcomponents.all;entity bjq isport(clk:in std_logic;qz,sjd,start:in std_logic;bj:out std_logic);end bjq;architecture behavioral of bjq issignal bj1,bj2,bj3:std_logic;signal en:std_logic:=0;beginstate:process(start)beginif start event and start=0 thenen = not en;end if;end process;t1:process(clk,en)variable q:integer range 1 to 14400000:=1;beginif en=0 thenbj1 =1; q:=1;elseif clk event and clk=1 thenif q=14400000 thenbj1 =1;elseq:=q+1;bj1=0;end if;end if;end if;end process;t2:process(clk,qz)variable q:integer range 1 to 14400000:=1;beginif qz=1 thenbj2 =1; q:=1;elseif clk event and clk=1 thenif q=14400000 thenbj2 =1;elseq:=q+1;bj2 =0;end if;end if;end if;end process;t3:process(clk,sjd)variable q:integer range 1 to 14400000:=1;beginif sjd=1 thenbj3=1;q:=1;elseif clk event and clk=1 thenif q=14400000 thenbj3 =1;elseq:=q+1;bj3 =0;end if;end if;end if;end process;bj clk,qz = qz,sjd = sjd,start = start,bj = bj);tb : processbegin clk=0;wait for 10 ns;clk=1;wait for 10 ns;end process; stm_proc : processbegin start=1; qz=1; sjd=1; wait for 50 ns; start =0;wait for 100 ns; start =1;wait for 150 ms; qz=0;wait for 200 ms; sjd=0;wait for 280 ms; start=0;wait for 100 ns; start=1;wait for 1 ms;end process;end;bjq仿真波形2.4扫描显示电路(scan)(1)该电路主要实现的功能是:对倒计时时间和抢到的选手号码进行显示。本电路共有6个端口。4个输入端口:系统时钟、选手号码、时间十位数据、时间个位数据;2个输出端口:输出的三位扫描信号,显示数据信号。(2) 模块程序- company: - engineer: - - create date: 20:57:27 11/13/2013 - design name: - module name: scan - behavioral - project name: - target devices: - tool versions: - description: - dependencies: - revision: - revision 0.01 - file created- additional comments: -library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;- uncomment the following library declaration if instantiating- any xilinx primitives in this code.-library unisim;-use unisim.vcomponents.all;entity scan isport ( clk : in std_logic; s : in std_logic_vector (3 downto 0); t10 : in std_logic_vector (3 downto 0); t0 : in std_logic_vector (3 downto 0); dig : out std_logic_vector (2 downto 0); dout : out std_logic_vector (3 downto 0);end scan;architecture behavioral of scan issignal cnt:integer range 1 to 24000:=1;signal clk1k:std_logic:=0;signal q:std_logic_vector(2 downto 0):=000;beginprocess(clk)beginif clkevent and clk=1 thenif cnt=24000 thencnt=1;clk1k=not clk1k;elsecnt=cnt+1;end if;end if;end process;process(clk1k)beginif clk1k event and clk1k=1 thenif q=111 thenq=000;elseqdout dout dout dout =1111;end case;end process;dig0);signal t10 : std_logic_vector(3 downto 0) := (others=0);signal t0 : std_logic_vector(3 downto 0) := (others=0);-outputssignal dig : std_logic_vector(2 downto 0);signal dout : std_logic_vector(3 downto 0);begin- instantiate the unit under test (uut)uut: scan port map(clk = clk,s = s,t10 = t10,t0 = t0,dig = dig,dout = dout);tb : processbegin clk=0; wait fo

温馨提示

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

评论

0/150

提交评论