fpga 抢答器VHDL源代码

合集下载

「基于VHDL的智力竞赛抢答器完全设计」

「基于VHDL的智力竞赛抢答器完全设计」

「基于VHDL的智力竞赛抢答器完全设计」智力竞赛抢答器是一种常见的比赛辅助设备,它可以帮助比赛主持人快速确定哪位选手按下抢答器按钮,并且在一定的时间内限制其他选手抢答。

本文将基于VHDL(Very High Speed Integrated Circuit Hardware Description Language)对智力竞赛抢答器进行完全设计。

首先,我们需要确定抢答器的基本功能。

智力竞赛抢答器应该具备以下功能:1.按下按钮时抢答器需要发出信号,主持人可以通过这个信号来确认哪位选手抢答。

2.如果已经有选手抢答,其他选手不能再次抢答,抢答器需要提供信号以阻止其他选手抢答。

基于上述功能需求,我们可以进行如下设计。

首先,我们需要使用VHDL语言定义抢答器所需要用到的模块和信号。

```entity 抢答器 isportStart_Button : in std_logic; -- 抢答器按钮输入信号Response : out std_logic; -- 抢答信号Busy : out std_logic -- 抢答器忙碌信号end entity 抢答器;```在抢答器模块中,我们需要定义两个重要的信号:Start_Button,表示抢答器按钮的输入信号;Response,表示抢答信号的输出;Busy,表示抢答器忙碌信号的输出。

接下来,我们需要定义这些信号的行为。

根据抢答器的功能需求,我们可以进行如下行为定义。

```architecture 抢答器行为 of 抢答器 issignal isPressed : std_logic := '0'; -- 按钮按下信号signal isBusy : std_logic := '0'; -- 抢答器忙碌信号beginprocess(Start_Button)beginif Start_Button = '1' and isBusy = '0' then -- 按钮按下,且抢答器没有被占用isPressed <= '1'; -- 设置按钮按下信号为1isBusy <= '1'; -- 设置抢答器忙碌信号为1end if;if isPressed = '1' then -- 如果按钮被按下Response <= '1'; -- 输出抢答信号else -- 如果按钮未被按下Response <= '0'; -- 不输出抢答信号end if;end process;--重置抢答器状态reset_process : processbeginif Start_Button = '0' thenisPressed <= '0'; -- 标记按钮未被按下isBusy <= '0'; -- 标记抢答器未被占用end if;end process;--根据抢答器的状态设置忙碌信号busy_signal_process : process(response, isBusy) beginif isBusy = '1' thenBusy <= '1'; -- 输出忙碌信号elseBusy <= '0'; -- 不输出忙碌信号end if;end process;end architecture 抢答器行为;```以上代码定义了抢答器的行为,通过进程的方式处理输入信号,并根据当前的状态输出相应的信号。

VHDL源代码

VHDL源代码

