数电课程设计-竞赛抢答器.doc_第1页
数电课程设计-竞赛抢答器.doc_第2页
数电课程设计-竞赛抢答器.doc_第3页
数电课程设计-竞赛抢答器.doc_第4页
数电课程设计-竞赛抢答器.doc_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

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

文档简介

数电课程设计实验报告 课题:竞赛抢答器 学院:电气与信息工程学院 姓名:班级:电子信息工程1001班 目录一、课程设计的要求及目的- 1 -二、设计的功能要求- 2 -三、设计思路框图- 3 -四、vhdl程序- 4 -1、键盘转按键模块- 4 -2、显示模块- 6 -3、主模块- 9 -五、电路连接图- 14 -六、心得体会- 14 -一、课程设计的要求及目的1了解电子设计的具体流程和方法。 2. 掌握电子设计的基本要求,能够运用所学的知识解决生活中的一些问题。 3. 初步掌握vhdl语言编程,并设计出一个有意义的小型系统。 4. 掌握altium designer 6.9软件的应用,并且了解相关硬件的组成和功能。 5. 用eda(electronic design automation)或者原理图完成一个课题的设计,并达到相应的功能要求。 二、设计的功能要求 在许多比赛活动中,为了准确、公正、直观地判断出第一抢答者,通常设置一台抢答器,通过数显、灯光及音响等各种手段批示出第一抢答者。同时,还可以设置计分、犯规及奖惩记录等各种功能。本设计利用eda技术,可容纳8组参赛,每组设置一个按钮供参赛者抢答使用。主持人按下开始按键后,10s倒计时开始,当一组抢答器按下后,1602lcd显示抢答的组别。由于抢答器具有第一信号鉴别和锁存功能使其余的组就抢答无效,抢答的组回答问题后由主持人进行加减分,然后主持人按复位键后继续进行抢答。1、在1602lcd屏幕上显示所需组别及分数;2、考虑到有选手犯规,在主持人未按下开始键但是已经有组别按下抢答键时会在屏幕显示该组别犯规(fg),并由主持人手动减分; 3、按下开始键后,有10s的时间供选手们抢答,如果30s后仍无人抢答,则蜂鸣器报警,并在屏幕上显示超时(cs);4、每个组别设置的初始分数为0分,加分上限为9分; 5、能实现系统手动复位,复位后回到初始状态,并等待主持人按下开始键。三、设计思路框图译码显示译码优先编码 抢答按钮控制模块主持人控制开关显示模块定时模块秒脉冲产生四、vhdl程序1、键盘转按键模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity padtokey is port ( cpin,r,validkey :in std_logic; key :in std_logic_vector(3 downto 0); keyout: out std_logic_vector(15 downto 0); clk_1mhz,rst: out std_logic );end entity ;architecture jgt of padtokey is signal ctcp: integer range 0 to 5; signal cpo :std_logic:=0; signal ctcpo :integer range 0 to 4999; type states is (s0,s1,s2); signal s: states;beginprocess(cpin)beginif cpin=1 and cpin event then if ctcp=5 then cpo = not cpo; ctcp=0; else ctcp=ctcp+1; end if;end if;end process;process(cpo,r)beginclk_1mhz=cpo;if r=1 then rst=0;s=s0;ctcpo=0; keyout=0000000000000000;elsif cpo=1 and cpo event then if ctcpo /= 4999 then ctcpo=ctcpo+1; else ctcporst=0; if validkey=1 then skeyoutkeyoutkeyoutkeyoutkeyoutkeyoutkeyoutkeyoutkeyoutkeyoutkeyoutkeyoutkeyoutkeyoutkeyoutkeyoutnull; end case; else s=s0;keyoutrst=1;srst=0;s null; end case; end if;end if;end process; end architecture jgt;此模块使用状态机将键盘的16个按键转换为16个按键信号。2、显示模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity qdqlcd is port (cpin,r,busy :in std_logic; fs1,fs2,fs3,fs4,fs5,fs6,fs7,fs8,tm :in std_logic_vector(7 downto 0); zb : in std_logic_vector(3 downto 0); teshu : in std_logic_vector(1 downto 0); clk,rst,strobe,outline : out std_logic; data : out std_logic_vector(7 downto 0); addr : out std_logic_vector(3 downto 0) );end entity ;architecture jgt of qdqlcd is type states is (s0,s1,s2,s3,s4); signal s: states; signal lcdpt : integer range 0 to 27; signal cpct : integer range 0 to 65535; signal cp: std_logic; -signal ascew,ascsn : std_logic_vector(7 downto 0);beginprocess(cpin,r)beginclk=cpin;if r=1 then cpct=65535;elsif cpin=1 and cpin event then if cpct=0 then cpct=65535;cp=not cp; else cpcts2 - :y: s3- ;n; null-s2:strobes1-s1,s2process(cp,r)beginif r=1 then s=s0;lcdpt=0;rst s=s1;lcdpt=0;rst rst=0;strobe=0; if busy=0 then lcdpt=lcdpt+1; if lcdpt=7 then s=s3; else s s=s1;strobe strobe=0; if busy=0 then if lcdpt=27 then lcdpt=7; else lcdpt=lcdpt+1; end if; s strobe=1;s null; end case;end if; end process;-(lcdpt)-lcdpt=0,null- =16 zb: tm: e 45h,5 w57h,6 s53h,9 n4eh,10process(lcdpt)begincase lcdpt iswhen 0 = null;when 1= data=01011010;addr=1001;outline data=01000010;addr=1010;outline data=00111010;addr=0100;outline data=01010100;addr=0010;outline data=01001101;addr=0011;outline data=00111010;addr=1011;outlinedata=0011&fs1(7 downto 4);addr=0000;outlinedata=0011&fs1(3 downto 0);addr=0001;outlinedata=0011&fs2(7 downto 4);addr=0010;outlinedata=0011&fs2(3 downto 0);addr=0011;outlinedata=0011&fs3(7 downto 4);addr=0100;outlinedata=0011&fs3(3 downto 0);addr=0101;outlinedata=0011&fs4(7 downto 4);addr=0110;outlinedata=0011&fs4(3 downto 0);addr=0111;outlinedata=0011&fs5(7 downto 4);addr=1000;outlinedata=0011&fs5(3 downto 0);addr=1001;outlinedata=0011&fs6(7 downto 4);addr=1010;outlinedata=0011&fs6(3 downto 0);addr=1011;outlinedata=0011&fs7(7 downto 4);addr=1100;outlinedata=0011&fs7(3 downto 0);addr=1101;outlinedata=0011&fs8(7 downto 4);addr=1110;outlinedata=0011&fs8(3 downto 0);addr=1111;outlinedata=0011&tm(7 downto 4);addr=0101;outlinedata=0011&tm(3 downto 0);addr=0110;outlinedata=0011&zb(3 downto 0);addr=1101;outlinecase teshu is when 01= data=01000110;addr=1110;outline data=01000011;addr=1110;outline null; end case;when 27=case teshu is when 01= data=01000111;addr=1111;outline data=01010011;addr=1111;outline null; end case;when others= null;end case;end process; end architecture jgt;此模块采用状态机的方法在lcd上按格式显示抢答器的8个2位bcd码分数、抢答的组别、时间。3、主模块library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;- uncomment the following library declaration if instantiating- any xilinx primitives in this code.-library unisim;-use unisim.vcomponents.all;entity qdmain1 is port ( teshu : out std_logic_vector (1 downto 0); cpin : in std_logic; keyout : in std_logic_vector (15 downto 0); r : in std_logic; fs1 : out std_logic_vector (7 downto 0); fs2 : out std_logic_vector (7 downto 0); fs3 : out std_logic_vector (7 downto 0); fs4 : out std_logic_vector (7 downto 0); fs5 : out std_logic_vector (7 downto 0); fs6 : out std_logic_vector (7 downto 0); fs7 : out std_logic_vector (7 downto 0); fs8 : out std_logic_vector (7 downto 0); tm : out std_logic_vector (7 downto 0); zb : out std_logic_vector (3 downto 0);end qdmain1;architecture behavioral of qdmain1 issignal kskey:std_logic:=0;signal yida:std_logic:=0;signal jiaflag,jianflag:std_logic;signal cpct : integer range 0 to 4999;signal cp: std_logic;signal cp1s : integer range 0 to 999;signal cpcnt: std_logic; signal tm1 : std_logic_vector (7 downto 0); signal zb1 : std_logic_vector (3 downto 0);- signal f1,f2,f3,f4,f5,f6,f7,f8 : std_logic_vector (7 downto 0); signal fk1,fk2,fk3,fk4,fk5,fk6,fk7,fk8 : std_logic_vector (7 downto 0);begintm=tm1;zb=zb1;fs1=fk1; fs2=fk2; fs3=fk3;fs4=fk4; fs5=fk5;fs6=fk6; fs7=fk7;fs8=fk8;process(r,cpin)begin if r=1 then cpct=4999; elsif cpin=1 and cpin event then -20mhz if cpct=0 then -cp shi 500us; cpct=4999;cp=not cp; else cpct=cpct-1; end if; end if;end process;process(r,cp)begin if r=1 then cp1s=0; elsif cp=1 and cp event then if cp1s=999 then cp1s=0; cpcnt=not cpcnt; -cpcnt shi 1s; else cp1s=cp1s+1; end if; end if;end process;process(cpin,cpcnt)beginif cpin=1 and cpin event then if keyout=1000000000000000 then fk1=00000000; fk2=00000000; fk3=00000000;fk4=00000000; fk5=00000000; fk6=00000000;fk7=00000000; fk8=00000000; elsif r=1 then yida=0; kskey=0; tm1=00001001; zb1=0000; teshu=00; jiaflag=1; jianflagkskeyyida=1;zb1=0001; -fk1yida=1;zb1=0010; -fk2yida=1;zb1=0011; -fk3yida=1;zb1=0100; -fk4yida=1;zb1=0101; -fk5yida=1;zb1=0110; -fk6yida=1;zb1=0111; -fk7yida=1;zb1=1000; -fk8yida=0;kskeynull; end case; if kskey=1 then if cpcnt=1 and cpcnt event then if tm1/=00000000 then tm1=tm1-1; end if; end if; if tm1=00000000 then teshu=10; -chao shi end if; end if; else if kskey=0 then teshufk1=fk1-1; jianflagfk2=fk2-1; jianflagfk3=fk3-1; jianflagfk4=fk4-1; jianflagfk5=fk5-1; jianflagfk6=fk6-1; jianflagfk7=fk7-1; jianflagfk8=fk8-1; jianflagnull; end case; end if; end if; else if keyout=0001000000000000 then if jiaflag=1 then case zb1 is when 0001=fk1=fk1+1;jiaflagfk2=fk2+1;jiaflagfk3=fk3+1;jiaflagfk4=fk4+1;jiaflagfk5=fk5+1;jiaflagfk6=fk6+1;jiaflagfk7=fk7+1;jiaflagfk8=fk8+1; jiaflagnull; end case; end if; end if; end if; end if; end if; end if;end process;end behavioral; else cpct=cpct-1; end if;end

温馨提示

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

评论

0/150

提交评论