← Work
Simulation waveform: after the start pulse, the valid signals for issue, z, x, e, s and p rise in sequence, then the running sum starts to change.
Pipeline fill after start: each stage's valid bit rises one cycle after the previous stage's (three cycles through the exp unit), so p_valid rises 8 cycles after start, and a new path finishes every clock after that.

Monte Carlo option pricer on an FPGA

A Monte Carlo pricer estimates an option's value by simulating many random price paths and averaging their payoffs. The catch is the error: it shrinks only as 1/√n, so every extra digit of accuracy costs 100× more paths. I built a pricer in hardware to make paths cheap: fully pipelined, in fixed point, finishing one path every clock cycle on a Lattice ECP5-85F.

Line chart: a Monte Carlo call-price estimate converging to the Black-Scholes price of 10.4506 between 100 and about 3 million paths, inside a narrowing ±2 standard error band.
A Monte Carlo call-price estimate closing in on the Black-Scholes price (10.4506) as paths increase. The band is ±2 standard errors.

The pipeline

The design is built from xorshift random number generators, a CLT Gaussian adder tree and a block-RAM exponential unit. Each stage passes a valid bit to the next: z, x, e (three cycles through the exp unit), s and p, into the running sum. The RTL's prices land within 2σ of Black-Scholes.

The letters are the signal each stage produces, named after the math:

  • z: the standard normal sample Z ~ N(0,1), the sum of 12 uniforms minus 6.
  • x: the exponent x = a + b·Z, where a = (r − σ²/2)T and b = σ√T. This is the stock's log-return over the year.
  • e: eˣ, the growth factor for the path. It takes 3 cycles: the table read plus two pipeline registers.
  • s: S_T = S₀·eˣ, the simulated stock price at expiry.
  • p: the payoff, max(S_T − K, 0): what the call option pays on this path.
issuestartz1 cycleZ ~ N(0,1)(xorshift RNGs +CLT adder tree)x1 cyclex = a + b·Zlog-returne3 cyclese^x, growth factor(block-RAM exp unit)s1 cycleS_T = S₀·e^xprice at expiryp1 cyclemax(S_T − K, 0)payoffΣrunning sum8 cycles to fill, then 1 path / cycle
The stages behind the waveform above, one path per cycle.

Sizing the numbers

I sized the datapath with a fixed-point error sweep across every fraction width from 4 to 20 bits. Rounding error came out 28× below the Monte Carlo noise. The sweep also uncovered a systematic rounding bias that grew as fractional bits were added: 14 bits did worse than 12.

Log-scale chart of price error against fraction bits from 4 to 20, dropping below the Monte Carlo noise line from 11 bits on, with a bump at 14 bits.
Price error from quantization at each fraction width, against Monte Carlo noise (1 standard error at 1,000,000 paths).

The exponential unit was checked against math.exp on all 262,144 inputs. The worst case is ±2.61 LSB, with one LSB = 2⁻¹⁵.

Exp unit error in LSBs for every input from −2 to 2, all within ±2.61 LSB.
Exp unit error on every possible input, x from −2 to 2.

Making it fast

Two rounds of critical-path pipelining raised Fmax from 61.6 to 89.1 MHz, a 45% gain, for 69 extra flip-flops. Pipelining the exp unit reached 72.6 MHz; splitting the payoff stage reached 89.1 MHz. The remaining critical path is the exp multiply into two adds, with about 40% of its delay in routing. At one path per cycle, Fmax is throughput: 89.1 million paths per second from one lane.

Bar chart of Fmax: 61.6 MHz at baseline with 376 flip-flops, 72.6 MHz with a pipelined exp unit (423), and 89.1 MHz with a split payoff stage (445).
Fmax and flip-flop count after each pipelining step, with the critical path that limited each one.
after an 8-cycle pipeline fill
1 path / cycle
Fmax, up from 61.6 (+45%)
89.1 MHz
flip-flops for the speedup (376 → 445)
+69
rounding error below Monte Carlo noise
28×

Proving it right

Every block is verified bit-exact against Python models in cocotb: 9 tests, about 6,000 random vectors and 13 corner cases. On top of that, the exp unit was checked exhaustively, on all 262,144 inputs.