gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 23:18:28 27 4
gpt4 key购买 nike

我正在尝试初始化一个 (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 的定义文字也是免费的。

关于VHDL-2008 初始化 ufixed 在modelsim 中给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43367363/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com