VHDL源代码:library ieee; --显示器彩条发生器use VGA isport(clk,mode :in std_logic; --扫描时钟/显示模式选择时钟d,hs,vs,r,g,b:out std_logic); --行,场同步/红,绿,蓝end VGA;architecture a of VGA issignal hs1,vs1,fclk,cclk,divide_clk,dly: std_logic;signal mmode :std_logic_vector(1 downto 0); --方式选择signal cnt :std_logic_vector(2 downto 0);signal fs :std_logic_vector(3 downto 0);signal cc :std_logic_vector(4 downto 0); --行同步/横彩条生成 signal ll :std_logic_vector(8 downto 0); --长同步/竖彩条生成 signal grbh :std_logic_vector(3 downto 1); --X 横彩条signal grby :std_logic_vector(3 downto 1); --Y 竖彩条signal grbx :std_logic_vector(3 downto 1); --文字signal grbt :std_logic_vector(3 downto 1); --图案signal grbp :std_logic_vector(3 downto 1);signal grb :std_logic_vector(3 downto 1);signal x :integer range 0 to 800;signal x1: integer range 0 to 800;signal y1: integer range 0 to 600;signal x2: integer range 0 to 800;signal x3: integer range 0 to 800;signal x4: integer range 0 to 800;signal x5: integer range 0 to 800;signal x7: integer range 0 to 800;signal x8: integer range 0 to 800;signal x9: integer range 0 to 800;signal x10: integer range 0 to 800;signal x11: integer range 0 to 800;signal y2: integer range 0 to 600;signal y3: integer range 0 to 600;signal y4: integer range 0 to 600;signal y5: integer range 0 to 600;signal y6: integer range 0 to 600;signal c: integer range 0 to 30;begingrb(3)<=(grbp(3) xor mode) and hs1 and vs1;grb(2)<=(grbp(2) xor mode) and hs1 and vs1;grb(1)<=(grbp(1) xor mode) and hs1 and vs1;process(mode)beginif mode'event and mode='1' thenif mmode="11" thenmmode<="00";elsemmode<=mmode+1;end if;end if;end process; --四种模式process (mmode)beginif mmode="00" then grbp<=grbx;elsif mmode="01" then grbp<=grbh; --选择横彩条 elsif mmode="10" then grbp<=grby; --选择竖彩条elsif mmode="11" then grbp<=grbh xor grby; --选择棋盘格 else grbp<="000";end if;end process;process(clk) --3/4分频 beginif clk'event and clk='1' thencnt<=cnt+3;dly<=cnt(2);end if;--if cnt<3 then-- divide_clk<='0';--elsif cnt<5 then-- divide_clk<='1';--else-- cnt<="000";--end if;end process;divide_clk<=(cnt(2) xor dly) and clk;process(divide_clk) --13分频beginif divide_clk'event and divide_clk='1' thenif fs=12 thenfs<="0000";elsefs<=fs+1;end if;end if;end process;process(fclk)beginif fclk'event and fclk='1' thenif cc=29 thencc<="00000";elsecc<=cc+1;end if;end if;end process;d<=fclk;process(cclk)beginif cclk'event and cclk='1' thenif ll=481 thenll<="000000000";elsell<=ll+1;end if;end if;end process;process(cc,ll)beginif cc>23 then --行同步hs1<='0';elsehs1<='1';end if;if ll>479 then --长同步 vs1<='0';elsevs1<='1';end if;end process;process(clk)beginif clk'event and clk='1' thenif hs1='0' thenx<=0;elsex<=x+1;end if;end if;end process;process(x,ll,cc,hs1,vs1)variable s1: integer range 0 to 3;beginif cc<3 then grbh<="111"; --竖彩条 elsif cc<6 then grbh<="110";elsif cc<9 then grbh<="101";elsif cc<12 then grbh<="100";elsif cc<15 then grbh<="011";elsif cc<18 then grbh<="010";elsif cc<21 then grbh<="001";else grbh<="000";end if;if ll<60 then grby<="111"; --横彩条 elsif ll<120 then grby<="110";elsif ll<180 then grby<="101";elsif ll<240 then grby<="100";elsif ll<300 then grby<="011";elsif ll<360 then grby<="010";elsif ll<420 then grby<="001";else grby<="000";end if;if x=4 thengrbx<="100";elsif x=180 thengrbx<="001";elsegrbx<="000";end if;if ll>20 and ll<24 thenif x<110 thengrbx<="100";end if;end if;if ll>30 and ll<33 thenif x<80 thengrbx<="100";end if;end if;if ll>445 and ll<449 thenif x>90 thengrbx<="001";end if;end if;if ll>437 and ll<440 thenif x>100 thengrbx<="001";end if;end if;--"湖"if ll>89 and ll<94 thenif x=100 or x=103 or x=106 or x=107 or x=108 then grbx<="110";end if;end if;if ll>93 and ll<98 thenif x=102 or x=103 or x=104 or x=106 or x=108 then grbx<="110";end if;end if;if ll>97 and ll<102 thenif x=100 or x=103 or x=106 or x=107 or x=108 then grbx<="110";end if;end if;if ll>101 and ll<106 thenif x=102 or x=103 or x=104 or x=106 or x=108 thengrbx<="110";end if;end if;if ll>105 and ll<110 thenif x=100 or x=102 or x=104 or x=106 or x=107 or x=108 then grbx<="110";end if;end if;if ll>109 and ll<114 thenif x=100 or x=102 or x=103 or x=104 or x=106 or x=108 then grbx<="110";end if;end if;if ll>113 and ll<118 thenif x=106 thengrbx<="110";end if;end if;--"南"if ll>121 and ll<126 thenif x=104 thengrbx<="110";end if;end if;if ll>125 and ll<130 thenif x>99 and x<109 thengrbx<="110";end if;if ll>129 and ll<134 thenif x=104 thengrbx<="110";end if;end if;if ll>133 and ll<138 thenif x>99 and x<109 thengrbx<="110";end if;end if;if ll>137 and ll<142 thenif x=100 or x=108 thengrbx<="110";end if;end if;if ll>141 and ll<146 thenif x=100 or x=103 or x=105 or x=108 thengrbx<="110";end if;end if;if ll>145 and ll<150 thenif x=100 or x=102 or x=103 or x=104 or x=105 or x=106 or x=108 then grbx<="110";end if;end if;if ll>149 and ll<154 thenif x=100 or x=104 or x=108 thengrbx<="110";end if;if ll>153 and ll<158 thenif x=100 or x=102 or x=103 or x=104 or x=105 or x=106 or x=108 thengrbx<="110";end if;end if;if ll>157 and ll<162 thenif x=100 or x=104 or x=108 thengrbx<="110";end if;end if;--"大"if ll>165 and ll<170 thenif x=103 or x=104 thengrbx<="110";end if;end if;if ll>169 and ll<174 thenif x=103 or x=104 thengrbx<="110";end if;end if;if ll>173 and ll<178 thenif x=100 or x=101 or x=102 or x=103 or x=104 or x=105 or x=106 or x=107 or x=108 thengrbx<="110";end if;end if;if ll>177 and ll<182 thenif x=103 or x=104 thengrbx<="110";end if;end if;if ll>181 and ll<186 thenif x=103 or x=104 thengrbx<="110";end if;end if;if ll>185 and ll<190 thenif x=103 or x=105 thengrbx<="110";end if;end if;if ll>189 and ll<194 thenif x=102 or x=103 or x=106 thengrbx<="110";end if;end if;if ll>193 and ll<198 thenif x=101 or x=102 or x=107 thengrbx<="110";end if;end if;if ll>197 and ll<202 thenif x=100 or x=101 or x=107 or x=108 then grbx<="110";end if;end if;--"学"if ll>205 and ll<210 thenif x=102 or x=104 or x=106 thengrbx<="110";end if;end if;if ll>209 and ll<214 thenif x=100 or x=101 or x=102 or x=103 or x=104 or x=105 or x=106 or x=107 or x=108 thengrbx<="110";end if;end if;if ll>213 and ll<218 thenif x=100 or x=108 thengrbx<="110";end if;end if;if ll>217 and ll<222 thenif x=102 or x=103 or x=104 or x=105 or x=106 thengrbx<="110";end if;end if;if ll>221 and ll<226 thenif x=105 thengrbx<="110";end if;end if;if ll>225 and ll<230 thenif x=104 thengrbx<="110";end if;end if;if ll>229 and ll<234 thenif x=100 or x=101 or x=102 or x=103 or x=104 or x=105 or x=106 or x=107 or x=108 thengrbx<="110";end if;end if;if ll>233 and ll<238 thenif x=104 thengrbx<="110";end if;end if;if ll>237 and ll<242 thenif x=104 thengrbx<="110";end if;end if;if ll>241 and ll<245 thenif x=103 or x=104 thengrbx<="110";end if;end if;if vs1'event and vs1='1' thenif c=20 thenc<=0;case s1 iswhen 0 =>if x1=120 thens1:=1;elsex1<=x1+1 ; end if;when 1 =>if y1=350 thens1:=2;elsey1<=y1+1; end if;when 2 =>if x1=35 thens1:=3;elsex1<=x1-1; end if;when 3 =>if y1=280 thens1:=0;elsey1<=y1-1; end if;end case;elsec<=c+1;end if;end if;--"HU NAN DA XUE"x2<=x1+1;x3<=x1+2;x4<=x1+3;x5<=x1+5;x7<=x1+7;x8<=x1+8;x9<=x1+9;x10<=x1+10;x11<=x1+11;--y1<=250;y2<=y1+4;y3<=y1+8;y4<=y1+12;y5<=y1+16;y6<=y1+20;if ll>=y1 and ll<y2 thenif x=x1 or x=x5 or x=x7 or x=x8 or x=x11 thengrbx<="101";end if;end if;if ll>=y2 and ll<y3 thenif x=x1 or x=x5 or x=x7 or x=x8 or x=x9 or x=x11 then grbx<="101";end if;end if;if ll>=y3 and ll<y4 thenif x=x1 or x=x2 or x=x3 or x=x4 or x=x5 or x=x7 or x=x9 or x=x11 then grbx<="101";end if;end if;if ll>=y4 and ll<y5 thenif x=x1 or x=x5 or x=x7 or x=x10 or x=x11 thengrbx<="101";end if;end if;if ll>=y5 and ll<y6 thenif x=x1 or x=x5 or x=x7 or x=x10 or x=x11 thengrbx<="101";end if;end if;if ll>100 and 11<150 then --图案设计if ll>121 and ll<126 thenif x>43 and x<57 thengrbx<="100";end if;elsif x=50 thengrbx<="100";end if;end if;if ll>150 and 11<200 thenif ll>171 and ll<176 thenif x>60 and x<74 thengrbx<="010";end if;elsif x=67 thengrbx<="010";end if;end if;if ll>200 and 11<250 then if ll>221 and ll<226 then if x>74 and x<88 then grbx<="001";end if;elsif x=81 thengrbx<="001";end if;end if;end process;fclk<=fs(2);cclk<=cc(4);hs<= not hs1;vs<= not vs1;g<=grb(3);r<=grb(2);b<=grb(1);end a;。

