使用 SystemVerilog 中的二维数组实例化 VHDL 实体

Instantiate VHDL entity with 2D array from SystemVerilog

关于如何在 VHDL 和 SystemVerilog 之间传递二维数组的文档似乎很少。我在 VHDL 中有以下类型的端口:

package my_package is
    type my_array_t is array (natural range <>) of std_logic_vector(N-1 downto 0);
end my_package

entity my_entity is
    port(
        my_input  : in  my_array_t(M-1 downto 0);
        my_output : out my_array_t(M-1 downto 0);
    );
end entity;

以及以下 SystemVerilog 信号:

wire [N-1:0] my_input_s[M-1:0];
wire [N-1:0] my_output_s[M-1:0];

我相信这两种类型是完全等价的。但是,我不能在没有错误的情况下相互交流。从 SystemVerilog 实例化 VHDL 模块:

my_entity my_entity_inst(
    .my_input(my_input_s),
    .my_output(my_output_s)
);

我得到的错误是“类型'my_array_t'的正式端口'my_input'与实际类型'logic'”不匹配,类似地输出信号。我在 SystemVerilog 中尝试了不同的数组类型组合(完全打包,完全解包),但 none 有效。请注意,在我的例子中,我没有更改 VHDL 声明的自由,我必须找到一种方法使其仅在 SystemVerilog 中工作。所以,this question帮不了我。

如何以最直接的方式从 SystemVerilog 实例化我的 VHDL 模块?

要在 Verilog 或 SV 中成功实例化 VHDL,请坚持使用 VHDL 中的基本类型(原始 VHDL 中内置的类型,而不是自定义包),例如 std_logic 和 std_logic 矢量。

对于这种无法使用自定义端口类型修改 VHDL 文件的情况,我建议编写一个 VHDL 包装器 (mydesign_wrapper.vhd),它实例化使用自定义类型的实体并将端口转换为 std_logic 和 std_logic_vector 类型用于包装器设计的 top/entity。在 Verilog 或 SystemVerilog 文件中实例化新的包装文件。 std_logic_vector 数组将使用包装器表示为多个 std_logic_vector 端口。

Verilog/SV 内部没有 VHDL 标准,因此支持有限,并且因工具、供应商和版本而异。