如何制作VHDL 7段6位阵列

时间:2018-11-05 02:47:22

标签: vhdl

我是一个开始学习vhdl的初学者。 我做了一个7seg 6位数组。 代码已编译。但是没有用。 我试图找出问题所在,但找不到。 第一步是计数。第二是显示。 我想知道第二个代码是否有问题。 非常感谢您的建议。

enter code here 
library ieee;
use ieee.std_logic_1164.all;


use ieee.numeric_std.all;
entity display is
port(
   display_dco           : in  std_logic;
    r                     : in std_logic;   
    seg_gamma            : out std_logic_vector(6 downto 0);    
    r6 : out std_logic;
    r5 : out std_logic;
    r4 : out std_logic;
    r3 : out std_logic;
    r2 : out std_logic;
    r1 : out std_logic;



    );
    end display;

    architecture step11_1_final_main of display is

    signal seg_counts : integer range 0 to 150000000; 
    signal seg_counttr : integer range 0 to 5;
    signal seg_counttb : integer range 0 to 5;

    signal rcount : integer range 0 to 150000000;

    signal gresult5         : integer range 0 to 9 := 0 ;  --gamma3
    signal gresult4         : integer range 0 to 9 := 0 ;  --gamma3
    signal gresult3         : integer range 0 to 9 := 0 ;  --gamma3
     signal gresult2         : integer range 0 to 9 := 0 ;   --gamma2
     signal gresult1         : integer range 0 to 9 := 0 ;   --gamma1



    begin
    process(display_dco,seg_counts)
     begin
    if falling_edge(display_dco) then
     if (seg_counts < 150000000) then
         seg_counts <= seg_counts+1;
     else
         seg_counts <= 0;
      end if;
     end if;
    end process;

   process(display_dco,seg_counttr)
    begin
    if falling_edge(display_dco) then
      if (seg_counttr < 5) then
          seg_counttr <= seg_counttr+1;
      else
          seg_counttr <= 0;
       end if;
    end if;
    end process;    



      process(display_dco,r,b,rcount,bcount)
        begin
       if falling_edge(display_dco) then
         if (r='1') then
              rcount <= rcount+1;
         elsif (b='1') then
                rcount <= rcount;
                else
                rcount <= rcount;
             end if;
       end if;
      end process;



process(seg_counts,rcount)
  begin
   if (seg_counts > 140000000) then

       if(rcount>10000 and rcount<99999) then

        gresult5 <= rcount/10000;
        gresult4 <= ((rcount rem 10000)/1000);
        gresult3 <= ((rcount rem 1000)rem 1000)/100;
        gresult2 <= (((rcount rem 1000)rem 1000) rem 100)/10;
        gresult1 <= 0;


        elsif( (rcount<10000) and (rcount>1000) ) then

        gresult5 <= 0;
        gresult4 <= rcount/1000;
        gresult3 <= ((rcount rem 1000)/100);
        gresult2 <= ((rcount rem 1000) rem 100)/10;
        gresult1 <= ((rcount rem 1000) rem 100)rem 10;


     elsif( (rcount>100) and (rcount<1000) ) then
     gresult5 <= 0;
        gresult4 <= 0;
     gresult3 <= rcount/100;
     gresult2 <= rcount rem 100 ;
     gresult1 <= (rcount rem 100) rem 10;   

     elsif( (rcount<100) and (rcount>10) ) then
     gresult5 <= 0;
       gresult4 <= 0;
     gresult3 <= 0;
     gresult2 <= rcount/10; 
     gresult1 <= rcount rem 10;        

     elsif (rcount<10) then
     gresult5 <= 0;
        gresult4 <= 0;
     gresult3 <= 0;
     gresult2 <= 0;
     gresult1 <= rcount;

     end if;

    else

  end if;

结束过程;

      process(seg_counttr,gresult3,gresult2,gresult1)
        begin
        case seg_counttr is
              when 0 => r1 <= '0'; r2 <='1'; r3<='1'; r4<= '1'; r5<= '1'; r6<='1'; 
              when 1 => r1 <= '1'; r2 <='0'; r3<='1'; r4<= '1'; r5<= '1'; r6<='1';
              when 2 => r1 <= '1'; r2 <='1'; r3<='0'; r4<= '1'; r5<= '1'; r6<='1'; 
              when 3 => r1 <= '1'; r2 <='1'; r3<='1'; r4<= '0'; r5<= '1'; r6<='1'; 
              when 4 => r1 <= '1'; r2 <='1'; r3<='1'; r4<= '1'; r5<= '0'; r6<='1'; 
              when 5 => r1 <= '1'; r2 <='1'; r3<='1'; r4<= '1'; r5<= '1'; r6<='0';        
         end case;  


