Change record elements

H

hssig

Hi,

I want to divide all elements of a record by 2.
How can I perform that in a kind of loop?

type typeMine is record
a : natural;
b : natural;
c : positive;
d : integer
...
end record;



Thank you for your suggestion.

Cheers, hssig
 
K

KJ

Hi, I want to divide all elements of a record by 2. How can I perform that
in a kind of loop?
type typeMine is record
a : natural;
b : natural;
c : positive;
d : integer
... end record;

You can't iterate through the elements of a record so you can't do exactly what you're asking.

However, if all of your elements are integers of the same range (yours are all integers but not of the same range), then you could consider that your 'record' is simply a vector of integers. If you're using the record type as a way to make the usage clearer (i.e. xx.a means something whereas xx(0) isn't quite so informative) then there is another approach...

type t_my_thing_of_integers is(a, b, c, d);
type arr_my_integers is array(t_my_thing_of_integers);
signal xx: arr_my_integers;

Then you would access the elements as xx(a) which from the perspective selfdocumenting is equivalent to xx.a where xx is a signal of your record type..

Not sure if this alternate usage is along the lines you were looking for ornot since your record elements weren't of the same integer ranges but thought I'd toss it out as food for thought.

Kevin Jennings
 
K

KJ

On Monday, July 29, 2013 10:35:20 PM UTC-4, KJ wrote:
In the above post, should be
type arr_my_integers is array(t_my_thing_of_integers) of integer;
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top