EDA课程设计毕业课程设计_第1页
EDA课程设计毕业课程设计_第2页
EDA课程设计毕业课程设计_第3页
EDA课程设计毕业课程设计_第4页
EDA课程设计毕业课程设计_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

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

文档简介

1、 课程设计说明书 no. 20设计题目:抢答器的设计与仿真一课程设计的目的eda课程设计是电子信息科学与技术专业开设的一门独立实践环节课程。通过课程设计使学生具体掌握将理论知识与实际应用相结合的方法,提高分析问题和解决问题的能力,激发学习兴趣、锻炼动手能力和科研能力。了解cpld为复杂可编程逻辑器件,通过eda技术对其进行编程,可将一个较复杂的数字系统集成于一个芯片中,制成专用集成电路芯片,并可随时在系统修改其逻辑功能。二设计方案论证1. 设计原理抢答器原理是根据所要设计的系统功能,将整个系统划分成几个主要模块,再将每个模块细分成几个子模块,直到最底层的小模块容易编程实现为止。只需对底层元件编

2、程实现,最后将各模块连接起来组成所需的系统。对于一个抢答器系统,可将其分为五个模块:选手抢答模块、抢答启动模块、加减分模块、显示模块、蜂鸣器控制模块,整体框图如图(1)所示。 图(1)总体框图其中抢答启动模块具有启动抢答及启动定时功能,输出使能信号给选手识别模块,以及抢答剩余时间给显示模块;选手识别模块完成锁存抢答信号的功能,并输出选手号给显示模块;蜂鸣器对抢答成功以及超时鸣声报警;显示模块对输入的数据进行显示。2. 设计内容(1)设计一智力竞赛抢答器,可同时供8名选手参加比赛。(2)给节目主持人设置一个控制开关,控制系统清零和抢答开始。(3)抢答器具有锁存功能和显示功能。抢答开始后,若有选手

3、按动抢答按钮,编号立即锁存,并在led数码管上显示选手编号,同时扬声器响,禁止其他选手抢答。(4)抢答器具有抢答定时功能,时间由主持人确定。(5)参赛选手在设定的时间内抢答有效,定时器停止工作。(6)如果定时时间到,无人抢答,本次抢答无效,系统报警,并封锁输入电路,禁止超时抢答,定时器显示00 。(7)为每组设计一个计分电路,0999分,可加分,也可减分。3. 设计整体原理图 图(2)设计原理图三设计结果与分析1、抢答启动模块启动模块除了有启动的功能外,还有启动定时的功能。定时时间分为5秒和20秒两种,使用两个按键对应两种限时抢答。将本模块再划分为2个子模:一个模块完成按键识别的功能,另一模块

4、完成倒计时功能。(1)按键识别子模块按键的识别即对输入信号进行电平变化检测,电平发生跳变就认为是键被按下。但vhdl程序中一个结构体内不能同时对两个信号进行电平跳变的检测,所以对本模块的程序设计采用状态机来实现,并使用统一的时钟信号来扫描按键的电平状态。模块如图(3)所示。 图(3)按键识别子模块对start5和start20两个按键定义三种状态,start5按下为st1状态,此时两个按键“start5&start20”输入电平为“01”;start20按下为st2状态,此时电平为“10”;两个都没按下为st0状态,此时电平为“11”。状态转换图如图(4)所示。 图(4)按键识别子模块状态转换

5、图本模块程序为:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity start_5_20 isport(clk1,rst,start5,start20:in std_logic; b,a:out std_logic_vector(3 downto 0); s_flag:out std_logic); end entity;architecture one of start_5_20 issignal datain:std_logic_vector(1 downto 0);type st_

6、type is (st0,st1,st2); signal c_st:st_type;begindatain=start5&start20; process(rst,clk1)beginif rst=0 then b=0000;a=0000;c_st=st0;s_flag if datain=01 then c_st=st1; s_flag=1; b=0000;a=0101; elsif datain=10 then c_st=st2; s_flag=1; b=0011;a=0000; else c_stif datain=11 thenc_st=st0;s_flag=0; else c_st

