Change record elements

Discussion in 'VHDL' started by hssig, Jul 29, 2013.

  1. hssig

    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
     
    hssig, Jul 29, 2013
    #1
    1. Advertising

  2. hssig

    KJ Guest

    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 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
     
    KJ, Jul 30, 2013
    #2
    1. Advertising

  3. hssig

    KJ Guest

    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;
     
    KJ, Jul 30, 2013
    #3
  4. hssig

    hssig Guest

    Hi Kevin,

    thank you for your solution.

    Cheers, hssig
     
    hssig, Jul 30, 2013
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SnVzdGlu?=

    Retrieving Record Key while creating the record.

    =?Utf-8?B?SnVzdGlu?=, Oct 4, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    656
    =?Utf-8?B?SnVzdGlu?=
    Oct 5, 2004
  2. André
    Replies:
    0
    Views:
    3,771
    André
    Jun 25, 2006
  3. MRW
    Replies:
    0
    Views:
    393
  4. THurkmans
    Replies:
    2
    Views:
    622
  5. André
    Replies:
    0
    Views:
    459
    André
    Jun 25, 2006
Loading...

Share This Page