if (seg_counttr = 4) then
    if(gresult5=0) then  
    seg_gamma<="0111111";
    elsif(gresult5=1) then
    seg_gamma<="0000110";
    elsif(gresult5=2) then
    seg_gamma<="1011011";
    elsif(gresult5=3) then
    seg_gamma<="1001111";
    elsif(gresult5=4) then
    seg_gamma<="1100110";
    elsif(gresult5=5) then
    seg_gamma<="1101101";
    elsif(gresult5=6) then
    seg_gamma<="1111101";
    elsif(gresult5=7) then
    seg_gamma<="0000111";
    elsif(gresult5=8) then
    seg_gamma<="1111111";
    elsif(gresult5=9) then
    seg_gamma<="1101111";
    else
    seg_gamma<="0000000";
    end if;      


elsif (seg_counttr = 3) then
    if(gresult4=0) then  
    seg_gamma<="0111111";
    elsif(gresult4=1) then
    seg_gamma<="0000110";
    elsif(gresult4=2) then
    seg_gamma<="1011011";
    elsif(gresult4=3) then
    seg_gamma<="1001111";
    elsif(gresult4=4) then
    seg_gamma<="1100110";
    elsif(gresult4=5) then
    seg_gamma<="1101101";
    elsif(gresult4=6) then
    seg_gamma<="1111101";
    elsif(gresult4=7) then
    seg_gamma<="0000111";
    elsif(gresult4=8) then
    seg_gamma<="1111111";
    elsif(gresult4=9) then
    seg_gamma<="1101111";
    else
    seg_gamma<="0000000";
    end if;  



elsif (seg_counttr = 2) then
    if(gresult3=0) then  
    seg_gamma<="0111111";
    elsif(gresult3=1) then
    seg_gamma<="0000110";
    elsif(gresult3=2) then
    seg_gamma<="1011011";
    elsif(gresult3=3) then
    seg_gamma<="1001111";
    elsif(gresult3=4) then
    seg_gamma<="1100110";
    elsif(gresult3=5) then
    seg_gamma<="1101101";
    elsif(gresult3=6) then
    seg_gamma<="1111101";
    elsif(gresult3=7) then
    seg_gamma<="0000111";
    elsif(gresult3=8) then
    seg_gamma<="1111111";
    elsif(gresult3=9) then
    seg_gamma<="1101111";
    else
    seg_gamma<="0000000";
    end if;

      elsif (seg_counttr = 1) then
   if(gresult2=0) then  
    seg_gamma<="0111111";
    elsif(gresult2=1) then
    seg_gamma<="0000110";
    elsif(gresult2=2) then
    seg_gamma<="1011011";
    elsif(gresult2=3) then
    seg_gamma<="1001111";
    elsif(gresult2=4) then
    seg_gamma<="1100110";
    elsif(gresult2=5) then
    seg_gamma<="1101101";
    elsif(gresult2=6) then
    seg_gamma<="1111101";
    elsif(gresult2=7) then
    seg_gamma<="0000111";
    elsif(gresult2=8) then
    seg_gamma<="1111111";
    elsif(gresult2=9) then
    seg_gamma<="1101111";
    else
    seg_gamma<="0000000";
    end if;

   elsif (seg_counttr = 0) then
  if(gresult1=0) then 
   seg_gamma<="0111111";
    elsif(gresult1=1) then
    seg_gamma<="0000110";
    elsif(gresult1=2) then
    seg_gamma<="1011011";
    elsif(gresult1=3) then
    seg_gamma<="1001111";
    elsif(gresult1=4) then
    seg_gamma<="1100110";
    elsif(gresult1=5) then
    seg_gamma<="1101101";
    elsif(gresult1=6) then
    seg_gamma<="1111101";
    elsif(gresult1=7) then
    seg_gamma<="0000111";
    elsif(gresult1=8) then
    seg_gamma<="1111111";
    elsif(gresult1=9) then
    seg_gamma<="1101111";
    else
    seg_gamma<="0000000";
    end if;

如果结束; 结束过程;

结束step11_1_final_main;

0 个答案:

没有答案