Change record elements

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

  1. hssig

    hssig Guest


    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. Advertisements

  2. hssig

    KJ Guest

    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
    1. Advertisements

  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
  4. hssig

    hssig Guest

    Hi Kevin,

    thank you for your solution.

    Cheers, hssig
    hssig, Jul 30, 2013
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.