即使条目保持在“1”,如何在输出中只发送一个“1”
How to send only one "1" in output even when the entry stays on "1"
我正在做一些 VHDL,但我是初学者,我有一个用户一直在输入 1。我想要的只是我的输出像“10000000”而不是“111111”,除非条目是“101010”然后输出是“101010”。我尝试了一种 Mealy 机器。
library ieee;
use ieee.std_logic_1164.ALL;
use ieee.std_logic_unsigned.all;
entity Button1_sync is
port ( i_button1 : in std_logic;
i_clk : in std_logic;
i_clk_game : in std_logic;
i_rst : in std_logic;
o_button1_sync : out std_logic);
end Button1_sync;
architecture BEHAVIORAL of Button1_sync is
type stateType is (noPressure, Pressed);
signal state, nextState : stateType;
begin
process(i_clk_game,i_rst)
begin
if (i_rst = '0') then
state <= noPressure;
o_button1_sync <= '0';
elsif rising_edge(i_clk_game) then
state <= nextState;
end if;
end process;
process(state,i_button1)
begin
if i_button1 = '1' then
nextState <= Pressed;
else
nextState <= noPressure;
end if;
end process;
o_button1_sync <= '1' when (state = noPressure and i_button1 ='1') else '0';
end Behavioral;
但输出保持 "U"
最简单的做法是将输入信号移位一个时钟周期,如(在一个过程中):
i_button1_d <= i_button1;
然后用2个信号检测输入的上升沿,组合表达式:
i_button1_d = '0' and i_button1 = '1'
例如在进程中的一个 IF 中。该表达式表示信号在前一个时钟为“0”,在当前时钟为“1”,所以刚刚上升。
在下降沿(之后)使用“1”和“0”进行测试以在“1”处获得独特的脉冲也很常见。
然后,如果需要保持信号向上或向下,您可以将此表达式与其他表达式组合(例如,可能是输入的 OR 或将相同的脉冲再移动一个周期)!
我正在做一些 VHDL,但我是初学者,我有一个用户一直在输入 1。我想要的只是我的输出像“10000000”而不是“111111”,除非条目是“101010”然后输出是“101010”。我尝试了一种 Mealy 机器。
library ieee;
use ieee.std_logic_1164.ALL;
use ieee.std_logic_unsigned.all;
entity Button1_sync is
port ( i_button1 : in std_logic;
i_clk : in std_logic;
i_clk_game : in std_logic;
i_rst : in std_logic;
o_button1_sync : out std_logic);
end Button1_sync;
architecture BEHAVIORAL of Button1_sync is
type stateType is (noPressure, Pressed);
signal state, nextState : stateType;
begin
process(i_clk_game,i_rst)
begin
if (i_rst = '0') then
state <= noPressure;
o_button1_sync <= '0';
elsif rising_edge(i_clk_game) then
state <= nextState;
end if;
end process;
process(state,i_button1)
begin
if i_button1 = '1' then
nextState <= Pressed;
else
nextState <= noPressure;
end if;
end process;
o_button1_sync <= '1' when (state = noPressure and i_button1 ='1') else '0';
end Behavioral;
但输出保持 "U"
最简单的做法是将输入信号移位一个时钟周期,如(在一个过程中):
i_button1_d <= i_button1;
然后用2个信号检测输入的上升沿,组合表达式:
i_button1_d = '0' and i_button1 = '1'
例如在进程中的一个 IF 中。该表达式表示信号在前一个时钟为“0”,在当前时钟为“1”,所以刚刚上升。
在下降沿(之后)使用“1”和“0”进行测试以在“1”处获得独特的脉冲也很常见。
然后,如果需要保持信号向上或向下,您可以将此表达式与其他表达式组合(例如,可能是输入的 OR 或将相同的脉冲再移动一个周期)!