【问题标题】:type in port declaration VHDL without using package在不使用包的情况下输入端口声明 VHDL
【发布时间】:2018-10-25 20:49:03
【问题描述】:

我必须编写一个分层状态机,但我需要将状态添加到端口。它不会让我因为我正在使用的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;

【问题讨论】:

  • 我看不出这种设计将如何实现分层 FSM。此外,通过改变 FSM 模式,您会失去对综合工具的 FSM 优化。
  • 标题约束 without using package 不清楚(所有类型,如 STD_LOGICinteger 都在包中定义),而我们确实找到了设计约束编写分层状态机。问题不清楚。
  • 我一直被教导只能将 std_logic 及其向量变体用于实体端口。不知道这是如何在硬件上实现的。

标签: types port vhdl state-machine


【解决方案1】:

需要在包中声明枚举类型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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-29
    • 2018-10-30
    • 1970-01-01
    相关资源
    最近更新 更多