求电子钟课程设计报告

如题所述

第1个回答  2010-12-27
  EDA课程设计报告
  电子钟
  组员
  吕卫伟:200840720126
  张奎:200840830133
  侯从彬:200840830133
  万远程:200840830133
  李传迪:200840830133
  杨占胜:200840830133
  指导教师:陈卫兵

  一、电子钟的设计原理:
  电子钟主要有四个模块组成: 扫描电路、计数模块电路、BCD
  码转换电路、显示器驱动电路。
  由CP送入1HZ的时钟信号,并输入计数60的分频计秒电路。在计数至6o瞬间. 进位至计数60的分频计分分频使分频计分电路加1。而计秒电路也消除为0重新再计秒。计分电路与计时电路功能同上。计数输出的二进制数通过BCD码转换电路将其转为BCD码,再通过扫描电路选择输出的BCD码。送至显示驱动电路.再将其结果转换成相应的十进制数在七段数码显示管上显示.并通过扫描电路控制数码管的显示。最终在数码显示管上可以看到秒,分,时的显示结果
  二、设计实现
  本程序总共有十二个部分依次是产生脉冲信号、60秒计数器、60分计数器、24时计数器、毫秒计数器、秒计数器、月份判断、年月日。
  设计过程:仿真图和源程序
  (1).秒钟模块
  秒是这次电子钟设计的最底层模块.其核心是一个60进制计数器,以外来时钟信号作为其触发时钟信号,当外来信号进入clk时钟信号端,其内部的60进制计数器便开始工作,对信号源进行计数.计数结果由count输出至数码管显示秒钟时间.当计数到60时,其值置零,并向外输出一个进位信号C,这个进位信号便为下个分钟模块的输入时钟信号

  library ieee;
  use ieee.std_logic_1164.all;
  use ieee.std_logic_unsigned.all;
  entity miao is
  port(rst,clk:in std_logic;
  d:in std_logic_vector(1 downto 0);
  clk1:out std_logic);
  end miao;
  architecture do of miao is
  signal d1:std_logic_vector(1 downto 0);
  begin
  process(clk,d)
  begin
  if rst='1' then
  d1<="00";
  ELSif clk'event and clk='1'then
  if d1="11"then
  d1<=d;clk1<='1';
  else d1<=d1+1; clk1<='0';
  end if;
  end if;
  end process;
  end do;

  (2).分钟模块
  分钟模块核心也是一个60进制计数器,其功能的实现是将秒模块的进位信号进行计数,计数结果由dout输至数码管显示,当计数至60是数值置零,并向外输出进位信号c.

  library ieee;
  use ieee.std_logic_1164.all;
  use ieee.std_logic_unsigned.all;
  entity fen is
  port(zs1,clk2,rst1:in std_logic;
  d1: in std_logic_vector(5 downto 0);
  fe :out std_logic_vector(5 downto 0);
  clk3:out std_logic);

  end fen;
  architecture do of fen is
  signal d0:std_logic_vector(5 downto 0);
  begin
  process(clk2,d1,zs1,rst1)
  begin
  if rst1='1'then
  d0<="000000";
  elsif clk2'event and clk2='1'then
  if d0="111111"then
  clk3<='1';d0<="000000";
  elsif zs1='1'then
  d0<=d1;
  else d0<=d0+1;clk3<='0';
  end if;
  end if;
  end process;
  fe<=d0;
  end do;
  (3)时、星期计数模块

  library ieee;
  use ieee.std_logic_1164.all;
  use ieee.std_logic_unsigned.all;
  entity shi is
  port(clk5 :in std_logic;
  xs:out std_logic_vector(4 downto 0);
  xinqi:out std_logic_vector(2 downto 0));
  end shi;
  architecture do of shi is
  signal d3:std_logic_vector(4 downto 0);
  signal d4:std_logic_vector(2 downto 0);
  signal clk6:std_logic;
  begin
  r1:process(clk5)
  begin
  if clk5'event and clk5='1'then
  if d3="11000"then
  d3<="00000";clk6<='1';
  else d3<=d3+1;clk6<='0';
  end if;
  end if;
  end process r1;
  r2: process(clk6)
  begin
  if clk6'event and clk6='1'then
  if d4="111"then
  d4<="001";
  else d4<=d4+1;
  end if;
  end if;
  end process r2;
  xs<=d3;xinqi<=d4;
  end do;
  (4)年月日计数

  library ieee;
  use ieee.std_logic_1164.all;
  use ieee.std_logic_unsigned.all;
  entity haos is
  port(clk8,zr,zy:in std_logic;
  g2:in std_logic_vector(4 downto 0);
  g1: in std_logic_vector(3 downto 0);
  ri :out std_logic_vector(4 downto 0);
  yue: out std_logic_vector(3 downto 0));
  end haos;
  architecture do of haos is
  signal clk9:std_logic;
  signal w1:std_logic_vector(4 downto 0);
  signal w2:std_logic_vector(3 downto 0);
  begin
  r1: process(clk8,zr,g2)
  begin
  if zr='1'then
  w1<=g2;
  elsif clk8'event and clk8='1'then
  if w1="11110"then
  w1<="00001";clk9<='1';
  else w1<=w1+1;clk9<='0';
  end if;
  end if;
  end process r1;
  r2:process(clk9)
  begin
  if zy='1'then
  w2<=g1;
  elsif clk9'event and clk9='1'then
  if w2="1100"then
  w2<="0001";
  else w2<=w2+1;
  end if;
  end if;
  end process r2;
  ri<=w1;yue<=w2;
  end do;
  最后将这几个模块(GDF)连接一起就可以了.

  根据实际情况做引脚锁定,引脚表见附录。

  课程设计心得
  设计语言主要是采用VHDL语言的自顶向下的设计方法。EDA中,自顶向下的设计方法,就是在整个设计流程中各设计环节逐步求精的过程,应用VHDL运行自顶向下的设计,就是使用VHDL模型在所有综合级别上对硬件进行说明、建模和仿真测试。顶层文件采用了原理图的方法设计,使各模块之间的层次关系清晰。
  在多功能电子钟实际设计过程中,所有的模块都是通过不同进制的计数器来实现其主要功能的,各模块之间是通过进位信号连接在一起的。前一级的进位信号作为下一级的计数clk信号,通过层次关系使设计思路清晰一开始由于程序的设计考虑置位调整。没有好的思路,走了不少弯路。后来(有人)想到了在程序里设置总控制端,于是解决了问题。和同学的合作使我的程序更加优化。
  通过这次课设,也给我带来以下一些收获:
  1、 进一步熟悉maxplus II软件的使用和操作方法,以及硬件实现时的下载方法与运行方法;
  2、 对VHDL语言的自顶向下设计方法有了进一步的认识;在底层文件具备的条件下,使用原理图可以使设置更加简单。使程序清晰,增加可读性。
  3、 锻炼了我独立思考和解决问题的能力,也认识到团队合作的重要性。
  4、 熟悉了写电子设计试验报告的方法,为写毕业设计论文奠定了一定的基础。
  5、 当然本次课程设计也存在一些不足之处,月的功能没有设置好,很多扩展功能没有实现,比如说秒表,闹铃等等

  谢辞
  首先,在这里感谢学校给我们安排了这次课设,使我们有一个可以自己动手的机会,通过动手,进一步熟悉自己所学的理论知识,体会自己动手得出结果的那种感觉。
  再次,在这要感谢我们的指导老师,陈卫兵老师和实验室老师在我们的实践过程中不提自己的辛苦,耐心回答我们所问的所有问题,帮助我们解决一些程序和调试,在这表示感谢!
  感谢这次课程设计中给我帮助的同学,是你们的帮助,我才顺利的完成了课程设计任务。
  谢谢你们的帮助!

  参考文献

  [1]卢毅.赖杰. VHDL与数字电路设计. 北京:科学出版社, 2001

  [2]潘松. VHDL使用教程. 成都:电子科技出版社,2000

  [3]黄继业. EDA技术实用教程.科学出版社,2002

  [4]徐志军.CPLD/FPGA的开发与应用.北京电子工业出版社,2002

  [5]曾繁泰,侯亚宁,崔元明.可编程器件应用导论,2001本回答被提问者采纳