mahmood.n
Member level 5
Trying to use "procedure" in a vhdl code, I have been confused with using variables or signals. Consider the following code
It says: Formal "s" of class variable must be associated with a variable. If I use a variable in the process and then assign the variable to sum, then it will be OK. I wonder why I get that error. Does that mean, I have to pass only variables to a procedure? If the answer is yes, then why passing a(0) and .. as inputs don't have such problem.
Code:
entity proc_adder is
port( a,b: in bit_vector(1 downto 0);
cin: in bit;
sum: out bit_vector(1 downto 0);
cout: out bit);
end;
architecture proc of proc_adder is
procedure full_adder( a, b, c: in bit; s, co: out bit) is
begin
s := a xor b xor c;
co := (a and b) or (a and c) or (b and c);
end;
begin
process( a, b, cin )
variable carry: bit;
begin
full_adder( a(0), b(0), cin, sum(0), carry);
full_adder( a(1), b(1), carry, sum(1), carry);
end process;
end;
It says: Formal "s" of class variable must be associated with a variable. If I use a variable in the process and then assign the variable to sum, then it will be OK. I wonder why I get that error. Does that mean, I have to pass only variables to a procedure? If the answer is yes, then why passing a(0) and .. as inputs don't have such problem.