四路抢答器VDHL实验报告含程序.docx

上传人:b****6 文档编号:7410199 上传时间:2023-01-23 格式:DOCX 页数:25 大小:747.22KB
下载 相关 举报
四路抢答器VDHL实验报告含程序.docx_第1页
第1页 / 共25页
四路抢答器VDHL实验报告含程序.docx_第2页
第2页 / 共25页
四路抢答器VDHL实验报告含程序.docx_第3页
第3页 / 共25页
四路抢答器VDHL实验报告含程序.docx_第4页
第4页 / 共25页
四路抢答器VDHL实验报告含程序.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

四路抢答器VDHL实验报告含程序.docx

《四路抢答器VDHL实验报告含程序.docx》由会员分享,可在线阅读,更多相关《四路抢答器VDHL实验报告含程序.docx(25页珍藏版)》请在冰豆网上搜索。

四路抢答器VDHL实验报告含程序.docx

四路抢答器VDHL实验报告含程序

电子学课程设计实验报告

——四路抢答器设计与制作

 

Rong

 

目录

第1章设计的性质、目的和任务

……………………………………………………………………2

第2章设计课题要求

……………………………………………………………………3

第3章设计的内容、电路原理和详细的设计过程

……………………………………………………………………4

第4章调试与仿真结果

……………………………………………………………………20

第5章调试中遇到的问题及解决的方法

……………………………………………………………………22

第6章体会、感想、建议

……………………………………………………………………23

附录1参考文献

……………………………………………………………………24

 

第一章设计的性质、目的和任务

创新精神和实践能力二者之中,实践能力是基础和根本。

这是由于创新基于实践、源于实践,实践出真知,实践检验真理。

实践活动是创新的源泉,也是人才成长的必由之路。

通过课程设计的锻炼,要求学生掌握电路的一般设计方法,具备初步的独立设计能力,提高综合运用所学的理论知识独立分析和解决问题的能力,培养学生的创新精神。

 

第二章设计课题要求

四路抢答器设计与制作

设计要求:

设计一个四路抢答器。

抢答器必须具有互锁功能,同时抢答时每次只能有一个输出有效。

同时,抢答时具有计时功能,限定选手的答题时间,在接近规定时间时进行提示,达到规定时间发出终止音。

主持人可控制加分或减分。

见简略示意图。

 

第三章设计的内容、电路原理和详细的设计过程

3.1设计内容

3.1.1流程图

 

YESNO

 

YES

NO

YES

NO

图1流程图

3.1.2设计思路

自顶向下,顶层采用原理图设计,以下各层次采取VHDL描述语言实现。

顶层用原理图简单,方便。

模块用VHDL,可读性好,移植性好,入档、交流、交付方便。

模块须分为以下模块:

抢答鉴别电路,计时器,记分器,分频器,扫描显示,译码器,蜂鸣器。

3.2电路原理

图2四路抢答器的组成

3.3详细的设计过程

3.3.1顶层设计

按图2设计。

如果模块需要增减再进行修改。

3.3.2抢答鉴别电路设计

I.输入/输出:

4个按键抢答输入:

a,b,c,d;

4个接LED的输出a1,b1,c1,d1;

1组给记分器的片选输出states[3..0]。

II.功能:

先输入a时,a1输出,b,c,d不能输入;

先输入b时,b1输出,a,c,d不能输入;

先输入c时,c1输出,a,b,d不能输入;

先输入d时,d1输出,a,b,c不能输入;

片选给记分器选择结果。

III.VHDL程序:

libraryieee;

useieee.std_logic_1164.all;

entityqdjbis

port(a,b,c,d:

instd_logic;

a1,b1,c1,d1:

outstd_logic;

states:

outstd_logic_vector(3downto0));

endentityqdjb;

architectureartofqdjbis

constantw1:

std_logic_vector:

="0001";

constantw2:

std_logic_vector:

="0010";

constantw3:

std_logic_vector:

="0100";

constantw4:

std_logic_vector:

="1000";

begin

process(a,b,c,d)is

begin

if(a='1'andb='1'andc='1'andd='1')then

a1<='0';b1<='0';c1<='0';d1<='0';states<="0000";

elsif(a='0'andb='1'andc='1'andd='1')then

a1<='1';b1<='0';c1<='0';d1<='0';states<=w1;

elsif(a='1'andb='0'andc='1'andd='1')then

a1<='0';b1<='1';c1<='0';d1<='0';states<=w2;

elsif(a='1'andb='1'andc='0'andd='1')then

a1<='0';b1<='0';c1<='1';d1<='0';states<=w3;

elsif(a='1'andb='1'andc='1'andd='0')then

a1<='0';b1<='0';c1<='0';d1<='1';states<=w4;

endif;

endprocess;

endarchitectureart;

IV.模块图形:

图3抢答鉴别电路

3.3.3计时器设计

I.输入/输出:

1个时钟信号输入

1个复位信号输入

2组4位2进制信号输出作为显示计时信号。

II.功能:

通过1Hz的时钟进行20秒倒计时,至00停止直至复位信号给入,恢复20。

III.VHDL程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityjsqis

port(clk,clr:

instd_logic;

qa:

outstd_logic_vector(3downto0);

qb:

outstd_logic_vector(3downto0));

endentityjsq;

architectureartofjsqis

begin

process(clk,clr)is

variabletmpa:

std_logic_vector(3downto0);

variabletmpb:

std_logic_vector(3downto0);

begin

ifclr='0'thentmpa:

="0000";tmpb:

="0010";

elsifclk'eventandclk='1'then

iftmpa="0000"andtmpb="0000"then

tmpa:

="0000";

tmpb:

="0000";

elsiftmpa="0000"then

tmpa:

="1001";

iftmpb="0000"thentmpb:

="0010";

elsetmpb:

=tmpb-1;

endif;

elsetmpa:

=tmpa-1;

endif;

endif;

qa<=tmpa;qb<=tmpb;

endprocess;

endarchitectureart;

IV.模块图形:

图4计时器

3.3.4记分器设计

I.输入/输出:

1个时钟信号输入;

1个复位信号输入;

1组片选信号输入;

4组4位2进制输出作为分数信号;

II.功能:

在时钟上升沿,依照片选信号,通过add(min)信号进行加(减)1分操作。

结果分别通过aa1,bb1,cc1,dd1反映。

III.VHDL程序:

--jifenqi

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entityjfqis

port(rst:

instd_logic;

clk:

instd_logic;

add:

instd_logic;

min:

instd_logic;

chos:

instd_logic_vector(3downto0);

aa1,bb1:

outstd_logic_vector(3downto0);

cc1,dd1:

outstd_logic_vector(3downto0));

endentityjfq;

architectureartofjfqis

begin

process(rst,add,min,chos)is

variablepoints_a1:

std_logic_vector(3downto0);

variablepoints_b1:

std_logic_vector(3downto0);

variablepoints_c1:

std_logic_vector(3downto0);

variablepoints_d1:

std_logic_vector(3downto0);

begin