数字式竞赛抢答器VHDL

数字式竞赛抢答器VHDL

数字系统设计与硬件描述语言期末考试作业题目:数字式竞赛抢答器设计学院:电子信息工程专业:电子信息工程学号:姓名:一、选题设计描述1.功能介绍此设计用于竞赛的四人抢答,有如下的功能:(1)具有多路抢答功能,台数设计为四;(2)具有抢答器开始后30秒倒计时,30秒后无人抢答显示超时,并报警;(3)能显示超前抢答犯规,并警报;(4)能显示各组得分,大队加分,答错扣分;当系统复位,主持人按下抢答开始按键,处于使能状态,抢答开始,某路抢答键按下时,该路信号将其他路信号锁存,同时抢答铃声响起,直至此路按键松开,显示该路组号。

2.算法简介本设计采用分层设计思想,分为:信号鉴别模块、计时模块、计分模块、BCD译码模块、分频器,还有顶层模块。

信号鉴别模块。

此模块主要实现抢答器的抢答功能,并能够分辨是正常抢答还是提前抢答,选取最先按下的一路信号,锁存其余信号,实现信号选取功能。

在此模块中,用到的信号为抢答信号a、b、c、d;抢答使能信号en;抢答结果信号states;警报时钟信号clk2;复位信号rst;提前抢答信号fangui。

计时模块。

此模块主要实现抢答过程中的计时功能,在抢答开始后进行30秒的倒计时,且在30秒后显示无人抢答报警信号。

其中有抢答时钟信号clk;系统复位信号rst;抢答使能信号en;无人抢答警报信号warn;计时中止信号stop;计时十位个位信号tb,ta。

计分模块。

此模块主要实现给四个抢答器计分的功能,初始条件下,为每个抢答器信号预制5分,当某组抢答且回答正确时加一分,答错减一分,未获答题机会时保持不变。

其中设有时钟信号clk;复位信号rst;抢答使能信号en;抢答结果显示信号states;记分加减信号add(add=‘1’时为加,add=‘0’时为减);四个信号的得分显示信号a_out,b_out,c_out,d_out。

BCD译码模块。

此模块主要实现将抢答结果信号显示在bcd七段译码器上。

基于FPGA的抢答器毕业设计

基于FPGA的抢答器毕业设计

