Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a state type in VHDL.
VHDL
type state_type is ([1]);Attempts:
3 left
💡 Hint
Common Mistakes
Including multiple states without commas or parentheses.
Using lowercase state names without quotes.
✗ Incorrect
In VHDL, when declaring an enumeration type, the states are listed inside parentheses separated by commas. Here, only one state 'IDLE' is declared as a simple example.
2fill in blank
mediumComplete the code to define the next state logic in a process.
VHDL
process(current_state, input_signal) begin
case current_state is
when IDLE =>
if input_signal = '1' then
next_state <= [1];
else
next_state <= IDLE;
end if;
when others =>
next_state <= IDLE;
end case;
end process;Attempts:
3 left
💡 Hint
Common Mistakes
Assigning next_state to IDLE again, causing no state change.
Using a state name not declared in the type.
✗ Incorrect
When the FSM is in IDLE and input_signal is '1', the next state should be RUNNING to start the operation.
3fill in blank
hardFix the error in the state register process to update the current state on clock edge.
VHDL
process(clk, reset) begin if reset = '1' then current_state <= IDLE; elsif rising_edge([1]) then current_state <= next_state; end if; end process;
Attempts:
3 left
💡 Hint
Common Mistakes
Using reset or other signals in rising_edge instead of clk.
Forgetting to use rising_edge function.
✗ Incorrect
The state register updates on the rising edge of the clock signal 'clk', not on reset or other signals.
4fill in blank
hardFill both blanks to complete the output logic based on the current state.
VHDL
process(current_state) begin
case current_state is
when IDLE => output_signal <= [1];
when RUNNING => output_signal <= [2];
when others => output_signal <= '0';
end case;
end process;Attempts:
3 left
💡 Hint
Common Mistakes
Using '1' in IDLE state causing output to be on when idle.
Using undefined signal values like 'Z' or 'X'.
✗ Incorrect
In IDLE state, output_signal is '0' (off). In RUNNING state, output_signal is '1' (on).
5fill in blank
hardFill all three blanks to complete the FSM state transition with an additional STOPPED state.
VHDL
type state_type is (IDLE, RUNNING, [1]); process(current_state, input_signal) begin case current_state is when IDLE => if input_signal = '1' then next_state <= RUNNING; else next_state <= IDLE; end if; when RUNNING => if input_signal = '0' then next_state <= [2]; else next_state <= RUNNING; end if; when [3] => next_state <= IDLE; when others => next_state <= IDLE; end case; end process;
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent state names in different parts of the code.
Forgetting to include the new state in the type declaration.
✗ Incorrect
The additional state is STOPPED. The FSM moves to STOPPED from RUNNING when input_signal is '0', and from STOPPED it returns to IDLE.
