Challenge - 5 Problems
Moore Machine Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of a simple Moore machine VHDL code
What is the output on the signal
y after the input sequence 101 is applied to this Moore machine?VHDL
library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity moore_simple is Port ( clk : in STD_LOGIC; rst : in STD_LOGIC; x : in STD_LOGIC; y : out STD_LOGIC); end moore_simple; architecture Behavioral of moore_simple is type state_type is (S0, S1); signal state, next_state : state_type; begin process(clk, rst) begin if rst = '1' then state <= S0; elsif rising_edge(clk) then state <= next_state; end if; end process; process(state, x) begin case state is when S0 => if x = '1' then next_state <= S1; else next_state <= S0; end if; when S1 => if x = '1' then next_state <= S0; else next_state <= S1; end if; end case; end process; process(state) begin case state is when S0 => y <= '0'; when S1 => y <= '1'; end case; end process; end Behavioral;
Attempts:
2 left
💡 Hint
Remember that Moore machine outputs depend only on the current state, not the input.
✗ Incorrect
The machine starts in S0 with output 0. Input '1' moves it to S1 with output 1, and next input '0' keeps it in S1 because the transition only moves back to S0 if input is '1' from S1. So outputs are 0, 1, 1.
🧠 Conceptual
intermediateUnderstanding Moore machine output timing
In a Moore machine implemented in VHDL, when does the output signal typically change relative to the clock?
Attempts:
2 left
💡 Hint
Think about when the state is updated and how output depends on state.
✗ Incorrect
In Moore machines, output depends only on the current state. The state updates on the rising clock edge, so output changes after the state update on the clock edge.
🔧 Debug
advancedIdentify the error in this Moore machine VHDL code
What error will this VHDL code produce when synthesizing a Moore machine?
VHDL
library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity moore_buggy is Port ( clk : in STD_LOGIC; rst : in STD_LOGIC; x : in STD_LOGIC; y : out STD_LOGIC); end moore_buggy; architecture Behavioral of moore_buggy is type state_type is (S0, S1); signal state, next_state : state_type; begin process(clk, rst) begin if rst = '1' then state <= S0; elsif rising_edge(clk) then state <= next_state; end if; end process; process(state, x) begin case state is when S0 => if x = '1' then next_state <= S1; -- missing else branch here else next_state <= S0; end if; when S1 => if x = '0' then next_state <= S0; else next_state <= S1; end if; end case; end process; process(state) begin case state is when S0 => y <= '0'; when S1 => y <= '1'; end case; end process; end Behavioral;
Attempts:
2 left
💡 Hint
Check if all possible input conditions assign next_state in every branch.
✗ Incorrect
In the process for next_state, the 'when S0' branch lacks an else clause, so next_state is not assigned for x='0'. This causes a latch inference or synthesis error.
📝 Syntax
advancedIdentify the syntax error in this Moore machine VHDL snippet
Which option correctly identifies the syntax error in this VHDL code snippet?
VHDL
process(state)
begin
case state is
when S0 => y <= '0';
when S1 => y <= '1';
end case;
end process;Attempts:
2 left
💡 Hint
Check each line for proper statement termination.
✗ Incorrect
In VHDL, each assignment statement must end with a semicolon. The line 'y <= '0'' is missing a semicolon.
🚀 Application
expertNumber of states in a Moore machine for a given sequence detector
You want to design a Moore machine in VHDL that detects the sequence '1101' on input
x. How many states are needed at minimum to implement this detector?Attempts:
2 left
💡 Hint
Think about how many partial matches of the sequence you need to remember.
✗ Incorrect
To detect '1101', the machine must remember progress through the sequence: no match, matched '1', matched '11', matched '110', and matched '1101'. This requires 5 states.
