name: "Priority-Based Packet Filter"
category: "Networking & Communications"
complexity: "Medium"
description: >
  Implement a combinational packet filter (stateless firewall).
  
  The module examines packet header fields and decides whether to ALLOW or DROP
  the packet based on the firewall rules below. Rules are evaluated in order;
  the first matching rule determines the action.
  
  FIREWALL RULES (evaluated in priority order):
  
    | Priority | Match Condition                          | Action |
    |----------|------------------------------------------|--------|
    | 1        | Source IP in 10.0.0.0/8                  | DROP   |
    | 2        | Source IP in 192.168.0.0/16              | DROP   |
    | 3        | Protocol = ICMP (1)                      | ALLOW  |
    | 4        | Protocol = TCP (6) AND dst_port = 80     | ALLOW  |
    | 5        | Protocol = TCP (6) AND dst_port = 443    | ALLOW  |
    | 6        | Protocol = TCP (6) AND dst_port = 22     | ALLOW  |
    | 7        | Protocol = UDP (17) AND dst_port = 53    | ALLOW  |
    | 8        | (Default) No match                       | DROP   |

interface:
  module_name: "packet_filter"
  clocked: false
  ports:
    - name: "src_ip"
      type: "input"
      width: "32"
      description: "Source IP address"
    - name: "dst_port"
      type: "input"
      width: "16"
      description: "Destination port number"
    - name: "protocol"
      type: "input"
      width: "8"
      description: "IP protocol (ICMP=1, TCP=6, UDP=17)"
    - name: "allow"
      type: "output"
      width: "1"
      description: "1 = Allow packet, 0 = Drop packet"

target_platform:
  device_family: "AMD Xilinx Zynq-7000"

tasks:
  - name: "Area-Efficient Packet Filter"
    constraints:
      max_lut: 60
      max_ff: 0
      max_bram: 0
      max_dsp: 0
      min_frequency: 150
    objective:
      goal: "minimise"
      target: "LUT"
