xiaodou.vhd

来自「这是一个键盘的消抖电路的代码 有兴趣的可以看看 我做了很长时间的」· VHDL 代码 · 共 55 行

VHD
55
字号
//键盘消抖电路的程序,自己觉得和别人的是不一样的 哈哈。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

entity xiaodou is
	port(	clk: in std_logic;
		row: in std_logic_vector(3 downto 0);
		key_pre: out std_logic);
	end entity;
architecture trl of xiaodou is
signal sig_1,counter: std_logic_vector(3 downto 0);
signal temp1,sig_2,sig_3: std_logic;
	begin
		sig_1<=row;
		temp1<=sig_1(0) and sig_1(1) and sig_1(2) and sig_1(3);
		key_pre<=counter(0) and counter(1) and counter(2) and counter(3);

		process(clk)
		begin
			if(clk'event and clk='1')then
			  if(sig_3='0')then
			    counter<="0000";
			else
				counter<=counter+1;
			end if;
		      end if;
		end process;
	
		process(clk)
		begin
			if(clk'event and clk='1')then
			  if(temp1='0')then
			    if(sig_2='0')then
			      sig_2<='1';
				end if;
			 elsif(sig_3='0')then
			    sig_2<='0';
				end if;
			   end if;
			end process;

		process(sig_2,counter)
		 begin
			if(sig_2='1')then
			  if(counter="1111")then
			    sig_3<='0';
				else
				  sig_3<='1';
			  end if;
			end if;
		    end process;
		end architecture;
		

⌨️ 快捷键说明

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