converting std_logic_vector to integer

V

vedpsingh

Hi all,
The code given below has perfectly compiled, but is not giving integer
output.
What am I doing wrong?

Thanks
ved


LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;

ENTITY conv_vec_int IS

PORT ( a : IN std_logic_vector(7 downto 0);
b : OUT integer range 0 to 255
);
END conv_vec_int;

ARCHITECTURE behav_conv_vec_int OF conv_vec_int IS

SIGNAL ai : std_logic_vector(7 downto 0);
SIGNAL bi : integer range 0 to 255;

BEGIN

ai <= a;

-- convert a from std_logic_vector to integer

bi <= bi* (conv_integer(ai));

END behav_conv_vec_int;
 
B

Benjamin Todd

Take a look through the FAQ, there are a few things wrong with your code.
Not to mention that this should be a function, not a component, and whether
a function is really needed in such a simple case as this.

I'm not going to give too much in the way of help... More fun to figure it
out IMHO.
http://www.vhdl.org/comp.lang.vhdl/
is the URL to get you started.
Ben
 
N

Neo

Your variable bi is not assigned, so it will always have the initial
value zero making your output also zero. the variables ai and bi are
actually unnecessary. by the way, what is the need for a module when
you can simply use the conversion function directly.
 
B

Benjamin Todd

In this case std_logic_vector vs integer is not a question of whether it can
be synthesised. Fundamentally hardware has no notion of integer, everything
is wires and logic, '1' and '0'.
i.e. using integer instead of std_logic_vector simply allows the code to be
easier to read and more readily interpreted (in various cases) by the
synthesis tool.
 
V

vizziee

I hope these funtions are synthesizable ??
Conversion functions are programming utilities and don't consume any
hardware on chip. You can write a few simple programs to check this.

KVM.
 

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

Forum statistics

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

Latest Threads

Top