如何修复“错误:std_ulogic类型的预期表达”?

发布于 2025-01-23 23:28:32 字数 2014 浏览 0 评论 0原文

我正在学习VHDL,我尝试用两个文件来实现“ adder_array_generic_tree”,第一个文件“ user_defined_type_pkg.vhd” contanct:and contance:

library IEEE;
use ieee.numeric_std.all;

package user_defined_type_pkg is
    type signed_vector is array (natural range<>) of signed;
end package;

and第二文件“ adder_array_generic_tree.vhd”包含:

library IEEE;
use IEEE.numeric_std.all;
use ieee.math_real.all;
use work.user_defined_type_pkg.all;

entity adder_array_generic_tree is
    generic (
        NUM_INPUTS: natural := 10;
        NUM_BITS: natural := 7);
    port (
        x: in signed_vector(0 to NUM_INPUTS-1)(NUM_BITS-1 downto 0);
        sum: out signed(NUM_BITS + integer(ceil(log2(real(NUM_INPUTS))))-1 downto 0));
end adder_array_generic_tree;

architecture tree_type_generic of adder_array_generic_tree is
    constant LAYERS: natural := integer(ceil(log2(real(NUM_INPUTS))));
    constant PWR_OF_TWO: natural := 2**LAYERS;
    alias EXTRA_BITS: natural is LAYERS;
begin
    process (all)
        variable accum: signed_vector(0 to PWR_OF_TWO-1)(NUM_BITS+EXTRA_BITS-1 downto 0);
    begin
        loop1: for i in 0 to NUM_INPUTS-1 loop
            accum(i) := resize(x(i), NUM_BITS+EXTRA_BITS);
        end loop loop1;
        accum(NUM_INPUTS to PWR_OF_TWO-1) := (others => (others => '0'));
        
        loop2: for j in 1 to LAYERS loop
            loop3: for i in 0 to PWR_OF_TWO/(2**j)-1 loop
                accum(i) := accum(2*i) + accum(2*i+1);
            end loop loop3;
        end loop loop2;
        sum <= accum(0);
    end process;
end tree_type_generic;

但是,第二个问题是 :文件:

accum(NUM_INPUTS to PWR_OF_TWO-1) := (others => (others => '0'));

'0'在上划线的Vivado红色,说“错误:std_ulogic类型的预期表达”。该文件类型是VHDL 2008,XA7S6CPGA196-2I被采用。

I'm learning VHDL, I tried to implement "adder_array_generic_tree" with two files, the first file "user_defined_type_pkg.vhd" contain:

library IEEE;
use ieee.numeric_std.all;

package user_defined_type_pkg is
    type signed_vector is array (natural range<>) of signed;
end package;

and the second file "adder_array_generic_tree.vhd" contains:

library IEEE;
use IEEE.numeric_std.all;
use ieee.math_real.all;
use work.user_defined_type_pkg.all;

entity adder_array_generic_tree is
    generic (
        NUM_INPUTS: natural := 10;
        NUM_BITS: natural := 7);
    port (
        x: in signed_vector(0 to NUM_INPUTS-1)(NUM_BITS-1 downto 0);
        sum: out signed(NUM_BITS + integer(ceil(log2(real(NUM_INPUTS))))-1 downto 0));
end adder_array_generic_tree;

architecture tree_type_generic of adder_array_generic_tree is
    constant LAYERS: natural := integer(ceil(log2(real(NUM_INPUTS))));
    constant PWR_OF_TWO: natural := 2**LAYERS;
    alias EXTRA_BITS: natural is LAYERS;
begin
    process (all)
        variable accum: signed_vector(0 to PWR_OF_TWO-1)(NUM_BITS+EXTRA_BITS-1 downto 0);
    begin
        loop1: for i in 0 to NUM_INPUTS-1 loop
            accum(i) := resize(x(i), NUM_BITS+EXTRA_BITS);
        end loop loop1;
        accum(NUM_INPUTS to PWR_OF_TWO-1) := (others => (others => '0'));
        
        loop2: for j in 1 to LAYERS loop
            loop3: for i in 0 to PWR_OF_TWO/(2**j)-1 loop
                accum(i) := accum(2*i) + accum(2*i+1);
            end loop loop3;
        end loop loop2;
        sum <= accum(0);
    end process;
end tree_type_generic;

however, there is a problem in line 26 of the second file:

accum(NUM_INPUTS to PWR_OF_TWO-1) := (others => (others => '0'));

the Vivado red-underlined on '0', says "Error: Expected expression of type std_ulogic". The file type is VHDL 2008, xa7s6cpga196-2I is adopped.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小姐丶请自重 2025-01-30 23:28:32

您没有包含软件包ieee.std_logic_1164,因此std_ulogic看不到。 '0'的唯一可见选项是contracbit来自std.Standard.Standard软件包,因此,错误AS ieee.numeric_std.signedieee.std_logic_1164.std_logic的数组。

要修复,只需添加行:

use ieee.std_logic_1164.all

在文件的顶部。

You didnt include the package ieee.std_logic_1164 and hence std_ulogic is not visible. The only visible option for '0' is character or bit from the std.standard package, hence the error as ieee.numeric_std.signed is an array of ieee.std_logic_1164.std_logic.

To fix, simply add the line:

use ieee.std_logic_1164.all

at the top of the file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文