Files
mlkem-sync/.trellis/tasks/archive/2026-06/06-27-fix-kg-compute/prd.md

21 lines
817 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 修复 KeyGen 计算路径
## Goal
修复 `mlkem_top.v` 中 KeyGen 的占位状态,实现 t_hat、pk、sk 的实际计算,使 `./run_tb.sh top` 中 KeyGen 产生非零输出。
## Current Issues
1. KeyGen 的 t_hat 计算poly_mul + poly_arith是占位`phase_done <= 1'b1`
2. `pk_o_r` / `sk_o_r` 从未被赋值(默认 0
3. `rng_valid_i` 竞态(可能已跨过,仿真确认 FSM 在跑)
## Fix Plan
1. 实现 `S_KG_TMUL_LOAD/COMP/OUT` 状态 → 调用 poly_mul_sync 计算 t_hat
2. 实现 `S_KG_ADD` → 调用 poly_arith_sync
3.`S_KG_DONE` 中赋值 `pk_o_r = {t_hat polys, rho}``sk_o_r = {s_hat polys}`
4. 验证:`./run_tb.sh top` KeyGen 输出非零
## Out of Scope
- Encaps/Decaps 修复
- pk/sk ByteEncode 编码(先输出 raw 12-bit coeffs
- KAT 数值完全匹配