-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFSM_synth.vhd.bak
63 lines (58 loc) · 1.27 KB
/
FSM_synth.vhd.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
ENTITY FSM_octave IS
PORT(
button: in std_logic;
clk: in std_logic;
z: out std_logic_vector (1 downto 0)
);
END ENTITY FSM_octave;
ARCHITECTURE states of FSM_octave IS
SIGNAL current: bit_vector (1 downto 0) := "01";
BEGIN
FSM_cycle: PROCESS (clk, button) IS
VARIABLE pressed: std_logic := '0';
BEGIN
IF (rising_edge(clk)) THEN
CASE current IS
WHEN "00" =>
--octave 1
z <= "00";
IF (button = '0' AND pressed = '0') THEN
current <= "01";
pressed := '1';
ELSIF (button = '0' AND pressed = '1') THEN
--do nothing
ELSE
pressed := '0';
END IF;
WHEN "01" =>
--octave 2
z <= "01";
IF (button = '0' AND pressed = '0') THEN
current <= "10";
pressed := '1';
ELSIF (button = '0' AND pressed = '1') THEN
--do nothing
ELSE
pressed := '0';
END IF;
WHEN "10" =>
--octave 3
z <= "10";
IF (button = '0' AND pressed = '0') THEN
current <= "00";
pressed := '1';
ELSIF (button = '0' AND pressed = '1') THEN
--do nothing
ELSE
pressed := '0';
END IF;
-- cases it will never reach
WHEN "11" =>
current <= "01";
END CASE;
END IF;
END PROCESS FSM_cycle;
END ARCHITECTURE states;