我是VHDL的新手。
我在这段代码中有一个错误:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity AandB is
Port ( a : in STD_LOGIC_vector(31 downto 0);
b : in STD_LOGIC_vector(31 downto 0);
salida : out STD_LOGIC_vector(31 downto 0)
);
end AandB;
architecture Behavioral of AandB is
begin
for i in 0 to 31 loop
salida(i) <= a(i) and b(i);
end loop;
end Behavioral;错误是这样的:
ERROR:HDLCompiler:806 - Line 43: Syntax error near "for".
ERROR:HDLCompiler:69 - Line 45: <i> is not declared.
ERROR:HDLCompiler:806 - Line 47: Syntax error near "generate".
ERROR:HDLCompiler:854 - Line 39: Unit <behavioral> ignored due to previous errors.我已经搜索了这里的输入代码`前3个错误。我没有注意到" for“语句的语法错误是什么;它假定是在循环中间接声明的;不知道"generate”中的错误。
帮帮忙?
发布于 2017-03-11 03:09:01
ThirtyTwoAnd: for i in 0 to 31 generate
salida(i) <= a(i) and b(i);
end generate ThirtyTwoAnd;发布于 2017-03-19 04:32:20
吉姆说的话甚至可以简化。ieee.std_logic_1164实际上定义了:
FUNCTION "and" ( l,r : std_logic_vector ) RETURN std_logic_vector;所以在等长向量的情况下,你可以这样写:
salida <= "and"(a, b);但这也是可行的:
salida <= a and b;https://stackoverflow.com/questions/42724988
复制相似问题