Often in a digital system, two separate and independent sequential behaviors must be implemented as a part of an overall solution. If these behaviors have similar clocking needs and use similar I/O signals, it may make sense to code both behaviors as a part of one larger state machine. But if the behaviors have different clocking needs, or use different I/O signals, it is often more efficient to separate the behaviors into two separate machines that each solve their own problem, while staying coordinated and synchronized.
If two or more state machines are implemented as a part of the same overall digital system, and if they must stay synchronized and coordinated, a “handshaking” system is often implemented. Often, coordinated state machines use different clocks (in fact, that’s one of the main reasons for using separate state machines). If those clocks are derived from the same master clock in the system as shown in the example below, then the coordinated machines are in the same “clock domain” and their inputs and outputs can be considered mutually synchronized (more on clock domains later). If the state machines use different clocks that are derived from different sources, then their inputs and outputs are mutually asynchronous, and must be treated as such.
The figure below shows a typical hand-shaking system. State machine 1 (FSM1) receives an input from some source – in this example, a signal called XRAW from a pushbutton. The input may be just one of several inputs to FSM1, but it is the only one that matters for this discussion. The state diagram above FSM1 shows how the input is sampled and then reissued to FSM2 as XSAMP. FSM2 waits for the XSMP input, and then after receiving it issues the signal CONT back to FSM1. Note that FSM1 must wait for the CONT signal before it can progress any further. Using this system, both machines are prevented from progressing down certain paths until released by the other state machine – this is one example of handshaking.
This is a simple example of a hand-shake system, and there are many potential variations. But all handshaking systems share this lock-step binding, where one machine must be released by the other before continuing down a given path. Note that with this system, the clocks to the individual machines can use vastly different frequencies.