FSM Controller

Medium VHDL FSM
Solve this problem

Write a VHDL FSM that controls a motor based on commands START, STOP, and ERROR. The FSM must move between IDLE, RUN, and FAULT states with appropriate transitions.

Constraints

  • cmd: START='01', STOP='10', ERROR='11'.
  • IDLE -> RUN on START.
  • RUN -> IDLE on STOP.
  • Any -> FAULT on ERROR.
  • Reset returns to IDLE.
  • cmd interpreted each rising edge.
Starter codeVHDL
1entity motor_fsm is2  Port ( clk: in std_logic;3         rst: in std_logic;4         cmd: in std_logic_vector(1 downto 0);5         state: out std_logic_vector(1 downto 0));6end motor_fsm;