7、if datain=11 then c_st=st0;s_flag=0;else c_stc_st=st0;b=0000;a=0000;end case;end if;end process;end architecture;本模块仿真波形如图(5)所示。 图(5)按键识别子模块仿真波形(2)倒计时子模块倒计时需要1hz的脉冲输入,每来一个上升沿,进行一次减一运算,将结果输出到timeb、timea;置数信号load输入有效,读入b、a端口的数据;输入l_cr信号与选手识别模块连接,当选手抢答成功后,l_cr信号为0,将倒计时清0.;若倒计时到,没有选手抢答,则在sr1输出1使扬声器发声。同时

8、输出信号给选手抢答模块,禁止选手抢答如图(6)所示。图(6)倒计时模块本模块程序为:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity de_count is port(clk2,load,l_cr,rst:in std_logic; b,a:in std_logic_vector(3 downto 0); timeb,timea:out std_logic_vector(3 downto 0); timeout,sr1:out std_logic);end entity;archite

9、cture two of de_count isbeginprocess(load,l_cr,rst,clk2)variable p1,p0:std_logic_vector(3 downto 0);beginif load=1 thenp1:=b;p0:=a; elsif l_cr=0 then p1:=0000;p0:=0000;timeout=0;sr1=1; elsif rst=0 then p1:=0000;p0:=0000;timeout=0;sr10 thenp1:=p1-1;p0:=1001; end if;else p0:=p0-1; if p0=0000 and p1=00

10、00 thentimeout=0;sr1=1; end if;end if;end if;timeb=p1;timeaclk1,start5=start5,start20=start20,rst=rst,b=m,a=n,s_flag=p); u2:de_count port map(clk2=clk2,b=m,a=n,load=p,rst=rst,l_cr=l_cr,timeb=timeb,timea=timea,timeout=timeout,sr1=sr1);end architecture;2、选手抢答模块在一个结构体中用8个进程同时对8个选手按键电平变化的监测是不可实现的,所以将本模块

11、划分为两个子模块:单个选手按键模块和判断抢答选手模块。最后将8个选手按键模块和1个判断抢答选手模块连接起来,得到整个选手抢答模块。(1)单个选手按键子模块按键输入相当于该实体的时钟信号,键被按下,等于来一个脉冲,输出信号给判断模块进行选手号的判断。只要有选手抢答成功,相关模块会输出信号使8个按键模块的lock信号有效,禁止其他选手抢答。如图(8)所示。 图(8)单个选手按键子模块本模块程序如下:library ieee;use ieee.std_logic_1164.all;entity button1 isport(lock , button , rst :in std_logic; pre

12、ssed:out std_logic);end entity;architecture b1 of button1 isbeginprocess(rst , button) beginif rst=0 thenpressed=0; elsif buttonevent and button=0 thenif lock=1 then pressed=1; end if;end if;end process;end architecture;单个选手模块仿真波形如图(9)所示。 图(9)单个选手按键子模块仿真波形(2)判断抢答选手子模块本子模块接收8个按键子模块的输出信号,如收到1号子模块输出的高电

13、平,则输出选手号“0001”;并发出信号使扬声器发声并控制8个按键子模块使它们的lock信号有效,禁止其他选手抢答。本子模块端口设置如图(10)所示。 图(10)判断选手模块本子模块程序如下:library ieee;use ieee.std_logic_1164.all;entity identifier isport(pp1,pp2,pp3,pp4,pp5,pp6,pp7,pp8:in std_logic; p_num:out std_logic_vector(3 downto 0); lock,sr1:out std_logic);end entity;architecture one

14、of identifier issignal p:std_logic_vector(7 downto 0);beginpp_num=0001;lock=0;sr1p_num=0010;lock=0;sr1p_num=0011;lock=0;sr1p_num=0100;lock=0;sr1p_num=0101;lock=0;sr1p_num=0110;lock=0;sr1p_num=0111;lock=0;sr1p_num=1000;lock=0;sr1p_num=0000;lock=1;sr1lock,b=p1,rst=rst,pressed=a1); u2:button1 port map(

15、lock=lock,b=p2,rst=rst,pressed=a2); u3:button1 port map(lock=lock,b=p3,rst=rst,pressed=a3); u4:button1 port map(lock=lock,b=p4,rst=rst,pressed=a4); u5:button1 port map(lock=lock,b=p5,rst=rst,pressed=a5); u6:button1 port map(lock=lock,b=p6,rst=rst,pressed=a6); u7:button1 port map(lock=lock,b=p7,rst=r

16、st,pressed=a7); u8:button1 port map(lock=lock,b=p8,rst=rst,pressed=a8); u9:identifier port map(pp1=a1,pp2=a2,pp3=a3,pp4=a4,pp5=a5,pp6=a6, pp7=a7,pp8=a8,p_num=p_num,lock=lock_s,sr1=sr1);end architecture;3.分数选择输出模块四组分数要显示出来,需要12个7段数码管。若只显示当前抢答成功选手的分数,则只需3个数码管。所以设置一个分数选择器,根据抢答成功的选手编号,选择其分数输出给显示模块显示。设计源