摘要本文介绍了一种采用EDA技术,在QuartusII工具软件环境下用VHDL语言编写的数码显示8路抢答器的电路组成、设计思路及功能。

抢答器同时供8名选手或8个代表队比赛,分别用8个按钮[1]~[8]表示。

设置一个系统清除和抢答控制开关,该开关由主持人控制。

抢答器具有锁存与显示功能,即选手按动按钮,锁存相应的编号,扬声器发出声响提示,并在七段数码管上显示选手号码。

选手抢答实行优先锁存,优先抢答选手的编号一直保持到主持人将系统清除为止。

系统主芯片采用EP2C35F484C8,由基本时钟发生电路模块,复位电路模块,键盘防抖动模块,键盘扫描模块,数码管驱动模块,报警频率选择模块组成。

经编译和仿真所设计的程序,在可编程逻辑器件上下载验证,从而完成抢答器功能。

关键词:抢答器;硬件描述语言;可编程逻辑门阵列;AbstractThis article introduces an EDA technology tools in QuartusII environment using VHDL language digital display 8 answering device circuit design ideas and features.Responder same time for eight players or eight team competition, with eight buttons, respectively [1] ~ [8] said. Setting clear and answer in a system control switch, the switch control by the moderator. Responder has a latch and display, the player press the button, latch the corresponding number, speaker audible prompts, and seven-segment digital tube display in player numbers. Players answer in the implementation of the priority latch, first answer in player numbers has been maintained to host the system cleared.System main chip EP2C35F484C8, from the basic clock circuit module, reset the circuit module, keyboard judder module, the keyboard scan module, a digital control drive module, alarm frequency selection module. The compilation and simulation process is designed, in the programmable logic device to download verification, thus completing the Responder feature.Key words:Responder;Very Hardware Description Language; FPGA;目录摘要 (I)Abstract (II)1 绪论 (1)1.1 选题背景 (1)1.1.1 EDA技术的发展 (1)1.1.2课题研究的必要性 (2)1.2课题研究的内容 (2)2 系统方案设计 (3)2.1 FPGA简介 (3)2.1.1 FPGA基本结构 (4)2.1.2 FPGA系统设计流程 (5)2.1.3 FPGA开发编程原理 (7)2.1.4 FPGA配置模式 (7)2.2 FPGA的应用 (8)2.2.1 电路设计中FPGA的应用 (8)2.2.2 产品设计 (8)2.2.3 系统及应用 (9)2.3抢答器总体设计方案 (9)2.3.1抢答器的定义 (9)2.3.2 本文设计的抢答器的构成 (10)2.3.3 抢答器的工作原理 (10)3 系统硬件设计与实现 (12)3.1基本时钟发生模块 (12)3.2键盘防抖动模块 (13)3.2.1键盘的作用 (13)3.2.2键盘系统设计 (13)3.2.3键盘防抖动模块工作方式 (14)3.4键盘扫描模块 (15)3.5数码管驱动模块 (16)3.6报警频率选择模块 (17)4 抢答器的程序设计与实现 (18)4.1 基本时钟发生程序设计 (18)4.2 键盘防抖动程序设计 (18)4.3 键盘扫描程序设计 (19)4.4 数码管驱动程序设计 (19)4.5 报警频率选择程序设计 (20)结论 (22)致谢 (23)参考文献 (24)附录一 (25)附录二 (34)附录三 (45)1 绪论1.1 选题背景现代社会的标志之一就是信息产品的广泛使用,而且是产品的性能越来越强,复杂程度越来越高,更新步伐越来越快。

基于FPGA的八位数字抢答器

基于FPGA的八位数字抢答器

一、课程设计的内容通过学习掌握使用可编程逻辑器件和QuartusII 软件的基本使用,利用QuartusII 软件各种器件进行多路智力竞赛抢答器设计;利用DE2板对所设计的电路进行验证;总结电路设计结果。

通过设计掌握基本工程设计方法,提高动手能力。

二、课程设计的要求与数据八位数字抢答器设计要求:1). 抢答器同时供8名选手或8个代表队比赛,分别用8个按钮S0 ~ S7表示。

2). 设置一个系统清除和抢答控制开关S,该开关由主持人控制。

3). 抢答器具有锁存与显示功能。

即选手按动按钮,锁存相应的编号,并在优先抢答选手的编号一直保持到主持人将系统清除为止。

4). 抢答器具有定时抢答功能,且一次抢答的时间由主持人设定(如,30秒)。

当主持人启动"开始"键后,定时器进行减计时,同时扬声器发出短暂的声响,声响持续的时间0.5秒左右。

5). 参赛选手在设定的时间内进行抢答,抢答有效,定时器停止工作,显示器上显示选手的编号和抢答的时间,并保持到主持人将系统清除为止。

6). 如果定时时间已到,无人抢答,本次抢答无效,系统报警并禁止抢答,定时显示器上显示00。

三、课程设计应完成的工作利用QuartusII 软件各种器件画出八位数字抢答器的原理图。

对原理图进行编译修改错误;设计引脚,再重新编译;进行仿真,根据仿真结果观察设计是否符合设计要求。

然后加载到DE2板上,验证电路是否正确。

对设计进行优化、完善。

附加要求:写出设计的VHDL源程序,利用QuartusII 软件生成原理图。

进行编译修改错误;设计引脚,再重新编译;进行仿真,根据仿真结果观察设计是否符合设计要求。

然后加载到DE2板上,验证电路是否正确。

