我必须编写一个分层状态机,但是我需要将状态添加到端口。因为我正在使用的value_type
尚未声明,但我不知道该怎么做。
这是我的代码:
entity statereg is
port (
Rst : in STD_LOGIC;
Clk : in STD_LOGIC;
TimeBase : in STD_LOGIC;
StateDuration : in integer range 0 to 15;
next_state : in state_values;
pres_state : out state_values
);
end statereg;
architecture Behavioral of statereg is
type state_values is (RED,REDAMBER,GREEN,AMBER);
signal pres_state, next_state : state_values;
begin
end Behavioral;
答案 0 :(得分:0)
您需要在包中声明枚举类型state_values
。通过使用该程序包,您可以在实体的端口声明中引用其中声明的类型。
此处是所需的软件包:
package FSM_types is
type state_values is (RED, REDAMBER, GREEN, AMBER);
end package;
在此更改实体:
library IEEE;
use IEEE.std_logic_1164.all;
use work.FSM_types.all;
entity statereg is
port (
Clock : in std_logic;
-- ...
next_state : in state_values;
pres_state : out state_values
);
end entity;