Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 在VHDL中按特定顺序映射数组子元素的端口?_Arrays_Vhdl_Wrapper - Fatal编程技术网

Arrays 在VHDL中按特定顺序映射数组子元素的端口?

Arrays 在VHDL中按特定顺序映射数组子元素的端口?,arrays,vhdl,wrapper,Arrays,Vhdl,Wrapper,因此,我正在为一个组件编写一个包装器。该组件有一些类似数组的输入 -- Definition in the original component array_1 : out std_logic_vector (1 downto 0); array_2 : out std_logic_vector (1 downto 0); 我试图在端口映射中将数组的子元素指定为 -- All foo1, foo2, bar1, bar2 are defined as output std_logic in w

因此,我正在为一个组件编写一个包装器。该组件有一些类似数组的输入

-- Definition in the original component
array_1 : out std_logic_vector (1 downto 0);
array_2 : out std_logic_vector (1 downto 0);
我试图在端口映射中将数组的子元素指定为

-- All foo1, foo2, bar1, bar2 are defined as output std_logic in wrapper port list
array_1 (0) =>   foo1,
array_2 (0) =>   bar1,
array_1 (1) =>   foo2,
array_2 (1) =>   bar2,
上述操作会产生一个错误,如:多次进行正式关联

但奇怪的是,下面的编译很好

array_1 (0) =>   foo1,
array_1 (1) =>   foo2,
array_2 (0) =>   bar1,
array_2 (1) =>   bar2,
如果我遗漏了什么,我找不到数组的子元素必须关联在一起的任何地方,但我找不到一个没有关联的示例。我知道我可以做后者,但我很好奇。任何帮助都将不胜感激

顺便说一句,这是我编的一个简短的例子。。。原始代码有50多个元素,但我已将问题缩小到这一点。谢谢你的帮助和建议。

A:

这给了我们:

ghdl-a--std=08关联元素。vhdl
assoc_元素。vhdl:30:30:端口“array_1”的非连续单个关联
ghdl:编译错误

除了沾沾自喜之外,还有一个工具提供了更好的错误信息,LRM参考-

IEEE标准1076-2008 6.5.7关联列表,6.5.7.1概述第16段:

正式接口对象应为明确声明的接口对象或此类接口对象的成员(见5.1)。在前一种情况下,这样一种形式被称为整体关联。在后一种情况下,应使用命名的关联来关联正式的和实际的;这种形式的子元素称为单独关联的。此外,显式声明的接口对象的每个标量子元素应与同一关联列表中的实际(或其子元素)精确关联一次,并且所有此类关联应在该关联列表中以连续顺序出现。将接口对象的切片或子元素(或其切片)关联的每个关联元素应使用本地静态名称标识形式


这告诉我们元素关联必须是连续的,这是您显示的代码段中的情况,它确实在分析,而失败的元素关联由元素交错。

将这个小示例扩展到任何人都可以(失败)编译的MCVE。。。IEEE标准1076-1993 4.3.2.2协会列表第14段“形式化对象可以是显式声明的接口对象或成员…”。。。在后一种情况下,必须使用命名关联来关联正式和实际;这种形式的子元素称为单独关联的。此外,显式声明的接口对象的每个标量子元素必须与同一关联列表中的一个实际(或其子元素)精确关联一次,并且所有此类关联必须以连续序列的形式出现在该关联列表中。@user1155120:我被弄糊涂了,为VHDL-2008编译了错误的源代码。ghdl确实(正如您所指出的那样正确)拒绝了此代码,而不考虑
--std=08
标志,报告
端口“array_1”的非连续单个关联然后我在LRM中迷路了,没有找到4.3.2.2。谢谢你找到它!(删除先前的评论。)
library ieee;
use ieee.std_logic_1164.all;

entity assoc_elements is
    port (
        array_1 : out std_logic_vector (1 downto 0);
        array_2 : out std_logic_vector (1 downto 0)  -- ;
    );
end entity;

architecture nothing of assoc_elements is
begin
end architecture;

library ieee;
use ieee.std_logic_1164.all;

entity element_assoc_test is
end entity;

architecture test of element_assoc_test is
    signal foo1, foo2, bar1, bar2: std_logic;
begin
ASSOC:
    entity work.assoc_elements
        port map (
            -- All foo1, foo2, bar1, bar2 are defined as output std_logic in wrapper port list
            array_1 (0) =>   foo1,
            array_2 (0) =>   bar1,
            array_1 (1) =>   foo2,
            array_2 (1) =>   bar2    -- ,
        );
end architecture;