贵州师范大学学生实习报告
科目:EDA实习
专业: 电气工程及其自动化
班级: 10电气
姓名: 李启应
学号: 101401010202
实验项目名称:数字电子钟的设计
实验项目性质:普通试验
所属课程名称:VHDL程序设计
一、实验目的
1 学习VHDL语言的一些基本特点。
2 掌握VHDL程序的基本结构。
3掌握VHDL程序设计方法。
4 要能够用vhdl语言读懂并编写eda程序,对eda设计的总体框架能有较好的把握,掌握各模块的调用方式。
二、实验内容和要求
设计一个数字时钟,显示时(2位),分(2位),秒(2位),具体要求是:具有时分秒计数显示功能,以24小时循环计时;数码管动态显示时,分,秒;具有清零功能。
在软件工具平台上,进行VHDL语言的各模块编程输入、编译实现和仿真验证。
三、实验主要仪器设备和材料
计算机,开发环境MAX-PLUSII,ZY11EDA实验系统,VHDL语言。
四、实验方法、步骤及结果测试
1、设计思路:
数字钟的主体是计数器,它记录并显示接收到的秒脉冲个数,其中秒和分位60进制计数器,小时为24进制计数器,分别产生3位BCD码。BCD码经译码,驱动后接数码显示电路。
根据实验要求,将设计分为5个主要部分,时功能模块、分功能模块、秒功能模块、扫描仪功能模块和7段LED功能模块。在时、分、秒模块中,包括复位和预置数,其主要思路如下:
秒钟的模块:设计一个60进制的计数器,以clk为其时钟信号,每60个clk后产
生一个进位信号CF给分钟模块,作为分钟进程的响应信号。
秒钟模块VHDL程序见附录1:
仿真波形如下:
封装如下图:
分钟的模块:同理于秒钟的模块,设计一个60进制的计数器,以CFM为其时钟信号,每60个CFM后产生一个进位信号CFM给小时模块,作为小时模块进程的响应信号。分钟模块VHDL程序见附录二:
仿真波形如下:
封装如下图:
小时的模块:为24进制计数器,在分的进位信号CFM的激发下计数,从0到23的时候产生一个信号CFH,全部清0,重新开始计时。
小时模块VHDL程序见附录三:
仿真波形如下:
封装如下图:
扫描仪模块:在扫描仪内部,有一个3-8译码器的片选信号,当3-8译码器的片选信号为000时,片选信号选中7段LED模块中的秒的个位,当3-8译码器的片选信号为001时,片选信号选中7段LED模块中的秒的十位,当3-8译码器的片选信号为010时,片选信号选中7段LED模块中的分的个位,当3-8译码器的片选信号为011时,片选信号选中7段LED模块中的分的十位,当3-8译码器的片选信号为100时,片选信号选中7段LED模块中的时的个位,当3-8译码器的片选信号为101时,片选信号选中7段LED 模块中的时的十位,就这样动态扫描,当输入的时钟信号频率很高的时候,就形成了我们的时钟。
扫描仪模块VHDL程序见附录四:
仿真波形如下:
封装如下图:
7段LED模块:根据动态扫描仪的片选信号来依次点亮我们所需的时间。7段LED模块VHDL程序见附录五:
仿真波形如下:
封装如下图:
综合以上5大模块,把它们用线连接起来就得到我们的总的电路图:如下图所示:其工作原理为:扫描仪3-8译码器的片选信号根据时分秒的输入选中7段LED模块,然后再由时分秒中产生的3位BCD码来输出秒的个位,十位、时的个位,十位、小时的个位,十位。
4.总结:
在实验这两周的时间里,我们做过DC触发器、DQ触发器、3-8译码器、二选一电
路和四选一电路等,最后综合做了数字时钟电路,通过这次实习,我对用VHDL来编程
有了更深的了解,在要编程的时候,我学会了分模块进行,因为一开始的时候设计一个
时钟系统比较麻烦,没有分模块之前总是会有差错,而之后思路就会比较清晰,有明确
的方案,在对照书本里的编程规则与语句,就完成了这次的设计,总之就是获益良多。
附录1:秒钟模块VHDL程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity second is
port(clk,reset:in std_logic;
cf:out std_logic;
second1_out:out std_logic_vector(3 downto 0); second10_out:out std_logic_vector(2 downto 0));
end entity second;
architecture one of second is
signal second1n:std_logic_vector(3 downto 0);
signal second10n:std_logic_vector(2 downto 0);
begin
second1_out<=second1n;
second10_out<=second10n;
process(clk,reset)
begin
if(reset='1') then
second1n<="0000";
second10n<="000";
elsif(clk' event and clk='1') then
if(second1n="1001")then
second1n<="0000";
if(second10n="101")then
second10n<="000";
cf<='1';
else second10n<=second10n+1; end if;
else second1n<=second1n+1;
end if;
end if;
end process;
end architecture one;
附录二:分钟模块VHDL程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity minute is
port(clk,reset:in std_logic;
cf:out std_logic;
minute1_out:out std_logic_vector(3 downto 0); minute10_out:out std_logic_vector(2 downto 0));
end entity minute;
architecture one of minute is
signal minute1n:std_logic_vector(3 downto 0);
signal minute10n:std_logic_vector(2 downto 0);
begin
minute1_out<=minute1n;
minute10_out<=minute10n;
process(clk,reset)
begin
if(reset='1') then
minute1n<="0000";
minute10n<="000";
elsif(clk' event and clk='1') then
if(minute1n="1001")then
minute1n<="0000";
if(minute10n="101")then
minute10n<="000";
cf<='1';
else minute10n<=minute10n+1; end if;
else minute1n<=minute1n+1;
end if;
end if;
end process;
end architecture one;
附录三:小时模块VHDL程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity hour is
port(clk,reset:in std_logic;
hour1_out:out std_logic_vector(3 downto 0); hour10_out:out std_logic_vector(1 downto 0));
end entity hour;
architecture one of hour is
signal hour1n:std_logic_vector(3 downto 0);
signal hour10n:std_logic_vector(1 downto 0);
begin
hour1_out<=hour1n;
hour10_out<=hour10n;
process(clk,reset)
begin
if(reset='1') then
hour1n<="0000";
hour10n<="00";
elsif(clk' event and clk='1') then
if(hour1n="1001"or(hour1n="0011"and hour10n="0010"))then
hour1n<="0000";
if(hour10n="10")then
hour10n<="00";
else hour10n<=hour10n+1; end if;
else hour1n<=hour1n+1;
end if;
end if;
end process;
end architecture one;
附录四:扫描仪模块VHDL程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity saomiaoyi is
port(clk:in std_logic;
reset:in std_logic;
second1,minute1,hour1:in std_logic_vector(3 downto 0); second_10,minute_10:in std_logic_vector(2 downto 0); hour_10:in std_logic_vector(1 downto 0); dataout:out std_logic_vector(3 downto 0); sel:out std_logic_vector(2 downto 0)); end entity saomiaoyi;
architecture one of saomiaoyi is
signal count:std_logic_vector(2 downto 0);
begin
sel<=count;
process(clk,reset)
begin
if(reset='1')then
dataout<="0000";
elsif (clk'event and clk='1') then
if count>="101" then
count<="000";
else
count<=count+1;
end if;
end if;
case count is
when"000"=>dataout<=second1;
when"001"=>dataout<='0'& second_10; when"010"=>dataout<=minute1;
when"011"=>dataout<='0'& minute_10; when"100"=>dataout<=hour1;
when others =>dataout<="00"& hour_10; end case;
end process;
end architecture one;
附录五:7段LED模块VHDL程序
LIBRARY IEEE ;
USE IEEE.STD_LOGIC_1164.ALL ;
ENTITY led_7 IS
PORT ( A:IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;
LED7S:OUT STD_LOGIC_VECTOR(6 DOWNTO 0));
END entity led_7;
ARCHITECTURE one OF led_7 IS
BEGIN
PROCESS( A )
BEGIN
CASE A(3 DOWNTO 0) IS
WHEN "0000" => LED7S <= "0111111" ; -- X"3F" 0 WHEN "0001" => LED7S <= "0000110" ; -- X"06" 1 WHEN "0010" => LED7S <= "1011011" ; -- X"5B" 2
WHEN "0011" => LED7S <= "1001111" ; -- X"4F" 3 WHEN "0100" => LED7S <= "1100110" ; -- X"66" 4 WHEN "0101" => LED7S <= "1101101" ; -- X"6D" 5 WHEN "0110" => LED7S <= "1111101" ; -- X"7D" 6 WHEN "0111" => LED7S <= "0000111" ; -- X"07" 7 WHEN "1000" => LED7S <= "1111111" ; -- X"7F" 8 WHEN "1001" => LED7S <= "1101111" ; -- X"6F" 9 WHEN OTHERS => NULL ;
END CASE ;
END PROCESS ;
END ARCHITECTURE one;