类型 std_logic 不是数组类型,无法索引

Type std_logic is not an array type and cannot be indexed

检查此代码的语法:在第 12 行和第 14 行给了我 "Type std_logic is not an array type and cannot be indexed."。

为什么?!

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity Tot_and_module is
Port ( s : in  STD_LOGIC_VECTOR(0 to 39);
res : out  STD_LOGIC);
end Tot_and_module;

architecture Behavioral of Tot_and_module is
signal temp: std_logic_vector(0 to 39);
begin
temp(0) <= res(0);
gen: for i in 1 to 39 generate
temp(i) <= temp(i-1) and res(i);
end generate; 
res <= temp(39);
end Behavioral;

res 是 std_logic - 一位。 temp 和 s 是 std_logic_vectors - std_logic

类型的数组

你有:

temp(0) <= res(0);

这是不可能的,因为 res 不是数组。修复它:

temp(0) <= res;