⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baijinzhi.txt

📁 利用扫描加记数程序实现百进制,适合VHDL的初学者使用.
💻 TXT
字号:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;

entity counter100 is
Port(--clk:in std_logic;
     saomiao:in std_logic;
     led:out std_logic_vector(6 downto 0);
     ss0:out std_logic
     );
end counter100;

architecture action of counter100 is 
signal count_low: std_logic_vector(3 downto 0);
signal count_high:std_logic_vector(3 downto 0);
signal c:std_logic;
signal fenpin:std_logic_vector(5 downto 0);

signal j:std_logic;
signal clk:std_logic;
begin
     process(saomiao)
       begin 
        if(saomiao'event and saomiao='1') then
           fenpin<=fenpin+1;
          clk<=fenpin(5);
        end if ;
     end process;

     process(clk)

        begin
           if(clk'event and clk='1')  then 
              if (count_low=9) then
               count_low<="0000";
               c<='1';
              else count_low<=count_low+1;
               c<='0';
              end if;
           end if;

      end process;
      process(c)

           begin
             if(c'event and c='1')  then 
                if (count_high=9) then
                 count_high<="0000";
               else count_high<=count_high+1;
              end if;
           end if;
       end process;


     process(count_low)
         begin
           if j='0' then
            case count_low is 
               when"0000"=>led<="0111111";
               when"0001"=>led<="0000110";
               when"0010"=>led<="1011011";
               when"0011"=>led<="1001111";
               when"0100"=>led<="1100110";
               when"0101"=>led<="1101101";
               when"0110"=>led<="1111101";
               when"0111"=>led<="0100111";
               when"1000"=>led<="1111111";
               when"1001"=>led<="1101111";
               when others=>led<="0000000";
             end case;
             
            else
               case count_high is 
               when"0000"=>led<="0111111";
               when"0001"=>led<="0000110";
               when"0010"=>led<="1011011";
               when"0011"=>led<="1001111";
               when"0100"=>led<="1100110";
               when"0101"=>led<="1101101";
               when"0110"=>led<="1111101";
               when"0111"=>led<="0100111";
               when"1000"=>led<="1111111";
               when"1001"=>led<="1101111";
               when others=>led<="0000000"; 
               end case;
           end if;
         end process;

   process(saomiao)
       begin
       if saomiao'event and saomiao='1' then
            if j='0' then j<='1';
            else j<='0';
            end if ;
            
            ss0<=j;
       end if;
   end process;

end action;
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -