【问题标题】:delayed signal cause unexpected behavior in VHDL延迟信号导致 VHDL 中出现意外行为
【发布时间】:2015-03-19 17:23:54
【问题描述】:

当信号不正确时,我的程序将停止。但是,输入信号需要时间来重新生成,并且该过程会重用旧信号。它会导致代码停止并且无法恢复操作。

例如

process(A,B,startRun) 
begin
if (A = 1) then
    case (B) is
    when 0 => 
        -- do something
    when others =>  
    if(startRun = '1')then
        halt <= '1';
    end if;
end case;
else
    -- do something else
end if;
end process;

我的问题是当A = 1,但B是旧值,比如1。B成为新值后,halt总是设置为1。程序最终会停止。我该如何解决这个问题?

【问题讨论】:

  • 一方面它看起来好像 startRun 从敏感性列表中丢失。或者,使用时钟进程和同步设计,大大简化生活。
  • 你应该在每条路径中分配暂停(当 B = 0 时,当 A /= 1 时),否则你会得到一个闩锁。
  • 顺便说一句:“程序最终会停止”在 HDL 的上下文中没有意义,因为严格来说,没有程序。它是一种具有特定架构的硬件,通过它运行一些信号。所以没有什么可以“停止”那里。

标签: vhdl


【解决方案1】:

我同意“Jonathan Drolet”。我看不到您将信号halt 重置为零的位置。设置 halt 后,始终为 1 并且没有重置语句。 您可以在不需要暂停时使用else 语句将halt 重置为零:

process(A,B,startRun) 
begin
    if (A = 1) then
        case (B) is
            when 0 =>
                halt <= '0';
                -- do something
            when others =>  
                if(startRun = '1')then
                    halt <= '1';
                else
                    halt <= '0';
                end if;
        end case;
    else
        halt <= '0';
        -- do something else
    end if;
end process;

您也可以在进程开始时将halt 重置为0,但如果(A = 1B /= 0startRun = '1')请确保将hlat 设置为1,因为信号或在进程结束时应用端口分配:

process(A,B,startRun) 
begin
    halt <= '0';
    if (A = 1) then
        case (B) is
            when 0 =>
                -- do something
            when others =>  
                if(startRun = '1')then
                    halt <= '1';
                end if;
        end case;
    else
        -- do something else
    end if;
end process;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多