Upload
ira-carson
View
216
Download
1
Embed Size (px)
Citation preview
State Table Problem #1
An electronic lock is controlled by a keypad, which has three buttons labeled A, B, and R. The keypad is restricted such that, at most, one key can be pressed at a time, and that each key press generates an input signal that lasts for
only one clock cycle. A state machine takes the key presses as input, and its output is either lock (L) or unlock (U). If the correct sequence of keys is typed and followed by an R, the state machine generates an unlock (U) signal
and then resets. At any other time the output should be locked (L). If an incorrect sequence of keys is pressed the lock becomes inactive until the reset (R) key is pressed, at
which point the lock resets (with no unlock signal).
State Table Problem #1
1) An electronic lock is controlled by a keypad, which has three buttons labeled A, B, and R. The keypad is restricted such that, at most, one key can be pressed at a time, and that each key press generates an input signal that lasts for
only one clock cycle. A state machine takes the key presses as input, and its output is either lock (L) or unlock (U). If the correct sequence of keys is typed and followed by an R, the state machine generates an unlock (U) signal
and then resets. At any other time the output should be locked (L). If an incorrect sequence of keys is pressed the lock becomes inactive until the reset (R) key is pressed, at
which point the lock resets (with no unlock signal).
Create the symbolic state machine (state diagram) for this lock if the correct key
sequence is BBAB. Label your inputs A, B, R, and O (for no key pressed). Label your output L or U. Label your states with words
such as "reset" and "inactive," or with partial key sequences such as "BBA." Make sure that all possible transitions
exist.
Bubble Diagram
Problem #2
• Candy costs 15 cents, and the candy machine accepts nickels and dimes. However, it has a coin return and can only output one item (a nickel, a dime, or candy) at a time. In addition, only one input (a nickel, a dime, or the coin return) can occur at a time.
• Create the symbolic state machine (state diagram) for this candy machine. Label your inputs N, D, CR (coin return), and O (for no input). Label your outputs N, D, C (candy), and O (for no out put). Make sure that all possible transitions exist.
Bubble Diagram For Prob #2
Problem #3
• Sequence Recognizer – Given a string of bits, recognize the sequence 011 or 10
– Overlapping sequences are OK ex:
• When we get a zero, look for two ones following it • When we get a one, look for a zero following it
Possible inputs:
• The next bit you are trying to identify • Can be a 0 or a 1 • Have 2 inputs, need 1 binary variable
Possible outputs:
• Did you complete a sequence {Y} or not {N}?
• Have 2 outputs, need 1 binary variable
Possible states:
• I don't have any recognizable sequence -> {x} • I have a 0 (we may be able to match the 1st
sequence) -> {x0} • I have a 0 followed by a 1 (we may be able to
match the 1st sequence) -> {x01} • I have a 1 (we may be able to match the 2nd
sequence) -> {x1} • Have 4 possible states, need 2 binary variables
Sequence Recognizer Example
Sequence Recognizing State Diagram
Input = 0 is shown in blue. Input = 1 is shown in red. Notice, every state has both a red and blue arrow from it.
What happens to the state diagram if we don't allow overlapping sequences?
Sequence Recognizing State Diagram No Overlapping Sequences
Changes from previous diagram are shown in green.
What happens to the state diagram if we have a reset?
• If the reset is on, it will go back to the unrecognizable sequence state no matter what the other input is
• The reset can be on {R} or off {R'}
• Have 2 more inputs, need 1 more binary variable
Sequence Recognizing State Diagram with a Reset
How do we describe sequential systems?
• Sequential system description – If state=0¢ and input=nickel, then next
state=5¢ and output=no candy – if state=5¢ and input=nickel, then next
state=0¢ and output=candy
How do we describe sequential systems?
• State diagrams – Circles represent state– Arrows represent what the next state is
– Numbers on arrows represent the input required to get that next state/resulting output
What causes transition?
If input causes transition, get the following state diagram
Called an asynchronous system
If have a periodic signal constantly checking for the input (called clock), must have an arrow directing you to a state if no input is received
Called a synchronous system. This is the type system we will be dealing with.
How do we describe sequential systems?
• take the existing state diagram and write using binary variables?
– Have 2 possible inputs {nickel / no nickel}, so need 1 binary variable to represent
• Nickel=1 • No nickel=0 • Input=N, which can be either 1 or 0 to represent having a nickel or not
– Have 2 possible states {0¢ / 5¢}, so need 1 binary variable to represent
• 0¢=0 • 5¢=1 • State variable=M, which can be either 0 or 1 to represent 0¢ state or 5¢
state – Have 2 possible outputs {candy / no candy}, so need 1 binary variable
to represent • Candy=1 • No candy=0 • Output=C, which can be either 1 or 0 to represent getting candy or not • Note that assignment of binary definitions (ie nickel = 1) is arbitrary
Writing State Diagrams with Binary Definitions
nickel = 1 0¢ = 0 candy = 1
no nickel = 0 5¢ = 1 no candy = 0
Garage Door Opener
– The door can go up, go down, stay up, stay down, or stop in the middle
– You can push a button that will change what the door is going to do
• If the door stopped at the bottom, push the button and the door will go up
• If the door stopped at the top or in the middle, push the button and the door will go down
• If the door is going up, push the button and the door will stop in the middle
• If the door is going down, push the button and the door will go back up (emergency feature)
– There exist limit switches that stop the motor when the door hits the top or the bottom
• When the door is stopped at the top or bottom, the limit switch is always pushed
So, we have a limit switch and a button, either of which may be on or off
Possible inputs:
• Neither button nor limit switch pushed -> {L' B'} • Button pushed, limit switch not pushed -> {L' B} • Limit switch pushed, button not pushed -> {L B'} • Both button and switch pushed -> {L B} • Have 4 inputs, need 2 binary variables
Possible outputs = possible states:
• Going up -> {G-U} • Going down -> {G-D} • Stopped up -> {S-U} • Stopped down -> {S-D} • Stopped middle -> {S-M}
• Have 5 states, need 3 binary variables
Garage Door Opener State Diagram
S-U and S-M states may be combined into a single state
{S-U-M}
• Inputs not possible for S-U state are valid inputs for S-M state and vice versa
• Now, only need 2 binary variables
Garage Door Opener State Diagram with States Combined
Complex Candy Machine– 15¢ candy machine that accepts nickels and dimes – Possible inputs:
• Nothing -> {X} • Nickel -> {N} • Dime -> {D} • Have 3 inputs, need 2 binary variables
– Possible outputs: • Candy -> {C} • No candy -> {C'} • Have 2 outputs, need 1 binary variable
– Possible states: • 0¢ • 5¢ • 10¢ • Have 3 states, need 2 binary variables
Complex Candy Machine State Diagram