当前位置:文档之家› EDA篮球比赛电子记分牌设计

EDA篮球比赛电子记分牌设计

长沙学院课程设计说明书题目篮球比赛电子记分牌设计目录一、课题名称ﻩ错误!未定义书签。

二、设计内容ﻩ错误!未定义书签。

三、设计思路ﻩ错误!未定义书签。

1、整体设计思路: ............................................................................................ 错误!未定义书签。

2、整体设计流程:ﻩ错误!未定义书签。

四、设计说明 (2)1、设计程序ﻩ32、ﻩ引脚分配设置: ....................................................................................... 错误!未定义书签。

3、ﻩ功能描述 ................................................................................................... 错误!未定义书签。

五、设计心得....................................................................................................... 错误!未定义书签。

六、参考文献ﻩ错误!未定义书签。

一、课题名称篮球比赛电子记分牌设计二、设计内容设计一个篮球比赛记分牌,使用4位数码管显示倒计时的分钟、秒钟值;2位数码管显示A方得分;2位数码管显示B方得分;使用LED灯作为上、下半场的标志;单次加分值包括1分、2分和3分;半场时间到输出3秒的声光提示;可进行比赛暂停、比赛加时等操作;终场时间到输出5秒的声光提示。

三、设计思路1、整体设计思路:根据设计内容,可将设计将分为五个模块来设计:分频计数模块、时间模块、加分模块、动态扫描显示模块、LED灯模块。

