FPGA & digital Built · controlled demonstration
FPGA Orderbook Engine
Hardware that reads market-style packets and keeps an up-to-date best bid and ask.
What I did
I wrote the Ethernet, IPv4 and UDP parsers, an ITCH-style decoder, the order table and top-of-book logic, and an AXI4-Lite peripheral.
A MicroBlaze program injects test packets, including bad frames, and reports results over UART.
Result
- On the board, valid packets update the book and invalid frames increment the drop counter.
- Timing closed at 100 MHz on Spartan-7; about 13k LUTs and 280 mW for the build.
- A controlled demo with software-injected packets, not a live feed or a trading engine.
- Power is a build figure, not a bench measurement; no per-packet latency is claimed.
Design decision
Inject packets from software
A MicroBlaze program writes packet bytes into a FIFO. Every test is reproducible without a working network MAC, at the cost of a demo rate set by software, not the parser.
Try it
Step through the messages and watch the book update.
Empty book. No messages applied.
Messages
- A Add buy #1: 300 at 99
- A Add sell #2: 200 at 101
- A Add buy #3: 150 at 98
- A Add sell #4: 250 at 102
- A Add buy #5: 100 at 99
- X Cancel 150 from #3
- E Execute 120 against #2
- E Execute 80 against #2
- U Replace #5 with #6: 180 at 100
- A Add sell #7: 120 at 101
- X Cancel 100 from #1
Top of book
- Best bid
- none
- Best ask
- none
Depth by price tick
bids (buy) asks (sell)
Active orders
| Order | Side | Price | Qty |
|---|---|---|---|
| No active orders. | |||
Best prices by message
More detail
Layered parsing
Each header layer is checked and stripped before the message is decoded. A malformed frame is consumed to its end so the parser stays aligned.
Parsers and the order table
Each parser accepts a byte only when valid and ready are both high, so backpressure can't corrupt header offsets. The decoder packs big-endian fields into one structure.
Active orders sit in parallel arrays. After each update, logic finds the highest buy and lowest sell and sums the quantity at each. The top of book covers the whole table, not each symbol.
Testing
Testbenches covered Ethernet accept and drop, each order operation and its errors, register reads and integrated packet injection.
Other design decisions
Replace in two steps
Remove the old order, then insert the new one in the next state. Instead of: both in one cycle.
Avoids reusing a slot before it is visibly free, for one extra state.
UART instead of HDMI
Print results over UART and plot them in Python. Instead of: the HDMI display tried early on.
Dropping a fragile display path kept the focus on the book logic.