G
G Iveco
Guest
Hello there,
Following code I want to convert std_logic_vector of any bit-width into
signed
numbers. My need is that it should be versatile as I can't code same
function
for every bit-width..
Thank you for your ideas.
function slv_2_signed(
data: in std_logic_vector)
return signed is
variable index : integer;
variable data_signed: signed(data'range-1 downto 0);
begin
for index in data'range loop
data_signed(index) := data(index);
end loop;
return data_signed;
end function slv_2_signed;
In Modelsim, I see the following errors.
# ** Error: ../TB/coms_fir_sim.vhd(121): (vcom-1078) Identifier "signed" is
not directly visible.
# Potentially visible declarations are:
# ieee.numeric_bit.signed (type declaration)
# ieee.std_logic_arith.signed (type declaration)
# ** Error: ../TB/coms_fir_sim.vhd(121): Function cannot return anonymous
subtype.
# ** Error: ../TB/coms_fir_sim.vhd(123): Attribute name with designator
"range" cannot be left operand of infix expression "-".
# ** Error: ../TB/coms_fir_sim.vhd(123): Illegal use of range.
# ** Error: ../TB/coms_fir_sim.vhd(123): Bad expression in left bound of
range expression.
# ** Error: ../TB/coms_fir_sim.vhd(123): (vcom-1078) Identifier "signed" is
not directly visible.
# Potentially visible declarations are:
# ieee.numeric_bit.signed (type declaration)
# ieee.std_logic_arith.signed (type declaration)
# ** Error: ../TB/coms_fir_sim.vhd(137): No feasible entries for subprogram
"to_integer".
# ** Error: ../TB/coms_fir_sim.vhd(174): VHDL Compiler exiting
# C:/Programs/Modeltech_xe_starter/win32xoem/vcom failed.
Following code I want to convert std_logic_vector of any bit-width into
signed
numbers. My need is that it should be versatile as I can't code same
function
for every bit-width..
Thank you for your ideas.
function slv_2_signed(
data: in std_logic_vector)
return signed is
variable index : integer;
variable data_signed: signed(data'range-1 downto 0);
begin
for index in data'range loop
data_signed(index) := data(index);
end loop;
return data_signed;
end function slv_2_signed;
In Modelsim, I see the following errors.
# ** Error: ../TB/coms_fir_sim.vhd(121): (vcom-1078) Identifier "signed" is
not directly visible.
# Potentially visible declarations are:
# ieee.numeric_bit.signed (type declaration)
# ieee.std_logic_arith.signed (type declaration)
# ** Error: ../TB/coms_fir_sim.vhd(121): Function cannot return anonymous
subtype.
# ** Error: ../TB/coms_fir_sim.vhd(123): Attribute name with designator
"range" cannot be left operand of infix expression "-".
# ** Error: ../TB/coms_fir_sim.vhd(123): Illegal use of range.
# ** Error: ../TB/coms_fir_sim.vhd(123): Bad expression in left bound of
range expression.
# ** Error: ../TB/coms_fir_sim.vhd(123): (vcom-1078) Identifier "signed" is
not directly visible.
# Potentially visible declarations are:
# ieee.numeric_bit.signed (type declaration)
# ieee.std_logic_arith.signed (type declaration)
# ** Error: ../TB/coms_fir_sim.vhd(137): No feasible entries for subprogram
"to_integer".
# ** Error: ../TB/coms_fir_sim.vhd(174): VHDL Compiler exiting
# C:/Programs/Modeltech_xe_starter/win32xoem/vcom failed.