如何修复“错误:std_ulogic类型的预期表达”?
我正在学习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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有包含软件包
ieee.std_logic_1164
,因此std_ulogic
看不到。'0'
的唯一可见选项是contrac
或bit
来自std.Standard.Standard
软件包,因此,错误ASieee.numeric_std.signed
是ieee.std_logic_1164.std_logic
的数组。要修复,只需添加行:
在文件的顶部。
You didnt include the package
ieee.std_logic_1164
and hencestd_ulogic
is not visible. The only visible option for'0'
ischaracter
orbit
from thestd.standard
package, hence the error asieee.numeric_std.signed
is an array ofieee.std_logic_1164.std_logic
.To fix, simply add the line:
at the top of the file.