Vhdl 使用for generate实现或门

Vhdl 使用for generate实现或门,vhdl,Vhdl,我已经用泛型参数实现了一个或门,但是我目前在用for-generate实现它时遇到了一些问题 entity OR_gate is generic( n : natural := 2); port(x : in std_logic_vector(1 to n); z : out std_logic); end OR_gate; architecture Behavioral of OR_gate is begin process(x) variable temp : s

我已经用泛型参数实现了一个或门,但是我目前在用for-generate实现它时遇到了一些问题

entity OR_gate is
generic( n : natural := 2);
port(x : in std_logic_vector(1 to n);
      z : out std_logic);
end OR_gate;
architecture Behavioral of OR_gate is
begin
    process(x)
    variable temp : std_logic;
    begin
    temp := '0';
    G1: for i in 1 to N loop
        temp := temp or x(i);
    end generate G1;
z <= temp;
end process;
end Behavioral;
实体或门是
通用(n:自然:=2);
端口(x:std_逻辑_向量中的(1到n);
z:输出标准(U逻辑);
结束或关闭门;
Oru门的架构是
开始
过程(x)
可变温度:标准逻辑;
开始
温度:='0';
G1:对于1到N循环中的i
温度:=温度或x(i);
末端生成G1;
z在进程内部进行时,它不是生成(并发)循环。在本例中,它只是一个常规循环,语法中没有
generate
,因此:

process(x)
  variable temp : std_logic;
begin
  temp := '0';
  G1 : for i in 1 to N loop
    temp := temp or x(i);
  end loop G1;
  z <= temp;
end process;
最后,如果这些工具支持VHDL-2008定义的逻辑简化运算符,那么您可以将其简化为:

z <= or x;
z
z <= or x;