2、整体设计流程:(1)、分频计数模块:通过分频模块,将试验箱自带的50MHZ的频率分频得到1MZ以及1HZ的频率(2)、时间模块:将计时器的分钟、秒钟,通过借位的方式设计成40分钟的倒计时时钟(3)、加分模块:通过拨盘开关的选择,输入A、B队的比赛得分(4)、动态扫面显示模块:通过1MHZ的频率,将时间以及ﻩA、B队的比赛得分同时扫描显示在数码管上(5)、LED灯模块:对上下场的显示,以及比赛结束的灯亮延长显示四、设计说明1、设计程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity baseketballisport(clk:instd_logic;ﻩstart,addtime,add1_A,add2_A,add3_A,add1_B,add2_B,add3_B:in std_logi c;--A\B duijiafen xinhao--比赛开始,A.B队加分信号ﻩstop:in std_logic; --比赛暂停ﻩﻩled7s_selout:outstd_logic_vector(7downto0); --数码管位选ﻩled7s:out std_logic_vector(6 downto0); --7 段数码显示管ﻩled_up:out std_logic; --上半场亮灯显示ﻩled_down:outstd_logic; --下半场亮灯显示ﻩled_h_end:outstd_logic; --半场结束延时亮灯输出ﻩled_f_end:outstd_logic); --全场结束延时亮灯输出end;architecture oneofbaseketball isconstant time_m:integer:=9; --时间分位初始化constanttime_s :integer:=59; --时间秒位初始化signal time_m0:integer range0 to9; --分位时间范围signaltime_s0:integer range 0to 59;--秒位时间范围signal cout_A,cout_B:integer range0to 99;-- 比分计数范围signal clk0_1,clk0_1M:std_logic; --1HZ\1MHZ 信号signal q0_1:integer range0 to24999999; --1HZ 分频计数范围signal q0_1M:integer range0 to25; --1MHZ分频计数范围signalhalf_end,full_end,add_end:std_logic;-- 上下半场结束信号signal r,a,b,c,d,e,f,g,h:integer range0 to 9;--扫描显示加载信号signal q1:integerrange0 to7;--动态扫描显示信号范围signal q_3:integer range0 to3;--s半场比赛结束延时提示signal q_5:integer range 0to 5; --全场比赛结束延时提示signalq_t_m:integerrange 0to 1; --秒借位signal q_t_s:integer range 0 to 1;--分借位beginprocess(clk) --1MHZ频率beginﻩﻩif clk'eventandclk='1'thenﻩifq0_1M=25 thenﻩﻩﻩq0_1M<=0;ﻩclk0_1M<=notclk0_1M;ﻩelse q0_1M<=q0_1M+1;ﻩendif;ﻩendif;ﻩend process;process(clk) -- 1HZ 频率beginﻩifclk'event and clk='1' thenﻩif q0_1=24999999thenﻩq0_1<=0;ﻩﻩclk0_1<=notclk0_1;ﻩelseﻩﻩq0_1<=q0_1+1;end if;ﻩend if;end process;process(clk0_1,clk) --时间模块beginif clk0_1'event andclk0_1='1'thenifstart='1' thenﻩif half_end='0' and full_end='0'thentime_s0<=time_s;led_up<='1';ﻩif time_m0=0and time_s0=0then ﻩﻩtime_m0<=time_m;ﻩﻩled_up<='0';ﻩﻩﻩﻩhalf_end<='1';elsif time_s0=0 thenﻩﻩﻩq_t_m<=1;ﻩﻩﻩtime_m0<=time_m0-q_t_m;ﻩelseﻩﻩﻩﻩq_t_s<=1;ﻩﻩﻩﻩtime_s0<=time_s0-q_t_s;ﻩﻩend if;ﻩend if;ﻩif half_end='1' and full_end='0'thenﻩﻩtime_s0<=time_s;ﻩled_down<='1';if time_m0=0 andtime_s0=0 thenﻩtime_m0<=time_m;ﻩﻩled_down<='0';ﻩfull_end<='1';ﻩﻩelsif time_s0=0 thenﻩﻩﻩq_t_m<=1;ﻩﻩﻩtime_m0<=time_m0-q_t_m;ﻩelseﻩﻩﻩq_t_s<=1;ﻩﻩtime_s0<=time_s0-q_t_s;ﻩﻩend if;ﻩend if;ﻩﻩend if;if addtime='1' andfull_end='1' then --比赛计时ﻩﻩifadd_end='0'thentime_s0<=time_s;ﻩif time_m0=0and time_s0=0 thenﻩﻩﻩtime_m0<=time_m;add_end<='1';ﻩﻩelsif time_s0=0 thenﻩq_t_m<=1;ﻩﻩtime_m0<=time_m0-q_t_m;ﻩﻩﻩelseﻩﻩﻩq_t_s<=1;ﻩﻩﻩtime_s0<=time_s0-q_t_s;ﻩend if;endif;ﻩif stop='1' thenﻩhalf_end<='0';ﻩfull_end<='0';add_end<='0';ﻩendif;end if;endprocess;process(add1_A,add2_A,add3_A) --A 对加分模块beginif add1_A='1'thenﻩcout_A<=cout_A+1;ﻩendif;ifadd2_A='1' thenﻩﻩcout_A<=cout_A+2;ﻩend if;if add3_A='1'thenﻩcout_A<=cout_A+3;ﻩﻩend if;ﻩifstop='1' thencout_A <=0;end if;endprocess;process(add1_B,add2_B,add3_B)--B对加分模块beginif add1_B='1'thenﻩcout_B<=cout_B+1;ﻩend if;ifadd2_B='1'thenﻩcout_B<=cout_B+2;ﻩendif;ﻩif add3_B='1' thenﻩﻩcout_B<=cout_B+3;ﻩend if;ﻩif stop='1'thenﻩcout_B <=0;ﻩend if;end process;process(clk0_1M,q1)ﻩbeginﻩif clk0_1M'eventand clk0_1M='1'thenﻩif q1=7 thenﻩﻩq1<=0;ﻩelseq1<=q1+1;ﻩendif;endif;endprocess;process(q1,a,b,c,d,e,f,g,h) --动态扫描显示模块ﻩbegina<=time_m0/10;b<=time_m0rem10;ﻩc<=time_s0/10;ﻩﻩd<=time_s0 rem 10;ﻩﻩe<=cout_A/10;f<=cout_A rem10;ﻩg<=cout_B/10;ﻩh<=cout_B rem 10;ﻩcase q1iswhen 0 => led7s_selout<="00000001";r<=a;when 1=> led7s_selout<="00000010";r<=b;ﻩwhen2=> led7s_selout<="00000100";r<=c;ﻩﻩwhen 3 => led7s_selout<="00001000";r<=d;ﻩwhen 4 =>led7s_selout<="00010000";r<=e;ﻩﻩwhen5 => led7s_selout<="00100000"; r<=f;ﻩﻩwhen6=> led7s_selout<="01000000";r<=g;ﻩﻩwhen7 => led7s_selout<="10000000"; r<=h;ﻩwhenothers=> null;ﻩend case;end process;ﻩprocess(r)ﻩbeginﻩﻩcaser isﻩﻩwhen 0=>led7s<="1000000";ﻩﻩwhen 1=>led7s<="1111001";ﻩwhen2=>led7s<="0100100";ﻩﻩwhen 3=>led7s<="0110000";ﻩﻩwhen 4=>led7s<="0011001";ﻩwhen5=>led7s<="0010010";ﻩﻩﻩwhen6=>led7s<="0000010";ﻩﻩwhen7=>led7s<="1111000";ﻩﻩwhen8=>led7s<="0000000";ﻩﻩwhen 9=>led7s<="0010000";ﻩﻩﻩﻩwhen others=> null;ﻩﻩend case;end process;process(clk0_1,half_end,full_end) --上下半场灯亮延时提示beginif clk0_1'event and clk0_1='1'thenif half_end='1'thenifq_3=3thenﻩled_h_end<='0';ﻩelse q_3<=q_3+1;ﻩﻩled_h_end<='1';end if;endif;ﻩif full_end='1' thenﻩif q_5=5thenﻩﻩﻩled_f_end<='0';ﻩﻩelse q_5<=q_5+1;led_f_end<='1';ﻩend if;endif;ﻩif stop='1' thenﻩq_3<=0;ﻩﻩq_5<=0;end if;end if;end process; end;2、引脚分配设置:3、功能描述加载程序至试验箱,打开拨盘开关1,比赛开始,LED灯1灭,进行上半场比赛,8个数码显示管依次显示09590000,比赛时间一共10分钟,前四位为时间显示每一秒减计数一次;第五位和第六位为A对比赛分值,当拨动拨盘开关3、4、5时,数码管相应显示加1分、2分、3分;第七位和第八位为B对比赛分值,当拨动拨盘开关6、7、8时,数码管相应显示加1分、2分、3分;打开把盘开关2,比赛暂停,恢复以后比赛继续进行。

相关主题