How to sequencialize two finite state machines ?

Discussion in 'VHDL' started by Martin Maurer, Jun 13, 2004.

  1. Hello,

    i have two state machine: one is collecting data (FSM1) and the second one
    is storing them (FSM2).
    How can i start FSM2 from a state in FSM1 ? I tried to modify a state of
    FSM2 in FSM1, but then i get an error message, that state of FSM2 is
    multi-sourced. I already tried to create a variable to signal "Start" to
    second state machine, but even there i can't reset the variable. So FSM1
    must set and reset the variable, but i don't know when i can reset the
    variable, because FSM2 is running...

    Is there a better way of doing it ? My solution look more like workarounds
    than elegant solutions.

    Regards,

    Martin
    Martin Maurer, Jun 13, 2004
    #1
    1. Advertising

  2. Martin Maurer

    Ken Smith Guest

    In article <caiihm$2jm$00$-online.com>,
    Martin Maurer <> wrote:
    >Hello,
    >
    >i have two state machine: one is collecting data (FSM1) and the second one
    >is storing them (FSM2).
    >How can i start FSM2 from a state in FSM1 ? I tried to modify a state of
    >FSM2 in FSM1, but then i get an error message, that state of FSM2 is
    >multi-sourced. I already tried to create a variable to signal "Start" to
    >second state machine, but even there i can't reset the variable. So FSM1
    >must set and reset the variable, but i don't know when i can reset the
    >variable, because FSM2 is running...
    >
    >Is there a better way of doing it ? My solution look more like workarounds
    >than elegant solutions.


    My suggestion:

    Use 2 signals like this:

    FSM1 takes the FSM2Go signal true when it wants FSM2To start. When FSM2
    is running it takes FSM2Running true. When FSM1 sees FSM2Running go true
    it steps to the next state allowing FSM2Go to go false. This assumes that
    the two state machines are timed by using the same clock or something that
    makes sure you don't get glitches.

    If you can't be sure of no glitches then you need a bunch more logic to
    ensure the timing, but the same idea applies..
    --
    --
    forging knowledge
    Ken Smith, Jun 14, 2004
    #2
    1. Advertising

  3. Re: How to sequence two finite state machines ?

    Martin Maurer wrote:

    > Hello,
    >
    > i have two state machine: one is collecting data (FSM1) and the second one
    > is storing them (FSM2).
    > How can i start FSM2 from a state in FSM1 ? I tried to modify a state of
    > FSM2 in FSM1, but then i get an error message, that state of FSM2 is
    > multi-sourced. I already tried to create a variable to signal "Start" to
    > second state machine, but even there i can't reset the variable. So FSM1
    > must set and reset the variable, but i don't know when i can reset the
    > variable, because FSM2 is running...


    > Is there a better way of doing it ?


    Yes. Consider putting this controller in a single synchronous process.
    You may just need a single boolean variable for the two modes.
    Use whatever sequential statements you need to update the state
    variables and the output signals every rising_edge.
    Don't get hung up on the textbook machine examples.

    -- Mike Treseler
    Mike Treseler, Jun 14, 2004
    #3
  4. Martin Maurer

    Andrew Hall Guest

    On Sun, 13 Jun 2004 23:56:03 +0200, Martin Maurer wrote:

    > Hello,
    >
    > i have two state machine: one is collecting data (FSM1) and the second one
    > is storing them (FSM2).
    > How can i start FSM2 from a state in FSM1 ? I tried to modify a state of
    > FSM2 in FSM1, but then i get an error message, that state of FSM2 is
    > multi-sourced. I already tried to create a variable to signal "Start" to
    > second state machine, but even there i can't reset the variable. So FSM1
    > must set and reset the variable, but i don't know when i can reset the
    > variable, because FSM2 is running...
    >
    > Is there a better way of doing it ? My solution look more like workarounds
    > than elegant solutions.
    >
    > Regards,
    >
    > Martin


    You don't need to use a registered signal, use a combinational signal
    that's set when FSM1 reaches a certain state.

    E.g. when GoState =>
    GoSignal <= '1';

    and then have a second signal from FSM2 to hand control back. Just
    remember to set the default value of GoSignal to be '0' otherwise you'll
    infer a latch.

    It might be worth running one of the FSMs on an inverted clock to make the
    synchronisation a bit easier.

    HTH,

    Andrew.
    Andrew Hall, Jun 14, 2004
    #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. Sidney Cadot
    Replies:
    0
    Views:
    2,341
    Sidney Cadot
    Apr 18, 2004
  2. Henrik Vallgren
    Replies:
    0
    Views:
    777
    Henrik Vallgren
    Jun 15, 2004
  3. john
    Replies:
    3
    Views:
    676
    backhus
    Jun 12, 2006
  4. Rui Maciel
    Replies:
    67
    Views:
    2,060
    Christopher Layne
    Feb 16, 2007
  5. Aardalath
    Replies:
    4
    Views:
    403
    Aardalath
    Jan 27, 2009
Loading...

Share This Page