Commit Graph

137 Commits

Author SHA1 Message Date
ce40a6df42 perf(mlkem): stream compress feed (B1) — ~27% fewer Encaps cycles
Decouple the ENC_C1/C2 compress micro-sequence into a streaming
producer/collector instead of feeding one coeff and draining the whole
6-stage comp_decomp pipeline per coeff.

- comp_decomp_sync: ready_o = 1'b1 (fully pipelined, consumer never
  backpressures since ready_i is tied high), so feeders can issue a new
  coeff every cycle.
- mlkem_top ENC_C1/C2: producer feeds one coeff every 2 cycles
  (<=5.5 bit/cyc, under the single-port ct drain of 8 bit/cyc so the bit
  buffer stays bounded); a per-cycle collector appends compressed bits
  and drains one ct byte/cycle.

Verified byte-exact against NIST KAT (Vivado 2019.2 XSIM) for KeyGen,
Encaps (9/9), Decaps (9/9 incl. reject path + DECOMP), hello_world e2e.

K=2 Encaps: ENC_C1 6273->1035, ENC_C2 2945->522, total 27851->20190.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-11 02:00:03 +08:00
6a1b374bc1 set mlkem_clk to 50Mhz 2026-07-08 17:01:46 +08:00
ab4751bfd3 doc: add ML-KEM IP design report with figures 2026-07-08 04:42:11 +08:00
3d2917a807 add examples/mlkem_hello 2026-07-08 04:41:37 +08:00
5a3529d09b update vivado reports 2026-07-08 04:20:27 +08:00
4229652659 fix: add use_dsp=no to FFT Multiply and fft_mlkem_axi_slave
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-08 03:57:39 +08:00
f676fc6e60 add vivado reports 2026-07-08 03:48:37 +08:00
b003fc057f fix(mlkem): verilator lint fixes — BLKLOOPINIT and UNUSEDSIGNAL
ntt_core.v / poly_mul_sync.v: <= → = in array for loops
mlkem_top.v / sha3_top.v: UNUSEDSIGNAL → UNUSED

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-08 03:36:52 +08:00
1b494fe44d add use_dsp=no for matmul 2026-07-08 03:20:34 +08:00
94f8f443d3 add mlkem test results 2026-07-08 03:18:19 +08:00
83473b66aa remove dsp usage 2026-07-08 03:18:10 +08:00
0c85a20b4e mlkem test diagnostics and allocator updates 2026-07-08 02:35:56 +08:00
65607badd2 add vivado reports v0.1 2026-07-06 00:03:57 +08:00
34ce639f69 test(fft): update fft_dma example
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-05 23:25:51 +08:00
088a9bd5b8 fix(fft): update SdfUnit, Twiddle, and axi wrapper
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-05 23:25:51 +08:00
e8893a28dd mlkem_test: add mlkem-native 2026-07-05 21:26:39 +08:00
cd039e2e2e mlkem_test: add mlkem-native 2026-07-05 21:26:19 +08:00
b8ddb2ef08 c program: use prng 2026-07-05 21:04:42 +08:00
54ec54d421 feat: add prng 2026-07-05 21:04:25 +08:00
19751b9d18 add no dsp hint for FFT 2026-07-05 20:37:19 +08:00
4eca83bd3d Add MLKEM DMA comparison test 2026-07-05 20:23:58 +08:00
69de12e79f update test data and remove mif files 2026-07-05 20:16:13 +08:00
ca1472d859 Stop tracking generated binary images 2026-07-05 20:12:56 +08:00
2b7c43edcb Add DMA-friendly MLKEM windows 2026-07-05 20:07:14 +08:00
d13f7933d8 Optimize FFT test input generation 2026-07-05 19:48:16 +08:00
7e72bd455a feat: add fft module 2026-07-05 19:30:51 +08:00
48072c5ecb remove all the LF 2026-07-05 18:23:23 +08:00
264e65f8d9 optimize uart output 2026-07-05 17:59:31 +08:00
7281df356f feat: optimize startup and linking 2026-07-05 17:27:26 +08:00
423ff32b49 feat: optimize sram read channel 2026-07-05 17:12:38 +08:00
f735f789d6 remove dsp usage 2026-07-04 21:20:32 +08:00
d3a08b1f9d Split CDMA matmul endpoint engines 2026-07-04 20:42:31 +08:00
2725f6eb57 Reduce CDMA matmul bridge request latency 2026-07-04 20:12:45 +08:00
27cdfb713a Optimize CDMA matmul bridge scheduling 2026-07-04 19:59:49 +08:00
c37f493bcb Compute matmul CRC before result store 2026-07-04 19:45:22 +08:00
bf6051c8c6 Add standalone CDMA matmul bridge 2026-07-04 19:35:42 +08:00
b7553418fa Add direct CDMA matmul path 2026-07-04 19:15:34 +08:00
3f7c9b7a37 feat: optimize sram write channel 2026-07-04 18:54:05 +08:00
58f99d82ba chore: typo 2026-07-04 18:53:23 +08:00
3d39fc2f5e doc(mlkem): add mlkem user guide 2026-06-30 15:23:13 +08:00
29313653a9 fix(mlkem): replace Barrett division with direct / and % in comp_decomp_sync
The previous Barrett multiplication-based division was incorrect. Both
compress and decompress used the same wrong implementation, so they
happened to be consistent with each other, but the math was wrong.

