VHDL四路抢答器.docx

上传人:b****3 文档编号:27393228 上传时间:2023-06-30 格式:DOCX 页数:17 大小:135.51KB
下载 相关 举报
VHDL四路抢答器.docx_第1页
第1页 / 共17页
VHDL四路抢答器.docx_第2页
第2页 / 共17页
VHDL四路抢答器.docx_第3页
第3页 / 共17页
VHDL四路抢答器.docx_第4页
第4页 / 共17页
VHDL四路抢答器.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

VHDL四路抢答器.docx

《VHDL四路抢答器.docx》由会员分享,可在线阅读,更多相关《VHDL四路抢答器.docx(17页珍藏版)》请在冰豆网上搜索。

VHDL四路抢答器.docx

VHDL四路抢答器

目录

1.系统的设计要求2

2.系统分析2

2.1系统构成2

2.2系统实现过程3

3.1四输入与门模块3

3.2捕捉模块3

3.2锁存模块3

3.3抢答模块4

3.4计分模块4

3.5整体结构电路图4

4.程序设计4

4.1四输入与门模块代码4

4.2捕捉信号模块源代码5

4.3锁存器模块源代码6

4.4抢答显示模块源代码6

4.5计分显示模块源代码7

4.6顶层源代码9

5.运行结果与分析11

6.结束语133

参考文献13

 

引言

随着现代社会的发展,抢答器被广泛的运用于很多的娱乐节目,其作用也是越来越大。

近年来,随着社会的迅猛发展,抢答器得到了广泛的运用。

很多的电视台都会播放一些娱乐节目,在节目过程中都会添加一些娱乐节目,尤其是互动性的竞争游戏,这样都会使用到抢答器,这样使得对抢答器的要求也越来越高,当然也更进一步体现了抢答器的价值。

结合这种的背景,结合一些娱乐节目的实际情况,并发出真正适合我们特点的智能显示控制系统已经成为当前的主要任务,智能控制的效果能直接影响到大家对此娱乐节目的认可,同时好的智能控制也能为大家带来很多方便。

通过对抢答器基本原理的了解,我们可以设计多路抢答器,让节目可以有更多得人参与。

同时我们可以全面熟悉、掌握VHDL语言基本知识,掌握利用VHDL语言对常用的的组合逻辑电路和时序逻辑电路编程,把编程和实际结合起来,熟悉编制和调试程序的技巧,掌握分析结果的若干有效方法,进一步提高上机动手能力,培养使用设计综合电路的能力,养成提供文档资料的习惯和规范编程的思想。

 

1.系统的设计要求

四路抢答器由四输入与门模块、捕捉信号模块、锁存器模块、抢答显示模块、计分显示模块,锁存器、抢答电路将输出选手的编号;主持人开关启动和鉴别电路;选手答题正确加分。

基于硬件电路,经过程序设计、调试、仿真、下载和软硬件联合调试等工作,实现了抢答功能。

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

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

2.给主持人三个控制开关,实现系统的清零和抢答的开始以及给抢答正确的人加分和分数重置。

3.具有数据锁存,如果有选手按下了抢答按钮,其编号立即锁存。

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

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

计分功能:

1.具有计分功能,可由主持人给抢答正确的人计分,最大值为9。

2.系统分析

2.1系统构成

图1智能抢答器功能模块划分图

该智能抢答器分为五个模块,分别为:

四输入与门s41模块、锁存器lock模块、捕捉catch模块、抢答显示ch41a模块、计分显示jiafen模块。

2.2系统实现过程

主持人按下抢答开关,选手进行抢答,抢答回答正确后主持人可以给抢答的选手加分,然后开始下一轮抢答。

3.1四输入与门模块

实现选手输入的开关信号,该模块RTL电路图如图所示。

3.2捕捉模块

实现选手输入信号的捕捉。

该模块如图所示。

6554

3.2锁存模块

锁存器对四位答题者的结果进行锁存,并将其赋给输出信号q1,q2,q3,q4。

该模块如图所示。

3.3抢答模块

抢答显示模块如图4所示,把抢答结果转化为二进制数,易于读数。

该模块如图所示。

 

3.4计分模块

3.5整体结构电路图

4.程序设计

4.1四输入与门模块代码

libraryIEEE;

useIEEE.STD_LOGIC_1164.ALL;

useIEEE.STD_LOGIC_ARITH.ALL;

useIEEE.STD_LOGIC_UNSIGNED.ALL;

entitys41is

port(a:

instd_logic;

b:

instd_logic;

c:

instd_logic;

d:

instd_logic;

y:

outstd_logic);

ends41;

architectureBehavioralofs41is

begin

process(a,b,c,d)

begin

y<=aandbandcandd;

endprocess;

endBehavioral;

4.2捕捉信号模块源代码

libraryIEEE;

useIEEE.STD_LOGIC_1164.ALL;