四、课程设计进程安排序号设计各阶段内容地点起止日期1熟悉QuartusII 软件,掌握QuartusII 软件的基本使用实验2号楼2142007-11-26上午2 根据设计要求进行方案设计,利用基本器件用笔画出基本原理图,给老师检修实验2号楼2142007-11-26下午至273 利用QuartusII 软件进行设计,画出原理图。

数字式竞赛抢答器的VHDL设计

数字式竞赛抢答器的VHDL设计

实验报告实验名称:VHDL实验实验日期:2012年3月7日学院:信息工程学院班级:2009级通信工程一班姓名:沈晶晶学号:2009550607数字式竞赛抢答器的VHDL设计1、设计任务及要求:设计任务:(1)设计一个可容纳8组参赛的数字式抢答器,每组设一个按钮,供抢答使用。

(2)抢答器具有第一信号鉴别和锁存功能,使除第一抢答者外的按钮不起作用。

(3)设置一个主持人“复位”按钮。

(4)主持人复位后,开始抢答,第一信号鉴别锁存电路得到信号后,由指示灯显示抢答组的编号,同时扬声器发出2~3秒的音响。

扩展功能:(5)设置一个计分电路,每组开始预制100分,由主持人计分,答对一次加10分,答错一次减10分。

设计要求:(1)采用VHDL语言编写程序,并在QUARTUS II平台中进行仿真,下载到EDA实验箱进行验证。

(2)编写设计报告,要求包括方案选择、程序清单、调试过程、测试结果及心得体会。

(3)设计时间和地点:两个星期,信息楼4楼EDA实验室。

定时抢答器的总体框图如图1所示,它由主体电路和扩展电路两部分构成,主体电路完成基本的抢答功能,即开始抢答后,当选手按动抢答键时,能显示选手的编号,同时能封锁输入电路,禁止其他选手抢答。

扩展电路完成各选手的得分显示功能。

定时抢答器的工作过程是:接通电源时,主持人将开关置于“清除”位置,抢答器处于禁止工作状态,编号显示器灭灯;抢答开始时,主持人将控制开关拨到“开始”位置,扬声器给出声响提示,抢答器处于工作状态,这时,抢答器完成以下工作:(1)优先编码器电路立即分辨出抢答者编号,并由锁存器进行锁存,然后由译码显示电路显示编号;(2)扬声器发出短暂声响,提醒主持人注意;(3)控制电路要对输入编码电路进行封锁,避免其他选手再次进行抢答;(4)当选手将问题回答完毕,主持人操作计分开关,计分电路采用十进制加/减计数器、数码管显示。

本轮抢答完毕,主持人操作控制开关,使系统回复到禁止工作状态,以便进行下一轮抢答。

8路抢答器的VHDL语言

八路抢答器由抢答启动电路、抢答定时器及定时译码显示电路、抢中报警电路、选手编号译码显示电路、答题时间限制电路,答题时间剩余显示电路和答题结束报警电路组成。

优先编码电路、锁存器、译码电路将抢中选手的编号译码显示输出;主持人开关启动和选手抢中报警电路;答题限时时间显示电路,答题时间结束和答题完成报警电路。

基于FPGA,经过程序设计、调试、仿真、下载和软硬件联合调试等工作,实现了抢答功能(另设计提供限时答题功能)。

1.设计一个八路智力抢答器,同时供8个选手参赛,编号分别为1到8。

每位选手用一个答题按钮。

2.给主持人一个控制开关,实现系统的清零和抢答的开始。

3.具有数据锁存和显示功能。

抢答开始后,如果有选手按下了抢答按钮,其编号立即锁存并显示在LED数码管上,同是扬声器报警。

此外,禁止其他选手再次抢答。

选手的编号一直保存直到主持人清除。

扩展功能:1.具有定时抢答功能,可由主持人设定抢答时间。

当抢答开始后。

定时其开始倒计时,并显示在LED上,同时扬声器发声提醒、2.选手在规定时间内抢答有效,停止倒计时,并讲倒计时时间显示在LED上,同时报警3.在规定时间内,无人抢答时,电路报警提醒主持人,此后的抢答按键无效。

4.选手抢中后,开始答题。

规定答题时间为:10s,在规定的时间内,选手答完题,手动报警。

若在规定时间内,未完成答题,报警提示。

答题时,显示答题剩余时间。

