Design a multi-leg options position P&L calculator that computes the unrealized
profit/loss for each leg and aggregates them, using signed fixed-point arithmetic.

Module name: multi_leg_pnl
Parameters:
  - WIDTH    = 24   // Total bit width (Q15.8 fixed-point)
  - FRAC     = 8    // Fractional bits
  - MAX_LEGS = 4    // Number of legs

Ports:
  - input  clk, rst_n
  - input  [WIDTH-1:0]           market_price   // current underlying price
  - input  [MAX_LEGS*WIDTH-1:0]  entry_prices   // entry price per leg (flat bus)
  - input  [MAX_LEGS*WIDTH-1:0]  quantities     // signed quantity per leg (flat bus, positive=long, negative=short)
  - input                        valid_in
  - output signed [WIDTH-1:0]    total_pnl      // sum of all legs' unrealized P&L
  - output signed [WIDTH-1:0]    max_leg_pnl    // P&L of the best-performing leg
  - output signed [WIDTH-1:0]    min_leg_pnl    // P&L of the worst-performing leg
  - output                       valid_out

Functional specification:
  - For each leg i: pnl_i = quantity_i * (market_price - entry_price_i)
  - Signed fixed-point multiply (Q15.8 * Q15.8 -> Q15.8, truncate after >> FRAC)
  - total_pnl = sum of pnl_i across all MAX_LEGS legs
  - max_leg_pnl = max(pnl_0, pnl_1, ..., pnl_{MAX_LEGS-1})
  - min_leg_pnl = min(pnl_0, pnl_1, ..., pnl_{MAX_LEGS-1})
  - Registered output (1 cycle latency)
  - valid_out mirrors valid_in with 1 cycle delay
