[back to the deck]

raid: a MegaRAID SAS 2108 RAID card, written in l8

Source: what this page distributes is the Verilog exported by the l8 compiler (l8i --emit, comments stripped), with its constraints and Vivado flow -- the design as Vivado builds it. The l8 sources themselves are not published.

The third card of the House of cards. The Mercury+ KX2 on the PE1 seen as an LSI (Broadcom) MegaRAID SAS 2108 RAID controller (1000:0079, class 0104, subsystem 1000:9261 = MegaRAID SAS 9260-8i), its logical drive a RAID-1 over two SATA drives on l8's own SATA host cores, on the KX2's transceivers. The controller's firmware interface (MFI: the frames, the reply queue, the DCMDs, SCSI pass-through to the logical drive), the RAID engine and the SATA hosts are written in l8.

Program a new KX2 + PE1 card

The hardware: an Enclustra Mercury+ KX2 module on a Mercury+ PE1 base board, a PC with a free PCIe x4 (or wider) slot, a Xilinx Platform Cable USB II (or a compatible JTAG cable) and Vivado's hardware server (hw_server, Vivado 2026.1 or later) on the machine the cable is plugged into -- the PC itself or another machine on the network.

1. The switches -- set them with the board UNPOWERED and no USB cable plugged in (the PE1's system controller reads CFG B when power first reaches the board). From the Mercury+ PE1 User Manual V08 (sections 5.2-5.5, 6.3) and the Mercury KX2 User Manual V08 (section 3.3):

switch position why
S1900 power slide PCIe (1-2) 12 V from the PC's slot
CFG A 1 (BOOT_MODE0) ON the FPGA boots from its QSPI flash
CFG A 2 (USB_PWR_EN#) OFF no power over USB -- required when the board is powered over PCIe
CFG A 3 (SDIO_SEL) OFF unused
CFG A 4 (PWR_ON#) ON the module powers up with the PC, no PWR button press
CFG B 1 (USB_ID) OFF
CFG B 2 (USB_SEL) OFF (B1 OFF + B2 ON is forbidden)
CFG B 3 (SCMODE0#) OFF ON turns the system controller into a JTAG programmer on the same lines and blocks the external cable
CFG B 4 (SCMODE1#) OFF
USER 1..4 (S1101) any not read by these designs
J2000 jumpers 9-10 and 3-4

2. Into the PC: the card in a PCIe x4 (or wider) slot; the JTAG cable on the PE1's header J1700 (the module's own USB JTAG did not find the device in our tests), its USB end at the machine running hw_server.

3. Power the PC on. A blank card does not show up on the PCIe bus yet -- that is fine.

The raid card has no image in this archive (no flash baseline, no demo image) and has not run on the board yet (its SATA drives need an adapter card that is not built). What applies today:

4. Your own build, loaded over JTAG (volatile, the flash untouched): make bit builds verilog/top.bit; with Linux running on the PC, remove the card's PCI device if there is one, load, rescan (as root on the PC):

echo 1 > /sys/bus/pci/devices/<BDF>/remove             # <BDF> from lspci -D, when the card is listed
sh scripts/jtag_load.sh verilog/top.bit                # [host:port] for an hw_server on another machine
echo 1 > /sys/bus/pci/rescan
lspci -nn -k -d 1000:0079

A warm reboot keeps the loaded image, a power cycle loses it. The flash path (scripts/flash_kx2.tcl, as the network card's flash_baseline.sh runs it) waits for a baseline.

Status

Linux (megaraid_sas), in QEMU works: the card's Verilog, Verilated, as a vfio-user PCI device of a QEMU guest: lspci 1000:0079 with megaraid_sas, the logical drive "L8 RAID LD" a disk, the whole disk read md5-equal, 1024 sectors written and read back (8 of 8 runs), 64-bit DMA addresses with a 5 GB guest; the RAID-1 over two simulated SATA drives in the card bench
the KX2 build routed, timing met at 200 MHz: WNS +0.225 ns, 0 failing endpoints (2026-11-23); 11371 LUTs, 9871 registers, 6 GTX
on the board not yet: the SATA drives need a small adapter card on the PE1's I/O connector (designed, not built)
Windows 10 / 11 not run; whether the inbox driver takes the 2108 is a lead to be checked
image no baseline image yet

The design document with its log: docs/plan.md. The board steps, for when the adapter exists: docs/HOWTO.md.

Download: l8raid-dist.tar.gz (396K): the card as Verilog with its constraints and Vivado flow, the design document and the HOWTO.

What is in the archive

path what
verilog/ the card as Verilog, emitted without comments: top.v (the board: pins, clocks, the PCIe block, the two SATA transceivers), storage_kx2.v (the card), top.xdc, top.tcl, pcie7x.cfg, Makefile
scripts/ jtag_load.sh (a bitstream over JTAG, volatile; --dry-run), the Vivado scripts jtag_prog.tcl, flash_kx2.tcl
docs/ plan.md (the chip's choice, the layers, the test ladder, the log), HOWTO.md

make bit builds verilog/top.bit (Vivado 2026.1 or later, XC7K160T). THE CARD WRITES WHAT THE HOST WRITES, TO BOTH DRIVES: only drives whose content may go. The design's l8 sources are not in the archive.

[back to the deck]