1、电子时钟实验报告目录前言一、题目二、实验目的三、任务要求四、实验步骤五、统设计方案六、模块VHDL源程序设计.七、引脚锁定与下载验证八、问题分析附录:设计人员前言EDA技术就是以计算机为工具,设计者在EDA软件平台上,用硬件描述语言HDL完成设计文件,然后由计算机自动地完成逻辑编译、化简、分割、综合、优化、布局、布线和仿真,直至对于特定目标芯片的适配编译、逻辑映射和编程下载等工作。EDA技术的出现,极大地提高了电路设计的效率和可操作性,减轻了设计者的劳动强度。电子时钟的设计过程就是一个充分利用EDA软件的过程,利用VHDL语言对硬件进行描述,充分利用软件的逻辑综合与仿真的功能完成对电子时钟的设
2、计,然后将程序写入实验箱,实现其电子时钟的各种功能。一、 题目 设计多功能数字时钟二、 实验目的通过Max+plus2软件和实验箱实现电子时钟功能,熟练掌握用Max+plus2实现电子时钟的操作步骤并解决在运行过程中的问题。三、 任务要求 1时、分、秒计数功能,且以24小时循环计时。2.计时结果要用6个数码管分别显示时、分、秒的十位和个位。3.具有清零的功能。4.调整数码显示器,使其符合设计要求。5.参照程序,改善显示效果。四、实验步骤1.打开Max+plus2软件 2.打开file-open,在 open对话框的Text Editor files选择后缀为*.vhd文件格式 3.选择file
3、s为VOTE7.vhd的文件,单击ok,出现源程序文本 4.单击file-project-set project to,单击Assign-Device选择驱动,在弹出的Device窗口下选择Device为EPF1OK1OLC84-4,单击ok 5单击Assign-pin/location/chip进行引脚锁定。例如,输入从men0到men6,对应的input pin为28-30、35-38,在Node name中输入pass,对应输出pin为Vote7,output pin为23,在Node name中输入stop chip name为vote7,output pin为65,单击ok 6.单击
4、菜单下的compiler选项,在出现的窗口下单击start完成综合,单击确定,关闭窗口 7.单击菜单下的programmer选项,若未出现Hardware setup窗口,则打开options菜单下的Hardware setup选项,在弹出的窗口下,选择Hardware type为Byteblaster(MV)选项,单击ok,然后再单击configure,完成进程 8.使用仪器测试电子时钟功能,调整时钟脉冲,降低计时频率。 五、设计方案 根据系统设计要求,系统设计采用自顶向下的设计方法,由10进制计数器(count10), 6进制计数器(count6), 24进制计数器(count24),8位
5、数码扫描显示电路( scan_led)模块组成。点子时钟的小时部分是24进制,时与分之间各位和十位分别是6进制和十进制,此处则需要以上模块完成。动态扫描控制模块,在SEL模块输出控制下轮流点亮8数码管来显示相对应的数据。六、模块VHDL源程序设计1. 顶层设计文件(,设计的电子时钟可以显示时,分,秒,还可以进行时间的设置和调节。顶层文件VHDL源程序如下:library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity clock_top1 i
6、sPort ( clk : in std_logic; -1Hz clk1:in std_logic; -512Hz reset : in std_logic; -复位信号 dins : in std_logic_vector(6 downto 0); -秒钟预设 dinm : in std_logic_vector(6 downto 0); -分钟预设 dinh : in std_logic_vector(5 downto 0); -时钟预设 sg: out std_logic_vector(6 downto 0); -段控制信号输出 bt: out std_logic_vector(7 d
7、ownto 0);- wei ma -位控制信号输出end clock_top1;architecture Behavioral of clock_top1 iscomponent count10 is -十进制计数器Port ( clk : in std_logic; reset : in std_logic; din : in std_logic_vector(3 downto 0); dout : out std_logic_vector(3 downto 0); c:out std_logic);end component;component count6 is -6进制计数器Port
8、 ( clk : in std_logic;reset : in std_logic;din : in std_logic_vector(2 downto 0);dout : out std_logic_vector(2 downto 0);c:out std_logic);end component;component count24 is -24进制计数器 Port ( clk : in std_logic; reset : in std_logic; din : in std_logic_vector(5 downto 0); dout : out std_logic_vector(5
9、downto 0);end component;component scan_led is -动态扫描控制模块Port (clk : in std_logic; count: in std_logic_vector(19 downto 0); sg :out std_logic_vector(6 downto 0); bt:out std_logic_vector(7 downto 0) );end component;signal n:std_logic_vector(24 downto 0);signal m:std_logic;signal c1,c2,c3,c4:std_logic;s
10、ignal doutsl,doutml:std_logic_vector(3 downto 0);signal doutsh,doutmh:std_logic_vector(2 downto 0);signal douth:std_logic_vector(5 downto 0);signal rdoutsh,rdoutmh:std_logic_vector(3 downto 0); signal rdouth:std_logic_vector(7 downto 0);signal counter:std_logic_vector(19 downto 0);BeginProcess(clk,r
11、eset) Begin If reset=0 then n0); Elsif(clkevent and clk=1)then n=n+1; End if;End process;m=n(24);rdoutsh = 0&doutsh; -将秒钟高位数据变为4位,在进行译码rdoutmh = 0&doutmh; -将分钟高位数据变为4位,在进行译码rdouth clk,reset=reset,din=dins(3 downto 0),dout=counter(3 downnto 0),c=c1);u2:count6 port map(clk=c1,reset=reset,din=dins(6 do
12、wnto 4),dout=counter(6 downnto 4),c=c2);u3:count10 port map(clk=c2,reset=reset,din=dinm(3downto 0),dout=counter(10 downnto 7),c=c3);u4:count6 port map(clk=c3,reset=reset,din=dinm(6 downto 4),dout=counter(13 downnto 11),c=c4);u5:count24 port map(clk=c4,reset=reset,din=dinh(5 downto 0), dout=counter(1
13、9 downto 14);u6:scan_led port map(clk=clk1,count=counter,sg=sg,bt=bt);end Behavioral;顶层文件RTL视图右接下图右接下图顶层文件仿真波形图2.十进制计数器VHDL源程序library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity count10 is Port ( clk : in std_logic; reset : in std_logic; din :
14、 in std_logic_vector(3 downto 0); dout : out std_logic_vector(3 downto 0); c:out std_logic); end count10;architecture Behavioral of count10 issignal count : std_logic_vector(3 downto 0);begindout = count;process(clk,reset,din)begin if reset=0then count = din ; c=0; elsif rising_edge(clk) then if cou
15、nt = 1001 then count = 0000; c=1; else count = count+1; c=0; end if; end if;end process;end Behavioral;功能:十进制可预置计数器模块。时钟由时、分、秒组成,分、秒都为60进制。由于需要使用LED显示时间,所以采用的计数器应该是十进制的,从而方便译码模块的通用。而60进制计数器可以由十进制计数器和6进制计数器组成。该程序正好表示了秒和分的个位。仿真波形图模块图3.六进制计数器VHDL源程序library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.ST
16、D_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity count6 is Port ( clk : in std_logic; reset : in std_logic; din : in std_logic_vector(2 downto 0); dout : out std_logic_vector(2 downto 0); c:out std_logic); end count6;architecture Behavioral of count6 is signal count : std_logic_vector(2 do
17、wnto 0); begin dout = count; process(clk,reset,din) begin if reset= 0 then count = din; c=0; elsif rising_edge(clk) then if count=101 then count=000; c=1; else count=count+1; c=0; end if; end if; end process;end Behavioral;功能:六进制可预置计数器模块。要组成一个可预置六十进制的计数器,还需要一个六进制计数器,使用十进制的进位作为六进制的计数器的时钟可以组成一个六十进制的计数
18、器.仿真波形图模块图4.二十四进制计数器VHDL源程序library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity count24 is Port ( clk : in std_logic; reset : in std_logic; din : in std_logic_vector(5 downto 0); dout : out std_logic_vector(5 downto 0); end count24;architec
19、ture Behavioral of count24 is signal count : std_logic_vector(5 downto 0); begin dout = count;process(clk,reset,din) begin if reset= 0 then count = din; elsif rising_edge(clk) then if count(3 downto 0)=1001 then count(3 downto 0)=0000; count(5 downto 4)=count(5 downto 4) +1; else count(3 downto 0)=c
20、ount(3 downto 0)+1; end if; if count=100011 then count BT = 00000001 ; A BT = 00000010 ; A BT = 00000100 ; A BT = 00001000 ; A BT = 00010000 ; A BT = 00100000 ; A BT = 01000000 ; A BT = 10000000 ; A NULL ; END CASE ; END PROCESS p1; p2:PROCESS(clk) BEGIN IF clkevent AND CLK =1 THEN CNT8 SG SG SG SG
21、SG SG SG SG SG SG SG NULL ; END CASE ; END PROCESS P3; END; 功能:实验原理:下图所示的是8位数码扫描显示电路,其中每个数码管的8个段:h、g、f、e、d、c、b、a(h是小数点)都分别连在一起,8个数码管分别由8个选通信号k1、k2、k8来选择。被选通的数码管显示数据,其余关闭。如在某一时刻,k3为高电平,其余选通信号为低电平,这时仅k3对应的数码管显示来自段信号端的数据,而其它7个数码管呈现关闭状态。根据这种电路状况,如果希望在8个数码管显示希望的数据,就必须使得8个选通信号k1、k2、k8分别被单独选通,并在此同时,在段信号输入口
22、加上希望在该对应数码管上显示的数据,于是随着选通信号的扫变,就能实现扫描显示的目的。 仿真波形图模块图七、引脚锁定与下载验证实验所用的设备如下:引脚锁定: 时钟信号clock由cp1 1Hz控制,时钟信号clock1由cp2 256Hz控制.复位reset信号由K1键控制,小时的初始信号值由K2K7控制,分钟的初始信号值由K8K14控制,秒的初始信号值dins0,dins1分别由K15,K16控制,dins2dins6由L3L6控制.输出由动态数码显示管显示.显示结果如下:八、问题分析 在运行程序时,发现秒、分、小时的显示位不同,那么需要参照程序调整个个显示位,调试是一个复杂的过程,在调试的过程中要注意程序的结构化,完整化和顺序性,不仅要做到在短时间内调整程序,还要保证调试的简单性和简洁操作性。通过调试,那么我们成功实现了电子时钟的计时功能,保证了实验的成功,这里也要感谢老师的指导!
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1