This section explains how to create a state machine and add it into a HDL Flow project.
The Files tab in the Hierarchy Browser displays the state machine name. HDL code is automatically generated from the FSM diagram. The module (VHDL) or entity (Verilog) name is automatically added to the top-level selection list.
You will see the FSM macro listed in the Files tab of the Project Manager.
Following is an example of VHDL code (my_fsm.vhd) generated from the State Editor for a state machine macro.
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
entity my_fsm is
port (clk: in STD_LOGIC;
in_a: in STD_LOGIC;
in_b: in STD_LOGIC;
in_c: in STD_LOGIC;
reset: in STD_LOGIC;
out_a: out STD_LOGIC;
out_b: out STD_LOGIC;
out_c: out STD_LOGIC);
end;
architecture my_fsm_arch of my_fsm is
-- SYMBOLIC ENCODED state machine: Sreg0
type Sreg0_type is (S1, S2, S3);
signal Sreg0: Sreg0_type;
begin
--concurrent signal assignments
--diagram ACTIONS
process (clk)
begin
if clk'event and clk = '1' then
if reset='1' then
Sreg0 <= S1;
else
case Sreg0 is
when S1 =>
if in_a = '1' then
Sreg0 <= S2;
end if;
when S2 =>
if in_b = '1' then
Sreg0 <= S3;
end if;
when S3 =>
if in_c = '1' then
Sreg0 <= S1;
end if;
when others =>
null;
end case;
end if;
end if;
end process;
-- signal assignment statements for combinatorial
-- outputs
out_c <= '0' when (Sreg0 = S2) else
'0' when (Sreg0 = S3) else
'1';
out_a <= '1' when (Sreg0 = S2) else
'0' when (Sreg0 = S3) else
'0';
out_b <= '0' when (Sreg0 = S2) else
'1' when (Sreg0 = S3) else
'0';
end my_fsm_arch;
For more information about creating state machine macros, refer to the State Machine Designs chapter. Or, select Help Foundation Help Contents and then Click State Editor.