第二章 抢答器的设计要求...................................2
第三章 抢答器的设计分析...................................3
第四章 抢答器的抢答鉴别模块...............................4
4.1抢答鉴别的功能.....................................4
4.2抢答鉴别模块的源程序...............................4
4.3抢答鉴别模块的时序仿真图...........................7
第五章 抢答器的计时模块......................................................................8
5.1计时模块的功能.....................................8
5.2计时模块的源程序...................................8
5.3计时模块的时序仿真图...............................11
第六章 抢答器的计分模块...................................12
6.1计分模块的功能.....................................12
6.2计分模块的源程序...................................12
6.3计分模块的时序仿真图...............................15
第七章 抢答器的译码显示模块...............................16
7.1译码显示模块的功能.................................16
7.2译码显示模块的源程序...............................16
7.3译码显示模块的时序仿真图...........................17
第八章 抢答器的其他功能模块...............................18
8.1其他功能模块的具体信息.............................18
第九章 抢答器的顶层原理图设计.............................19
9.1顶层原理图的源文件.................................20
9.2顶层设计的时序仿真图...............................21
第十章 抢答器的硬件测试...................................22
10.1抢答器的引脚绑定..................................22
10.2抢答器的测试结果..................................22
第十一章 课程设计的总结...................................23
参考文献...............................................23
第一章 EDA技术简介
数字抢答器控制系统在现今许多工厂、学校和电视台等单位所举办的各种知识竞赛中起着不可替代的作用。基于EDA技术设计的电子抢答器,以其价格便宜、安全可靠、使用方便而受到了人们的普遍欢迎。本文以现场可编程逻辑器件(FPGA)为设计载体,以硬件描述语言VHDL为主要表达方式,以OuartusⅡ开发软件和GW48EDA开发系统为设计工具设计的电子抢答器,具有抢答鉴别与锁存功能以及60秒答题限时功能、对抢答犯规的小组进行警告和对各抢答小组进行相应的成绩加减操作等功能。
第二章 抢答器的设计要求
1 电子抢答器的功能
该电子抢答器实现的功能主要包括四项操作:
(1)第一抢答信号的鉴别和锁存
该电子抢答器共设4个组别,每组控制一个抢答开关,分别为a,b,c,d。在主持人发出抢答指令后,若有参赛者按抢答器按钮,则该组指示灯亮,同时显示器显示出抢答者的组别。同时,电路处于自锁状态,以使其他组的抢答器按钮不起作用。
(2)计时功能
在初始状态时。主持人可以设置答题时间的初时值。在主持人对抢答组别进行确认,并给出倒计时计数开始信号以后,抢答者便可开始回答问题。此时,显示器从初始值开始倒计时,计至0时停止计数,同时扬声器发出超时报警信号。若参赛者在规定的时间内回答完问题,主持人即可给出计时停止信号,以免扬声器鸣叫。
(3)计分功能
在初始状态时,主持人可以给每组设置初始分值。每组抢答完后,由主持人打分,答对一次加1分,答错一次减1分。
(4)犯规设置
对提前抢答者和超时抢答者给予蜂鸣警示,并显示犯规组别。
2 电子抢答器的结构原理
2.1 电子抢答器的整体结构
电子抢答器的整体结构如图1所示。它包括鉴别与锁存模块、定时与犯规设置模块以及计分模块。
第三章 抢答器的设计分析
按照要求,我们可以将整个系统分为四个主要模块:抢答鉴别模块;抢答计时模块;抢答计分模块;译码显示模块。对于需显示的信息,需要增加或外接译码器,进行显示译码。考虑到实验开发平台提供的输出显示资源的,我们将组别显示和计时显示的译码器内设,而将各组的计分显示的译码器外接。整个系统的大致组成框图如图2.1所示。
图 2.1
第四章 抢答器的抢答鉴别模块
4.1抢答鉴别模块的功能
抢答队伍共分为四组A,B,C,D。当主持人按下START键后,四组队伍才可以按抢答键抢答。抢答成功后表示该组的指示灯见亮起,但在主持人未按下START键之前,所有的抢答键按下均是无效的。当任意一个组抢答成功后,其余的组按抢答键无效。抢答键为A,B,C,D四个键。
4.2抢答鉴别模块的源程序
library ieee;
use ieee.std_logic_11.all;
entity jb is
port(sta:in std_logic;
rst:in std_logic;
a,b,c,d:in std_logic;
a1,b1,c1,d1:out std_logic;
states: out std_logic_vector(3 downto 0);
start: out std_logic);
end entity jb;
architecture art of jb is
constant w1: std_logic_vector:="0001";
constant w2: std_logic_vector:="0010";
constant w3: std_logic_vector:="0100";
constant w4: std_logic_vector:="1000";
signal sinor: std_logic;
signal nsinor: std_logic;
signal s_start: std_logic;
begin
sinor<=a or b or c or d;
nsinor<=not(a or b or c or d);
start<=s_start;
process(sta,nsinor) is
begin
if (sta='1') then
s_start<='1';
elsif(nsinor'event and nsinor='1')then
s_start<='0';
end if;
end process;
process(rst,sta,sinor,nsinor) is
begin
if(rst='1' or sta='1' or nsinor='1')then
a1<='0';b1<='0';c1<='0';d1<='0';
elsif(sinor'event and sinor='1')then
if(s_start='1')then
if(a='1')then
a1<='1';b1<='0';c1<='0';d1<='0';
elsif(b='1')then
a1<='0';b1<='1';c1<='0';d1<='0';
elsif(c='1')then
a1<='0';b1<='0';c1<='1';d1<='0';
elsif(d='1')then
a1<='0';b1<='0';c1<='0';d1<='1';
end if;
end if;
end if;
end process;
process(sinor) is
begin
if(rst='1')then
states<="0000";
elsif(sinor'event and sinor='1')then
if(s_start='1')then
if(a='1')then
states<=w1;
elsif(b='1')then
states<=w2;
elsif(c='1')then
states<=w3;
elsif(d='1')then
states<=w4;
end if;
end if;
end if;
end process;
end architecture art;
4.3抢答鉴别模块的时序仿真图
图 4.1
抢答开始后,A组按下抢答键,抢答成功
第五章 抢答器的抢答计时模块
5.1抢答计时模块的功能
主持人宣布抢答成功后,按下EN键,选手开始回答,系统开始计时。TA和TB键选择计时的时间(TA:9秒,TB:7秒)
5.2 抢答计时模块的源程序
library ieee;
use ieee.std_logic_11.all;
use ieee.std_logic_unsigned.all;
entity js is
port(clr,ldn,en,clk:in std_logic;
ta,tb: in std_logic;
qa: out std_logic_vector(3 downto 0);
qb: out std_logic_vector(3 downto 0));
end entity js;
architecture art of js is
signal da: std_logic_vector(3 downto 0);
signal db: std_logic_vector(3 downto 0);
begin
process(ta,clr) is
begin
if(clr='1')then
da<="1001";
elsif(ta'event and ta='1')then
if(ldn='1')then
if(da="0000")then
da<="1001";
else
da<=da-1;
end if;
end if;
end if;
end process;
process(tb,clr) is
begin
if(clr='1')then
db<="0101";
elsif(tb'event and tb='1')then
if(ldn='1')then
if db="0000"then
db<="1001";
else
db<=db-1;
end if;
end if;
end if;
end process;
process(clk) is
variable tmpa: std_logic_vector(3 downto 0);
variable tmpb: std_logic_vector(3 downto 0);
begin
if(clr='1')then
tmpa:="0000";
tmpb:="0000";
elsif clk'event and clk='1' then
if en='1'then
tmpa:=da;
tmpb:=db;
elsif tmpa="0000"then
if tmpb="0000"then
tmpa:="0000";
else
tmpa:="1001";
end if;
if tmpb="0000"then
tmpb:="0000";
else
tmpb:=tmpb-1;
end if;
else
tmpa:=tmpa-1;
end if;
end if;
qa<=tmpa;
qb<=tmpb;
end process;
end architecture art;
5.3抢答计时模块的时序仿真图
图 5.1
按下EN开始答题,回答问题时,选择TA模式计时
第六章 抢答器的计分模块
6.1抢答计分模块的功能
主持人确认选手回答正确后,按下ADD键为选手加分。
6.2抢答计分模块的源程序
library ieee;
use ieee.std_logic_11.all;
use ieee.std_logic_unsigned.all;
entity jf is
port(rst: in std_logic;
add: in std_logic;
chose: in std_logic_vector(3 downto 0);
aa2,aa1,aa0,bb2,bb1,bb0: out std_logic_vector(3 downto 0);
cc2,cc1,cc0,dd2,dd1,dd0: out std_logic_vector(3 downto 0));
end entity jf;
architecture art of jf is
begin
process(rst,add,chose) is
variable a2,a1:std_logic_vector(3 downto 0);
variable b2,b1:std_logic_vector(3 downto 0);
variable c2,c1:std_logic_vector(3 downto 0);
variable d2,d1:std_logic_vector(3 downto 0);
begin
if(rst='1')then
a2:="0001";a1:="0000";
b2:="0001";b1:="0000";
c2:="0001";c1:="0000";
d2:="0001";d1:="0000";
elsif(add'event and add='1')then
if chose="0001"then
if a1="1001"then
a1:="0000";
if a2="1001"then
a2:="0000";
else
a2:=a2+'1';
end if;
else
a1:=a1+'1';
end if;
elsif chose="0010"then
if b1="1001"then
b1:="0000";
if b2="1001"then
b2:="0000";
else
b2:=b2+'1';
end if;
else
b1:=b1+'1';
end if;
elsif chose="0100"then
if c1="1001"then
c1:="0000";
if c2="1001"then
c2:="0000";
else
c2:=c2+'1';
end if;
else
c1:=c1+'1';
end if;
elsif chose="1000"then
if d1="1001"then
d1:="0000";
if d2="1001"then
d2:="0000";
else
d2:=d2+'1';
end if;
else
d1:=d1+'1';
end if;
end if;
end if;
aa2<=a2;aa1<=a1;aa0<="0000";
bb2<=b2;bb1<=b1;bb0<="0000";
cc2<=c2;cc1<=c1;cc0<="0000";
dd2<=d2;dd1<=d1;dd0<="0000";
end process;
end architecture art;
6.3抢答计分模块的时序仿真图
图 6.1
A组回答正确,加分
第七章 抢答器的译码显示模块
7.1译码显示模块的功能
译码显示模块用于显示每组选手的分数,计时的的时间等信息。
7.2译码显示模块的源程序
library ieee;
use ieee.std_logic_11.all;
use ieee.std_logic_unsigned.all;
entity ym is
port(in4: in std_logic_vector(3 downto 0);
out7:out std_logic_vector(6 downto 0));
end ym;
architecture art of ym is
begin
process(in4)
begin
case in4 is
when"0000"=>out7<="0111111";
when"0001"=>out7<="0000110";
when"0010"=>out7<="1011011";
when"0011"=>out7<="1001111";
when"0100"=>out7<="1100110";
when"0101"=>out7<="1101101";
when"0110"=>out7<="1111101";
when"0111"=>out7<="0000111";
when"1000"=>out7<="1111111";
when"1001"=>out7<="1101111";
when others=>out7<="0000000";
end case;
end process;
end architecture;
7.3译码显示模块的时序仿真图
图 7.1
输入0001,输出0000110,在共阴极数码管上显示1
第八章 抢答器的其他功能模块
其他功能模块的具体信息
犯规功能模块:但主持人未按下START键时,若有选手按抢答键,系统报警。
犯规功能模块的源程序:
library ieee;
use ieee.std_logic_11.all;
entity fg is
port(a,b,c,d,start:in std_logic;
y:out std_logic);
end fg;
architecture bhv of fg is
begin
process(a,b,c,d,start)
begin
if start='0' then
if (a or b or c or d)='1' then
y<='1';
end if;
else
y<='0';
end if;
end process;
end architecture;
犯规功能模块的时序仿真图:
图 8.1
B组提前抢答,报警铃鸣叫示意
第九章 抢答器的顶层原理图设计
9.1顶层原理图的源文件
图 9.1
9.2顶层原理图的时序仿真图
图 9.2
A组抢答成功,问题回答正确,加分
第十章 抢答器的硬件测试
10.1抢答器的引脚绑定
由于硬件条件的,只测试抢答鉴别功能的检测。实验用的芯片为GWAC3EP1C3TC144采用实验电路模式6检测,引脚绑定如下图:
图 10.1
ZB接共阴极数码管,A,B,C,D接按键5,6,7,8。
10.2抢答器的测试结果
按下5键,数码管显示1,即A组抢答成功。
第十一章 课程设计的总结
本次的EDA课程设计历时三个星期,时间虽短,但通过三个星期的实践,使我对EDA技术有了更进一步的了解。同时,大致懂得了一个课题制作的具体流程和实施方法。另外,课程设计对QuartusⅡ软件的使用要求较高,从而使我能较为熟练的运用此软件。在设计时,采用模块化的设计思路使得问题变的简单明了,大大缩短了时间,降低了发生错误的机侓,也便于修改和更新。
课程设计中,需要找很多资料,在当今的信息化环境中,虽然资料很多,但需要仔细斟酌才能找到所要的。这次的课程设计很好的锻炼了这种能力。此外,与同学和老师的交流必不可少,我从中也学到了不少东西。
课程设计是一次很好的锻炼机会,我从中学的很多知识对将来的学习和工作都有很大的帮助,十分感谢学校能提供这样一个机会。
【1】EDA技术与VHDL(第2版) 潘 松 黄继业 编著 清华大学出版社.2007
【2】EDA技术实验与课程设计 曹昕燕 周凤臣 聂春燕 编著 清华大学出版社. 2006
【3】杭州康芯电子有限公司GW48-PK3实验系统说明书. 杭州康芯电子有限公司.2006