FSM Word Problems

Download Report

Transcript FSM Word Problems

String Recognition
• Simple case: recognize 1101
0
0
“”
0
Reset
0
1
“1”
0
0
1
“11”
0
0
“110”
0
1
“1101”
1
1
1
String Recognition
• General rules:
1. Create string matching tree
2. State output = 1 if a “pattern” is contained along the path
3. Add failure edges: find longest “suffix” of string seen so
far and transition to the corresponding “prefix” state
String Recognition
• Example: 1101, 1011, 101
1. Create string matching tree
2. State output = 1 if a “pattern” is contained along the path
3. Add failure edges: find longest “suffix” of string seen so
far and transition to the corresponding “prefix” state
Reset
“”
0
1
1
“1”
0
“11”
0
0
“110”
0
1
“1101”
1
“10”
0
1
“101”
1
1
“1011”
1
0
String Recognition
• Example: 1101, 1011, 101
1. Create string matching tree
2. State output = 1 if a “pattern” is contained along the path
3. Add failure edges: find longest “suffix” of string seen so
far and transition to the corresponding “prefix” state
0
Reset
1
“”
0
1
1
“1”
0
0
“11”
0
0
“110”
0
1
0
“1101”
1
0
1
1
0
“10”
0
1
“101”
1
0
1
0
“1011”
1
String Recognition using Shift Registers
• Example: 1111, 1011, 101
1.
2.
3.
4.
Use N bit shift register if longest pattern has N bits
Create an AND gate for pattern
OR together AND gates
Caveat: result is invalid for the first N cycles
S3
S2
S1
S0
FF
FF
FF
FF
OUTPUT
INPUT