Article directory
theory
concept
The state machine is referred to as FSM, also known as synchronous finite state machine, with limited states, suitable for describing sequential events, such as counters
- Moore type: the final output is related to the current state and has nothing to do with the input
- Mealy type: the final output is related to the current state and input
- Common ground: state jumps are only related to input
state machine representation
State transition diagrams to aid in coding
combat
Implement a simple coke machine system
A bottle of Coke is 3 yuan, when you put in three hard pens, you get a bottle of Coke
- Build a file system
- Draw the system block diagram and state transition diagram.
Each rounded rectangle represents a state. The left side of the slash is the input, and the right side is the output.
The state transition diagram is three elements: input, output, state
- Input: Put in a one-yuan coin
- Output: Out Coke / Out Coke
- Status: input 0 yuan/1 yuan/2 yuan/3 yuan
- State analysis
Analyze the output and next state in each state and under various input conditions
Three states: Moore type
Four states: Mealy type
Both state transition diagrams are correct, but it is generally used to simplify the state to the simplest