Chinaunix首页 | 论坛 | 博客
  • 博客访问: 400267
  • 博文数量: 77
  • 博客积分: 798
  • 博客等级: 军士长
  • 技术积分: 1238
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-01 22:33
文章分类

全部博文(77)

文章存档

2015年(1)

2014年(7)

2013年(38)

2012年(31)

分类: IT业界

2012-04-17 16:20:09

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

use ieee.std_logic_arith.all;

entity jishu is

 port(  en,clk,reset,load:in std_logic;

        d:in std_logic_vector(7 downto 0);

        ql:buffer std_logic_vector(3 downto 0);

        qh:buffer std_logic_vector(3 downto 0);

        c0:out std_logic;

        seg:out std_logic_vector(7 downto 0));

end entity jishu;

architecture art of jishu is

 signal datain:buffer std_logic_vector(7 downto 0)   --中间变量装载预显示数据

 signal cnt:std_logic_vector(2 downto 0);

 signal sel:std_logic_vector(2 downto 0);

 signal data:std_logic_vector(3 downto 0);

 signal com:std_logic_vector(7downto 0);

  begin  

m:process(clk,reset)is  --60计数模块

 begin         

  if(qh="0101"and ql="1001"and en='1')then

    c0<='1';

    else c0<='0';end if;

  if reset='1' then

    qh<="0000";

    ql<="0000";

   elsif clk'event and clk='1'then

    if load='1' then

      qh<=d(7 downto 4);

      ql<=d(3 downto 0);

      elsif en='1'then

      if ql=9 then

       ql<="0000";

       if qh=5 then

        qh<="0000";

        else

         qh<=qh+1;

         end if;

         else

          ql<=ql+1;

          end if;end if;end if;

          datain(7 downto 4)<=qh;          --实现中间变量功能

          datain(3 downto 0)<=ql;

    end process m;

    m0:process(clk)is

    begin

    if clk'event and clk='1'then          --产生控制信号

    if cnt="010"then

    cnt<="000";

    else cnt<=cnt+1;

    end if;end if;

    end process m0;

    sel<=cnt;

    p0:process(sel,clk)is               --由控制信号控制位码

    begin

    if clk'event and clk='1'then

    case sel is

         when"000"=>com<="11111110";

         when"001"=>com<="11111101";

         when others=>com<="11111111";

     end case;end if;

     end process p0;

     p1:process(sel,clk)is           --载入显示数据

       begin

       if clk'event and clk='1'then

       case sel is

       when"000"=>data<=datain(3 downto 0);

       when"001"=>data<=datain(7 downto 4);

       when others=>null;

       end case;end if;

       end process p1;

       p2:process(data,clk)is

       begin

       if clk'event and clk='1'then       --动态显示,数码管驱动显示

       case data is

       when"0000"=>seg<="00111111";  --0

       when"0001"=>seg<="00000110"; --1

       when"0010"=>seg<="01011011";--2

       when"0011"=>seg<="01001111";--3

       when"0100"=>seg<="01100110";--4

       when"0101"=>seg<="01101101";--5

       when"0110"=>seg<="01111101";--6

       when"0111"=>seg<="00000111";--7

       when"1000"=>seg<="01111111";--8

       when"1001"=>seg<="01101111";--9    

       when others=>seg<="00000000"; --灭掉

         end case;end if;                                              

                                            为了消除不确定信号引起的毛刺,每个进程里,强制加入控制信号,使得被控制信号的不确定情况突发信号消失!

                                            在仿真时,很明显的可以看到延时特性,这也是quartusII 的功能限制。Modelism 待摸索,估计其仿真效果优于Quartus II

                                           类似,可以实现特定的数字动态显示。

 

 

                                  整理思路:

 

                    A:一个计数模块   --60进制

                    B::产生控制信号,控制位码的选择

                    C: 预载入显示数据模块,由控制信号将预显示数据载入中间变量

                    D:由中间变量的显示数据导入显示数码管中,驱动显示数据

        

                    (为减小毛刺,每个模块的加入相应的控制信号)

                

              

 

 

 

 

 

 

 

 

 

 

 

阅读(1269) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~