【发布时间】:2016-03-07 16:06:45
【问题描述】:
我用 VHDL 制作了我的 FSM,现在我想使用带有端口映射的去抖动代码。
虽然我对协会有困难。事实上,我想在驱动 FSM 的信号中插入 debouncebutton 分量。
entity myFSM is
Port ( CLK : in STD_LOGIC;
RST : in STD_LOGIC;
IN0 : in STD_LOGIC;
IN1 : in STD_LOGIC;
IN2 : in STD_LOGIC;
LED : out STD_LOGIC_VECTOR (7 downto 0));
end myFSM;
architecture Behavioral of myFSM is
type state is (A, B, C);
signal currentS, nextS: state;
component debouncebutton
Port ( clk : in std_logic; -- connect it to the Clock of the board
rst : in std_logic; -- connect it to the Reset Button of the board
input : in std_logic; -- connect it to the Push Button of the board
output : out std_logic -- connect it to your circuit
);
end component;
begin
myFSM_comb: process (currentS, IN0, IN1, IN2)
begin
case currentS is
when A => LED <= "11111111";
if IN0 = '1' then nextS<=B;
elsif IN1 = '1' then nextS<=C;
else nextS<=A;
end if;
when B => LED <= "11000011";
if IN0 = '1' then nextS<=C;
elsif IN1 = '1' then nextS<=A;
else nextS<=B;
end if;
when C => LED <= "00111100";
if IN0 = '1' then nextS<=A;
elsif IN1 = '1' then nextS<=B;
else nextS<=C;
end if;
end case;
end process;
myFSM_synch: process(CLK,RST)
begin
if (RST='1') then currentS<=A;
elsif (rising_edge(CLK)) then currentS<= nextS;
end if;
end process ;
begin
db0 : debounce
port map
(
clk => CLK,
rst => RST,
input => IN0,
output
end Behavioral;
【问题讨论】: