I am trying to code a 8 bit full adder using just concurrent code in VHDL but I got an error in the syntaxis. In the first instance i did this:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY concfulladder IS
PORT( A: IN std_logic_vector (7 DOWNTO 0);
B: IN std_logic_vector (7 DOWNTO 0);
Cin: IN std_logic_vector (7 DOWNTO 0);
Sum: OUT std_logic_vector(7 DOWNTO 0);
Cout: OUT std_logic_vector(7 DOWNTO 0));
END concfulladder;
ARCHITECTURE cfulladder OF concfulladder IS
BEGIN
sum(0) <= '0' WHEN (A(0) XOR B(0) XOR CIN(0)) = '0' ELSE
'1';
cout(0) <= '0' WHEN ((A(0) AND B(0)) OR (Cin(0) AND A(0)) OR (Cin(0) AND B(0))) = '0' ELSE
'1';
sum(1) <= '0' WHEN (A(1) XOR B(1) XOR CIN(1)) = '0' ELSE
'1';
cout(1) <= '0' WHEN ((A(1) AND B(1)) OR (Cin(1) AND A(1)) OR (Cin(1) AND B(1))) = '0' ELSE
'1';
sum(2) <= '0' WHEN (A(2) XOR B(2) XOR CIN(2)) = '0' ELSE
'1';
cout(2) <= '0' WHEN ((A(2) AND B(2)) OR (Cin(2) AND A(2)) OR (Cin(2) AND B(2))) = '0' ELSE
'1';
sum(3) <= '0' WHEN (A(3) XOR B(3) XOR CIN(3)) = '0' ELSE
'1';
cout(3) <= '0' WHEN ((A(3) AND B(3)) OR (Cin(3) AND A(3)) OR (Cin(3) AND B(3))) = '0' ELSE
'1';
sum(4) <= '0' WHEN (A(4) XOR B(4) XOR CIN(4)) = '0' ELSE
'1';
cout(4) <= '0' WHEN ((A(4) AND B(4)) OR (Cin(4) AND A(4)) OR (Cin(4) AND B(4))) = '0' ELSE
'1';
sum(5) <= '0' WHEN (A(5) XOR B(5) XOR CIN(5 )) = '0' ELSE
'1';
cout(5) <= '0' WHEN ((A(5) AND B(5)) OR (Cin(5) AND A(5)) OR (Cin(5) AND B(5))) = '0' ELSE
'1';
sum(6) <= '0' WHEN (A(6) XOR B(6) XOR CIN(6)) = '0' ELSE
'1';
cout(6) <= '0' WHEN ((A(6) AND B(6)) OR (Cin(6) AND A(6)) OR (Cin(6) AND B(6))) = '0' ELSE
'1';
sum(7) <= '0' WHEN (A(7) XOR B(7) XOR CIN(7)) = '0' ELSE
'1';
cout(7) <= '0' WHEN ((A(7) AND B(7)) OR (Cin(7) AND A(7)) OR (Cin(7) AND B(7))) = '0' ELSE
'1';
END cfulladder;
And all of this is correct I don't get any error. But, if I try to decrease the number of lines using a for loop I got an error:
PROCESS (all) IS
BEGIN
FOR I IN 0 TO 7 LOOP
Sum(I) <= '0' WHEN (A(I) XOR B(I) XOR CIN(I)) = '0' ELSE
'1';
Cout(I) <= '0' WHEN ((A(I) AND B(I)) OR (Cin(I) AND A(I)) OR (Cin(I) AND B(I))) = '0' ELSE
'1';
END LOOP;
END PROCESS;
The error is: Error near text WHEN; expecting ";". Searching a solution in internet I found that I can't use sequential code and concurrent code in the same program. Is there any solution for this problem?
Sum(I) <= A(I) XOR B(I) XOR CIN(I);andCout(I) <= (A(I) AND B(I)) OR (Cin(I) AND A(I)) OR (Cin(I) AND B(I));which provides the same values using overload operators defined in IEEE package std_logic_1164.allin the process sensitivity list you appear to be using -2008. Sequential conditional signal assignment statements may not be implemented in your particular tool environment. Likewise you may have missed passing the -2008 flag to the tool analyzer (compiler). Substituting the above process statement for the concurrent statements found in the architecture will successfully analyze (e.g. ghdl -a --std=08 concfulladder.vhdl, a recent ghdl commit 1.0-dev v0.37.0-773-gd85a1a9).