Modular BlockRAMBased LongestPrefix Match Ternary ContentAddressable Memories Ameer
Modular Block-RAM-Based Longest-Prefix Match Ternary Content-Addressable Memories Ameer M. S. Abdelhadi*, Guy G. F. Lemieux+, and Lesley Shannon* * School of Engineering; Simon Fraser University; Canada + Dept. of ECE; The University of British Columbia; Canada 1
Binary Content-Addressable Memories Hardware-based Single-Cycle Parallel Search Engines Write Match Stores new data at specific address Search all addresses for a given data (pattern) 0 “RAW” 1 “FSP” 2 “FPL” 3 “FPT” BCAM 0 “RAW” Found 1 “FSP” in ‘ 2’ 2 “FPL” 3 “FPT” BCAM Store “FSP” in ‘ 1’ Searc h for “FPL” 2
Ternary Content-Addressable Memories Adds the ability to use wildcards (X’s) Match Search all addresses for a given data (pattern) Search for “FPL” 0 “RAW” Found 1 “FSP” in 2 “F**” ‘ 2’ & ‘ 3’ 3 “FP*” BCAM Encoding Priority Encoder (PE) (First occurrence) The smallest address were “FPL” is found is ‘ 2’ Longest-Prefix Match (LPM) The longest matching prefix of “FPL” is found in ‘ 3’ 3
Associated Memory AKA CAM/RAM structure to read associated data Example: search when a conference takes place Searc h for “FPL” 0 “RAW” Found 1 “FSP” in ‘ 2’ 2 “FPL” 3 “FPT” CAM 0 “May” 1 “Aug” 2 “Aug” 3 “Dec” RAM “FPL“ takes place in “Aug” !! 4
CAM Classification & Applications Search the memory for exact match Wildcards may be used How close is each item to the searched data? Search for “BOMB” 0: BOOK 1: RING 2: BOMB 3: ROOM 4: WOMB 5: LINK 6: WOOD 7: WARD Search for “BOMB” 0: BO** 1: RING 2: BOMB 3: **OM 4: W*MB 5: LINK 6: WO*D 7: WARD Search for “BOMB” 0: BOOK 1: RING 2: BOMB 3: ROOM 4: WOMB 5: LINK 6: WOOD 7: WARD Expensive! Power hungry! More expensive! Computing intensive! • Memory Management • Data Compression • Package classification FPT’ 14 & FCCM’ 15 • IP forwarding • The internet BGP routers Current work Similarity Vector Differentiable Found in ‘ 0’ and ‘ 2’ Ternary Found in location ‘ 2’ Binary Memory-augmented neural networks • Neural Turing Machines (Deep. Mind) • Memory Networks (Facebook AI) Research in progress 5
Motivation - FPGAs 1000’s Memory Blocks 100, 000’s Logic Elements No dedicated CAM resources in FPGAs 6
Objectives Use BRAMs to construct • • Modular and flexible Storage efficient CAMs Single-cycle Performance oriented 7
Algorithmic Heuristics Associative Arrays Search Trees: Tries, BSTs, … Hashes Data dependent performance Variable search depth Misses due to conflicts Multi-unpredictable-cycle 8
Custom-designed CAMs Modified SRAM cell – Custom-design in transistor level Renesas TCAM device • 20 Mbit • 360 M Searches/Sec Performance Cost Integration overhead 9
Register-Based CAMs: PE-BCAM Concurrent register read and compare Single-cycle Limited resources Complex routing Fits small CAMs 10
Register-Based CAMs: LPM-TCAM Concurrent register read and compare Single-cycle Limited resources Complex routing Fits small CAMs 11
Brute-Force Transposed-RAM A Traditional BRAM-based CAM Key idea: Transposed RAM - data becomes addresses Write Match Write ‘ 0’ to location ‘B’ Read location ‘D’ for match ‘ 0’ to ‘B’ A B C D 3 0 1 2 ‘D’ A B C D 3 0 1 2 ‘ 2’ * Xilinx App Notes 12
Brute-Force Transposed-RAM A Traditional BRAM-based CAM • How can we store data to multiple addresses? • Specify addresses using one-hot coding • Each bit indicates a match or “store at location” ØPROBLEM: Depth of CAM is limited by data width of RAM • e. g. to build 1 M deep CAM, we need 1 M bits wide • In FPGAs: 1000 BRAMs x 32 bit wide = 32 K deep CAM A B C D 0 1 2 3 1 BRAM-based Single-cycle Depth of CAM is limited by RAM width 13
CAM Cascading • Solution: Cascading 1. Divide pattern into smaller slices 2. Search for each slice separately 3. If all slices are found pattern match! Ø RAM depth is linear to pattern width RAM Depth = 2 Slice Width x (Pattern Width / Slice Width) CAM … Pattern Match CAM Slice Match RAM Depth = 2 Pattern. Width Slice Match • Patterns are encoded as RAM addresses Ø RAM depth is exponential to pattern width … … Matched Pattern Slice Match • PROBLEM: 14
Hierarchical Search 2 D BCAM: Narrow and Deep BCAM Key idea: Hierarchical search 1 D BCAM 2 D BCAM Find a set (row) with match using a 1 D BCAM Search this set (row) in parallel for a specific match 2 k 4 M too deep 2 k 15
Hierarchical Search 2 D BCAM: Example patterns addresses patterns 0 2 1 3 1 RAM addresses 0 1 2 3 00 0 10 0 1 1 21 0 0 0 30 1 0 0 Transposed-RAM 16
Hierarchical Search 2 D BCAM: Example 1. Find a set (row) with match using a 1 D BCAM 2. Search this set (row) in parallel for a specific match addresses 0 1 2 3 00 0 10 0 1 1 21 0 0 0 30 1 0 0 Transposed-RAM patterns • RAM: each set in a line • Transposed-RAM: indicates “pattern in set? ” • Hierarchical Search: patterns 0 2 1 3 1 RAM addresses • Divide address space into sets 16
Hierarchical Search 2 D BCAM: Example sets • RAM: each set in a line • Transposed-RAM: indicates “pattern in set? ” patterns 0 2 3 1 1 1 • Hierarchical Search: 1. Find a set (row) with match using a 1 D BCAM 2. Search this set (row) in parallel for a specific match RAM addresses 0 1 2 3 00 0 10 0 1 1 21 0 0 0 30 1 0 0 Transposed-RAM patterns • Divide address space into sets 16
Hierarchical Search 2 D BCAM: Example sets • RAM: each set in a line • Transposed-RAM: indicates “pattern in set? ” patterns 0 2 3 1 1 1 • Hierarchical Search: 1. Find a set (row) with match using a 1 D BCAM 2. Search this set (row) in parallel for a specific match RAM sets 0 1 00 0 10 1 21 0 31 0 Transposed-RAM patterns • Divide address space into sets 16
Hierarchical Search 2 D BCAM: Example sets • RAM: each set in a line • Transposed-RAM: indicates “pattern in set? ” patterns 0 2 3 1 1 1 • Hierarchical Search: 1. Find a set (row) with match using a 1 D BCAM 2. Search this set (row) in parallel for a specific match RAM sets 0 1 00 0 10 1 21 0 31 0 Transposed-RAM patterns • Divide address space into sets Match pattern ‘ 3’ 16
Hierarchical Search 2 D BCAM: Example sets • RAM: each set in a line • Transposed-RAM: indicates “pattern in set? ” patterns 0 2 3 1 1 1 • Hierarchical Search: 1. Find a set (row) with match using a 1 D BCAM 2. Search this set (row) in parallel for a specific match RAM sets 0 1 00 0 10 1 21 0 31 0 Transposed-RAM patterns • Divide address space into sets 16
Hierarchical Search 2 D BCAM: Pros and Cons BRAM-Based Single match only Cannot be cascaded Single-cycle RAM depth is exponential to pattern width Efficient for deep CAMs Inefficient for wide patterns 17
Indirectly-Indexed HS BCAM: Cascadable Wide and Deep BCAM Transposed RAM is a sparse matrix Key observation n columns (set of addresses) accommodates n matches (1’s) at most! patterns PROBLEM: is it possible to regenerate matches for all addresses? addresses 1 h c 1 M a t 1 s 1 i c a t 1 o r I 1 n d 1 1 18
Indirectly-Indexed HS BCAM: Cascadable Wide and Deep BCAM Transposed RAM is a sparse matrix Key observation n columns (set of addresses) accommodates n matches (1’s) at most! Key idea: use indirect indices to point to intra-set matches Cascadable Scalable (linear growth) Supports wider patterns PROBLEM: is it possible to regenerate matches for all addresses? Sets rs o t a c I n d id i c e s In 1 1 1 Intra-set. Match Indicators 1 18
Indirectly-Indexed HS BCAM: Cascadable Wide and Deep BCAM Transposed RAM is a sparse matrix Key observation n columns (set of addresses) accommodates n matches (1’s) at most! Key idea: use indirect indices to point to intra-set matches Cascadable Scalable (linear growth) Supports wider patterns PROBLEM: is it possible to regenerate matches for all addresses? Sets rs o t a c I n d id i c e s In 1 1 1 Intra-set. Match Indicators 1 1 1 LUTRAM BRAM 18
Indirectly-Indexed HS BCAM: Example patterns 0 2 1 3 2 3 3 1 addresses 0123 00000 10001 21000 301 10 patterns • Find indices of all matching sets in Transposed-RAM • Read Indicators-RAM using indices from Transposed-RAM RAM(reference) Transposed-RAM addresses • Divide address space into sets • Store sets with a match in Indicators-RAM • Transposed-RAM stores indices to all matches in set • Hierarchical Search: 19
Indirectly-Indexed HS BCAM: Example patterns 0 2 1 3 2 3 3 1 addresses 0123 00000 10001 21000 301 10 patterns • Find indices of all matching sets in Transposed-RAM • Read Indicators-RAM using indices from Transposed-RAM RAM(reference) Transposed-RAM addresses • Divide address space into sets • Store sets with a match in Indicators-RAM • Transposed-RAM stores indices to all matches in set • Hierarchical Search: 19
Indirectly-Indexed HS BCAM: Example patterns 0 2 1 3 2 3 3 1 addresses 0123 00000 100 2 00 3 10 01 01 10 patterns • Find indices of all matching sets in Transposed-RAM • Read Indicators-RAM using indices from Transposed-RAM RAM(reference) Transposed-RAM addresses • Divide address space into sets • Store sets with a match in Indicators-RAM • Transposed-RAM stores indices to all matches in set • Hierarchical Search: Indicators-RAMs 19
Indirectly-Indexed HS BCAM: Example patterns 0 2 1 3 2 3 3 1 sets 0 1 0 - 1 2 3 10 01 01 10 patterns • Find indices of all matching sets in Transposed-RAM • Read Indicators-RAM using indices from Transposed-RAM RAM(reference) Transposed-RAM addresses • Divide address space into sets • Store sets with a match in Indicators-RAM • Transposed-RAM stores indices to all matches in set • Hierarchical Search: Indicators-RAMs 19
Indirectly-Indexed HS BCAM: Example patterns 0 2 1 3 2 3 3 1 Match pattern ‘ 3’ sets 0 1 0 - 1 2 3 10 01 01 10 patterns • Find indices of all matching sets in Transposed-RAM • Read Indicators-RAM using indices from Transposed-RAM RAM(reference) Transposed-RAM addresses • Divide address space into sets • Store sets with a match in Indicators-RAM • Transposed-RAM stores indices to all matches in set • Hierarchical Search: Indicators-RAMs 19
Indirectly-Indexed HS BCAM: Example patterns 0 2 1 3 2 3 3 1 Match pattern ‘ 3’ sets 0 1 0 - 1 2 3 10 01 01 10 patterns • Find indices of all matching sets in Transposed-RAM • Read Indicators-RAM using indices from Transposed-RAM RAM(reference) Transposed-RAM addresses • Divide address space into sets • Store sets with a match in Indicators-RAM • Transposed-RAM stores indices to all matches in set • Hierarchical Search: Indicators-RAMs 19
Indirectly-Indexed HS BCAM: Example patterns 0 2 1 3 2 3 3 1 Match pattern ‘ 3’ 0123 0110 Found in ‘ 1’ and ‘ 2’ sets 0 1 0 - 1 2 3 10 01 01 10 patterns • Find indices of all matching sets in Transposed-RAM • Read Indicators-RAM using indices from Transposed-RAM RAM(reference) Transposed-RAM addresses • Divide address space into sets • Store sets with a match in Indicators-RAM • Transposed-RAM stores indices to all matches in set • Hierarchical Search: Indicators-RAMs 19
Indirectly-Indexed HS TCAMs • Can Indirectly-Indexed HS be applied to TCAMs? Transposed-RAM patterns addresses RAM(reference) Observation: patterns TCAM addresses 0 1* (columns) may have 1 ** more than one pattern 2 11 3 0* (due to wildcards) addresses 0123 00 0 1 01 0 1 10 1 1 0 0 11 1 0 • Can we still do the same set grouping as in II-HSBCAM? The answer is YES! 20
Indirectly-Indexed HS TCAMs Transposed-RAM patterns addresses RAM(reference) Key Observation: patterns A set of n addresses 0 1* (columns) has at most 1 ** n different lines 2 11 3 0* (proof in paper) addresses 0123 00 0 1 01 0 1 10 1 1 0 0 11 1 0 21
Indirectly-Indexed HS TCAMs • Move lines to LUTRAMs and store indices • Requires n×n LUTRAMs for each set Transposed-RAM patterns addresses RAM(reference) Key Observation: patterns A set of n addresses 0 1* (columns) has at most 1 ** n different lines 2 11 3 0* (proof in paper) 00 01 10 11 addresses 0123 01 01 11 10 Indicators-RAMs 22
Indirectly-Indexed HS TCAMs: Design parameters 23
Indirectly-Indexed HS TCAMs: Design parameters 24
Indirectly-Indexed HS TCAMs: Area and Performance 25
Open Source HS BCAM (FPT’ 14) II-HS BCAM (FCCM’ 15) II-HS TCAM (FPL’ 18) Patterns support Narrow Wide Match encoding PE PE LPM Storage efficiency 90% 8% 8% Fmax (Stratix V) Up to 550 MHz Up to 300 MHz Up to 200 MHz Cycle/Update 2 2 Shallowest RAM Depth Search/cycle 1 1 1 Search latency 2 ~ log 4(depth) Available as open source: https: //github. com/Ameer. Abdelhadi • Modular and parametric Verilog files • Run-in-batch simulation and synthesis manager 26
Conclusions Single-cycle Cascadable Scalable Deep Wide Brute-Force Transposed-RAM CAMs addresses patterns BRAM-based ch t a M s r o t a c i d In 26
Conclusions Single-cycle Cascadable Scalable Deep Wide Hierarchical Search (HS) CAMs sets ch t a rs M o t t e a S ic d In patterns BRAM-based 26
Conclusions Single-cycle Cascadable Scalable Deep Wide Indirectly-Indexed HS (II-HS) CAMs sets rs Multi-unpredictable-cyclet o a s c i Ind dice In patterns BRAM-based Intra-set Match Indicators 26
Thank You!
Backup Slides
Conclusions BRAM-based Single-cycle Deep Wide sets h rs c t Maicato Ind II 2 D patterns addresses h M a t ct o r s a Indic Hierarchical patterns Brute-Force s e t s s r o t id ca ices In Ind Match Indicators 16
- Slides: 45