useIEEE.STD_LOGIC_ARITH.ALL;

useIEEE.STD_LOGIC_UNSIGNED.ALL;

entitycatchis

port(cp:

instd_logic;

clr:

instd_logic;

q:

outstd_logic);

endcatch;

architectureBehavioralofcatchis

begin

process(cp,clr)

begin

ifclr='0'then

q<='0';

elsifcp'eventandcp='0'then

q<='1';

endif;

endprocess;

endBehavioral;

4.3锁存器模块源代码

libraryIEEE;

useIEEE.STD_LOGIC_1164.ALL;

useIEEE.STD_LOGIC_ARITH.ALL;

useIEEE.STD_LOGIC_UNSIGNED.ALL;

entitylockis

port(d1:

instd_logic;

d2:

instd_logic;

d3:

instd_logic;

d4:

instd_logic;

clk:

instd_logic;

clr:

instd_logic;

q1:

outstd_logic;

q2:

outstd_logic;

q3:

outstd_logic;

q4:

outstd_logic);

endlock;

architectureBehavioraloflockis

begin

process(clk)

begin

ifclr='0'then

q1<='0';

q2<='0';

q3<='0';

q4<='0';

elsifclk'eventandclk='1'then

q1<=d1;

q2<=d2;

q3<=d3;

q4<=d4;

endif;

endprocess;

endBehavioral;

4.4抢答显示模块源代码

libraryIEEE;

useIEEE.STD_LOGIC_1164.ALL;

useIEEE.STD_LOGIC_ARITH.ALL;

useIEEE.STD_LOGIC_UNSIGNED.ALL;

entitych41ais

port(d1:

instd_logic;

d2:

instd_logic;

d3:

instd_logic;

d4:

instd_logic;

led:

outstd_logic_vector(6downto0));

endch41a;

architectureBehavioralofch41ais

begin

process(d1,d2,d3,d4)

variabletmp:

std_logic_vector(3downto0);

begin

tmp:

=d1&d2&d3&d4;

casetmpis

when"0111"=>led<="0000110";

when"1011"=>led<="1011011";

when"1101"=>led<="1001111";

when"1110"=>led<="1100110";

whenothers=>led<="0000000";

endcase;

endprocess;

endBehavioral;

4.5计分显示模块源代码

libraryIEEE;

useIEEE.STD_LOGIC_1164.ALL;

useIEEE.STD_LOGIC_ARITH.ALL;

useIEEE.STD_LOGIC_UNSIGNED.ALL;

entityjiafenis

port(JA:

instd_logic;

clr:

instd_logic;

q:

instd_logic_vector(3downto0);

led1,led2,led3,led4:

outstd_logic_vector(6downto0));

endjiafen;

architectureBehavioralofjiafenis

signalz1,z2,z3,z4:

std_logic_vector(3downto0);

begin

com1:

process(JA,clr)

begin

ifclr='0'then

z4<="0000";

z1<="0000";

z2<="0000";

z3<="0000";

elsifJA'eventandJA='1'

then

ifq="0111"thenz1<=z1+1;

elsifq="1011"thenz2<=z2+1;

elsifq="1101"thenz3<=z3+1;

elsifq="1110"thenz4<=z4+1;

endif;

endif;

endprocess;

com2:

process(z1,z2,z3,z4)

begin

casez1is

when"0001"=>led1<="0000110";

when"0010"=>led1<="1011011";

when"0011"=>led1<="1001111";

when"0100"=>led1<="1100110";

when"0101"=>led1<="1101101";

when"0110"=>led1<="1111101";

when"0111"=>led1<="0000111";

when"1000"=>led1<="1111111";

when"1001"=>led1<="1101111";

whenothers=>led1<="0000000";

endcase;

casez2is

when"0001"=>led2<="0000110";

when"0010"=>led2<="1011011";

when"0011"=>led2<="1001111";

when"0100"=>led2<="1100110";

when"0101"=>led2<="1101101";

when"0110"=>led2<="1111101";

when"0111"=>led2<="0000111";

when"1000"=>led2<="1111111";

when"1001"=>led2<="1101111";

whenothers=>led2<="0000000";

endcase;

casez3is

when"0001"=>led3<="0000110";

when"0010"=>led3<="1011011";

when"0011"=>led3<="1001111";

when"0100"=>led3<="1100110";

when"0101"=>led3<="1101101";

when"0110"=>led3<="1111101";

when"0111"=>led3<="0000111";

when"1000"=>led3<="1111111";

when"1001"=>led3<="1101111";

whenothers=>led3<="0000000";

endcase;

casez4is

when"0001"=>led4<="0000110";

when"0010"=>led4<="1011011";

when"0011"=>led4<="1001111";

when"0100"=>led4<="1100110";

when"0101"=>led4<="1101101";

when"0110"=>led4<="1111101";

when"0111"=>led4<="0000111";

