【问题标题】:How to check the condition of an output signal in an if statement如何在 if 语句中检查输出信号的条件
【发布时间】:2019-11-02 14:42:46
【问题描述】:

我正在尝试检查输出的条件(可以稍后在代码中设置),但您似乎无法做到这一点。

如何在 if 语句中检查输出信号的条件?

entity turbine_action is
Port (  freq550 : in STD_LOGIC;
        freq650 : in STD_LOGIC;
        freq850 : in STD_LOGIC;
        freq950 : in STD_LOGIC;
        user_ip : in STD_LOGIC;
        mild : out STD_LOGIC;
        aggressive : out STD_LOGIC;
        brake : out STD_LOGIC;
        alarm : out STD_LOGIC;
        clock : in STD_LOGIC);
end turbine_action;

architecture Behavioral of turbine_action is

type state_type is (s0, s1, s2);
signal current_s, next_s : state_type;

begin

process (clock)
begin
    if (rising_edge(clock)) then
        current_s <= next_s;    --change state according to next state logic
    end if;
end process;


process (current_s, freq550, freq650, freq850, freq950, user_ip)
begin
    case current_s is
        when s0 =>
        if (user_ip = '1') then
            if (freq550 = '1') then
                brake <= '1';
                alarm <= '1';
                -- ADD DELAY delay(1000);
            end if;
            if (freq650 = '1') then
                if (mild = '1') then
                    aggressive <= '1';
                end if;
            end if;

end Behavioral;

【问题讨论】:

  • 在早期版本的 VHDL 编译器中不允许读取输出。解决方案是制作一个可以在任何地方使用的本地信号。您也可以阅读它。然后在一个地方将本地信号分配给您的输出。或者您可以查看是否可以访问更新的 VHDL 编译器。由于过于复杂而无法在评论中解释,请不要将输出设为buf 类型。理论上是可以的。实际上,任何有经验的人都知道这样做。
  • A minimal reproducible example 包含重现特定错误的完整示例。这缺少完整的 case 语句、if 语句和错误属于问题的过程以及上下文子句。问题是重复的(搜索词 [vhdl]“无法读取输出”),例如VHDL - Phase Accumulator with feedback 带有所示的解决方案。 Oldfart 的 mode buffer 缺乏广泛的综合供应商工具支持,而在 -2008 年 mode out 提供与模式 buffer 相同的语义 - 可以评估 mild .
  • 这能回答你的问题吗? VHDL - Phase Accumulator with feedback

标签: vhdl


【解决方案1】:

假设你将使用这个:

alarm : out STD_LOGIC;

你可以定义为inout信号:

alarm : inout STD_LOGIC;

或者您可以将其与信号连接(假设您定义了 std_logic 信号):

local_signal <= alarm; 

然后你可以检查local_signal的情况。

通常输出向量会转到一个顶级 vhd 文件,并且可以在该 vhd 文件中控制它们,因为它们是作为输入向量来的。

【讨论】:

    猜你喜欢
    • 2017-12-08
    • 2023-01-11
    • 1970-01-01
    • 2023-02-06
    • 1970-01-01
    • 1970-01-01
    • 2012-12-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多