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

📄 debouncer.vhd

📁 This is a project about PWM. Application in motor speed control
💻 VHD
字号:
------------------------------------------------------------------------------ debouncer for buttons -- variable bounce window ("period")----------------------------------------------------------------------------library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity debouncer is  port(    clk: in std_logic;    raw: in std_logic;    period: in std_logic_vector(31 downto 0);    debounced: out std_logic  );end debouncer;architecture behavior of debouncer istype statetype is (standby, pressed, released);signal state: statetype := standby;signal count: std_logic_vector(31 downto 0);begin  process    begin      wait until rising_edge(clk);      case state is        when standby =>          if (raw = '1') then            state <= pressed;            debounced <= '1';            count <= (others => '0');          end if;                                   when pressed =>          if (count < period) then            count <= count + 1;          elsif (raw = '0') then            count <= (others => '0');            state <= released;          end if;        when released =>          debounced <= '0';          if (count < period) then            count <= count + 1;          else	    state <= standby;          end if;       end case;    end process;end behavior;

⌨️ 快捷键说明

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