Signal assignment inside for loop

Discussion in 'VHDL' started by krkrkr, Jun 14, 2009.

  1. krkrkr

    krkrkr

    Joined:
    Jun 14, 2009
    Messages:
    4
    Hello all,
    I'm new to VHDL and having a problem.

    I know that signal assignment does not take effect until the end of the process unlike the variable assignment.
    ie cnt <= cnt +1;
    out <= cnt;
    If cnt is a signal then out will have the value of cnt before adding 1.

    My problem is I want to have same kind of signal assignment inside a for loop
    ie for i 0 to 2 loop
    cnt <= cnt +1;
    end loop;

    cnt is a signal, how can i do that and have the right cnt value?

    Thanks.
    krkrkr, Jun 14, 2009
    #1
    1. Advertising

  2. krkrkr

    debayan_p

    Joined:
    Jun 2, 2009
    Messages:
    23
    for i 0 to 2 loop
    cnt <= cnt +1;
    end loop;

    The above is ok if you declare 'cnt' as a variable. Is it necessary to declare it as a signal ?

    Later when ur looping is complete you can saaign the variable 'cnt' to a signal or an output port.
    debayan_p, Jun 17, 2009
    #2
    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. Nicolas Moreau
    Replies:
    9
    Views:
    3,126
  2. Roedy Green
    Replies:
    3
    Views:
    423
    Mike Schilling
    Sep 13, 2008
  3. dibacco73
    Replies:
    1
    Views:
    645
    joris
    Feb 12, 2009
  4. Aggelos

    Loop Inside loop for writing text lines

    Aggelos, Nov 11, 2003, in forum: ASP General
    Replies:
    2
    Views:
    191
    Aggelos
    Nov 12, 2003
  5. Isaac Won
    Replies:
    9
    Views:
    364
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page