Change record elements

H

hssig

Guest
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
 
On Monday, July 29, 2013 4:36:02 AM UTC-4, hssig wrote:
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 self documenting 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 or not since your record elements weren't of the same integer ranges but thought I'd toss it out as food for thought.

Kevin Jennings
 
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;
 

Welcome to EDABoard.com

Sponsor

Back
Top