5.报警时间定为:100ms1.2.系统顶层文件顶层文件原理图:VHDL程序:library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;-- Uncomment the following lines to use the declarations that are -- provided for instantiating Xilinx primitive components.--library UNISIM;--use UNISIM.VComponents.all;entity myproject isport( clk : in std_logic; --时钟信号clear : in std_logic; --清零信号player : in std_logic_vector(7 downto 0); --八个抢答选手输入settime1 : in std_logic_vector(3 downto 0);--答题时间设置led_10s : out std_logic_vector(6 downto 0); --10s抢答计时已进行的时间显示selector : out std_logic_vector(6 downto 0); --抢中选手编码输出a udio : out std_logic; --喇叭响,低有效.endanswer : in std_logic; --答题完成led_left1 : out std_logic_vector(6 downto 0));end myproject;architecture Behavioral of myproject isc omponent qiangdap ort(set_start : in std_logic;a : in std_logic_vector(7 downto 0);clk : in std_logic;led : out std_logic_vector(6 downto 0);selector : out std_logic_vector(6 downto 0);selected : out std_logic;alarm : out std_logic);e nd component;c omponent dingshiqip ort(selected : in std_logic;clk : in std_logic;settime1: in std_logic_vector(3 downto 0);endanswer : in std_logic;alarm : out std_logic;led : out std_logic_vector(6 downto 0));e nd component;c omponent baojingp ort(clk : in std_logic;alarm1 : in std_logic;alarm2 : in std_logic;alarm3 : in std_logic;audioer : out std_logic);e nd component;s ignal selected1 : std_logic;s ignal start : std_logic:='0';s ignal alarm1 : std_logic:='0';s ignal alarm2 : std_logic;beginstartall : process(clear)beginif clear'event and clear='1' thenstart<=not start;end if;e nd process;u1: qiangda port map(start,player,clk,led_10s,selector,selected1,alarm1);u2: dingshiqi port map(selected1,clk,settime1,endanswer,alarm2,led_left1);u3: baojing port map(clk,start,alarm1,alarm2,audio);end Behavioral;系统仿真图:2、抢答模块VHDL程序:library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;-- Uncomment the following lines to use the declarations that are-- provided for instantiating Xilinx primitive components.--library UNISIM;--use UNISIM.VComponents.all;entity qiangda isport(set_start : in std_logic; --开始抢答信号(主持人按)否则一直有效,a : in std_logic_vector(7 downto 0); --八个抢答选手输入clk : in std_logic;led : out std_logic_vector(6 downto 0); --10s抢答计时已进行的时间显示selector : out std_logic_vector(6 downto 0); --抢中选手编码输出selected : out std_logic;alarm : out std_logic);end qiangda;architecture Behavioral of qiangda issignal deny1 : std_logic:='0'; --作为选中后标志signal deny2 : std_logic:='0'; --作为抢答计时结束标志signal timeon : integer range 0 to 15 :=0;signal cnt1 : integer range 0 to 32000000;beginalarm<=deny1 or deny2;selected<=deny1;select1 : process(set_start,deny2,a)beginif set_start='0' thendeny1<='0';selector<="0110000";elsif(deny1='0' and deny2='0' ) thencase a iswhen "10000000"=> selector<="1001111"; deny1<='1';when "01000000"=> selector<="0010010"; deny1<='1';when "00100000"=> selector<="0000110"; deny1<='1';when "00010000"=> selector<="1001100"; deny1<='1';when "00001000"=> selector<="0100100"; deny1<='1';when "00000100"=> selector<="0100000"; deny1<='1';when "00000010"=> selector<="0001111"; deny1<='1';when "00000001"=> selector<="0000000"; deny1<='1';when others => selector<="1111111"; --all unlaw states!!!end case;end if;end process;time10s : process(clk,deny1,set_start)beginif (clk'event and clk='1') thenif set_start='0' thendeny2<='0';timeon<=10;cnt1<=0;elsif deny1='1' thentimeon<=timeon;elsif timeon/=0 thenif cnt1/=32000000 thencnt1<=cnt1+1;elsetimeon<=timeon-1;cnt1<=0;end if;elsedeny2<='1';end if;end if;end process;ledshow : process(timeon)begincase timeon iswhen 0=> led<="0000001"; --0when 1=> led<="1001111"; --1when 2=> led<="0010010"; --2when 3=> led<="0000110"; --3when 4=> led<="1001100"; --4when 5=> led<="0100100"; --5when 6=> led<="0100000"; --6when 7=> led<="0001111"; --7when 8=> led<="0000000"; --8when 9=> led<="0000100"; --9when others => led<="1111111"; --未选中的状态,不显示end case;end process;end Behavioral;抢答电路仿真图:3.答题模块VHDL程序:(定时)library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;-- Uncomment the following lines to use the declarations that are-- provided for instantiating Xilinx primitive components.--library UNISIM;--use UNISIM.VComponents.all;entity dingshiqi is--设置答题时间,并计数,显示剩余时间,并将计数剩余时间转换为LED码输出。

基于fpga技术的智力抢答器设计

毕业论文任务书毕业设计开题报告摘要抢答环节经常出现在竞赛、文体娱乐等活动中,在活动中抢答是一种生动活泼的教育形式和方法,它通过抢答和必答方式引起参赛者和观众的兴趣,并能在短时间内,增加人们的科学知识和生活知识。

为了在比赛活动中,准确、公正、直观地判断出第一抢答者,通常需要一台抢答器,通过数显、灯光及音响等多种手段指示出第一抢答者并进行抢答、计分等功能。

所以,研究智力抢答器具有较强的实际意义。

本次设计在EDA开发平台上基于FPGA运用QuartusⅡ7.2软件和VHDL语言进行设计,进行了系统需求分析、系统的总体规划、各个模块设计及顶层文件的设计,实现了比赛中的智力抢答功能,其中包括:第一抢答鉴别功能;抢答信号输出模块;抢答计分功能;抢答以及答题倒计时功能;犯规报警功能以及分数、时间台号显示等功能。

因此本设计具有电路简单、可靠性强、运算速度高等特点。

随着相关设备的提高,我们可以考虑将抢答器的功能进行扩展,扩展成为功能更加全面的智力抢答器。

