shaiko
Advanced Member level 5
Hello People,
What do you think about this code:
------------------------------------------------------------------------------
FSM: process (clk,rst) is -- Effected directly by the SPI_transceiver_rst
begin
if rst = '1' then
state <= idle;
elsif rising_edge(clk) then
case state is
when idle =>
if input = '1' then
state <= run;
end if;
when run =>
case internal_state is
when x =>
-- do something or move to state y
when y =>
-- do something or move to state x
end case;
end case;
end process;
------------------------------------------------------------------------
A far as I understand it will create a child state machine embedded inside one of the states of the main state machine.
Am I correct?
Is this a good way to write code?
What do you think about this code:
------------------------------------------------------------------------------
FSM: process (clk,rst) is -- Effected directly by the SPI_transceiver_rst
begin
if rst = '1' then
state <= idle;
elsif rising_edge(clk) then
case state is
when idle =>
if input = '1' then
state <= run;
end if;
when run =>
case internal_state is
when x =>
-- do something or move to state y
when y =>
-- do something or move to state x
end case;
end case;
end process;
------------------------------------------------------------------------
A far as I understand it will create a child state machine embedded inside one of the states of the main state machine.
Am I correct?
Is this a good way to write code?