VHDL-2008 初始化 ufixed 在 modelsim 中给出错误

VHDL-2008 initializing ufixed gives error in modelsim

我正在尝试初始化一个 (VHDL-2008) ufixed。但是下面的代码在Modelsim 10.5b

中给出了错误
entity test_e is
end entity;

library ieee;

architecture test_a of test_e is
    use ieee.fixed_pkg.all;
    constant value : ufixed(3 downto 0) := "0001";
begin
end architecture;

错误信息是:

Error: [file].vhd(8): Character literal '0' of type ieee.std_logic_1164.STD_ULOGIC is not visible at the place of this string literal.

我可以通过将定义行更改为

来修复它
constant value : ufixed(3 downto 0) := to_ufixed(1,3,0);

然后当我运行模拟时,值保持为“0001”....

我不知道我做错了什么。我一直在浏览网页寻找答案,但找不到。有人知道我做错了什么吗?

添加额外的 use 语句修复它:

entity test_e is
end entity;

library ieee;

architecture test_a of test_e is
    use ieee.std_logic_1164.all;                     -- HERE !
    use ieee.fixed_pkg.all;
    constant value : ufixed(3 downto 0) := "0001";
begin
end architecture;

这是错误还是正确的?我认为是正确的。 ufixed 是这样声明的:

type ufixed is array (integer range <>) of std_logic;

我相信您会同意,仅仅因为您输入了 use ieee.fixed_pkg.all 并不意味着您可以免费获得 std_logic 的定义。嗯,我 认为 只是因为你输入了 use ieee.fixed_pkg.all 意味着你没有得到 std_logic 文字 [=27= 的定义] 免费。