I am trying to create a 16-bit adder using 2-bit adders as components (which themselves use 1-bit adder as component). However, my code doesn't compile in Quartus II. Can someone help me please? Thank you very much!
My project is consisted of 3 files: bit_adder.vhd, add2.vhd and add16.vhd. The error happens in add16.vhd:
--- bit_adder.vhd
-- description of 1 bit adder
LIBRARY IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity BIT_ADDER is
port( a, b, cin : in STD_LOGIC;
sum, cout : out STD_LOGIC );
end BIT_ADDER;
architecture BHV of BIT_ADDER is
begin
sum <= (not a and not b and cin) or
(not a and b and not cin) or
(a and not b and not cin) or
(a and b and cin);
cout <= (not a and b and cin) or
(a and not b and cin) or
(a and b and not cin) or
(a and b and cin);
end BHV;
-- below is add2.vhd, a 2-bit Adder. adds two 2-bit numbers together using two 1-bit adders
LIBRARY IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity add2 is
port( a, b : in STD_LOGIC_VECTOR(1 downto 0);
ans : out STD_LOGIC_VECTOR(1 downto 0);
cout : out STD_LOGIC );
end add2;
architecture STRUCTURE of add2 is
-- Component: two 1-bit adders
component BIT_ADDER
port( a, b, cin : in STD_LOGIC;
sum, cout : out STD_LOGIC );
end component;
signal c0, c1 : STD_LOGIC;
begin
c0 <= '0';
b_adder0: BIT_ADDER port map (a(0), b(0), c0, ans(0), c1);
b_adder1: BIT_ADDER port map (a(1), b(1), c1, ans(1), cout);
END STRUCTURE;
-- add16.vhd -- set as top level entity
LIBRARY IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity add16 is
port (a, b : in std_logic_vector(15 downto 0);
sum1 : out std_logic_vector(15 downto 0);
cout : out std_logic_VECTOR(1 downto 0)); --_vector);
end add16;
architecture arch16 of add16 is
component BIT_ADDER
port( a, b, cin : in STD_LOGIC;
sum, cout : out STD_LOGIC );
end component;
component add2
port (a, b : in STD_LOGIC_VECTOR(1 downto 0);
ans : out STD_LOGIC_VECTOR(1 downto 0);
cout : out STD_LOGIC );
end component;
signal c0, c1, c2, c3, c4, c5, c6, c7 : std_LOGIC_VECTOR(1 downto 0);
begin
c0 <='00'; --Error (10500): VHDL syntax error at add16.vhd(26) near text "'"; expecting "(", or an identifier, or unary operator
D_adder0: add2 port map (a(0), b(0), c0, sum1(0), c1);
D_adder1: add2 port map (a(1), b(1), c0, sum1(1), c2);
D_adder2: add2 port map (a(2), b(2), c0, sum1(2), c3);
D_adder3: add2 port map (a(3), b(3), c0, sum1(3), c4);
D_adder4: add2 port map (a(4), b(4), c0, sum1(4), c5);
D_adder5: add2 port map (a(5), b(5), c0, sum1(5), c6);
D_adder6: add2 port map (a(6), b(6), c0, sum1(6), c7);
D_adder7: add2 port map (a(7), b(7), c0, sum1(7), cout);
end arch16;