Challenge - 5 Problems
FSM Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of a simple FSM state transition
Consider this VHDL FSM snippet controlling a traffic light. What is the output signal
light after the first clock rising edge if the initial state is RED?VHDL
type state_type is (RED, GREEN, YELLOW); signal state: state_type := RED; signal light: std_logic_vector(1 downto 0); process(clk) begin if rising_edge(clk) then case state is when RED => light <= "10"; -- red light on state <= GREEN; when GREEN => light <= "01"; -- green light on state <= YELLOW; when YELLOW => light <= "11"; -- yellow light on state <= RED; end case; end if; end process;
Attempts:
2 left
💡 Hint
Look at the initial state and what output is assigned before the state changes.
✗ Incorrect
The FSM starts in RED state. On the first clock edge, it outputs "10" for red light and then moves to GREEN state.
🧠 Conceptual
intermediateWhy FSMs are used for complex sequential control
Why do engineers use FSMs (Finite State Machines) to control complex sequential behavior in hardware design?
Attempts:
2 left
💡 Hint
Think about how FSMs help organize behavior step-by-step.
✗ Incorrect
FSMs break down complex sequences into manageable states and transitions, making design and debugging simpler.
🔧 Debug
advancedIdentify the error in this FSM VHDL code
This FSM code is intended to cycle through states A, B, and C on each clock. What error will occur when synthesizing or simulating this code?
VHDL
type state_type is (A, B, C); signal state: state_type := A; process(clk) begin if rising_edge(clk) then case state is when A => state <= B; when B => state <= C; when C => state <= D; -- Error here end case; end if; end process;
Attempts:
2 left
💡 Hint
Check if all states used are declared in the type.
✗ Incorrect
State 'D' is not declared in the state_type enumeration, causing a syntax error.
🚀 Application
advancedNumber of states needed for a sequence controller
You want to design an FSM to control a sequence of 5 steps, each step requiring a unique output signal. How many states should your FSM have at minimum?
Attempts:
2 left
💡 Hint
Each unique step usually corresponds to one state in FSM design.
✗ Incorrect
Each step in a sequence typically maps to one state to clearly represent the behavior.
❓ Predict Output
expertOutput of a Moore FSM with delayed output
Given this Moore FSM VHDL code, what is the value of
output_signal after the third rising clock edge if the initial state is S0?VHDL
type state_type is (S0, S1, S2); signal state: state_type := S0; signal output_signal: std_logic := '0'; process(clk) begin if rising_edge(clk) then case state is when S0 => output_signal <= '0'; state <= S1; when S1 => output_signal <= '1'; state <= S2; when S2 => output_signal <= '0'; state <= S0; end case; end if; end process;
Attempts:
2 left
💡 Hint
Trace the state and output signal values step-by-step for each clock edge.
✗ Incorrect
At clock 1: state S0, output '0'; clock 2: S1, output '1'; clock 3: S2, output '0'. So after third clock, output is '0'.
