How to sequencialize two finite state machines ?

M

Martin Maurer

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
 
K

Ken Smith

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

Mike Treseler

Martin said:
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
 
A

Andrew Hall

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.
 

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

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top