Washington University in St. Louis CSE 465 – Spring 2005 Digital Systems Laboratory Lecture 6 : String Matching in Reconfigurable Hardware John W Lockwood Washington University in St. Louis Lockwood@arl.wustl.edu Copyright 2005 http://www.arl.wustl.edu/~lockwood/class/cse465-s05/
String Scanning : 32-bit Data Format H0 Packet Header .. Header .. Packet Header (N Words) [31 downto 0] of Words H0 .. HN Packet Payload (M bytes) Bytes P0 .. PM HN P0 P1 P2 P3 Packet Payload P4 P5 P6 P7 P8 P9 P10 P11 .. Payload .. PM 32 bits
MP6 Problem Statement Problem Statement Details Implement a plug-in module that monitors a traffic flow. For cells with payloads that begin with “HELLO” Details Scan Flows destined for particular port Match the content of the cell for the “HELLO” ASCII: “HELLO” Hex: 48 – 45 – 4C – 4C – 4F Binary: 0100,1000 ; 0100,0101; 0100,1100 ; 0100,1100 ; 0100,1111
String Scanning : 32-bit Data Format H0 Packet Header .. Header .. “HELLO” at even word offset in packet HN P0 P1 P2 .. Packet Payload ‘H’ ‘E’ ‘L’ ‘L’ ‘O’ .. .. .. .. Payload .. PM 32 bits
String Scanning : 32-bit Data Format H0 Packet Header .. Header .. “HELLO” offset by one byte in packet HN P0 P1 P2 P3 Packet Payload .. ‘H’ ‘E’ ‘L’ ‘L’ ‘O’ .. .. .. Payload .. PM 32 bits
String Scanning : 32-bit Data Format H0 Packet Header .. Header .. “HELLO” offset by two bytes in packet HN P0 P1 P2 P3 Packet Payload P4 .. ‘H’ ‘E’ ‘L’ ‘L’ ‘O’ .. .. Payload .. PM 32 bits
String Scanning : 32-bit Data Format H0 Packet Header .. Header .. “HELLO” offset by three bytes in packet HN P0 P1 P2 P3 Packet Payload P4 P5 .. ‘H’ ‘E’ ‘L’ ‘L’ ‘O’ .. Payload .. PM 32 bits
String Scanning : Simplified State Machine Packet Header Init .. Header .. HN Header Match P0 P1 P2 .. Packet Payload ‘H’ ‘E’ ‘L’ ‘L’ ‘HELL’ Match ‘O’ .. .. .. .. Payload .. ‘HELLO’ Match PM 32 bits Basic State Transition Diagram (simplified)
String Scanning : Simplified State Machine Packet Header Init .. Header .. HN Header Match P0 P1 P2 P3 Packet Payload .. ‘H’ ‘E’ ‘L’ ‘HEL’ Match ‘L’ ‘O’ .. .. .. Payload .. ‘HELLO’ Match PM 32 bits Basic State Transition Diagram (simplified)
String Scanning : Simplified State Machine Packet Header Init .. Header .. HN Header Match P0 P1 P2 P3 Packet Payload P4 .. ‘H’ ‘E’ ‘HE’ Match ‘L’ ‘L’ ‘O’ .. .. Payload .. ‘HELLO’ Match PM 32 bits Basic State Transition Diagram (simplified)
String Scanning : Detailed State Machine Packet Header Init .. Header .. End of Packet HN Matching Port Header Match P0 P1 P2 P3 End of Packet ‘HXXX’ Packet Payload P4 P5 .. ‘H’ ‘H’ Match ‘E’ ‘L’ ‘L’ ‘O’ Not ‘HXXX’ ‘ELLO’ .. Payload .. ‘HELLO’ Match ‘HXXX’ PM 32 bits End of Packet Additional State Transitions (more detail provided)
Search Modules Specification: Search for: “HELLO” n “HELLO” match
Parallel Matching Engines Final Value ( Count @ end of document ) Control Signals 8 32 Start 8 End 8 Data_Enable … 32 = 8 Streaming Data Input 8 Count Register Match Adder 32 8 8 Initial Value ( Zero @ start of Document ) 32 Streaming Input Data 8 Parallel Finite State Machines (one for each offset)
Matching different length strings Length=2 String : “my” my** *my* **my ***m + y*** Length=3 String : “cry” cry* *cry **cr + y*** ***c + ry** Length=5 String : “laugh” laug + h*** *lau + gh** **la + ugh* ***l + augh
Special Cases : Multiple Matches in a clock For streams > 1,000 bytes, multiple packets are sent from the traffic generator State machines should only transit when Data Enabled, otherwise – stay in the same state. “MY’ count += 2 “CRY” count += 2 M Y M Y x x C R Y C R Y
Process data only when enabled Data streams can be larger than 1,000 bytes For streams > 1,000 bytes, multiple packets are sent fom the traffic generator State machines should only transit when Data Enabled, otherwise – stay in the same state. Hello Count = 1 Hello Count = 2 M Y M Y L L O H x x x x E L L O Data Enabled Data Enabled Data Enabled No Data
Data Enable Data streams can be larger than 1,000 bytes For streams > 1,000 bytes, multiple packets are sent from the traffic generator State machines should only transit when Data Enabled, otherwise – stay in the same state. Hello Count = 1 Hello Count = 2 x H E L L L O H x x x x E L L O Data Enabled Data Enabled Data Enabled No Data