关键词:四人抢答器数码显示动态显示信号封锁犯规报警AbstractResponder links often appear in the race, sports and entertainment activities, in activities, answer in a lively and educational forms and methods, it way through the Responder and will answer participants and the audience's interest aroused, and can in a short time,to increase scientific knowledge and life knowledge.In order to match activities, accurate, fair and visually determine the first answer in person, usually a Responder, via digital display, lighting and sound and other means to direct the First Responder, and to answer in person, namely classification function.Therefore, research intelligence Responder has strong practical significance.The design of the EDA development platform FPGA using Quartus Ⅱ7.2 based software design and VHDL languages, for the system requirements analysis, system of overall planning, design and top-level documentation of each module, design and implement a game of intelligence Responder functionThese include: First Responder identification function; answer in scoring function; answer in and answer the countdown function; foul alarm function as well as scores, time, station number display.Therefore, this simple circuit design, reliability, high operation speed characteristics.With the college laboratory boxes and other equipment increased, we can consider the design to extend the functionality of answering device, extending a more comprehensive intelligence functions Responder.Key Words:Four people vie to answer first Digital demonstration Dynamic demonstration Signal blockade Violates a regulation the warning目录目录 (7)第1章绪论 (9)1.1 设计研究的相关背景 (9)1.2 设计研究的重要性 (9)1.3 国内外研究现状 (10)第2章实现工具简介 (11)2.1 FPGA简介 (11)2.2 QuartusⅡ的概况 (12)2.3 硬件描述语言的概述 (13)第3章系统软件 (15)3.1 设计任务 (15)3.1.1 方案拟定 (15)3.1.2 模块的划分 (17)3.2 抢答器鉴别模块 (17)3.2.1 抢答鉴别模块VHDL程序设计关键代码 (17)3.2.2 抢答鉴别模块元件图 (17)3.2.3 抢答鉴别模块仿真 (18)3.3 抢答信号输出模块 (18)3.3.1 抢答信号输出模块VHDL程序设计关键代码 (18)3.3.2 抢答信号输出模块元件图 (18)3.3.3 抢答信号输出模块仿真 (19)3.4 抢答计时模块 (19)3.4.1 抢答计时模块VHDL程序设计关键代码 (19)3.4.2 抢答计时模块元件图 (19)3.4.3 抢答计时模块仿真 (20)3.5 答题计时模块 (20)3.5.1 答题计时模块VHDL程序设计关键代码 (20)3.5.2 答题计时模块元件图 (21)3.5.3 答题计时模块仿真 (21)3.6 防抖动电路模块 (22)3.6.1 防抖动电路模块VHDL程序设计关键代码 (22)3.6.2 防抖动模块元件图 (23)3.6.3 防抖动模块仿真 (23)3.7 抢答计分模块 (24)3.7.1 抢答计分模块VHDL程序设计关键代码 (24)3.7.2 抢答计分模块元件图 (25)3.7.3 抢答计分模块仿真 (26)3.8 分频模块 (26)3.8.1 分频模块VHDL程序设计关键代码 (27)3.8.2 分频模块元件图 (27)3.8.3 分频模块仿真 (27)3.9 抢答显示模块 (28)3.9.1 抢答显示模块VHDL程序设计关键代码 (28)3.9.2 抢答显示模块元件图 (29)3.9.3 抢答显示模块仿真 (29)3.10 抢答报警模块 (30)3.10.1 抢答报警模块VHDL程序设计关键代码 (30)3.10.2 抢答报警模块元件图 (30)3.10.3 抢答报警模块仿真 (30)3.11 答题报警模块 (31)3.11.1 答题报警模块VHDL程序设计关键代码 (31)3.11.2 答题报警模块元件图 (31)3.11.3 答题报警模块仿真 (32)3.12 顶层模块 (32)3.12.1 顶层模块电路图 (33)3.12.2 顶层模块元件图 (33)3.12.2 顶层模块仿真 (34)第4章硬件环境及调试过程 (35)4.1 芯片介绍 (35)4.2 硬件实现 (35)4.2.1 选择芯片 (35)4.2.2 引脚锁定 (36)4.2.3 下载到硬件环境 (38)第5章总结及完善 (41)参考文献 (42)致谢 (43)附录A 英文资料翻译 (44)英文原文 (44)Building Programmable Automation Controllers with LabVIEW FPGA (44)中文译文 (49)使用LabVIEW FPGA(现场可编程门阵列)模块开发可编程自动化控制器 (49)附录B 源代码 (53)第1章绪论1.1 设计研究的相关背景抢答器是一种应用非常广泛的设备,在各种竞赛、抢答场合中,它能迅速、客观的分辨出最先获得发言权的选手。

VHDL语言设计四路抢答器

一、设计要求:在许多比赛活动中,为了准确、公正、直观地判断出第一抢答者,通常设置一台抢答器,通过数显、灯光及音响等各种手段批示出第一抢答者。

同时,还可以设置计分、犯规及奖惩记录等各种功能。

本设计的具体功能是:1.可容纳四组参赛者进行抢答,每组设置一个抢答按钮供抢答者使用。

2.电路具有第一抢答信号的鉴别和锁存功能。

在主持人交系统复位并发出抢答指令后,若有一组先按下抢答开关,则该组指示灯亮并用组别显示电路显示抢答者的组别,同时扬声器发出“嘀嘟”的双音音响,且持续2~3秒。

此时,电路具备自锁功能,使他组的抢答开关不起作用。

3.具有计分功能,使每组在开始时的分数预置成100分,抢答后由主持人计分,答对一次加10分。

二、系统方案论证与模块划分:根据系统设计要求可知:1.系统的输入信号有:各组的抢答按钮A、B、C、D,系统清零信号CLR,系统时钟信号CLK,计分复位端RST,加分按钮端ADD,计时预置控制端LDN,计时使能端EN,计时预置数据调整按钮TA、TB;2.系统的输出信号有:四个组抢答成功与否的指示灯控制信号输出口LED_A、LES_B、LED_C、LED_D,四个组抢答时的计时数码显示控制信号若干,抢答成功组别显示的控制信号若干,各组计分动态显示的控制信号若干。