when"1000"=>led4<="1111111";

when"1001"=>led4<="1101111";

whenothers=>led4<="0000000";

endcase;

endprocess;

endBehavioral;

4.6顶层源代码

libraryIEEE;

useIEEE.STD_LOGIC_1164.ALL;

useIEEE.STD_LOGIC_ARITH.ALL;

useIEEE.STD_LOGIC_UNSIGNED.ALL;

entityans_topis

port(d1:

instd_logic;

d2:

instd_logic;

d3:

instd_logic;

JA:

instd_logic;

clr:

instd_logic;

d4:

instd_logic;

host:

instd_logic;

led:

outstd_logic_vector(6downto0);

led1,led2,led3,led4:

outstd_logic_vector(6downto0));

endans_top;

architectureBehavioralofans_topis

componentcatch

port(cp:

instd_logic;

clr:

instd_logic;

q:

outstd_logic);

endcomponent;

componentch41a

port(d1:

instd_logic;

d2:

instd_logic;

d3:

instd_logic;

d4:

instd_logic;

led:

outstd_logic_vector(6downto0));

endcomponent;

componentlock

port(d1:

instd_logic;

d2:

instd_logic;

d3:

instd_logic;

d4:

instd_logic;

clk:

instd_logic;

clr:

instd_logic;

q1:

outstd_logic;

q2:

outstd_logic;

q3:

outstd_logic;

q4:

outstd_logic);

endcomponent;

components41

port(a:

instd_logic;

b:

instd_logic;

c:

instd_logic;

d:

instd_logic;

y:

outstd_logic);

endcomponent;

componentjiafen

port(JA:

instd_logic;

clr:

instd_logic;

q:

instd_logic_vector(3downto0);

led1,led2,led3,led4:

outstd_logic_vector(6downto0));

endcomponent;

signalsq1,sq2,sq3,sq4,sq5,sq6:

std_logic;

begin

u0:

s41portmap(a=>d1,b=>d2,c=>d3,d=>d4,y=>sq1);

u1:

catchportmap(cp=>sq1,clr=>host,q=>sq2);

u2:

lockportmap(d1=>d1,d2=>d2,d3=>d3,d4=>d4,clk=>sq2,clr=>host,

q1=>sq3,q2=>sq4,q3=>sq5,q4=>sq6);

u3:

ch41aportmap(d1=>sq3,d2=>sq4,d3=>sq5,d4=>sq6,led=>led);

u4:

jiafenportmap(JA=>JA,q(3)=>sq3,q

(2)=>sq4,q

(1)=>sq5,q(0)=>sq6,clr=>clr,led1=>led1,led2=>led2,led3=>led3,led4=>led4);

endBehavioral;

5.运行结果与分析

各模块程序的调试

(1)四输入与门模块:

图9四输入与门模块仿真波形图

(2)捕捉模块:

图10捕捉模块仿真波形图

(3)锁存器模块:

图11锁存器模块仿真波形图

(4)抢答显示模块:

图12抢答显示模块仿真波形图

当有选手抢答时,数码管显示抢答选手的序号,图中依次为1234号选手抢答,数码管将依次显示1234。

(5)计分显示模块:

图13计分显示模块仿真波形图

1号选手抢答并回答正确,当主持了按动加分按钮时数码管显示1号选手分数加1,主持题按重置按钮时所有选手分数清零,开始再次抢答,4号选手抢答回答正确,数码管显示4号选手分数加1。

(6)顶层文件:

图16顶层文件仿真波形图

1号选手抢答,其他几位选手抢答无效,抢答数码显示管显示1,1号选手回答问题成功后分数加1,主持人将分数清零,并重新开始抢答,3号选手先抢答,3号选手抢答无效,3号回答正确,主持人按按钮,3号分数加1。

6.结束语

本四路抢答器基于vhdl,经过程序设计、调试、仿真、下载和软硬件联合调试等工作,实现了抢答功能。

本抢答器由四输入与门模块、捕捉模块、锁存器模块、抢答显示模块、计分显示模块的电路组成,存器、转换电路将抢中选手的编号显示输出;主持人开关启动和四输入与门电路;答对选手加分,最高9分。

本次实验让我对VHDL有了进一步的理解,例如编译通过不一定代表逻辑全部正确,仿真全部正确,一个细小的错误可能就会导致仿真得不到理论的结果。

本次实验设计的抢答器比较简陋,没有抢答时限控制。

计分可变范围不够宽。

参考文献

[1].侯伯亭,顾新.VHDL硬件描述语言与数字逻辑电路设计.西安:

西安电子科技大学出版社,1999.

[2].EDA技术与VHDL。

潘松,黄继业编著。

——4版。

——北京:

清华大学出版社,2013.4

[3].王金明.数字系统设计VHDL北京:

电子工业出版设,2010。

13

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 社交礼仪

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

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