80 likes | 277 Views
String Recognition. Simple case: recognize 1101. 0. 0. “ ” 0. “1” 0. “11” 0. “110” 0. “1101” 1. 1. 1. 0. 1. Reset. 0. 1. 0. 1. String Recognition. General rules: Create string matching tree State output = 1 if a “pattern” is contained along the path
E N D
String Recognition • Simple case: recognize 1101 0 0 “ ” 0 “1” 0 “11” 0 “110” 0 “1101” 1 1 1 0 1 Reset 0 1 0 1
String Recognition • General rules: • Create string matching tree • State output = 1 if a “pattern” is contained along the path • Add failure edges: find longest “suffix” of string seen so far and transition to the corresponding “prefix” state
String Recognition • Example: 1101, 1011, 101 • Create string matching tree • State output = 1 if a “pattern” is contained along the path • Add failure edges: find longest “suffix” of string seen so far and transition to the corresponding “prefix” state “ ” 0 “1” 0 “11” 0 “110” 0 “1101” 1 1 1 0 1 Reset 0 “10” 0 “101” 1 “1011” 1 1 1
String Recognition • Example: 1101, 1011, 101 • Create string matching tree • State output = 1 if a “pattern” is contained along the path • Add failure edges: find longest “suffix” of string seen so far and transition to the corresponding “prefix” state 0 1 0 “ ” 0 “1” 0 “11” 0 “110” 0 “1101” 1 1 1 0 1 Reset 0 0 0 1 “10” 0 “101” 1 “1011” 1 1 1 0 0 1
String Recognition using Shift Registers • Example: 1111, 1011, 101 • 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 INPUT OUTPUT