name: "IPv4 Header Sniffer"
category: "Networking & Communications"
complexity: "Easy"
description: >
  Implement a combinational IPv4 header field extractor.
  
  The module receives the first 160 bits (20 bytes) of an IPv4 packet header
  and extracts key fields for downstream processing (e.g., routing, filtering).
  
  IPv4 HEADER FORMAT (first 20 bytes, no options):
  
    Bits  0-3:   Version (should be 4)
    Bits  4-7:   IHL (Header Length in 32-bit words, should be 5 for no options)
    Bits  8-15:  Type of Service (ignored)
    Bits 16-31:  Total Length (packet size in bytes)
    Bits 32-47:  Identification (ignored)
    Bits 48-50:  Flags (ignored)
    Bits 51-63:  Fragment Offset (ignored)
    Bits 64-71:  TTL (Time to Live)
    Bits 72-79:  Protocol (e.g., TCP=6, UDP=17, ICMP=1)
    Bits 80-95:  Header Checksum (ignored for this task)
    Bits 96-127: Source IP Address
    Bits 128-159: Destination IP Address
  
  The module should:
  1. Extract Total Length, TTL, Protocol, Source IP, and Destination IP.
  2. Assert `valid` output if Version=4 and IHL=5 (no options case).
  
  INTERFACE:
  - Input: 160-bit header (bit 0 = MSB of first byte, network byte order).
  - Outputs: Extracted fields + valid flag.

interface:
  module_name: "ipv4_parser"
  clocked: false
  ports:
    - name: "header"
      type: "input"
      width: "160"
      description: "Raw IPv4 header (160 bits = 20 bytes, MSB first)"
    - name: "valid"
      type: "output"
      width: "1"
      description: "High if Version=4 and IHL=5"
    - name: "total_length"
      type: "output"
      width: "16"
      description: "Total packet length in bytes"
    - name: "ttl"
      type: "output"
      width: "8"
      description: "Time to Live"
    - name: "protocol"
      type: "output"
      width: "8"
      description: "Protocol number (TCP=6, UDP=17, ICMP=1)"
    - name: "src_ip"
      type: "output"
      width: "32"
      description: "Source IP address"
    - name: "dst_ip"
      type: "output"
      width: "32"
      description: "Destination IP address"

target_platform:
  device_family: "AMD Xilinx Zynq-7000"

tasks:
  - name: "Efficient IPv4 Header Parser"
    constraints:
      max_lut: 20
      max_ff: 0
      max_bram: 0
      max_dsp: 0
      min_frequency: 200
    objective:
      goal: "minimise"
      target: "LUT"
