10M02SCM >> VHDL

Button


程式如下:

library ieee;
use ieee.std_logic_1164.all;
 
entity main is
  port(
    btn: in bit;
    led: out bit_vector(7 downto 0));
end main;
 
architecture logic of main is
signal cnt:bit_vector(7 downto 0):="11111110";

begin
  process(btn) is 
  begin
    if (btn'event and btn = '0') then
      cnt<= cnt rol 1;
    end if;
  end process;
  
  led<= cnt;
end logic;

依序旋轉位元並且輸出到led

腳位


完成


返回上一頁