数字电路课程设计
院系:
专业: 电子信息工程
姓名:
学号:
完成日期:2009
数字钟设计
系统功概述
()系统实现功:
1具时分秒十进制数字显示(时00 ~ 23)
2具手动校时校分校秒功
3定时闹钟功够设定时间发出闹铃声
4进行整点报时59分50秒起隔2秒发次低音嘟信号连续5次次高音嘀信号
(二)项设计指标:
1显示部分采6LED显示器高位低位分显示时分秒
2设置调闹钟定时时间正常时间钮选择调象
3三钮分调时分秒时间
4钮作开启关闭闹铃
5外需两时钟信号系统提供脉信号时钟闹钟正常工作分1Hz1kHz脉
二系统组成系统部分设计
1系统结构描述 求:系统(顶层文件)结构描述模块(子程序)功描述
() 系统顶层文件:
1 顶层文件图:(见页)
2 模块解释:
(1)7输入量clk_1khzclk_1hzkey_sltkey_alarmsec_setmin_sethour_set:
中clk_1khz闹铃模块提供时钟处理产生嘟嘀变化闹铃声音clk_1hz计时模块提供时钟信号秒计数次key_slt选择设置象:定时正常时间key_alarm够开启关闭闹铃sec_setmin_sethour_set设置时间定时key_slt相关联键输出脉信号
(2)CNT60_A_SEC模块:
模块式clk_1hz时钟信号进行60进制计数产生分钟触发信号该模块前计数值实时BCD码格式输出该输出接两位LED数码时时显示秒状态通alarm_clk选择设置象时间定时值设置时间模式key输入脉clk输入信号加设置定时模式key脉修改定时值影响时间脉clk状态
时该模块具两输出口out_doout_di触发整点报时嘟嘀声音
(3)CNT60_A_MIN模块:
模块式CNT60_A_SEC输出信号进行60进制计数产生时位触发信号该模块前计数值实时BCD码格式输出该输出接两位LED数码时时显示分状态通alarm_clk选择设置象时间定时值设置时间模式key输入脉clk输入信号加设置定时模式key脉修改定时值影响时间脉clk状态
时该模块具三输出口out_doout_diout_alarm触发整点报时嘟嘀闹铃声音
(4)CNT24_A_HOUR模块:
模块式CNT60_A_MIN输出信号做24进制计数该模块前计数值实时BCD码格式输出该输出接两位LED数码时时显示时状态通alarm_clk选择设置象时间定时值设置时间模式key输入脉clk输入信号加设置定时模式key脉修改定时值影响时间脉clk状态
时该模块具输出口out_alarm触发整点报时闹铃声音
(5)PWM_OUT模块:
该模块PWM产生模块通EN开启关闭PWM输出模块根CLK信号二分频产生高低音组合输出三种声音状态——嘟嘀闹铃该三种声音秒分时输出触发输出PWM
(二) 系统模块VHDL程序:
(1)CNT60_A_SEC模块:
程序源代码:
library ieee
use ieeestd_logic_1164all
use ieeestd_logic_unsignedall
entity cnt60_a_sec is
port(
clkclrenb in std_logicclk:时钟输入信号clr:清零端enb:端
key in std_logic 输入键脉调整闹铃定时时间
alarm_clk in std_logic1alarm 0clk 设置模式选择:闹铃调节模式时间调节模式
qout_sl out std_logic_vector(3 downto 0) 显示输出秒低位
qout_sh out std_logic_vector(3 downto 0)显示输出秒高位
co out std_logic 进位输出触发分计数模块
out_do out std_logic整点报时中输出嘟触发信号
out_di out std_logic 整点报时中输出嘀触发信号
)
end
architecture a of cnt60_a_sec is
signal qout2_lstd_logic_vector(3 downto 0)
signal qout2_hstd_logic_vector(3 downto 0)
signal alarm_lstd_logic_vector(3 downto 0)
signal alarm_hstd_logic_vector(3 downto 0)
signal clk1clk2tclkaclkac_slt std_logic
begin
process(alarm_clk) 该端口输入脉时修改设置模式:时间调整闹铃模式切换
begin
if alarm_clk'event and alarm_clk'1' then
if ac_slt'0' then果定时模式改闹铃模式
ac_slt<'1'
else
ac_slt<'0'
end if
end if
end process
process(keyclkac_slt)根设置模式处理key脉信号
begin
if ac_slt'0' then 时间调整模式
aclk<'0'
if clk'1' and key'1' then clk1tclk<0通挖洞方式添加脉
tclk<'0'
elsif clk'0' and key'1' then clk0tclk<1产生高电添加脉
tclk<'1'
else
tclk
elsif ac_slt'1' then 闹铃调整模式
tclk
end process
process(tclkclrenb) 60进制计数位十位放两时变量中表示秒状态
begin
if clr'1' thenclearing works at the state of high voltage
qout2_l<0000
qout2_h<0000
elsif tclk'event and tclk'1' then
if enb'1' thenenable works at high voltage
if qout2_l1001 and qout2_h0101 then
qout2_l<0000a full mode is completed and a carryout is generated
qout2_h<0000
elsif qout2_l1001 then
qout2_l<0000
qout2_h
qout2_l
end if
end if
end process
process(aclkclrenb)修改闹铃定时值
begin
if clr'1' thenclearing works at the state of high voltage
alarm_l<0000
alarm_h<0000
elsif aclk'event and aclk'1' then
if enb'1' thenenable works at high voltage
if alarm_l1001 and alarm_h0101 then
alarm_l<0000a full mode is completed and a carryout is generated
alarm_h<0000
elsif alarm_l0101 then
alarm_l<0000
alarm_h
alarm_l
end if
end if
end process
process(qout2_lqout2_halarm_lalarm_halarm_clk) 产生进位显示时间闹铃定时值
begin
if qout2_l0000 and qout2_h0000 then
co<'1'
else
co<'0'
end if
if ac_slt'0' then 显示时间
qout_sl
qout_sh
end process
process(qout2_lqout2_h) 根秒状态输出嘟嘀触发信号
begin
if qout2_h0101 then
if qout2_l0000 then
out_do<'1'
elsif qout2_l0010 then
out_do<'1'
elsif qout2_l0100 then
out_do<'1'
elsif qout2_l0110 then
out_do<'1'
elsif qout2_l1000 then
out_do<'1'
else
out_do<'0'
end if
elsif qout2_h0000 then
if qout2_l0000 then
out_di<'1'
out_do<'0'
else
out_di<'0'
end if
else
out_do<'0'
out_di<'0'
end if
end process
end
(2)CNT60_A_MIN模块:
library ieee
use ieeestd_logic_1164all
use ieeestd_logic_unsignedall
entity cnt60_a_min is
port(
clkclrenb in std_logic clk:时钟输入信号clr:清零端enb:端
key in std_logic 输入键脉调整闹铃定时时间
alarm_clk in std_logic 1alarm 0clk 设置模式选择:闹铃调节模式时间调节模式
qout_ml out std_logic_vector(3 downto 0) 显示输出分低位
qout_mh out std_logic_vector(3 downto 0) 显示输出分高位
co out std_logic 进位输出触发时计数模块
out_alarmout std_logic闹铃触发信号时间输出高电触发闹铃
out_doout_di out std_logic整点报时中输出嘟嘀触发信号
)
end
architecture a of cnt60_a_min is
signal qout2_lstd_logic_vector(3 downto 0)
signal qout2_hstd_logic_vector(3 downto 0)
signal alarm_lstd_logic_vector(3 downto 0)
signal alarm_hstd_logic_vector(3 downto 0)
signal clk1clk2tclkaclkac_slt std_logic
begin
process(alarm_clk) 该端口输入脉时修改设置模式:时间调整闹铃模式切换
begin
if alarm_clk'event and alarm_clk'1' then
if ac_slt'0' then果定时模式改闹铃模式
ac_slt<'1'
else
ac_slt<'0'
end if
end if
end process
process(keyclkac_slt) 根设置模式处理key脉信号
begin
if ac_slt'0' then 时间调整模式
aclk<'0'
if clk'1' and key'1' thenclk1tclk<0通挖洞方式添加脉
tclk<'0'
elsif clk'0' and key'1' thenclk0tclk<1产生高电添加脉
tclk<'1'
else
tclk
elsif ac_slt'1' then 闹铃调整模式
tclk
end process
process(tclkclrenb) 60进制计数位十位放两时变量中表示分状态
begin
if clr'1' thenclearing works at the state of high voltage
qout2_l<0000
qout2_h<0000
elsif tclk'event and tclk'1' then
if enb'1' thenenable works at high voltage
if qout2_l1001 and qout2_h0101 then
qout2_l<0000a full mode is completed and a carryout is generated
qout2_h<0000
elsif qout2_l1001 then
qout2_l<0000
qout2_h
qout2_l
end if
end if
end process
process(aclkclrenb) 修改闹铃定时值
begin
if clr'1' thenclearing works at the state of high voltage
alarm_l<0000
alarm_h<0000
elsif aclk'event and aclk'1' then
if enb'1' thenenable works at high voltage
if alarm_l1001 and alarm_h0101 then
alarm_l<0000a full mode is completed and a carryout is generated
alarm_h<0000
elsif alarm_l0101 then
alarm_l<0000
alarm_h
alarm_l
end if
end if
end process
process(qout2_lqout2_halarm_lalarm_halarm_clk) 产生进位显示时间闹铃定时值of high voltage
begin
if qout2_l0000 and qout2_h0000 then
co<'1'
else
co<'0'
end if
if ac_slt'0' then
qout_ml
qout_mh
end process
process(qout2_lqout2_halarm_lalarm_h) –判断定时值时间值相等输出闹铃触发信号
begin
if qout2_lalarm_l and qout2_halarm_h then
out_alarm<'1'
else
out_alarm<'0'
end if
end process
process(qout2_lqout2_h) 根分状态输出嘟嘀触发信号
begin
if qout2_l1001 and qout2_h0101 then
out_do<'1'
else
out_do<'0'
end if
if qout2_l0000 and qout2_h0000 then
out_di<'1'
else
out_di<'0'
end if
end process
end
(3)CNT24_A_HOUR模块:
library ieee
use ieeestd_logic_1164all
use ieeestd_logic_unsignedall
entity cnt24_a_hour is
port(
clkclrenb in std_logic clk:时钟输入信号clr:清零端enb:端
key in std_logic 输入键脉调整闹铃定时时间
alarm_clk in std_logic1alarm 0clk设置模式选择:闹铃调节模式时间调节模式
qout_hl out std_logic_vector(3 downto 0) 显示输出时低位
qout_hh out std_logic_vector(3 downto 0) 显示输出时高位
co out std_logic 进位输出
out_alarmout std_logi闹铃触发信号输出
)
end
architecture a of cnt24_a_hour is
signal qout2_lstd_logic_vector(3 downto 0)
signal qout2_hstd_logic_vector(3 downto 0)
signal alarm_lstd_logic_vector(3 downto 0)
signal alarm_hstd_logic_vector(3 downto 0)
signal clk1clk2tclkaclkac_slt std_logic
begin
process(alarm_clk) 该端口输入脉时修改设置模式:时间调整闹铃模式切换
begin
if alarm_clk'event and alarm_clk'1' then
if ac_slt'0' then果定时模式改闹铃模式
ac_slt<'1'
else
ac_slt<'0'
end if
end if
end process
process(keyclkac_slt) 根设置模式处理key脉信号
begin
if ac_slt'0' then 时间调整模式
aclk<'0'
if clk'1' and key'1' thenclk1tclk<0通挖洞方式添加脉
tclk<'0'
elsif clk'0' and key'1' thenclk0tclk<1产生高电添加脉
tclk<'1'
else
tclk
elsif ac_slt'1' then 闹铃调整模式
tclk
end process
process(tclkclrenb) 24进制计数位十位放两时变量中表示时状态
begin
if clr'1' thenclearing works at the state of high voltage
qout2_l<0000
qout2_h<0000
elsif tclk'event and tclk'1' then
if enb'1' thenenable works at high voltage
if qout2_l1001 then
qout2_l<0000a full mode is completed and a carryout is generated
qout2_h
qout2_l<0000
qout2_h<0000
else
qout2_l
end if
end if
end process
process(aclkclrenb) 修改闹铃定时值
begin
if clr'1' thenclearing works at the state of high voltage
alarm_l<0000
alarm_h<0000
elsif aclk'event and aclk'1' then
if enb'1' thenenable works at high voltage
if alarm_l1001 then
alarm_l<0000a full mode is completed and a carryout is generated
alarm_h
alarm_l<0000
alarm_h<0000
else
alarm_l
end if
end if
end process
process(qout2_lqout2_halarm_lalarm_halarm_clk) 产生进位显示时间闹铃定时值of high voltage
begin
if qout2_l0000 and qout2_h0000 then
co<'1'
else
co<'0'
end if
if ac_slt'0' then
qout_hl
qout_hh
end process
process(qout2_lqout2_halarm_lalarm_h)定时值时间值相等输出闹钟触发信号
begin
if qout2_lalarm_l and qout2_halarm_h then
out_alarm<'1'
else
out_alarm<'0'
end if
end process
end
2系统模块仿真波形
(1)系统仿真波形:
注:面模块仿真存毛刺导致系统仿真图定问题
(2)CNT60_A_SEC模块:
注:5052545658处嘟触发输出00处嘀触发输出等
(3)CNT60_A_MIN模块:
注:图展示键调节时间值定时值仿真波形(部分仿真图)
注:该模块仿真波形图具嘟嘀声音触发输出定时时间相等时闹铃触发输出等
(4)CNT24_A_HOUR模块
注:该模块仿真图包含键调整时间定时值闹钟触发输出等
(5)PWM_OUT模块(分三段剪切展示三种声音效果)
(1)嘟嘀输出波形(en脉开PWMO效)
注:开输出两路嘟嘀触发输入时效时分输出嘟嘀声音两路闹铃触发时效时开始闹铃声音输出
注:闹铃输出变化情况(嘀嘟交发声)
注:闹铃输出变化情况
3载时选择开发系统模式脚定义
表1 GW48CK开发系统工作模式:3
接口
名称
类型
(输入输出)
结构图
信号名
引脚号
说明
clk_1hz
输入
CLOCK0
2
时钟计数脉
clk_1khz
输入
CLOCK5
83
三种声音脉信号源
pwm_out
输入
SPEAKER
3
连接蜂鸣器发出声音
key_slt
输入
PIO7
16
切换定时调整模式时间调整模式
key_alarm
输入
PIO6
11
开启关断声音产生
hour_set
输入
PIO3
8
修改定时时间时数值
min_set
输入
PIO2
7
修改定时时间分钟数值
sec_set
输入
PIO1
6
修改定时时间秒数值
hour_h[30]
输出
PIO39PIO36
6561
时高位输出
hour_l[30]
输出
PIO35PIO32
605854
时低位输出
min_h[30]
输出
PIO31PIO28
5350
分钟高位输出
min_l[30]
输出
PIO27PIO24
494739
分钟低位输出
sec_h[30]
输出
PIO23PIO20
3835
秒高位输出
sec_l[30]
输出
PIO19PIO16
3027
秒低位输出
三课程设计程中遇问题解决方法
调整时间调整定时面遇非常困难开始想象样进程中加入时钟信号没够键脉直接时钟脉进行累加时VHDL语法熟悉花费量时间
解决方法通进程先两信号进行处理分产生aclktclk分定时调整部分时间调整部分提供时钟信号调整键脉信号正常时钟信号简单运算处理
1)果调整时间:
1 时钟信号高电键信号高电时tclk赋值0
2 时钟信号高电键信号低电时tclk赋值1
3 时钟信号低电键信号高电时tclk赋值1
4 时钟信号低电键信号低电tclk赋值0
样键脉高电低电者高低电两种状态出现终结果会产生脉信号导致计数值变化达修改时间目期间aclk始终变
2)果调整定时:
1时钟输入信号赋值tclk
2键输入信号赋值aclk
样键脉结束时定时调整信号会出现脉时钟信号受影响
外闹铃产生遇问题通产生周期较长信号切换输出值容嘟嘀效果嘟嘀声音交发出
仿真时数模块会出现毛刺会导致总仿真结果乐观会脉干扰加方面试图调久没解决实际载相较正常仿真中毛刺没消掉
8路彩灯控制系统
系统功概述
()系统实现功:
1彩灯左右次点亮
2彩灯左右次熄灭
3彩灯右左次点亮
4彩灯右左次熄灭
5彩灯全亮
6彩灯全灭
(二)项设计指标:
1显示部分采8彩灯
2需时钟信号系统提供脉信号1Hz脉
二系统组成系统部分设计
1系统VHDL设计
library ieee
use ieeestd_logic_1164all
use ieeestd_logic_unsignedall
entity colorlight66 is
port(clkin std_logic
q out std_logic_vector(7 downto 0)
s out std_logic_vector(1 downto 0))
end
architecture one of colorlight66 is
signal cnt4std_logic_vector(1 downto 0)
begin
process(clk)
variable cntinteger range 0 to 34
begin
if rising_edge(clk)then
if cnt34 then
cnt0cnt4
cntcnt+1
end if
case cnt is
when 0 >q<00000000
when 1 >q<10000000
when 2 >q<11000000
when 3 >q<11100000
when 4 >q<11110000
when 5 >q<11111000
when 6 >q<11111100
when 7 >q<11111110
when 8 >q<11111111
when 9 >q<01111111
when 10>q<00111111
when 11>q<00011111
when 12>q<00001111
when 13>q<00000111
when 14>q<00000011
when 15>q<00000001
when 16>q<00000000
when 17>q<00000001
when 18>q<00000011
when 19>q<00000111
when 20>q<00001111
when 21>q<00011111
when 22>q<00111111
when 23>q<01111111
when 24>q<11111111
when 25>q<11111110
when 26>q<11111100
when 27>q<11111000
when 28>q<11110000
when 29>q<11100000
when 30>q<11000000
when 31>q<10000000
when 32>q<00000000
when 33>q<11111111
when 34>q<00000000
when others>null
end case
end if
end process
s
2 系统仿真波形
3载时选择开发系统模式脚定义
表1 GW48CK开发系统工作模式:3
接口
名称
类型
(输入输出)
引脚号
说明
clk_1hz
输入
2
彩灯驱动脉
q0
输出
54
彩灯1
q1
输出
58
彩灯2
q2
输出
59
彩灯3
q3
输出
60
彩灯4
q4
输出
61
彩灯5
q5
输出
62
彩灯6
q6
输出
64
彩灯7
q7
输出
65
彩灯8
S0
输出
80
S1
输出
81
三课程设计程中遇问题解决方法
实验较简单设计程中没遇什问题
四课程建议
种实验方式挺够提高学学理应实践力希够时开放喜欢学种编程更机会实现想法
时感觉仅仅通实验够发挥出方面潜希提供建议够机会做项目什
tgKQcWA3PtGZ7R4I30kA1DkaGhn3XtKknBYCUDxqA7FHYi2CHhI92tgKQcWA3PtGshLs50cLmTWN60eo8Wgqv7XAv2OHUm32WGeaUwYDIAWGMeR4I30kA1DkaGhn3XtKknBYCUDxqA7FHYi2CHhI92tgKQcWA3PtGZ7R4I30kA1DkaGtgKQcWA3PtGZ7R4I30kA1DkaGhn3XtKknBYCUDxqA7FHYi2CHhI92tgKQcWA3PtGshLs50cLmTWN60eo8Wgqv7XAv2OHUm32WGeaUwYDIAWGMeR4I30kA1DkaGhn3XtKknBYCUDxqA7FHYi2CHhI92tgKQcWA3PtGZ7R4I30kA1DkaGtgKQcWA3PtGZ7R4I30kA1DkaGhn3XtKknBYCUDxqA7FHYi2CHhI92tgKQcWA3PtGshLs50cLmTWN60eo8Wgqv7XAv2OHUm32WGeaUwYDIAWGeR4I30kA1DkaGhn3XtKknBYCUDxqA7FHYi2CHhI92tgKQcWA3PtGZ7R4I30kA1DkaGtgKQcWA3PtGZ7R4I30kA1DkaGhn3XtKknBYCUDxqA7FHYi2CHhI92tgKQcWA3PtGshLs50cLmTWN60eo8Wgqv7XAv2OHUm32WGeaUwYDIAWGMeR4I30kA1DkaGhn3XtKknBYCUDxqA7FHYi2CHhI92tgKQcWA3PtGZ7R4I30kA1DkaGtgKQcWA3PtGZ7R4I30kA1DkaGhn3XtKknBYCUDxqA7FHYi2CHhI92tgKQcWA3PtGshLs50cLmTWN60eo8Wgqv7XAv2OHUm32WGeaUwYDIAWGMeR4I30kA1DkaGhn3XtKknBYCUDxqA7FHYi2CHhI92tgKQcWA3PtGZ7R4I30kA1DkaGtgKQcWA3PtGZ7R4I30kA1DkaGhn3XtKknBYCUDxqA7FHYi2CHhI92tgKQcWA3PtGshLs50cLmTWN60eo8Wgqv7XAv2OHUm32WGeaUwYDIAWGMeR4I30kA1DkaGhn3XtKknBYCUDxqA7FHYi2CHhI92tgKQcWA3PtGZ7R4I30kA1DkaG
文档香网(httpswwwxiangdangnet)户传
《香当网》用户分享的内容,不代表《香当网》观点或立场,请自行判断内容的真实性和可靠性!
该内容是文档的文本内容,更好的格式请下载文档