integer_vector 作为 NULL 数组

El-*_*-SB 1 vhdl

如何传递等于零integer_vector的空值length?(= 空数组)

\n

背景:

\n

在测试平台内,我\xc2\xb4d喜欢对不同类型的事务使用一个过程。像这样的东西:

\n
entity foo is\nend entity foo;\n\narchitecture bar of foo is\n  procedure Transaction (\n        constant RX_BYTES     : integer_vector\n        ) is\n    begin\n        report "RX_BYTES\'length = " & to_string(RX_BYTES\'length);\n    end procedure;\nbegin\n\n  Transaction(RX_BYTES => ""); -- it\xc2\xb4s about this line\n\nend architecture bar;\n
Run Code Online (Sandbox Code Playgroud)\n

我有这样的想法,但这不起作用:

\n
Transaction(RX_BYTES => "");\n
Run Code Online (Sandbox Code Playgroud)\n

模型模拟错误:

\n
** Error: C:/Users/sbuhrow/Desktop/NULL_Vector.vhd(13): (vcom-1600) No feasible entries for subprogram "Transaction".\n
Run Code Online (Sandbox Code Playgroud)\n

Ren*_*let 5

只需使用一个空范围:

Transaction(RX_BYTES => (1 to 0 => 0), ...);
Run Code Online (Sandbox Code Playgroud)

演示:

$ cat foo.vhd
entity foo is
end entity foo;

architecture bar of foo is
  procedure p(constant c: integer_vector) is
  begin
    report "c'length = " & to_string(c'length);
  end procedure p;
begin
  p(c => (0 downto 1 => 0));
end architecture bar;

$ ghdl -a --std=08 foo.vhd
$ ghdl -r --std=08 foo
foo.vhd:7:5:@0ms:(report note): c'length = 0
Run Code Online (Sandbox Code Playgroud)

注意:如果您经常使用这样的空整数向量,您也可以声明一个常量:

constant empty_iv: integer_vector := (1 to 0 => 0);
Run Code Online (Sandbox Code Playgroud)

并在任何需要的地方使用它。