EDA数字钟设计_eda数字钟设计
EDA数字钟设计由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“eda数字钟设计”。
数字钟
一、实验目的1、掌握多位计数器相连的设计方法。
2、掌握十进制,六进制,二十四进制计数器的设计方法。
3、掌握扬声器的驱动及报时的设计。
4、LED灯的花样显示。
5、掌握CPLD技术的层次化设计方法。
二、实验器材
1、主芯片Altera EPF10K10LC84-4。
2、8个LED灯。
3、扬声器。
4、4位数码显示管。
5、8个按键开关(清零,调小时,调分钟)。
三、实验内容
根据电路特点,运用层次设计概念设计。将此设计任务分成若干模块,规定每一模块的功能和各模块之间的接口。
1、时计时程序: library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;
entity hour is
port(reset,clk : in std_logic;
daout : out std_logic_vector(7 downto 0));end hour;
architecture behav of hour is
signal count : std_logic_vector(3 downto 0);signal counter : std_logic_vector(3 downto 0);begin
p1: proce(reset,clk)
begin
if reset='0' then
count
counter
elsif(clk'event and clk='1')then
if(counter
if(count=9)then
count
counter
else
count
end if;
else
if(count=3)
then
counter
else
count
count
end if;
end if;
end if;
end proce;
daout(7 downto 4)
end behav;
2、分计时程序: library ieee;
use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;
entity minute is
port(reset,clk,sethour: in std_logic;
daout : out std_logic_vector(7 downto 0);
enhour : out std_logic);end minute;
architecture behav of minute is
signal count : std_logic_vector(3 downto 0);signal counter : std_logic_vector(3 downto 0);signal carry_out1 : std_logic;signal carry_out2 : std_logic;begin
p1: proce(reset,clk)begin
if reset='0' then
count
counter
elsif(clk'event and clk='1')then
if(counter
if(count=9)then
count
counter
else
count
end if;
carry_out1
else
if(count=9)then
count
counter
carry_out1
else
count
carry_out1
end if;
end if;end if;end proce;
p2: proce(clk)begin
if(clk'event and clk='0')then
if(counter=0)then
if(count=0)then
carry_out2
end if;
else
carry_out2
end if;end if;end proce;
daout(7 downto 4)
3、秒计时程序: library ieee;
use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;
entity second is
port(reset,clk,setmin : in std_logic;
daout : out std_logic_vector(7 downto 0);
enmin : out std_logic);end second;
architecture behav of second is
signal count : std_logic_vector(3 downto 0);signal counter : std_logic_vector(3 downto 0);signal carry_out1 : std_logic;signal carry_out2 : std_logic;begin
p1: proce(reset,clk)begin
if reset='0' then
count
counter
elsif(clk'event and clk='1')then
if(counter
then
if
(count=9)
then
count
counter
else
count
end if;
carry_out1
else
if(count=9)
then
count
counter
carry_out1
else
count
carry_out1
end if;
end if;end if;end proce;daout(7 downto
4)
daout(3
downto
0)
4、alert程序: library ieee;
use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;
entity alert is port(clkspk : in std_logic;
second : in std_logic_vector(7 downto 0);
minute : in std_logic_vector(7 downto 0);
speak : out std_logic;
lamp : out std_logic_vector(8 downto 0));end alert;
architecture behav of alert is signal divclkspk2 : std_logic;begin p1: proce(clkspk)begin
if(clkspk'event and clkspk='1')then
divclkspk2
end if;end proce;p2: proce(second,minute)begin if(minute=“01011001”)then case second is
when “01010001”=>lamplamplamplamplamplamplamplamplamplamp
5、seltime程序 library ieee;
use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;
entity seltime is port(ckdsp : in std_logic;
reset : in std_logic;
second : in std_logic_vector(7 downto 0);
minute : in std_logic_vector(7 downto 0);
hour : in std_logic_vector(7 downto 0);
daout : out std_logic_vector(3 downto 0);
sel : out std_logic_vector(2 downto 0));end seltime;
architecture behav of seltime is signal sec : std_logic_vector(2 downto 0);begin
proce(reset,ckdsp)begin
if(reset='0')then sec
elsif(ckdsp'event and ckdsp='1')then
sec
sec
proce(sec,second,minute,hour)begin case sec is
when “000”=>daoutdaoutdaoutdaoutdaoutdaoutdaout
if(sec=“111”)then
sel
6、deled程序: LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;use ieee.std_logic_unsigned.all;
ENTITY deled IS PORT(S: IN STD_LOGIC_VECTOR(3 DOWNTO 0);
A,B,C,D,E,F,G,H: OUT STD_LOGIC);END deled;
ARCHITECTURE BEHAV OF deled IS
SIGNAL DATA:STD_LOGIC_VECTOR(3 DOWNTO 0);SIGNAL DOUT:STD_LOGIC_VECTOR(7 DOWNTO 0);BEGIN DATA
CASE DATA IS
WHEN “0000”=>DOUTDOUTDOUTDOUTDOUTDOUTDOUTDOUTDOUTDOUTDOUTDOUTDOUTDOUTDOUTDOUTDOUT
END PROCESS;H
G
F
E
7、顶层原理图:
四、实验结果 顶层原理图仿真波形:
五、心得体会
1、系统设计进要行充分的方案论证,不可盲目就动手去做;
2、实验中对每一个细节部分都要全面思考,要对特殊情况进行处理;
3、对于数字系统,要考虑同步、异步问题;
4、数字电路的理论分析要结合时序图;
5、遇到问题,要顺藤摸瓜,分析清楚,不可胡乱改动,每做一次改变都要有充分的理由;
6、模块化设计方法的优点在于其简洁性,但是在实验设计中也发现,在实验最终电路确定之前,要尽量减少模块重叠嵌套,因为在总的电路敲定之前,电路还不成熟,很多地方需要改进,如果在开始时就进行多层模块化,里层模块电路的修改将影响其外层的全部电路,这样就是牵一发动全身,很显然,这样将导致电 数字钟课程设计 电路设计的低效,所以在设计过程中,一定要尽量减少超过两层的模块;
7、遇到问题花了很长时间没有解决掉,要学会想他人请教,别人的不经意一点,可能就能把自己带出思维死区。