procedure

S

Salman Sheikh

What is wrong with this?

procedure gen_s (
variable si, di : in std_logic_vector(z_width downto 0);
variable so : out std_logic_vector(z_width downto 0)) is
begin
if si(z_width) = '1' then
so := (si(z_width-1 downto 0) & '0') + di;
else
so := (si(z_width-1 downto 0) & '0' - di);
end if;
end gen_s;


I get errors about the + and - being infix operators in Modelsim, below.

# ** Error: C:/dividers/div_uu.vhd(72): No feasible entries for infix op: "+"
# ** Error: C:/dividers/div_uu.vhd(72): Bad right hand side in assignment.
# ** Error: C:/dividers/div_uu.vhd(74): No feasible entries for infix op: "-"
# ** Error: C:/dividers/div_uu.vhd(74): Bad right hand side in assignment.


Thanks.

Salman
 
Y

Yves Deweerdt

Salman said:
What is wrong with this?

procedure gen_s (
variable si, di : in std_logic_vector(z_width downto 0);
variable so : out std_logic_vector(z_width downto 0)) is
begin
if si(z_width) = '1' then
so := (si(z_width-1 downto 0) & '0') + di;
else
so := (si(z_width-1 downto 0) & '0' - di);
end if;
end gen_s;


I get errors about the + and - being infix operators in Modelsim, below.

# ** Error: C:/dividers/div_uu.vhd(72): No feasible entries for infix op: "+"
# ** Error: C:/dividers/div_uu.vhd(72): Bad right hand side in assignment.
# ** Error: C:/dividers/div_uu.vhd(74): No feasible entries for infix op: "-"
# ** Error: C:/dividers/div_uu.vhd(74): Bad right hand side in assignment.


Thanks.

Salman

Salman,

You can't do calculations on a std_logic_vector. Try using signed or
unsigned in stead.

Kind regards,

Yves
 
M

Mike Treseler

Salman said:
What is wrong with this?

procedure gen_s (
variable si, di : in std_logic_vector(z_width downto 0);
variable so : out std_logic_vector(z_width downto 0)) is
begin
if si(z_width) = '1' then
so := (si(z_width-1 downto 0) & '0') + di;
else
so := (si(z_width-1 downto 0) & '0' - di);
end if;
end gen_s;

Not too much.

Add this to the top of your entity:

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

and change std_logic_vector to unsigned.

-- Mike Treseler
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top