湖南科技大学信息与电气工程学院课程设计任务书20 —20 学年第学期专业:学号:姓名:课程设计名称:设计题目:完成期限:自年月日至年月日共周设计依据、要求及主要内容(可另加附页):指导教师(签字):批准日期:年月日目录一、摘要二、VHDL语言介绍三、设计的目的四、设计内容五、电路工作原理六、主要程序及仿真结果七、对本次设计的体会和建议八、参考文献一、摘要人类社会已进入到高度发达的信息化社会。
信息化社会的发展离不开电子信息产品开发技术、产品品质的提高和进步。
电子信息产品随着科学技术的进步,其电子器件和设计方法更新换代的速度日新月异。
实现这种进步的主要原因就是电子设计技术和电子制造技术的发展,其核心就是电子设计自动化(EDA,Electronics Design Automation)技术,EDA技术的发展和推广应用又极大地推动了电子信息产业的发展。
为保证电子系统设计的速度和质量,适应“第一时间推出产品”的设计要求,EDA技术正逐渐成为不可缺少的一项先进技术和重要工具。
目前,在国内电子技术教学和产业界的技术推广中已形成“EDA热”,完全可以说,掌握EDA技术是电子信息类专业学生、工程技术人员所必备的基本能力和技能。
EDA技术在电子系统设计领域越来越普及,本设计主要利用VHDL语言设计一个电子数字钟,它的计时周期为24小时,显示满刻度为24时59分59秒。
总的程序由几个各具不同功能的单元模块程序拼接而成,其中包括分频程序模块、时分秒计数和设置程序模块、比较器程序模块、三输入数据选择器程序模块、译码显示程序模块和拼接程序模块。
并且使用软件进行电路波形仿真。
关键词:数字钟EDA VHDL语言二、VHDL语言介绍1987年底,VHDL被IEEE和美国国防部确认为标准硬件描述语言。
自IEEE公布了VHDL的标准版本,IEEE-1076(简称87版)之后,各EDA公司相继推出了自己的VHDL 设计环境,或宣布自己的设计工具可以和VHDL接口。
此后VHDL在电子设计领域得到了广泛的接受,并逐步取代了原有的非标准的硬件描述语言。
1993年,IEEE对VHDL进行了修订,从更高的抽象层次和系统描述能力上扩展VHDL的内容,公布了新版本的VHDL,即IEEE标准的1076-1993版本,(简称93版)。
现在,VHDL和Verilog作为IEEE的工业标准硬件描述语言,又得到众多EDA公司的支持,在电子工程领域,已成为事实上的通用硬件描述语言。
有专家认为,在新的世纪中,VHDL于Verilog语言将承担起大部分的数字系统设计任务。
VHDL主要用于描述数字系统的结构,行为,功能和接口。
除了含有许多具有硬件特征的语句外,VHDL的语言形式和描述风格与句法是十分类似于一般的计算机高级语言。
VHDL的程序结构特点是将一项工程设计,或称设计实体(可以是一个元件,一个电路模块或一个系统)分成外部(或称可是部分,及端口)和内部(或称不可视部分),既涉及实体的内部功能和算法完成部分。
在对一个设计实体定义了外部界面后,一旦其内部开发完成后,其他的设计就可以直接调用这个实体。
这种将设计实体分成内外部分的概念是VHDL系统设计的基本点。
三、设计的目的本项实验通过六十进制计数器和数字钟的设计与仿真,学习VHDL语言及VHDL文本输入设计方法,编写六十进制计数器和数字钟源程序,应用VMAX+plusII软件进HDL文本输入设计与波形仿真。
熟练地运用数字系统的设计方法进行数字系统设计,能进行较复杂的数字系统设计,按要求设计一个数字钟。
四、设计内容1、60进制计数器计数器60进制计数器计数器是一个用以实现计数功能的时序部件,它不仅可用来及脉冲数,还常用作数子系统的定时、分频和执行数字运算以及其它特定的逻辑功能。
计数器种类很多。
按构成计数器中的各触发器是否使用一个时钟脉冲源来分,有同步计数器和异步计数器。
2、数字钟显示秒、分、时,可清零、可调时,具有整点报时功能五、电路工作原理1、六十进制计数器“秒计数器”采用60进制计数器,每累计60秒发出一个“分脉冲”信号,该信号将作为“分计数器”的时钟脉冲。
“分计数器”也采用60进制计数器,每累计60分钟,发出一个“时脉冲”信号,该信号将被送到“时计数器”。
2、数字钟由石英晶体振荡器、分频器、计数器、译码器显示器和校时电路组成。
振荡器产生稳定的高频脉冲信号,作为数字钟的时间基准,然后经过分频器输出标准秒脉冲。
秒计数器满60后向分计数器进位,分计数器满60后向小时计数器进位,小时计数器按照“24翻1”规律计数。
计数器的输出分别经译码器送显示器显示。
计时出现误差时,可以用校时电路校时、校分。
六、主要程序及仿真结果1、六十进制计数器LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY bcd60count ISPORT(clk,bcd1wr,bcd10wr,cin:IN STD_LOGIC;co:OUT STD_LOGIC;datain:IN STD_LOGIC_VECTOR(3 DOWNTO 0);bcd1:OUT STD_LOGIC_VECTOR(3 DOWNTO 0);bcdSHI:OUT STD_LOGIC_VECTOR(2 DOWNTO 0));END ENTITY bcd60count;ARCHITECTURE rtl OF bcd60count ISSIGNAL bcd1n:STD_LOGIC_VECTOR(3 DOWNTO 0);SIGNAL bcd10n:STD_LOGIC_VECTOR(2 DOWNTO 0);BEGINbcd1<=bcd1n;bcdSHI<=bcd10n;PROCESS(clk,bcd1wr)ISBEGINIF(bcd1wr ='1')THENbcd1n<=datain;ELSIF(clk 'EVENT AND clk='1')THENIF(cin='1')THENIF(bcd1n=9)THENbcd1n<="0000";ELSEbcd1n<=bcd1n+1;END IF;END IF;END IF;END PROCESS;PROCESS(clk,bcd10wr)ISBEGINIF(bcd10wr='1')THENbcd10n<=datain(2 DOWNTO 0);ELSIF(clk'EVENT AND clk='1')THENIF(cin='1'AND bcd1n=9)THENIF(bcd10n=5)THENbcd10n<="000";ELSEbcd10n<=bcd10n+1;END IF;END IF;END IF;END PROCESS;PROCESS(bcd10n,bcd1n,cin)ISBEGINIF(cin='1'AND bcd1n=9 AND bcd10n=5)THEN co<='1';ELSEco<='0';END IF;END PROCESS;END ARCHITECTURE rtl;2、仿真结果3、数字钟use ieee.std_logic_1164.all;--顶层实体,用的是20Mhz的时钟use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity clock_shu isport(clk : in std_logic;reset : in std_logic;duan : out std_logic_vector(5 downto 0);data_o : out std_logic_vector(7 downto 0));end;architecture a of clock_shu iscomponent count60port(carry : std_logic;rst : std_logic;times : out integer range 0 to 59;full : out std_logic);end component;component count24port(carry : in std_logic;rst : in std_logic;times : out integer range 0 to 23--full : out std_logic);end component;component i60bcdport(interg : in integer range 0 to 59;ten : out std_logic_vector(7 downto 0);one : out std_logic_vector(7 downto 0));end component;component i24bcdport(interg : in integer range 0 to 23;ten : out std_logic_vector(7 downto 0);one : out std_logic_vector(7 downto 0));end component;signal carry1,carry2 : std_logic;signal abin1,abin2 : integer range 0 to 59;signal abin3 : integer range 0 to 23;signal clk_1h : std_logic;signal sh,sl,mh,ml,hh,hl : std_logic_vector(7 downto 0); signal cnt : integer range 0 to 5 :=0; beginprocess(clk)--分频为1hzconstant counter_len:integer:=19999999;variable cnt:integer range 0 to counter_len;beginif clk'event and clk='1' thenif cnt=counter_len thencnt:=0;elsecnt:=cnt+1;end if;case cnt iswhen 0 to counter_len/2=>clk_1h<='0';when others =>clk_1h<='1';end case;end if;end process;process(clk)variable cnt1 : integer range 0 to 200;variable cnt2 : integer range 0 to 10;beginif clk'event and clk='1' thenif cnt1=200 thencnt1:=0;if cnt2=10 thencnt2:=0;if(cnt=5)thencnt<=0;elsecnt<=cnt+1;end if;elsecnt2:=cnt2+1;end if;elsecnt1:=cnt1+1;end if;end if;end process;process(clk)beginif clk='1' thencase cnt iswhen 0 => duan<="000001";data_o<=sl;when 1 => duan<="000010";data_o<=sh;when 2 => duan<="000100";data_o<=ml;when 3 => duan<="001000";data_o<=mh;when 4 => duan<="010000";data_o<=hl;when 5 => duan<="100000";data_o<=hh;when others=>duan<="000000";end case;end if;end process;u1 : count60 port map(carry=>clk_1h,rst=>reset,times=>abin1,full=>carry1); u2 : count60 port map(carry=>carry1,rst=>reset,times=>abin2,full=>carry2); u3 : count24 port map(carry=>carry2,rst=>reset,times=>abin3);u4 : i60bcd port map(interg=>abin1,ten=>sh,one=>sl);u5 : i60bcd port map(interg=>abin2,ten=>mh,one=>ml);u6 : i24bcd port map(interg=>abin3,ten=>hh,one=>hl);end;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity count60 is--分,秒计数器port(carry : std_logic;rst : std_logic;times : out integer range 0 to 59;full : out std_logic);end;architecture a of count60 issignal time_s : integer range 0 to 59;beginprocess(rst,carry)beginif rst='1' thentime_s<=0;full<='0';elsif rising_edge(carry) thenif time_s=59 thentime_s<=0;full<='1';elsetime_s<=time_s+1;full<='0';end if;end if;end process;times<=time_s;end; library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity count24 is--时计数器port(carry : in std_logic;rst : in std_logic;times : out integer range 0 to 23--full : out std_logic);end;architecture a of count24 issignal time_s : integer range 0 to 23;beginprocess(rst,carry)beginif rst='1' thentime_s<=0;--full<='0';elsif rising_edge(carry) thenif time_s=23 thentime_s<=0;--full<='1';elsetime_s<=time_s+1;--full<='1';end if;end if;end process;times<=time_s;end; library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity i60bcd is--分,秒显示port(interg : in integer range 0 to 59;ten : out std_logic_vector(7 downto 0);one : out std_logic_vector(7 downto 0));end;architecture a of i60bcd isbeginprocess(interg)begincase interg iswhen 0|10|20|30|40|50 => one<="11000000";when 1|11|21|31|41|51 => one<="11111001";when 2|12|22|32|42|52 => one<="10100100";when 3|13|23|33|43|53 => one<="10110000";when 4|14|24|34|44|54 => one<="10011001";when 5|15|25|35|45|55 => one<="10010010";when 6|16|26|36|46|56 => one<="10000011";when 7|17|27|37|47|57 => one<="11111000";when 8|18|28|38|48|58 => one<="10000000";when 9|19|29|39|49|59 => one<="10011000";when others => one<=null;end case;case interg iswhen 0|1|2|3|4|5|6|7|8|9 => ten<="11000000"; when 10|11|12|13|14|15|16|17|18|19 => ten<="11111001"; when 20|21|22|23|24|25|26|27|28|29 => ten<="10100100"; when 30|31|32|33|34|35|36|37|38|39 => ten<="10110000"; when 40|41|42|43|44|45|46|47|48|49 => ten<="10011001"; when 50|51|52|53|54|55|56|57|58|59 => ten<="10010010"; when others => ten<=null;end case;end process;end;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity i24bcd is--时显示port(interg : in integer range 0 to 23;ten : out std_logic_vector(7 downto 0);one : out std_logic_vector(7 downto 0));end;architecture a of i24bcd isbeginprocess(interg)begincase interg iswhen 0|10|20 => one<="11000000";when 1|11|21 => one<="11111001";when 2|12|22 => one<="10100100";when 3|13|23 => one<="10110000";when 4|14 => one<="10011001";when 5|15 => one<="10010010";when 6|16 => one<="10000011";when 7|17 => one<="11111000";when 8|18 => one<="10000000";when 9|19 => one<="10011000";when others => one<=null;end case;case interg iswhen 0|1|2|3|4|5|6|7|8|9 => ten<="11000000"; when 10|11|12|13|14|15|16|17|18|19 => ten<="11111001"; when 20|21|22|23 => ten<="10100100"; when others => ten<=null;end case;end process;end;4、仿真结果七、对本次设计的体会与建议本设计原理简单,结构清晰,较为容易仿真成功。