Vhdl For Engineers Kenneth L Short Official
-- 3. Output logic (can be concurrent or sequential) red <= '1' when state = S_RED else '0'; green <= '1' when state = S_GREEN else '0'; yellow <= '1' when state = S_YELLOW else '0'; end architecture;
-- Three-process FSM (state, next_state logic, outputs) entity traffic_light is port (clk, reset : in std_logic; red, yellow, green : out std_logic); end entity; architecture short_style of traffic_light is type state_type is (S_RED, S_YELLOW, S_GREEN); signal state, next_state : state_type; begin -- 1. State register seq_proc: process(clk, reset) begin if reset = '1' then state <= S_RED; elsif rising_edge(clk) then state <= next_state; end if; end process; Vhdl For Engineers Kenneth L Short
-- 2. Next state logic (combinational) comb_proc: process(state) begin case state is when S_RED => next_state <= S_GREEN; when S_GREEN => next_state <= S_YELLOW; when S_YELLOW => next_state <= S_RED; when others => next_state <= S_RED; end case; end process; when S_GREEN =>