本程序试图在输入信号去抖动后转换为程序中中的复位、开启信号,en信号合适,但是reset信号转换后一直是高电平,不合适,望高手不吝赐教,在下感激不尽 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all;
entity key_test is port(start_stop,reset,clk,en:in std_logic; rst:out std_logic; eno:out std_logic); end key_test;
architecture behav of key_test is signal station1:std_logic_vector(1 downto 0):="00"; signal station2:std_logic_vector(1 downto 0):="00"; signal sum_tmp:std_logic_vector(3 downto 0); signal co_tmp:std_logic; signal rst_tmp:std_logic:='1'; signal eno_tmp:std_logic:='0'; component cnt10_test port(reset,en,clk:in std_logic; sum:out std_logic_vector(3 downto 0); co:out std_logic); end component; begin u0:cnt10_test port map(reset,en,clk,sum_tmp,co_tmp);
process(reset,co_tmp) is begin if(reset='0') then if(co_tmp'event and co_tmp='1') then case station1 is when "00"=>station1<="01"; when "01"=>station1<="10"; when "10"=>station1<="11"; when "11"=>station1<="11"; when others=>station1<="00"; end case; end if; else station1<="00"; end if; if(start_stop'event and start_stop='1') then if(station2="11") then rst_tmp<='0'; end if; end if; end process;
process(start_stop,co_tmp) is begin if(start_stop='1') then if(co_tmp'event and co_tmp='1') then case station2 is when "00"=>station2<="01"; when "01"=>station2<="10"; when "10"=>station2<="11"; when "11"=>station2<="11"; when others=>station2<="00"; end case; end if; else station2<="00"; end if; if(start_stop'event and start_stop='0') then if(station2="11") then eno_tmp<=not eno_tmp; end if; end if; end process;
个人认为楼主还没有入门:
1.用非时钟信号作为DFF的clk输入,例如:
“if(co_tmp'event and co_tmp='1') then”
2.敏感列表中的东西不对
3.还没有VHDL编程的思路
这是非常不合理的。一般的写法是:
process(clk, reset)
begin
if reset='0' then
elsif rising_edge(clk) then
end if;
end process;
多看看别人的代码是怎么写的,起步阶段都是依葫芦画瓢,别总自己想当然的乱写一气