I am trying to do a T-Bird tail light function using VHDL. I have been able to get the emergency (Hazard) and Left and right turn to work and brake but can not get the when brake light and the lights in the direction of the turn function as before, the lights opposite the tail lights are all on below is my code so what i want to do is "When the brakes are on, and when the hazard is on, it takes precedence and the tail lights all blink as before got this to work. when the left or right turn signal is on, the lights in the direction of the turn function as before, the lights opposite the tail lights are all on. can't get this to work when the brakes are on and the hazard and left or right are not, the tail lights are all on. got this to work.

1 | library IEEE; |

2 | use IEEE.std_logic_1164.all; |

3 | |

4 | ENTITY tbird_lc is |

5 | GENERIC(DIVISOR : positive := 10000000); |

6 | PORT(clk : IN std_logic; |

7 | rst : IN std_logic; |

8 | left : IN std_logic; |

9 | right : IN std_logic; |

10 | haz : in std_logic; |

11 | brake : IN std_logic; |

12 | left_tail_lt : OUT std_logic_vector(3 downto 1); |

13 | right_tail_lt : OUT std_logic_vector(1 to 3)); |

14 | END tbird_lc; |

15 | |

16 | ARCHITECTURE behavior OF tbird_lc IS |

17 | |

18 | TYPE state_type IS (IDLE, LR3, L1, L2, L3, R1, R2, R3,LB,LB1,LB2,LB3); |

19 | SIGNAL present_state, next_state : state_type; |

20 | CONSTANT leftoff : std_logic_vector(3 downto 1) := "000"; |

21 | CONSTANT left1on : std_logic_vector(3 downto 1) := "001"; |

22 | CONSTANT left2on : std_logic_vector(3 downto 1) := "011"; |

23 | CONSTANT left3on : std_logic_vector(3 downto 1) := "111"; |

24 | CONSTANT rightoff : std_logic_vector(3 downto 1) := "000"; |

25 | CONSTANT right1on : std_logic_vector(3 downto 1) := "100"; |

26 | CONSTANT right2on : std_logic_vector(3 downto 1) := "110"; |

27 | CONSTANT right3on : std_logic_vector(3 downto 1) := "111"; |

28 | |

29 | signal sclk: std_logic; |

30 | |

31 | ```
BEGIN
``` |

32 | DIVIDER : entity work.clock_divider(behavior) |

33 | generic map (DIVISOR => DIVISOR) |

34 | port map (clk => clk, rst => rst, q => sclk); |

35 | clocked : PROCESS(sclk,rst) |

36 | ```
BEGIN
``` |

37 | IF(rst='1') THEN |

38 | present_state <= idle; |

39 | ELSIF(rising_edge(sclk)) THEN |

40 | present_state <= next_state; |

41 | END IF; |

42 | END PROCESS clocked; |

43 | |

44 | nextstate : PROCESS(present_state,left,right,haz, brake) |

45 | ```
BEGIN
``` |

46 | CASE present_state IS |

47 | WHEN idle => |

48 | IF(haz = '1' OR(brake='1' and haz='1')OR (left = '1' AND right = '1')) THEN |

49 | next_state <= LR3; |

50 | ELSIF(left = '1') THEN |

51 | next_state <= L1; |

52 | ELSIF (left='1' and brake='1') THEN --trying to make another state for left and brake |

53 | next_state<=LB1; |

54 | ELSIF(right = '1') THEN |

55 | next_state <= R1; |

56 | ELSIF(brake='1' and haz='0' and left='0' and right='0')THEN |

57 | next_state<=LR3; |

58 | ```
ELSE
``` |

59 | next_state <= idle; |

60 | END IF; |

61 | WHEN LR3 => |

62 | IF(brake='1' and haz='0' and left='0' and right='0') THEN |

63 | next_state<=LR3; |

64 | ```
else
``` |

65 | next_state <= idle; |

66 | END IF; |

67 | WHEN L1 => |

68 | IF(haz = '1' or (brake='1' and haz='1') ) THEN |