17、程序为:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity muxx is port(p_num,aa2,aa1,aa0,bb2,bb1,bb0:in std_logic_vector(3 downto 0); cc2,cc1,cc0,dd2,dd1,dd0:in std_logic_vector(3 downto 0); d2,d1,d0:out std_logic_vector(3 downto 0);end entity;architecture one of muxx isbeg

18、in process(p_num) begin case p_num iswhen 0001=d2=aa2;d1=aa1;d0d2=aa2;d1=aa1;d0d2=bb2;d1=bb1;d0d2=bb2;d1=bb1;d0d2=cc2;d1=cc1;d0d2=cc2;d1=cc1;d0d2=dd2;d1=dd1;d0d2=dd2;d1=dd1;d0d2=0000;d1=0000;d0=0000; end case; end process;end architecture;仿真波形如图(13)所示。 图(13)分数选择输出模块仿真波形4.显示模块本模块根据送来的数据:抢答成功选手号,选手分数、

19、倒计时时间,将相应的字形码送数码管显示。端口设置如图(14)所示。该图中,bt为数码管的位选信号,sg为数码管的段选信号。另外图20为数码管的分配。左起第一位为选手编号,第3、4位为该选手的分数,最后两位为倒计时。 图(14)显示模块设计程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity display isport(clk:in std_logic; score2,score1,score0,p_number,timeb,timea:in std_logic_vector(3

20、 downto 0); bt,sg:out std_logic_vector(7 downto 0);end entity;architecture one of display issignal cnt8:std_logic_vector(2 downto 0);signal a:std_logic_vector(3 downto 0);begin p1:process(clk) beginif clkevent and clk=1 then cnt8bt=10000000;abt=01000000;abt=00100000;abt=00010000;abt=00001000;abt=000

21、00100;abt=00000010;abt=00000001;asgsgsgsgsgsgsgsgsgsgsgnull;end case;end process;end architecture;本模块仿真波形如图(15)所示。 图(15)显示模块仿真波形5.蜂鸣器模块当sr1鸣声信号来时,输出clk2(2khz)驱动蜂鸣器发声。clk1用于扫描sr1的电平变化,sr1上升沿来到,允许clk2输出,并持续一段时间。模块如图(16)所示。图(16)蜂鸣器模块本模块程序如下:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_un

22、signed.all;entity speaker is port(clk1,sr1,clk2:in std_logic; s:out std_logic);end entity;architecture one of speaker istype st_type is (st0,st1);signal c_st:st_type;signal a:std_logic;begin process(clk1) variable p:std_logic_vector(7 downto 0);beginif clk1event and clk1=1 thencase c_st iswhen st0=i

23、f sr1=1 then p:=00111111;c_st=st1;a=1; else c_st=st0;aif p/=0 then p:=p-1;c_st=st1; elsea=0; if sr1=1 then c_st=st1; else c_stc_st=st0;a=0;end case;end if;end process;s=clk2 and a; end architecture;本模块的仿真波形如图(17)所示。 图(17)蜂鸣器模块仿真波形四设计体会通过这次课程设计我学会了使用max+puls软件,还学了verilog hdl编程的方法。因为verilog hdl语言语法和以前学过的c语言比较相近,所以在看了些相关书籍和程序范例后,就入手编写verilog hdl代码,开始时候没有遇到太大问题。但是毕竟verilog hdl和c许多还是有差别的,如case的用法等。但是经过我们一起的努力,顺利的完成了ve

温馨提示

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

评论

0/150

提交评论