3.本系统应具有的功能有:第一抢答信号的鉴别和锁存功能;抢答计时功能;各组得分的累加和动态显示功能。

根据以上的分析,我们可将整个系统分为三个主要模块:抢鉴别模块QDJB;抢答计时模块JSQ;抢答计分模块JFQ;对于需显示的信息,需增加或外接译码器,进行显示译码。

考虑到FPGA、CPLD的可用接口及一般EDA实验开发系统的输出显示资源的限制,这里我们将组别显示和计时显示的译码器内设,而将各组的计分显示的译码器外接。

整个系统的组成框图如图2-1所示:系统的工作原理如下:当主持人按下使能端EN1时,抢答器开始工作,A、B、C、D四个抢答者谁最先抢答成功则此选手的台号灯(LED_A—LED_D)将点亮,并且组别显示数码管将显示出抢答成功者的台号,并由蜂鸣器发出抢答成功的警报;接下来主持人提问,若回答正确,主持人按加分按钮ADD,抢答计分模块JFQ将给对应的组加分,并将该组的总分显示在对应的选手计分数码管JF2_A-JF0_A、JF2_B-JF0_B、JF2_C-JF0_C、JF2_D-JF0_D、上。

基于VHDL语言的FPGA智能抢答器设计论文

电子科技大学光电信息学院课程设计论文课程名称现代电子技术综合实验题目名称基于VHDL语言的FPGA智能抢答器设计论文摘要智力抢答器作为一种快速准确判断选手抢答先后的比赛工具,现如今经常出现各类智力抢答,竞猜类比赛中。

本文利用FPGA开发平台为基础,以VHDL语言进行编程,在ISE软件上进行开发,实现电视中比赛选手抢答器的各项功能。

其中,第二章简单介绍FPGA开发平台的特点、VHDL语言的特点,以及大体的开发流程。

第三章主要介绍了开发软件ISE和仿真软件ModelSim的使用。

第四章主要介绍智力抢答器的具体设计过程、原理设计、模块化设计。

第五章主要对各个模块进行仿真测试,以及对最后的整个系统进行仿真测试。

最后第六章,在基于整个系统仿真无误的前提下进行硬件编程下载,在实验硬件平台上测试设计结果和智力抢答器的实用性。

并对这次试验进行总结。

目录一、实验目的二、实验任务与要求三、实验原理、设计思路与方案四、单元模块设计与仿真模块功能、模块符号及端口说明、模块程序、仿真程序、仿真波形五、系统模块设计顶层模块设计、系统管脚适配表、编程文件、下载成功标志、硬件调试说明六、结论一、实验目的在许多比赛活动中,为了准确、公正、直观地判断出第一抢答者,通常设置一台抢答器。

通过抢答器的数显,灯光和音响等手段指示出第一抢答者。

同时还可以设置定时、记分犯规及奖惩等多种功能。

本设计采用手动抢答的方式,有人抢答后,系统自动封锁其他人的抢答按钮,使其不能再抢答,从而实现抢答功能。

二、实验任务与要求1.基本要求(1)、编号1~6号的选手在规定的时间内按键抢答(2)、抢中编号锁定显示,其他无效(3)、主持按键控制清零和开始(4)、具有报警提示功能,分别提示抢答开始,有人抢答,定时时间到2.参数要求(1)、显示组数:6组(2)、报警延时:300ms(3)、抢答时间:20s三、实验原理、设计思路与方案抢答信号输入系统后,系统必须对最先抢到的选手进行编码,而后锁存这个编码,并将这个编码显示输出,所以需要用到编码器、锁存器和译码显示电路。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

library ieee;
use ieee.std_logic_1164.all;
use ieee. std_logic_arith.all;
use ieee. std_logic_unsigned.all;
entity qiangda is
port( S1,S2,S3,S4 : in std_logic; --输入:表示4个人,为0表示有抢答K : in std_logic; --主持人抢答开始键
G : out std_logic; --报警信号
ledag : out std_logic_vector (6 downto 0);
Dout :out std_logic_vector(3 downto 0) ); --抢答结果显示
end qiangda;
architecture behave of qiangda is
signal Enable_Flag : std_logic;--允许抢答控制变量,为1表示允许抢答
signal S : std_logic_vector(3 downto 0);
signal D : std_logic_vector(3 downto 0);
begin
process(S1,S2,S3,S4,K) --允许抢答控制
begin
S<=S1&S2&S3&S4;
If (K='1') then
Enable_Flag<='1';
elsif(S/="1111") then
Enable_Flag<='0';
end if;
end process;
process(S1,S2,S3,S4,K) --抢答结果显示
begin
if(K='0') then
D<="0000";
Elsif (Enable_Flag='1') then
if(S1='0') then
D(0)<='1';
G<='0';
elsif(S2='0') then
D(1)<='1';
G<='0';
elsif(S3='0') then
D(2)<='1';
G<='0';
elsif(S4='0') then
D(3)<='1';
G<='0';
end if;
dout<=d;
end if;
end process;
process(d) --显示抢答成功者号码
begin
case d is
when "0000"=>ledag<="0111111";
when "0001"=>ledag<="0000110";
when "0010"=>ledag<="1011011";
when "0100"=>ledag<="1001111";
when "1000"=>ledag<="1100110";
when others=>ledag<="0000000";
end case;
end process;
end behave;。

相关文档
最新文档