1、具有篮球倒计时的数字钟 VHDL语言及数字电路 课程设计说 明 书 装 订 线 设计题目 具有篮球倒计时的数字钟 系 别 机电系 专业班级 10应用电子技术 学生姓名 杨华培 学 号 1010401028 指导教师 吴小玲老师 日 期 2012. 06. 25 一 项目要求 例如: 设计一个电子数字钟,具体要求如下:(1) 有调时,调分按键。(2) 具有时钟复位,倒计时复位按键。(3) 设有一个时钟模式和倒计时模式的切换键。(4) 倒计时分别从14秒或24秒倒计,计到0是有报警二设计方案1. 项目分析 本设计是基于ACEX1K系列芯片设计的。显示界面为一个8位的LED数码管,时间显示方式为8位
2、同时显示,即显示状态为:88-88-88。显示的时间制为24小时制。当按下切换键时,显示倒计时模式为两位数码管显示。本设计有7个按键,分别为clr(选择24秒倒计时),pld(选择14秒倒计时),enb(倒计时使能)setmin(数字钟调分),sethour(数字钟调时),reset(数字钟复位),k(数字钟和倒计时切换键)。2系统设计 2.1设计方案: 数字钟模块:蓝球倒计时模块:总体模块:2.2 各模块分析 2.21模块一(时钟模块)该模块主要有两个小模块组成,分别为计时模块和模块,程序如下:-计数模块-(1)24计数器library ieee;use ieee.std_logic_116
3、4.all;use ieee.std_logic_unsigned.all;entity hour is port(clk,reset:in std_logic; hour_l:out std_logic_vector(3 downto 0); hour_h:out std_logic_vector(3 downto 0);end hour;architecture abc of hour issignal count_l:std_logic_vector(3 downto 0);signal count_h:std_logic_vector(3 downto 0);begin hour_l=
4、count_l; hour_h=count_h; process(clk,reset) begin if(reset=0)then count_l=0000;count_h=0000;-复位 elsif(clkevent and clk=1)then if(count_h=0010and count_l=0011)then -满23时,个位、十位清零; count_h=0000;count_l=0000; elsif(count_l=1001)then -十位不为2,个位为9时;个位清零、十位加1 count_l=0000;count_h=count_h+1; else count_l=cou
5、nt_l+1; -其它情况下,个位加1,十位不变 end if; end if; end process;end abc;-(2)60计数器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity minute is port(clk,reset,sethour:in std_logic; -时钟信号、复位信号、时间设置信号 enhour:out std_logic; minout_l:out std_logic_vector(3 downto 0); minout_h:out std_log
6、ic_vector(3 downto 0);end minute;architecture abc of minute is signal count_l:std_logic_vector(3 downto 0); signal count_h:std_logic_vector(3 downto 0); signal enhour_1:std_logic; begin minout_l=count_l; minout_h=count_h; enhour=(enhour_1 or sethour); process(clk,reset,sethour) begin if(reset=0)then
7、 count_l=0000;count_h=0000; elsif(clkevent and clk=1)then if(count_h=0101and count_l=1001)then -满59时,个位、十位清零,给下一个模块产生进位输出 count_h=0000;count_l=0000;enhour_1=1; elsif(count_l=1001)then count_l=0000;count_h=count_h+1; -十位不为5,个位为9时;个位清零、十位加1 else count_l=count_l+1;enhour_1=0; -其它情况下,个位加1,十位不变 end if; e
8、nd if; end process;end abc;-显示模块-library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;entity ddisp is port(clk :in std_logic; a,b,c,d,e,f,g,h:in std_logic_vector(3 downto 0); com:out std_logic_vector(2 downto 0); seg:out std_logic_vector(6 downto 0);end ddisp;architecture art o
9、f ddisp issignal cnt:std_logic_vector(2 downto 0);signal bcd:std_logic_vector(3 downto 0); begin process(clk) begin if clkevent and clk=1 then if cnt=111 then cnt=000; else cnt bcd=a;com bcd=b;com bcd=c;com bcd=d;com bcd=e;com bcd=f;com bcd=g;com bcd=h;com seg seg seg seg seg seg seg seg seg seg seg
10、 seg=0000000; end case; end process;end art;由上面的各个子模组成了数字钟模块,用图形编辑实现,截图如下:2.2.2 模块二(篮球倒计时模块)该模块分为2个子模块,分别为24、14倒计时和显示模块,程序如下:-(24、14倒计时)library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;entity bsjsb is port(clr,pld,enb,clk:in std_logic; warn:out std_logic; ddout:out std_logi
11、c_vector(3 downto 0); ssout:out std_logic_vector(3 downto 0);end bsjsb;architecture art of bsjsb is begin process(clk,clr,enb) variable tmpa:std_logic_vector(3 downto 0); variable tmpb:std_logic_vector(3 downto 0); variable tmpwarn:std_logic; begin if clr=1 then tmpa:=0100; tmpb:=0010; tmpwarn:=0; e
12、lsif clkevent and clk=1 then if pld=1 then tmpb:=0001; tmpa:=0100; elsif enb=1 then if tmpa=0000 then if tmpb/=0000 then tmpa:=1001; tmpb:=tmpb-1; else tmpwarn:=1; end if; else tmpa:=tmpa-1; end if; end if; end if; ssout=tmpa; ddout=tmpb; warn=tmpwarn; end process; end art; -(显示模块)library ieee; use
13、ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all;entity disp is port(clk :in std_logic; a,b:in std_logic_vector(3 downto 0); com:out std_logic_vector(2 downto 0); seg:out std_logic_vector(6 downto 0);end disp;architecture art of disp issignal cnt:std_logic_vector(2 downto 0);signal bcd:std_l
14、ogic_vector(3 downto 0); begin process(clk) begin if clkevent and clk=1 then if cnt=001 then cnt=000; else cnt bcd=a;com bcd=b;combcd seg seg seg seg seg seg seg seg seg seg seg=0000000; end case; end process;end art;由上面的各个子模组成了倒计时模块,用图形编辑实现,截图如下:2.3 顶层文件顶层文件是用图形编辑实现的,截图如下:2.4 仿真分析2.5 芯片管脚分配2.6 下载三课程设计总结 本次设计综合了数字钟和倒计时两个模块为一个整体,通过一个切换功能模块来让用户选择使用哪个功能。由于时间紧迫,这个设计的程序编写不是很完善,如数字钟没有减时、分按键,只有加按键;在倒计时模式下,14秒倒计时开启时,报警信号不能停止,只能先从24倒计时切换到14秒倒计时时才能解决这问题,所以,程序有待改进。 通过这次课程设计,让我们对用编写一个完整的项目有了进一步的了解。加强了我们的实操能力。
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1