实验四:电子钟显示 一、 实验目的
(1)掌握较复杂的逻辑设计和调试。
(2)学习用原理图+VHDL语言设计逻辑电路。 (3)学习数字电路模块层次设计。 (4)掌握ispLEVER 软件的使用方法。 (5)掌握ISP 器件的使用。 二、实验所用器件和设备
在系统可编程逻辑器件ISP1032 一片 示波器 一台 万用表或逻辑笔 一只 TEC-5实验系统,或TDS-2B 数字电路实验系统 一台 三、 实验内容
数字显示电子钟 1、任务要求
(1)、时钟的“时”要求用两位显示;上、下午用发光管作为标志; (2)、时钟的“分”、“秒”要求各用两位显示;
(3)、整个系统要有校时部分(可以手动,也可以自动),校时时不能产生进位; (4)*、系统要有闹钟部分,声音要响5秒(可以是一声一声的响,也可以连续响)。
VHDL源代码:
LIBRARY ieee;
USE ieee.std_logic_1164.all; USE ieee.std_logic_unsigned.all;
----主体部分- ENTITY clock is
port(clk,clr,put,clk1 : in std_logic; --clr 为清零信号,put为置数脉冲,clk1 为响铃控制时钟
choice : in std_logic; --用来选择时钟状态的脉冲信号 lighthour : out std_logic_vector(10 downto 0); lightmin : out std_logic_vector(7 downto 0);
lightsec : out std_logic_vector(7 downto 0);--输出显示 ring : out std_logic); --响铃信号 end clock;
--60进制计数器模块
ARCHITECTURE func of clock is component counter_60
port(clock : in std_logic; clk_1s : in std_logic; putust : in std_logic;
clr : in std_logic;
load : in std_logic;
s1 : out std_logic_vector(3 downto 0) ;
s10 : out std_logic_vector(3 downto 0) ;
co : out std_logic) ;
end component;
--24进制计数器模块 component counter_24
port(clock : in std_logic; clk_1s : in std_logic;
putust : in std_logic;
clr : in std_logic; load : in std_logic;
s1 : out std_logic_vector(3 downto 0); s10 : out std_logic_vector(6 downto 0)); end component;
signal sec,a:std_logic; ---2 分频产生1s信号 signal l1,l2,l3:std_logic; ---判定对时间三部分修改 signal c1,c2:std_logic; ---进位信号 signal load:std_logic_vector(1 downto 0); signal temp:integer range 0 to 2499; signal temp1:integer range 0 to 95; --计数信号 signal sec_temp:std_logic_vector(7 downto 0);
--总进程 begin
u1 : counter_60 port map (sec,sec,put,clr,l1,sec_temp(3 downto 0),sec_temp(7 downto 4),c1); u2 : counter_60 port map (c1,sec,put,clr,l2,lightmin(3 downto 0),lightmin(7 downto 4),c2); u3 : counter_24 port map (c2,sec,put,clr,l3,lighthour(3 downto 0),lighthour(10 downto 4)); lightsec(7 downto 0)<=sec_temp(7 downto 0);
--状态转换
process (choice) begin
if (choice'event and choice='1') then case load is
when \非修改状态 l2<='0'; l3<='0';
load<=\
when \此状态下对小时进行修改
l2<='0' ; l3<='1' ;
load<=\
;
when \此状态下对分钟进行修改 l2<='1'; l3<='0';
load<=\
when others => l1<='1'; --此状态下对秒进行修改 l2<='0'; l3<='0';
load<=\;
end case; end if;
end process;
--计数进程 process(clk) begin
if (clk'event and clk='1') then
if (temp=2499) then temp <= 0; sec<=not sec; else
temp <= temp+1; end if; end if; end process;
--响铃进程 process(clk1)
begin
if(clk1'event and clk1='1') then
--分频
if (temp1=95) then temp1<=0; a<=not a;
else
temp1<=temp1+1; end if; end if; end process;
ring<=a when (c2='1' and sec_temp<5 and sec='1') else --5s整点响铃 '0'; end func;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter_60 is
port (clock : in std_logic; --计数信号,即低位的进位信号或时钟脉冲信号 clk_1s : in std_logic; --周期1s 的时钟信号 putust : in std_logic; --调表置数信号
clr : in std_logic; --清零
load : in std_logic; --判定信号
s1 : out std_logic_vector(3 downto 0); --计数器的个位s10 : out std_logic_vector(3 downto 0); --计数器的十位 co : out std_logic ); end counter_60;
if(load=1 ) --防止脉冲产生进位 co_ temp<=’0’;
architecture func of counter_60 is
signal s1_temp: std_logic_vector(3 downto 0); signal s10_temp : std_logic_vector(3 downto 0);
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库北邮数字逻辑课程设计实验报告(电子钟显示)在线全文阅读。
相关推荐: