name: "Longest Prefix Match Router"
category: "Networking & Communications"
complexity: "Medium"
description: >
  Implement a combinational Longest Prefix Match (LPM) router.
  
  Given a 32-bit destination IP address, the module must determine the best
  matching route from the routing table below and output the corresponding
  next-hop port. If the IP matches multiple prefixes, the LONGEST matching
  prefix wins (most specific route).
  
  ROUTING TABLE (8 entries):
  
    | Prefix          | Mask Length | Next-Hop Port |
    |-----------------|-------------|---------------|
    | 10.0.0.0        | /8          | 1             |
    | 10.1.0.0        | /16         | 2             |
    | 10.1.1.0        | /24         | 3             |
    | 192.168.0.0     | /16         | 4             |
    | 192.168.1.0     | /24         | 5             |
    | 172.16.0.0      | /12         | 6             |
    | 8.8.8.0         | /24         | 7             |
    | 0.0.0.0         | /0          | 0 (default)   |
  
  OUTPUT BEHAVIOR:
  - `next_hop` is the port number (0-7) for the longest matching prefix.

interface:
  module_name: "lpm_router"
  clocked: false
  ports:
    - name: "ip_addr"
      type: "input"
      width: "32"
      description: "Destination IP address (MSB = first octet)"
    - name: "next_hop"
      type: "output"
      width: "3"
      description: "Next-hop port number (0-7)"

target_platform:
  device_family: "AMD Xilinx Zynq-7000"

tasks:
  - name: "Area-Efficient LPM Router"
    constraints:
      max_lut: 100
      max_ff: 0
      max_bram: 0
      max_dsp: 0
      min_frequency: 100
    objective:
      goal: "minimise"
      target: "LUT"
