【发布时间】:2017-08-13 20:30:49
【问题描述】:
我正在尝试创建一个长度减小的 std_logic_vectors 数组。我尝试使用通用 std_logic_vector 创建一个数组,然后使用 generate 语句创建向量。
architecture behavioral of dadda_mul_32bit is
type and_planes is array (0 to 31) of std_logic_vector;
begin
generate_and_plane:
for i in 0 to 31 generate
and_planes(i) <= and_vector(a, b(i), i);
end generate generate_and_plane;
end behavioral;
以及返回通用 std_logic_vector 的函数:
function and_vector(vec: std_logic_vector; x: std_logic; length: natural) return std_logic_vector is
variable result: std_logic_vector(length - 1 downto 0);
begin
for i in 0 to length - 1 loop
result(i) := vec(i) and x;
end loop;
return result;
end function;
我是否错误地使用了 generate 语句?
【问题讨论】:
-
为什么你的 AND 结果不是 a 的长度?