69 | next_state <= LR3; |

70 | ```
ELSE
``` |

71 | next_state <= L2; |

72 | END IF; |

73 | WHEN L2 => |

74 | IF(haz = '1' or (brake='1' and haz='1') ) THEN |

75 | next_state <= LR3; |

76 | ```
ELSE
``` |

77 | next_state <= L3; |

78 | END IF; |

79 | WHEN L3 => |

80 | next_state <= idle; |

81 | WHEN R1 => |

82 | IF(haz = '1' or (brake='1' and haz='1')) THEN |

83 | next_state <= LR3; |

84 | ```
ELSE
``` |

85 | next_state <= R2; |

86 | END IF; |

87 | WHEN R2 => |

88 | IF(haz = '1' or (brake='1' and haz='1')) THEN |

89 | next_state <= LR3; |

90 | ```
ELSE
``` |

91 | next_state <= LB; |

92 | END IF; |

93 | WHEN R3 => |

94 | next_state <= idle; |

95 | WHEN LB1 => --next state for left and brake |

96 | IF (left='1' and brake='1') THEN |

97 | next_state<=LB2; |

98 | ```
else
``` |

99 | next_state<=LB; |

100 | END IF; |

101 | WHEN LB2=> |

102 | IF (left='1' and brake='1') THEN |

103 | next_state<=LB3; |

104 | ```
ELSE
``` |

105 | next_state<=LB; |

106 | END IF; |

107 | WHEN LB3 => |

108 | next_state<= idle; |

109 | WHEN LB => |

110 | next_state<=LB; |

111 | END CASE; |

112 | END PROCESS nextstate; |

113 | |

114 | output : PROCESS(present_state) |

115 | ```
BEGIN
``` |

116 | CASE present_state IS |

117 | WHEN idle => |

118 | left_tail_lt <= leftoff; |

119 | right_tail_lt <= rightoff; |

120 | WHEN LR3 => |

121 | left_tail_lt <= left3on; |

122 | right_tail_lt <= right3on; |

123 | WHEN L1 => |

124 | left_tail_lt <= left1on; |

125 | right_tail_lt <= rightoff; |

126 | WHEN L2 => |

127 | left_tail_lt <= left2on; |

128 | right_tail_lt <= rightoff; |

129 | WHEN L3 => |

130 | left_tail_lt <= left3on; |

131 | right_tail_lt <= rightoff; |

132 | WHEN R1 => |

133 | left_tail_lt <= leftoff; |

134 | right_tail_lt <= right1on; |

135 | WHEN R2 => |

136 | left_tail_lt <= leftoff; |

137 | right_tail_lt <= right2on; |

138 | WHEN R3 => |

139 | left_tail_lt <= leftoff; |

140 | right_tail_lt <= right3on; |

141 | WHEN LB1 => --trying to do left and brake but working |

142 | left_tail_lt <= left1on; |

143 | right_tail_lt <= right3on; |

144 | WHEN LB2 => |

145 | left_tail_lt <= left2on; |

146 | right_tail_lt <= right3on; |

147 | WHEN LB3 => |

148 | left_tail_lt <= left3on; |

149 | right_tail_lt <= right3on; |

150 | WHEN LB => |

151 | right_tail_lt <=right3on; |

152 | left_tail_lt<=leftoff; |

153 | END CASE; |

154 | END PROCESS output; |

155 | |

156 | END ARCHITECTURE behavior; |

Why do you one signle state machine, that codes everything? You have a number of lights that are independant, so you shouldn't code them into one big state machine, creating dependancies where they don't really exist. I doubt whether you even need a state machine. Maybe it is just enough to register the inputs for synchronisation and if required debounce them and afterwards do a pure combinational assignment. e.g:

1 | brake_left <= '1' when brake_registered_debounced = '1' else |

2 | '0'; |

3 | dir_left <= blink when left_registered_debounced = '1' or |

4 | haz_registered_debounced = '1' else |

5 | '0'; |

... "blink" is an independantly generated (ever running) blinking signal running at your desired speed.