function args on procedures

O

Olaf Petzold

Guest
Hello,

I get the error:

** Error: (106): Type conversion functions are not allowed on
subprogram signal parameters.
** Error: (106): The formal parameter for a type conversion function
must be a constant.
** Error: (106): Cannot assign to signal 'b'.

for these code:

---8<---
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

package pkg_arithmetic is
procedure adder (
signal a, b : in std_logic_vector;
signal sum : out std_logic_vector;
signal carry_out : out std_logic);
procedure subtractor (
signal a, b : in std_logic_vector;
signal diff : out std_logic_vector;
signal carry_out : out std_logic);
function two_compl (signal slv : std_logic_vector)
return std_logic_vector;
end package pkg_arithmetic;

package body pkg_arithmetic is
-- binary adder -------------------------------
procedure adder (
signal a, b : in std_logic_vector;
signal sum : out std_logic_vector;
signal carry_out : out std_logic)
is
constant WIDTH : natural := a'high + 1;
variable tmp : std_logic_vector(WIDTH downto 0);
variable a_i, b_i : natural;
begin
assert (a'length = b'length) and (sum'length = a'length)
report "[E@adder] Operands of different lengths."
severity failure;
a_i := to_integer(unsigned(a));
b_i := to_integer(unsigned(b));
tmp := std_logic_vector(
to_unsigned(a_i + b_i, tmp'length));
sum <= tmp(WIDTH-1 downto 0);
carry_out <= tmp(WIDTH);
end procedure adder;
-- two's-complement ----------------------------
function two_compl (signal slv : std_logic_vector)
return std_logic_vector is
begin
return std_logic_vector(to_unsigned(
to_integer(unsigned(not slv)) + 1, slv'length));
end function two_compl;
-- binary subtractor ---------------------------
procedure subtractor (
signal a, b : in std_logic_vector;
signal diff : out std_logic_vector;
signal carry_out : out std_logic)
is
begin
assert (a'length = b'length) and (diff'length = a'length)
report "[E@subtractor] Operands of different lengths."
severity failure;
adder(a, two_compl(b), diff, carry_out); -- LINE 106
end procedure subtractor;

end package body pkg_arithmetic;
--->8---

using a local signal for two's complement inside substractor doesn't
work, using a variable for this too (compile error). Is there a way to
get it working?

Thanks and regards,
Olaf
 
Olaf Petzold a écrit :

Hello,

I get the error:

** Error: (106): Type conversion functions are not allowed on
subprogram signal parameters.
** Error: (106): The formal parameter for a type conversion function
must be a constant.
** Error: (106): Cannot assign to signal 'b'.
[...]

using a local signal for two's complement inside substractor doesn't
work, using a variable for this too (compile error). Is there a way to
get it working?
Since a and b are never written, makes them constant interfaces:
a, b : std_logic_vector;

JD.
 

Welcome to EDABoard.com

Sponsor

Back
Top