【问题标题】:Handle mutliple write operations to the same signal in vhdl在 vhdl 中处理对同一信号的多个写操作
【发布时间】:2020-06-13 11:41:28
【问题描述】:

我有 n 个组件来计算某个哈希值,但我不知道它们何时会完成。完成后,他们应该将找到的哈希发送到主组件,在那里,哪个哈希首先到达主组件并不重要,只要他收到一个。

在两个或更多组件同时完成计算其哈希而不需要 n 个信号(每个哈希一个)进入主节点的情况下,有没有一种方法可以避免竞争条件?

我尝试在主组件和 n 个组件之间实现以下内容,但意识到这没有多大意义,因为仍然存在所有组件写入相同 hash_in 信号的竞争条件。

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

-- System to connect multiple components to one master
-- When a component finds a hash, it writes to hash_in. Bus saves hash_in to an internal signal
-- and waits until master_ready is set to 1 to pass it the next signal
-- (Master sets master_ready to 0 while it's processing the last hash).

entity connector is
  port(
    -- The signal that all n components write to
    hash_in             : in    std_logic_vector(255 downto 0);
    -- Signal indicating if master is ready for the next hash
    master_ready        : in    std_logic;
    -- Hash we give to master
    hash_out            : out   std_logic_vector(255 downto 0)
  );
end connector;

architecture arch of connector is

  signal hash_internal : std_logic_vector(255 downto 0) := (others => '0');

begin

  hash_out <= hash_internal;

  process(master_ready, hash_in)
  begin

    if(master_ready) then
      hash_internal <= hash_in;
    end if;

  end process;

end architecture;

提前致谢!

【问题讨论】:

  • 让多个设备写入同一个信号会在同一个信号上创建多个驱动程序。您需要一个可以根据所有就绪信号的解码选择适当组件的多路复用器。解码中可以应用优先级。

标签: signals vhdl


【解决方案1】:

根据您的问题,我认为您必须最小化最终设计的尺寸。

VHDL(仅)是描述硬件设计的一种方式。因此,在编写任何 VHDL 之前,您应该确定如何在目标技术中以最小的尺寸实现该功能。

目标技术不太可能支持具有多个驱动程序的信号,因此这意味着您不能在尝试使用此类功能的 VHDL 中编写设计,因为综合工具将无法映射 VHDL 设计到目标技术。

正如 Tricky 在评论中所写,可能最小的设计是使用一个多路复用器,该多路复用器可以根据所有就绪信号的解码选择适当的组件。

它可能看起来像是一个相当大的解决方案,但如果这是目标技术允许的最佳解决方案,那么它就是最小的解决方案。

So 按钮行:了解目标技术允许什么,编写 VHDL,以便综合工具将设计有效地映射到目标技术,最后检查结果实现是否符合预期。

【讨论】:

    猜你喜欢
    • 2018-01-07
    • 1970-01-01
    • 2017-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多