actual 必须是静态名称——端口映射中的索引向量
actual must be a static name -- indexing vector in portmap
我认为这个错误是GHDL 不支持VHDL 2008 的结果。错误发生在第27/28 行,当ff0 D 被赋给向量din 的值时。从端口映射中索引向量的正确方法是什么?
我创建了 count_temp 来尝试绕过错误,但它没有帮助,我宁愿没有额外的变量。谢谢
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity conv_encoder is
generic (d_width : positive := 16);
port (
clk : in std_logic;
din : in std_logic_vector(d_width-1 downto 0);
ff_set : in std_logic;
count : in std_logic_vector(5 downto 0);
dout : out std_logic_vector(d_width*2-1 downto 0));
end conv_encoder;
architecture behavioral of conv_encoder is
component d_ff is
port ( clk, ff_set, D : in std_logic;
Q : out std_logic);
end component;
signal a, b : std_logic;
signal count_temp : integer range 0 to d_width;
begin
count_temp <= to_integer(unsigned(count));
ff0 : d_ff
port map (clk => clk,
ff_set => ff_set,
D => din(count_temp),
-- D => din(to_integer(unsigned(count))),
Q => a);
ff1 : d_ff
port map (clk => clk,
ff_set => ff_set,
D => a,
Q => b);
-- conv encoder is r=1/2 A=111 B=101
process (clk, ff_set)
begin
if (ff_set = '0') then
if (rising_edge(clk)) then
dout(count_temp*2) <= din(count_temp) xor a xor b;
dout(count_temp*2+1) <= din(count_temp) xor b;
end if;
end if;
end process;
end behavioral;
错误:
ghdl -a conv_encoder.vhd
conv_encoder.vhd:28:30: actual must be a static name
ghdl: compilation error
这不是 GHDL 中的 VHD2008 支持问题。你解决这个问题的两次尝试在概念上很简单,但正如错误所说,你不能将端口连接到非静态的东西。用简单的英语来说,这意味着您不能将端口与某些组合逻辑相关联。连D => not din(0)
都不允许。
我在这里要做的是包括一个多路复用器。这可以很简单:
signal selected_din : std_logic;
...
selected_din <= din(count_temp);
然后您可以将行 D => din(count_temp),
替换为 D => selected_din,
。
您也可以编写一个 mux
函数,然后您的行将看起来像 D => mux(din, count_temp),
。该函数将根据 count_temp
.
的值 return din
中的一个元素
根据@user1155120 的评论,在撰写本文时,您的 GHDL 编译器不支持此 'function' 方法。
我认为这个错误是GHDL 不支持VHDL 2008 的结果。错误发生在第27/28 行,当ff0 D 被赋给向量din 的值时。从端口映射中索引向量的正确方法是什么?
我创建了 count_temp 来尝试绕过错误,但它没有帮助,我宁愿没有额外的变量。谢谢
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity conv_encoder is
generic (d_width : positive := 16);
port (
clk : in std_logic;
din : in std_logic_vector(d_width-1 downto 0);
ff_set : in std_logic;
count : in std_logic_vector(5 downto 0);
dout : out std_logic_vector(d_width*2-1 downto 0));
end conv_encoder;
architecture behavioral of conv_encoder is
component d_ff is
port ( clk, ff_set, D : in std_logic;
Q : out std_logic);
end component;
signal a, b : std_logic;
signal count_temp : integer range 0 to d_width;
begin
count_temp <= to_integer(unsigned(count));
ff0 : d_ff
port map (clk => clk,
ff_set => ff_set,
D => din(count_temp),
-- D => din(to_integer(unsigned(count))),
Q => a);
ff1 : d_ff
port map (clk => clk,
ff_set => ff_set,
D => a,
Q => b);
-- conv encoder is r=1/2 A=111 B=101
process (clk, ff_set)
begin
if (ff_set = '0') then
if (rising_edge(clk)) then
dout(count_temp*2) <= din(count_temp) xor a xor b;
dout(count_temp*2+1) <= din(count_temp) xor b;
end if;
end if;
end process;
end behavioral;
错误:
ghdl -a conv_encoder.vhd
conv_encoder.vhd:28:30: actual must be a static name
ghdl: compilation error
这不是 GHDL 中的 VHD2008 支持问题。你解决这个问题的两次尝试在概念上很简单,但正如错误所说,你不能将端口连接到非静态的东西。用简单的英语来说,这意味着您不能将端口与某些组合逻辑相关联。连D => not din(0)
都不允许。
我在这里要做的是包括一个多路复用器。这可以很简单:
signal selected_din : std_logic;
...
selected_din <= din(count_temp);
然后您可以将行 D => din(count_temp),
替换为 D => selected_din,
。
您也可以编写一个 mux
函数,然后您的行将看起来像 D => mux(din, count_temp),
。该函数将根据 count_temp
.
din
中的一个元素
根据@user1155120 的评论,在撰写本文时,您的 GHDL 编译器不支持此 'function' 方法。