Gast
#546643
Hallo Leute,
hat jemand ne Ahnung wie man eine FSM auf steigender und fallender
reagieren lässt. Ich bräuchte eine FSM die bei steigender und bei
fallender Taktflanke den Status ändern kann. Gibt es eine einfach
Lösung, oder muss ich den takt mit pll verdoppeln.
Das nachfolgende Beispiel (nur als Test gedacht) funktioniert leider
nicht.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
ENTITY myEntity IS
PORT
(
clk : IN std_logic;
engine : IN std_logic;
detection : OUT std_logic
);
END myEntity;
ARCHITECTURE myEntityArch OF myEntity IS
SIGNAL counter : signed(15 DOWNTO 0);
TYPE fsmstates IS (stop, starting);
SIGNAL fsmstate : fsmstates := stop;
SIGNAL nextfsmstate : fsmstates := stop;
BEGIN
PROCESS (clk)
BEGIN
IF rising_edge(clk) THEN
fsmstate <= nextfsmstate;
END IF;
IF falling_edge (clk) THEN
fsmstate <= nextfsmstate;
END IF;
CASE fsmState IS
WHEN stop =>
IF (engine = '1') THEN
nextfsmstate <= starting;
ELSE
nextfsmstate <= stop;
END IF;
detection <= '0';
WHEN starting =>
IF (engine = '1') THEN
nextfsmstate <= starting;
ELSE
nextfsmstate <= stop;
END IF;
detection <= '1';
WHEN OTHERS =>
detection <= '0';
END CASE;
END PROCESS ;
END myEntityArch;
Danke