【问题标题】:VHDL, passing a partial array of std_logic_vector into an instantiated port mapVHDL,将 std_logic_vector 的部分数组传递到实例化的端口映射中
【发布时间】:2019-11-26 01:43:38
【问题描述】:

考虑下面的代码

library ieee;
use ieee.std_logic_1164.all;

package pkg is
    type foo is (A, B, C);
    type foo_vector is array (foo) of std_logic_vector;
end package;

实体具有以下端口的情况

library ieee;
use ieee.std_logic_1164.all;

entity baz is 
port (iInput : in foo_vector;
      oOutput : out foo_vector);
end;

它是由一个顶级模块实例化的。现在的问题是我怎样才能只将 bar 的 std_logic_vectors 的一部分传递给 baz 实例?尝试使用(打开)时编译失败

library ieee;
use ieee.std_logic_1164.all;

entity top is 
end;

architecture rtl of top is 
    signal bar: foo_vector (open) (31 downto 0) := (others => (others => '0'));
begin
    inst : entity work.baz 
    port map (iInput => bar(open)(3 downto 0), --The (open) here does not work
              oOutput => open);    
end;

【问题讨论】:

  • 折扣保留字 open 既不代表子类型指示也不代表离散范围。您需要一个中间信号或隐式信号(6.5.6.3 端口子句)作为表达式(在支持的情况下,可能不在综合中)。分配给中间或隐式信号的表达式将是数组聚合(9.3.3.3 数组聚合),其类型由上下文(9.3.3.1 通用)确定,不包括聚合本身(声明在限定表达式中使用的子类型或约束端口形式)。 (你真的应该显示错误信息)。
  • 如果没有限制所有范围,则无法声明对象。类似地,实体上的任何端口在实例化时都不能不受约束。因此,信号和实体实例化会出错,因为它们的范围不受限制。
  • @Tricky 不正确。 VHDL-2008 允许以这种方式声明信号。这是因为第一个范围已经在定义中受到限制。

标签: vhdl


【解决方案1】:

使用带有不受约束类型的锯齿状数组,您想部分地分配,这让您的生活变得非常困难。我会说:保持简单。只需使用三个单独的数组 foovec_Afoovec_Bfoovec_C

但是,如果您真的想按照自己的方式进行操作,则需要添加逻辑以将所需的信号发送到单独的 foo_vector。例如

library ieee;
use ieee.std_logic_1164.all;

package pkg is
    type foo is (A, B, C);
    type foo_vector is array (foo) of std_logic_vector;
end package;

use work.pkg.all;

entity baz is 
port (iInput : in foo_vector;
      oOutput : out foo_vector);
end;

architecture rtl of baz is begin
end architecture;

entity top is 
end;

library ieee;

architecture rtl of top is 
    use ieee.std_logic_1164.all;
    use work.pkg.all;
    signal bar: foo_vector(open)(31 downto 0) := (others => (others => '0'));
    signal bar_part: foo_vector(open)(3 downto 0);
    signal output : foo_vector(open)(0 downto 0);
begin
    conn : for i in foo generate
        bar_part(i) <= bar(i)(3 downto 0);
    end generate;

    inst : entity work.baz 
    port map (iInput => bar_part,
              oOutput => output);    
end;

将编译(VHDL-2008 模式)。

【讨论】:

  • 这个答案很公平
猜你喜欢
  • 1970-01-01
  • 2016-06-06
  • 1970-01-01
  • 1970-01-01
  • 2023-03-15
  • 1970-01-01
  • 1970-01-01
  • 2018-08-16
  • 2010-10-12
相关资源
最近更新 更多