Replace with synthesizer-native / and % operators. This is cleaner
and the synthesis tool handles integer division/remainder correctly
for these small operand widths (12-bit dividend, 12-bit divisor).

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-30 03:32:20 +08:00
3617ee7656 fix: change <= to = in array for loops for verilator BLKLOOPINIT 2026-06-30 02:15:14 +08:00
99e6c884d7 chore: untrack auto-generated PLL files, add .gitignore 2026-06-30 02:10:29 +08:00
542495cb52 fix: replace UNUSEDPARAM/UNUSEDSIGNAL with UNUSED for verilator lint
Verilator does not recognize UNUSEDPARAM or UNUSEDSIGNAL.
Correct suppression code is UNUSED.
2026-06-30 02:10:07 +08:00
92777efd30 fix: drive dbg_dk_idx_i only during full-dk readback
The core's ek_rd_addr/dkp_rd_addr muxes give dbg_dk_idx_i priority over
dbg_byte_idx_i whenever it falls in the ek (768..1567) or dk_pke (<768)
region. The wrapper drove both dbg_byte_idx_i and dbg_dk_idx_i from the
same rdb_addr, so an ek readback of the rho tail (bytes 768..799) was
hijacked to read ek[0..31] instead — corrupting the public key fed to
Encaps and causing Decaps implicit rejection (full 32-byte ss mismatch).

Present rdb_addr on dbg_dk_idx_i only when rdb_sel==2 (full-dk); hold it
at 0xFFF otherwise so ek/dk_pke readbacks aren't corrupted. Verified by
KeyGen->Encaps->Decaps round trip (MLKEM_RESULT=PASS).
2026-06-30 02:00:50 +08:00
c5072d7170 feat: add ML-KEM accelerator with AXI slave wrapper
Wrap mlkem_top in an AXI4 burst slave (mlkem_axi_slave) mapped to the
freed FFT slot 6 at 0x1f400000 (virtual 0xbf400000). The core runs on
sys_clk/2 (25 MHz); the wrapper handles the clock-domain crossing:
start toggle->pulse, wait-stated byte-preload handshake, busy/done
sync, and direct readback taps (ek/dk/ct/ss). CPU drives it via a
register map (CTRL/STATUS/CONFIG, d/z/msg, preload + readback windows).

Wire into soc_top on the existing axiOut_6 nets (no crossbar change),
add mlkem_intr on intrpt[3]. Add sdk mlkem_test example running a
KeyGen->Encaps->Decaps self-consistency round trip.
2026-06-30 01:39:35 +08:00
95fe94063c fix: revert UART FIFO batching — caused FIFO overflow + syserr on board
uart_puts(13B) + uart_puthex(8B) = 21 bytes without polling → FIFO overflow.
Board UART IP asserts AXI error → CPU syserr exception.
Simulation UART model is lenient, so sim passed but board failed.

Back to per-byte polling (safe).
2026-06-26 23:53:15 +08:00
9202327dd0 perf: batch UART FIFO writes — poll once per 16 bytes instead of per byte
uart_puts: burst-write up to 16 chars before polling LSR
uart_puthex: write all 8 hex digits without polling (8 < 16 FIFO depth)

Reduces AXI register reads from ~50 to ~3 per CRC output.
Each saved poll: -1 uncached AXI read (~390ns)
2026-06-26 23:48:23 +08:00
52e85aa6fb perf: drop stdint.h + picolibc — zero libc dependency
dma.h: typedef u32 instead of uint32_t, no stdint.h include
dma.c: use u32 instead of uint32_t
user-sample.c: unsigned char/int instead of uint8_t/uint32_t

Makefile: filter-out -lc -lm -lg -lsemihost from LDFLAGS
  → picolibc .data section (2.1KB, 532 words) eliminated
  → startup data-copy loop: ~30000 → ~200 cycles
  → total start.S latency: ~44000 → ~14000 cycles (~0.42ms at 33MHz)
2026-06-26 22:34:26 +08:00
dd6053ab73 add test data 2026-06-26 21:36:55 +08:00