大神想问下 这个循环哪里出错了 (n位加法器)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity adder is
generic(N:integer);
Port ( cin: in STD_LOGIC;
a,b: in STD_LOGIC_vector(N downto 1);
c:out std_logic_vector(N downto 1);
cout:out std_logic
);
end adder;
architecture behaviour of adder is
signal m:std_logic_vector(N-1 downto 1);
begin
c(1) <= a(1) xor b(1) xor cin;
m(1) <= (a(1) AND b(1)) OR (a(1) AND cin) OR (b(1) AND cin);
for i in 2 TO N-1 loop
c(i) <= a(i) XOR b(i) XOR m(i-1);
m(i) <= (a(i)AND b(i)) OR (m(i-1) AND a(i)) OR (m(i-1) AND b(i));
end loop;
c(N) <= a(N) XOR b(N) XOR m(N-1);
cout <= (a(N) AND b(N)) OR (a(N)AND m(N-1)) OR (b(N) AND m(N-1));
end behaviour;