How to add an binary value to a vector?

A

ALuPin

Hi everybody,

I have a question concerning the following:

If I want to add a binary value to a vector WITHOUT using
the ieee.std_logic_unsigned.all library
I get the error message : "No feasible entries for infix op: "+"
How can I do this addition only with the ARITH and 1164 library?
Thank you for your help.

Kind regards
Andre V.


----------------------------------------------------------------
use ieee.std_logic_arith.all;
use ieee.std_logic_1164.all;

signal t_Parallel_data_in : std_logic_vector(7 downto 0);

begin

process
begin
...
if condition='1' then
t_Parallel_data_ in <= t_Parallel_data_in + "00001010";
end if;

end process;
-----------------------------------------------------------------
 
A

Anders Hellerup Madsen

ALuPin said:
Hi everybody,

I have a question concerning the following:

If I want to add a binary value to a vector WITHOUT using
the ieee.std_logic_unsigned.all library
I get the error message : "No feasible entries for infix op: "+"
How can I do this addition only with the ARITH and 1164 library?
Thank you for your help.

Convert you operands to unsigned, using the unsigned() function, then
add them, and convert them back std_logic_vector with the
conv_std_logic_vector() function.

-- Anders
 
T

Tim Hubberstey

ALuPin said:
If I want to add a binary value to a vector WITHOUT using
the ieee.std_logic_unsigned.all library
I get the error message : "No feasible entries for infix op: "+"
How can I do this addition only with the ARITH and 1164 library?

use ieee.std_logic_arith.all;
use ieee.std_logic_1164.all;

signal t_Parallel_data_in : std_logic_vector(7 downto 0);

begin

process
begin
...
if condition='1' then
t_Parallel_data_in <= t_Parallel_data_in + "00001010";

t_Parallel_data_in <= std_logic_vector(unsigned(t_Parallel_data_in) +
10));

or, if you REALLY want to use the "00001010" format:

t_Parallel_data_in <= std_logic_vector(unsigned(t_Parallel_data_in) +
unsigned'("00001010"));
end if;
end process;

I also suggest that you use ieee.numeric_std instead of
ieee.std_logic_arith as it's newer and more portable across tools. For
your case, the code is the same for both packages.
 

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,786
Messages
2,569,625
Members
45,320
Latest member
icelord

Latest Threads

Top