name: "Key-Value Database with Round-Robin Replacement"
category: "Algorithmic Hardware Primitives"
complexity: "Medium"
description: >
  Implement a small Key-Value Store accelerator with GET and PUT operations.
  
  The module maintains an 8-entry cache of key-value pairs. Each key is 8 bits
  and each value is 16 bits. The store supports two operations:
  
  OPERATIONS:
  - GET (op=0): Look up the key. If found, output the value and set hit=1.
                If not found, output is undefined and hit=0.
  - PUT (op=1): Store the key-value pair. If the key already exists, update
                its value. If the key is new, store it in the first available
                empty slot. If the store is full and the key is new, overwrite
                the oldest entry (slot 0, then 1, etc. in round-robin fashion).
  
  TIMING:
  - Operations are initiated on the rising edge of clk when enable=1.
  - Results (value_out, hit) are valid on the next clock cycle.
  - When enable=0, the store retains its state but outputs are undefined.
  
  RESET:
  - Synchronous active-high reset clears all entries (all slots become empty).
  
  SLOT MANAGEMENT:
  - Empty slots are indicated internally (implementation choice).
  - PUT to an existing key updates in-place without consuming a new slot.
  - Round-robin replacement starts at slot 0 after reset.

interface:
  module_name: "kv_store"
  clocked: true
  ports:
    - name: "clk"
      type: "input"
      width: "1"
      description: "Clock signal"
    - name: "rst"
      type: "input"
      width: "1"
      description: "Synchronous reset, active high"
    - name: "enable"
      type: "input"
      width: "1"
      description: "Operation enable"
    - name: "op"
      type: "input"
      width: "1"
      description: "Operation: 0=GET, 1=PUT"
    - name: "key"
      type: "input"
      width: "8"
      description: "Key to look up or store"
    - name: "value_in"
      type: "input"
      width: "16"
      description: "Value to store (for PUT operation)"
    - name: "value_out"
      type: "output"
      width: "16"
      description: "Value retrieved (for GET operation)"
    - name: "hit"
      type: "output"
      width: "1"
      description: "1 if key was found (GET) or stored (PUT)"

target_platform:
  device_family: "AMD Xilinx Zynq-7000"

tasks:
  - name: "Area-Efficient Key-Value Store"
    constraints:
      max_lut: 300
      max_ff: 200
      max_bram: 0
      max_dsp: 0
      min_frequency: 100
    objective:
      goal: "minimise"
      target: "LUT"
