exiting from state machine

Discussion in 'VHDL' started by jiten, Jun 22, 2005.

  1. jiten

    jiten Guest

    if (rst='1') then
    mplr := (others=>'0');
    st <= idle;
    i <= "000";
    elsif (clk'event and clk='1') then
    case st is
    when idle => tmc := "00000000" & mc;
    st <= add;
    when add => if (mp(conv_integer(i))='1') then
    mplr := mplr + tmc ;
    end if;
    st <= shift;

    when shift => tmc := tmc(14 downto 0) & '0';
    i <= i + 1;
    st <= add;
    if (i = "111")then
    -- from here i want that i shoud come out of
    states, bcoz i've got the output. i m coming out by taking one more
    state. is there any other way of coming out from the state machines
    without taking one more state. of course 'exit' doesn't work here.
    jiten, Jun 22, 2005
    #1
    1. Advertising

  2. jiten wrote:

    > if (rst='1') then
    > mplr := (others=>'0');
    > st <= idle;
    > i <= "000";
    > elsif (clk'event and clk='1') then
    > case st is
    > when idle => tmc := "00000000" & mc;
    > st <= add;
    > when add => if (mp(conv_integer(i))='1') then
    > mplr := mplr + tmc ;
    > end if;
    > st <= shift;
    >
    > when shift => tmc := tmc(14 downto 0) & '0';
    > i <= i + 1;
    > st <= add;
    > if (i = "111")then
    > -- from here i want that i shoud come out of
    > states, bcoz i've got the output.


    Seems to me, that you are thinking like sofware and you are looking for
    a similar thing to the ANSI C "break;".

    VHDL case has different behavoir than ANSI C switch. You don't need a
    "break;".

    Just test
    if (i /= "111") then
    and do there all the stuff you need and don't use an else clause. ->
    Nothing will then be done in the state "shift".



    Generally: Don't program VHDL! Model hardware with it. VHDL is not a
    software language.

    Ralf
    Ralf Hildebrandt, Jun 22, 2005
    #2
    1. Advertising

  3. jiten

    Alex Guest

    Hi,

    The software approach is obvious in here ;). The thing is that you don't
    go out of the state machine
    - simple implement some idle(dummy) state.
    In your case it won't make a problem as you have already have 2
    flops(unless you want to use on-hot coding), so forth state
    will be fine.
    p.s. VHDL is not a programming language- it is descrptive one ;)
    Regards,
    Alex

    > if (rst='1') then
    > mplr := (others=>'0');
    > st <= idle;
    > i <= "000";
    > elsif (clk'event and clk='1') then
    > case st is
    > when idle => tmc := "00000000" & mc;
    > st <= add;
    > when add => if (mp(conv_integer(i))='1') then
    > mplr := mplr + tmc ;
    > end if;
    > st <= shift;
    >
    > when shift => tmc := tmc(14 downto 0) & '0';
    > i <= i + 1;
    > st <= add;
    > if (i = "111")then
    > -- from here i want that i shoud come out of
    > states, bcoz i've got the output. i m coming out by taking one more
    > state. is there any other way of coming out from the state machines
    > without taking one more state. of course 'exit' doesn't work here.
    >

    --
    Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
    Alex, Jun 22, 2005
    #3
  4. jiten

    Alex Guest

    Hi,

    The software approach is obvious in here ;). The thing is that you don't
    go out of the state machine
    - simple implement some idle(dummy) state.
    In your case it won't make a problem as you have already have 2
    flops(unless you want to use on-hot coding), so forth state
    will be fine.
    p.s. VHDL is not a programming language- it is descrptive one ;)
    Regards,
    Alex

    > if (rst='1') then
    > mplr := (others=>'0');
    > st <= idle;
    > i <= "000";
    > elsif (clk'event and clk='1') then
    > case st is
    > when idle => tmc := "00000000" & mc;
    > st <= add;
    > when add => if (mp(conv_integer(i))='1') then
    > mplr := mplr + tmc ;
    > end if;
    > st <= shift;
    >
    > when shift => tmc := tmc(14 downto 0) & '0';
    > i <= i + 1;
    > st <= add;
    > if (i = "111")then
    > -- from here i want that i shoud come out of
    > states, bcoz i've got the output. i m coming out by taking one more
    > state. is there any other way of coming out from the state machines
    > without taking one more state. of course 'exit' doesn't work here.
    >




    --
    Alex
    Alex, Aug 14, 2005
    #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. David Lamb
    Replies:
    1
    Views:
    654
  2. Weng Tianxiang
    Replies:
    7
    Views:
    1,077
    Mike Treseler
    Nov 25, 2003
  3. Weng Tianxiang
    Replies:
    3
    Views:
    1,361
    Weng Tianxiang
    Jul 25, 2006
  4. Grumps
    Replies:
    2
    Views:
    658
    Grumps
    Feb 13, 2008
  5. fenster
    Replies:
    3
    Views:
    1,146
    jeppe
    Dec 23, 2011
Loading...

Share This Page