📄 autorepeat.vhd
字号:
----------------------------------------------------------------------------- autorepeat-- pass on pulse, iff long then start repeating pulses (e.g., keyboard)---------------------------------------------------------------------------library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity autorepeat is port ( clk: in std_logic; input: in std_logic; output: out std_logic );end entity;architecture behaviour of autorepeat istype statetype is (stdby, press0, press1, press2);signal state: statetype := stdby;signal counter : std_logic_vector(31 downto 0);begin process begin wait until rising_edge(clk); case state is when stdby => output <= '0'; counter <= x"02000000"; if (input = '1') then state <= press0; end if; when press0 => output <= '1'; if (input = '0') then state <= stdby; end if; -- else when timeout goto repeater counter <= counter - '1'; if (counter = x"00000000") then state <= press1; end if; when press1 => if (input = '0') then state <= stdby; end if; -- else repeat 0-1 output <= '0'; counter <= counter + '1'; if (counter > x"00040000") then counter <= (others => '0'); state <= press2; end if; when press2 => if (input = '0') then state <= stdby; end if; -- else repeat 0-1 output <= '1'; counter <= counter + '1'; if (counter > x"00040000") then counter <= (others => '0'); state <= press1; end if; end case; end process;end behaviour;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -