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

📄 stopwatch.vhd

📁 电子秒表
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all; 
use ieee.std_logic_unsigned.all;
entity stopwatch is
  port(led1:out std_logic_vector(3 downto 0);      --??????? 
       led2:out std_logic_vector(3 downto 0);
       led3:out std_logic_vector(3 downto 0);
       led4:out std_logic_vector(3 downto 0);
       led5:out std_logic_vector(3 downto 0);
       led6:out std_logic_vector(3 downto 0);      
       reset_star:in std_logic;                       --???????
       clk:in std_logic);
  end stopwatch;
architecture behave of stopwatch is
    signal num1: std_logic_vector(3 downto 0);
    signal num2: std_logic_vector(3 downto 0);
    signal num3: std_logic_vector(3 downto 0);
    signal num4: std_logic_vector(3 downto 0);
    signal num5: std_logic_vector(3 downto 0);
    signal num6: std_logic_vector(3 downto 0);
    signal star:std_logic;
    signal reset:std_logic;
    signal cnt3:integer  range 0 to 2;
    signal count: std_logic_vector(9 downto 0);
    signal cp_stopwatch:std_logic;
begin
process(reset_star)
begin 
if reset_star'event and  reset_star='1' then         --???????
    cnt3<=cnt3+1;         ---????1
if (cnt3=0) then        -- ?????
star<='1';     --????
reset<='0';
else      
  star<='0';            --??
if (cnt3=2 )then          ---?????
    cnt3<=0;             ----?????
    reset<='1';else           ----?????
 reset<='0';
end if;         
end if; 
end if;
end process; 
            ---???
process(clk)
  begin 
  if clk'event and clk='1' then 
     if count="1010001111" then count<="0000000000";cp_stopwatch<=not cp_stopwatch;
     else count<=count+1;
     end if;
     end if;
    cp_stopwatch<=count(9);
     end process;
process(reset,cp_stopwatch)
  begin 
   if reset ='1' then num1(3 downto 0) <="0000";
                      num2(3 downto 0) <="0000";
                      num3(3 downto 0) <="0000";
                      num4(3 downto 0) <="0000";
                      num5(3 downto 0) <="0000";
                      num6(3 downto 0) <="0000";
   else if cp_stopwatch'event and cp_stopwatch='1' then 
     if star='1' then num1<=num1+1;
     if num1 (3 downto 0)="1001" then 
        num1 (3 downto 0)<="0000"; num2<= num2+1;
     if num2 (3 downto 0)="1001" then 
        num2 (3 downto 0)<="0000"; num3<= num3+1;
     if num3 (3 downto 0)="1001" then 
        num3 (3 downto 0)<="0000"; num4<= num4+1;
     if num4 (3 downto 0)="0101" then 
        num4 (3 downto 0)<="0000"; num5<= num5+1;
     if num5 (3 downto 0)="1001" then 
        num5 (3 downto 0)<="0000"; num6<= num6+1;
     if num6 (3 downto 0)="0101" then 
        num6 (3 downto 0)<="0000";
   end if; end if; end if; end if; end if; end if; end if;
   end if; end if;
      led1<=num1;led2<=num2;led3<=num3;
      led4<=num4;led5<=num5;led6<=num6;
end process;
end behave;





⌨️ 快捷键说明

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