xsecond.vhd

来自「DEMO2 数码管扫描显示电路/DEMO4 计数时钟 DEMO5 键盘扫描设计」· VHDL 代码 · 共 67 行

VHD
67
字号
library IEEE;
use IEEE.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity xsecond is
    port (
        clk: in STD_LOGIC;
        clkset: in STD_LOGIC;
        setmin: in STD_LOGIC;
        reset: in STD_LOGIC;
        secout: out STD_LOGIC_VECTOR (6 downto 0);
        enmin: out STD_LOGIC
    );
end xsecond;

architecture xsecond_arch of xsecond is
signal sec : std_logic_vector(6 downto 0);
signal emin : std_logic;
signal sec1 : std_logic;
begin
  -- <<enter your statements here>>

  process(reset,sec,emin,setmin,clkset)
  begin
  if reset='0' then
    enmin<='0';
    secout<="0000000";
    sec1<='1';
  else
    sec1<='0';
    secout<=sec;
    if clkset='1' and clkset'event then
      if setmin='0' then
         enmin<='1';
      else
         enmin<=emin;         
      end if;
    end if;
  end if;
  end process;   
  
  process(clk,sec1)
  alias lcount : std_logic_vector(3 downto 0) is sec(3 downto 0);
  alias hcount : std_logic_vector(2 downto 0) is sec(6 downto 4);
  begin
    if sec1='1' then
      sec<="0000000";
    else
    if (clk='1' and clk'event) then           
      if lcount=9 then
         lcount<="0000";
         if hcount/=5 then
          hcount<=hcount+1;
          emin<='0';
         else
          hcount<="000";
          emin<='1';
         end if;
      else
         lcount<=lcount+1;
         emin<='0';
      end if;
  end if;
  end if;
end process;
end xsecond_arch;

⌨️ 快捷键说明

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