Rules | Recent posts | topic RSS | Search | Register  | Log in

using integer arrays in VHDL

 
Post new topic  Reply to topic    EDAboard.com Forum Index -> PLD, SPLD, GAL, CPLD, FPGA Design
Author Message
chillimillii



Joined: 26 Sep 2007
Posts: 10


Post20 Aug 2008 7:34   using integer arrays in VHDL

hi,


i have to use integer arrays in VHDL. the main problem is i have to put integer values into arrays. i dont know how to implement this in VHDL. please help me. Thanks!
Back to top
avimit



Joined: 16 Nov 2005
Posts: 415
Helped: 68
Location: Fleet, UK


Post20 Aug 2008 11:54   Re: using integer arrays in VHDL

Dont understand what exactly your problem is.
you can eaisly define a data type like
type int_array is array(0 to N-1) of integer;

then a signal of that type:

signal my_integers : int_array;


now you can eaisly assign values to the array elements like:
my_integers(0) <= 24;
or
my_integers(N-1) <= 100;
Kr,
Avi
Back to top
craftor



Joined: 18 Aug 2008
Posts: 23
Helped: 2
Location: China


Post20 Aug 2008 14:05   using integer arrays in VHDL

Well, if I want to assign values in array like:

type type_array is array(0 to N-1) of std_logic_vector(o to N-1);
signal tmp : type_array;

how should I do ?
Back to top
FvM



Joined: 22 Jan 2008
Posts: 2635
Helped: 431
Location: Bochum, Germany


Post20 Aug 2008 14:30   using integer arrays in VHDL

Code:
tmp(i) <= std_logic_vector(conv_unsigned(j,N));
-- respectively conv_signed(), according to your data interpretation

An integer array (with a range to control the bit width) would be possible as well.

By the way, the arithmetic types generally have a downto bit order, thus a std_logic_vector(0 to N-1) would be supplied with inverted bits. Not a problem for the std_logic_vector, but a possible source of confusion when further processing the data.
Back to top
chillimillii



Joined: 26 Sep 2007
Posts: 10


Post20 Aug 2008 14:50   Re: using integer arrays in VHDL

avimit wrote:
Dont understand what exactly your problem is.
you can eaisly define a data type like
type int_array is array(0 to N-1) of integer;

then a signal of that type:

signal my_integers : int_array;


now you can eaisly assign values to the array elements like:
my_integers(0) <= 24;
or
my_integers(N-1) <= 100;
Kr,
Avi



basically i have to use 4x 3 array having its elements as integers in Vhdl (for performing matrix subtraction and multiplication etc etc operations). I don't know exactly declaring and defining this. do you have any idea about it?
Back to top
FvM



Joined: 22 Jan 2008
Posts: 2635
Helped: 431
Location: Bochum, Germany


Post21 Aug 2008 0:17   Re: using integer arrays in VHDL

Code:
type int_array is array(0 to 3, 0 to 2) of integer range -2**15 to 2**15 -1;
Back to top
avimit



Joined: 16 Nov 2005
Posts: 415
Helped: 68
Location: Fleet, UK


Post21 Aug 2008 8:47   Re: using integer arrays in VHDL

You may also break down the array type declaration into 2 steps for clarity like this:
type my_int_array is array(0 to 3) of integer range -2**15 to 2**15 -1;
type my_int_matrix is array (0 to 2) of my_int_array;

Kr,
Avi
Back to top
Post new topic  Reply to topic    EDAboard.com Forum Index -> PLD, SPLD, GAL, CPLD, FPGA Design
Page 1 of 1 All times are GMT + 1 Hour


Abuse
Administrator
Moderators
topic RSS 
sitemap