summing of array elements in for loop

Discussion in 'VHDL' started by antsor, Feb 12, 2012.

  1. antsor

    antsor

    Joined:
    Feb 12, 2012
    Messages:
    1
    How can I sum an array of vectors in a for loop? If e.g. I would have a type

    type tab is array(my_size downto 0) of STD_LOGIC_VECTOR(3 DOWNTO 0);
    signal s : tab;


    and I want to do a sum that would be equivalent to this:

    dout <= s(0) + s(1) + s(2) + s(3) ....

    but how can I do that in a for loop? Of course I could use a variable:

    for N in my_size-1 downto 0 loop
    temp_var := temp_var + s(N);
    end loop;


    but how is it possible without using a variable?
    antsor, Feb 12, 2012
    #1
    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. Alf P. Steinbach
    Replies:
    2
    Views:
    525
    Chris Theis
    Feb 5, 2004
  2. Yaroslav Bulatov

    Microbenchmark: Summing over array of doubles

    Yaroslav Bulatov, Aug 1, 2004, in forum: Python
    Replies:
    9
    Views:
    385
    Christopher T King
    Aug 3, 2004
  3. RS
    Replies:
    1
    Views:
    391
    Jacek Dziedzic
    Sep 21, 2006
  4. RS
    Replies:
    0
    Views:
    334
  5. Isaac Won
    Replies:
    9
    Views:
    352
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page