数字式竞赛抢答器VHDL_第1页
数字式竞赛抢答器VHDL_第2页
数字式竞赛抢答器VHDL_第3页
数字式竞赛抢答器VHDL_第4页
数字式竞赛抢答器VHDL_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

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

文档简介

..数字系统设计与硬件描述语言期末考试作业题目:数字式竞赛抢答器设计学院:电子信息工程专业:电子信息工程学号::选题设计描述功能介绍此设计用于竞赛的四人抢答,有如下的功能:具有多路抢答功能,台数设计为四;具有抢答器开场后30秒倒计时,30秒后无人抢答显示超时,并报警;能显示超前抢答犯规,并警报;能显示各组得分,大队加分,答错扣分;当系统复位,主持人按下抢答开场按键,处于使能状态,抢答开场,某路抢答键按下时,该路信号将其他路信号锁存,同时抢答铃声响起,直至此路按键松开,显示该路组号。算法简介本设计采用分层设计思想,分为:信号鉴别模块、计时模块、计分模块、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七段译码器上。其中输入信号a;输出译码结果信号q。分频器。此模块主要实现时钟分频功能。在开头对时钟信号进展一次千分频。其中时钟输入信号clkin,输出信号clk。顶层模块。将前几个模块综合在一起,形成一个整体。分频器输出作为其他模块所需的时钟信号,使整个系统正常运转。程序源代码及说明抢答信号鉴别模块的程序:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityqdisport(clk2,en,rst:instd_logic;a,b,c,d:instd_logic;fangui:outstd_logic;states:outstd_logic_vector(3downto0));endqd;architectureoneofqdissignalsinor,fanguif,tmp:std_logic;signalt:std_logic_vector(5downto0);beginsinor<=aorborcord;p1:process(a,rst,b,c,d,tmp)beginifrst='1'then--复位信号有效,系统复位。tmp<='1';states<="0000";elsiftmp='1'thenifa='1'then--判断哪路信号变化,进展选取states<="0001";tmp<='0';--对states进展置数elsifb='1'thenstates<="0010";tmp<='0';elsifc='1'thenstates<="0011";tmp<='0';elsifd='1'thenstates<="0100";tmp<='0';elsetmp<='1';states<="0000";endif;endif;endprocessp1;p2:process(clk2,en,rst,t)--判断是否提前抢答并报警beginifrst='1'thent<="000000";fanguif<='0';--初始化提前抢答犯规信号elsifclk2'eventandclk2='1'thenifen='0'andsinor='1'thenift<"111111"thenfanguif<=notfanguif;t<=t+1;elsefanguif<='0';endif;endif;endif;endprocessp2;fangui<=fanguif;endone;计时模块的程序:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityjsisport(clk,rst,en,stop:instd_logic;warn:bufferstd_logic;ta,tb:bufferstd_logic_vector(3downto0));endjs;architectureoneofjsissignalco:std_logic;beginp1:process(clk,rst,en,stop,ta)--个位计时信号进展0到9循环计数beginifrst='1'orstop='1'thenta<="0000";elsifclk'eventandclk='1'thenco<='0';ifen='1'thenifta="0000"thenta<="1001";co<='1';elseta<=ta-1;endif;endif;endif;endprocessp1;p2:process(co,rst,en,stop,tb)--十位计时信号0到3变化beginifrst='1'orstop='1'thentb<="0011";elsifco'eventandco='1'thenifen='1'theniftb="0000"thentb<="0011";elsetb<=tb-1;endif;endif;endif;endprocessp2;p3:process(rst,ta,tb)--计时时间到达,报警beginifrst='1'thenwarn<='0';elsifta="0000"andtb="0000"thenwarn<='1';elsewarn<='0';endif;endprocessp3;endone;计分模块的程序:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityjfisport(clk,rst,en,add:instd_logic;states:instd_logic_vector(3downto0);a_out,b_out,c_out,d_out:bufferstd_logic_vector(3downto0));endjf;architectureoneofjfisbeginp1:process(clk,rst,add,states,a_out,b_out,c_out,d_out)beginif(rst='1')thena_out<="0101";b_out<="0101";c_out<="0101";d_out<="0101";--初始化置5分 elsifen='1'then ifclk'eventandclk='1'then casestatesis when"0001"=> ifadd='1'then--add信号为高时,加1分 ifa_out="1111"then--最多15分 a_out<="0000";elsea_out<=a_out+1; endif; elsifadd='0'then--add信号为0,减1分 ifa_out="0000"then a_out<="0000"; elsea_out<=a_out-1; endif; endif;when"0010"=> ifadd='1'then ifb_out="1111"then b_out<="0000"; elseb_out<=b_out+1; endif; elsifadd='0'then ifb_out="0000"then b_out<="0000"; elseb_out<=b_out-1; endif; endif; when"0011"=> ifadd='1'then ifc_out="1111"then c_out<="0000"; elsec_out<=c_out+1; endif; elsifadd='0'then ifc_out="0000"then c_out<="0000"; elsec_out<=c_out-1; endif; endif; when"0100"=> ifadd='1'then ifd_out="1111"then d_out<="0000"; elsed_out<=d_out+1; endif; elsifadd='0'then ifd_out="0000"then d_out<="0000"; elsed_out<=d_out-1; endif;endif; whenothers=> a_out<=a_out;b_out<=b_out;c_out<=c_out;d_out<=d_out; endcase; endif; endif;endprocessp1;endone;抢答器顶层模块程序:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityqiangdaisport(clkin,clk2,en,a,b,c,d,add,stop,rst:instd_logic;fangui,alarm:outstd_logic;ta,tb:bufferstd_logic_vector(3downto0);states:bufferstd_logic_vector(3downto0);statesout:outstd_logic_vector(0to6);a_out,b_out,c_out,d_out:bufferstd_logic_vector(3downto0));endqiangda;architecturebhvofqiangdaisponentqdisport(clk2,en,rst:instd_logic;a,b,c,d:instd_logic;fangui:outstd_logic;states:outstd_logic_vector(3downto0));endponent;ponentjsisport(clk,rst,en,stop:instd_logic;warn:bufferstd_logic;ta,tb:bufferstd_logic_vector(3downto0));endponent;ponentjfisport(clk,rst,en,add:instd_logic;states:instd_logic_vector(3downto0);a_out,b_out,c_out,d_out:bufferstd_logic_vector(3downto0));endponent;ponentBCD7isport(a:instd_logic_vector(3downto0);q:outstd_logic_vector(0to6));endponentBCD7;ponentdivfisport(clk:INSTD_LOGIC;q:OUTSTD_LOGIC;qn:OUTstd_logic_vector(9downto0));endponentdivf;signalt:std_logic_vector(3downto0);signalclk:STD_LOGIC;signaldivqn:std_logic_vector(3downto0);beginu1:qdportmap(clk2,en,rst,a,b,c,d,fangui,states);u2:jsportmap(clk,rst,en,stop,alarm,ta,tb);u3:jfportmap(clk,rst,en,add,states,a_out,b_out,c_out,d_out);u4:BCD7portmap(states,statesout);u5:divfportmap(clkin,clk,divqn);endbhv;BCD7段译码器模块程序:LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;ENTITYBCD7ISPORT(a:INSTD_LOGIC_VECTOR(3DOWNTO0);--数据输入q:OUTSTD_LOGIC_VECTOR(0TO6));--7段输出ENDBCD7;ARCHITECTUREbehavOFBCD7ISBEGINPROCESS(a)BEGINcasea(3downto0)is--BCD7段译码表when"0000"=>q<="1111110";when"0001"=>q<="0110000";when"0010"=>q<="1101101";when"0011"=>q<="1111001";when"0100"=>q<="0110011";when"0101"=>q<="1011011";when"0110"=>q<="1011111";when"0111"=>q<="1110000";when"1000"=>q<="1111111";when"1001"=>q<="1111011";whenothers=>q<="0000000";ENDcase;ENDPROCESS;ENDbehav;一千分频器模块程序:LIBRARYIEEE;USEIEEE.STD_LOGIC_1164.ALL;USEIEEE.STD_LOGIC_unsigned.ALL;ENTITYdivfISPORT(clk:INSTD_LOGIC;q:OUTSTD_LOGIC;qn:OUTstd_logic_vector(9downto0));ENDdivf;ARCHITECTUREbehavOFdivfISsignalrst:std_logic;signalqn1:std_logic_vector(9downto0);BEGINPROCESS(clk,rst)BEGINifrst='1'thenqn1<="0000000000"; elsifclk'eventandclk='1'thenqn1<=qn1+1;endif;ENDPROCESS;rst<='1'whenqn1=1000else'0';qn<=qn1;--计数q<=qn1(9);--分频输出,1000分频ENDbehav;仿真结果及分析系统总体框图:对于各个模块的仿真测试所得结果,仿真波形分析如下:信号鉴别模块:仿真结果:本模块主要实现抢答功能。当rst信号为‘1’,en信号为‘1’时,抢答开场,当有一路正常获得抢答时,系统会自动封锁另外三路的抢答信号,只允许一人处于答题状态;当主持人没有允许抢答时,假设有人超前抢答,警报会响起,同时只要有人抢答那么抢答显示台〔states〕会显示哪一个在抢答。如上图示,在系统第一个复位信号降临后,电路自动复位,在允许抢答信号降临之前〔即en=‘0’〕,b台超前抢答,此时警报响起〔即超前抢答警报信号fangui获得一个频率很高的脉冲,就会响起〕,之后主持人复位,并允许抢答,a台最先抢答,此时抢答显示台显示其台号1。计时模块:仿真结果:本模块主要实现计时功能。当rst信号为‘1’时,计时复位为30秒倒计时,主持人允许的en信号为‘1’时,开场进展倒计时,系统时钟每来一个上升沿,倒计时减1,当到30秒倒计时计玩仍然无人抢答时,警报指示灯亮(即warn=‘1’),假设有人抢答主持人可以按下中止键〔即stop=‘1’〕,这样倒计时就会回到30秒初始状态。图示的情况为在倒计时16秒时,主持人按下中止键,计时器变为初始值

温馨提示

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

最新文档

评论

0/150

提交评论