if(clk'eventandclk='0')then

ifrst='0'then

points_a1:

="0000";

points_b1:

="0000";

points_c1:

="0000";

points_d1:

="0000";

endif;

ifadd='0'then

ifchos="0001"then

ifpoints_a1="1001"then

points_a1:

="0000";

else

points_a1:

=points_a1+'1';

endif;

elsifchos="0010"then

ifpoints_b1="1001"then

points_b1:

="0000";

else

points_b1:

=points_b1+'1';

endif;

elsifchos="0100"then

ifpoints_c1="1001"then

points_c1:

="0000";

else

points_c1:

=points_c1+'1';

endif;

elsifchos="1000"then

ifpoints_d1="1001"then

points_d1:

="0000";

else

points_d1:

=points_d1+'1';

endif;

endif;

elsifmin='0'then

ifchos="0001"then

ifpoints_a1="0000"then

points_a1:

="1001";

else

points_a1:

=points_a1-'1';

endif;

elsifchos="0010"then

ifpoints_b1="0000"then

points_b1:

="1001";

else

points_b1:

=points_b1-'1';

endif;

elsifchos="0100"then

ifpoints_c1="0000"then

points_c1:

="1001";

else

points_c1:

=points_c1-'1';

endif;

elsifchos="1000"then

ifpoints_d1="0000"then

points_d1:

="1001";

else

points_d1:

=points_d1-'1';

endif;

endif;

endif;

endif;

aa1<=points_a1;

bb1<=points_b1;

cc1<=points_c1;

dd1<=points_d1;

endprocess;

endarchitectureart;

IV.模块图形:

图5记分器

3.3.5分频器设计

I.输入/输出:

1个50MHz时钟信号输入;

1个1Hz时钟信号输出;

1个1KHz时钟信号输出;

1个2KHz时钟信号输出。

II.功能:

将50MHz时钟分频为1Hz,1KHz,2KHz分别输出。

III.VHDL程序:

libraryieee;

useieee.std_logic_1164.all;

entityfpis

port(

clk:

instd_logic;

clk1hz,clk1khz,clk2khz:

outstd_logic);

endfp;

architecturebehoffpis

signaldata1khz,data1hz,data2khz:

std_logic:

='0';

begin

clk1hz<=data1hz;

clk1khz<=data1khz;

clk2khz<=data2khz;

clk1khz_pro:

process(clk)--1khz

variablecnt:

integerrange0to24999;

begin

ifclk'eventandclk='1'then

ifcnt=24999then

cnt:

=0;data1khz<=notdata1khz;

else

cnt:

=cnt+1;

endif;

endif;

endprocessclk1khz_pro;

clk1hz_pro:

process(data1khz)--1hz

variablecnt:

integerrange0to499;

begin

ifdata1khz'eventanddata1khz='1'then

ifcnt=499then

cnt:

=0;data1hz<=notdata1hz;

else

cnt:

=cnt+1;

endif;

endif;

endprocessclk1hz_pro;

clk2khz_pro:

process(clk)--2khz

variablecnt:

integerrange0to12499;

begin

ifclk'eventandclk='1'then

ifcnt=12499then

cnt:

=0;data2khz<=notdata2khz;

else

cnt:

=cnt+1;

endif;

endif;

endprocessclk2khz_pro;

endbeh;

IV.模块图形:

图6分频器

3.3.6扫描显示设计

I.输入/输出:

1个时钟信号输入;

6组4位2进制信号输入;

1组位选信号输出;

1组4位2进制信号输出。

II.功能:

通过比人眼识别力频率高的时钟信号,将6组信号在6位上扫描输出,2位固定输出。

III.VHDL程序:

libraryieee;

useieee.std_logic_1164.all;

entityscanis

port(

clk1khz:

instd_logic;

fsd,fsc,fsb,fsa,djs0,djs1:

instd_logic_vector(3downto0);

en_out:

outstd_logic_vector(7downto0);

dataout:

outstd_logic_vector(3downto0));

endscan;

architecturebehofscanis

signalcnt:

integerrange0to7;

signalen:

std_logic_vector(7downto0);

begin

cnt_pro:

process(clk1khz)

begin

ifclk1khz'eventandclk1khz='1'then

ifcnt=7then

cnt<=0;

else

cnt<=cnt+1;

endif;

endif;

endprocesscnt_pro;

scan_pro:

process(cnt,fsd,fsc,fsb,fsa,djs0,djs1)

begin

casecntis

when0=>dataout<=fsd;en<="11111110";

when1=>dataout<=fsc;en<="11111101";

when2=>dataout<=fsb;en<="11111011";

when3=>dataout<=fsa;en<="11110111";

when4=>dataout<=djs0;en<="01111111";

when5=>dataout<=djs1;en<="10111111";

when6=>dataout<="1010";en<="11101111";

when7=>dataout<="1010";en<="11011111";

whenothers=>null;

endcase;

endprocessscan_pro;

en_out<=en;

endarchitecturebeh;

IV.模块图形:

图7扫描显示

3.3.7译码器设计

I.输入/输出:

1组4位2进制输入;

1组8位2进制输出。

II.功能:

将4位2进制输入译码为8位2进制方便八段数码管显示。

III.VHDL程序:

libraryieee;

useieee.std_logic_1164.all;

entitydisplayis

port(

datain:

instd_logic_vector(3downto0);

dataout:

outstd_logic_vector(7downto0));

enddisplay;

architecturebehofdisplayis

begin

process(datain)

begin

casedatainis

when"0000"=>dataout<="11000000";--dp,g,f,e,d,c,b,a

when"0001"=>dataout<="11111001";

when"0010"=>dataout<="10100100";

when"0011"=>dataout<="10110000";

when"0100"=>dataout<="10011001";

when"0101"=>dataout<="10010010";

when"0110"=>dataout<="10000010";

when"0111"=>dataout<="11111000";

when"1000"=>dataout<="10000000";

when"1001"=>dataout<="10010000";

when"1010"=>dataout<="10111111";

when"1011"=>dataout<="10000011";

when"1100"=>dataout<="10100111";

when"1101"=>dataout<="10100001";

when"1110"=>dataout<="10000110";

when"1111"=>dataout<="10001110";

whenothers=>null;

endcase;

endprocess;

endbeh;

IV.模块图形:

图8译码器

3.3.8蜂鸣器设计

I.输入/输出:

2个不同频率时钟信号输入;

2组4位2进制片选信号输入;

1个时钟信号输出。

II.功能:

倒计时2、4、6秒时输出提示音;0秒时输出终止音。

III.VHDL程序:

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitytsyis

port

(clk:

instd_logic;--zhongzhi

clk1:

instd_logic;--tishi

clk_out:

outstd_logic;

qa:

instd_logic_vector(3downto0);

qb:

instd_logic_vector(3downto0));

endentitytsy;

architecturebehaveoftsyis

begin

process(clk,qa,qb)is

begin

ifclk'eventandclk='1'then

if(qa="0000"andqb="0000")then

clk_out<=clk;

elsif(qa="0100"andqb="0000")then

clk_out<=clk1;

elsif(qa="0010"andqb="0000")then

clk_out<=clk1;

elsif(qa="0110"andqb="0000")then

clk_out<=clk1;

elseclk_out<='0';

endif;

endif;

endprocess;

endarchitecturebehave;

IV.模块图形:

图9蜂鸣器

 

第四章调试与仿真结果

4.1抢答鉴别电路

图10抢答鉴别电路仿真时序图

4.2计时器

图11计时器仿真时序图

4.3记分器

图12记分器仿真时序图

4.4分频器

图13分频器仿真时序图

4.5扫描显示

图14扫描显示仿真时序图

4.6译码器

图15译码器仿真时序图

4.7蜂鸣器

图16蜂鸣器仿真时序图

 

第五章调试中遇到的问题及解决的方法

5.1问题1:

按键无反应。

解决方法:

赋值高低电平给反了,把=’1’改为=’0’即可。

5.2问题2:

process中add’eventandadd=’1’ormin’eventandmin=’1’无法编译。

解决方法:

process中只能出现一个变化沿,用clk’eventandclk=’1’代替,再进行选择即可。

5.3问题3:

数码管显示乱码。

解决方法:

数码管位选与段选引脚接反,重新按正确接法分配引脚即可。

5.4问题4:

20s计时器到0后变为29。

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

当前位置:首页 > 小学教育 > 语文

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

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