Просмотр исходного кода

Converge CPLD project on real FAN PTC diagnostic

Codex 5 месяцев назад
Родитель
Сommit
f9488f1c17
100 измененных файлов с 10494 добавлено и 1384 удалено
  1. 23 12
      .gitignore
  2. 26 0
      AGENTS.md
  3. 56 0
      README.zh-CN.md
  4. 420 0
      config/pid_channels.json
  5. 82 0
      config/pin_inventory.fcb_fpga_mcu0611.json
  6. 131 0
      config/pin_inventory.mini.json
  7. 12 0
      config/pin_inventory.product.placeholder.json
  8. 10 0
      constraints/pid_study_01.adc
  9. 1 0
      constraints/pid_study_01.sdc
  10. 23 0
      constraints/uart_rs232_j6_host_sensor_real_fan_ptc_debug921_primary.adc
  11. 41 0
      docs/bmc-uart-temperature-protocol-v2.zh-CN.md
  12. 0 76
      docs/cpld-html-teaching-requirements.zh-CN.md
  13. 35 0
      docs/fact-source-boundary.zh-CN.md
  14. 24 0
      docs/fake-stress-verification-v2.zh-CN.md
  15. 23 0
      docs/high-temp-chamber-design-v2.zh-CN.md
  16. 28 0
      docs/interface-contract.zh-CN.md
  17. 104 0
      docs/j6-host-sensor-real-fan-ptc-debug921-runbook.zh-CN.md
  18. 96 0
      docs/offline-fidelity-gate-v1.zh-CN.md
  19. 15 0
      docs/offline-verification-report.zh-CN.md
  20. 23 0
      docs/pid-safety-contract-v2.zh-CN.md
  21. 16 0
      docs/td-2026.1-evidence-index.zh-CN.md
  22. 29 0
      docs/uart-rs232-validation-strategy.zh-CN.md
  23. 56 0
      docs/verification-gates-v2.zh-CN.md
  24. 48 0
      docs/verification-plan.zh-CN.md
  25. 15 0
      reference/original/MANIFEST.zh-CN.md
  26. 53 29
      workspace/cpld_temperature_control_board/td_project/demo.al
  27. 14 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/constraint_source/test_lvds.adc
  28. 5 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/constraint_source/test_lvds.sdc
  29. 147 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/design_top_wrapper.v
  30. 81 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/led.v
  31. 57 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/new_src/lvds_rec_8_1.v
  32. 74 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/new_src/lvds_rec_intf_8_1.v
  33. 63 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/new_src/lvds_snd_8_1_m.v
  34. 109 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/new_src/lvds_snd_intf_8_1_m.v
  35. 77 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/prbs/prbs_chk.v
  36. 64 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/prbs/prbs_gen.v
  37. 44 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/ip_source/lvds_pll.ipc
  38. 111 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/ip_source/lvds_pll.v
  39. 121 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/ip_source/lvds_pll.vhd
  40. 55 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/ip_source/lvds_pll_rx.ipc
  41. 120 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/ip_source/lvds_pll_rx.v
  42. 131 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/ip_source/lvds_pll_rx.vhd
  43. 0 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/sim_source/.lvds_bak.cwc
  44. 55 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/sim_source/lvds.cwc
  45. BIN
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0原理图/EF2L45BG256B_MINI_V2.0 DEMO板源文件/EF2L45BG256B_MINI_V2.0.DSN
  46. BIN
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0原理图/EF2L45BG256B_MINI_V2.0 DEMO板源文件/EF2L45BG256B_MINI_V2.0.brd
  47. BIN
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0原理图/EF2L45BG256B_MINI_V2.0dsn.pdf
  48. 2555 0
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0原理图/EF2L45BG256B_MINI_V2.0丝印.pdf
  49. BIN
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0板文档/TN426_安路科技EF2L45BG256B_MINI板应用例程使用指南.pdf
  50. BIN
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0板文档/TN427_安路科技EF2L45BG256B_MINI板硬件使用指南.pdf
  51. BIN
      reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256M_MINI_DEV3.pdf
  52. 21 0
      reference/original/diagrams/上位机逻辑.svg
  53. 21 0
      reference/original/diagrams/接长鑫水滴系统.svg
  54. BIN
      reference/original/schematics/FCB_FPGA+MCU0611.pdf
  55. 38 0
      schemas/bmc_uart_protocol_receipt.schema.json
  56. 53 0
      schemas/cpld_bmc_acceptance_v1_receipt.schema.json
  57. 72 0
      schemas/final_gate_v2_receipt.schema.json
  58. 88 0
      schemas/j6_host_sensor_real_fan_ptc_debug921_pin_conflict_blocked_manifest.schema.json
  59. 59 0
      schemas/j6_host_sensor_real_fan_ptc_debug921_pin_conflict_blocked_package.schema.json
  60. 49 0
      schemas/j6_host_sensor_real_fan_ptc_debug921_pin_conflict_blocked_sha256_inventory.schema.json
  61. 292 0
      schemas/offline_fidelity_gate_v1_receipt.schema.json
  62. 236 0
      schemas/real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt.schema.json
  63. 169 0
      schemas/real_bmc_j6_windows_gate_v2_receipt.schema.json
  64. 69 0
      schemas/uart_board_sram_receipt.schema.json
  65. 50 0
      schemas/uart_loopback_receipt.schema.json
  66. 39 0
      schemas/uart_preflight_receipt.schema.json
  67. 38 0
      schemas/uart_soak_receipt.schema.json
  68. 0 881
      scripts/generate_cpld_teaching_html.py
  69. 0 386
      scripts/validate_cpld_teaching_html.py
  70. 161 0
      src/rtl/actuator_domain.v
  71. 75 0
      src/rtl/actuator_sink.v
  72. 108 0
      src/rtl/bmc_dimm_frame_parser.v
  73. 385 0
      src/rtl/bmc_uart_ascii_poll.v
  74. 73 0
      src/rtl/bmc_uart_phy_bridge.v
  75. 307 0
      src/rtl/bmc_uart_raw48_poll_lite.v
  76. 19 0
      src/rtl/board_io_adapter.v
  77. 275 0
      src/rtl/control_service_24ch.v
  78. 45 0
      src/rtl/debug_probe_bus.v
  79. 51 0
      src/rtl/debug_register_window.v
  80. 145 0
      src/rtl/debug_snapshot_v2.v
  81. 66 0
      src/rtl/debug_trace_recorder_bram.v
  82. 35 0
      src/rtl/debug_trigger_unit.v
  83. 122 0
      src/rtl/debug_uart_stream.v
  84. 54 0
      src/rtl/fake_host_config.v
  85. 158 0
      src/rtl/fake_sensor_source.v
  86. 148 0
      src/rtl/fan_tach_domain.v
  87. 131 0
      src/rtl/host_command_plane.v
  88. 88 0
      src/rtl/hysteresis_pi_controller.v
  89. 95 0
      src/rtl/i2c_master_sensor_adapter.v
  90. 177 0
      src/rtl/i2c_slave_register_frontend.v
  91. 71 0
      src/rtl/motor_limit_domain.v
  92. 206 0
      src/rtl/pid_24ch_scheduler.v
  93. 269 0
      src/rtl/pid_control_regfile.v
  94. 85 0
      src/rtl/pid_core.v
  95. 136 0
      src/rtl/ptc_output_bank.v
  96. 106 0
      src/rtl/safety_supervisor.v
  97. 105 0
      src/rtl/sensor_domain.v
  98. 121 0
      src/rtl/sensor_source_mux.v
  99. 110 0
      src/rtl/source_arbitrator.v
  100. 0 0
      src/rtl/uart_rx_8n1.v

+ 23 - 12
.gitignore

@@ -1,34 +1,45 @@
 # Local/private files
+*.lic
 Anlogic.lic
 
-# Vendor installers, archives, and source PDFs.
+# Original local archives and vendor payloads are inventoried, not tracked.
+reference/original/local_archives/**
+reference/original/vendor/**
 *.exe
 *.rar
 *.zip
+*.7z
 ANLOGIC_CD/
 
-# TD generated outputs and local GUI state.
-workspace/temperature_control_board_repo/
-workspace/cpld_temperature_control_board/td_project/demo_Runs/
-workspace/cpld_temperature_control_board/td_project/log/
-workspace/cpld_temperature_control_board/td_project/.recent_user_depot.ini
-workspace/cpld_temperature_control_board/user_source/新建 文本文档*.txt
+# Deprecated workspaces must not become active project roots again.
+workspace/
+dist/
+_archive/
+
+# TD/generated outputs and local GUI state.
+tmp/
+receipts/local/
+td/build/
+td/project/.lock.f
+td/project/*_Runs/
+td/project/log/
+td/project/.recent_user_depot.ini
 *.db
 *.bit
 *.bid
+*.data
 *.timing
 *.rpt
 *.area
 *.qor
 *.log
 *.logw
-
-# Generated teaching backups and validation receipts.
-workspace/teaching_backups/
-workspace/teaching_receipts/
-tmp/
+minidump-*.dmp
+a.out
+tmp_last_pkg*.txt
 
 # Python/runtime caches.
+.codex/
 __pycache__/
 *.py[cod]
 .pytest_cache/

+ 26 - 0
AGENTS.md

@@ -0,0 +1,26 @@
+# CPLD Agent Instructions
+
+本仓库是单一顶层 CPLD PID 工程。workspace 不再是活工程入口,不能新增旧 study、教学工程或运行副本作为开发入口。
+
+## 工程边界
+
+- 活源码只放在 `src/rtl/`、`src/top/`。
+- 活验证只放在 `tests/`、`tools/`、`td/`、`config/`、`constraints/`、`schemas/`。
+- 原始资料只放在 `reference/original/`;安装包、license、私有压缩包只能本地保留并由 `.gitignore` 排除。
+- 不要把 `td/build/`、`tmp/`、TD GUI runtime、bit/bid/data/log/timing/area 当成源码基线。
+
+## 验证边界
+
+- 当前 final gate 是 `final-gate-v2`,证据核心是 software/model/replay/RTL/formal/detector/TD elaboration/UART strict receipt。
+- `uart-preflight` 只能枚举串口,禁止打开未知 COM 口或切换 DTR/RTS。
+- `uart-board-sram-test` 类 receipt 只允许 `PROGRAM_SRAM`,必须记录 bitstream hash、串口 transcript hash、debug UART 事件流、register dump 和 counterparty。
+- `final-gate-v2` 只接受所有 required layer 为 `pass`;`blocked_*`、`fail_*`、dry-run、fixture 或缺证据都不等于 pass。
+- 机器 gate 的 pass 只声明控制通讯链路和软件安全策略通过,不声明完整 thermal performance。
+
+## 安全边界
+
+禁止 flash、驱动安装/重装、真实 PTC/fan/BMC 未受控动作。任何出现 `PROGRAM_FLASH`、`ERASE_FLASH`、`PROGRAM_SPIBIN`、`DIRECT_FLASH_WRITE`、真实热闭环动作的路径必须 fail closed。
+
+## 更新要求
+
+新增真实板级 PID、flash、驱动、外部仪器或生产硬件动作时,必须同时新增独立 gate、receipt schema、rollback/安全边界和中文 runbook。

+ 56 - 0
README.zh-CN.md

@@ -0,0 +1,56 @@
+# CPLD PID 顶层工程
+
+本仓库只有一个正式工程入口:repo 顶层。旧 study、教学工程、运行副本和旧桌面调试路径不再作为活工程入口。
+
+## 目录
+
+- `src/rtl/`:可综合 RTL,包括 24 路 PID、BMC UART 文本协议、物理 UART RX/TX、safety、debug 和执行域。
+- `src/top/`:正式 top,包括 `system_contract_top.v` 和 `uart_rs232_j6_host_sensor_real_fan_ptc_debug921_top.v`。
+- `tests/sim/`、`tests/formal/`、`tests/cocotb/`、`tests/fixtures/`:RTL 仿真、形式验证、cocotb 和 detector selftest。
+- `tools/`:`pid_harness.py`、`uart_receipts.py`、static checks、toolchain probe、pin inventory 和 debug bundle 工具。
+- `td/`:TD 2026.1 source project file;当前唯一用户主入口是 `td/uart_rs232_j6_host_sensor_real_fan_ptc_debug921_primary.prj`。
+- `config/`、`constraints/`、`test_vectors/`:工程合同、MINI 安全 IO 约束和 replay vectors。
+- `schemas/`:UART receipt、pin inventory 和 final-gate-v2 schema。
+- `reference/original/`:原始板卡资料和来源索引,不是活工程入口。
+
+## 正式范围
+
+当前工程声明以下能力进入正式开发范围:
+
+- 24 路 PID/control contract。
+- BMC UART text parser/poll 与 `115200 8N1` 物理 UART RX/TX。
+- safety supervisor、PTC force-off、fan fallback、10s stale 和 90C overtemp contract。
+- fake/model/replay、RTL/HDL sim、formal、detector selftest、TD elaboration、UART receipt 和 debug bundle。
+- RS232 只作为外部电平转换链路;FPGA IO 侧必须是 3.3V UART,不能直接接 RS232 电平。
+
+机器 `pass` 只声明控制通讯链路和软件安全策略通过,不声明完整热性能认证。真实热性能必须由中文 runbook 中的人工/仪器记录承接。
+
+## 常用命令
+
+```powershell
+python tools\pid_harness.py static
+python tools\pid_harness.py model
+python tools\pid_harness.py hdl-sim --run --backend icarus --json
+python tools\pid_harness.py formal --run --json
+python tools\pid_harness.py detector-selftest --run --json
+python tools\pid_harness.py td-build --run --top uart_rs232_j6_host_sensor_real_fan_ptc_debug921_primary --json
+python tools\pid_harness.py uart-preflight --allowlist COM7 --json
+python tools\pid_harness.py uart-protocol-offline --text-file <bmc_text.txt> --json
+python tools\pid_harness.py uart-validate --receipt <uart_receipt.json> --strict --json
+python tools\pid_harness.py final-gate-v2 --receipt <uart_board_sram_receipt.json> --rtl-sim --formal --detector-selftest --td-build --json
+python tools\pid_harness.py clean-runtime --json
+```
+
+## UART/RS232 边界
+
+- RJ45 只作为线缆/转接形态,不定义协议本身。
+- RS232 电平必须经过 MAX3232 类转换板再进 FPGA UART;FPGA 管脚只允许 3.3V TTL UART。
+- `uart-preflight` 只枚举 COM,不打开未知端口,不切 DTR/RTS。
+- `uart-board-sram-receipt-v1` 只允许 `PROGRAM_SRAM`,必须记录 bitstream hash、transcript hash、debug UART/register dump 和 counterparty。
+- `blocked_*` 和 `fail_*` 不能改写为 `pass`。
+
+## 安全边界
+
+- 禁止 flash、驱动安装/重装、真实 PTC/fan/BMC 未受控动作。
+- 禁止 `PROGRAM_FLASH`、`ERASE_FLASH`、`PROGRAM_SPIBIN`、`DIRECT_FLASH_WRITE`。
+- `td/build/`、`tmp/`、TD GUI runtime、bit/bid/data/log/timing/area 都是运行产物,不是源码基线。

+ 420 - 0
config/pid_channels.json

@@ -0,0 +1,420 @@
+{
+  "schema": "pid-high-temp-chamber-config-v2",
+  "project": "pid_study_01",
+  "authority_boundary": "offline_contract_for_v2_high_temp_chamber_control_plane",
+  "fixed_point": {
+    "temperature_q": {
+      "width": 18,
+      "scale": "integer_celsius"
+    },
+    "control_q": {
+      "width": 18,
+      "scale": "abstract_pwm_level_0_127"
+    }
+  },
+  "physical_topology": {
+    "channel_count": 24,
+    "dimm_count": 24,
+    "ptc_count": 24,
+    "mapping_policy": "bmc_order_equals_physical_order_equals_ptc_channel_order",
+    "cpu_channel_ranges": [
+      {
+        "cpu_id": 0,
+        "channels": [
+          0,
+          1,
+          2,
+          3,
+          4,
+          5,
+          6,
+          7,
+          8,
+          9,
+          10,
+          11
+        ]
+      },
+      {
+        "cpu_id": 1,
+        "channels": [
+          12,
+          13,
+          14,
+          15,
+          16,
+          17,
+          18,
+          19,
+          20,
+          21,
+          22,
+          23
+        ]
+      }
+    ],
+    "airflow_zones": [
+      {
+        "zone_id": 0,
+        "name": "front_left_6_dimm",
+        "channels": [
+          0,
+          1,
+          2,
+          3,
+          4,
+          5
+        ]
+      },
+      {
+        "zone_id": 1,
+        "name": "middle_12_dimm",
+        "channels": [
+          6,
+          7,
+          8,
+          9,
+          10,
+          11,
+          12,
+          13,
+          14,
+          15,
+          16,
+          17
+        ]
+      },
+      {
+        "zone_id": 2,
+        "name": "rear_right_6_dimm",
+        "channels": [
+          18,
+          19,
+          20,
+          21,
+          22,
+          23
+        ]
+      }
+    ],
+    "fans": {
+      "fan_count": 6,
+      "front_fans": [
+        0,
+        1,
+        2
+      ],
+      "rear_fans": [
+        3,
+        4,
+        5
+      ],
+      "default_role": "background_airflow_only",
+      "fault_role": "full_speed_fallback"
+    }
+  },
+  "channels": {
+    "logical_channel_count": 24,
+    "dimm_count": 24,
+    "ptc_count": 24,
+    "airflow_zone_count": 3,
+    "channels_per_airflow_zone": [
+      6,
+      12,
+      6
+    ],
+    "default_dimm_to_channel_map": [
+      0,
+      1,
+      2,
+      3,
+      4,
+      5,
+      6,
+      7,
+      8,
+      9,
+      10,
+      11,
+      12,
+      13,
+      14,
+      15,
+      16,
+      17,
+      18,
+      19,
+      20,
+      21,
+      22,
+      23
+    ],
+    "channel_to_cpu": [
+      0,
+      0,
+      0,
+      0,
+      0,
+      0,
+      0,
+      0,
+      0,
+      0,
+      0,
+      0,
+      1,
+      1,
+      1,
+      1,
+      1,
+      1,
+      1,
+      1,
+      1,
+      1,
+      1,
+      1
+    ],
+    "channel_to_airflow_zone": [
+      0,
+      0,
+      0,
+      0,
+      0,
+      0,
+      1,
+      1,
+      1,
+      1,
+      1,
+      1,
+      1,
+      1,
+      1,
+      1,
+      1,
+      1,
+      2,
+      2,
+      2,
+      2,
+      2,
+      2
+    ]
+  },
+  "input_sources": {
+    "default_source_select": "bmc_uart_text",
+    "auto_priority_enabled": false,
+    "supported_sources": [
+      "bmc_uart_text",
+      "fake_stress",
+      "host_register_inject",
+      "uart_debug_replay"
+    ],
+    "deprecated_sources": [
+      "i2c_adc_master_pull",
+      "i2c_adc_slave_inject",
+      "rs232_temperature_inject",
+      "rs485_temperature_inject"
+    ]
+  },
+  "bmc_uart_poll": {
+    "uart": "115200 8N1",
+    "poll_period_ms": 1000,
+    "stale_timeout_ms": 10000,
+    "command_ascii": "ipmitool raw 0x36 0x6c 0xdf 0xdd 0x00 0x03\n",
+    "response_format": "loose_text_hex",
+    "token_compatibility": [
+      "space",
+      "comma",
+      "parentheses",
+      "quotes",
+      "0xNN",
+      "multiline",
+      "echo",
+      "no_echo"
+    ],
+    "expected_payload_bytes": 48,
+    "expected_dimm_count": 24,
+    "bytes_per_dimm": 2,
+    "integer_byte_index": 0,
+    "fraction_byte_index": 1,
+    "fraction_scale": 100,
+    "missing_pair": "ff ff",
+    "frame_selection": "sliding_window_semantic_validation",
+    "echo_rejection": "ignore_windows_containing_poll_command_bytes",
+    "evidence_boundary": "offline_text_hex_parser_contract"
+  },
+  "host_config_link": {
+    "interface": "independent_host_uart_or_register_plane",
+    "must_not_share_bmc_temperature_uart": true,
+    "host_target_range_policy": "host_may_configure_arbitrary_target_but_hard_protection_overrides"
+  },
+  "default_host_config": {
+    "enable": true,
+    "target_q": 70,
+    "a0": 4,
+    "a1": -1,
+    "a2": 1,
+    "mode": 3,
+    "config_seq": 1,
+    "watchdog": true
+  },
+  "control": {
+    "default_mode": "incremental_pid_default",
+    "mode_encoding": {
+      "safe_off": 0,
+      "hysteresis_pi_experimental": 1,
+      "manual_level": 2,
+      "incremental_pid_default": 3
+    },
+    "default_target_q": 70,
+    "target_tolerance_q": 5,
+    "steady_state_acceptance_seconds": 600,
+    "kp_q": 4,
+    "ki_q": 1,
+    "power_limit_default": 32,
+    "first_real_pid_duty_limit_percent": 25,
+    "manual_level_default": 0,
+    "incremental_pid_default_allowed": true,
+    "disable_clear_history_policy": "clear_channel_history",
+    "missing_or_fault_history_policy": "clear_channel_history"
+  },
+  "safety": {
+    "stale_timeout_cycles": 10,
+    "global_bmc_timeout_cycles": 10,
+    "control_period_ms": 1000,
+    "overtemp_limit_q": 90,
+    "missing_dimm_policy": "ptc_off_exclude_from_steady_state_stats_record_in_debug",
+    "upper_pc_disconnect_policy": "keep_last_valid_target_until_host_watchdog_policy_is_defined",
+    "bmc_stale_policy": "force_off_all_ptc_fan_full",
+    "overtemp_policy": "force_off_all_ptc_fan_full_latched",
+    "fault_latch_default": true
+  },
+  "fan_policy": {
+    "fan_count": 6,
+    "default_strategy": "fixed_background",
+    "dynamic_pid_fan_control": "disabled_until_thermal_calibration",
+    "background_percent": 30,
+    "background_level": 38,
+    "fallback_percent": 100,
+    "fallback_level": 127
+  },
+  "pwm_outputs": {
+    "sys_clk_hz": 25000000,
+    "duty_max": 127,
+    "ptc": {
+      "channel_count": 24,
+      "default_pwm_hz": 10,
+      "min_pwm_hz": 1,
+      "max_pwm_hz": 500,
+      "polarity": "active_high_request",
+      "safe_state": 0,
+      "first_real_pid_duty_limit": 32
+    },
+    "fan": {
+      "fan_count": 6,
+      "default_pwm_hz": 25000,
+      "min_pwm_hz": 21000,
+      "max_pwm_hz": 28000,
+      "normal_percent": 30,
+      "normal_level": 38,
+      "fallback_percent": 100,
+      "fallback_level": 127,
+      "output_stage": "open_drain_low_true",
+      "tach_pulses_per_revolution": 2,
+      "tach_window_ms": 1000
+    }
+  },
+  "fake_stress": {
+    "scenario_seed": 260626,
+    "model_status": "verification_default_not_real_thermal_parameter",
+    "self_coupling": 1.0,
+    "neighbor_channel_coupling": 0.04,
+    "same_airflow_zone_non_neighbor_coupling": 0.01,
+    "cross_airflow_zone_coupling": 0.005,
+    "supported_events": [
+      "ramp",
+      "step",
+      "noise",
+      "missing_mask",
+      "bmc_stale",
+      "echo_no_echo",
+      "parser_garbage",
+      "full_rate_sweep"
+    ],
+    "ci_short_seconds": 60,
+    "nightly_soak_hours": 8,
+    "final_offline_gate_hours": 24
+  },
+  "host_replay_updates": [
+    {
+      "effective_sample_seq": 13,
+      "enable": true,
+      "target_q": 70,
+      "a0": 3,
+      "a1": -1,
+      "a2": 1,
+      "mode": 3,
+      "config_seq": 2,
+      "source": "fake_host",
+      "interface": "host_uart_or_register",
+      "command": "SET_TARGET_AND_PID"
+    },
+    {
+      "effective_sample_seq": 28,
+      "enable": false,
+      "target_q": 70,
+      "a0": 3,
+      "a1": -1,
+      "a2": 1,
+      "mode": 3,
+      "config_seq": 3,
+      "source": "fake_host",
+      "interface": "host_uart_or_register",
+      "command": "SET_ENABLE_OFF"
+    }
+  ],
+  "actuator": {
+    "kind": "abstract_ptc_pwm_level",
+    "actuator_count": 24,
+    "out_min": 0,
+    "out_max": 127,
+    "safe_default": "force_off"
+  },
+  "debug_trace": {
+    "required_fields": [
+      "trace_seq",
+      "source_id",
+      "channel",
+      "dimm_id",
+      "cpu_id",
+      "airflow_zone",
+      "frame_seq",
+      "raw_integer_byte",
+      "raw_fraction_byte",
+      "raw_status",
+      "missing",
+      "temp_q",
+      "age_ms",
+      "target_q",
+      "error_q",
+      "control_mode",
+      "ctrl_q",
+      "clamped",
+      "ptc_duty",
+      "fan_duty",
+      "fault_code",
+      "config_seq",
+      "sample_seq",
+      "parser_state",
+      "missing_mask"
+    ]
+  },
+  "replay": {
+    "sensor_vector": "test_vectors/sensor_replay_basic.csv",
+    "host_vector": "test_vectors/host_config_replay_basic.csv",
+    "expectation_vector": "test_vectors/actuator_expectations_basic.csv",
+    "sample_count": 28
+  }
+}

+ 82 - 0
config/pin_inventory.fcb_fpga_mcu0611.json

@@ -0,0 +1,82 @@
+{
+  "schema": "cpld-pin-inventory-v1",
+  "board_id": "fcb_fpga_mcu0611",
+  "board_role": "real_fan_ptc_product_diagnostic_board",
+  "status": "reviewed_with_locked_debug_uart_conflicts",
+  "clock_hz": 25000000,
+  "manual_verification_required": true,
+  "product_thermal_gate_allowed": false,
+  "electrical_boundary": "FCB_FPGA+MCU0611 schematic review covers function net to FPGA ball mapping only. Current temporary J6/COM7/COM8 UART wiring conflicts with HEAT3/4/17/18/21/22, so full real FAN/PTC bitstream generation must remain fail-closed until that wiring or the target pin map changes.",
+  "locked_debug_uart_assignments": {
+    "bmc_uart_tx": "T4",
+    "bmc_uart_rx": "R5",
+    "host_uart_tx": "P7",
+    "host_uart_rx": "P8",
+    "debug_uart_rx": "P10",
+    "debug_uart_tx": "R10"
+  },
+  "source_documents": [
+    {
+      "kind": "schematic_pdf",
+      "path": "reference/original/schematics/FCB_FPGA+MCU0611.pdf",
+      "pages": [3, 7, 9, 10],
+      "confidence": "manual_pdf_cross_check"
+    }
+  ],
+  "review_artifacts": [
+    {
+      "index": "pdf-p10-function-table",
+      "description": "PDF page 10 function net to BANK_IO/BANK_GPIO table"
+    },
+    {
+      "index": "pdf-p3-fpga-ball-map",
+      "description": "PDF page 3 FPGA symbol reverse lookup from BANK_IO/BANK_GPIO to LFBGA ball"
+    },
+    {
+      "index": "subagent-pin-review-20260703",
+      "description": "Independent read-only pin review table returned by subagent Huygens"
+    }
+  ],
+  "pins": [
+    {"signal":"FAN_PWM1","function_net":"FAN_PWM1","role":"FAN_PWM","channel":1,"bank_io_net":"BANK0_IO1_2","fpga_ball":"C4","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_PWM2","function_net":"FAN_PWM2","role":"FAN_PWM","channel":2,"bank_io_net":"BANK0_IO1_5","fpga_ball":"B5","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_PWM3","function_net":"FAN_PWM3","role":"FAN_PWM","channel":3,"bank_io_net":"BANK5_IO1_8","fpga_ball":"B1","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_PWM4","function_net":"FAN_PWM4","role":"FAN_PWM","channel":4,"bank_io_net":"BANK0_IO1_11","fpga_ball":"A14","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_FG1","function_net":"FAN_FG1","role":"FAN_FG","channel":1,"bank_io_net":"BANK5_IO1_0","fpga_ball":"D2","direction":"input","io_standard":"LVCMOS33","capability":["gpio","tach_input"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_FG2","function_net":"FAN_FG2","role":"FAN_FG","channel":2,"bank_io_net":"BANK5_IO1_1","fpga_ball":"D3","direction":"input","io_standard":"LVCMOS33","capability":["gpio","tach_input"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_FG3","function_net":"FAN_FG3","role":"FAN_FG","channel":3,"bank_io_net":"BANK0_IO1_3","fpga_ball":"E6","direction":"input","io_standard":"LVCMOS33","capability":["gpio","tach_input"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_FG4","function_net":"FAN_FG4","role":"FAN_FG","channel":4,"bank_io_net":"BANK0_IO1_4","fpga_ball":"D6","direction":"input","io_standard":"LVCMOS33","capability":["gpio","tach_input"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_FG5","function_net":"FAN_FG5","role":"FAN_FG","channel":5,"bank_io_net":"BANK5_IO1_6","fpga_ball":"C1","direction":"input","io_standard":"LVCMOS33","capability":["gpio","tach_input"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_FG6","function_net":"FAN_FG6","role":"FAN_FG","channel":6,"bank_io_net":"BANK5_IO1_7","fpga_ball":"C2","direction":"input","io_standard":"LVCMOS33","capability":["gpio","tach_input"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_FG7","function_net":"FAN_FG7","role":"FAN_FG","channel":7,"bank_io_net":"BANK0_IO1_9","fpga_ball":"B3","direction":"input","io_standard":"LVCMOS33","capability":["gpio","tach_input"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_FG8","function_net":"FAN_FG8","role":"FAN_FG","channel":8,"bank_io_net":"BANK0_IO1_10","fpga_ball":"B13","direction":"input","io_standard":"LVCMOS33","capability":["gpio","tach_input"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_INSTALL1","function_net":"FAN_INSTALL1","role":"FAN_INSTALL","channel":1,"bank_io_net":"BANK2_GPIO56","fpga_ball":"N10","direction":"input","io_standard":"LVCMOS33","capability":["gpio","presence_input"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_INSTALL2","function_net":"FAN_INSTALL2","role":"FAN_INSTALL","channel":2,"bank_io_net":"BANK2_GPIO57","fpga_ball":"M11","direction":"input","io_standard":"LVCMOS33","capability":["gpio","presence_input"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_INSTALL3","function_net":"FAN_INSTALL3","role":"FAN_INSTALL","channel":3,"bank_io_net":"BANK2_GPIO58","fpga_ball":"P12","direction":"input","io_standard":"LVCMOS33","capability":["gpio","presence_input"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"FAN_INSTALL4","function_net":"FAN_INSTALL4","role":"FAN_INSTALL","channel":4,"bank_io_net":"BANK2_GPIO59","fpga_ball":"R11","direction":"input","io_standard":"LVCMOS33","capability":["gpio","presence_input"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT1","function_net":"HEAT1","role":"HEAT","channel":1,"bank_io_net":"BANK1_IO1_16","fpga_ball":"F16","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT2","function_net":"HEAT2","role":"HEAT","channel":2,"bank_io_net":"BANK1_IO1_17","fpga_ball":"G16","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT3","function_net":"HEAT3","role":"HEAT","channel":3,"bank_io_net":"BANK2_IO2_0","fpga_ball":"T4","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT4","function_net":"HEAT4","role":"HEAT","channel":4,"bank_io_net":"BANK2_IO2_1","fpga_ball":"R5","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT5","function_net":"HEAT5","role":"HEAT","channel":5,"bank_io_net":"BANK2_IO2_2","fpga_ball":"T6","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT6","function_net":"HEAT6","role":"HEAT","channel":6,"bank_io_net":"BANK2_IO2_3","fpga_ball":"R7","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT7","function_net":"HEAT7","role":"HEAT","channel":7,"bank_io_net":"BANK3_IO2_4","fpga_ball":"M1","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT8","function_net":"HEAT8","role":"HEAT","channel":8,"bank_io_net":"BANK3_IO2_5","fpga_ball":"N1","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT9","function_net":"HEAT9","role":"HEAT","channel":9,"bank_io_net":"BANK3_IO2_6","fpga_ball":"P1","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT10","function_net":"HEAT10","role":"HEAT","channel":10,"bank_io_net":"BANK3_IO2_7","fpga_ball":"R1","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT11","function_net":"HEAT11","role":"HEAT","channel":11,"bank_io_net":"BANK2_IO2_8","fpga_ball":"T2","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT12","function_net":"HEAT12","role":"HEAT","channel":12,"bank_io_net":"BANK2_IO2_9","fpga_ball":"R3","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT13","function_net":"HEAT13","role":"HEAT","channel":13,"bank_io_net":"BANK2_IO2_10","fpga_ball":"P16","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT14","function_net":"HEAT14","role":"HEAT","channel":14,"bank_io_net":"BANK2_IO2_11","fpga_ball":"R16","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT15","function_net":"HEAT15","role":"HEAT","channel":15,"bank_io_net":"BANK1_IO2_12","fpga_ball":"M16","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT16","function_net":"HEAT16","role":"HEAT","channel":16,"bank_io_net":"BANK2_IO2_13","fpga_ball":"N16","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT17","function_net":"HEAT17","role":"HEAT","channel":17,"bank_io_net":"BANK2_IO2_14","fpga_ball":"P8","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT18","function_net":"HEAT18","role":"HEAT","channel":18,"bank_io_net":"BANK2_IO2_15","fpga_ball":"P7","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT19","function_net":"HEAT19","role":"HEAT","channel":19,"bank_io_net":"BANK2_IO2_16","fpga_ball":"T9","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT20","function_net":"HEAT20","role":"HEAT","channel":20,"bank_io_net":"BANK2_IO2_17","fpga_ball":"P9","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT21","function_net":"HEAT21","role":"HEAT","channel":21,"bank_io_net":"BANK2_IO2_18","fpga_ball":"P10","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT22","function_net":"HEAT22","role":"HEAT","channel":22,"bank_io_net":"BANK2_IO2_19","fpga_ball":"R10","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT23","function_net":"HEAT23","role":"HEAT","channel":23,"bank_io_net":"BANK2_IO2_20","fpga_ball":"T13","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"},
+    {"signal":"HEAT24","function_net":"HEAT24","role":"HEAT","channel":24,"bank_io_net":"BANK2_IO2_21","fpga_ball":"T12","direction":"output","io_standard":"LVCMOS33","capability":["gpio","pwm_output"],"reserved":false,"manually_verified":true,"source_pages":[10,3],"screenshot_index":"pdf-p10-function-table;pdf-p3-fpga-ball-map","source_confidence":"manual_pdf_cross_check"}
+  ]
+}

+ 131 - 0
config/pin_inventory.mini.json

@@ -0,0 +1,131 @@
+{
+  "schema": "cpld-pin-inventory-v1",
+  "board_id": "ef2l45bg256b_mini_v2",
+  "board_role": "development_validation_carrier",
+  "clock_hz": 25000000,
+  "manual_verification_required": true,
+  "product_thermal_gate_allowed": false,
+  "electrical_boundary": "FPGA IO is 3.3V UART only. External MAX3232 RS232 level shifter required between GPIO UART and RJ45 RS232 wiring.",
+  "source_documents": [
+    {
+      "kind": "hardware_user_guide",
+      "path": "reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0板文档/TN427_安路科技EF2L45BG256B_MINI板硬件使用指南.pdf",
+      "confidence": "primary_manual_cross_check_required"
+    },
+    {
+      "kind": "schematic_pdf",
+      "path": "reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0原理图/EF2L45BG256B_MINI_V2.0dsn.pdf",
+      "confidence": "schematic_cross_check_required"
+    }
+  ],
+  "pins": [
+    {
+      "signal": null,
+      "connector": "J5",
+      "connector_pin": 5,
+      "fpga_ball": "D2",
+      "io_standard": "LVCMOS33",
+      "role": "user_io",
+      "capability": ["gpio", "uart_rx", "uart_tx"],
+      "reserved": false,
+      "manually_verified": false,
+      "source_confidence": "tn427_cross_check_required"
+    },
+    {
+      "signal": null,
+      "connector": "J5",
+      "connector_pin": 6,
+      "fpga_ball": "D3",
+      "io_standard": "LVCMOS33",
+      "role": "user_io",
+      "capability": ["gpio", "uart_rx", "uart_tx"],
+      "reserved": false,
+      "manually_verified": false,
+      "source_confidence": "tn427_cross_check_required"
+    },
+    {
+      "signal": null,
+      "connector": "J6",
+      "connector_pin": 5,
+      "fpga_ball": "T4",
+      "io_standard": "LVCMOS33",
+      "role": "user_io",
+      "capability": ["gpio", "uart_rx", "uart_tx"],
+      "reserved": false,
+      "manually_verified": false,
+      "source_confidence": "tn427_cross_check_required"
+    },
+    {
+      "signal": null,
+      "connector": "J6",
+      "connector_pin": 6,
+      "fpga_ball": "R5",
+      "io_standard": "LVCMOS33",
+      "role": "user_io",
+      "capability": ["gpio", "uart_rx", "uart_tx"],
+      "reserved": false,
+      "manually_verified": false,
+      "source_confidence": "tn427_cross_check_required"
+    },
+    {
+      "signal": "+3V3",
+      "connector": "J5",
+      "connector_pin": 1,
+      "fpga_ball": "PWR_3V3_J5_1",
+      "io_standard": null,
+      "role": "power",
+      "capability": ["power"],
+      "reserved": true,
+      "manually_verified": false,
+      "source_confidence": "tn427_cross_check_required"
+    },
+    {
+      "signal": "GND",
+      "connector": "J5",
+      "connector_pin": 37,
+      "fpga_ball": "GND_J5_37",
+      "io_standard": null,
+      "role": "gnd",
+      "capability": ["gnd"],
+      "reserved": true,
+      "manually_verified": false,
+      "source_confidence": "tn427_cross_check_required"
+    },
+    {
+      "signal": "GND",
+      "connector": "J5",
+      "connector_pin": 38,
+      "fpga_ball": "GND_J5_38",
+      "io_standard": null,
+      "role": "gnd",
+      "capability": ["gnd"],
+      "reserved": true,
+      "manually_verified": false,
+      "source_confidence": "tn427_cross_check_required"
+    },
+    {
+      "signal": "GND",
+      "connector": "J6",
+      "connector_pin": 39,
+      "fpga_ball": "GND_J6_39",
+      "io_standard": null,
+      "role": "gnd",
+      "capability": ["gnd"],
+      "reserved": true,
+      "manually_verified": false,
+      "source_confidence": "tn427_cross_check_required"
+    },
+    {
+      "signal": "GND",
+      "connector": "J6",
+      "connector_pin": 40,
+      "fpga_ball": "GND_J6_40",
+      "io_standard": null,
+      "role": "gnd",
+      "capability": ["gnd"],
+      "reserved": true,
+      "manually_verified": false,
+      "source_confidence": "tn427_cross_check_required"
+    }
+  ]
+}

+ 12 - 0
config/pin_inventory.product.placeholder.json

@@ -0,0 +1,12 @@
+{
+  "schema": "cpld-pin-inventory-v1",
+  "board_id": "product_board_placeholder",
+  "board_role": "final_product_board",
+  "status": "product_pin_map_missing",
+  "clock_hz": 25000000,
+  "manual_verification_required": true,
+  "product_thermal_gate_allowed": false,
+  "electrical_boundary": "Product board schematic, pin map, driver circuits, interlock wiring, and rollback evidence are not imported yet.",
+  "source_documents": [],
+  "pins": []
+}

+ 10 - 0
constraints/pid_study_01.adc

@@ -0,0 +1,10 @@
+set_pin_assignment { sys_clk }   { LOCATION = J1;  IOSTANDARD = LVCMOS33; PULLTYPE = PULLUP; }
+set_pin_assignment { sys_rst_n } { LOCATION = N6;  IOSTANDARD = LVCMOS33; PULLTYPE = PULLUP; }
+set_pin_assignment { led[0] }    { LOCATION = H16; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[1] }    { LOCATION = H15; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[2] }    { LOCATION = J16; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[3] }    { LOCATION = J15; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[4] }    { LOCATION = K16; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[5] }    { LOCATION = K15; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[6] }    { LOCATION = L16; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[7] }    { LOCATION = L15; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }

+ 1 - 0
constraints/pid_study_01.sdc

@@ -0,0 +1 @@
+create_clock -name sys_clk -period 40 -waveform {0 20} [get_ports {sys_clk}]

+ 23 - 0
constraints/uart_rs232_j6_host_sensor_real_fan_ptc_debug921_primary.adc

@@ -0,0 +1,23 @@
+# real-bmc-j6-host-sensor-real-fan-ptc-debug921-v1 primary build constraints.
+# COM7 Debug P10/R10 921600: USB serial TXD -> P10 (FPGA RX), USB serial RXD <- R10 (FPGA TX).
+# COM8 Host P7/P8 115200: serial RXD <- FPGA TX P7, serial TXD -> FPGA RX P8.
+# J6 T4/R5: FPGA TX -> J6 pin 5/T4, FPGA RX <- J6 pin 6/R5.
+# FAIL-CLOSED: real FAN/PTC pin map is incomplete in this repository. This ADC maps only
+# clocks, reset, J6, HostPort, DebugPort, and LEDs; it intentionally does not bind
+# real FAN/PTC actuator outputs and does not claim real hardware pin map pass.
+set_pin_assignment { sys_clk } { LOCATION = J1;  IOSTANDARD = LVCMOS33; PULLTYPE = PULLUP; }
+set_pin_assignment { sys_rst_n } { LOCATION = N6;  IOSTANDARD = LVCMOS33; PULLTYPE = PULLUP; }
+set_pin_assignment { bmc_uart_tx } { LOCATION = T4;  IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { bmc_uart_rx } { LOCATION = R5;  IOSTANDARD = LVCMOS33; PULLTYPE = PULLUP; }
+set_pin_assignment { host_uart_tx } { LOCATION = P7;  IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { host_uart_rx } { LOCATION = P8;  IOSTANDARD = LVCMOS33; PULLTYPE = PULLUP; }
+set_pin_assignment { debug_uart_rx } { LOCATION = P10; IOSTANDARD = LVCMOS33; PULLTYPE = PULLUP; }
+set_pin_assignment { debug_uart_tx } { LOCATION = R10; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[0] }        { LOCATION = H16; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[1] }        { LOCATION = H15; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[2] }        { LOCATION = J16; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[3] }        { LOCATION = J15; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[4] }        { LOCATION = K16; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[5] }        { LOCATION = K15; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[6] }        { LOCATION = L16; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }
+set_pin_assignment { led[7] }        { LOCATION = L15; IOSTANDARD = LVCMOS33; DRIVESTRENGTH = 20; PULLTYPE = NONE; }

+ 41 - 0
docs/bmc-uart-temperature-protocol-v2.zh-CN.md

@@ -0,0 +1,41 @@
+# BMC UART 温度协议 V2
+
+## 串口与轮询
+
+- UART:`115200 8N1`。
+- CPLD 每 1 秒发送:
+
+```text
+ipmitool raw 0x36 0x6c 0xdf 0xdd 0x00 0x03
+```
+
+命令实际带换行:`ipmitool raw 0x36 0x6c 0xdf 0xdd 0x00 0x03\n`。
+
+## 响应格式
+
+BMC 返回 loose text hex。parser 必须兼容:
+
+- 空格、逗号、括号、引号。
+- `0xNN` 或裸 hex byte。
+- 多行。
+- echo 和 no-echo。
+
+有效温度帧为 48 byte,即 24 个 DIMM,每个 DIMM 两个 byte。
+
+## 温度编码
+
+- 第一个 byte:整数摄氏。
+- 第二个 byte:小数百分位。
+- `23 4b` 表示 35.75C。
+- `28 00` 表示 40.00C。
+- `ff ff` 表示 DIMM 缺失。
+
+fraction 必须在 0..99;超出视为 parser error。有效 DIMM 温度达到 90C 必须触发 overtemp safety。
+
+## 滑动窗口规则
+
+parser 从文本 token 流中使用滑动候选窗口提取 48 byte。包含 poll command byte 序列 `36 6c df dd 00 03` 的候选窗口视为 echo,不得误当温度帧。窗口必须满足 24 对 byte、`ff ff` 缺失合法、fraction 合法、至少一个 present DIMM。
+
+## stale 规则
+
+10s 内没有有效 BMC 温度帧时,系统进入 BMC stale:PTC 全关,风扇进入 fallback。该规则独立于 host 配置串口。

Разница между файлами не показана из-за своего большого размера
+ 0 - 76
docs/cpld-html-teaching-requirements.zh-CN.md


+ 35 - 0
docs/fact-source-boundary.zh-CN.md

@@ -0,0 +1,35 @@
+# 事实来源与边界
+
+本工程是 CPLD PID/高温罩控制合同工程,不等同于最终产品板完整热认证。
+
+## 已冻结事实
+
+- BMC 温度源通过 UART loose text hex 协议进入。
+- UART 参数为 `115200 8N1`。
+- 每秒轮询一次 BMC 温度。
+- 24 根 DIMM、24 个 PTC、24 个 control channel 一一对应。
+- CPU0 为 channel 0..11,CPU1 为 channel 12..23。
+- 最新原理图目标风扇接口为 4 路 `FAN_PWM`、8 路 `FAN_FG`、4 路 `FAN_INSTALL`。
+- 风扇默认背景档和故障策略属于控制合同;真实转速、tach 脉冲含义和气流标定仍需后续硬件验证。
+- 默认目标 70C;90C 硬过温保护永远优先。
+- BMC 温度断更超过 10s:PTC 全关,风扇进入 fallback。
+- 首次真机 PID 最高 PTC duty 限幅 25%。
+- FPGA IO 侧 UART 是 3.3V TTL;RS232 必须外接电平转换。
+
+## 未冻结事实
+
+- 最新原理图 pin inventory 已追到 FPGA ball,但当前三路临时 UART 与 `HEAT3/4/17/18/21/22` 冲突;冲突解除前真实 FAN/PTC bitstream 必须 fail closed。
+- PTC 驱动电路、电气极性、功率能力、硬件互锁。
+- 风扇真实驱动极性、tach pulses、故障策略和气流标定。
+- BMC 实际串口线缆、隔离、电平转换、错误注入和长期稳定性。
+- 真实热模型参数、温升惯性、串扰矩阵和稳态收敛证据。
+
+## 约束策略
+
+`constraints/pid_study_01.adc` 只绑定 MINI smoke IO:`sys_clk`、`sys_rst_n`、`led[0..7]`。它不绑定 PTC、fan、BMC UART、host UART、motor、tach 或任何真实高温罩 IO。
+
+`td/uart_rs232_j6_host_sensor_real_fan_ptc_debug921_primary.prj` 是当前唯一用户主 TD profile;在真实 FAN/PTC pin 与临时 UART 冲突解除前,它必须 fail closed,不生成声明可刷的真实 FAN/PTC bitstream。
+
+## 资料治理
+
+原始资料只能放在 `reference/original/`。产品板资料未导入前,完整热闭环 gate 必须保持 blocked。

+ 24 - 0
docs/fake-stress-verification-v2.zh-CN.md

@@ -0,0 +1,24 @@
+# Fake Stress 验证
+
+fake stress 用来在不接真实高温罩的情况下压测 CPLD PID、parser、safety、debug UART 和 register dump 路径。它不是热标定模型。
+
+## 场景
+
+- `ramp`:缓慢升温。
+- `step`:快速阶跃。
+- `noise`:温度扰动。
+- `missing_mask`:DIMM 缺失。
+- `bmc_stale`:10s stale。
+- `echo_no_echo`:BMC 文本 echo 与无 echo。
+- `parser_garbage`:乱码、短帧、长帧、bad fraction。
+- `full_rate_sweep`:高频扫过 frame_seq、config_seq、fault/state 位,验证 debug UART 和 register dump 可观测。
+
+## 必需证据
+
+- 协议 parser receipt。
+- UART bit-level RTL sim。
+- debug UART event stream。
+- register dump 快照。
+- final-gate-v2 receipt。
+
+24 小时 offline fake gate 通过后,才允许进入分级实机 SRAM UART smoke。真实热闭环仍需独立 runbook 和人工/仪器记录。

+ 23 - 0
docs/high-temp-chamber-design-v2.zh-CN.md

@@ -0,0 +1,23 @@
+# 高温罩控制设计 V2
+
+## 默认策略
+
+- 默认目标温度:70C。
+- 硬过温:90C,优先级最高。
+- BMC stale:10s 后 PTC 全关,fan fallback。
+- 首次真实闭环:PTC duty 限幅 25%。
+- 风扇:默认背景档,故障全速。
+
+## 当前准入
+
+当前只允许 software/model/RTL/formal/UART evidence 和 SRAM-only 实机通信验证。不得绕过 `final-gate-v2` 直接进入真机 PID。
+
+## 产品板阻塞项
+
+- 产品板 pin map。
+- PTC/fan 驱动资料。
+- BMC 串口电气资料。
+- 人工急停和回滚方案。
+- 外部仪器记录模板。
+
+上述资料未完成前,完整热闭环保持 blocked。

+ 28 - 0
docs/interface-contract.zh-CN.md

@@ -0,0 +1,28 @@
+# 接口合同
+
+## BMC UART
+
+- 波特率:`115200`
+- 格式:`8N1`
+- 协议:loose text hex。
+- 温度:每 DIMM 两个 byte,整数摄氏 + 小数百分位。
+- 缺失:`ff ff`。
+- counterparty:`pc_emulator` 或 `real_bmc`。
+
+## 物理 UART/RS232
+
+RS232 只作为外部电平转换链路。FPGA IO 侧必须是 3.3V UART,通过 MAX3232 类转换板连接到 RJ45/RS232 线缆。
+
+## Debug Evidence
+
+必须能进入 debug bundle:
+
+- debug UART event stream。
+- register dump。
+- parser status。
+- stale/missing/fault/config_seq。
+- PTC force_off 和 fan fallback 状态。
+
+## 禁止
+
+不恢复 `rs232_temperature_inject` 作为逻辑源。不通过 RS232 电平直接驱动 FPGA IO。

+ 104 - 0
docs/j6-host-sensor-real-fan-ptc-debug921-runbook.zh-CN.md

@@ -0,0 +1,104 @@
+# J6 Host Sensor Real FAN PTC Debug921
+
+打开包根目录的 `START-HERE.zh-CN.md` 后先看这一页。包内路径、文件名、脚本名和命令全部使用英文;说明正文使用简体中文。
+
+当前包状态是 `blocked_pin_conflict_with_locked_debug_uart`。当前不要刷机,不要运行 collector,也不要尝试用这个包做 `PROGRAM_SRAM`。
+
+原因不是原理图 pin map 没有追完。当前 `config/pin_inventory.fcb_fpga_mcu0611.json` 已经把 24 路 `HEAT/PTC`、4 路 `FAN_PWM`、8 路 `FAN_FG`、4 路 `FAN_INSTALL` 追到 FPGA ball。但是这些真实 FAN/PTC 引脚和当前调试阶段锁定的三路串口飞线冲突:
+
+```text
+HEAT3  -> T4  conflicts with bmc_uart_tx
+HEAT4  -> R5  conflicts with bmc_uart_rx
+HEAT17 -> P8  conflicts with host_uart_rx
+HEAT18 -> P7  conflicts with host_uart_tx
+HEAT21 -> P10 conflicts with debug_uart_rx
+HEAT22 -> R10 conflicts with debug_uart_tx
+```
+
+同一个 FPGA ball 不能同时作为真实 `HEAT` 输出和调试 UART 引脚使用,所以本包刻意 fail closed:不包含 `bitstreams/`,不包含 `td-receipts/`,不包含可执行采集命令模板,不生成会把真实 FAN/PTC 和 J6/COM7/COM8 串口绑到同一引脚的 `.bit`。
+
+本诊断名称是 `real-bmc-j6-host-sensor-real-fan-ptc-debug921-v1`。目标设计边界仍然是:J6 继续从 BMC UART 获取 DIMM 温度 raw 数据,COM7 作为 P10/R10 DebugPort,COM8 作为 P7/P8 HostPort;PID 只记录 requested,不接管 PWM;FAN/PTC 控制协议按真实原理图改为 24 路 PTC、4 路 FAN PWM、8 路 FAN FG、4 路 FAN INSTALL。
+
+## 1. 当前边界
+
+- J6 BMC primary:CPLD `bmc_uart_tx=T4`,`bmc_uart_rx=R5`,BMC 温度来源仍是 J6 UART raw 命令。
+- DebugPort:串口板 TXD 接 P10,串口板 RXD 接 R10,Windows 显示为 COM7,目标波特率 921600。
+- HostPort:串口板 RXD 接 P7,串口板 TXD 接 P8,Windows 显示为 COM8,目标波特率 115200。
+- 不使用 MCU,不使用 `BMC_SCL/SDA`,不使用 `TEMP_SCL/SDA`,不使用 NTC 作为本轮 BMC 温度来源。
+- 当前不需要安装 Python、pip、pyserial 或驱动;当前 blocked 包不包含 collector,也不会打开任何 COM 口。后续非冲突 pin 包的 collector 设计必须保持不枚举 COM、不打开未知 COM、不写 DebugPort。
+- 当前包不会刷 flash,不会执行 `PROGRAM_FLASH`、`ERASE_FLASH`、`PROGRAM_SPIBIN` 或 `DIRECT_FLASH_WRITE`。
+
+## 2. 当前不要执行的动作
+
+当前包没有可刷 `.bit` 文件,也没有可复制执行的采集模板。不要执行以下动作:
+
+```text
+PROGRAM_SRAM
+HostPort collection
+DebugPort collection
+```
+
+只有在硬件接线或目标 pin map 调整后,`HEAT3/4/17/18/21/22` 不再与 J6/COM7/COM8 锁定调试串口冲突,才应该生成新的可刷 SRAM-only 包。新的可刷包应包含 `bitstreams/`、`td-receipts/`、`commands/`,并在 `START-HERE.zh-CN.md` 第一屏明确给出可复制 PowerShell 命令。
+
+## 3. HostPort 目标命令
+
+以下是未来非冲突 pin 包应支持的 HostPort 命令。PTC 和 FAN 单通道编号必须是 1-based:PTC 为 `01` 到 `24`,FAN 为 `01` 到 `04`。零号通道和超出 `04` 的 FAN 单通道都不允许使用。
+
+```text
+SET PTC 01 10
+SET PTC 24 20
+SET FAN 01 40
+SET FAN 04 30
+SET PID ENABLE
+GET STATUS
+GET MAP
+GET SENSOR
+GET SENSOR
+GET SENSOR
+SET PID DISABLE
+DISABLE
+```
+
+CPLD 对每条命令都应返回严格 ACK,例如 `OK seq=00000001 cmd=PTCCH`。命令和 ACK 的对应关系如下:
+
+```text
+SET PTC 01 10      -> PTCCH
+SET PTC 24 20      -> PTCCH
+SET FAN 01 40      -> FANCH
+SET FAN 04 30      -> FANCH
+SET PID ENABLE     -> PID_EN
+GET STATUS         -> STATUS
+GET MAP            -> MAP___
+GET SENSOR         -> SENSOR
+SET PID DISABLE    -> PID_DI
+DISABLE            -> DISABL
+```
+
+旧的 0-based 命令必须拒绝。PTC 的零号通道、FAN 的零号通道、第五路或第六路 FAN 单通道都不能作为新真实 FAN/PTC 诊断 pass。
+
+## 4. 未来现场现象
+
+这些现象是后续非冲突 pin 包刷入后应该看到的,不是当前 blocked 包的执行步骤:
+
+- `host-command-transcript.json` 里每条命令都有 `OK seq=... cmd=...`:COM8 到 CPLD 的 HostPort 控制链路通了,且 ACK 能严格归因到对应命令。
+- `host-port-escaped.txt` 里看到 `SENS seq=... status=... valid=.. missing=.. fault=..`:CPLD 已形成 BMC raw 温度采样摘要,其中 `valid` 和 `missing` 是十进制数量。
+- 每个 `SENS` 后看到 24 条 `DIMM`:CPLD 已把一个样本拆成 24 路 DIMM 上报。
+- `debug-uart-escaped.txt` 里看到 `J6RAW`、`J6TEMP`、`J6PWM`、`J6STAT`:COM7 DebugPort 的证据流可读。
+- `J6RAW` 可重建为 `bmc-raw-replay.bin`,用于证明 CPLD 从 BMC 看到的原始字节。
+- `host-sensor-report.json` 里每个有效 sample 都应有 24 条 DIMM 结构化记录。
+- `J6PWM`、`J6MOD`、`J6STAT`、`J6MAP` 用于证明 PWM 状态、PID 边界、drop/error 计数和真实 FAN/PTC 映射证据。
+- 真实 FAN/PTC 硬件状态必须写入 `real_fan_ptc_hardware_status`。在没有真实受控硬件前,状态只能是 `not_run` 或 `blocked_waiting_for_real_fan_ptc_hardware`,不能宣称 final gate pass。
+
+## 5. 当前包文件
+
+当前 blocked 包用于本机和设计评审,不用于远端刷机。重点文件:
+
+- `START-HERE.zh-CN.md`
+- `docs/j6-host-sensor-real-fan-ptc-debug921-runbook.zh-CN.md`
+- `schemas/j6_host_sensor_real_fan_ptc_debug921_pin_conflict_blocked_package.schema.json`
+- `config/pin_inventory.fcb_fpga_mcu0611.json`
+- `blocked/blocked-pin-conflict-receipt.json`
+- `manifest.json`
+- `sha256-inventory.json`
+
+只要状态仍是 `blocked_pin_conflict_with_locked_debug_uart`,本诊断就不能生成真实 pin bitstream,也不能声明真实 FAN/PTC 硬件、热性能、PID 闭环或 final gate 通过。

+ 96 - 0
docs/offline-fidelity-gate-v1.zh-CN.md

@@ -0,0 +1,96 @@
+# offline-fidelity-gate-v1
+
+`offline-fidelity-gate-v1` 是无真实物理设备条件下的最严离线验证 gate。它不替代 `final-gate-v2`,也不降低 UART strict 或板级 receipt 的要求。它只证明离线逻辑、协议、RTL、formal、debug 可观测性、安全策略、虚拟热模型、故障注入、mutation detector、TD 离线工具证据全部通过。
+
+Pass 语义固定为:offline-fidelity-gate-v1 proves offline logic/protocol/safety/debug/virtual-thermal evidence only and does not certify real hardware or thermal performance.
+
+## 权限边界
+
+允许:
+
+- 自动准备用户态离线工具链,例如 OSS CAD Suite、cocotb venv、`iverilog`、`vvp`、`verilator`、`yosys`、`sby`。
+- 自动准备扩展分析工具,例如 pytest/hypothesis、pyserial loopback URL、波形/trace 分析辅助工具;所有工具只能在用户态目录、venv 或临时目录内运行。
+- 运行用户态模拟驱动,例如 cocotb driver、Python driver facade、socket/pipe/mock API、BMC text driver、host register plane 和 debug UART decoder。
+- 运行 Python model、协议 fuzz、Verilog RTL simulation、cocotb virtual lab、formal、detector selftest、mutation、thermal digital twin、TD offline elaboration/build。
+- 生成 JSON receipt、debug bundle、coverage matrix 和可复现 seed/trace hash。
+
+禁止:
+
+- 打开 COM 口、枚举后自动连接未知串口、切换 DTR/RTS。
+- flash、`PROGRAM_FLASH`、`ERASE_FLASH`、`PROGRAM_SPIBIN`、`DIRECT_FLASH_WRITE`。
+- 主机 OS kernel/USB/JTAG/COM 驱动安装或重装;即使可卸载,也不能进入 `offline-fidelity-gate-v1` pass 证据。
+- 真实 PTC/fan/BMC 未受控动作。
+- 把 `hardware`、`board`、`uart_strict`、`chipwatcher`、`thermal_performance_pass` 写成离线 pass layer。
+
+## Required Layers
+
+receipt 的 `layers` 必须精确包含以下 required layer,且每一层 `status` 必须为 `pass`:
+
+- `static`
+- `model`
+- `replay`
+- `protocol_fuzz`
+- `hdl_sim`
+- `cocotb_virtual_lab`
+- `virtual_driver_lab`
+- `formal`
+- `detector_selftest`
+- `mutation`
+- `thermal_digital_twin`
+- `coverage_matrix`
+- `td_build`
+- `debug_bundle`
+
+任何 `blocked_*`、`partial`、`skipped`、`fail_*`、缺证据或 dry-run 都不能提升为顶层 pass。工具缺失且用户态 bootstrap 失败时,顶层必须 fail 或 blocked,不能通过。
+
+## 运行入口
+
+```powershell
+python tools\pid_harness.py offline-fidelity-gate-v1 --auto-bootstrap --hdl-backend all --formal --td-build --long-run final --json --report-file <receipt.json>
+```
+
+`--auto-bootstrap` 只允许用户态工具准备。它可以下载或解压离线仿真工具,也可以创建本地 Python venv;它不能安装系统驱动、不能打开串口、不能下载到硬件、不能写 flash。
+
+工具链缓存默认放在当前用户的 `CodexToolchains\CPLD` 目录下。每次自动准备都必须记录 manifest、下载 hash、工具版本、路径和 cleanup policy。`toolchain-clean` 默认 dry-run;只有带 `.cpld_toolchain_owner.json` owner marker 且 manifest 声明的用户态工具路径才允许实际删除。
+
+## 虚拟实验室
+
+Verilog testbench 保留确定性 smoke、协议边界、UART bit-level 和 RTL 基础安全场景。cocotb virtual lab 作为主虚拟实验室,覆盖:
+
+- UART 8N1 bit driver、start jitter、stop error、break、glitch、RX overflow、TX backpressure、debug UART overflow。
+- BMC loose text byte stream、echo/no-echo、裸 hex、`0xNN`、多行、乱码、短帧、长帧、bad fraction、全 missing、部分 missing。
+- host register plane、source switch、manual mode、host disable、PID history clear/freeze。
+- fault injection、scoreboard、debug UART frame decode 和 register/probe/trace 一致性。
+
+`virtual_driver_lab` 是 required layer。它只证明用户态模拟驱动合同通过,覆盖 pyserial `loop://` 或等价 loopback URL、socket/pipe transport、BMC text driver、host register plane、debug UART decoder,以及 timeout、disconnect、partial read/write、permission denied、buffer overflow、TX/RX backpressure 等错误路径。可选 Windows Sandbox/VM 证据只能作为隔离环境补强;主机 OS 不安装驱动,该 layer 也不声明真实驱动认证。
+
+系统级 scoreboard 分两条线:
+
+- `system_contract_top` 覆盖 host register、BMC byte stream、actuator、安全、debug register、BRAM trace、debug probe/status。
+- `uart_rs232_j6_host_sensor_real_fan_ptc_debug921_top` 覆盖真实 8N1 BMC RX/TX、COM8 HostPort、COM7 DebugPort、BMC raw 温度解析、真实 FAN/PTC 信号接口和端到端 UART 行为。
+
+## Debug 可信度
+
+离线 gate 必须闭环 debug 证据:
+
+- 解码 `debug_uart_tx`,校验 SOF、`frame_seq` 单调、payload、checksum、overflow。
+- 读 `0x80..0x93` debug register window,校验 event_count、frozen、overflow、last_fault、last_channel、trace read data。
+- 校验 BRAM trace wrap/freeze/clear 与 register/debug UART/probe bus 一致。
+
+## 热数字孪生
+
+`thermal_digital_twin` 同时运行保守、乐观、极端、随机扰动、传感器漂移、延迟、串扰、风扇退化、PTC 热惯性模型。所有模型都必须满足 fail-closed 合同才 pass。模型参数未校准时只能作为验证假设记录,不能声明真实 thermal performance。
+
+CI 使用 60s 固定 seed 矩阵;nightly 使用 8h 请求语义和固定/随机探索;final 使用 24h 请求语义和可复现 seed。所有 seed、模型参数、场景、trace hash 必须写入 receipt。
+
+## Coverage Matrix
+
+`coverage_matrix` 是 required contract coverage matrix,覆盖协议、UART bit、PID/control、safety、debug、virtual_driver_lab、thermal、fault injection、mutation、TD/toolchain。代码覆盖和功能覆盖只能作为增强指标,不能替代合同覆盖矩阵。
+
+## TD 离线工具证据
+
+TD layer 只接受离线 elaboration/build/timing/resource 证据。它不做下载、不做 flash、不声明真实 pin map,也不声明真实电气或热性能。
+
+## 与 final-gate-v2 的关系
+
+`offline-fidelity-gate-v1` 是无实物最高保真 gate;`final-gate-v2` 仍然是当前包含 UART strict receipt 的最终 gate。需要新增真实板级 PID、flash、驱动、外部仪器或生产硬件动作时,必须新增独立 gate、receipt schema、rollback/安全边界和中文 runbook。

+ 15 - 0
docs/offline-verification-report.zh-CN.md

@@ -0,0 +1,15 @@
+# 离线验证报告
+
+当前离线验证范围:
+
+- Python model。
+- BMC UART parser。
+- contract replay。
+- RTL/HDL sim。
+- formal。
+- detector selftest。
+- TD `uart_rs232_j6_host_sensor_real_fan_ptc_debug921_primary` build/blocker evidence。
+- UART receipt strict validation。
+- debug UART/register dump bundle。
+
+当前不声明真实热闭环、真实 PTC/fan/BMC、电气隔离或 thermal performance pass。

+ 23 - 0
docs/pid-safety-contract-v2.zh-CN.md

@@ -0,0 +1,23 @@
+# PID Safety Contract V2
+
+## Fail Closed
+
+- host disable:PTC off,相关 history clear。
+- invalid channel:不驱动 actuator。
+- missing DIMM:对应 PTC off,并进入 missing_mask。
+- BMC stale 10s:全部 PTC off,fan fallback。
+- overtemp 90C:全部 PTC off,fan fallback,fault latch。
+- interlock:全部 PTC off。
+
+## Evidence
+
+安全状态必须进入:
+
+- debug UART event stream。
+- register dump。
+- debug bundle。
+- final-gate-v2 layer evidence。
+
+## 禁止
+
+任何 flash、驱动安装/重装、真实 PTC/fan/BMC 未受控动作都必须 fail closed。

+ 16 - 0
docs/td-2026.1-evidence-index.zh-CN.md

@@ -0,0 +1,16 @@
+# TD 2026.1 Evidence Index
+
+## 活入口
+
+- TD source profile:`td/uart_rs232_j6_host_sensor_real_fan_ptc_debug921_primary.prj`。
+- top:`src/top/uart_rs232_j6_host_sensor_real_fan_ptc_debug921_top.v`。
+- contract top:`src/top/system_contract_top.v`。
+- constraints:`constraints/pid_study_01.adc`、`constraints/pid_study_01.sdc`。
+
+## 输出边界
+
+TD 生成物写入 `td/build/`、`tmp/` 或 TD GUI runtime 目录。bit、bid、data、log、timing、area 不作为源码基线。
+
+## Gate 语义
+
+当前 TD gate 对最新 real FAN/PTC 主线执行离线构建/阻塞判定;真实 FAN/PTC pin 与三路临时串口冲突时只允许记录 blocked,不声明真实产品板 bitstream、下载或热闭环通过。

+ 29 - 0
docs/uart-rs232-validation-strategy.zh-CN.md

@@ -0,0 +1,29 @@
+# UART/RS232 非 ChipWatcher 验证策略
+
+## 目标
+
+验证重点从外部逻辑分析 GUI 迁移到 software evidence、UART transcript、debug UART、register dump 和直接实机 SRAM 验证。机器 gate 只声明 software safety 与通信链路通过,不声明 thermal performance。
+
+## 层级
+
+- L0 static:源码边界、schema、pin inventory、禁止旧 gate、禁止 generated artifacts。
+- L1 protocol offline:BMC loose text hex parser 覆盖 echo/no-echo、裸 hex、`0xNN`、乱码、短帧、长帧、missing。
+- L2 bit-level RTL:UART RX/TX、framing error、break、overflow、TX backpressure。
+- L3 software safety:stale 10s、90C overtemp、host disable、interlock、missing DIMM、fan fallback。
+- L4 loopback/emulator:PC emulator 与同一 BMC 协议交互。
+- L5 board SRAM:只允许 SRAM bit,采集 transcript、debug UART、register dump。
+- L6 staged thermal:25% duty 短时、逐级放开、完整 soak,必须由人工/仪器 runbook 记录 thermal performance。
+
+## 证据
+
+- serial transcript hash。
+- bitstream hash。
+- parser result。
+- debug UART event stream。
+- register dump snapshot。
+- backend capability:pyserial/jsonschema 或 PowerShell/.NET fallback。
+- safety flags。
+
+## final-gate-v2
+
+`final-gate-v2` 强制所有 required layer pass。任何 `blocked_*`、`fail_*`、缺证据或 authority overclaim 都失败。产品板 pin map 和驱动资料未导入前,完整热闭环保持 blocked。

+ 56 - 0
docs/verification-gates-v2.zh-CN.md

@@ -0,0 +1,56 @@
+# 验证 Gate V2
+
+## 顺序
+
+1. `static`。
+2. `model`。
+3. `replay`。
+4. `hdl-sim --run` 或等价 RTL simulator evidence。
+5. `formal --run`。
+6. `detector-selftest --run`。
+7. `td --top uart_rs232_j6_host_sensor_real_fan_ptc_debug921_primary`;真实 FAN/PTC pin 与当前三路调试 UART 冲突时必须 blocked。
+8. `uart-validate --strict`,receipt 通常是 `uart-board-sram-receipt-v1`。
+9. `final-gate-v2`。
+10. 分级实机闭环 runbook receipt,产品板资料未导入前保持 blocked。
+
+## 自动 Gate
+
+`python tools\pid_harness.py final-gate-v2 --receipt <uart_receipt.json> --rtl-sim --formal --detector-selftest --td-build --json`
+
+strict 规则:
+
+- required layer:`static`、`model`、`replay`、`rtl_sim`、`formal`、`detector_selftest`、`td_build`、`uart_strict`。
+- 每个 layer 的 `status` 必须是 `pass`。
+- top-level receipt 的 `status` 必须是 `pass`。
+- schema 不允许未声明 layer。
+- `blocked_*` 和 `fail_*` 不得提升为 pass。
+- authority boundary 不能声明 thermal performance pass。
+
+`final-gate-v2` 的 pass 只证明控制通讯链路和软件安全策略通过,不证明完整 thermal performance。
+
+## UART Strict Receipt
+
+`uart-board-sram-receipt-v1` 至少需要:
+
+- `programming.mode=PROGRAM_SRAM`。
+- bitstream `sha256`。
+- serial `115200 8N1`、allowlist、DTR/RTS 记录。
+- transcript `sha256`。
+- debug UART event stream。
+- register dump。
+- `counterparty=pc_emulator|real_bmc`。
+- safety flags 全部显式 false。
+
+`uart-soak-receipt-v1` 不要求 top-level transcript,但 strict 模式要求每轮 pass round 关联可验证的 UART round receipt。
+
+## 不接受项
+
+- flash、driver install/reinstall、真实 PTC/fan/BMC 未受控动作。
+- 无 allowlist 的 COM。
+- 缺 transcript hash、bitstream hash、debug UART、register dump。
+- 产品板 pin map 未导入却声明完整热闭环。
+- 只靠 preflight 或人工口述。
+
+## 后续真实闭环
+
+真实闭环按 25% duty 短时、逐级放开、完整工况 soak 分级准入。强制保留 70C 默认目标、90C 硬过温、10s stale、fan fallback、人工急停和 SRAM-only 回滚。

Разница между файлами не показана из-за своего большого размера
+ 48 - 0
docs/verification-plan.zh-CN.md


+ 15 - 0
reference/original/MANIFEST.zh-CN.md

@@ -0,0 +1,15 @@
+# 原始资料 Manifest
+
+`reference/original/` 只保存原始资料和来源索引,不作为活工程入口。
+
+## 可跟踪资料
+
+- `board/EF2L45BG256B_MINI_V2.0/`:MINI 开发板手册、原理图和厂商示例资料,用于核对 TD/ChipWatcher/板卡上下文。
+- `diagrams/`:用户提供的系统逻辑图,仅作为需求背景。
+
+## 本地保留但不跟踪
+
+- `local_archives/`:安装包、压缩包、license、私有归档或体积较大的本地资料。
+- `vendor/`:厂商安装介质或可重新获取的大型 vendor payload。
+
+这些路径已由 `.gitignore` 排除。若后续确实需要把某个大型或私有资料纳入可复现证据,应先新增只含 `sha256`、来源、用途、许可边界的 manifest 条目,不直接提交 license、安装包或私有压缩包。

+ 53 - 29
workspace/cpld_temperature_control_board/td_project/demo.al

@@ -1,20 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<Project Version="3" Minor="2" Path="C:/Users/16936/Desktop/CPLD_temperature_control_board/td_project">
+<Project Version="3" Minor="2" Path="D:/user/project/mini_demo_case/demo review/EF2L45BG256B/demo/demo9_test_lvds/td_project">
     <Project_Created_Time></Project_Created_Time>
-    <TD_Version>6.2.198412</TD_Version>
-    <Name>demo</Name>
+    <TD_Version>5.6.71036</TD_Version>
+    <Name>test_lvds</Name>
     <HardWare>
         <Family>EF2</Family>
         <Device>EF2L45BG256B</Device>
         <Speed></Speed>
     </HardWare>
-    <MiscSettings>
-        <Setting Key="account" Val="" />
-        <Setting Key="farm" Val="disable" />
-    </MiscSettings>
     <Source_Files>
         <Verilog>
-            <File Path="../user_source/i2c_bit_shift.v">
+            <File Path="../user_source/hdl_source/design_top_wrapper.v">
                 <FileInfo>
                     <Attr Name="UsedInSyn" Val="true"/>
                     <Attr Name="UsedInP&R" Val="true"/>
@@ -22,7 +18,7 @@
                     <Attr Name="CompileOrder" Val="1"/>
                 </FileInfo>
             </File>
-            <File Path="../user_source/i2c_control.v">
+            <File Path="../user_source/hdl_source/led.v">
                 <FileInfo>
                     <Attr Name="UsedInSyn" Val="true"/>
                     <Attr Name="UsedInP&R" Val="true"/>
@@ -30,7 +26,7 @@
                     <Attr Name="CompileOrder" Val="2"/>
                 </FileInfo>
             </File>
-            <File Path="../user_source/iic_top.v">
+            <File Path="../user_source/hdl_source/new_src/lvds_rec_8_1.v">
                 <FileInfo>
                     <Attr Name="UsedInSyn" Val="true"/>
                     <Attr Name="UsedInP&R" Val="true"/>
@@ -38,42 +34,74 @@
                     <Attr Name="CompileOrder" Val="3"/>
                 </FileInfo>
             </File>
-            <File Path="../user_source/uart_helloword.v">
+            <File Path="../user_source/hdl_source/new_src/lvds_rec_intf_8_1.v">
+                <FileInfo>
+                    <Attr Name="UsedInSyn" Val="true"/>
+                    <Attr Name="UsedInP&R" Val="true"/>
+                    <Attr Name="BelongTo" Val="design_1"/>
+                    <Attr Name="CompileOrder" Val="4"/>
+                </FileInfo>
+            </File>
+            <File Path="../user_source/hdl_source/new_src/lvds_snd_8_1_m.v">
                 <FileInfo>
-                    <Attr Name="AutoExcluded" Val="true"/>
                     <Attr Name="UsedInSyn" Val="true"/>
                     <Attr Name="UsedInP&R" Val="true"/>
                     <Attr Name="BelongTo" Val="design_1"/>
                     <Attr Name="CompileOrder" Val="5"/>
                 </FileInfo>
             </File>
-            <File Path="../user_source/test_pid.v">
+            <File Path="../user_source/hdl_source/new_src/lvds_snd_intf_8_1_m.v">
+                <FileInfo>
+                    <Attr Name="UsedInSyn" Val="true"/>
+                    <Attr Name="UsedInP&R" Val="true"/>
+                    <Attr Name="BelongTo" Val="design_1"/>
+                    <Attr Name="CompileOrder" Val="6"/>
+                </FileInfo>
+            </File>
+            <File Path="../user_source/hdl_source/prbs/prbs_chk.v">
                 <FileInfo>
-                    <Attr Name="AutoExcluded" Val="true"/>
                     <Attr Name="UsedInSyn" Val="true"/>
                     <Attr Name="UsedInP&R" Val="true"/>
                     <Attr Name="BelongTo" Val="design_1"/>
                     <Attr Name="CompileOrder" Val="7"/>
                 </FileInfo>
             </File>
-        </Verilog>
-        <IP_FILE>
-            <File Path="al_ip/UART_0/UART_0.xml">
+            <File Path="../user_source/hdl_source/prbs/prbs_gen.v">
                 <FileInfo>
-                    <Attr Name="AutoExcluded" Val="true"/>
                     <Attr Name="UsedInSyn" Val="true"/>
                     <Attr Name="UsedInP&R" Val="true"/>
                     <Attr Name="BelongTo" Val="design_1"/>
-                    <Attr Name="CompileOrder" Val="4"/>
+                    <Attr Name="CompileOrder" Val="8"/>
+                </FileInfo>
+            </File>
+        </Verilog>
+        <ADC_FILE>
+            <File Path="../user_source/constraint_source/test_lvds.adc">
+                <FileInfo>
+                    <Attr Name="UsedInSyn" Val="true"/>
+                    <Attr Name="UsedInP&R" Val="true"/>
+                    <Attr Name="BelongTo" Val="constraint_1"/>
+                    <Attr Name="CompileOrder" Val="1"/>
                 </FileInfo>
             </File>
-            <File Path="al_ip/DSPF4F6D0P0_0/DSPF4F6D0P0_0.xml">
+        </ADC_FILE>
+        <SDC_FILE>
+            <File Path="../user_source/constraint_source/test_lvds.sdc">
+                <FileInfo>
+                    <Attr Name="UsedInSyn" Val="true"/>
+                    <Attr Name="UsedInP&R" Val="true"/>
+                    <Attr Name="BelongTo" Val="constraint_1"/>
+                    <Attr Name="CompileOrder" Val="2"/>
+                </FileInfo>
+            </File>
+        </SDC_FILE>
+        <IP_FILE>
+            <File Path="../user_source/ip_source/lvds_pll.ipc">
                 <FileInfo>
-                    <Attr Name="AutoExcluded" Val="true"/>
                     <Attr Name="UsedInSyn" Val="true"/>
                     <Attr Name="UsedInP&R" Val="true"/>
                     <Attr Name="BelongTo" Val="design_1"/>
-                    <Attr Name="CompileOrder" Val="6"/>
+                    <Attr Name="CompileOrder" Val="9"/>
                 </FileInfo>
             </File>
         </IP_FILE>
@@ -85,9 +113,9 @@
         </FileSet>
     </FileSets>
     <TOP_MODULE>
-        <LABEL>top</LABEL>
-        <MODULE>top</MODULE>
-        <CREATEINDEX>user</CREATEINDEX>
+        <LABEL></LABEL>
+        <MODULE>design_top_wrapper</MODULE>
+        <CREATEINDEX>auto</CREATEINDEX>
     </TOP_MODULE>
     <Property>
     </Property>
@@ -99,14 +127,10 @@
         <Run Name="syn_1" Type="Synthesis" ConstraintSet="constraint_1" Description="" Active="true">
             <Strategy Name="Default_Synthesis_Strategy">
             </Strategy>
-            <UserParams>
-            </UserParams>
         </Run>
         <Run Name="phy_1" Type="PhysicalDesign" ConstraintSet="constraint_1" Description="" SynRun="syn_1" Active="true">
             <Strategy Name="Default_PhysicalDesign_Strategy">
             </Strategy>
-            <UserParams>
-            </UserParams>
         </Run>
     </Runs>
     <Project_Settings>

+ 14 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/constraint_source/test_lvds.adc

@@ -0,0 +1,14 @@
+set_pin_assignment	{ led[0] }	{ LOCATION = H16; }
+set_pin_assignment	{ led[1] }	{ LOCATION = H15; }
+set_pin_assignment	{ led[2] }	{ LOCATION = J16; }
+set_pin_assignment	{ led[3] }	{ LOCATION = J15; }
+set_pin_assignment	{ rx_clk }	{ LOCATION = T7; IOSTANDARD = LVDS25; }
+set_pin_assignment	{ rx_in_p }	{ LOCATION = R13; IOSTANDARD = LVDS25; }
+set_pin_assignment	{ sys_clk }	{ LOCATION = J1; }
+set_pin_assignment	{ sys_rst_n }	{ LOCATION = N6; }
+set_pin_assignment	{ tx_clk }	{ LOCATION = T11; IOSTANDARD = LVDS25; }
+set_pin_assignment	{ tx_out_p }	{ LOCATION = T15; IOSTANDARD = LVDS25; }
+
+
+
+

+ 5 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/constraint_source/test_lvds.sdc

@@ -0,0 +1,5 @@
+create_clock -name sys_clk -period 40 -waveform {0 20} [get_ports {sys_clk}]
+#create_clock -name rxclk -period 5 -waveform {0 2.5} [get_ports {rx_clk}]
+#set_clock_groups -exclusive -group [get_clocks {clk25}]
+#set_clock_groups -exclusive -group [get_clocks {rxclk}]
+derive_pll_clocks

+ 147 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/design_top_wrapper.v

@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2011-2023 Anlogic, Inc.
+// All Right Reserved.
+///////////////////////////////////////////////////////////////////////////////
+//
+//
+//   Vendor : Anlogic
+//   Version : 1.0
+//   Description : 
+//   Filename : design_top_wrapper.v
+//   Timestamp :
+//
+///////////////////////////////////////////////////////////////////////////////
+//
+// Revision:
+//    2023/01/03 - 1.0 - Initial version.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+`timescale  1 ps / 1 ps
+
+module design_top_wrapper(
+	input               sys_rst_n,
+	input               sys_clk,
+	input               rx_in_p,
+	input               rx_clk,
+
+	output wire [3:0]   led,
+	output              tx_out_p,
+	output              tx_clk
+ );
+
+wire clk_25;
+wire clk_100;
+
+wire clk_x1;
+wire clk_x4;
+
+wire [7:0] lvds_data_in;
+wire [7:0] lvds_data_out;
+wire       tpg_data_valid;
+wire lock;
+wire alm0;
+wire rx_clk_x4;
+wire rx_clk_x1;
+
+wire reset_reg;
+reg [15:0] cnt;
+
+
+assign clk_x1 = clk_25;
+assign clk_x4 = clk_100;
+
+
+led#(
+    .CLK   (100_000_000)
+)u_led
+(
+    .clk   ( rx_clk_x4 ),
+    .led   ( led       ),
+    .rst_n ( ~alm0     )
+    );
+
+
+ always @(posedge sys_clk )begin
+         if(cnt[15] == 1)
+             cnt <= cnt;
+         else
+             cnt <= cnt + 1;
+ end
+ 
+assign reset_reg = ~cnt[15];  
+  
+lvds_pll ux_pll(
+	.refclk   ( sys_clk   ),
+	.reset    ( reset_reg ),
+	.extlock  ( lock      ),
+	.clk0_out ( clk_25    ),
+	.clk1_out ( clk_100   )
+);
+ 
+    
+lvds_snd_8_1_m ux_lvds_send
+(       
+	.lvds_rst             ( ~sys_rst_n   ),
+	.tx_inclock           ( clk_x4       ),
+	.tx_syncclock         ( clk_x1       ),
+	.tx_in                ( lvds_data_in ),
+	.tx_out               ( tx_out_p     ),
+	.tx_pinclk_edge_point (              ),
+	.tx_clk_out           ( tx_clk       )
+);  
+
+//lvds_pll_rx u_rx_clk(
+//	.refclk   ( rx_clk     ),
+//	.reset    ( ~sys_rst_n ),
+//	.lock     (            ),
+//	.clk0_out ( rx_clk_x1  ),
+//	.clk1_out ( rx_clk_x4  )
+//	);
+
+EF2_LOGIC_BUFIO #(
+	.DIV( 4 )
+)U_io_clk_div_0( 
+    .clki	 ( rx_clk     ),
+    .rst	 ( ~sys_rst_n ),
+    .coe	 ( 1'b1       ),
+    .clko	 (            ),       
+    .clkdiv1 ( rx_clk_x4  ),
+    .clkdivx ( rx_clk_x1  )
+);
+
+lvds_rec_8_1 ux_lvds_rec
+(
+	.lvds_rst    ( ~sys_rst_n    ),
+	.rx_sinclock ( rx_clk_x4     ),
+	.rx_pinclock ( rx_clk_x1     ),
+	.rx_in       ( rx_in_p       ),
+	.rx_out      ( lvds_data_out )
+); 
+
+prbs_chk
+#(
+	.PRBS_PLOY  ( 15'h6000 ),
+	.DAT_W      ( 8        ),
+	.PRBS_WIDTH ( 15       )
+)
+prbs_chk_inst(
+	.clk   ( rx_clk_x1           ),
+	.i_dat ( lvds_data_out       ),
+	.rst   ( ~sys_rst_n || ~lock ),
+	.o_alm ( alm0                )
+);
+
+prbs_gen
+#(
+	.PRBS_PLOY  ( 15'h6000 ),
+	.DAT_W      ( 8        ),
+	.PRBS_WIDTH ( 15       )
+)
+prbs_gen_inst(
+	.clk   ( clk_x1       ),
+	.i_err ( 1'b0         ),
+	.o_dat ( lvds_data_in ) 
+);
+
+endmodule

+ 81 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/led.v

@@ -0,0 +1,81 @@
+`timescale 1ns / 1ps
+
+module led#(
+	parameter CLK = 25_000_000
+)
+(
+    input clk,
+    output reg[3:0] led,
+    input rst_n
+    );
+	
+//参数定义
+reg [31:0] cnt0;
+wire      end_cnt0;
+wire      add_cnt0;
+reg [2:0] cnt1;
+wire      end_cnt1;
+wire      add_cnt1;
+
+//计数器2
+ always @(posedge clk or negedge rst_n)begin
+     if(!rst_n)begin
+         cnt0 <= 0;
+     end
+     else if(add_cnt0)begin
+         if(end_cnt0)
+             cnt0 <= 0;
+         else
+             cnt0 <= cnt0 + 1;
+     end
+ end
+
+ assign add_cnt0 = 1;
+ assign end_cnt0 = add_cnt0 && cnt0== CLK;
+
+ always @(posedge clk or negedge rst_n)begin 
+     if(!rst_n)begin
+         cnt1 <= 0;
+     end
+     else if(add_cnt1)begin
+         if(end_cnt1)
+             cnt1 <= 0;
+         else
+             cnt1 <= cnt1 + 1;
+     end
+ end
+
+ assign add_cnt1 = end_cnt0;
+ assign end_cnt1 = add_cnt1 && cnt1 == 5;  	
+	
+always @(posedge clk or negedge rst_n)begin
+	if(!rst_n)begin
+		led <= 4'b0000;
+	end
+	else if(add_cnt1 && cnt1 == 0)begin
+		led <= 4'b1110;
+	end
+	else if(add_cnt1 && cnt1 == 1)begin
+		led <= 4'b1101;
+	end
+	else if(add_cnt1 && cnt1 == 2)begin
+		led <= 4'b1011;
+	end
+	else if(add_cnt1 && cnt1 == 3)begin
+		led <= 4'b0111;
+	end
+	else if(add_cnt1 && cnt1 == 4)begin
+		led <= 4'b1011;
+	end
+	else if(add_cnt1 && cnt1 == 5)begin
+		led <= 4'b1101;
+	end
+	else begin
+		led <= led;
+	end	
+end	
+
+
+
+
+endmodule

+ 57 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/new_src/lvds_rec_8_1.v

@@ -0,0 +1,57 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2011-2023 Anlogic, Inc.
+// All Right Reserved.
+///////////////////////////////////////////////////////////////////////////////
+//
+//
+//   Vendor : Anlogic
+//   Version : 1.0
+//   Description : 
+//   Filename : lvds_rec_8_1.v
+//   Timestamp :
+//
+///////////////////////////////////////////////////////////////////////////////
+//
+// Revision:
+//    2023/01/03 - 1.0 - Initial version.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+`timescale  1 ps / 1 ps
+
+module lvds_rec_8_1(
+	input             lvds_rst	  ,	
+	input             rx_sinclock ,
+	input             rx_pinclock ,
+	input             rx_in       ,
+	output reg  [7:0] rx_out
+);
+
+wire [15:0]      rx_rec_out;
+wire [1:0]       ddio_in_dataout;
+reg [7:0]        rx_out_tmp;
+ 
+always @(posedge rx_pinclock)
+begin
+	 rx_out_tmp <= rx_rec_out[11:4];
+	 rx_out     <= rx_out_tmp;	 	 
+end
+
+lvds_rec_intf_8_1 U_lvds_rx_intf_8_1(
+	.lvds_rst		(lvds_rst		), 
+	.ddio_in_dataout(ddio_in_dataout), 
+	.rx_sinclock	(rx_sinclock	), 
+	.rx_pinclock	(rx_pinclock	), 
+	.rx_out_intf	(rx_rec_out		)
+);
+EF2_LOGIC_IDDR #(
+	.PIPEMODE("NONE")//PIPED
+)ddio_in_a0(
+	.q1			(ddio_in_dataout[1]	), 
+	.q0			(ddio_in_dataout[0]	), 
+	.clk		(rx_sinclock		), 
+	.d			(rx_in				), 
+	.rst		(1'b0				)
+);
+   
+endmodule

+ 74 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/new_src/lvds_rec_intf_8_1.v

@@ -0,0 +1,74 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2011-2023 Anlogic, Inc.
+// All Right Reserved.
+///////////////////////////////////////////////////////////////////////////////
+//
+//
+//   Vendor : Anlogic
+//   Version : 1.0
+//   Description : 
+//   Filename : lvds_rec_intf_8_1.v
+//   Timestamp :
+//
+///////////////////////////////////////////////////////////////////////////////
+//
+// Revision:
+//    2023/01/03 - 1.0 - Initial version.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+`timescale  1 ps / 1 ps
+
+module lvds_rec_intf_8_1(
+	input             lvds_rst		 ,	
+	input             rx_sinclock    ,
+	input             rx_pinclock    ,
+	input [1:0]       ddio_in_dataout,
+	output reg [15:0] rx_out_intf
+); 
+wire              wire_ddio_in_dataout_h;
+wire              wire_ddio_in_dataout_l;
+reg [15:0]        shiftreg;
+reg               rx_pinclk_edge_q;
+reg               rx_pinclk_edge_qq;
+reg               rx_pinclk_edge_point;
+wire [7:0]        rx_out_reg;
+reg               rx_pinclk_edge;
+   
+assign wire_ddio_in_dataout_h = ddio_in_dataout[1];
+assign wire_ddio_in_dataout_l = ddio_in_dataout[0];
+   
+always @(posedge rx_sinclock or posedge lvds_rst)
+begin
+	if (lvds_rst === 1'b1)
+	begin	 
+		 rx_pinclk_edge_q <= 1'b0;
+		 rx_pinclk_edge_qq <= 1'b0;
+		 rx_pinclk_edge_point <= 1'b0;
+		 shiftreg <= {16{1'b0}};
+	end
+	else 
+	begin
+		 rx_pinclk_edge_q <= rx_pinclk_edge;
+		 rx_pinclk_edge_qq <= rx_pinclk_edge_q;
+		 rx_pinclk_edge_point <= rx_pinclk_edge_q ^ rx_pinclk_edge_qq;
+		 shiftreg <= {shiftreg[13:0], wire_ddio_in_dataout_h, wire_ddio_in_dataout_l};
+		 if (rx_pinclk_edge_point === 1'b1)
+			rx_out_intf <= shiftreg;
+	end
+end
+
+
+always @(posedge rx_pinclock or posedge lvds_rst)
+begin
+	if (lvds_rst === 1'b1)
+		rx_pinclk_edge <= 1'b0;
+	else 
+		rx_pinclk_edge <= (~rx_pinclk_edge);
+end
+   
+endmodule
+
+
+
+

+ 63 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/new_src/lvds_snd_8_1_m.v

@@ -0,0 +1,63 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2011-2023 Anlogic, Inc.
+// All Right Reserved.
+///////////////////////////////////////////////////////////////////////////////
+//
+//
+//   Vendor : Anlogic
+//   Version : 1.0
+//   Description : 
+//   Filename : lvds_snd_8_1_m.v
+//   Timestamp :
+//
+///////////////////////////////////////////////////////////////////////////////
+//
+// Revision:
+//    2023/01/03 - 1.0 - Initial version.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+`timescale  1 ps / 1 ps
+
+module lvds_snd_8_1_m(
+	input       lvds_rst			,
+	input       tx_inclock          ,
+	input       tx_syncclock        ,
+	input [7:0] tx_in               ,
+	output      tx_pinclk_edge_point,
+	output      tx_out              ,
+	output reg  tx_clk_out
+);
+
+   
+
+wire [1:0]  out_lvds_data_pre;
+wire        tx_clk_out_pre;
+   
+   
+lvds_snd_intf_8_1_m U_lvds_snd_intf_8_1(
+	.lvds_rst				(lvds_rst				), 
+	.tx_in					(tx_in					), 
+	.tx_inclock				(tx_inclock				), 
+	.tx_syncclock			(tx_syncclock			), 
+	.tx_pinclk_edge_point	(tx_pinclk_edge_point	), 
+	.tx_out_pre				(out_lvds_data_pre		), 
+	.tx_clk_out				(tx_clk_out_pre			)
+);
+   
+EF2_LOGIC_ODDR ODDR0_snd(
+	.q						(tx_out					), 
+	.clk					(tx_inclock				), 
+	.d1						(out_lvds_data_pre[0]	), 
+	.d0						(out_lvds_data_pre[1]	), 
+	.rst					(1'b0					)
+);
+   
+always @(negedge tx_inclock or posedge lvds_rst)
+begin
+	if (lvds_rst == 1'b1)
+		tx_clk_out <= 1'b0;
+	else 
+		tx_clk_out <= tx_clk_out_pre;
+end  
+endmodule

+ 109 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/new_src/lvds_snd_intf_8_1_m.v

@@ -0,0 +1,109 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2011-2023 Anlogic, Inc.
+// All Right Reserved.
+///////////////////////////////////////////////////////////////////////////////
+//
+//
+//   Vendor : Anlogic
+//   Version : 1.0
+//   Description : 
+//   Filename : lvds_snd_intf_8_1_m.v
+//   Timestamp :
+//
+///////////////////////////////////////////////////////////////////////////////
+//
+// Revision:
+//    2023/01/03 - 1.0 - Initial version.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+`timescale  1 ps / 1 ps
+
+module lvds_snd_intf_8_1_m(
+	input            lvds_rst			  ,	
+	input            tx_inclock           ,
+	input            tx_syncclock         ,
+	input [7:0]      tx_in                ,
+	output reg       tx_pinclk_edge_point ,
+	output reg [1:0] tx_out_pre           ,
+	output reg       tx_clk_out
+);
+reg [1:0]        cnt4;
+wire             div4;
+reg [7:0]        shift_p0;
+wire             fast_clk;
+wire             slow_clk;
+reg              tx_pinclk_edge;
+reg              tx_pinclk_edge_q;
+reg              tx_pinclk_edge_qq;
+reg              tx_clk_pre;
+
+assign fast_clk = tx_inclock;
+assign slow_clk = tx_syncclock;
+
+always @(posedge slow_clk or posedge lvds_rst)
+begin
+	if (lvds_rst == 1'b1)
+		tx_pinclk_edge <= 1'b0;
+	else 
+		tx_pinclk_edge <= (~tx_pinclk_edge);
+end
+
+
+always @(posedge fast_clk or posedge lvds_rst)
+begin
+	if (lvds_rst == 1'b1)
+	begin
+		 tx_pinclk_edge_q     <= 1'b0;
+		 tx_pinclk_edge_qq    <= 1'b0;
+		 tx_pinclk_edge_point <= 1'b0;
+		 cnt4 <= {2{1'b0}};
+	end
+	else 
+	begin
+		 tx_pinclk_edge_q     <= tx_pinclk_edge;
+		 tx_pinclk_edge_qq    <= tx_pinclk_edge_q;
+		 tx_pinclk_edge_point <= tx_pinclk_edge_q ^ tx_pinclk_edge_qq;
+		 if (tx_pinclk_edge_point == 1'b1)
+			cnt4 <= 2'b00;
+		 else
+			cnt4 <= cnt4 + 1;
+	end
+end
+
+
+always @(posedge fast_clk or posedge lvds_rst)
+begin
+	if (lvds_rst == 1'b1)
+		shift_p0 <= {8{1'b0}};
+	else 
+	begin
+		if (tx_pinclk_edge_point == 1'b1)
+			shift_p0 <= tx_in[7:0];
+		else
+			shift_p0 <= {shift_p0[5:0], 1'b0, 1'b0};
+	end
+end
+
+always @(posedge fast_clk or posedge lvds_rst)
+begin
+	if (lvds_rst == 1'b1)
+		tx_out_pre <= {2{1'b0}};
+	else 
+		tx_out_pre <= shift_p0[7:6];
+end
+
+always @(posedge fast_clk or posedge lvds_rst)
+begin
+	if (lvds_rst == 1'b1)
+	begin
+		 tx_clk_pre <= 1'b0;
+		 tx_clk_out <= 1'b0;
+	end
+	else 
+	begin
+		 tx_clk_pre <= cnt4[1];
+		 tx_clk_out <= tx_clk_pre;
+	end
+end   
+endmodule

+ 77 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/prbs/prbs_chk.v

@@ -0,0 +1,77 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2011-2023 Anlogic, Inc.
+// All Right Reserved.
+///////////////////////////////////////////////////////////////////////////////
+//
+//
+//   Vendor : Anlogic
+//   Version : 1.0
+//   Description : 
+//   Filename : prbs_chk.v
+//   Timestamp :
+//
+///////////////////////////////////////////////////////////////////////////////
+//
+// Revision:
+//    2023/01/03 - 1.0 - Initial version.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+`timescale  1 ps / 1 ps
+
+module prbs_chk
+#(
+	parameter  PRBS_PLOY = 15'h6000 ,
+	parameter  DAT_W	 = 4		,
+	parameter  PRBS_WIDTH= 15		
+)
+(
+	input	clk						,
+	input	[DAT_W -1:0]	i_dat 	,
+	input                   rst     ,
+	output 	o_alm
+	
+);
+
+function [DAT_W + PRBS_WIDTH- 1 :0] PRBS_ANY		;
+input	 [PRBS_WIDTH - 1 : 0]			seed		;
+input	 [PRBS_WIDTH - 1 : 0]			poly		;
+reg 	 [PRBS_WIDTH - 1 : 0]			prbs		;
+integer 							i				;
+begin 
+	prbs = seed ;
+	for(i = 0 ; i < DAT_W ; i = i + 1)
+	begin 
+	
+		prbs = {prbs[PRBS_WIDTH-2:0],^(prbs & poly)}	;
+		PRBS_ANY[DAT_W + PRBS_WIDTH - 1 - i] = prbs[0]  ;
+		PRBS_ANY[PRBS_WIDTH - 1 : 0]         = prbs     ;
+	end 
+
+end 
+endfunction
+
+reg		alm;
+wire	[PRBS_WIDTH + DAT_W - 1 : 0] 	prbs_temp	;
+
+reg		[DAT_W - 1	    		: 0]  	data_prbs=4'd0	;
+reg		[DAT_W - 1	    		: 0]  	data_dly=4'd0	;
+reg		[PRBS_WIDTH - 1 		: 0]	data_seed=15'd0	;
+
+assign prbs_temp =  PRBS_ANY( (data_seed == 0) ? {{(PRBS_WIDTH -1){1'b0}},1'b1}:data_seed,PRBS_PLOY); 
+
+always @(posedge clk )   
+begin 
+	data_prbs <= prbs_temp[PRBS_WIDTH + DAT_W - 1 : PRBS_WIDTH];
+	data_seed <= {prbs_temp[PRBS_WIDTH - 1 : DAT_W],i_dat};
+	data_dly  <= i_dat ;
+end 
+
+always @(posedge clk ) 
+begin 
+	alm <= ~(data_prbs == data_dly) ;
+end 
+
+assign o_alm = alm ;
+
+endmodule 

+ 64 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/hdl_source/prbs/prbs_gen.v

@@ -0,0 +1,64 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2011-2023 Anlogic, Inc.
+// All Right Reserved.
+///////////////////////////////////////////////////////////////////////////////
+//
+//
+//   Vendor : Anlogic
+//   Version : 1.0
+//   Description : 
+//   Filename : prbs_gen.v
+//   Timestamp :
+//
+///////////////////////////////////////////////////////////////////////////////
+//
+// Revision:
+//    2023/01/03 - 1.0 - Initial version.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+`timescale  1 ps / 1 ps
+
+module prbs_gen
+#(
+	parameter  PRBS_PLOY = 15'h6000 ,
+	parameter  DAT_W	 = 4		,
+	parameter  PRBS_WIDTH= 15		
+)
+(
+	input	clk		,
+	input	i_err	,
+	output	reg	[DAT_W -1:0]	o_dat 
+);
+
+function [DAT_W + PRBS_WIDTH- 1 :0] PRBS_ANY		;
+input	 [PRBS_WIDTH - 1 : 0]			seed		;
+input	 [PRBS_WIDTH - 1 : 0]			poly		;
+reg 	 [PRBS_WIDTH - 1 : 0]			prbs;
+integer 							i				;
+begin 
+	prbs = seed ;
+	for(i = 0 ; i < DAT_W ; i = i + 1)
+	begin 
+	
+		prbs = {prbs[PRBS_WIDTH-2:0],^(prbs & poly)}	;
+		PRBS_ANY[DAT_W + PRBS_WIDTH - 1 - i] = prbs[0]  ;
+		PRBS_ANY[PRBS_WIDTH - 1 : 0]         = prbs     ;
+	end 
+
+end 
+endfunction
+
+reg		[DAT_W - 1	    : 0]	data_prbs=4'd0	;
+reg		[PRBS_WIDTH - 1 : 0]	data_seed=15'd0	;
+always @(posedge clk)
+begin 
+	{data_prbs,data_seed} <=  PRBS_ANY( (data_seed == 0) ? {{(PRBS_WIDTH -1){1'b0}},1'b1}:data_seed,PRBS_PLOY); 
+end 
+
+always @(posedge clk)
+begin 
+	o_dat <= data_prbs | {{(DAT_W - 1){1'b0}},i_err} ;
+end 
+
+endmodule 

+ 44 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/ip_source/lvds_pll.ipc

@@ -0,0 +1,44 @@
+<?xml version='1.0' encoding='utf-8'?>
+<PLLConfig version="1.0">
+    <GeneralConfig>
+        <Type>PLL</Type>
+        <Device>EF2L45BG256B</Device>
+        <create_VHDL>true</create_VHDL>
+    </GeneralConfig>
+    <Page1>
+        <speed_grade>Any</speed_grade>
+        <input_frequency>25.0000000000000000MHz</input_frequency>
+        <feedback_mode>Normal</feedback_mode>
+        <clk_num>CLKC0</clk_num>
+        <enable_reset>ENABLE</enable_reset>
+        <pll_lock>ENABLE</pll_lock>
+    </Page1>
+    <Page2>
+        <bandwidth_setting>Medium</bandwidth_setting>
+    </Page2>
+    <Page3>
+        <setting>frequncy_setting</setting>
+        <multiplication_factor>3</multiplication_factor>
+        <division_factor>1</division_factor>
+        <clocks>
+            <clock>
+                <id>0</id>
+                <clock_division_factor>12</clock_division_factor>
+                <clock_frequency>75.0000000000000000MHz</clock_frequency>
+                <phase_shift>0.0000000000000000deg</phase_shift>
+                <duty_cycle>0.5</duty_cycle>
+            </clock>
+            <clock>
+                <id>1</id>
+                <clock_division_factor>3</clock_division_factor>
+                <clock_frequency>300.0000000000000000MHz</clock_frequency>
+                <phase_shift>0.0000000000000000deg</phase_shift>
+                <duty_cycle>0.5</duty_cycle>
+            </clock>
+        </clocks>
+    </Page3>
+    <GeneratedFiles>
+        <Verilog Enable="true">lvds_pll.v</Verilog>
+        <VHDL Enable="false">lvds_pll.vhd</VHDL>
+    </GeneratedFiles>
+</PLLConfig>

+ 111 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/ip_source/lvds_pll.v

@@ -0,0 +1,111 @@
+/************************************************************\
+ **     Copyright (c) 2012-2023 Anlogic Inc.
+ **  All Right Reserved.\
+\************************************************************/
+/************************************************************\
+ ** Log	:	This file is generated by Anlogic IP Generator.
+ ** File	:	D:/user/project/mini_demo_case/EF2L45BG256B/demo/demo9_test_lvds/user_source/ip_source/lvds_pll.v
+ ** Date	:	2023 03 30
+ ** TD version	:	5.6.71036
+\************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+//	Input frequency:             25.000MHz
+//	Clock multiplication factor: 3
+//	Clock division factor:       1
+//	Clock information:
+//		Clock name	| Frequency 	| Phase shift
+//		C0        	| 75.000000 MHZ	| 0  DEG     
+//		C1        	| 300.000000MHZ	| 0  DEG     
+///////////////////////////////////////////////////////////////////////////////
+`timescale 1 ns / 100 fs
+
+module lvds_pll (
+  refclk,
+  reset,
+  extlock,
+  clk0_out,
+  clk1_out 
+);
+
+  input refclk;
+  input reset;
+  output extlock;
+  output clk0_out;
+  output clk1_out;
+
+  wire clk0_buf;
+
+  EF2_LOGIC_BUFG bufg_feedback (
+    .i(clk0_buf),
+    .o(clk0_out) 
+  );
+
+  EF2_PHY_PLL #(
+    .DPHASE_SOURCE("DISABLE"),
+    .DYNCFG("DISABLE"),
+    .FIN("25.000"),
+    .FEEDBK_MODE("NORMAL"),
+    .FEEDBK_PATH("CLKC0_EXT"),
+    .STDBY_ENABLE("DISABLE"),
+    .PLLRST_ENA("ENABLE"),
+    .SYNC_ENABLE("DISABLE"),
+    .GMC_GAIN(2),
+    .ICP_CURRENT(9),
+    .KVCO(2),
+    .LPF_CAPACITOR(1),
+    .LPF_RESISTOR(8),
+    .REFCLK_DIV(1),
+    .FBCLK_DIV(3),
+    .CLKC0_ENABLE("ENABLE"),
+    .CLKC0_DIV(12),
+    .CLKC0_CPHASE(11),
+    .CLKC0_FPHASE(0),
+    .CLKC1_ENABLE("ENABLE"),
+    .CLKC1_DIV(3),
+    .CLKC1_CPHASE(2),
+    .CLKC1_FPHASE(0),
+    .PU_INTP("DISABLE"),
+    .INTPI(0),
+    .HIGH_SPEED_EN("DISABLE"),
+    .SSC_ENABLE("DISABLE"),
+    .SSC_MODE("Down"),
+    .SSC_AMP(0.0000),
+    .SSC_FREQ_DIV(0),
+    .SSC_RNGE(0),
+    .FREQ_OFFSET(0.0000),
+    .OFFSET_MODE("EXT"),
+    .FREQ_OFFSET_INT(0),
+    .CLKC0_DUTY(0.5000),
+    .CLKC0_DUTY_INT(6),
+    .CLKC0_DUTY50("ENABLE"),
+    .CLKC1_DUTY(0.5000),
+    .CLKC1_DUTY_INT(2),
+    .CLKC1_DUTY50("ENABLE") 
+  ) pll_inst (
+    .refclk(refclk),
+    .reset(reset),
+    .stdby(1'b0),
+    .extlock(extlock),
+    .load_reg(1'b0),
+    .psclk(1'b0),
+    .psdown(1'b0),
+    .psstep(1'b0),
+    .psclksel(3'b000),
+    .psdone(open),
+    .dclk(1'b0),
+    .dcs(1'b0),
+    .dwe(1'b0),
+    .di(8'b00000000),
+    .daddr(6'b000000),
+    .do({open, open, open, open, open, open, open, open}),
+    .fbclk(clk0_out),
+    .clkc({open, open, open, open, open, clk1_out, clk0_buf}),
+    .ssc_en(1'b0),
+    .frac_offset_valid(1'b0),
+    .dsm_refclk(1'b0),
+    .dsm_rst(reset) 
+  );
+
+endmodule
+

+ 121 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/ip_source/lvds_pll.vhd

@@ -0,0 +1,121 @@
+--------------------------------------------------------------
+ --     Copyright (c) 2012-2023 Anlogic Inc.
+ --  All Right Reserved.
+--------------------------------------------------------------
+ -- Log	:	This file is generated by Anlogic IP Generator.
+ -- File	:	D:/user/project/mini_demo_case/EF2L45BG256B/demo/demo9_test_lvds/user_source/ip_source/lvds_pll.vhd
+ -- Date	:	2023 03 30
+ -- TD version	:	5.6.71036
+--------------------------------------------------------------
+
+-------------------------------------------------------------------------------
+--	Input frequency:             25.000MHz
+--	Clock multiplication factor: 3
+--	Clock division factor:       1
+--	Clock information:
+--		Clock name	| Frequency 	| Phase shift
+--		C0        	| 75.000000 MHZ	| 0  DEG     
+--		C1        	| 300.000000MHZ	| 0  DEG     
+-------------------------------------------------------------------------------
+
+LIBRARY ieee;
+USE ieee.std_logic_1164.ALL;
+USE ieee.numeric_std.ALL;
+USE ieee.std_logic_unsigned.ALL;
+USE ieee.std_logic_arith.ALL;
+LIBRARY ef2_macro;
+USE ef2_macro.EF2_COMPONENTS.ALL;
+
+ENTITY lvds_pll IS
+  PORT (
+    refclk : IN STD_LOGIC;
+    reset : IN STD_LOGIC;
+    extlock : OUT STD_LOGIC;
+    clk0_out : OUT STD_LOGIC;
+    clk1_out : OUT STD_LOGIC 
+  );
+END lvds_pll;
+
+ARCHITECTURE rtl OF lvds_pll IS
+  SIGNAL clk0_buf :  STD_LOGIC;
+  SIGNAL fbk_wire :  STD_LOGIC;
+  SIGNAL clkc_wire :  STD_LOGIC_VECTOR (6 DOWNTO 0);
+BEGIN
+  bufg_feedback : EF2_LOGIC_BUFG
+  PORT MAP (
+    i => clk0_buf,
+    o => fbk_wire 
+  );
+
+  pll_inst : EF2_PHY_PLL
+  GENERIC MAP (
+    DPHASE_SOURCE => "DISABLE",
+    DYNCFG => "DISABLE",
+    FIN => "25.000",
+    FEEDBK_MODE => "NORMAL",
+    FEEDBK_PATH => "CLKC0_EXT",
+    STDBY_ENABLE => "DISABLE",
+    PLLRST_ENA => "ENABLE",
+    SYNC_ENABLE => "DISABLE",
+    GMC_GAIN => 2,
+    ICP_CURRENT => 9,
+    KVCO => 2,
+    LPF_CAPACITOR => 1,
+    LPF_RESISTOR => 8,
+    REFCLK_DIV => 1,
+    FBCLK_DIV => 3,
+    CLKC0_ENABLE => "ENABLE",
+    CLKC0_DIV => 12,
+    CLKC0_CPHASE => 11,
+    CLKC0_FPHASE => 0,
+    CLKC1_ENABLE => "ENABLE",
+    CLKC1_DIV => 3,
+    CLKC1_CPHASE => 2,
+    CLKC1_FPHASE => 0,
+    PU_INTP => "DISABLE",
+    INTPI => 0,
+    HIGH_SPEED_EN => "DISABLE",
+    SSC_ENABLE => "DISABLE",
+    SSC_MODE => "Down",
+    SSC_AMP => 0.0000,
+    SSC_FREQ_DIV => 0,
+    SSC_RNGE => 0,
+    FREQ_OFFSET => 0.0000,
+    OFFSET_MODE => "EXT",
+    FREQ_OFFSET_INT => 0,
+    CLKC0_DUTY => 0.5000,
+    CLKC0_DUTY_INT => 6,
+    CLKC0_DUTY50 => "ENABLE",
+    CLKC1_DUTY => 0.5000,
+    CLKC1_DUTY_INT => 2,
+    CLKC1_DUTY50 => "ENABLE" 
+  )
+  PORT MAP (
+    refclk => refclk,
+    reset => reset,
+    stdby => '0',
+    extlock => extlock,
+    load_reg => '0',
+    psclk => '0',
+    psdown => '0',
+    psstep => '0',
+    psclksel => b"000",
+    dclk => '0',
+    dcs => '0',
+    dwe => '0',
+    di => b"00000000",
+    daddr => b"000000",
+    fbclk => fbk_wire,
+    clkc => clkc_wire,
+    ssc_en => '0',
+    frac_offset_valid => '0',
+    dsm_refclk => '0',
+    dsm_rst => reset 
+  );
+
+  clk0_out <= fbk_wire;
+  clk1_out <= clkc_wire(1);
+  clk0_buf <= clkc_wire(0);
+
+END rtl;
+

+ 55 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/ip_source/lvds_pll_rx.ipc

@@ -0,0 +1,55 @@
+<?xml version='1.0' encoding='utf-8'?>
+<PLLConfig version="1.0">
+    <GeneralConfig>
+        <Type>PLL</Type>
+        <Device>PH1A100GSG324</Device>
+        <create_VHDL>true</create_VHDL>
+    </GeneralConfig>
+    <Page1>
+        <speed_grade>Any</speed_grade>
+        <input_frequency>300.0000000000000000MHz</input_frequency>
+        <feedback_mode>Normal</feedback_mode>
+        <clk_num>CLKC0</clk_num>
+        <power_down_up>DISABLE</power_down_up>
+        <ssc_enable>DISABLE</ssc_enable>
+        <use_fre_modulation>DISABLE</use_fre_modulation>
+        <dynamicCPhase>DISABLE</dynamicCPhase>
+        <dynamicFPhase>DISABLE</dynamicFPhase>
+        <clock_reset>DISABLE</clock_reset>
+        <enable_reset>ENABLE</enable_reset>
+        <pll_lock>ENABLE</pll_lock>
+        <derive_pll_clocks>ENABLE</derive_pll_clocks>
+    </Page1>
+    <Page2>
+        <bandwidth_setting>Medium</bandwidth_setting>
+    </Page2>
+    <Page3>
+        <setting>frequncy_setting</setting>
+        <multiplication_factor>1</multiplication_factor>
+        <division_factor>4</division_factor>
+        <clocks>
+            <clock>
+                <id>0</id>
+                <clock_division_factor>12</clock_division_factor>
+                <clock_frequency>75.0000000000000000MHz</clock_frequency>
+                <phase_shift>0.0000000000000000deg</phase_shift>
+                <clkB>false</clkB>
+                <clkEN>false</clkEN>
+                <bufg_option>BUFG</bufg_option>
+            </clock>
+            <clock>
+                <id>1</id>
+                <clock_division_factor>3</clock_division_factor>
+                <clock_frequency>300.0000000000000000MHz</clock_frequency>
+                <phase_shift>0.0000000000000000deg</phase_shift>
+                <clkB>false</clkB>
+                <clkEN>false</clkEN>
+                <bufg_option>NONE</bufg_option>
+            </clock>
+        </clocks>
+    </Page3>
+    <GeneratedFiles>
+        <Verilog Enable="true">lvds_pll_rx.v</Verilog>
+        <VHDL Enable="false">lvds_pll_rx.vhd</VHDL>
+    </GeneratedFiles>
+</PLLConfig>

+ 120 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/ip_source/lvds_pll_rx.v

@@ -0,0 +1,120 @@
+/************************************************************\
+ **  Copyright (c) 2011-2022 Anlogic, Inc.
+ **  All Right Reserved.\
+\************************************************************/
+/************************************************************\
+ ** Log	:	This file is generated by Anlogic IP Generator.
+ ** File	:	D:/user/project/mini_demo_case/test_lvds/user_source/ip_source/lvds_pll_rx.v
+ ** Date	:	2023 01 30
+ ** TD version	:	5.6.53426
+\************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+//	Input frequency:             300.000MHz
+//	Clock multiplication factor: 1
+//	Clock division factor:       4
+//	Clock information:
+//		Clock name	| Frequency 	| Phase shift
+//		C0        	| 75.000000 MHZ	| 0  DEG     
+//		C1        	| 300.000000MHZ	| 0  DEG     
+///////////////////////////////////////////////////////////////////////////////
+`timescale 1 ns / 100 fs
+
+module lvds_pll_rx (
+  refclk,
+  reset,
+  lock,
+  clk0_out,
+  clk1_out 
+);
+
+  input refclk;
+  input reset;
+  output lock;
+  output clk0_out;
+  output clk1_out;
+
+  wire clk0_buf;
+
+  PH1_LOGIC_BUFG bufg_feedback (
+    .i(clk0_buf),
+    .o(clk0_out) 
+  );
+
+  PH1_PHY_PLL #(
+    .DYN_PHASE_PATH_SEL("DISABLE"),
+    .DYN_FPHASE_EN("DISABLE"),
+    .MPHASE_ENABLE("DISABLE"),
+    .FIN("300.000"),
+    .FEEDBK_MODE("NORMAL"),
+    .FBKCLK("CLKC0_EXT"),
+    .PLL_FEED_TYPE("EXTERNAL"),
+    .PLL_USR_RST("ENABLE"),
+    .DERIVE_PLL_CLOCKS("ENABLE"),
+    .GEN_BASIC_CLOCK("DISABLE"),
+    .GMC_GAIN(2),
+    .ICP_CUR(12),
+    .LPF_CAP(2),
+    .LPF_RES(2),
+    .REFCLK_DIV(4),
+    .FBCLK_DIV(1),
+    .CLKC0_ENABLE("ENABLE"),
+    .CLKC0_DIV(12),
+    .CLKC0_CPHASE(11),
+    .CLKC0_FPHASE(0),
+    .CLKC0_FPHASE_RSTSEL(0),
+    .CLKC0_DUTY_INT(6),
+    .CLKC0_DUTY50("ENABLE"),
+    .CLKC1_ENABLE("ENABLE"),
+    .CLKC1_DIV(3),
+    .CLKC1_CPHASE(2),
+    .CLKC1_FPHASE(0),
+    .CLKC1_FPHASE_RSTSEL(0),
+    .CLKC1_DUTY_INT(2),
+    .CLKC1_DUTY50("ENABLE"),
+    .INTPI(0),
+    .HIGH_SPEED_EN("DISABLE"),
+    .SSC_ENABLE("DISABLE"),
+    .SSC_MODE("CENTER"),
+    .SSC_AMP(0.0000),
+    .SSC_FREQ_DIV(0),
+    .SSC_RNGE(0),
+    .FRAC_ENABLE("DISABLE"),
+    .DITHER_ENABLE("DISABLE"),
+    .SDM_FRAC(0) 
+  ) pll_inst (
+    .refclk(refclk),
+    .pllreset(reset),
+    .lock(lock),
+    .pllpd(1'b0),
+    .refclk_rst(1'b0),
+    .wakeup(1'b0),
+    .psclk(1'b0),
+    .psdown(1'b0),
+    .psstep(1'b0),
+    .psclksel(3'b000),
+    .psdone(open),
+    .cps_step(2'b00),
+    .drp_clk(1'b0),
+    .drp_rstn(1'b1),
+    .drp_sel(1'b0),
+    .drp_rd(1'b0),
+    .drp_wr(1'b0),
+    .drp_addr(8'b00000000),
+    .drp_wdata(8'b00000000),
+    .drp_err(open),
+    .drp_rdy(open),
+    .drp_rdata({open, open, open, open, open, open, open, open}),
+    .fbclk(clk0_out),
+    .clkc({open, open, open, open, open, open, clk1_out, clk0_buf}),
+    .clkcb({open, open, open, open, open, open, open, open}),
+    .clkc_en({8'b00000011}),
+    .clkc_rst(2'b00),
+    .ext_freq_mod_clk(1'b0),
+    .ext_freq_mod_en(1'b0),
+    .ext_freq_mod_val(17'b00000000000000000),
+    .ssc_en(1'b0) 
+  );
+
+endmodule
+

+ 131 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/ip_source/lvds_pll_rx.vhd

@@ -0,0 +1,131 @@
+--------------------------------------------------------------
+ --  Copyright (c) 2011-2022 Anlogic, Inc.
+ --  All Right Reserved.
+--------------------------------------------------------------
+ -- Log	:	This file is generated by Anlogic IP Generator.
+ -- File	:	D:/user/project/mini_demo_case/test_lvds/user_source/ip_source/lvds_pll_rx.vhd
+ -- Date	:	2023 01 30
+ -- TD version	:	5.6.53426
+--------------------------------------------------------------
+
+-------------------------------------------------------------------------------
+--	Input frequency:             300.000MHz
+--	Clock multiplication factor: 1
+--	Clock division factor:       4
+--	Clock information:
+--		Clock name	| Frequency 	| Phase shift
+--		C0        	| 75.000000 MHZ	| 0  DEG     
+--		C1        	| 300.000000MHZ	| 0  DEG     
+-------------------------------------------------------------------------------
+
+LIBRARY ieee;
+USE ieee.std_logic_1164.ALL;
+USE ieee.numeric_std.ALL;
+USE ieee.std_logic_unsigned.ALL;
+USE ieee.std_logic_arith.ALL;
+LIBRARY ph1_macro;
+USE ph1_macro.PH1_COMPONENTS.ALL;
+
+ENTITY lvds_pll_rx IS
+  PORT (
+    refclk : IN STD_LOGIC;
+    reset : IN STD_LOGIC;
+    lock : OUT STD_LOGIC;
+    clk0_out : OUT STD_LOGIC;
+    clk1_out : OUT STD_LOGIC 
+  );
+END lvds_pll_rx;
+
+ARCHITECTURE rtl OF lvds_pll_rx IS
+  SIGNAL clk0_buf :  STD_LOGIC;
+  SIGNAL fbk_wire :  STD_LOGIC;
+  SIGNAL clkc_en_wire :  STD_LOGIC_VECTOR (7 DOWNTO 0);
+  SIGNAL clkc_wire :  STD_LOGIC_VECTOR (7 DOWNTO 0);
+  SIGNAL clkcb_wire :  STD_LOGIC_VECTOR (7 DOWNTO 0);
+BEGIN
+  bufg_feedback : PH1_LOGIC_BUFG
+  PORT MAP (
+    i => clk0_buf,
+    o => fbk_wire 
+  );
+
+  pll_inst : PH1_PHY_PLL
+  GENERIC MAP (
+    DYN_PHASE_PATH_SEL => "DISABLE",
+    DYN_FPHASE_EN => "DISABLE",
+    MPHASE_ENABLE => "DISABLE",
+    FIN => "300.000",
+    FEEDBK_MODE => "NORMAL",
+    FBKCLK => "CLKC0_EXT",
+    PLL_FEED_TYPE => "EXTERNAL",
+    PLL_USR_RST => "ENABLE",
+    DERIVE_PLL_CLOCKS => "ENABLE",
+    GEN_BASIC_CLOCK => "DISABLE",
+    GMC_GAIN => 2,
+    ICP_CUR => 12,
+    LPF_CAP => 2,
+    LPF_RES => 2,
+    REFCLK_DIV => 4,
+    FBCLK_DIV => 1,
+    CLKC0_ENABLE => "ENABLE",
+    CLKC0_DIV => 12,
+    CLKC0_CPHASE => 11,
+    CLKC0_FPHASE => 0,
+    CLKC0_FPHASE_RSTSEL => 0,
+    CLKC0_DUTY_INT => 6,
+    CLKC0_DUTY50 => "ENABLE",
+    CLKC1_ENABLE => "ENABLE",
+    CLKC1_DIV => 3,
+    CLKC1_CPHASE => 2,
+    CLKC1_FPHASE => 0,
+    CLKC1_FPHASE_RSTSEL => 0,
+    CLKC1_DUTY_INT => 2,
+    CLKC1_DUTY50 => "ENABLE",
+    INTPI => 0,
+    HIGH_SPEED_EN => "DISABLE",
+    SSC_ENABLE => "DISABLE",
+    SSC_MODE => "CENTER",
+    SSC_AMP => 0.0000,
+    SSC_FREQ_DIV => 0,
+    SSC_RNGE => 0,
+    FRAC_ENABLE => "DISABLE",
+    DITHER_ENABLE => "DISABLE",
+    SDM_FRAC => 0 
+  )
+  PORT MAP (
+    refclk => refclk,
+    pllreset => reset,
+    lock => lock,
+    pllpd => '0',
+    refclk_rst => '0',
+    wakeup => '0',
+    psclk => '0',
+    psdown => '0',
+    psstep => '0',
+    psclksel => b"000",
+    cps_step => b"00",
+    drp_clk => '0',
+    drp_rstn => '1',
+    drp_sel => '0',
+    drp_rd => '0',
+    drp_wr => '0',
+    drp_addr => b"00000000",
+    drp_wdata => b"00000000",
+    fbclk => fbk_wire,
+    clkc => clkc_wire,
+    clkcb => clkcb_wire,
+    clkc_en => clkc_en_wire,
+    clkc_rst => b"00",
+    ext_freq_mod_clk => '0',
+    ext_freq_mod_en => '0',
+    ext_freq_mod_val => b"00000000000000000",
+    ssc_en => '0' 
+  );
+
+  clk0_out <= fbk_wire;
+  clkc_en_wire <= b"00000011";
+  clk1_out <= clkc_wire(1);
+  clk0_buf <= clkc_wire(0);
+
+END rtl;
+

workspace/cpld_temperature_control_board/td_project/al_ip/UART_0/RTL/include/define.v → reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/sim_source/.lvds_bak.cwc


Разница между файлами не показана из-за своего большого размера
+ 55 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0 demo应用例程/demo9_test_lvds/demo9_test_lvds/user_source/sim_source/lvds.cwc


BIN
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0原理图/EF2L45BG256B_MINI_V2.0 DEMO板源文件/EF2L45BG256B_MINI_V2.0.DSN


BIN
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0原理图/EF2L45BG256B_MINI_V2.0 DEMO板源文件/EF2L45BG256B_MINI_V2.0.brd


BIN
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0原理图/EF2L45BG256B_MINI_V2.0dsn.pdf


Разница между файлами не показана из-за своего большого размера
+ 2555 - 0
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0原理图/EF2L45BG256B_MINI_V2.0丝印.pdf


BIN
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0板文档/TN426_安路科技EF2L45BG256B_MINI板应用例程使用指南.pdf


BIN
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256B_MINI_V2.0板文档/TN427_安路科技EF2L45BG256B_MINI板硬件使用指南.pdf


BIN
reference/original/board/EF2L45BG256B_MINI_V2.0/EF2L45BG256M_MINI_DEV3.pdf


Разница между файлами не показана из-за своего большого размера
+ 21 - 0
reference/original/diagrams/上位机逻辑.svg


Разница между файлами не показана из-за своего большого размера
+ 21 - 0
reference/original/diagrams/接长鑫水滴系统.svg


BIN
reference/original/schematics/FCB_FPGA+MCU0611.pdf


+ 38 - 0
schemas/bmc_uart_protocol_receipt.schema.json

@@ -0,0 +1,38 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "bmc_uart_protocol_receipt.schema.json",
+  "title": "BMC UART protocol offline receipt",
+  "type": "object",
+  "required": ["schema", "status", "scenario", "counterparty", "parser", "safety", "authority_boundary"],
+  "properties": {
+    "schema": { "const": "bmc-uart-protocol-receipt-v1" },
+    "status": { "type": "string" },
+    "scenario": { "type": "string" },
+    "counterparty": { "enum": ["pc_emulator", "real_bmc"] },
+    "parser": {
+      "type": "object",
+      "required": ["status", "sample_count", "missing_mask", "raw_token_count", "rejected_echo_windows"],
+      "properties": {
+        "status": { "type": "string" },
+        "sample_count": { "type": "integer", "minimum": 0 },
+        "missing_mask": { "type": "integer", "minimum": 0 },
+        "raw_token_count": { "type": "integer", "minimum": 0 },
+        "selected_window_start": { "type": "integer" },
+        "rejected_echo_windows": { "type": "integer", "minimum": 0 }
+      },
+      "additionalProperties": true
+    },
+    "safety": {
+      "type": "object",
+      "required": ["flash_attempted", "real_ptc_fan_bmc_action_attempted", "driver_install_attempted"],
+      "properties": {
+        "flash_attempted": { "const": false },
+        "real_ptc_fan_bmc_action_attempted": { "const": false },
+        "driver_install_attempted": { "const": false }
+      },
+      "additionalProperties": true
+    },
+    "authority_boundary": { "type": "string" }
+  },
+  "additionalProperties": true
+}

+ 53 - 0
schemas/cpld_bmc_acceptance_v1_receipt.schema.json

@@ -0,0 +1,53 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "cpld_bmc_acceptance_v1_receipt.schema.json",
+  "title": "CPLD BMC acceptance v1 receipt",
+  "type": "object",
+  "required": ["schema", "status", "layers", "authority_boundary"],
+  "properties": {
+    "schema": { "const": "cpld-bmc-acceptance-v1-receipt-v1" },
+    "status": { "const": "pass" },
+    "layers": {
+      "type": "object",
+      "required": ["final_gate_v2", "real_bmc_j6_windows_gate_v2"],
+      "properties": {
+        "final_gate_v2": {
+          "type": "object",
+          "required": ["status", "receipt"],
+          "properties": {
+            "status": { "const": "pass" },
+            "receipt": { "$ref": "#/$defs/artifact" }
+          },
+          "additionalProperties": true
+        },
+        "real_bmc_j6_windows_gate_v2": {
+          "type": "object",
+          "required": ["status", "receipt"],
+          "properties": {
+            "status": { "const": "pass" },
+            "receipt": { "$ref": "#/$defs/artifact" }
+          },
+          "additionalProperties": true
+        }
+      },
+      "additionalProperties": false
+    },
+    "authority_boundary": { "type": "string", "minLength": 1 }
+  },
+  "additionalProperties": true,
+  "$defs": {
+    "artifact": {
+      "type": "object",
+      "required": ["path", "sha256"],
+      "properties": {
+        "path": { "type": "string", "minLength": 1 },
+        "sha256": { "$ref": "#/$defs/sha256" }
+      },
+      "additionalProperties": true
+    },
+    "sha256": {
+      "type": "string",
+      "pattern": "^[0-9a-fA-F]{64}$"
+    }
+  }
+}

+ 72 - 0
schemas/final_gate_v2_receipt.schema.json

@@ -0,0 +1,72 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "final_gate_v2_receipt.schema.json",
+  "title": "Final gate v2 receipt",
+  "type": "object",
+  "required": ["schema", "status", "layers", "authority_boundary"],
+  "properties": {
+    "schema": { "const": "final-gate-v2-receipt-v1" },
+    "status": { "const": "pass" },
+    "layers": {
+      "type": "object",
+      "required": ["static", "model", "replay", "rtl_sim", "formal", "detector_selftest", "td_build", "uart_strict"],
+      "properties": {
+        "static": {
+          "type": "object",
+          "required": ["status"],
+          "properties": { "status": { "const": "pass" } },
+          "additionalProperties": true
+        },
+        "model": {
+          "type": "object",
+          "required": ["status"],
+          "properties": { "status": { "const": "pass" } },
+          "additionalProperties": true
+        },
+        "replay": {
+          "type": "object",
+          "required": ["status"],
+          "properties": { "status": { "const": "pass" } },
+          "additionalProperties": true
+        },
+        "rtl_sim": {
+          "type": "object",
+          "required": ["status"],
+          "properties": { "status": { "const": "pass" } },
+          "additionalProperties": true
+        },
+        "formal": {
+          "type": "object",
+          "required": ["status"],
+          "properties": { "status": { "const": "pass" } },
+          "additionalProperties": true
+        },
+        "detector_selftest": {
+          "type": "object",
+          "required": ["status"],
+          "properties": { "status": { "const": "pass" } },
+          "additionalProperties": true
+        },
+        "td_build": {
+          "type": "object",
+          "required": ["status"],
+          "properties": { "status": { "const": "pass" } },
+          "additionalProperties": true
+        },
+        "uart_strict": {
+          "type": "object",
+          "required": ["status"],
+          "properties": { "status": { "const": "pass" } },
+          "additionalProperties": true
+        }
+      },
+      "additionalProperties": false,
+      "$comment": "ChipWatcher and all other undeclared layers are intentionally rejected by schema and validator.",
+      "not": {
+        "required": ["chipwatcher"]
+      }
+    },
+    "authority_boundary": { "type": "string" }
+  },
+  "additionalProperties": true
+}

+ 88 - 0
schemas/j6_host_sensor_real_fan_ptc_debug921_pin_conflict_blocked_manifest.schema.json

@@ -0,0 +1,88 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "j6_host_sensor_real_fan_ptc_debug921_pin_conflict_blocked_manifest.schema.json",
+  "type": "object",
+  "required": [
+    "schema",
+    "status",
+    "generated_at",
+    "authority_boundary",
+    "required_remote_action",
+    "programming_mode",
+    "user_flow",
+    "blocked_reason",
+    "pin_inventory",
+    "pin_conflicts",
+    "non_executable_reference",
+    "remote_dependencies",
+    "sha256_inventory_policy"
+  ],
+  "properties": {
+    "schema": {
+      "const": "j6-host-sensor-real-fan-ptc-debug921-pin-conflict-blocked-package-manifest-v1"
+    },
+    "status": {
+      "const": "blocked_pin_conflict_with_locked_debug_uart"
+    },
+    "generated_at": {
+      "type": "string",
+      "minLength": 1
+    },
+    "authority_boundary": {
+      "type": "string",
+      "minLength": 1
+    },
+    "required_remote_action": {
+      "type": "string",
+      "pattern": "Do not program SRAM"
+    },
+    "programming_mode": {
+      "const": "not_applicable"
+    },
+    "user_flow": {
+      "type": "string",
+      "minLength": 1
+    },
+    "blocked_reason": {
+      "type": "string",
+      "minLength": 1
+    },
+    "pin_inventory": {
+      "type": "object",
+      "required": ["path", "sha256"],
+      "properties": {
+        "path": {
+          "const": "config/pin_inventory.fcb_fpga_mcu0611.json"
+        },
+        "sha256": {
+          "type": "string",
+          "pattern": "^[0-9a-f]{64}$"
+        }
+      }
+    },
+    "pin_conflicts": {
+      "type": "array",
+      "minItems": 6
+    },
+    "non_executable_reference": {
+      "type": "object",
+      "required": ["future_expected_host_control_commands"],
+      "properties": {
+        "future_expected_host_control_commands": {
+          "type": "array",
+          "minItems": 1,
+          "items": {
+            "type": "string"
+          }
+        }
+      }
+    },
+    "remote_dependencies": {
+      "const": "None for this blocked package."
+    },
+    "sha256_inventory_policy": {
+      "type": "string",
+      "pattern": "self-referential"
+    }
+  }
+}

+ 59 - 0
schemas/j6_host_sensor_real_fan_ptc_debug921_pin_conflict_blocked_package.schema.json

@@ -0,0 +1,59 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "j6_host_sensor_real_fan_ptc_debug921_pin_conflict_blocked_package.schema.json",
+  "type": "object",
+  "required": ["schema", "status", "generated_at", "reason", "td_bitstream", "pin_map", "real_fan_ptc_hardware_status", "non_executable_reference", "authority_boundary"],
+  "properties": {
+    "schema": { "const": "j6-host-sensor-real-fan-ptc-debug921-pin-conflict-blocked-package-v1" },
+    "status": { "const": "blocked_pin_conflict_with_locked_debug_uart" },
+    "generated_at": { "type": "string", "minLength": 1 },
+    "reason": { "type": "string", "minLength": 1 },
+    "td_bitstream": {
+      "type": "object",
+      "required": ["status", "top", "top_module", "bitstream", "reason"],
+      "properties": {
+        "status": { "const": "blocked_pin_conflict_with_locked_debug_uart" },
+        "top": { "const": "uart_rs232_j6_host_sensor_real_fan_ptc_debug921_primary" },
+        "top_module": { "const": "uart_rs232_j6_host_sensor_real_fan_ptc_debug921_top" },
+        "bitstream": { "type": "null" },
+        "reason": { "type": "string", "minLength": 1 }
+      }
+    },
+    "pin_map": {
+      "type": "object",
+      "required": ["status", "ptc_count", "fan_count", "fan_fg_count", "fan_install_count", "physical_balls_verified", "usable_with_locked_debug_uart", "inventory", "conflicts"],
+      "properties": {
+        "status": { "const": "blocked_pin_conflict_with_locked_debug_uart" },
+        "ptc_count": { "const": 24 },
+        "fan_count": { "const": 4 },
+        "fan_fg_count": { "const": 8 },
+        "fan_install_count": { "const": 4 },
+        "physical_balls_verified": { "const": true },
+        "usable_with_locked_debug_uart": { "const": false },
+        "inventory": { "const": "config/pin_inventory.fcb_fpga_mcu0611.json" },
+        "conflicts": { "type": "array", "minItems": 1 }
+      }
+    },
+    "real_fan_ptc_hardware_status": {
+      "type": "object",
+      "required": ["status", "real_fan_ptc_hardware_present", "qualifies_final_gate"],
+      "properties": {
+        "status": { "const": "not_run" },
+        "real_fan_ptc_hardware_present": { "const": false },
+        "qualifies_final_gate": { "const": false }
+      }
+    },
+    "non_executable_reference": {
+      "type": "object",
+      "required": ["future_expected_host_control_commands"],
+      "properties": {
+        "future_expected_host_control_commands": {
+          "type": "array",
+          "items": { "type": "string" },
+          "minItems": 1
+        }
+      }
+    },
+    "authority_boundary": { "type": "string", "minLength": 1 }
+  }
+}

+ 49 - 0
schemas/j6_host_sensor_real_fan_ptc_debug921_pin_conflict_blocked_sha256_inventory.schema.json

@@ -0,0 +1,49 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "j6_host_sensor_real_fan_ptc_debug921_pin_conflict_blocked_sha256_inventory.schema.json",
+  "type": "object",
+  "required": ["schema", "generated_at", "self_hash_policy", "inventory"],
+  "properties": {
+    "schema": {
+      "const": "j6-host-sensor-real-fan-ptc-debug921-pin-conflict-blocked-package-sha256-inventory-v1"
+    },
+    "generated_at": {
+      "type": "string",
+      "minLength": 1
+    },
+    "self_hash_policy": {
+      "const": "excluded_self_referential_file"
+    },
+    "inventory": {
+      "type": "array",
+      "minItems": 1,
+      "items": {
+        "type": "object",
+        "required": ["path", "sha256", "bytes"],
+        "properties": {
+          "path": {
+            "type": "string",
+            "minLength": 1
+          },
+          "sha256": {
+            "type": "string",
+            "pattern": "^[0-9a-f]{64}$"
+          },
+          "bytes": {
+            "type": "integer",
+            "minimum": 0
+          }
+        }
+      },
+      "contains": {
+        "type": "object",
+        "required": ["path"],
+        "properties": {
+          "path": {
+            "const": "manifest.json"
+          }
+        }
+      }
+    }
+  }
+}

+ 292 - 0
schemas/offline_fidelity_gate_v1_receipt.schema.json

@@ -0,0 +1,292 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "offline_fidelity_gate_v1_receipt.schema.json",
+  "title": "Offline fidelity gate v1 receipt",
+  "type": "object",
+  "required": ["schema", "status", "generated_at", "toolchain", "layers", "coverage_matrix", "safety", "authority_boundary"],
+  "properties": {
+    "schema": { "const": "offline-fidelity-gate-v1-receipt-v1" },
+    "status": { "const": "pass" },
+    "generated_at": { "type": "string" },
+    "toolchain": {
+      "type": "object",
+      "required": ["status", "toolchain", "manifest", "cleanup_policy", "safety", "authority_boundary"],
+      "properties": {
+        "status": { "const": "pass" },
+        "toolchain": {
+          "type": "object",
+          "required": ["status", "tools"],
+          "properties": {
+            "status": { "const": "pass" },
+            "tools": {
+              "type": "object",
+              "required": ["python", "iverilog", "vvp", "verilator", "yosys", "sby", "cocotb", "td_cli"]
+            }
+          },
+          "additionalProperties": true
+        },
+        "manifest": {
+          "type": "object",
+          "required": ["install_roots", "tools", "cleanup_plan", "safety"],
+          "properties": {
+            "install_roots": { "type": "object", "minProperties": 1 },
+            "tools": { "type": "array", "minItems": 8 },
+            "cleanup_plan": {
+              "type": "object",
+              "required": ["default", "requires_owner_marker", "allowed_root"],
+              "properties": {
+                "default": { "const": "dry_run" },
+                "requires_owner_marker": { "const": true },
+                "allowed_root": { "type": "string", "minLength": 1 }
+              },
+              "additionalProperties": true
+            }
+          },
+          "additionalProperties": true
+        },
+        "cleanup_policy": {
+          "type": "object",
+          "required": ["default", "requires_owner_marker", "allowed_root"],
+          "properties": {
+            "default": { "const": "dry_run" },
+            "requires_owner_marker": { "const": true },
+            "allowed_root": { "type": "string", "minLength": 1 }
+          },
+          "additionalProperties": true
+        },
+        "safety": {
+          "type": "object",
+          "required": ["opens_com_ports", "toggles_dtr_rts", "installs_drivers", "programs_flash", "touches_ptc_fan_bmc"],
+          "properties": {
+            "opens_com_ports": { "const": false },
+            "toggles_dtr_rts": { "const": false },
+            "installs_drivers": { "const": false },
+            "programs_flash": { "const": false },
+            "touches_ptc_fan_bmc": { "const": false }
+          },
+          "additionalProperties": true
+        },
+        "authority_boundary": { "type": "string" }
+      },
+      "additionalProperties": true
+    },
+    "layers": {
+      "type": "object",
+      "required": [
+        "static",
+        "model",
+        "replay",
+        "protocol_fuzz",
+        "hdl_sim",
+        "cocotb_virtual_lab",
+        "virtual_driver_lab",
+        "formal",
+        "detector_selftest",
+        "mutation",
+        "thermal_digital_twin",
+        "coverage_matrix",
+        "td_build",
+        "debug_bundle"
+      ],
+      "properties": {
+        "static": { "$ref": "#/$defs/staticLayer" },
+        "model": { "$ref": "#/$defs/modelLayer" },
+        "replay": { "$ref": "#/$defs/passLayer" },
+        "protocol_fuzz": { "$ref": "#/$defs/scenarioLayer" },
+        "hdl_sim": { "$ref": "#/$defs/hdlLayer" },
+        "cocotb_virtual_lab": { "$ref": "#/$defs/cocotbLayer" },
+        "virtual_driver_lab": { "$ref": "#/$defs/virtualDriverLayer" },
+        "formal": { "$ref": "#/$defs/formalLayer" },
+        "detector_selftest": { "$ref": "#/$defs/detectorLayer" },
+        "mutation": { "$ref": "#/$defs/mutationLayer" },
+        "thermal_digital_twin": { "$ref": "#/$defs/thermalLayer" },
+        "coverage_matrix": { "$ref": "#/$defs/coverageLayer" },
+        "td_build": { "$ref": "#/$defs/tdLayer" },
+        "debug_bundle": { "$ref": "#/$defs/debugBundleLayer" }
+      },
+      "additionalProperties": false,
+      "$comment": "hardware, board, uart_strict, chipwatcher, thermal_performance_pass, and any undeclared layer are rejected."
+    },
+    "coverage_matrix": { "$ref": "#/$defs/passLayer" },
+    "safety": {
+      "type": "object",
+      "required": ["opens_com_ports", "toggles_dtr_rts", "programs_flash", "installs_drivers", "real_ptc_fan_bmc_action_attempted"],
+      "properties": {
+        "opens_com_ports": { "const": false },
+        "toggles_dtr_rts": { "const": false },
+        "programs_flash": { "const": false },
+        "installs_drivers": { "const": false },
+        "real_ptc_fan_bmc_action_attempted": { "const": false }
+      },
+      "additionalProperties": true
+    },
+    "authority_boundary": {
+      "type": "string",
+      "not": {
+        "anyOf": [
+          { "pattern": "thermal_performance_pass" },
+          { "pattern": "thermal performance pass" },
+          { "pattern": "hardware pass" },
+          { "pattern": "board pass" },
+          { "pattern": "uart_strict pass" },
+          { "pattern": "chipwatcher pass" }
+        ]
+      }
+    }
+  },
+  "not": {
+    "anyOf": [
+      { "required": ["hardware"] },
+      { "required": ["board"] },
+      { "required": ["uart_strict"] },
+      { "required": ["chipwatcher"] },
+      { "required": ["thermal_performance_pass"] }
+    ]
+  },
+  "additionalProperties": true,
+  "$defs": {
+    "passLayer": {
+      "type": "object",
+      "required": ["status"],
+      "properties": { "status": { "const": "pass" } },
+      "additionalProperties": true
+    },
+    "staticLayer": {
+      "allOf": [{ "$ref": "#/$defs/passLayer" }],
+      "required": ["status", "returncode"]
+    },
+    "modelLayer": {
+      "allOf": [{ "$ref": "#/$defs/passLayer" }],
+      "required": ["status", "tests"]
+    },
+    "scenarioLayer": {
+      "allOf": [{ "$ref": "#/$defs/passLayer" }],
+      "required": ["status", "scenarios"]
+    },
+    "hdlLayer": {
+      "allOf": [{ "$ref": "#/$defs/passLayer" }],
+      "anyOf": [{ "required": ["tests"] }, { "required": ["backend_results"] }]
+    },
+    "cocotbLayer": {
+      "allOf": [{ "$ref": "#/$defs/passLayer" }],
+      "required": ["status", "sim"]
+    },
+    "formalLayer": {
+      "allOf": [{ "$ref": "#/$defs/passLayer" }],
+      "required": ["status", "targets"]
+    },
+    "detectorLayer": {
+      "allOf": [{ "$ref": "#/$defs/passLayer" }],
+      "required": ["status", "results"]
+    },
+    "virtualDriverLayer": {
+      "allOf": [{ "$ref": "#/$defs/passLayer" }],
+      "required": ["status", "user_mode_shims", "fault_contracts", "trace_hash"],
+      "properties": {
+        "user_mode_shims": {
+          "type": "array",
+          "minItems": 6,
+          "allOf": [
+            { "contains": { "type": "object", "properties": { "name": { "const": "pyserial_loopback_url" }, "status": { "const": "pass" } }, "required": ["name", "status", "transcript"] } },
+            { "contains": { "type": "object", "properties": { "name": { "const": "socket_pipe_transport" }, "status": { "const": "pass" } }, "required": ["name", "status", "transcript"] } },
+            { "contains": { "type": "object", "properties": { "name": { "const": "bmc_text_driver" }, "status": { "const": "pass" } }, "required": ["name", "status", "transcript"] } },
+            { "contains": { "type": "object", "properties": { "name": { "const": "host_register_plane" }, "status": { "const": "pass" } }, "required": ["name", "status", "transcript"] } },
+            { "contains": { "type": "object", "properties": { "name": { "const": "debug_uart_decoder" }, "status": { "const": "pass" } }, "required": ["name", "status", "transcript"] } },
+            { "contains": { "type": "object", "properties": { "name": { "const": "fault_injection_facade" }, "status": { "const": "pass" } }, "required": ["name", "status", "transcript"] } }
+          ]
+        },
+        "fault_contracts": {
+          "type": "array",
+          "minItems": 8,
+          "allOf": [
+            { "contains": { "const": "timeout" } },
+            { "contains": { "const": "disconnect" } },
+            { "contains": { "const": "partial_read" } },
+            { "contains": { "const": "partial_write" } },
+            { "contains": { "const": "permission_denied" } },
+            { "contains": { "const": "buffer_overflow" } },
+            { "contains": { "const": "tx_backpressure" } },
+            { "contains": { "const": "rx_overflow" } }
+          ]
+        },
+        "trace_hash": { "type": "string", "pattern": "^[0-9a-fA-F]{64}$" }
+      },
+      "additionalProperties": true
+    },
+    "mutationLayer": {
+      "allOf": [{ "$ref": "#/$defs/passLayer" }],
+      "required": ["status", "mutants"],
+      "properties": {
+        "mutants": {
+          "type": "array",
+          "minItems": 6,
+          "items": {
+            "type": "object",
+            "required": ["name", "status", "mutation_status", "artifact_sha256"],
+            "properties": {
+              "status": { "const": "pass" },
+              "mutation_status": { "const": "killed" },
+              "artifact_sha256": { "type": "string", "pattern": "^[0-9a-fA-F]{64}$" }
+            },
+            "additionalProperties": true
+          }
+        }
+      },
+      "additionalProperties": true
+    },
+    "thermalLayer": {
+      "allOf": [{ "$ref": "#/$defs/passLayer" }],
+      "required": ["status", "models"],
+      "properties": {
+        "models": {
+          "type": "array",
+          "minItems": 7,
+          "items": {
+            "type": "object",
+            "required": ["name", "status", "trace_hash"],
+            "properties": {
+              "status": { "const": "pass" },
+              "trace_hash": { "type": "string", "pattern": "^[0-9a-fA-F]{64}$" },
+              "violations": { "type": "array", "maxItems": 0 }
+            },
+            "additionalProperties": true
+          }
+        }
+      },
+      "additionalProperties": true
+    },
+    "coverageLayer": {
+      "allOf": [{ "$ref": "#/$defs/passLayer" }],
+      "required": ["status", "items"],
+      "properties": {
+        "items": {
+          "type": "array",
+          "minItems": 12,
+          "allOf": [
+            { "contains": { "type": "object", "properties": { "category": { "const": "protocol" }, "status": { "const": "pass" } }, "required": ["category", "status", "covered_by"] } },
+            { "contains": { "type": "object", "properties": { "category": { "const": "uart_bit" }, "status": { "const": "pass" } }, "required": ["category", "status", "covered_by"] } },
+            { "contains": { "type": "object", "properties": { "category": { "const": "control" }, "status": { "const": "pass" } }, "required": ["category", "status", "covered_by"] } },
+            { "contains": { "type": "object", "properties": { "category": { "const": "safety" }, "status": { "const": "pass" } }, "required": ["category", "status", "covered_by"] } },
+            { "contains": { "type": "object", "properties": { "category": { "const": "debug" }, "status": { "const": "pass" } }, "required": ["category", "status", "covered_by"] } },
+            { "contains": { "type": "object", "properties": { "category": { "const": "virtual_driver_lab" }, "status": { "const": "pass" } }, "required": ["category", "status", "covered_by"] } },
+            { "contains": { "type": "object", "properties": { "category": { "const": "thermal" }, "status": { "const": "pass" } }, "required": ["category", "status", "covered_by"] } },
+            { "contains": { "type": "object", "properties": { "category": { "const": "fault_injection" }, "status": { "const": "pass" } }, "required": ["category", "status", "covered_by"] } },
+            { "contains": { "type": "object", "properties": { "category": { "const": "cocotb_virtual_lab" }, "status": { "const": "pass" } }, "required": ["category", "status", "covered_by"] } },
+            { "contains": { "type": "object", "properties": { "category": { "const": "formal" }, "status": { "const": "pass" } }, "required": ["category", "status", "covered_by"] } },
+            { "contains": { "type": "object", "properties": { "category": { "const": "mutation" }, "status": { "const": "pass" } }, "required": ["category", "status", "covered_by"] } },
+            { "contains": { "type": "object", "properties": { "category": { "const": "td_toolchain" }, "status": { "const": "pass" } }, "required": ["category", "status", "covered_by"] } }
+          ]
+        }
+      },
+      "additionalProperties": true
+    },
+    "tdLayer": {
+      "allOf": [{ "$ref": "#/$defs/passLayer" }],
+      "required": ["status", "elaboration"]
+    },
+    "debugBundleLayer": {
+      "allOf": [{ "$ref": "#/$defs/passLayer" }],
+      "anyOf": [{ "required": ["path"] }, { "required": ["bundle_dir"] }]
+    }
+  }
+}

+ 236 - 0
schemas/real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt.schema.json

@@ -0,0 +1,236 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "real_bmc_j6_host_sensor_real_fan_ptc_debug921_v1_receipt.schema.json",
+  "type": "object",
+  "required": ["schema", "status", "counterparty", "diagnostic_scope", "programming", "collector", "layers", "safety"],
+  "properties": {
+    "schema": { "const": "real-bmc-j6-host-sensor-real-fan-ptc-debug921-v1-receipt-v1" },
+    "status": { "type": "string" },
+    "counterparty": { "const": "real_bmc" },
+    "diagnostic_scope": { "const": "host_sensor_real_fan_ptc_debug921" },
+    "programming": {
+      "type": "object",
+      "required": ["mode", "manual_programming", "bitstream"],
+      "properties": {
+        "mode": { "const": "PROGRAM_SRAM" },
+        "manual_programming": { "const": true },
+        "bitstream": { "$ref": "#/$defs/artifact" }
+      }
+    },
+    "collector": {
+      "type": "object",
+      "required": ["host_port", "debug_port", "baud", "debug_baud", "format", "host_port_writes_to_serial", "debug_port_writes_to_serial", "opens_unknown_com_ports", "enumerates_com_ports"],
+      "properties": {
+        "host_port": { "const": "COM8" },
+        "debug_port": { "const": "COM7" },
+        "baud": { "const": 115200 },
+        "debug_baud": { "const": 921600 },
+        "format": { "const": "8N1" },
+        "host_port_writes_to_serial": { "const": true },
+        "debug_port_writes_to_serial": { "const": false },
+        "opens_unknown_com_ports": { "const": false },
+        "enumerates_com_ports": { "const": false }
+      }
+    },
+    "layers": {
+      "type": "object",
+      "required": [
+        "td_bitstream",
+        "manual_sram_programming",
+        "host_command_sequence",
+        "host_control_transcript",
+        "host_sensor_reports",
+        "debug_frame_capture",
+        "bmc_raw_sampling",
+        "pid_boundary",
+        "timeout_evidence",
+        "pin_map",
+        "safety_contract",
+        "real_fan_ptc_hardware_status",
+        "artifact_hashes"
+      ],
+      "properties": {
+        "td_bitstream": {
+          "type": "object",
+          "required": ["status", "receipt"],
+          "properties": { "status": { "type": "string" }, "receipt": { "$ref": "#/$defs/artifact" } }
+        },
+        "manual_sram_programming": {
+          "type": "object",
+          "required": ["status", "mode", "manual_programming", "attestation"],
+          "properties": {
+            "status": { "type": "string" },
+            "mode": { "const": "PROGRAM_SRAM" },
+            "manual_programming": { "const": true },
+            "attestation": { "$ref": "#/$defs/artifact" }
+          }
+        },
+        "host_command_sequence": {
+          "type": "object",
+          "required": ["status", "commands"],
+          "properties": {
+            "status": { "type": "string" },
+            "commands": {
+              "type": "array",
+              "prefixItems": [
+                { "const": "SET PTC 01 10" },
+                { "const": "SET PTC 24 20" },
+                { "const": "SET FAN 01 40" },
+                { "const": "SET FAN 04 30" },
+                { "const": "SET PID ENABLE" },
+                { "const": "GET STATUS" },
+                { "const": "GET MAP" },
+                { "const": "GET SENSOR" },
+                { "const": "GET SENSOR" },
+                { "const": "GET SENSOR" },
+                { "const": "SET PID DISABLE" },
+                { "const": "DISABLE" }
+              ],
+              "minItems": 12,
+              "maxItems": 12
+            }
+          }
+        },
+        "host_control_transcript": {
+          "type": "object",
+          "required": ["status", "host_command_transcript"],
+          "properties": { "status": { "type": "string" }, "host_command_transcript": { "$ref": "#/$defs/artifact" } }
+        },
+        "host_sensor_reports": {
+          "type": "object",
+          "required": ["status", "host_transcript_text", "host_raw_bin", "host_sensor_report"],
+          "properties": {
+            "status": { "type": "string" },
+            "host_transcript_text": { "$ref": "#/$defs/artifact" },
+            "host_raw_bin": { "$ref": "#/$defs/artifact" },
+            "host_sensor_report": { "$ref": "#/$defs/artifact" }
+          }
+        },
+        "debug_frame_capture": {
+          "type": "object",
+          "required": ["status", "debug_transcript", "raw_bin", "raw_replay", "debug_frame_stream", "manifest"],
+          "properties": {
+            "status": { "type": "string" },
+            "debug_transcript": { "$ref": "#/$defs/artifact" },
+            "raw_bin": { "$ref": "#/$defs/artifact" },
+            "raw_replay": { "$ref": "#/$defs/artifact" },
+            "debug_frame_stream": { "$ref": "#/$defs/artifact" },
+            "manifest": { "$ref": "#/$defs/artifact" }
+          }
+        },
+        "bmc_raw_sampling": {
+          "type": "object",
+          "required": ["status", "minimum_completed_samples", "completed_samples", "bmc_timeout"],
+          "properties": {
+            "status": { "type": "string" },
+            "minimum_completed_samples": { "type": "integer", "minimum": 3 },
+            "completed_samples": { "type": "integer", "minimum": 0 },
+            "bmc_timeout": { "type": "boolean" }
+          }
+        },
+        "pid_boundary": {
+          "type": "object",
+          "required": ["status", "pid_requested", "pid_requested_ever", "pid_active", "pwm_source"],
+          "properties": {
+            "status": { "type": "string" },
+            "pid_requested": { "type": "boolean" },
+            "pid_requested_ever": { "const": true },
+            "pid_active": { "const": false },
+            "pwm_source": { "const": "host_manual" }
+          }
+        },
+        "timeout_evidence": {
+          "type": "object",
+          "required": ["status", "timeout_evidence"],
+          "properties": {
+            "status": { "type": "string" },
+            "timeout_evidence": {
+              "type": "object",
+              "required": ["timeout_s", "ptc_all_percent", "fan_all_percent"],
+              "properties": {
+                "timeout_s": { "const": 5 },
+                "ptc_all_percent": { "const": 0 },
+                "fan_all_percent": { "const": 30 }
+              }
+            }
+          }
+        },
+        "pin_map": {
+          "type": "object",
+          "required": ["status", "ptc_count", "fan_count"],
+          "properties": { "status": { "type": "string" }, "ptc_count": { "const": 24 }, "fan_count": { "const": 4 } }
+        },
+        "safety_contract": {
+          "type": "object",
+          "required": ["status", "pid_default_enabled", "pid_active", "bmc_controls_pwm", "debug_port_writes_to_serial", "host_port_writes_to_serial", "real_thermal_performance_claimed"],
+          "properties": {
+            "status": { "type": "string" },
+            "pid_default_enabled": { "const": false },
+            "pid_active": { "const": false },
+            "bmc_controls_pwm": { "const": false },
+            "debug_port_writes_to_serial": { "const": false },
+            "host_port_writes_to_serial": { "const": true },
+            "real_thermal_performance_claimed": { "const": false }
+          }
+        },
+        "real_fan_ptc_hardware_status": {
+          "type": "object",
+          "required": ["status", "qualifies_final_gate"],
+          "properties": {
+            "status": { "enum": ["not_run", "blocked_waiting_for_real_fan_ptc_hardware"] },
+            "real_fan_ptc_hardware_present": { "type": "boolean" },
+            "qualifies_final_gate": { "const": false }
+          }
+        },
+        "artifact_hashes": {
+          "type": "object",
+          "required": [
+            "bitstream_sha256",
+            "td_receipt_sha256",
+            "manual_sram_attestation_sha256",
+            "host_transcript_text_sha256",
+            "host_raw_bin_sha256",
+            "host_sensor_report_sha256",
+            "debug_transcript_sha256",
+            "debug_raw_bin_sha256",
+            "raw_replay_sha256",
+            "debug_frame_stream_sha256",
+            "host_command_transcript_sha256",
+            "manifest_sha256"
+          ],
+          "properties": {
+            "status": { "type": "string" }
+          },
+          "additionalProperties": true
+        }
+      }
+    },
+    "safety": {
+      "type": "object",
+      "required": ["flash_attempted", "driver_install_attempted", "programs_flash", "programs_nonvolatile", "opens_unknown_com_ports", "enumerates_com_ports", "toggles_dtr_rts", "debug_port_writes_to_serial", "host_port_writes_to_serial", "uncontrolled_real_bmc_action_attempted", "real_thermal_performance_claimed"],
+      "properties": {
+        "flash_attempted": { "const": false },
+        "driver_install_attempted": { "const": false },
+        "programs_flash": { "const": false },
+        "programs_nonvolatile": { "const": false },
+        "opens_unknown_com_ports": { "const": false },
+        "enumerates_com_ports": { "const": false },
+        "toggles_dtr_rts": { "const": false },
+        "debug_port_writes_to_serial": { "const": false },
+        "host_port_writes_to_serial": { "const": true },
+        "uncontrolled_real_bmc_action_attempted": { "const": false },
+        "real_thermal_performance_claimed": { "const": false }
+      }
+    }
+  },
+  "$defs": {
+    "artifact": {
+      "type": "object",
+      "required": ["path", "sha256"],
+      "properties": {
+        "path": { "type": "string", "minLength": 1 },
+        "sha256": { "type": "string", "pattern": "^[0-9a-fA-F]{64}$" }
+      }
+    }
+  }
+}

+ 169 - 0
schemas/real_bmc_j6_windows_gate_v2_receipt.schema.json

@@ -0,0 +1,169 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "real_bmc_j6_windows_gate_v2_receipt.schema.json",
+  "title": "Real BMC J6 Windows gate v2 receipt",
+  "type": "object",
+  "required": ["schema", "status", "counterparty", "pin_profile", "programming", "layers", "safety", "authority_boundary"],
+  "properties": {
+    "schema": { "const": "real-bmc-j6-windows-gate-v2-receipt-v1" },
+    "status": { "const": "pass" },
+    "counterparty": { "const": "real_bmc" },
+    "pin_profile": {
+      "type": "object",
+      "required": ["name", "connector", "tx_ball", "rx_ball", "debug_rx_ball", "debug_tx_ball"],
+      "properties": {
+        "name": { "enum": ["primary", "swapped"] },
+        "connector": { "const": "J6" },
+        "tx_ball": { "enum": ["T4", "R5"] },
+        "rx_ball": { "enum": ["T4", "R5"] },
+        "debug_rx_ball": { "const": "P10" },
+        "debug_tx_ball": { "const": "R10" }
+      },
+      "additionalProperties": true
+    },
+    "programming": {
+      "type": "object",
+      "required": ["mode", "manual_programming", "bitstream"],
+      "properties": {
+        "mode": { "const": "PROGRAM_SRAM" },
+        "manual_programming": { "const": true },
+        "bitstream": { "$ref": "#/$defs/artifact" }
+      },
+      "additionalProperties": true
+    },
+    "layers": {
+      "type": "object",
+      "required": [
+        "td_bitstream",
+        "manual_sram_programming",
+        "windows_serial_capture",
+        "real_bmc_protocol",
+        "safety_contract",
+        "artifact_hashes"
+      ],
+      "properties": {
+        "td_bitstream": {
+          "type": "object",
+          "required": ["status", "receipt"],
+          "properties": {
+            "status": { "const": "pass" },
+            "receipt": { "$ref": "#/$defs/artifact" }
+          },
+          "additionalProperties": true
+        },
+        "manual_sram_programming": {
+          "type": "object",
+          "required": ["status", "operator", "mode", "manual_programming", "programmed_at", "attestation"],
+          "properties": {
+            "status": { "const": "pass" },
+            "operator": { "type": "string", "minLength": 1 },
+            "mode": { "const": "PROGRAM_SRAM" },
+            "manual_programming": { "const": true },
+            "programmed_at": { "type": "string", "minLength": 1 },
+            "attestation": { "$ref": "#/$defs/artifact" }
+          },
+          "additionalProperties": true
+        },
+        "windows_serial_capture": {
+          "type": "object",
+          "required": ["status", "port", "baud", "format", "duration_s", "transcript", "event_stream", "register_dump"],
+          "properties": {
+            "status": { "const": "pass" },
+            "port": { "type": "string", "pattern": "^COM[0-9]+$" },
+            "baud": { "const": 115200 },
+            "format": { "const": "8N1" },
+            "duration_s": { "type": "integer", "minimum": 90 },
+            "transcript": { "$ref": "#/$defs/artifact" },
+            "event_stream": { "$ref": "#/$defs/artifact" },
+            "register_dump": { "$ref": "#/$defs/artifact" }
+          },
+          "additionalProperties": true
+        },
+        "real_bmc_protocol": {
+          "type": "object",
+          "required": ["status", "valid_frame_count", "source_id"],
+          "properties": {
+            "status": { "const": "pass" },
+            "valid_frame_count": { "type": "integer", "minimum": 3 },
+            "source_id": { "const": "BMC_UART_TEXT" }
+          },
+          "additionalProperties": true
+        },
+        "safety_contract": {
+          "type": "object",
+          "required": ["status", "ptc_fan_pins_exported", "real_actuator_action_attempted"],
+          "properties": {
+            "status": { "const": "pass" },
+            "ptc_fan_pins_exported": { "const": false },
+            "real_actuator_action_attempted": { "const": false }
+          },
+          "additionalProperties": true
+        },
+        "artifact_hashes": {
+          "type": "object",
+          "required": [
+            "status",
+            "bitstream_sha256",
+            "td_receipt_sha256",
+            "manual_sram_attestation_sha256",
+            "transcript_sha256",
+            "event_stream_sha256",
+            "register_dump_sha256"
+          ],
+          "properties": {
+            "status": { "const": "pass" },
+            "bitstream_sha256": { "$ref": "#/$defs/sha256" },
+            "td_receipt_sha256": { "$ref": "#/$defs/sha256" },
+            "manual_sram_attestation_sha256": { "$ref": "#/$defs/sha256" },
+            "transcript_sha256": { "$ref": "#/$defs/sha256" },
+            "event_stream_sha256": { "$ref": "#/$defs/sha256" },
+            "register_dump_sha256": { "$ref": "#/$defs/sha256" }
+          },
+          "additionalProperties": true
+        }
+      },
+      "additionalProperties": false
+    },
+    "safety": {
+      "type": "object",
+      "required": [
+        "flash_attempted",
+        "driver_install_attempted",
+        "programs_flash",
+        "opens_unknown_com_ports",
+        "toggles_dtr_rts",
+        "ptc_fan_pins_exported",
+        "real_ptc_fan_action_attempted",
+        "uncontrolled_real_bmc_action_attempted"
+      ],
+      "properties": {
+        "flash_attempted": { "const": false },
+        "driver_install_attempted": { "const": false },
+        "programs_flash": { "const": false },
+        "opens_unknown_com_ports": { "const": false },
+        "toggles_dtr_rts": { "const": false },
+        "ptc_fan_pins_exported": { "const": false },
+        "real_ptc_fan_action_attempted": { "const": false },
+        "uncontrolled_real_bmc_action_attempted": { "const": false }
+      },
+      "additionalProperties": false
+    },
+    "authority_boundary": { "type": "string", "minLength": 1 }
+  },
+  "additionalProperties": true,
+  "$defs": {
+    "artifact": {
+      "type": "object",
+      "required": ["path", "sha256"],
+      "properties": {
+        "path": { "type": "string", "minLength": 1 },
+        "sha256": { "$ref": "#/$defs/sha256" }
+      },
+      "additionalProperties": true
+    },
+    "sha256": {
+      "type": "string",
+      "pattern": "^[0-9a-fA-F]{64}$"
+    }
+  }
+}

+ 69 - 0
schemas/uart_board_sram_receipt.schema.json

@@ -0,0 +1,69 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "uart_board_sram_receipt.schema.json",
+  "title": "UART board SRAM receipt",
+  "type": "object",
+  "required": ["schema", "status", "counterparty", "programming", "serial", "transcript", "debug_evidence", "safety"],
+  "properties": {
+    "schema": { "const": "uart-board-sram-receipt-v1" },
+    "status": { "type": "string" },
+    "counterparty": { "enum": ["pc_emulator", "real_bmc"] },
+    "programming": {
+      "type": "object",
+      "required": ["mode", "bitstream"],
+      "properties": {
+        "mode": { "const": "PROGRAM_SRAM" },
+        "bitstream": { "$ref": "#/$defs/artifact" }
+      },
+      "additionalProperties": true
+    },
+    "serial": { "$ref": "#/$defs/serial" },
+    "transcript": { "$ref": "#/$defs/artifact" },
+    "debug_evidence": {
+      "type": "object",
+      "required": ["event_stream", "register_dump"],
+      "properties": {
+        "event_stream": { "type": "string" },
+        "register_dump": { "type": "string" }
+      },
+      "additionalProperties": true
+    },
+    "safety": { "$ref": "#/$defs/safety" },
+    "authority_boundary": { "type": "string" }
+  },
+  "additionalProperties": true,
+  "$defs": {
+    "serial": {
+      "type": "object",
+      "required": ["port", "baud", "format", "allowlisted"],
+      "properties": {
+        "port": { "type": "string" },
+        "baud": { "const": 115200 },
+        "format": { "const": "8N1" },
+        "allowlisted": { "const": true },
+        "dtr": { "type": "boolean" },
+        "rts": { "type": "boolean" }
+      },
+      "additionalProperties": true
+    },
+    "artifact": {
+      "type": "object",
+      "required": ["path", "sha256"],
+      "properties": {
+        "path": { "type": "string" },
+        "sha256": { "type": "string", "pattern": "^[0-9a-fA-F]{64}$" }
+      },
+      "additionalProperties": true
+    },
+    "safety": {
+      "type": "object",
+      "required": ["flash_attempted", "real_ptc_fan_bmc_action_attempted", "driver_install_attempted"],
+      "properties": {
+        "flash_attempted": { "const": false },
+        "real_ptc_fan_bmc_action_attempted": { "const": false },
+        "driver_install_attempted": { "const": false }
+      },
+      "additionalProperties": true
+    }
+  }
+}

+ 50 - 0
schemas/uart_loopback_receipt.schema.json

@@ -0,0 +1,50 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "uart_loopback_receipt.schema.json",
+  "title": "UART loopback receipt",
+  "type": "object",
+  "required": ["schema", "status", "counterparty", "serial", "transcript", "safety"],
+  "properties": {
+    "schema": { "const": "uart-loopback-receipt-v1" },
+    "status": { "type": "string" },
+    "counterparty": { "enum": ["pc_emulator", "real_bmc"] },
+    "serial": { "$ref": "#/$defs/serial" },
+    "transcript": { "$ref": "#/$defs/artifact" },
+    "safety": { "$ref": "#/$defs/safety" }
+  },
+  "additionalProperties": true,
+  "$defs": {
+    "serial": {
+      "type": "object",
+      "required": ["port", "baud", "format", "allowlisted"],
+      "properties": {
+        "port": { "type": "string" },
+        "baud": { "const": 115200 },
+        "format": { "const": "8N1" },
+        "allowlisted": { "type": "boolean" },
+        "dtr": { "type": "boolean" },
+        "rts": { "type": "boolean" }
+      },
+      "additionalProperties": true
+    },
+    "artifact": {
+      "type": "object",
+      "required": ["path"],
+      "properties": {
+        "path": { "type": "string" },
+        "sha256": { "type": "string", "pattern": "^[0-9a-fA-F]{64}$" }
+      },
+      "additionalProperties": true
+    },
+    "safety": {
+      "type": "object",
+      "required": ["flash_attempted", "real_ptc_fan_bmc_action_attempted", "driver_install_attempted"],
+      "properties": {
+        "flash_attempted": { "const": false },
+        "real_ptc_fan_bmc_action_attempted": { "const": false },
+        "driver_install_attempted": { "const": false }
+      },
+      "additionalProperties": true
+    }
+  }
+}

+ 39 - 0
schemas/uart_preflight_receipt.schema.json

@@ -0,0 +1,39 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "uart_preflight_receipt.schema.json",
+  "title": "UART preflight receipt",
+  "type": "object",
+  "required": ["schema", "status", "serial", "enumeration", "safety", "authority_boundary"],
+  "properties": {
+    "schema": { "const": "uart-preflight-receipt-v1" },
+    "status": { "type": "string" },
+    "serial": {
+      "type": "object",
+      "required": ["baud", "format", "allowlisted", "opened"],
+      "properties": {
+        "baud": { "const": 115200 },
+        "format": { "const": "8N1" },
+        "allowlisted": { "type": "boolean" },
+        "opened": { "const": false },
+        "allowlist": { "type": "array", "items": { "type": "string" } }
+      },
+      "additionalProperties": true
+    },
+    "enumeration": { "type": "object", "additionalProperties": true },
+    "safety": { "$ref": "#/$defs/safety" },
+    "authority_boundary": { "type": "string" }
+  },
+  "additionalProperties": true,
+  "$defs": {
+    "safety": {
+      "type": "object",
+      "required": ["flash_attempted", "real_ptc_fan_bmc_action_attempted", "driver_install_attempted"],
+      "properties": {
+        "flash_attempted": { "const": false },
+        "real_ptc_fan_bmc_action_attempted": { "const": false },
+        "driver_install_attempted": { "const": false }
+      },
+      "additionalProperties": true
+    }
+  }
+}

+ 38 - 0
schemas/uart_soak_receipt.schema.json

@@ -0,0 +1,38 @@
+{
+  "$schema": "https://json-schema.org/draft/2020-12/schema",
+  "$id": "uart_soak_receipt.schema.json",
+  "title": "UART soak receipt",
+  "type": "object",
+  "required": ["schema", "status", "counterparty", "duration_hours_requested", "duration_hours_observed", "rounds", "safety"],
+  "properties": {
+    "schema": { "const": "uart-soak-receipt-v1" },
+    "status": { "type": "string" },
+    "counterparty": { "enum": ["pc_emulator", "real_bmc"] },
+    "duration_hours_requested": { "type": "number", "minimum": 0 },
+    "duration_hours_observed": { "type": "number", "minimum": 0 },
+    "rounds": {
+      "type": "array",
+      "items": {
+        "type": "object",
+        "required": ["index", "status"],
+        "properties": {
+          "index": { "type": "integer", "minimum": 1 },
+          "status": { "type": "string" },
+          "receipt": { "type": "string" }
+        },
+        "additionalProperties": true
+      }
+    },
+    "safety": {
+      "type": "object",
+      "required": ["flash_attempted", "real_ptc_fan_bmc_action_attempted", "driver_install_attempted"],
+      "properties": {
+        "flash_attempted": { "const": false },
+        "real_ptc_fan_bmc_action_attempted": { "const": false },
+        "driver_install_attempted": { "const": false }
+      },
+      "additionalProperties": true
+    }
+  },
+  "additionalProperties": true
+}

Разница между файлами не показана из-за своего большого размера
+ 0 - 881
scripts/generate_cpld_teaching_html.py


+ 0 - 386
scripts/validate_cpld_teaching_html.py

@@ -1,386 +0,0 @@
-#!/usr/bin/env python3
-"""Validate generated CPLD teaching HTML reports."""
-
-from __future__ import annotations
-
-import argparse
-import html
-import json
-import re
-import sys
-from collections import Counter
-from dataclasses import dataclass
-from pathlib import Path
-from typing import Any
-
-
-ROOT = Path(__file__).resolve().parents[1]
-DEFAULT_CONTENT = ROOT / "workspace" / "teaching_content" / "chapters" / "cpld_teaching_content.json"
-
-OLD_TEMPLATE_PHRASES = [
-    "建议读者先完成前序章节,再在本节动手",
-    "打开 TD 工程对照 Top Module",
-    "排障时保留 Waveform 截图、 Programmer 日志与 Git 版本号",
-    "若出现 Timing 违例或 CDC 告警,不要强行下板",
-]
-
-FORBIDDEN_BY_CHAPTER = {
-    4: ["PID 控制器", "三 DSP", "A0*e"],
-    5: ["UART 调试接口", "24 路 PID"],
-    6: ["PID24", "PWM", "ADC"],
-    11: ["EEPROM 写周期忙状态会直接导致 PID 饱和"],
-}
-
-REQUIRED_INTERACTIVE = {
-    4: ["id=\"i2cFrameBtn\""],
-    5: ["id=\"sclCalcBtn\""],
-    6: ["id=\"transactionStepper\""],
-    7: ["id=\"transactionStepper\""],
-    9: ["id=\"tool-pin\""],
-    11: ["id=\"pidScheduler\""],
-    13: ["id=\"debugTree\""],
-}
-
-RIGID_STRUCTURE_MARKERS = [
-    'class="causal-grid"',
-    "前因 Why",
-    "机制 How",
-    "后果 So what",
-]
-
-MECHANICAL_JOIN_MARKERS = [
-    "。;",
-    ";;",
-    "。。这个问题链",
-]
-
-GENERIC_NARRATION_MARKERS = [
-    "本节的交付标准是读者能把",
-    "常见误判要单独拎出来",
-    "复盘本章时建议按下面的问题链自问",
-    "本章的最小复述标准是",
-    "讨论「",
-    "读者真正会遇到的不是抽象名词",
-    "这个现象要落到证据上看",
-    "顺着这个点往下学",
-    "放进系统里看",
-    "扩展学习时不要把",
-    "讲解时可以采用一个很小的实验",
-    "不要从术语背诵开始",
-    "自然串讲:从现象走到验证",
-    "工程化深挖",
-    "问题链自问",
-    "最小复述标准",
-]
-
-
-VISIBLE_HTML_FRAGMENT_PATTERNS = [
-    re.compile(r'\b[a-z][a-z0-9_-]{1,40}">[A-Za-z0-9\u4e00-\u9fff]', re.I),
-    re.compile(r'\b(?:button|article|section|header|aside|div|span|a)\s+class="[^"]+"', re.I),
-    re.compile(r'\bdata-term="[^"]+"', re.I),
-]
-
-RAW_HTML_CORRUPTION_PATTERNS = [
-    re.compile(r'<meta\s+charset="utf-<', re.I),
-    re.compile(r'\b[a-z_:][\w:.-]*="[^"]*<[^"]*"', re.I),
-    re.compile(r'(?<!<)\b(?:button|article|section|header|aside|div|span|a)\s+(?:class|id|type|data-[\w-]+)=', re.I),
-    re.compile(r'\b(?:class|id|href|data-target|type|aria-label)="[^"]*<[^"]*"', re.I),
-    re.compile(r'cpld-tooltip-enhance-v\d+', re.I),
-    re.compile(r'cpld-visual-teach-v\d+', re.I),
-    re.compile(r'\bvisual-body\b', re.I),
-    re.compile(r'\bteach-(?:takeaway|split|matrix|cell|figure|table|flow|step|pitfall)\b', re.I),
-    re.compile(r'<button\b[^>]*>(?:(?!</button>).)*<(?:a|button)\b', re.I | re.S),
-]
-
-BALANCED_TAGS = ["button"]
-
-
-@dataclass
-class Finding:
-    level: str
-    file: str
-    message: str
-
-
-def load_content(path: Path) -> dict[str, Any]:
-    return json.loads(path.read_text(encoding="utf-8-sig"))
-
-
-def strip_tags(html: str) -> str:
-    html = re.sub(r"<script[\s\S]*?</script>", " ", html, flags=re.I)
-    html = re.sub(r"<style[\s\S]*?</style>", " ", html, flags=re.I)
-    html = re.sub(r"<[^>]+>", " ", html)
-    return html_module_unescape(re.sub(r"\s+", " ", html))
-
-
-def html_module_unescape(text: str) -> str:
-    return html.unescape(text)
-
-
-def han_count(text: str) -> int:
-    return sum(1 for ch in text if "\u4e00" <= ch <= "\u9fff")
-
-
-def section_blocks(html: str) -> list[str]:
-    return re.findall(r'<section class="section depth-section"[\s\S]*?</section>', html, flags=re.I)
-
-
-def repeated_paragraphs(plain: str) -> list[str]:
-    sentences = [s.strip() for s in re.split(r"[。!?!?]", plain) if len(s.strip()) >= 28]
-    counts = Counter(sentences)
-    return [sentence for sentence, count in counts.items() if count >= 4]
-
-
-def clipped(text: str, start: int, size: int = 80) -> str:
-    return text[max(0, start - 24) : start + size].replace("\n", " ")
-
-
-def tag_counts(markup: str, tag: str) -> tuple[int, int]:
-    opens = len(re.findall(fr"<{tag}\b", markup, flags=re.I))
-    closes = len(re.findall(fr"</{tag}\s*>", markup, flags=re.I))
-    return opens, closes
-
-
-def validate_integrated_section(block: str, block_plain: str, index: int, name: str) -> list[Finding]:
-    findings: list[Finding] = []
-    if han_count(block_plain) < 800:
-        findings.append(Finding("error", name, f"section {index} is too shallow: {han_count(block_plain)} Han chars"))
-    for marker in [
-        'class="integrated-section"',
-        'class="scene-lead"',
-        'class="visual-explain-grid"',
-        'class="integrated-mechanism"',
-        'class="visual-figure-block"',
-        'class="integrated-proof-table"',
-        'class="verify-table"',
-    ]:
-        if marker not in block:
-            findings.append(Finding("error", name, f"section {index} missing integrated marker {marker}"))
-    for forbidden in ['class="term-strip"', 'class="section-story"', 'class="evidence-panel"', 'class="explanation-flow"']:
-        if forbidden in block:
-            findings.append(Finding("error", name, f"section {index} still uses legacy marker {forbidden}"))
-    for forbidden_text in ["工程讲解", "证据与操作", "完整讲解"]:
-        if forbidden_text in block_plain:
-            findings.append(Finding("error", name, f"section {index} still exposes legacy heading {forbidden_text}"))
-    for required_text in ["先看现场", "结构图", "工程锚点表", "机制拆解", "验证与排障"]:
-        if required_text not in block_plain:
-            findings.append(Finding("error", name, f"section {index} missing integrated text {required_text}"))
-    if "<svg" not in block:
-        findings.append(Finding("error", name, f"section {index} missing integrated SVG diagram"))
-    if block.count("<table") < 2:
-        findings.append(Finding("error", name, f"section {index} missing integrated proof/verify tables"))
-    if block.count('class="term"') < 2:
-        findings.append(Finding("error", name, f"section {index} missing inline clickable terms"))
-    return findings
-
-
-def validate_legacy_section(block: str, block_plain: str, index: int, name: str) -> list[Finding]:
-    findings: list[Finding] = []
-    if han_count(block_plain) < 900:
-        findings.append(Finding("error", name, f"section {index} is too shallow: {han_count(block_plain)} Han chars"))
-    if 'class="explanation-flow"' not in block:
-        findings.append(Finding("error", name, f"section {index} missing natural explanation flow"))
-    if 'class="evidence-panel"' not in block:
-        findings.append(Finding("error", name, f"section {index} missing evidence panel"))
-    if 'class="section-story"' not in block:
-        findings.append(Finding("error", name, f"section {index} missing section-specific story"))
-    if 'class="progressive-note"' not in block:
-        findings.append(Finding("error", name, f"section {index} missing progressive note"))
-    if 'class="section-thread"' in block:
-        findings.append(Finding("error", name, f"section {index} still uses generic section thread"))
-    for required_text in ["工程讲解", "证据与操作", "验证", "Runbook", "完整讲解"]:
-        if required_text not in block_plain:
-            findings.append(Finding("error", name, f"section {index} missing required text {required_text}"))
-    return findings
-
-
-def validate_file(path: Path, chapter: dict[str, Any], glossary: dict[str, Any]) -> list[Finding]:
-    findings: list[Finding] = []
-    html = path.read_text(encoding="utf-8")
-    plain = strip_tags(html)
-    name = path.name
-
-    if '<meta charset="utf-8">' not in html:
-        findings.append(Finding("error", name, "html fragment leak: missing exact utf-8 meta tag"))
-    if '<meta name="viewport" content="width=device-width, initial-scale=1">' not in html:
-        findings.append(Finding("error", name, "html fragment leak: missing exact viewport meta tag"))
-    for pattern in RAW_HTML_CORRUPTION_PATTERNS:
-        match = pattern.search(html)
-        if match:
-            findings.append(Finding("error", name, f"html fragment leak in markup: {clipped(html, match.start())}"))
-    for tag in BALANCED_TAGS:
-        opens, closes = tag_counts(html, tag)
-        if opens != closes:
-            findings.append(Finding("error", name, f"html fragment leak: unbalanced <{tag}> tags ({opens} open, {closes} close)"))
-    for pattern in VISIBLE_HTML_FRAGMENT_PATTERNS:
-        match = pattern.search(plain)
-        if match:
-            findings.append(Finding("error", name, f"html fragment leak in visible text: {clipped(plain, match.start())}"))
-
-    min_han = 8200 if chapter["id"] in {1, 2} else 9000
-    if han_count(plain) < min_han:
-        findings.append(Finding("error", name, f"content depth too shallow: {han_count(plain)} Han chars"))
-
-    sections = section_blocks(html)
-    expected_sections = len(chapter["sections"])
-    if len(sections) != expected_sections:
-        findings.append(Finding("error", name, f"expected {expected_sections} depth sections, got {len(sections)}"))
-
-    for index, block in enumerate(sections, start=1):
-        block_plain = strip_tags(block)
-        if chapter["id"] in {1, 2}:
-            findings.extend(validate_integrated_section(block, block_plain, index, name))
-        else:
-            findings.extend(validate_legacy_section(block, block_plain, index, name))
-
-    if "learning-ladder" not in html or "从浅到深的学习阶梯" not in plain:
-        findings.append(Finding("error", name, "missing progressive learning ladder"))
-    if "knowledge-system" not in html or "本章知识系统" not in plain:
-        findings.append(Finding("error", name, "missing chapter knowledge system"))
-
-    for marker in RIGID_STRUCTURE_MARKERS:
-        if marker in html:
-            findings.append(Finding("error", name, f"rigid causal grid marker found: {marker}"))
-    for marker in MECHANICAL_JOIN_MARKERS:
-        if marker in html:
-            findings.append(Finding("error", name, f"mechanical join marker found: {marker}"))
-    for marker in GENERIC_NARRATION_MARKERS:
-        if marker in plain:
-            findings.append(Finding("error", name, f"generic narration marker found: {marker}"))
-
-    for phrase in OLD_TEMPLATE_PHRASES:
-        if phrase in plain:
-            findings.append(Finding("error", name, f"forbidden template phrase found: {phrase}"))
-
-    for sentence in repeated_paragraphs(plain):
-        if any(phrase in sentence for phrase in OLD_TEMPLATE_PHRASES):
-            findings.append(Finding("error", name, f"forbidden template repetition: {sentence[:80]}"))
-
-    section_plain = " ".join(strip_tags(block) for block in sections)
-    for phrase in FORBIDDEN_BY_CHAPTER.get(chapter["id"], []):
-        if phrase in section_plain:
-            findings.append(Finding("error", name, f"chapter-specific forbidden phrase found: {phrase}"))
-
-    if html.count("<svg") < expected_sections:
-        findings.append(Finding("error", name, f"expected at least {expected_sections} SVG diagrams"))
-    if html.count('class="term"') < 40:
-        findings.append(Finding("error", name, "expected at least 40 clickable terms"))
-    if "CPLD 术语总表" not in html:
-        findings.append(Finding("error", name, "missing glossary"))
-    if "series-nav" not in html or "tocPanel" not in html or "progress" not in html:
-        findings.append(Finding("error", name, "missing navigation/progress chrome"))
-    if re.search(r"https?://|file://", html, flags=re.I):
-        findings.append(Finding("error", name, "HTML should not depend on external URLs"))
-
-    for needle in REQUIRED_INTERACTIVE.get(chapter["id"], []):
-        if needle not in html:
-            findings.append(Finding("error", name, f"missing interactive component marker {needle}"))
-
-    for section in chapter["sections"]:
-        for anchor in section["anchors"]:
-            if str(anchor) not in html and str(anchor) not in plain:
-                findings.append(Finding("error", name, f"missing anchor: {anchor}"))
-
-    for term in chapter.get("terms", []):
-        if term not in glossary:
-            findings.append(Finding("error", name, f"term not defined in glossary: {term}"))
-        elif f'data-term="{term}"' not in html:
-            findings.append(Finding("error", name, f"term not clickable in HTML: {term}"))
-
-    return findings
-
-
-def validate(directory: Path, content: Path) -> dict[str, Any]:
-    data = load_content(content)
-    chapters = data["chapters"]
-    glossary = data["glossary"]
-    all_findings: list[Finding] = []
-    files = []
-
-    for chapter in chapters:
-        path = directory / chapter["file"]
-        files.append(path)
-        if not path.exists():
-            all_findings.append(Finding("error", chapter["file"], "missing expected HTML file"))
-            continue
-        all_findings.extend(validate_file(path, chapter, glossary))
-
-    extra = sorted(p.name for p in directory.glob("cpld_ch*_learning_report_v1.html") if p not in files)
-    for name in extra:
-        all_findings.append(Finding("warning", name, "extra CPLD teaching HTML file"))
-
-    errors = [f for f in all_findings if f.level == "error"]
-    warnings = [f for f in all_findings if f.level == "warning"]
-    required_anchor_errors = [f for f in errors if f.message.startswith("missing anchor")]
-    forbidden_template_errors = [f for f in errors if "forbidden template" in f.message]
-    interactive_errors = [f for f in errors if "interactive component" in f.message]
-    rigid_structure_errors = [f for f in errors if "rigid causal grid marker" in f.message]
-    mechanical_join_errors = [f for f in errors if "mechanical join marker" in f.message]
-    learning_progression_errors = [f for f in errors if "progressive" in f.message or "learning ladder" in f.message]
-    knowledge_system_errors = [f for f in errors if "knowledge system" in f.message]
-    natural_section_story_errors = [
-        f
-        for f in errors
-        if "section-specific story" in f.message
-        or "generic section thread" in f.message
-        or "generic narration marker" in f.message
-    ]
-    integrated_section_errors = [
-        f
-        for f in errors
-        if "integrated" in f.message or "legacy marker" in f.message or "legacy heading" in f.message
-    ]
-    html_integrity_errors = [f for f in errors if "html fragment leak" in f.message]
-
-    return {
-        "summary": {
-            "files": sum(1 for p in files if p.exists()),
-            "expected_files": len(chapters),
-            "errors": len(errors),
-            "warnings": len(warnings),
-        },
-        "checks": {
-            "required_anchors": {"passed": not required_anchor_errors, "errors": len(required_anchor_errors)},
-            "forbidden_template": {"passed": not forbidden_template_errors, "errors": len(forbidden_template_errors)},
-            "interactive_components": {"passed": not interactive_errors, "errors": len(interactive_errors)},
-            "rigid_causal_grid": {"passed": not rigid_structure_errors, "errors": len(rigid_structure_errors)},
-            "mechanical_join": {"passed": not mechanical_join_errors, "errors": len(mechanical_join_errors)},
-            "learning_progression": {"passed": not learning_progression_errors, "errors": len(learning_progression_errors)},
-            "knowledge_system": {"passed": not knowledge_system_errors, "errors": len(knowledge_system_errors)},
-            "natural_section_story": {"passed": not natural_section_story_errors, "errors": len(natural_section_story_errors)},
-            "integrated_sections": {"passed": not integrated_section_errors, "errors": len(integrated_section_errors)},
-            "html_integrity": {"passed": not html_integrity_errors, "errors": len(html_integrity_errors)},
-        },
-        "findings": [f.__dict__ for f in all_findings],
-    }
-
-
-def main() -> int:
-    parser = argparse.ArgumentParser(description=__doc__)
-    parser.add_argument("--dir", type=Path, required=True)
-    parser.add_argument("--content", type=Path, default=DEFAULT_CONTENT)
-    parser.add_argument("--json", action="store_true")
-    parser.add_argument("--receipt", type=Path)
-    args = parser.parse_args()
-
-    payload = validate(args.dir, args.content)
-    text = json.dumps(payload, ensure_ascii=False, indent=2)
-    if args.receipt:
-        args.receipt.parent.mkdir(parents=True, exist_ok=True)
-        args.receipt.write_text(text + "\n", encoding="utf-8")
-    if args.json:
-        print(text)
-    else:
-        for finding in payload["findings"]:
-            print(f"{finding['level'].upper()} {finding['file']}: {finding['message']}")
-        print(
-            f"files={payload['summary']['files']} errors={payload['summary']['errors']} warnings={payload['summary']['warnings']}"
-        )
-    if payload["summary"]["errors"]:
-        print("validation failed", file=sys.stderr)
-        return 1
-    return 0
-
-
-if __name__ == "__main__":
-    raise SystemExit(main())

+ 161 - 0
src/rtl/actuator_domain.v

@@ -0,0 +1,161 @@
+`timescale 1ns/1ps
+
+module actuator_domain #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5,
+    parameter integer CHANNEL_COUNT = 24,
+    parameter integer FAN_COUNT = 6,
+    parameter [DW-1:0] OUT_MIN = 18'd0,
+    parameter [DW-1:0] OUT_MAX = 18'd127,
+    parameter [DW-1:0] FAN_BACKGROUND_LEVEL = 18'd38,
+    parameter [DW-1:0] FAN_FALLBACK_LEVEL = 18'd127
+) (
+    input  wire                 clk,
+    input  wire                 rst_n,
+    input  wire                 pid_valid,
+    input  wire [CHW-1:0]       pid_channel,
+    input  wire signed [DW-1:0] pid_ctrl_q,
+    input  wire                 pid_fault,
+    input  wire                 global_enable,
+    input  wire                 fault_latched,
+    input  wire [3:0]           fault_code,
+    input  wire                 motor_open_req,
+    input  wire                 motor_close_req,
+    input  wire                 button_open_req,
+    input  wire                 button_close_req,
+    input  wire                 limit_open,
+    input  wire                 limit_close,
+    input  wire [FAN_COUNT-1:0] fan_tach_in,
+    input  wire                 interlock,
+    output reg                  ptc_enable,
+    output reg  [CHW-1:0]       ptc_channel,
+    output reg  [DW-1:0]        ptc_duty_or_level,
+    output reg                  ptc_force_off,
+    output reg  [3:0]           ptc_reason,
+    output reg                  fan_enable,
+    output reg  [DW-1:0]        fan_duty_or_level,
+    output reg                  fan_force_off,
+    output reg  [3:0]           fan_reason,
+    output reg                  motor_enable,
+    output reg  [1:0]           motor_dir,
+    output reg                  motor_force_off,
+    output reg  [3:0]           motor_reason,
+    output wire [CHANNEL_COUNT-1:0]    ptc_bank_enable,
+    output wire [CHANNEL_COUNT-1:0]    ptc_bank_force_off,
+    output wire [CHANNEL_COUNT*DW-1:0] ptc_bank_duty_or_level,
+    output wire [CHANNEL_COUNT-1:0]    ptc_pwm_out,
+    output wire [FAN_COUNT-1:0]        fan_pwm_enable,
+    output wire [FAN_COUNT-1:0]        fan_pwm_logic_high,
+    output wire [FAN_COUNT-1:0]        fan_pwm_drive_low,
+    output wire [FAN_COUNT*16-1:0]     fan_tach_count,
+    output wire [FAN_COUNT*16-1:0]     fan_tach_window_edges,
+    output wire [FAN_COUNT*16-1:0]     fan_rpm_estimate,
+    output wire [1:0]                  motor_state,
+    output wire [1:0]                  limit_status,
+    output wire [1:0]                  button_status
+);
+
+    wire ptc_enable_w;
+    wire [CHW-1:0] ptc_channel_w;
+    wire [DW-1:0] ptc_duty_or_level_w;
+    wire ptc_force_off_w;
+    wire [3:0] ptc_reason_w;
+    wire fan_enable_w;
+    wire [DW-1:0] fan_duty_or_level_w;
+    wire fan_force_off_w;
+    wire [3:0] fan_reason_w;
+    wire motor_enable_w;
+    wire [1:0] motor_dir_w;
+    wire motor_force_off_w;
+    wire [3:0] motor_reason_w;
+
+    ptc_output_bank #(
+        .DW(DW),
+        .CHW(CHW),
+        .CHANNEL_COUNT(CHANNEL_COUNT),
+        .OUT_MIN(OUT_MIN),
+        .OUT_MAX(OUT_MAX)
+    ) u_ptc_output_bank (
+        .clk(clk),
+        .rst_n(rst_n),
+        .pid_valid(pid_valid),
+        .pid_channel(pid_channel),
+        .pid_ctrl_q(pid_ctrl_q),
+        .pid_fault(pid_fault),
+        .global_enable(global_enable),
+        .fault_latched(fault_latched),
+        .fault_code(fault_code),
+        .ptc_enable(ptc_enable_w),
+        .ptc_channel(ptc_channel_w),
+        .ptc_duty_or_level(ptc_duty_or_level_w),
+        .ptc_force_off(ptc_force_off_w),
+        .ptc_reason(ptc_reason_w),
+        .ptc_bank_enable(ptc_bank_enable),
+        .ptc_bank_force_off(ptc_bank_force_off),
+        .ptc_bank_duty_or_level(ptc_bank_duty_or_level),
+        .ptc_pwm_out(ptc_pwm_out)
+    );
+
+    fan_tach_domain #(
+        .DW(DW),
+        .FAN_COUNT(FAN_COUNT),
+        .FAN_BACKGROUND_LEVEL(FAN_BACKGROUND_LEVEL),
+        .FAN_FALLBACK_LEVEL(FAN_FALLBACK_LEVEL)
+    ) u_fan_tach_domain (
+        .clk(clk),
+        .rst_n(rst_n),
+        .global_enable(global_enable),
+        .fault_latched(fault_latched),
+        .fault_code(fault_code),
+        .fan_tach_in(fan_tach_in),
+        .fan_enable(fan_enable_w),
+        .fan_duty_or_level(fan_duty_or_level_w),
+        .fan_force_off(fan_force_off_w),
+        .fan_reason(fan_reason_w),
+        .fan_pwm_enable(fan_pwm_enable),
+        .fan_pwm_logic_high(fan_pwm_logic_high),
+        .fan_pwm_drive_low(fan_pwm_drive_low),
+        .fan_tach_count(fan_tach_count),
+        .fan_tach_window_edges(fan_tach_window_edges),
+        .fan_rpm_estimate(fan_rpm_estimate)
+    );
+
+    motor_limit_domain u_motor_limit_domain (
+        .clk(clk),
+        .rst_n(rst_n),
+        .global_enable(global_enable),
+        .fault_latched(fault_latched),
+        .fault_code(fault_code),
+        .motor_open_req(motor_open_req),
+        .motor_close_req(motor_close_req),
+        .button_open_req(button_open_req),
+        .button_close_req(button_close_req),
+        .limit_open(limit_open),
+        .limit_close(limit_close),
+        .interlock(interlock),
+        .motor_enable(motor_enable_w),
+        .motor_dir(motor_dir_w),
+        .motor_force_off(motor_force_off_w),
+        .motor_reason(motor_reason_w),
+        .motor_state(motor_state),
+        .limit_status(limit_status),
+        .button_status(button_status)
+    );
+
+    always @(*) begin
+        ptc_enable = ptc_enable_w;
+        ptc_channel = ptc_channel_w;
+        ptc_duty_or_level = ptc_duty_or_level_w;
+        ptc_force_off = ptc_force_off_w;
+        ptc_reason = ptc_reason_w;
+        fan_enable = fan_enable_w;
+        fan_duty_or_level = fan_duty_or_level_w;
+        fan_force_off = fan_force_off_w;
+        fan_reason = fan_reason_w;
+        motor_enable = motor_enable_w;
+        motor_dir = motor_dir_w;
+        motor_force_off = motor_force_off_w;
+        motor_reason = motor_reason_w;
+    end
+
+endmodule

+ 75 - 0
src/rtl/actuator_sink.v

@@ -0,0 +1,75 @@
+`timescale 1ns/1ps
+
+module actuator_sink #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5,
+    parameter integer CHANNEL_COUNT = 24,
+    parameter [DW-1:0] OUT_MIN = 18'd0,
+    parameter [DW-1:0] OUT_MAX = 18'd127
+) (
+    input  wire                 clk,
+    input  wire                 rst_n,
+    input  wire                 host_enable,
+    input  wire                 pid_valid,
+    input  wire [CHW-1:0]       pid_channel,
+    input  wire signed [DW-1:0] pid_ctrl_q,
+    input  wire                 pid_fault,
+    output reg                  act_enable,
+    output reg  [CHW-1:0]       act_channel,
+    output reg  [DW-1:0]        act_duty_or_level,
+    output reg                  act_force_off,
+    output reg  [1:0]           act_reason
+);
+
+    localparam REASON_OK = 2'd0;
+    localparam REASON_HOST_DISABLED = 2'd1;
+    localparam REASON_PID_OR_SENSOR_FAULT = 2'd2;
+    localparam REASON_CHANNEL_INVALID = 2'd3;
+    localparam [CHW-1:0] LAST_CHANNEL = CHANNEL_COUNT - 1;
+
+    reg [DW-1:0] clamped_duty;
+
+    always @(*) begin
+        if (pid_ctrl_q < $signed(OUT_MIN)) begin
+            clamped_duty = OUT_MIN;
+        end else if (pid_ctrl_q > $signed(OUT_MAX)) begin
+            clamped_duty = OUT_MAX;
+        end else begin
+            clamped_duty = pid_ctrl_q[DW-1:0];
+        end
+    end
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            act_enable <= 1'b0;
+            act_channel <= {CHW{1'b0}};
+            act_duty_or_level <= {DW{1'b0}};
+            act_force_off <= 1'b1;
+            act_reason <= REASON_HOST_DISABLED;
+        end else if (pid_valid) begin
+            act_channel <= pid_channel;
+            if (pid_channel > LAST_CHANNEL) begin
+                act_enable <= 1'b0;
+                act_duty_or_level <= {DW{1'b0}};
+                act_force_off <= 1'b1;
+                act_reason <= REASON_CHANNEL_INVALID;
+            end else if (!host_enable) begin
+                act_enable <= 1'b0;
+                act_duty_or_level <= {DW{1'b0}};
+                act_force_off <= 1'b1;
+                act_reason <= REASON_HOST_DISABLED;
+            end else if (pid_fault) begin
+                act_enable <= 1'b0;
+                act_duty_or_level <= {DW{1'b0}};
+                act_force_off <= 1'b1;
+                act_reason <= REASON_PID_OR_SENSOR_FAULT;
+            end else begin
+                act_enable <= 1'b1;
+                act_duty_or_level <= clamped_duty;
+                act_force_off <= 1'b0;
+                act_reason <= REASON_OK;
+            end
+        end
+    end
+
+endmodule

+ 108 - 0
src/rtl/bmc_dimm_frame_parser.v

@@ -0,0 +1,108 @@
+`timescale 1ns/1ps
+
+module bmc_dimm_frame_parser #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5,
+    parameter integer EXPECTED_DIMM_COUNT = 24,
+    parameter integer FRACTION_SCALE = 100
+) (
+    input  wire                 clk,
+    input  wire                 rst_n,
+    input  wire                 raw_valid,
+    output wire                 raw_ready,
+    input  wire [7:0]           raw_integer_byte,
+    input  wire [7:0]           raw_fraction_byte,
+    input  wire [CHW-1:0]       raw_pair_index,
+    input  wire [15:0]          frame_seq,
+    input  wire [15:0]          sample_seq_base,
+    input  wire [15:0]          age_ms,
+    input  wire                 frame_bad_length,
+    input  wire                 sample_stale,
+    input  wire                 sample_ready,
+    output reg                  dimm_valid,
+    output reg  [2:0]           source_id,
+    output reg  [15:0]          dimm_frame_seq,
+    output reg  [15:0]          dimm_sample_seq,
+    output reg  [CHW-1:0]       raw_pair_index_out,
+    output reg  [CHW-1:0]       dimm_id,
+    output reg  [CHW-1:0]       channel,
+    output reg  [7:0]           raw_integer_byte_out,
+    output reg  [7:0]           raw_fraction_byte_out,
+    output reg  signed [DW-1:0] temp_q,
+    output reg  [15:0]          temp_c_x100,
+    output reg                  missing,
+    output reg                  fault,
+    output reg                  stale,
+    output reg  [15:0]          age_ms_out,
+    output reg  [7:0]           raw_status,
+    output reg  [7:0]           parser_status
+);
+
+    localparam [7:0] RAW_STATUS_MISSING_DIMM = 8'h01;
+    localparam [7:0] RAW_STATUS_PARSER_ERROR = 8'h02;
+    localparam [7:0] RAW_STATUS_STALE = 8'h08;
+    localparam [7:0] PARSER_STATUS_OK = 8'h00;
+    localparam [7:0] PARSER_STATUS_BAD_LENGTH = 8'h01;
+    localparam [2:0] SOURCE_BMC_UART_TEXT = 3'd5;
+
+    assign raw_ready = sample_ready;
+
+    wire is_missing = (raw_integer_byte == 8'hff) && (raw_fraction_byte == 8'hff);
+    wire [15:0] integer_x100 =
+        ({8'd0, raw_integer_byte} << 6) +
+        ({8'd0, raw_integer_byte} << 5) +
+        ({8'd0, raw_integer_byte} << 2);
+    wire [15:0] converted_x100 = is_missing ? 16'd0 : integer_x100 + {8'd0, raw_fraction_byte};
+    wire [15:0] rounded_temp = is_missing ? 16'd0 :
+        {8'd0, raw_integer_byte} + ((raw_fraction_byte >= 8'd50) ? 16'd1 : 16'd0);
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            dimm_valid <= 1'b0;
+            source_id <= SOURCE_BMC_UART_TEXT;
+            dimm_frame_seq <= 16'd0;
+            dimm_sample_seq <= 16'd0;
+            raw_pair_index_out <= {CHW{1'b0}};
+            dimm_id <= {CHW{1'b0}};
+            channel <= {CHW{1'b0}};
+            raw_integer_byte_out <= 8'd0;
+            raw_fraction_byte_out <= 8'd0;
+            temp_q <= {DW{1'b0}};
+            temp_c_x100 <= 16'd0;
+            missing <= 1'b0;
+            fault <= 1'b0;
+            stale <= 1'b0;
+            age_ms_out <= 16'd0;
+            raw_status <= 8'd0;
+            parser_status <= PARSER_STATUS_OK;
+        end else begin
+            dimm_valid <= 1'b0;
+            if (raw_valid && raw_ready) begin
+                dimm_valid <= 1'b1;
+                source_id <= SOURCE_BMC_UART_TEXT;
+                dimm_frame_seq <= frame_seq;
+                dimm_sample_seq <= sample_seq_base + {11'd0, raw_pair_index};
+                raw_pair_index_out <= raw_pair_index;
+                dimm_id <= raw_pair_index;
+                channel <= raw_pair_index;
+                raw_integer_byte_out <= raw_integer_byte;
+                raw_fraction_byte_out <= raw_fraction_byte;
+                temp_q <= {{(DW-16){1'b0}}, rounded_temp};
+                temp_c_x100 <= converted_x100;
+                missing <= is_missing;
+                fault <= frame_bad_length;
+                stale <= sample_stale;
+                age_ms_out <= age_ms;
+                parser_status <= frame_bad_length ? PARSER_STATUS_BAD_LENGTH : PARSER_STATUS_OK;
+                raw_status <=
+                    (is_missing ? RAW_STATUS_MISSING_DIMM : 8'd0) |
+                    (frame_bad_length ? RAW_STATUS_PARSER_ERROR : 8'd0) |
+                    (sample_stale ? RAW_STATUS_STALE : 8'd0);
+            end
+        end
+    end
+
+    wire unused_expected_dimm_count = |EXPECTED_DIMM_COUNT;
+    wire unused_fraction_scale = |FRACTION_SCALE;
+
+endmodule

+ 385 - 0
src/rtl/bmc_uart_ascii_poll.v

@@ -0,0 +1,385 @@
+`timescale 1ns/1ps
+
+module bmc_uart_ascii_poll #(
+    parameter integer POLL_PERIOD_TICKS = 25000000,
+    parameter integer STALE_TIMEOUT_TICKS = 250000000,
+    parameter integer STARTUP_WAKE_COUNT = 3,
+    parameter integer STARTUP_WAKE_GAP_TICKS = 5000000,
+    parameter integer STARTUP_POST_WAKE_DELAY_TICKS = 12500000,
+    parameter [7:0] STARTUP_WAKE_BYTE = 8'h0d,
+    parameter integer FRAME_BYTES = 48,
+    parameter integer FRAME_BYTE_INDEX_WIDTH = 6,
+    parameter integer WAIT_FOR_FRAME_BEFORE_NEXT_POLL = 0,
+    parameter integer ALLOW_ALL_FF_FRAME = 0
+) (
+    input  wire       clk,
+    input  wire       rst_n,
+    input  wire       tx_ready,
+    output reg        tx_valid,
+    output reg [7:0]  tx_data,
+    input  wire       rx_valid,
+    input  wire [7:0] rx_data,
+    output reg        frame_valid,
+    output reg [7:0]  frame_byte,
+    output reg [FRAME_BYTE_INDEX_WIDTH-1:0] frame_index,
+    output reg [15:0] frame_seq,
+    output reg        frame_done,
+    output reg        parser_error,
+    output reg        stale,
+    output reg [2:0]  parser_state,
+    output reg [15:0] token_count,
+    output reg [15:0] rejected_echo_windows,
+    output reg [15:0] startup_wake_sent_count,
+    output reg [15:0] poll_command_count,
+    output reg [15:0] tx_byte_count,
+    output reg [15:0] rx_byte_count
+);
+
+    // Command text: ipmitool raw 0x36 0x6c 0xdf 0xdd 0x00 0x03
+    localparam integer COMMAND_LEN = 43;
+    localparam S_IDLE = 3'd0;
+    localparam S_SEND = 3'd1;
+    localparam S_RX = 3'd2;
+    localparam S_TOKEN = 3'd3;
+    localparam S_FRAME = 3'd4;
+    localparam TX_WAKE = 3'd0;
+    localparam TX_WAKE_GAP = 3'd1;
+    localparam TX_POST_WAKE = 3'd2;
+    localparam TX_POLL_WAIT = 3'd3;
+    localparam TX_SEND_COMMAND = 3'd4;
+    localparam [FRAME_BYTE_INDEX_WIDTH-1:0] FRAME_BYTES_W = FRAME_BYTES;
+    localparam [FRAME_BYTE_INDEX_WIDTH-1:0] FRAME_LAST_INDEX_W = FRAME_BYTES - 1;
+
+    reg [2:0] tx_state;
+    reg [31:0] tx_wait_counter;
+    reg [31:0] stale_counter;
+    reg [5:0] command_index;
+    reg [7:0] high_nibble;
+    reg have_high_nibble;
+    reg [7:0] byte_window [0:FRAME_BYTES-1];
+    reg [7:0] emit_window [0:FRAME_BYTES-1];
+    reg [FRAME_BYTE_INDEX_WIDTH-1:0] window_count;
+    reg [FRAME_BYTE_INDEX_WIDTH-1:0] emit_index;
+    reg emitting;
+    reg response_frame_accepted;
+    reg [7:0] candidate_byte;
+    reg candidate_ready;
+    reg [2:0] echo_match_count;
+    reg window_has_echo;
+    reg [5:0] valid_pair_count;
+    integer i;
+
+    function [7:0] command_char;
+        input [5:0] index;
+        begin
+            case (index)
+                6'd0: command_char = "i";
+                6'd1: command_char = "p";
+                6'd2: command_char = "m";
+                6'd3: command_char = "i";
+                6'd4: command_char = "t";
+                6'd5: command_char = "o";
+                6'd6: command_char = "o";
+                6'd7: command_char = "l";
+                6'd8: command_char = " ";
+                6'd9: command_char = "r";
+                6'd10: command_char = "a";
+                6'd11: command_char = "w";
+                6'd12: command_char = " ";
+                6'd13: command_char = "0";
+                6'd14: command_char = "x";
+                6'd15: command_char = "3";
+                6'd16: command_char = "6";
+                6'd17: command_char = " ";
+                6'd18: command_char = "0";
+                6'd19: command_char = "x";
+                6'd20: command_char = "6";
+                6'd21: command_char = "c";
+                6'd22: command_char = " ";
+                6'd23: command_char = "0";
+                6'd24: command_char = "x";
+                6'd25: command_char = "d";
+                6'd26: command_char = "f";
+                6'd27: command_char = " ";
+                6'd28: command_char = "0";
+                6'd29: command_char = "x";
+                6'd30: command_char = "d";
+                6'd31: command_char = "d";
+                6'd32: command_char = " ";
+                6'd33: command_char = "0";
+                6'd34: command_char = "x";
+                6'd35: command_char = "0";
+                6'd36: command_char = "0";
+                6'd37: command_char = " ";
+                6'd38: command_char = "0";
+                6'd39: command_char = "x";
+                6'd40: command_char = "0";
+                6'd41: command_char = "3";
+                6'd42: command_char = 8'h0a;
+                default: command_char = 8'h00;
+            endcase
+        end
+    endfunction
+
+    function is_hex_char;
+        input [7:0] ch;
+        begin
+            is_hex_char = ((ch >= "0") && (ch <= "9")) ||
+                          ((ch >= "a") && (ch <= "f")) ||
+                          ((ch >= "A") && (ch <= "F"));
+        end
+    endfunction
+
+    function [3:0] hex_value;
+        input [7:0] ch;
+        begin
+            if (ch >= "0" && ch <= "9") begin
+                hex_value = ch - "0";
+            end else if (ch >= "a" && ch <= "f") begin
+                hex_value = ch - "a" + 4'd10;
+            end else begin
+                hex_value = ch - "A" + 4'd10;
+            end
+        end
+    endfunction
+
+    function frame_window_valid;
+        input dummy;
+        integer pair_index;
+        reg [7:0] int_byte;
+        reg [7:0] frac_byte;
+        reg [5:0] present_count;
+        begin
+            present_count = 6'd0;
+            frame_window_valid = 1'b1;
+            for (pair_index = 0; pair_index < FRAME_BYTES / 2; pair_index = pair_index + 1) begin
+                int_byte = byte_window[pair_index * 2];
+                frac_byte = byte_window[(pair_index * 2) + 1];
+                if (int_byte == 8'hff && frac_byte == 8'hff) begin
+                end else if (frac_byte >= 8'd100) begin
+                    frame_window_valid = 1'b0;
+                end else begin
+                    present_count = present_count + 6'd1;
+                end
+            end
+            if (present_count == 6'd0 && ALLOW_ALL_FF_FRAME == 0) begin
+                frame_window_valid = 1'b0;
+            end
+        end
+    endfunction
+
+    function [2:0] next_echo_match;
+        input [2:0] current;
+        input [7:0] value;
+        begin
+            case (current)
+                3'd0: next_echo_match = (value == 8'h36) ? 3'd1 : 3'd0;
+                3'd1: next_echo_match = (value == 8'h6c) ? 3'd2 : ((value == 8'h36) ? 3'd1 : 3'd0);
+                3'd2: next_echo_match = (value == 8'hdf) ? 3'd3 : ((value == 8'h36) ? 3'd1 : 3'd0);
+                3'd3: next_echo_match = (value == 8'hdd) ? 3'd4 : ((value == 8'h36) ? 3'd1 : 3'd0);
+                3'd4: next_echo_match = (value == 8'h00) ? 3'd5 : ((value == 8'h36) ? 3'd1 : 3'd0);
+                3'd5: next_echo_match = (value == 8'h03) ? 3'd6 : ((value == 8'h36) ? 3'd1 : 3'd0);
+                default: next_echo_match = (value == 8'h36) ? 3'd1 : 3'd0;
+            endcase
+        end
+    endfunction
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            tx_state <= TX_WAKE;
+            tx_wait_counter <= 32'd0;
+            stale_counter <= 32'd0;
+            command_index <= 6'd0;
+            tx_valid <= 1'b0;
+            tx_data <= 8'd0;
+            frame_valid <= 1'b0;
+            frame_byte <= 8'd0;
+            frame_index <= {FRAME_BYTE_INDEX_WIDTH{1'b0}};
+            frame_seq <= 16'd0;
+            frame_done <= 1'b0;
+            parser_error <= 1'b0;
+            stale <= 1'b0;
+            parser_state <= S_IDLE;
+            token_count <= 16'd0;
+            rejected_echo_windows <= 16'd0;
+            startup_wake_sent_count <= 16'd0;
+            poll_command_count <= 16'd0;
+            tx_byte_count <= 16'd0;
+            rx_byte_count <= 16'd0;
+            high_nibble <= 8'd0;
+            have_high_nibble <= 1'b0;
+            window_count <= {FRAME_BYTE_INDEX_WIDTH{1'b0}};
+            emit_index <= {FRAME_BYTE_INDEX_WIDTH{1'b0}};
+            emitting <= 1'b0;
+            response_frame_accepted <= 1'b0;
+            candidate_byte <= 8'd0;
+            candidate_ready <= 1'b0;
+            echo_match_count <= 3'd0;
+            window_has_echo <= 1'b0;
+            valid_pair_count <= 6'd0;
+            for (i = 0; i < FRAME_BYTES; i = i + 1) begin
+                byte_window[i] <= 8'd0;
+                emit_window[i] <= 8'd0;
+            end
+        end else begin
+            tx_valid <= 1'b0;
+            frame_valid <= 1'b0;
+            frame_done <= 1'b0;
+            candidate_ready <= 1'b0;
+
+            if (stale_counter < STALE_TIMEOUT_TICKS) begin
+                stale_counter <= stale_counter + 32'd1;
+            end else begin
+                stale <= 1'b1;
+            end
+
+            if (tx_state == TX_WAKE) begin
+                if (STARTUP_WAKE_COUNT <= 0) begin
+                    tx_state <= TX_POST_WAKE;
+                    tx_wait_counter <= 32'd0;
+                end else if (tx_ready) begin
+                    tx_valid <= 1'b1;
+                    tx_data <= STARTUP_WAKE_BYTE;
+                    if (startup_wake_sent_count != 16'hffff) begin
+                        startup_wake_sent_count <= startup_wake_sent_count + 16'd1;
+                    end
+                    if (tx_byte_count != 16'hffff) begin
+                        tx_byte_count <= tx_byte_count + 16'd1;
+                    end
+                    tx_wait_counter <= 32'd0;
+                    if (startup_wake_sent_count + 16'd1 >= STARTUP_WAKE_COUNT[15:0]) begin
+                        tx_state <= TX_POST_WAKE;
+                    end else begin
+                        tx_state <= TX_WAKE_GAP;
+                    end
+                end
+            end else if (tx_state == TX_WAKE_GAP) begin
+                if (STARTUP_WAKE_GAP_TICKS <= 1 || tx_wait_counter == STARTUP_WAKE_GAP_TICKS - 1) begin
+                    tx_wait_counter <= 32'd0;
+                    tx_state <= TX_WAKE;
+                end else begin
+                    tx_wait_counter <= tx_wait_counter + 32'd1;
+                end
+            end else if (tx_state == TX_POST_WAKE) begin
+                if (STARTUP_POST_WAKE_DELAY_TICKS <= 1 || tx_wait_counter == STARTUP_POST_WAKE_DELAY_TICKS - 1) begin
+                    tx_wait_counter <= 32'd0;
+                    tx_state <= TX_SEND_COMMAND;
+                    command_index <= 6'd0;
+                end else begin
+                    tx_wait_counter <= tx_wait_counter + 32'd1;
+                end
+            end else if (tx_state == TX_POLL_WAIT) begin
+                if ((WAIT_FOR_FRAME_BEFORE_NEXT_POLL != 0) && !response_frame_accepted) begin
+                    tx_wait_counter <= 32'd0;
+                end else if (POLL_PERIOD_TICKS <= 1 || tx_wait_counter == POLL_PERIOD_TICKS - 1) begin
+                    tx_wait_counter <= 32'd0;
+                    tx_state <= TX_SEND_COMMAND;
+                    command_index <= 6'd0;
+                end else begin
+                    tx_wait_counter <= tx_wait_counter + 32'd1;
+                end
+            end else if (tx_state == TX_SEND_COMMAND && tx_ready) begin
+                tx_valid <= 1'b1;
+                tx_data <= command_char(command_index);
+                parser_state <= S_SEND;
+                if (tx_byte_count != 16'hffff) begin
+                    tx_byte_count <= tx_byte_count + 16'd1;
+                end
+                if (command_index == 6'd0) begin
+                    response_frame_accepted <= 1'b0;
+                    window_count <= {FRAME_BYTE_INDEX_WIDTH{1'b0}};
+                    echo_match_count <= 3'd0;
+                    window_has_echo <= 1'b0;
+                    have_high_nibble <= 1'b0;
+                end
+                if (command_index == COMMAND_LEN - 1) begin
+                    parser_state <= S_RX;
+                    command_index <= 6'd0;
+                    tx_state <= TX_POLL_WAIT;
+                    tx_wait_counter <= 32'd0;
+                    if (poll_command_count != 16'hffff) begin
+                        poll_command_count <= poll_command_count + 16'd1;
+                    end
+                end else begin
+                    command_index <= command_index + 6'd1;
+                end
+            end
+
+            if (rx_valid) begin
+                if (rx_byte_count != 16'hffff) begin
+                    rx_byte_count <= rx_byte_count + 16'd1;
+                end
+                parser_state <= S_TOKEN;
+                if (is_hex_char(rx_data)) begin
+                    if (!have_high_nibble) begin
+                        high_nibble <= {4'd0, hex_value(rx_data)};
+                        have_high_nibble <= 1'b1;
+                    end else begin
+                        candidate_byte <= {high_nibble[3:0], hex_value(rx_data)};
+                        candidate_ready <= 1'b1;
+                        have_high_nibble <= 1'b0;
+                        token_count <= token_count + 16'd1;
+                    end
+                end else begin
+                    have_high_nibble <= 1'b0;
+                end
+            end
+
+            if (candidate_ready) begin
+                for (i = 0; i < FRAME_BYTES - 1; i = i + 1) begin
+                    byte_window[i] = byte_window[i + 1];
+                end
+                byte_window[FRAME_BYTES - 1] = candidate_byte;
+                if (window_count < FRAME_BYTES_W) begin
+                    window_count <= window_count + {{(FRAME_BYTE_INDEX_WIDTH-1){1'b0}}, 1'b1};
+                end
+                if (next_echo_match(echo_match_count, candidate_byte) == 3'd6) begin
+                    echo_match_count <= 3'd0;
+                    window_has_echo <= 1'b0;
+                    window_count <= {FRAME_BYTE_INDEX_WIDTH{1'b0}};
+                    rejected_echo_windows <= rejected_echo_windows + 16'd1;
+                    parser_error <= 1'b0;
+                end else begin
+                    echo_match_count <= next_echo_match(echo_match_count, candidate_byte);
+                    if (!response_frame_accepted && !emitting && window_count >= FRAME_LAST_INDEX_W) begin
+                        if (window_has_echo) begin
+                            rejected_echo_windows <= rejected_echo_windows + 16'd1;
+                            window_has_echo <= 1'b0;
+                        end else if (frame_window_valid(1'b1)) begin
+                        for (i = 0; i < FRAME_BYTES; i = i + 1) begin
+                            emit_window[i] <= byte_window[i];
+                        end
+                            emitting <= 1'b1;
+                            response_frame_accepted <= 1'b1;
+                            emit_index <= {FRAME_BYTE_INDEX_WIDTH{1'b0}};
+                            frame_seq <= frame_seq + 16'd1;
+                            parser_error <= 1'b0;
+                            stale_counter <= 32'd0;
+                            stale <= 1'b0;
+                            parser_state <= S_FRAME;
+                        end else begin
+                            parser_error <= 1'b1;
+                        end
+                    end
+                end
+            end
+
+            if (emitting) begin
+                frame_valid <= 1'b1;
+                frame_index <= emit_index;
+                frame_byte <= emit_window[emit_index];
+                if (emit_index == FRAME_LAST_INDEX_W) begin
+                    emitting <= 1'b0;
+                    emit_index <= {FRAME_BYTE_INDEX_WIDTH{1'b0}};
+                    frame_done <= 1'b1;
+                    parser_state <= S_RX;
+                end else begin
+                    emit_index <= emit_index + {{(FRAME_BYTE_INDEX_WIDTH-1){1'b0}}, 1'b1};
+                end
+            end
+        end
+    end
+
+    wire [5:0] unused_valid_pair_count = valid_pair_count;
+
+endmodule

+ 73 - 0
src/rtl/bmc_uart_phy_bridge.v

@@ -0,0 +1,73 @@
+`timescale 1ns/1ps
+
+module bmc_uart_phy_bridge (
+    input  wire       clk,
+    input  wire       rst_n,
+    input  wire       core_tx_valid,
+    input  wire [7:0] core_tx_data,
+    output wire       core_tx_ready,
+    output reg        core_rx_valid,
+    output reg [7:0]  core_rx_data,
+    input  wire       phy_tx_ready,
+    output reg        phy_tx_valid,
+    output reg [7:0]  phy_tx_data,
+    input  wire       phy_rx_valid,
+    input  wire [7:0] phy_rx_data,
+    output reg        rx_overflow,
+    output reg        tx_overflow,
+    output wire [7:0] status
+);
+
+    reg tx_pending;
+    reg [7:0] tx_pending_data;
+
+    assign core_tx_ready = !tx_pending && phy_tx_ready;
+    assign status = {
+        4'd0,
+        tx_pending,
+        phy_tx_ready,
+        rx_overflow,
+        tx_overflow
+    };
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            core_rx_valid <= 1'b0;
+            core_rx_data <= 8'd0;
+            phy_tx_valid <= 1'b0;
+            phy_tx_data <= 8'd0;
+            rx_overflow <= 1'b0;
+            tx_overflow <= 1'b0;
+            tx_pending <= 1'b0;
+            tx_pending_data <= 8'd0;
+        end else begin
+            phy_tx_valid <= 1'b0;
+            core_rx_valid <= 1'b0;
+
+            if (phy_rx_valid) begin
+                if (core_rx_valid) begin
+                    rx_overflow <= 1'b1;
+                end
+                core_rx_data <= phy_rx_data;
+                core_rx_valid <= 1'b1;
+            end
+
+            if (tx_pending && phy_tx_ready) begin
+                phy_tx_data <= tx_pending_data;
+                phy_tx_valid <= 1'b1;
+                tx_pending <= 1'b0;
+            end else if (core_tx_valid) begin
+                if (phy_tx_ready && !tx_pending) begin
+                    phy_tx_data <= core_tx_data;
+                    phy_tx_valid <= 1'b1;
+                end else if (!tx_pending) begin
+                    tx_pending <= 1'b1;
+                    tx_pending_data <= core_tx_data;
+                end else begin
+                    tx_overflow <= 1'b1;
+                end
+            end
+        end
+    end
+
+endmodule

+ 307 - 0
src/rtl/bmc_uart_raw48_poll_lite.v

@@ -0,0 +1,307 @@
+`timescale 1ns/1ps
+
+module bmc_uart_raw48_poll_lite #(
+    parameter integer POLL_PERIOD_TICKS = 25000000,
+    parameter integer STARTUP_WAKE_COUNT = 3,
+    parameter integer STARTUP_WAKE_GAP_TICKS = 5000000,
+    parameter integer STARTUP_POST_WAKE_DELAY_TICKS = 12500000,
+    parameter [7:0] STARTUP_WAKE_BYTE = 8'h0d,
+    parameter integer WAIT_FOR_FRAME_BEFORE_NEXT_POLL = 1
+) (
+    input  wire       clk,
+    input  wire       rst_n,
+    input  wire       tx_ready,
+    output reg        tx_valid,
+    output reg [7:0]  tx_data,
+    input  wire       rx_valid,
+    input  wire [7:0] rx_data,
+    output reg        frame_valid,
+    output reg [7:0]  frame_byte,
+    output reg [5:0]  frame_index,
+    output reg [15:0] frame_seq,
+    output reg        frame_done,
+    output reg        parser_error,
+    output reg        stale,
+    output reg [2:0]  parser_state,
+    output reg [15:0] token_count,
+    output reg [15:0] rejected_echo_windows,
+    output reg [15:0] startup_wake_sent_count,
+    output reg [15:0] poll_command_count,
+    output reg [15:0] tx_byte_count,
+    output reg [15:0] rx_byte_count
+);
+
+    // Lightweight fixed-purpose replacement for bmc_uart_ascii_poll behavior in
+    // the host-sensor debug image. It sends one read-only raw command and accepts
+    // the first 48 response hex bytes after an optional command echo.
+    localparam integer COMMAND_LEN = 43;
+    localparam [2:0] TX_WAKE = 3'd0;
+    localparam [2:0] TX_WAKE_GAP = 3'd1;
+    localparam [2:0] TX_POST_WAKE = 3'd2;
+    localparam [2:0] TX_POLL_WAIT = 3'd3;
+    localparam [2:0] TX_SEND_COMMAND = 3'd4;
+    localparam [2:0] PARSER_IDLE = 3'd0;
+    localparam [2:0] PARSER_SEND = 3'd1;
+    localparam [2:0] PARSER_RX = 3'd2;
+    localparam [2:0] PARSER_TOKEN = 3'd3;
+    localparam [2:0] PARSER_FRAME = 3'd4;
+
+    reg [2:0] tx_state;
+    reg [31:0] tx_wait_counter;
+    reg [5:0] command_index;
+    reg [7:0] high_nibble;
+    reg have_high_nibble;
+    reg [7:0] echo_buffer [0:4];
+    reg [5:0] capture_count;
+    reg response_frame_accepted;
+    reg [7:0] candidate_byte;
+    reg candidate_ready;
+    integer i;
+
+    function [7:0] command_char;
+        input [5:0] index;
+        begin
+            case (index)
+                6'd0: command_char = "i";
+                6'd1: command_char = "p";
+                6'd2: command_char = "m";
+                6'd3: command_char = "i";
+                6'd4: command_char = "t";
+                6'd5: command_char = "o";
+                6'd6: command_char = "o";
+                6'd7: command_char = "l";
+                6'd8: command_char = " ";
+                6'd9: command_char = "r";
+                6'd10: command_char = "a";
+                6'd11: command_char = "w";
+                6'd12: command_char = " ";
+                6'd13: command_char = "0";
+                6'd14: command_char = "x";
+                6'd15: command_char = "3";
+                6'd16: command_char = "6";
+                6'd17: command_char = " ";
+                6'd18: command_char = "0";
+                6'd19: command_char = "x";
+                6'd20: command_char = "6";
+                6'd21: command_char = "c";
+                6'd22: command_char = " ";
+                6'd23: command_char = "0";
+                6'd24: command_char = "x";
+                6'd25: command_char = "d";
+                6'd26: command_char = "f";
+                6'd27: command_char = " ";
+                6'd28: command_char = "0";
+                6'd29: command_char = "x";
+                6'd30: command_char = "d";
+                6'd31: command_char = "d";
+                6'd32: command_char = " ";
+                6'd33: command_char = "0";
+                6'd34: command_char = "x";
+                6'd35: command_char = "0";
+                6'd36: command_char = "0";
+                6'd37: command_char = " ";
+                6'd38: command_char = "0";
+                6'd39: command_char = "x";
+                6'd40: command_char = "0";
+                6'd41: command_char = "3";
+                6'd42: command_char = 8'h0a;
+                default: command_char = 8'h00;
+            endcase
+        end
+    endfunction
+
+    function [7:0] echo_byte;
+        input [2:0] index;
+        begin
+            case (index)
+                3'd0: echo_byte = 8'h36;
+                3'd1: echo_byte = 8'h6c;
+                3'd2: echo_byte = 8'hdf;
+                3'd3: echo_byte = 8'hdd;
+                3'd4: echo_byte = 8'h00;
+                default: echo_byte = 8'h03;
+            endcase
+        end
+    endfunction
+
+    function is_hex_char;
+        input [7:0] ch;
+        begin
+            is_hex_char = ((ch >= "0") && (ch <= "9")) ||
+                          ((ch >= "a") && (ch <= "f")) ||
+                          ((ch >= "A") && (ch <= "F"));
+        end
+    endfunction
+
+    function [3:0] hex_value;
+        input [7:0] ch;
+        begin
+            if (ch >= "0" && ch <= "9") begin
+                hex_value = ch - "0";
+            end else if (ch >= "a" && ch <= "f") begin
+                hex_value = ch - "a" + 4'd10;
+            end else begin
+                hex_value = ch - "A" + 4'd10;
+            end
+        end
+    endfunction
+
+    function capture_is_echo;
+        input [7:0] last_byte;
+        begin
+            capture_is_echo =
+                echo_buffer[0] == echo_byte(3'd0) &&
+                echo_buffer[1] == echo_byte(3'd1) &&
+                echo_buffer[2] == echo_byte(3'd2) &&
+                echo_buffer[3] == echo_byte(3'd3) &&
+                echo_buffer[4] == echo_byte(3'd4) &&
+                last_byte == echo_byte(3'd5);
+        end
+    endfunction
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            tx_state <= TX_WAKE;
+            tx_wait_counter <= 32'd0;
+            command_index <= 6'd0;
+            tx_valid <= 1'b0;
+            tx_data <= 8'd0;
+            frame_valid <= 1'b0;
+            frame_byte <= 8'd0;
+            frame_index <= 6'd0;
+            frame_seq <= 16'd0;
+            frame_done <= 1'b0;
+            parser_error <= 1'b0;
+            stale <= 1'b0;
+            parser_state <= PARSER_IDLE;
+            token_count <= 16'd0;
+            rejected_echo_windows <= 16'd0;
+            startup_wake_sent_count <= 16'd0;
+            poll_command_count <= 16'd0;
+            tx_byte_count <= 16'd0;
+            rx_byte_count <= 16'd0;
+            high_nibble <= 8'd0;
+            have_high_nibble <= 1'b0;
+            capture_count <= 6'd0;
+            response_frame_accepted <= 1'b0;
+            candidate_byte <= 8'd0;
+            candidate_ready <= 1'b0;
+            for (i = 0; i < 5; i = i + 1) begin
+                echo_buffer[i] <= 8'd0;
+            end
+        end else begin
+            tx_valid <= 1'b0;
+            frame_valid <= 1'b0;
+            frame_done <= 1'b0;
+            candidate_ready <= 1'b0;
+
+            if (tx_state == TX_WAKE) begin
+                if (STARTUP_WAKE_COUNT <= 0) begin
+                    tx_state <= TX_POST_WAKE;
+                    tx_wait_counter <= 32'd0;
+                end else if (tx_ready) begin
+                    tx_valid <= 1'b1;
+                    tx_data <= STARTUP_WAKE_BYTE;
+                    tx_wait_counter <= 32'd0;
+                    startup_wake_sent_count <= startup_wake_sent_count + 16'd1;
+                    tx_byte_count <= tx_byte_count + 16'd1;
+                    if (startup_wake_sent_count + 16'd1 >= STARTUP_WAKE_COUNT[15:0]) begin
+                        tx_state <= TX_POST_WAKE;
+                    end else begin
+                        tx_state <= TX_WAKE_GAP;
+                    end
+                end
+            end else if (tx_state == TX_WAKE_GAP) begin
+                if (STARTUP_WAKE_GAP_TICKS <= 1 || tx_wait_counter == STARTUP_WAKE_GAP_TICKS - 1) begin
+                    tx_wait_counter <= 32'd0;
+                    tx_state <= TX_WAKE;
+                end else begin
+                    tx_wait_counter <= tx_wait_counter + 32'd1;
+                end
+            end else if (tx_state == TX_POST_WAKE) begin
+                if (STARTUP_POST_WAKE_DELAY_TICKS <= 1 || tx_wait_counter == STARTUP_POST_WAKE_DELAY_TICKS - 1) begin
+                    tx_wait_counter <= 32'd0;
+                    tx_state <= TX_SEND_COMMAND;
+                    command_index <= 6'd0;
+                end else begin
+                    tx_wait_counter <= tx_wait_counter + 32'd1;
+                end
+            end else if (tx_state == TX_POLL_WAIT) begin
+                if ((WAIT_FOR_FRAME_BEFORE_NEXT_POLL != 0) && !response_frame_accepted) begin
+                    tx_wait_counter <= 32'd0;
+                end else if (POLL_PERIOD_TICKS <= 1 || tx_wait_counter == POLL_PERIOD_TICKS - 1) begin
+                    tx_wait_counter <= 32'd0;
+                    tx_state <= TX_SEND_COMMAND;
+                    command_index <= 6'd0;
+                end else begin
+                    tx_wait_counter <= tx_wait_counter + 32'd1;
+                end
+            end else if (tx_state == TX_SEND_COMMAND && tx_ready) begin
+                tx_valid <= 1'b1;
+                tx_data <= command_char(command_index);
+                parser_state <= PARSER_SEND;
+                tx_byte_count <= tx_byte_count + 16'd1;
+                if (command_index == 6'd0) begin
+                    response_frame_accepted <= 1'b0;
+                    capture_count <= 6'd0;
+                    have_high_nibble <= 1'b0;
+                    parser_error <= 1'b0;
+                    stale <= 1'b0;
+                end
+                if (command_index == COMMAND_LEN - 1) begin
+                    command_index <= 6'd0;
+                    tx_state <= TX_POLL_WAIT;
+                    tx_wait_counter <= 32'd0;
+                    poll_command_count <= poll_command_count + 16'd1;
+                    parser_state <= PARSER_RX;
+                end else begin
+                    command_index <= command_index + 6'd1;
+                end
+            end
+
+            if (rx_valid) begin
+                rx_byte_count <= rx_byte_count + 16'd1;
+                parser_state <= PARSER_TOKEN;
+                if (is_hex_char(rx_data)) begin
+                    if (!have_high_nibble) begin
+                        high_nibble <= {4'd0, hex_value(rx_data)};
+                        have_high_nibble <= 1'b1;
+                    end else begin
+                        candidate_byte <= {high_nibble[3:0], hex_value(rx_data)};
+                        candidate_ready <= 1'b1;
+                        have_high_nibble <= 1'b0;
+                        token_count <= token_count + 16'd1;
+                    end
+                end else begin
+                    have_high_nibble <= 1'b0;
+                end
+            end
+
+            if (candidate_ready && !response_frame_accepted) begin
+                if (capture_count < 6'd5) begin
+                    echo_buffer[capture_count[2:0]] <= candidate_byte;
+                end
+                if (capture_count == 6'd5 && capture_is_echo(candidate_byte)) begin
+                    capture_count <= 6'd0;
+                    rejected_echo_windows <= rejected_echo_windows + 16'd1;
+                end else if (capture_count == 6'd47) begin
+                    capture_count <= 6'd0;
+                    response_frame_accepted <= 1'b1;
+                    frame_seq <= frame_seq + 16'd1;
+                    frame_valid <= 1'b1;
+                    frame_index <= capture_count;
+                    frame_byte <= candidate_byte;
+                    frame_done <= 1'b1;
+                    parser_error <= 1'b0;
+                    stale <= 1'b0;
+                    parser_state <= PARSER_FRAME;
+                end else begin
+                    frame_valid <= 1'b1;
+                    frame_index <= capture_count;
+                    frame_byte <= candidate_byte;
+                    capture_count <= capture_count + 6'd1;
+                end
+            end
+        end
+    end
+endmodule

+ 19 - 0
src/rtl/board_io_adapter.v

@@ -0,0 +1,19 @@
+`timescale 1ns/1ps
+
+module board_io_adapter #(
+    parameter integer PTC_COUNT = 24,
+    parameter integer FAN_COUNT = 8
+) (
+    input  wire [PTC_COUNT-1:0] ptc_pwm_request,
+    input  wire [FAN_COUNT-1:0] fan_pwm_logic_high,
+    input  wire [FAN_COUNT-1:0] fan_pwm_drive_low,
+    output wire [PTC_COUNT-1:0] ptc_pwm_pin_o,
+    output wire [FAN_COUNT-1:0] fan_pwm_pin_o,
+    output wire [FAN_COUNT-1:0] fan_pwm_pin_oe
+);
+
+    assign ptc_pwm_pin_o = ptc_pwm_request;
+    assign fan_pwm_pin_o = {FAN_COUNT{1'b0}};
+    assign fan_pwm_pin_oe = fan_pwm_drive_low & ~fan_pwm_logic_high;
+
+endmodule

+ 275 - 0
src/rtl/control_service_24ch.v

@@ -0,0 +1,275 @@
+`timescale 1ns/1ps
+
+module control_service_24ch #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5,
+    parameter integer CHANNEL_COUNT = 24,
+    parameter signed [DW-1:0] OUT_MIN = 18'sd0,
+    parameter signed [DW-1:0] OUT_MAX = 18'sd127,
+    parameter signed [DW-1:0] POWER_LIMIT = 18'sd90,
+    parameter signed [DW-1:0] TARGET_TOLERANCE_Q = 18'sd7,
+    parameter signed [DW-1:0] KP_Q = 18'sd4,
+    parameter signed [DW-1:0] KI_Q = 18'sd1
+) (
+    input  wire                         clk,
+    input  wire                         rst_n,
+    input  wire                         sensor_valid,
+    output wire                         sensor_ready,
+    input  wire                         sensor_fault,
+    input  wire [CHW-1:0]               sensor_channel,
+    input  wire signed [DW-1:0]         sensor_temp_q,
+    input  wire [15:0]                  sensor_sample_seq,
+    input  wire                         host_enable,
+    input  wire signed [DW-1:0]         host_target_q,
+    input  wire signed [DW-1:0]         host_a0,
+    input  wire signed [DW-1:0]         host_a1,
+    input  wire signed [DW-1:0]         host_a2,
+    input  wire [1:0]                   control_mode,
+    input  wire [15:0]                  host_config_seq,
+    input  wire                         clear_history_all,
+    input  wire signed [DW-1:0]         manual_level_q,
+    output reg                          result_valid,
+    output reg  [CHW-1:0]               result_channel,
+    output reg  signed [DW-1:0]         result_error_q,
+    output reg  signed [DW-1:0]         result_ctrl_q,
+    output reg                          result_fault,
+    output reg  [15:0]                  result_sample_seq,
+    output reg  [1:0]                   result_control_mode,
+    output reg                          result_experimental,
+    output reg                          result_clamped,
+    output reg                          result_history_cleared,
+    output wire [1:0]                   state,
+    output reg  [2:0]                   cycle_phase,
+    output wire                         busy
+);
+
+    localparam [1:0] CONTROL_MODE_SAFE_OFF = 2'd0;
+    localparam [1:0] CONTROL_MODE_HYSTERESIS_PI_DEFAULT = 2'd1;
+    localparam [1:0] CONTROL_MODE_MANUAL_LEVEL = 2'd2;
+    localparam [1:0] CONTROL_MODE_INCREMENTAL_PID_EXPERIMENTAL = 2'd3;
+
+    wire sched_ready;
+    wire sched_valid;
+    wire [CHW-1:0] sched_channel;
+    wire signed [DW-1:0] sched_error_q;
+    wire signed [DW-1:0] sched_ctrl_q;
+    wire sched_done;
+    wire sched_fault;
+    wire [15:0] sched_sample_seq;
+    wire signed [DW-1:0] sched_ctrl_prev_q;
+    wire signed [DW-1:0] sched_delta_q;
+    wire sched_clamped;
+    wire sched_history_cleared;
+    wire [1:0] sched_state;
+    wire [2:0] sched_cycle_phase;
+    wire sched_busy;
+
+    pid_24ch_scheduler #(
+        .DW(DW),
+        .CHW(CHW),
+        .CHANNEL_COUNT(CHANNEL_COUNT),
+        .OUT_MIN(OUT_MIN),
+        .OUT_MAX(OUT_MAX)
+    ) u_incremental_scheduler (
+        .clk(clk),
+        .rst_n(rst_n),
+        .sensor_valid(sensor_valid && control_mode == CONTROL_MODE_INCREMENTAL_PID_EXPERIMENTAL),
+        .sensor_ready(sched_ready),
+        .sensor_fault(sensor_fault),
+        .sensor_channel(sensor_channel),
+        .sensor_temp_q(sensor_temp_q),
+        .sensor_sample_seq(sensor_sample_seq),
+        .host_enable(host_enable),
+        .host_target_q(host_target_q),
+        .host_a0(host_a0),
+        .host_a1(host_a1),
+        .host_a2(host_a2),
+        .host_mode(control_mode),
+        .host_config_seq(host_config_seq),
+        .clear_history_all(clear_history_all),
+        .pid_valid(sched_valid),
+        .pid_channel(sched_channel),
+        .pid_error_q(sched_error_q),
+        .pid_ctrl_q(sched_ctrl_q),
+        .pid_done(sched_done),
+        .pid_fault(sched_fault),
+        .pid_sample_seq(sched_sample_seq),
+        .pid_ctrl_prev_q(sched_ctrl_prev_q),
+        .pid_delta_q(sched_delta_q),
+        .pid_clamped(sched_clamped),
+        .pid_history_cleared(sched_history_cleared),
+        .pid_state(sched_state),
+        .pid_cycle_phase(sched_cycle_phase),
+        .busy(sched_busy)
+    );
+
+    localparam S_IDLE = 2'd0;
+    localparam S_UPDATE = 2'd1;
+
+    reg [1:0] local_state;
+    reg signed [DW-1:0] integral_mem [0:CHANNEL_COUNT-1];
+    reg [CHW-1:0] active_channel;
+    reg [15:0] active_sample_seq;
+    reg signed [DW-1:0] active_error;
+    reg active_fault;
+    reg active_host_enable;
+    reg [1:0] active_mode;
+    reg signed [DW-1:0] active_manual_level;
+    reg signed [(2*DW):0] raw_ctrl;
+    reg signed [DW-1:0] next_integral;
+    integer i;
+
+    assign sensor_ready = (control_mode == CONTROL_MODE_INCREMENTAL_PID_EXPERIMENTAL) ? sched_ready : (local_state == S_IDLE);
+    assign busy = (control_mode == CONTROL_MODE_INCREMENTAL_PID_EXPERIMENTAL) ? sched_busy : (local_state != S_IDLE);
+    assign state = (control_mode == CONTROL_MODE_INCREMENTAL_PID_EXPERIMENTAL) ? sched_state : local_state;
+
+    function signed [DW-1:0] clamp_output;
+        input signed [(2*DW):0] value;
+        begin
+            if (value > $signed(POWER_LIMIT)) begin
+                clamp_output = POWER_LIMIT;
+            end else if (value > $signed(OUT_MAX)) begin
+                clamp_output = OUT_MAX;
+            end else if (value < $signed(OUT_MIN)) begin
+                clamp_output = OUT_MIN;
+            end else begin
+                clamp_output = value[DW-1:0];
+            end
+        end
+    endfunction
+
+    function signed [DW-1:0] clamp_hard_output;
+        input signed [(2*DW):0] value;
+        begin
+            if (value > $signed(OUT_MAX)) begin
+                clamp_hard_output = OUT_MAX;
+            end else if (value < $signed(OUT_MIN)) begin
+                clamp_hard_output = OUT_MIN;
+            end else begin
+                clamp_hard_output = value[DW-1:0];
+            end
+        end
+    endfunction
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            local_state <= S_IDLE;
+            active_channel <= {CHW{1'b0}};
+            active_sample_seq <= 16'd0;
+            active_error <= {DW{1'b0}};
+            active_fault <= 1'b0;
+            active_host_enable <= 1'b0;
+            active_mode <= CONTROL_MODE_SAFE_OFF;
+            active_manual_level <= {DW{1'b0}};
+            raw_ctrl <= {(2*DW+1){1'b0}};
+            next_integral <= {DW{1'b0}};
+            result_valid <= 1'b0;
+            result_channel <= {CHW{1'b0}};
+            result_error_q <= {DW{1'b0}};
+            result_ctrl_q <= {DW{1'b0}};
+            result_fault <= 1'b0;
+            result_sample_seq <= 16'd0;
+            result_control_mode <= CONTROL_MODE_SAFE_OFF;
+            result_experimental <= 1'b0;
+            result_clamped <= 1'b0;
+            result_history_cleared <= 1'b0;
+            cycle_phase <= 3'd0;
+            for (i = 0; i < CHANNEL_COUNT; i = i + 1) begin
+                integral_mem[i] <= {DW{1'b0}};
+            end
+        end else begin
+            result_valid <= 1'b0;
+            result_clamped <= 1'b0;
+            result_history_cleared <= 1'b0;
+            cycle_phase <= 3'd0;
+
+            if (control_mode == CONTROL_MODE_INCREMENTAL_PID_EXPERIMENTAL) begin
+                if (sched_valid) begin
+                    result_valid <= sched_valid;
+                    result_channel <= sched_channel;
+                    result_error_q <= sched_error_q;
+                    result_ctrl_q <= sched_ctrl_q;
+                    result_fault <= sched_fault;
+                    result_sample_seq <= sched_sample_seq;
+                    result_control_mode <= CONTROL_MODE_INCREMENTAL_PID_EXPERIMENTAL;
+                    result_experimental <= 1'b1;
+                    result_clamped <= sched_clamped;
+                    result_history_cleared <= sched_history_cleared;
+                    cycle_phase <= sched_cycle_phase;
+                end
+            end else if (clear_history_all) begin
+                for (i = 0; i < CHANNEL_COUNT; i = i + 1) begin
+                    integral_mem[i] <= {DW{1'b0}};
+                end
+                result_history_cleared <= 1'b1;
+                local_state <= S_IDLE;
+            end else begin
+                case (local_state)
+                    S_IDLE: begin
+                        if (sensor_valid && sensor_ready) begin
+                            active_channel <= sensor_channel;
+                            active_sample_seq <= sensor_sample_seq;
+                            active_error <= host_target_q - sensor_temp_q;
+                            active_fault <= sensor_fault | (sensor_channel >= CHANNEL_COUNT);
+                            active_host_enable <= host_enable;
+                            active_mode <= control_mode;
+                            active_manual_level <= manual_level_q;
+                            cycle_phase <= 3'd1;
+                            local_state <= S_UPDATE;
+                        end
+                    end
+
+                    S_UPDATE: begin
+                        result_valid <= 1'b1;
+                        result_channel <= active_channel;
+                        result_sample_seq <= active_sample_seq;
+                        result_error_q <= active_error;
+                        result_fault <= active_fault;
+                        result_control_mode <= active_mode;
+                        result_experimental <= 1'b0;
+                        cycle_phase <= 3'd3;
+                        if (active_fault || !active_host_enable || active_mode == CONTROL_MODE_SAFE_OFF) begin
+                            result_ctrl_q <= {DW{1'b0}};
+                            if (active_channel < CHANNEL_COUNT) begin
+                                integral_mem[active_channel] <= {DW{1'b0}};
+                            end
+                            result_history_cleared <= 1'b1;
+                        end else if (active_mode == CONTROL_MODE_MANUAL_LEVEL) begin
+                            result_ctrl_q <= clamp_hard_output(active_manual_level);
+                            result_clamped <= active_manual_level != clamp_hard_output(active_manual_level);
+                        end else begin
+                            if (active_error <= -TARGET_TOLERANCE_Q) begin
+                                result_ctrl_q <= {DW{1'b0}};
+                                integral_mem[active_channel] <= {DW{1'b0}};
+                                result_clamped <= 1'b1;
+                                result_history_cleared <= 1'b1;
+                            end else begin
+                                if (active_error >= TARGET_TOLERANCE_Q) begin
+                                    next_integral = integral_mem[active_channel] + active_error;
+                                    raw_ctrl = ($signed(KP_Q) * $signed(active_error)) + ($signed(KI_Q) * $signed(next_integral));
+                                end else begin
+                                    next_integral = integral_mem[active_channel];
+                                    if (active_error > 0) begin
+                                        next_integral = integral_mem[active_channel] + active_error;
+                                    end
+                                    raw_ctrl = $signed(KI_Q) * $signed(next_integral);
+                                end
+                                integral_mem[active_channel] <= next_integral;
+                                result_ctrl_q <= clamp_output(raw_ctrl);
+                                result_clamped <= (raw_ctrl > $signed(POWER_LIMIT)) ||
+                                                  (raw_ctrl > $signed(OUT_MAX)) ||
+                                                  (raw_ctrl < $signed(OUT_MIN));
+                            end
+                        end
+                        local_state <= S_IDLE;
+                    end
+
+                    default: begin
+                        local_state <= S_IDLE;
+                    end
+                endcase
+            end
+        end
+    end
+
+endmodule

+ 45 - 0
src/rtl/debug_probe_bus.v

@@ -0,0 +1,45 @@
+`timescale 1ns/1ps
+
+module debug_probe_bus #(
+    parameter integer DW = 18
+) (
+    input  wire        sensor_valid,
+    input  wire        sensor_ready,
+    input  wire [2:0]  source_select,
+    input  wire [2:0]  sensor_source_id,
+    input  wire [4:0]  channel,
+    input  wire [2:0]  pid_cycle_phase,
+    input  wire [1:0]  pid_state,
+    input  wire        pid_done,
+    input  wire        pid_fault,
+    input  wire [3:0]  fault_code,
+    input  wire [3:0]  force_off_reason,
+    input  wire [23:0] ptc_pwm_out,
+    input  wire [5:0]  fan_pwm_drive_low,
+    input  wire [15:0] tach_window_edges,
+    input  wire [15:0] rpm_estimate,
+    input  wire [DW-1:0] ctrl_q,
+    output wire [127:0] probe_bus
+);
+
+    assign probe_bus = {
+        22'd0,
+        rpm_estimate,
+        tach_window_edges,
+        fan_pwm_drive_low,
+        ptc_pwm_out,
+        ctrl_q[15:0],
+        force_off_reason,
+        fault_code,
+        pid_fault,
+        pid_done,
+        pid_state,
+        pid_cycle_phase,
+        channel,
+        sensor_source_id,
+        source_select,
+        sensor_ready,
+        sensor_valid
+    };
+
+endmodule

+ 51 - 0
src/rtl/debug_register_window.v

@@ -0,0 +1,51 @@
+`timescale 1ns/1ps
+
+module debug_register_window (
+    input  wire [7:0]  reg_addr,
+    input  wire [15:0] trace_seq,
+    input  wire [15:0] event_count,
+    input  wire [7:0]  write_ptr,
+    input  wire        frozen,
+    input  wire        overflow,
+    input  wire [3:0]  last_event_type,
+    input  wire [3:0]  last_fault_code,
+    input  wire [3:0]  last_force_off_reason,
+    input  wire [4:0]  last_channel,
+    input  wire [2:0]  last_source_id,
+    input  wire [23:0] last_ptc_pwm_bitmap,
+    input  wire [5:0]  last_fan_pwm_drive_low,
+    input  wire [31:0] trace_read_data,
+    output reg         hit,
+    output reg  [7:0]  reg_data
+);
+
+    always @(*) begin
+        hit = 1'b1;
+        case (reg_addr)
+            8'h80: reg_data = trace_seq[7:0];
+            8'h81: reg_data = trace_seq[15:8];
+            8'h82: reg_data = event_count[7:0];
+            8'h83: reg_data = event_count[15:8];
+            8'h84: reg_data = {6'd0, overflow, frozen};
+            8'h85: reg_data = {4'd0, last_event_type};
+            8'h86: reg_data = {4'd0, last_fault_code};
+            8'h87: reg_data = {4'd0, last_force_off_reason};
+            8'h88: reg_data = {3'd0, last_channel};
+            8'h89: reg_data = {5'd0, last_source_id};
+            8'h8a: reg_data = last_ptc_pwm_bitmap[7:0];
+            8'h8b: reg_data = last_ptc_pwm_bitmap[15:8];
+            8'h8c: reg_data = last_ptc_pwm_bitmap[23:16];
+            8'h8d: reg_data = {2'd0, last_fan_pwm_drive_low};
+            8'h8e: reg_data = write_ptr;
+            8'h90: reg_data = trace_read_data[7:0];
+            8'h91: reg_data = trace_read_data[15:8];
+            8'h92: reg_data = trace_read_data[23:16];
+            8'h93: reg_data = trace_read_data[31:24];
+            default: begin
+                hit = 1'b0;
+                reg_data = 8'd0;
+            end
+        endcase
+    end
+
+endmodule

+ 145 - 0
src/rtl/debug_snapshot_v2.v

@@ -0,0 +1,145 @@
+`timescale 1ns/1ps
+
+module debug_snapshot_v2 #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5,
+    parameter integer FAN_COUNT = 6
+) (
+    input  wire                 clk,
+    input  wire                 rst_n,
+    input  wire [2:0]           sensor_source_id,
+    input  wire                 sensor_valid,
+    input  wire                 sensor_ready,
+    input  wire                 sensor_fault,
+    input  wire                 sensor_stale,
+    input  wire [CHW-1:0]       sensor_channel,
+    input  wire signed [DW-1:0] sensor_temp_q,
+    input  wire [15:0]          sensor_sample_seq,
+    input  wire                 host_enable,
+    input  wire [15:0]          host_config_seq,
+    input  wire signed [DW-1:0] pid_error_q,
+    input  wire signed [DW-1:0] pid_ctrl_q,
+    input  wire                 pid_done,
+    input  wire                 pid_fault,
+    input  wire                 global_enable,
+    input  wire                 fault_latched,
+    input  wire [3:0]           fault_code,
+    input  wire                 ptc_enable,
+    input  wire [DW-1:0]        ptc_duty_or_level,
+    input  wire                 ptc_force_off,
+    input  wire [3:0]           ptc_reason,
+    input  wire                 fan_enable,
+    input  wire [DW-1:0]        fan_duty_or_level,
+    input  wire [23:0]          ptc_pwm_out,
+    input  wire [FAN_COUNT-1:0] fan_pwm_logic_high,
+    input  wire [FAN_COUNT-1:0] fan_pwm_drive_low,
+    input  wire [15:0]          fan_tach_count,
+    input  wire [15:0]          fan_tach_window_edges,
+    input  wire [15:0]          fan_rpm_estimate,
+    input  wire                 motor_enable,
+    input  wire [1:0]           motor_dir,
+    output reg  [15:0]          trace_seq,
+    output reg  [2:0]           snap_source_id,
+    output reg                  snap_sensor_valid,
+    output reg                  snap_sensor_ready,
+    output reg                  snap_sensor_fault,
+    output reg                  snap_sensor_stale,
+    output reg  [CHW-1:0]       snap_channel,
+    output reg  signed [DW-1:0] snap_temp_q,
+    output reg  [15:0]          snap_sample_seq,
+    output reg                  snap_host_enable,
+    output reg  [15:0]          snap_config_seq,
+    output reg  signed [DW-1:0] snap_pid_error_q,
+    output reg  signed [DW-1:0] snap_pid_ctrl_q,
+    output reg                  snap_pid_done,
+    output reg                  snap_pid_fault,
+    output reg                  snap_global_enable,
+    output reg                  snap_fault_latched,
+    output reg  [3:0]           snap_fault_code,
+    output reg                  snap_ptc_enable,
+    output reg  [DW-1:0]        snap_ptc_duty_or_level,
+    output reg                  snap_ptc_force_off,
+    output reg  [3:0]           snap_ptc_reason,
+    output reg                  snap_fan_enable,
+    output reg  [DW-1:0]        snap_fan_duty_or_level,
+    output reg  [23:0]          snap_ptc_pwm_out,
+    output reg  [FAN_COUNT-1:0] snap_fan_pwm_logic_high,
+    output reg  [FAN_COUNT-1:0] snap_fan_pwm_drive_low,
+    output reg  [15:0]          snap_fan_tach_count,
+    output reg  [15:0]          snap_fan_tach_window_edges,
+    output reg  [15:0]          snap_fan_rpm_estimate,
+    output reg                  snap_motor_enable,
+    output reg  [1:0]           snap_motor_dir
+);
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            trace_seq <= 16'd0;
+            snap_source_id <= 3'd0;
+            snap_sensor_valid <= 1'b0;
+            snap_sensor_ready <= 1'b0;
+            snap_sensor_fault <= 1'b0;
+            snap_sensor_stale <= 1'b0;
+            snap_channel <= {CHW{1'b0}};
+            snap_temp_q <= {DW{1'b0}};
+            snap_sample_seq <= 16'd0;
+            snap_host_enable <= 1'b0;
+            snap_config_seq <= 16'd0;
+            snap_pid_error_q <= {DW{1'b0}};
+            snap_pid_ctrl_q <= {DW{1'b0}};
+            snap_pid_done <= 1'b0;
+            snap_pid_fault <= 1'b0;
+            snap_global_enable <= 1'b0;
+            snap_fault_latched <= 1'b0;
+            snap_fault_code <= 4'd0;
+            snap_ptc_enable <= 1'b0;
+            snap_ptc_duty_or_level <= {DW{1'b0}};
+            snap_ptc_force_off <= 1'b1;
+            snap_ptc_reason <= 4'd1;
+            snap_fan_enable <= 1'b0;
+            snap_fan_duty_or_level <= {DW{1'b0}};
+            snap_ptc_pwm_out <= 24'd0;
+            snap_fan_pwm_logic_high <= {FAN_COUNT{1'b0}};
+            snap_fan_pwm_drive_low <= {FAN_COUNT{1'b0}};
+            snap_fan_tach_count <= 16'd0;
+            snap_fan_tach_window_edges <= 16'd0;
+            snap_fan_rpm_estimate <= 16'd0;
+            snap_motor_enable <= 1'b0;
+            snap_motor_dir <= 2'd0;
+        end else begin
+            trace_seq <= trace_seq + 16'd1;
+            snap_source_id <= sensor_source_id;
+            snap_sensor_valid <= sensor_valid;
+            snap_sensor_ready <= sensor_ready;
+            snap_sensor_fault <= sensor_fault;
+            snap_sensor_stale <= sensor_stale;
+            snap_channel <= sensor_channel;
+            snap_temp_q <= sensor_temp_q;
+            snap_sample_seq <= sensor_sample_seq;
+            snap_host_enable <= host_enable;
+            snap_config_seq <= host_config_seq;
+            snap_pid_error_q <= pid_error_q;
+            snap_pid_ctrl_q <= pid_ctrl_q;
+            snap_pid_done <= pid_done;
+            snap_pid_fault <= pid_fault;
+            snap_global_enable <= global_enable;
+            snap_fault_latched <= fault_latched;
+            snap_fault_code <= fault_code;
+            snap_ptc_enable <= ptc_enable;
+            snap_ptc_duty_or_level <= ptc_duty_or_level;
+            snap_ptc_force_off <= ptc_force_off;
+            snap_ptc_reason <= ptc_reason;
+            snap_fan_enable <= fan_enable;
+            snap_fan_duty_or_level <= fan_duty_or_level;
+            snap_ptc_pwm_out <= ptc_pwm_out;
+            snap_fan_pwm_logic_high <= fan_pwm_logic_high;
+            snap_fan_pwm_drive_low <= fan_pwm_drive_low;
+            snap_fan_tach_count <= fan_tach_count;
+            snap_fan_tach_window_edges <= fan_tach_window_edges;
+            snap_fan_rpm_estimate <= fan_rpm_estimate;
+            snap_motor_enable <= motor_enable;
+            snap_motor_dir <= motor_dir;
+        end
+    end
+
+endmodule

+ 66 - 0
src/rtl/debug_trace_recorder_bram.v

@@ -0,0 +1,66 @@
+`timescale 1ns/1ps
+
+module debug_trace_recorder_bram #(
+    parameter integer DEPTH = 64,
+    parameter integer ADDR_W = 6,
+    parameter integer EVENT_WIDTH = 128
+) (
+    input  wire                   clk,
+    input  wire                   rst_n,
+    input  wire                   clear,
+    input  wire                   write_valid,
+    input  wire [EVENT_WIDTH-1:0] event_data,
+    input  wire                   trigger_freeze,
+    input  wire [ADDR_W-1:0]      read_addr,
+    output wire [EVENT_WIDTH-1:0] read_data,
+    output reg  [ADDR_W-1:0]      write_ptr,
+    output reg  [ADDR_W:0]        write_count,
+    output reg                    frozen,
+    output reg                    overflow
+);
+
+    reg [EVENT_WIDTH-1:0] mem [0:DEPTH-1];
+    integer i;
+    localparam [ADDR_W-1:0] LAST_ADDR = DEPTH - 1;
+    localparam [ADDR_W:0] DEPTH_COUNT = DEPTH;
+
+    assign read_data = (read_addr < DEPTH) ? mem[read_addr] : {EVENT_WIDTH{1'b0}};
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            write_ptr <= {ADDR_W{1'b0}};
+            write_count <= {(ADDR_W+1){1'b0}};
+            frozen <= 1'b0;
+            overflow <= 1'b0;
+            for (i = 0; i < DEPTH; i = i + 1) begin
+                mem[i] <= {EVENT_WIDTH{1'b0}};
+            end
+        end else if (clear) begin
+            write_ptr <= {ADDR_W{1'b0}};
+            write_count <= {(ADDR_W+1){1'b0}};
+            frozen <= 1'b0;
+            overflow <= 1'b0;
+            for (i = 0; i < DEPTH; i = i + 1) begin
+                mem[i] <= {EVENT_WIDTH{1'b0}};
+            end
+        end else begin
+            if (trigger_freeze) begin
+                frozen <= 1'b1;
+            end
+            if (write_valid && !frozen && !trigger_freeze) begin
+                mem[write_ptr] <= event_data;
+                if (write_ptr == LAST_ADDR) begin
+                    write_ptr <= {ADDR_W{1'b0}};
+                end else begin
+                    write_ptr <= write_ptr + {{(ADDR_W-1){1'b0}}, 1'b1};
+                end
+                if (write_count < DEPTH_COUNT) begin
+                    write_count <= write_count + {{ADDR_W{1'b0}}, 1'b1};
+                end else begin
+                    overflow <= 1'b1;
+                end
+            end
+        end
+    end
+
+endmodule

+ 35 - 0
src/rtl/debug_trigger_unit.v

@@ -0,0 +1,35 @@
+`timescale 1ns/1ps
+
+module debug_trigger_unit (
+    input  wire       event_valid,
+    input  wire [3:0] event_type,
+    input  wire [3:0] fault_code,
+    input  wire [4:0] channel,
+    input  wire [2:0] source_id,
+    input  wire [2:0] state,
+    input  wire       manual_trigger,
+    input  wire       trigger_on_fault,
+    input  wire       trigger_on_force_off,
+    input  wire       trigger_channel_enable,
+    input  wire [4:0] trigger_channel,
+    input  wire       trigger_source_enable,
+    input  wire [2:0] trigger_source_id,
+    input  wire       trigger_state_enable,
+    input  wire [2:0] trigger_state,
+    output wire       trigger_hit,
+    output wire       freeze_capture
+);
+
+    localparam [3:0] EVENT_FORCE_OFF = 4'd5;
+
+    wire fault_match = trigger_on_fault && event_valid && (fault_code != 4'd0);
+    wire force_off_match = trigger_on_force_off && event_valid && (event_type == EVENT_FORCE_OFF);
+    wire channel_match = (!trigger_channel_enable) || (channel == trigger_channel);
+    wire source_match = (!trigger_source_enable) || (source_id == trigger_source_id);
+    wire state_match = (!trigger_state_enable) || (state == trigger_state);
+    wire qualified_match = event_valid && channel_match && source_match && state_match;
+
+    assign trigger_hit = manual_trigger || fault_match || force_off_match || qualified_match;
+    assign freeze_capture = trigger_hit;
+
+endmodule

+ 122 - 0
src/rtl/debug_uart_stream.v

@@ -0,0 +1,122 @@
+`timescale 1ns/1ps
+
+module debug_uart_stream #(
+    parameter integer CLKS_PER_BIT = 217,
+    parameter integer PAYLOAD_BYTES = 4,
+    parameter integer EVENT_WIDTH = 32
+) (
+    input  wire                   clk,
+    input  wire                   rst_n,
+    input  wire                   event_valid,
+    input  wire [EVENT_WIDTH-1:0] event_data,
+    output reg                    tx,
+    output reg                    busy,
+    output reg                    overflow,
+    output reg  [15:0]            frame_seq
+);
+
+    localparam integer TOTAL_BYTES = PAYLOAD_BYTES + 5;
+    localparam [7:0] SOF0 = 8'ha5;
+    localparam [7:0] SOF1 = 8'h5a;
+
+    reg [7:0] frame [0:TOTAL_BYTES-1];
+    reg [7:0] current_byte;
+    reg [3:0] bit_index;
+    reg [7:0] byte_index;
+    reg [15:0] clk_count;
+    reg [1:0] phase;
+    reg [7:0] checksum;
+    reg [15:0] next_frame_seq;
+    integer i;
+
+    localparam [1:0] PH_START = 2'd0;
+    localparam [1:0] PH_DATA = 2'd1;
+    localparam [1:0] PH_STOP = 2'd2;
+
+    function [7:0] event_byte;
+        input integer index;
+        begin
+            case (index)
+                0: event_byte = event_data[7:0];
+                1: event_byte = event_data[15:8];
+                2: event_byte = event_data[23:16];
+                3: event_byte = event_data[31:24];
+                default: event_byte = 8'd0;
+            endcase
+        end
+    endfunction
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            tx <= 1'b1;
+            busy <= 1'b0;
+            overflow <= 1'b0;
+            frame_seq <= 16'd0;
+            current_byte <= 8'd0;
+            bit_index <= 4'd0;
+            byte_index <= 8'd0;
+            clk_count <= 16'd0;
+            phase <= PH_START;
+            checksum <= 8'd0;
+            for (i = 0; i < TOTAL_BYTES; i = i + 1) begin
+                frame[i] <= 8'd0;
+            end
+        end else begin
+            if (event_valid && busy) begin
+                overflow <= 1'b1;
+            end
+
+            if (event_valid && !busy) begin
+                next_frame_seq = frame_seq + 16'd1;
+                frame_seq <= next_frame_seq;
+                frame[0] <= SOF0;
+                frame[1] <= SOF1;
+                frame[2] <= next_frame_seq[7:0];
+                frame[3] <= next_frame_seq[15:8];
+                checksum = SOF0 ^ SOF1 ^ next_frame_seq[7:0] ^ next_frame_seq[15:8];
+                for (i = 0; i < PAYLOAD_BYTES; i = i + 1) begin
+                    frame[4 + i] <= event_byte(i);
+                    checksum = checksum ^ event_byte(i);
+                end
+                frame[TOTAL_BYTES-1] <= checksum;
+                current_byte <= SOF0;
+                byte_index <= 8'd0;
+                bit_index <= 4'd0;
+                clk_count <= 16'd0;
+                phase <= PH_START;
+                busy <= 1'b1;
+                tx <= 1'b0;
+            end else if (busy) begin
+                if (clk_count == CLKS_PER_BIT[15:0] - 16'd1) begin
+                    clk_count <= 16'd0;
+                    if (phase == PH_START) begin
+                        phase <= PH_DATA;
+                        bit_index <= 4'd0;
+                        tx <= current_byte[0];
+                    end else if (phase == PH_DATA) begin
+                        if (bit_index == 4'd7) begin
+                            phase <= PH_STOP;
+                            tx <= 1'b1;
+                        end else begin
+                            bit_index <= bit_index + 4'd1;
+                            tx <= current_byte[bit_index + 4'd1];
+                        end
+                    end else begin
+                        if (byte_index == TOTAL_BYTES[7:0] - 8'd1) begin
+                            busy <= 1'b0;
+                            tx <= 1'b1;
+                        end else begin
+                            byte_index <= byte_index + 8'd1;
+                            current_byte <= frame[byte_index + 8'd1];
+                            phase <= PH_START;
+                            tx <= 1'b0;
+                        end
+                    end
+                end else begin
+                    clk_count <= clk_count + 16'd1;
+                end
+            end
+        end
+    end
+
+endmodule

+ 54 - 0
src/rtl/fake_host_config.v

@@ -0,0 +1,54 @@
+`timescale 1ns/1ps
+
+module fake_host_config #(
+    parameter integer DW = 18
+) (
+    input  wire                 clk,
+    input  wire                 rst_n,
+    input  wire [15:0]          sample_seq,
+    output reg                  host_enable,
+    output reg  signed [DW-1:0] host_target_q,
+    output reg  signed [DW-1:0] host_a0,
+    output reg  signed [DW-1:0] host_a1,
+    output reg  signed [DW-1:0] host_a2,
+    output reg  [1:0]           host_mode,
+    output reg  [15:0]          host_config_seq
+);
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            host_enable <= 1'b1;
+            host_target_q <= 18'sd70;
+            host_a0 <= 18'sd4;
+            host_a1 <= -18'sd1;
+            host_a2 <= 18'sd1;
+            host_mode <= 2'd3;
+            host_config_seq <= 16'd1;
+        end else if (sample_seq >= 16'd27) begin
+            host_enable <= 1'b0;
+            host_target_q <= 18'sd70;
+            host_a0 <= 18'sd3;
+            host_a1 <= -18'sd1;
+            host_a2 <= 18'sd1;
+            host_mode <= 2'd3;
+            host_config_seq <= 16'd3;
+        end else if (sample_seq >= 16'd12) begin
+            host_enable <= 1'b1;
+            host_target_q <= 18'sd70;
+            host_a0 <= 18'sd3;
+            host_a1 <= -18'sd1;
+            host_a2 <= 18'sd1;
+            host_mode <= 2'd3;
+            host_config_seq <= 16'd2;
+        end else begin
+            host_enable <= 1'b1;
+            host_target_q <= 18'sd70;
+            host_a0 <= 18'sd4;
+            host_a1 <= -18'sd1;
+            host_a2 <= 18'sd1;
+            host_mode <= 2'd3;
+            host_config_seq <= 16'd1;
+        end
+    end
+
+endmodule

+ 158 - 0
src/rtl/fake_sensor_source.v

@@ -0,0 +1,158 @@
+`timescale 1ns/1ps
+
+module fake_sensor_source #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5,
+    parameter integer ADC_ZONE_COUNT = 4,
+    parameter integer CHANNEL_COUNT = 24
+) (
+    input  wire                 clk,
+    input  wire                 rst_n,
+    input  wire                 next_req,
+    input  wire                 sensor_ready,
+    output reg                  sensor_valid,
+    output reg                  sensor_fault,
+    output reg  [CHW-1:0]       sensor_channel,
+    output reg  signed [DW-1:0] sensor_temp_q,
+    output reg  [15:0]          sensor_sample_seq
+);
+
+    localparam [CHW-1:0] CHANNEL_COUNT_W = CHANNEL_COUNT[CHW-1:0];
+
+    reg [15:0] next_seq;
+    reg [CHW-1:0] replay_channel;
+    reg signed [DW-1:0] replay_temp_q;
+    reg replay_fault;
+    reg pending_valid;
+    reg replay_stale;
+    reg replay_missing;
+    reg [2:0] replay_phase;
+    reg [7:0] replay_raw_status;
+
+    wire unused_replay_stale = replay_stale;
+    wire unused_replay_missing = replay_missing;
+    wire [2:0] unused_replay_phase = replay_phase;
+    wire [7:0] unused_replay_raw_status = replay_raw_status;
+
+    task build_replay_sample;
+        input [15:0] seq;
+        output [CHW-1:0] channel;
+        output signed [DW-1:0] temp_q;
+        output fault;
+        output stale;
+        output missing;
+        output [2:0] phase;
+        output [7:0] raw_status;
+        reg [4:0] zero_based;
+        reg [4:0] zone_offset;
+        reg [15:0] long_index;
+        reg [3:0] noise_term;
+        begin
+            fault = 1'b0;
+            stale = 1'b0;
+            missing = 1'b0;
+            raw_status = 8'h10;
+            phase = seq[7:5];
+            long_index = seq - 16'd1;
+            if (seq >= 16'd1 && seq <= 16'd24) begin
+                zero_based = seq[4:0] - 5'd1;
+                channel = zero_based[CHW-1:0];
+                if (zero_based < 5'd6) begin
+                    zone_offset = zero_based;
+                    temp_q = 18'sd70 + $signed({13'd0, zone_offset});
+                end else if (zero_based < 5'd12) begin
+                    zone_offset = zero_based - 5'd6;
+                    temp_q = 18'sd78 + $signed({12'd0, zone_offset, 1'b0});
+                end else if (zero_based < 5'd18) begin
+                    zone_offset = zero_based - 5'd12;
+                    temp_q = 18'sd86 + $signed({12'd0, zone_offset, 1'b0}) + $signed({13'd0, zone_offset});
+                end else begin
+                    zone_offset = zero_based - 5'd18;
+                    temp_q = 18'sd94 + $signed({11'd0, zone_offset, 2'b00});
+                end
+            end else begin
+                channel = long_index[4:0];
+                if (channel >= CHANNEL_COUNT_W) begin
+                    channel = channel - CHANNEL_COUNT_W;
+                end
+                phase = long_index[7:5];
+                noise_term = {long_index[2:0], long_index[5]} ^ {long_index[6], long_index[4:2]};
+                case (phase)
+                    3'd0: begin
+                        temp_q = 18'sd66 + $signed({13'd0, channel});
+                    end
+                    3'd1: begin
+                        temp_q = 18'sd72 + $signed({12'd0, channel[3:0], 1'b0});
+                    end
+                    3'd2: begin
+                        temp_q = channel[0] ? 18'sd95 : 18'sd58;
+                    end
+                    3'd3: begin
+                        temp_q = 18'sd70 + $signed({14'd0, noise_term});
+                    end
+                    3'd4: begin
+                        missing = (channel == 5'd0) || (channel == 5'd5) || (channel == 5'd10);
+                        fault = missing;
+                        temp_q = missing ? 18'sd0 : 18'sd82;
+                        raw_status = missing ? 8'hff : 8'h10;
+                    end
+                    3'd5: begin
+                        stale = (channel[1:0] == 2'b00);
+                        temp_q = stale ? 18'sd89 : 18'sd76;
+                        raw_status = stale ? 8'h20 : 8'h10;
+                    end
+                    3'd6: begin
+                        fault = (channel == 5'd3);
+                        temp_q = fault ? 18'sd0 : 18'sd74;
+                        raw_status = fault ? 8'he1 : 8'h10;
+                    end
+                    default: begin
+                        temp_q = 18'sd62 + $signed({13'd0, long_index[4:0]});
+                    end
+                endcase
+            end
+        end
+    endtask
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            sensor_valid <= 1'b0;
+            sensor_fault <= 1'b0;
+            sensor_channel <= {CHW{1'b0}};
+            sensor_temp_q <= 18'sd70;
+            sensor_sample_seq <= 16'd0;
+            pending_valid <= 1'b0;
+        end else begin
+            if (pending_valid) begin
+                sensor_valid <= 1'b1;
+                if (sensor_ready) begin
+                    pending_valid <= 1'b0;
+                    sensor_valid <= 1'b0;
+                end
+            end else if (next_req) begin
+                next_seq = sensor_sample_seq + 16'd1;
+                build_replay_sample(
+                    next_seq,
+                    replay_channel,
+                    replay_temp_q,
+                    replay_fault,
+                    replay_stale,
+                    replay_missing,
+                    replay_phase,
+                    replay_raw_status
+                );
+                sensor_valid <= 1'b1;
+                sensor_fault <= replay_fault;
+                sensor_channel <= replay_channel;
+                sensor_temp_q <= replay_temp_q;
+                sensor_sample_seq <= next_seq;
+                if (!sensor_ready) begin
+                    pending_valid <= 1'b1;
+                end
+            end else begin
+                sensor_valid <= 1'b0;
+            end
+        end
+    end
+
+endmodule

+ 148 - 0
src/rtl/fan_tach_domain.v

@@ -0,0 +1,148 @@
+`timescale 1ns/1ps
+
+module fan_tach_domain #(
+    parameter integer DW = 18,
+    parameter integer FAN_COUNT = 6,
+    parameter [DW-1:0] FAN_BACKGROUND_LEVEL = 18'd38,
+    parameter [DW-1:0] FAN_FALLBACK_LEVEL = 18'd127,
+    parameter integer PWM_PERIOD_TICKS = 1000,
+    parameter integer PWM_COUNTER_WIDTH = 10,
+    parameter integer TACH_WINDOW_TICKS = 25000000,
+    parameter integer TACH_COUNTER_WIDTH = 25,
+    parameter integer TACH_PULSES_PER_REV = 2
+) (
+    input  wire                         clk,
+    input  wire                         rst_n,
+    input  wire                         global_enable,
+    input  wire                         fault_latched,
+    input  wire [3:0]                   fault_code,
+    input  wire [FAN_COUNT-1:0]         fan_tach_in,
+    output reg                          fan_enable,
+    output reg  [DW-1:0]                fan_duty_or_level,
+    output reg                          fan_force_off,
+    output reg  [3:0]                   fan_reason,
+    output reg  [FAN_COUNT-1:0]         fan_pwm_enable,
+    output reg  [FAN_COUNT-1:0]         fan_pwm_logic_high,
+    output reg  [FAN_COUNT-1:0]         fan_pwm_drive_low,
+    output reg  [FAN_COUNT*16-1:0]      fan_tach_count,
+    output reg  [FAN_COUNT*16-1:0]      fan_tach_window_edges,
+    output reg  [FAN_COUNT*16-1:0]      fan_rpm_estimate
+);
+
+    localparam [3:0] FAULT_OK = 4'd0;
+    localparam [3:0] FAULT_HOST_DISABLED = 4'd1;
+    localparam [3:0] FAULT_SENSOR_FAULT = 4'd2;
+    localparam [3:0] FAULT_SENSOR_STALE = 4'd3;
+    localparam [3:0] FAULT_HOST_TIMEOUT = 4'd4;
+    localparam [3:0] FAULT_OVERTEMP = 4'd5;
+    localparam [PWM_COUNTER_WIDTH-1:0] PWM_PERIOD_LIMIT = PWM_PERIOD_TICKS;
+    localparam [TACH_COUNTER_WIDTH-1:0] TACH_WINDOW_LIMIT = TACH_WINDOW_TICKS;
+
+    reg [FAN_COUNT-1:0] tach_prev;
+    reg [15:0] tach_mem [0:FAN_COUNT-1];
+    reg [15:0] tach_window_mem [0:FAN_COUNT-1];
+    reg [15:0] tach_window_last_mem [0:FAN_COUNT-1];
+    reg [15:0] rpm_mem [0:FAN_COUNT-1];
+    reg [PWM_COUNTER_WIDTH-1:0] pwm_counter;
+    reg [TACH_COUNTER_WIDTH-1:0] tach_window_counter;
+    reg [PWM_COUNTER_WIDTH-1:0] fan_high_ticks;
+    wire fan_fallback = (fault_latched || !global_enable) && (
+        fault_code == FAULT_SENSOR_FAULT ||
+        fault_code == FAULT_SENSOR_STALE ||
+        fault_code == FAULT_HOST_TIMEOUT ||
+        fault_code == FAULT_OVERTEMP
+    );
+    integer i;
+
+    always @(*) begin
+        for (i = 0; i < FAN_COUNT; i = i + 1) begin
+            fan_tach_count[(i*16) +: 16] = tach_mem[i];
+            fan_tach_window_edges[(i*16) +: 16] = tach_window_last_mem[i];
+            fan_rpm_estimate[(i*16) +: 16] = rpm_mem[i];
+        end
+    end
+
+    always @(*) begin
+        fan_high_ticks = {PWM_COUNTER_WIDTH{1'b0}};
+        if (fan_duty_or_level >= FAN_FALLBACK_LEVEL) begin
+            fan_high_ticks = PWM_PERIOD_LIMIT;
+        end else if (fan_duty_or_level != {DW{1'b0}}) begin
+            fan_high_ticks = (PWM_PERIOD_TICKS * fan_duty_or_level) / FAN_FALLBACK_LEVEL;
+        end
+        fan_pwm_logic_high = {FAN_COUNT{1'b0}};
+        fan_pwm_drive_low = {FAN_COUNT{1'b0}};
+        for (i = 0; i < FAN_COUNT; i = i + 1) begin
+            if (fan_pwm_enable[i] && fan_enable && !fan_force_off) begin
+                if (fan_high_ticks >= PWM_PERIOD_LIMIT) begin
+                    fan_pwm_logic_high[i] = 1'b1;
+                end else if (fan_high_ticks == {PWM_COUNTER_WIDTH{1'b0}}) begin
+                    fan_pwm_logic_high[i] = 1'b0;
+                end else begin
+                    fan_pwm_logic_high[i] = pwm_counter < fan_high_ticks;
+                end
+                fan_pwm_drive_low[i] = ~fan_pwm_logic_high[i];
+            end
+        end
+    end
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            tach_prev <= {FAN_COUNT{1'b0}};
+            pwm_counter <= {PWM_COUNTER_WIDTH{1'b0}};
+            tach_window_counter <= {TACH_COUNTER_WIDTH{1'b0}};
+            fan_enable <= 1'b0;
+            fan_duty_or_level <= {DW{1'b0}};
+            fan_force_off <= 1'b1;
+            fan_reason <= FAULT_HOST_DISABLED;
+            fan_pwm_enable <= {FAN_COUNT{1'b0}};
+            for (i = 0; i < FAN_COUNT; i = i + 1) begin
+                tach_mem[i] <= 16'd0;
+                tach_window_mem[i] <= 16'd0;
+                tach_window_last_mem[i] <= 16'd0;
+                rpm_mem[i] <= 16'd0;
+            end
+        end else begin
+            if (pwm_counter == PWM_PERIOD_LIMIT - {{(PWM_COUNTER_WIDTH-1){1'b0}}, 1'b1}) begin
+                pwm_counter <= {PWM_COUNTER_WIDTH{1'b0}};
+            end else begin
+                pwm_counter <= pwm_counter + {{(PWM_COUNTER_WIDTH-1){1'b0}}, 1'b1};
+            end
+
+            if (tach_window_counter == TACH_WINDOW_LIMIT - {{(TACH_COUNTER_WIDTH-1){1'b0}}, 1'b1}) begin
+                tach_window_counter <= {TACH_COUNTER_WIDTH{1'b0}};
+                for (i = 0; i < FAN_COUNT; i = i + 1) begin
+                    tach_window_last_mem[i] <= tach_window_mem[i];
+                    rpm_mem[i] <= (tach_window_mem[i] * 16'd60) / TACH_PULSES_PER_REV;
+                    tach_window_mem[i] <= 16'd0;
+                end
+            end else begin
+                tach_window_counter <= tach_window_counter + {{(TACH_COUNTER_WIDTH-1){1'b0}}, 1'b1};
+            end
+
+            tach_prev <= fan_tach_in;
+            for (i = 0; i < FAN_COUNT; i = i + 1) begin
+                if (!tach_prev[i] && fan_tach_in[i] && tach_mem[i] != 16'hffff) begin
+                    tach_mem[i] <= tach_mem[i] + 16'd1;
+                    if (tach_window_mem[i] != 16'hffff) begin
+                        tach_window_mem[i] <= tach_window_mem[i] + 16'd1;
+                    end
+                end
+            end
+
+            if (fan_fallback) begin
+                fan_enable <= 1'b1;
+                fan_duty_or_level <= FAN_FALLBACK_LEVEL;
+                fan_force_off <= 1'b0;
+                fan_reason <= fault_code;
+                fan_pwm_enable <= {FAN_COUNT{1'b1}};
+            end else begin
+                fan_enable <= 1'b1;
+                fan_duty_or_level <= FAN_BACKGROUND_LEVEL;
+                fan_force_off <= 1'b0;
+                fan_reason <= FAULT_OK;
+                fan_pwm_enable <= {FAN_COUNT{1'b1}};
+            end
+        end
+    end
+
+endmodule

+ 131 - 0
src/rtl/host_command_plane.v

@@ -0,0 +1,131 @@
+`timescale 1ns/1ps
+
+module host_command_plane #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5
+) (
+    input  wire                 clk,
+    input  wire                 rst_n,
+    input  wire                 reg_wr_valid,
+    input  wire [7:0]           reg_wr_addr,
+    input  wire [7:0]           reg_wr_data,
+    input  wire                 reg_rd_valid,
+    input  wire [7:0]           reg_rd_addr,
+    output wire [7:0]           reg_rd_data,
+    output wire                 host_enable,
+    output wire signed [DW-1:0] host_target_q,
+    output wire signed [DW-1:0] host_a0,
+    output wire signed [DW-1:0] host_a1,
+    output wire signed [DW-1:0] host_a2,
+    output wire [1:0]           host_mode,
+    output wire [15:0]          host_config_seq,
+    output wire                 host_watchdog_kick,
+    output wire                 manual_override,
+    output wire [2:0]           source_select,
+    output wire                 clear_fault_latch,
+    output wire                 clear_history_all,
+    input  wire                 slave_sensor_ready,
+    output wire                 slave_sample_valid,
+    output wire                 slave_sample_fault,
+    output wire [CHW-1:0]       slave_sample_channel,
+    output wire signed [DW-1:0] slave_sample_temp_q,
+    output wire [15:0]          slave_sample_seq,
+    input  wire                 sensor_ready,
+    input  wire                 pid_busy,
+    input  wire                 master_fault,
+    input  wire                 slave_fault,
+    input  wire                 fault_latched,
+    input  wire                 force_off_latched,
+    input  wire [2:0]           debug_source_id,
+    input  wire [2:0]           debug_cycle_phase,
+    input  wire [1:0]           debug_state,
+    input  wire [15:0]          debug_sample_seq,
+    input  wire [15:0]          debug_config_seq,
+    input  wire [CHW-1:0]       debug_channel,
+    input  wire                 debug_clamped,
+    input  wire                 debug_history_cleared,
+    input  wire                 debug_reset_seen,
+    input  wire                 pid_valid,
+    input  wire [CHW-1:0]       pid_channel,
+    input  wire [15:0]          pid_sample_seq,
+    input  wire signed [DW-1:0] pid_error_q,
+    input  wire signed [DW-1:0] pid_ctrl_q,
+    input  wire                 pid_done,
+    input  wire                 pid_fault,
+    input  wire                 act_enable,
+    input  wire [CHW-1:0]       act_channel,
+    input  wire [DW-1:0]        act_duty_or_level,
+    input  wire                 act_force_off,
+    input  wire [1:0]           act_reason,
+    input  wire [23:0]          ptc_pwm_out,
+    input  wire [5:0]           fan_pwm_logic_high,
+    input  wire [5:0]           fan_pwm_drive_low,
+    input  wire [15:0]          fan_tach_count,
+    input  wire [15:0]          fan_tach_window_edges,
+    input  wire [15:0]          fan_rpm_estimate
+);
+
+    pid_control_regfile u_pid_control_regfile (
+        .clk(clk),
+        .rst_n(rst_n),
+        .reg_wr_valid(reg_wr_valid),
+        .reg_wr_addr(reg_wr_addr),
+        .reg_wr_data(reg_wr_data),
+        .reg_rd_valid(reg_rd_valid),
+        .reg_rd_addr(reg_rd_addr),
+        .reg_rd_data(reg_rd_data),
+        .host_enable(host_enable),
+        .host_target_q(host_target_q),
+        .host_a0(host_a0),
+        .host_a1(host_a1),
+        .host_a2(host_a2),
+        .host_mode(host_mode),
+        .host_config_seq(host_config_seq),
+        .source_select(source_select),
+        .clear_fault_latch(clear_fault_latch),
+        .clear_history_all(clear_history_all),
+        .slave_sensor_ready(slave_sensor_ready),
+        .slave_sample_valid(slave_sample_valid),
+        .slave_sample_fault(slave_sample_fault),
+        .slave_sample_channel(slave_sample_channel),
+        .slave_sample_temp_q(slave_sample_temp_q),
+        .slave_sample_seq(slave_sample_seq),
+        .sensor_ready(sensor_ready),
+        .pid_busy(pid_busy),
+        .master_fault(master_fault),
+        .slave_fault(slave_fault),
+        .fault_latched(fault_latched),
+        .force_off_latched(force_off_latched),
+        .debug_source_id(debug_source_id),
+        .debug_cycle_phase(debug_cycle_phase),
+        .debug_state(debug_state),
+        .debug_sample_seq(debug_sample_seq),
+        .debug_config_seq(debug_config_seq),
+        .debug_channel(debug_channel),
+        .debug_clamped(debug_clamped),
+        .debug_history_cleared(debug_history_cleared),
+        .debug_reset_seen(debug_reset_seen),
+        .pid_valid(pid_valid),
+        .pid_channel(pid_channel),
+        .pid_sample_seq(pid_sample_seq),
+        .pid_error_q(pid_error_q),
+        .pid_ctrl_q(pid_ctrl_q),
+        .pid_done(pid_done),
+        .pid_fault(pid_fault),
+        .act_enable(act_enable),
+        .act_channel(act_channel),
+        .act_duty_or_level(act_duty_or_level),
+        .act_force_off(act_force_off),
+        .act_reason(act_reason),
+        .ptc_pwm_out(ptc_pwm_out),
+        .fan_pwm_logic_high(fan_pwm_logic_high),
+        .fan_pwm_drive_low(fan_pwm_drive_low),
+        .fan_tach_count(fan_tach_count),
+        .fan_tach_window_edges(fan_tach_window_edges),
+        .fan_rpm_estimate(fan_rpm_estimate)
+    );
+
+    assign host_watchdog_kick = reg_wr_valid || pid_done || clear_fault_latch || clear_history_all;
+    assign manual_override = (host_mode == 2'd2);
+
+endmodule

+ 88 - 0
src/rtl/hysteresis_pi_controller.v

@@ -0,0 +1,88 @@
+`timescale 1ns/1ps
+
+module hysteresis_pi_controller #(
+    parameter integer DW = 18,
+    parameter signed [DW-1:0] OUT_MIN = 18'sd0,
+    parameter signed [DW-1:0] OUT_MAX = 18'sd127,
+    parameter signed [DW-1:0] POWER_LIMIT = 18'sd90,
+    parameter signed [DW-1:0] TARGET_TOLERANCE_Q = 18'sd7,
+    parameter signed [DW-1:0] KP_Q = 18'sd4,
+    parameter signed [DW-1:0] KI_Q = 18'sd1
+) (
+    input  wire                         clk,
+    input  wire                         rst_n,
+    input  wire                         sample_tick,
+    input  wire                         clear_history,
+    input  wire signed [DW-1:0]         error_q,
+    output reg  signed [DW-1:0]         ctrl_q,
+    output reg  signed [DW-1:0]         integral_q,
+    output reg                          clamped,
+    output reg                          history_cleared,
+    output reg                          done
+);
+
+    reg signed [(2*DW):0] raw_ctrl;
+    reg signed [DW-1:0] next_integral;
+
+    function signed [DW-1:0] clamp_output;
+        input signed [(2*DW):0] value;
+        begin
+            if (value > $signed(POWER_LIMIT)) begin
+                clamp_output = POWER_LIMIT;
+            end else if (value > $signed(OUT_MAX)) begin
+                clamp_output = OUT_MAX;
+            end else if (value < $signed(OUT_MIN)) begin
+                clamp_output = OUT_MIN;
+            end else begin
+                clamp_output = value[DW-1:0];
+            end
+        end
+    endfunction
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            ctrl_q <= {DW{1'b0}};
+            integral_q <= {DW{1'b0}};
+            clamped <= 1'b0;
+            history_cleared <= 1'b0;
+            done <= 1'b0;
+            raw_ctrl <= {(2*DW+1){1'b0}};
+            next_integral <= {DW{1'b0}};
+        end else begin
+            done <= 1'b0;
+            history_cleared <= 1'b0;
+            clamped <= 1'b0;
+            if (clear_history) begin
+                ctrl_q <= {DW{1'b0}};
+                integral_q <= {DW{1'b0}};
+                history_cleared <= 1'b1;
+                done <= 1'b1;
+            end else if (sample_tick) begin
+                if (error_q <= -TARGET_TOLERANCE_Q) begin
+                    ctrl_q <= {DW{1'b0}};
+                    integral_q <= {DW{1'b0}};
+                    clamped <= 1'b1;
+                    history_cleared <= 1'b1;
+                end else begin
+                    if (error_q >= TARGET_TOLERANCE_Q) begin
+                        next_integral = integral_q + error_q;
+                        raw_ctrl = ($signed(KP_Q) * $signed(error_q)) + ($signed(KI_Q) * $signed(next_integral));
+                    end else begin
+                        next_integral = integral_q;
+                        if (error_q > 0) begin
+                            next_integral = integral_q + error_q;
+                        end
+                        raw_ctrl = $signed(KI_Q) * $signed(next_integral);
+                    end
+                    integral_q <= next_integral;
+                    ctrl_q <= clamp_output(raw_ctrl);
+                    clamped <= (raw_ctrl > $signed(POWER_LIMIT)) ||
+                               (raw_ctrl > $signed(OUT_MAX)) ||
+                               (raw_ctrl < $signed(OUT_MIN));
+                end
+                done <= 1'b1;
+            end
+        end
+    end
+
+endmodule

+ 95 - 0
src/rtl/i2c_master_sensor_adapter.v

@@ -0,0 +1,95 @@
+`timescale 1ns/1ps
+
+module i2c_master_sensor_adapter #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5,
+    parameter integer CHANNEL_COUNT = 24,
+    parameter [7:0] DEVICE_ID = 8'h50,
+    parameter [2:0] SOURCE_ID = 3'd1
+) (
+    input  wire                 clk,
+    input  wire                 rst_n,
+    input  wire                 enable,
+    input  wire                 sensor_ready,
+    output reg                  sensor_valid,
+    output reg                  sensor_fault,
+    output reg  [CHW-1:0]       sensor_channel,
+    output reg  signed [DW-1:0] sensor_temp_q,
+    output reg  [15:0]          sensor_sample_seq,
+    output wire [2:0]           sensor_source_id,
+    output wire                 master_fault
+);
+
+    // VIRTUAL_PROFILE: device 8'h50, round-robin channel register groups.
+    // Each channel uses four bytes: temp[7:0], temp[15:8], {fault,temp[17:16]}, valid/reserved.
+    localparam [CHW-1:0] LAST_CHANNEL = CHANNEL_COUNT - 1;
+    reg [CHW-1:0] next_channel;
+    reg pending_valid;
+    reg [CHW-1:0] pending_channel;
+    reg signed [DW-1:0] pending_temp_q;
+    reg [15:0] pending_sample_seq;
+
+    assign sensor_source_id = SOURCE_ID;
+    assign master_fault = 1'b0;
+
+    task build_virtual_profile_sample;
+        input [CHW-1:0] channel;
+        output signed [DW-1:0] temp_q;
+        reg [4:0] offset;
+        begin
+            offset = channel % 5'd6;
+            if (channel < 5'd6) begin
+                temp_q = 18'sd70 + $signed({13'd0, offset});
+            end else if (channel < 5'd12) begin
+                temp_q = 18'sd78 + $signed({12'd0, offset, 1'b0});
+            end else if (channel < 5'd18) begin
+                temp_q = 18'sd86 + $signed({12'd0, offset, 1'b0}) + $signed({13'd0, offset});
+            end else begin
+                temp_q = 18'sd94 + $signed({11'd0, offset, 2'b00});
+            end
+        end
+    endtask
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            sensor_valid <= 1'b0;
+            sensor_fault <= 1'b0;
+            sensor_channel <= {CHW{1'b0}};
+            sensor_temp_q <= {DW{1'b0}};
+            sensor_sample_seq <= 16'd0;
+            next_channel <= {CHW{1'b0}};
+            pending_valid <= 1'b0;
+            pending_channel <= {CHW{1'b0}};
+            pending_temp_q <= {DW{1'b0}};
+            pending_sample_seq <= 16'd0;
+        end else begin
+            sensor_valid <= 1'b0;
+
+            if (!enable) begin
+                pending_valid <= 1'b0;
+            end else if (!pending_valid) begin
+                pending_channel <= next_channel;
+                build_virtual_profile_sample(next_channel, pending_temp_q);
+                pending_sample_seq <= sensor_sample_seq + 16'd1;
+                pending_valid <= 1'b1;
+                if (next_channel == LAST_CHANNEL) begin
+                    next_channel <= {CHW{1'b0}};
+                end else begin
+                    next_channel <= next_channel + {{(CHW-1){1'b0}}, 1'b1};
+                end
+            end else begin
+                sensor_valid <= 1'b1;
+                sensor_fault <= 1'b0;
+                sensor_channel <= pending_channel;
+                sensor_temp_q <= pending_temp_q;
+                sensor_sample_seq <= pending_sample_seq;
+                if (sensor_ready) begin
+                    pending_valid <= 1'b0;
+                end
+            end
+        end
+    end
+
+    wire [7:0] unused_device_id = DEVICE_ID;
+
+endmodule

+ 177 - 0
src/rtl/i2c_slave_register_frontend.v

@@ -0,0 +1,177 @@
+`timescale 1ns/1ps
+
+module i2c_slave_register_frontend #(
+    parameter [6:0] DEVICE_ADDR = 7'h50
+) (
+    input  wire       clk,
+    input  wire       rst_n,
+    input  wire       i2c_sclk,
+    inout  wire       i2c_sdat,
+    output reg        reg_wr_valid,
+    output reg        reg_rd_valid,
+    output reg  [7:0] reg_addr,
+    output reg  [7:0] reg_wdata,
+    input  wire [7:0] reg_rdata
+);
+
+    localparam S_IDLE = 3'd0;
+    localparam S_ADDR = 3'd1;
+    localparam S_REG_ADDR = 3'd2;
+    localparam S_WRITE = 3'd3;
+    localparam S_READ = 3'd4;
+    localparam S_ACK = 3'd5;
+
+    reg [2:0] state;
+    reg [2:0] bit_cnt;
+    reg [7:0] shift_reg;
+    reg [7:0] tx_reg;
+    reg rw_bit;
+    reg sdat_oe;
+    reg sclk_d1;
+    reg sclk_d2;
+    reg sdat_d1;
+    reg sdat_d2;
+    reg [2:0] ack_next_state;
+
+    wire sdat_in = i2c_sdat;
+    wire sclk_posedge = sclk_d1 & ~sclk_d2;
+    wire sclk_negedge = ~sclk_d1 & sclk_d2;
+    wire start_detected = sclk_d1 && sdat_d2 && !sdat_d1;
+    wire stop_detected = sclk_d1 && !sdat_d2 && sdat_d1;
+    wire [7:0] rx_next_byte = {shift_reg[6:0], sdat_in};
+    wire [6:0] rx_next_addr = rx_next_byte[7:1];
+
+    assign i2c_sdat = sdat_oe ? 1'b0 : 1'bz;
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            sclk_d1 <= 1'b1;
+            sclk_d2 <= 1'b1;
+            sdat_d1 <= 1'b1;
+            sdat_d2 <= 1'b1;
+        end else begin
+            sclk_d1 <= i2c_sclk;
+            sclk_d2 <= sclk_d1;
+            sdat_d1 <= sdat_in;
+            sdat_d2 <= sdat_d1;
+        end
+    end
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            state <= S_IDLE;
+            bit_cnt <= 3'd0;
+            shift_reg <= 8'd0;
+            tx_reg <= 8'd0;
+            rw_bit <= 1'b0;
+            sdat_oe <= 1'b0;
+            reg_wr_valid <= 1'b0;
+            reg_rd_valid <= 1'b0;
+            reg_addr <= 8'd0;
+            reg_wdata <= 8'd0;
+            ack_next_state <= S_IDLE;
+        end else begin
+            reg_wr_valid <= 1'b0;
+            reg_rd_valid <= 1'b0;
+
+            if (start_detected) begin
+                state <= S_ADDR;
+                bit_cnt <= 3'd0;
+                sdat_oe <= 1'b0;
+            end else if (stop_detected) begin
+                state <= S_IDLE;
+                sdat_oe <= 1'b0;
+                bit_cnt <= 3'd0;
+            end else begin
+                case (state)
+                    S_IDLE: begin
+                        sdat_oe <= 1'b0;
+                    end
+
+                    S_ADDR: begin
+                        if (sclk_posedge) begin
+                            shift_reg <= {shift_reg[6:0], sdat_in};
+                            if (bit_cnt == 3'd7) begin
+                                rw_bit <= sdat_in;
+                                bit_cnt <= 3'd0;
+                                if (rx_next_addr == DEVICE_ADDR) begin
+                                    ack_next_state <= sdat_in ? S_READ : S_REG_ADDR;
+                                    state <= S_ACK;
+                                end else begin
+                                    state <= S_IDLE;
+                                end
+                            end else begin
+                                bit_cnt <= bit_cnt + 3'd1;
+                            end
+                        end
+                    end
+
+                    S_REG_ADDR: begin
+                        sdat_oe <= 1'b0;
+                        if (sclk_posedge) begin
+                            shift_reg <= {shift_reg[6:0], sdat_in};
+                            if (bit_cnt == 3'd7) begin
+                                reg_addr <= rx_next_byte;
+                                bit_cnt <= 3'd0;
+                                ack_next_state <= S_WRITE;
+                                state <= S_ACK;
+                            end else begin
+                                bit_cnt <= bit_cnt + 3'd1;
+                            end
+                        end
+                    end
+
+                    S_WRITE: begin
+                        sdat_oe <= 1'b0;
+                        if (sclk_posedge) begin
+                            shift_reg <= {shift_reg[6:0], sdat_in};
+                            if (bit_cnt == 3'd7) begin
+                                reg_wdata <= rx_next_byte;
+                                reg_wr_valid <= 1'b1;
+                                reg_addr <= reg_addr + 8'd1;
+                                bit_cnt <= 3'd0;
+                                ack_next_state <= S_WRITE;
+                                state <= S_ACK;
+                            end else begin
+                                bit_cnt <= bit_cnt + 3'd1;
+                            end
+                        end
+                    end
+
+                    S_READ: begin
+                        if (bit_cnt == 3'd0) begin
+                            tx_reg <= reg_rdata;
+                            reg_rd_valid <= 1'b1;
+                        end
+                        if (sclk_negedge) begin
+                            sdat_oe <= ~tx_reg[7 - bit_cnt];
+                            if (bit_cnt == 3'd7) begin
+                                bit_cnt <= 3'd0;
+                                reg_addr <= reg_addr + 8'd1;
+                                sdat_oe <= 1'b0;
+                                state <= S_IDLE;
+                            end else begin
+                                bit_cnt <= bit_cnt + 3'd1;
+                            end
+                        end
+                    end
+
+                    S_ACK: begin
+                        if (sclk_negedge) begin
+                            sdat_oe <= 1'b1;
+                        end
+                        if (sclk_posedge) begin
+                            sdat_oe <= 1'b0;
+                            state <= ack_next_state;
+                        end
+                    end
+
+                    default: begin
+                        state <= S_IDLE;
+                    end
+                endcase
+            end
+        end
+    end
+
+endmodule

+ 71 - 0
src/rtl/motor_limit_domain.v

@@ -0,0 +1,71 @@
+`timescale 1ns/1ps
+
+module motor_limit_domain (
+    input  wire       clk,
+    input  wire       rst_n,
+    input  wire       global_enable,
+    input  wire       fault_latched,
+    input  wire [3:0] fault_code,
+    input  wire       motor_open_req,
+    input  wire       motor_close_req,
+    input  wire       button_open_req,
+    input  wire       button_close_req,
+    input  wire       limit_open,
+    input  wire       limit_close,
+    input  wire       interlock,
+    output reg        motor_enable,
+    output reg  [1:0] motor_dir,
+    output reg        motor_force_off,
+    output reg  [3:0] motor_reason,
+    output reg  [1:0] motor_state,
+    output wire [1:0] limit_status,
+    output wire [1:0] button_status
+);
+
+    localparam [3:0] FAULT_OK = 4'd0;
+    localparam [3:0] FAULT_HOST_DISABLED = 4'd1;
+    localparam [3:0] FAULT_INTERLOCK = 4'd7;
+
+    wire open_cmd = motor_open_req || button_open_req;
+    wire close_cmd = motor_close_req || button_close_req;
+
+    assign limit_status = {limit_close, limit_open};
+    assign button_status = {button_close_req, button_open_req};
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            motor_enable <= 1'b0;
+            motor_dir <= 2'd0;
+            motor_force_off <= 1'b1;
+            motor_reason <= FAULT_HOST_DISABLED;
+            motor_state <= 2'd0;
+        end else begin
+            if (!global_enable || fault_latched || interlock) begin
+                motor_enable <= 1'b0;
+                motor_dir <= 2'd0;
+                motor_force_off <= 1'b1;
+                motor_reason <= interlock ? FAULT_INTERLOCK : fault_code;
+                motor_state <= 2'd0;
+            end else if (open_cmd && !close_cmd && !limit_open) begin
+                motor_enable <= 1'b1;
+                motor_dir <= 2'd1;
+                motor_force_off <= 1'b0;
+                motor_reason <= FAULT_OK;
+                motor_state <= 2'd1;
+            end else if (close_cmd && !open_cmd && !limit_close) begin
+                motor_enable <= 1'b1;
+                motor_dir <= 2'd2;
+                motor_force_off <= 1'b0;
+                motor_reason <= FAULT_OK;
+                motor_state <= 2'd2;
+            end else begin
+                motor_enable <= 1'b0;
+                motor_dir <= 2'd0;
+                motor_force_off <= 1'b0;
+                motor_reason <= FAULT_OK;
+                motor_state <= 2'd0;
+            end
+        end
+    end
+
+endmodule

+ 206 - 0
src/rtl/pid_24ch_scheduler.v

@@ -0,0 +1,206 @@
+`timescale 1ns/1ps
+
+module pid_24ch_scheduler #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5,
+    parameter integer CHANNEL_COUNT = 24,
+    parameter signed [DW-1:0] OUT_MIN = 18'sd0,
+    parameter signed [DW-1:0] OUT_MAX = 18'sd127
+) (
+    input  wire                         clk,
+    input  wire                         rst_n,
+    input  wire                         sensor_valid,
+    output wire                         sensor_ready,
+    input  wire                         sensor_fault,
+    input  wire [CHW-1:0]               sensor_channel,
+    input  wire signed [DW-1:0]         sensor_temp_q,
+    input  wire [15:0]                  sensor_sample_seq,
+    input  wire                         host_enable,
+    input  wire signed [DW-1:0]         host_target_q,
+    input  wire signed [DW-1:0]         host_a0,
+    input  wire signed [DW-1:0]         host_a1,
+    input  wire signed [DW-1:0]         host_a2,
+    input  wire [1:0]                   host_mode,
+    input  wire [15:0]                  host_config_seq,
+    input  wire                         clear_history_all,
+    output reg                          pid_valid,
+    output reg  [CHW-1:0]               pid_channel,
+    output reg  signed [DW-1:0]         pid_error_q,
+    output reg  signed [DW-1:0]         pid_ctrl_q,
+    output reg                          pid_done,
+    output reg                          pid_fault,
+    output reg  [15:0]                  pid_sample_seq,
+    output reg  signed [DW-1:0]         pid_ctrl_prev_q,
+    output reg  signed [DW-1:0]         pid_delta_q,
+    output reg                          pid_clamped,
+    output reg                          pid_history_cleared,
+    output wire [1:0]                   pid_state,
+    output reg  [2:0]                   pid_cycle_phase,
+    output wire                         busy
+);
+
+    localparam S_IDLE = 2'd0;
+    localparam S_CALC = 2'd1;
+    localparam S_UPDATE = 2'd2;
+    localparam [CHW-1:0] LAST_CHANNEL = CHANNEL_COUNT - 1;
+
+    reg [1:0] state;
+    reg [CHW-1:0] active_channel;
+    reg [15:0] active_sample_seq;
+    reg signed [DW-1:0] active_error;
+    reg active_fault;
+    reg active_host_enable;
+    reg signed [DW-1:0] active_a0;
+    reg signed [DW-1:0] active_a1;
+    reg signed [DW-1:0] active_a2;
+    reg signed [(2*DW):0] delta_full;
+    reg signed [(2*DW):0] next_full;
+
+    reg signed [DW-1:0] e_k1_mem [0:CHANNEL_COUNT-1];
+    reg signed [DW-1:0] e_k2_mem [0:CHANNEL_COUNT-1];
+    reg signed [DW-1:0] ctrl_mem [0:CHANNEL_COUNT-1];
+
+    integer i;
+
+    assign busy = (state != S_IDLE);
+    assign sensor_ready = (state == S_IDLE);
+    assign pid_state = state;
+
+    wire unused_host_mode = |host_mode;
+    wire unused_host_config_seq = |host_config_seq;
+
+    task clear_channel_state;
+        input [CHW-1:0] channel;
+        begin
+            e_k1_mem[channel] <= {DW{1'b0}};
+            e_k2_mem[channel] <= {DW{1'b0}};
+            ctrl_mem[channel] <= {DW{1'b0}};
+        end
+    endtask
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            state <= S_IDLE;
+            active_channel <= {CHW{1'b0}};
+            active_sample_seq <= 16'd0;
+            active_error <= {DW{1'b0}};
+            active_fault <= 1'b0;
+            active_host_enable <= 1'b0;
+            active_a0 <= {DW{1'b0}};
+            active_a1 <= {DW{1'b0}};
+            active_a2 <= {DW{1'b0}};
+            delta_full <= {(2*DW+1){1'b0}};
+            next_full <= {(2*DW+1){1'b0}};
+            pid_valid <= 1'b0;
+            pid_channel <= {CHW{1'b0}};
+            pid_error_q <= {DW{1'b0}};
+            pid_ctrl_q <= {DW{1'b0}};
+            pid_done <= 1'b0;
+            pid_fault <= 1'b0;
+            pid_sample_seq <= 16'd0;
+            pid_ctrl_prev_q <= {DW{1'b0}};
+            pid_delta_q <= {DW{1'b0}};
+            pid_clamped <= 1'b0;
+            pid_history_cleared <= 1'b0;
+            pid_cycle_phase <= 3'd0;
+            for (i = 0; i < CHANNEL_COUNT; i = i + 1) begin
+                e_k1_mem[i] <= {DW{1'b0}};
+                e_k2_mem[i] <= {DW{1'b0}};
+                ctrl_mem[i] <= {DW{1'b0}};
+            end
+        end else begin
+            pid_valid <= 1'b0;
+            pid_done <= 1'b0;
+            pid_history_cleared <= 1'b0;
+            pid_clamped <= 1'b0;
+            pid_cycle_phase <= 3'd0;
+
+            if (clear_history_all) begin
+                for (i = 0; i < CHANNEL_COUNT; i = i + 1) begin
+                    e_k1_mem[i] <= {DW{1'b0}};
+                    e_k2_mem[i] <= {DW{1'b0}};
+                    ctrl_mem[i] <= {DW{1'b0}};
+                end
+                pid_history_cleared <= 1'b1;
+                state <= S_IDLE;
+            end else begin
+                case (state)
+                S_IDLE: begin
+                    if (sensor_valid && sensor_ready) begin
+                        active_channel <= sensor_channel;
+                        active_sample_seq <= sensor_sample_seq;
+                        active_error <= host_target_q - sensor_temp_q;
+                        active_fault <= sensor_fault | (sensor_channel > LAST_CHANNEL);
+                        active_host_enable <= host_enable;
+                        active_a0 <= host_a0;
+                        active_a1 <= host_a1;
+                        active_a2 <= host_a2;
+                        pid_cycle_phase <= 3'd1;
+                        state <= S_CALC;
+                    end
+                end
+
+                S_CALC: begin
+                    if (active_fault) begin
+                        delta_full <= {(2*DW+1){1'b0}};
+                        pid_delta_q <= {DW{1'b0}};
+                    end else begin
+                        delta_full <=
+                            $signed(active_a0) * $signed(active_error) +
+                            $signed(active_a1) * $signed(e_k1_mem[active_channel]) +
+                            $signed(active_a2) * $signed(e_k2_mem[active_channel]);
+                        pid_delta_q <= (
+                            $signed(active_a0) * $signed(active_error) +
+                            $signed(active_a1) * $signed(e_k1_mem[active_channel]) +
+                            $signed(active_a2) * $signed(e_k2_mem[active_channel])
+                        );
+                    end
+                    pid_cycle_phase <= 3'd2;
+                    state <= S_UPDATE;
+                end
+
+                S_UPDATE: begin
+                    pid_valid <= 1'b1;
+                    pid_done <= 1'b1;
+                    pid_channel <= active_channel;
+                    pid_sample_seq <= active_sample_seq;
+                    pid_error_q <= active_error;
+                    pid_fault <= active_fault;
+                    pid_ctrl_prev_q <= (active_channel <= LAST_CHANNEL) ? ctrl_mem[active_channel] : {DW{1'b0}};
+                    pid_cycle_phase <= 3'd3;
+
+                    if (active_fault || !active_host_enable || !host_enable) begin
+                        pid_ctrl_q <= {DW{1'b0}};
+                        if (active_channel <= LAST_CHANNEL) begin
+                            clear_channel_state(active_channel);
+                            pid_history_cleared <= 1'b1;
+                        end
+                    end else begin
+                        next_full = $signed(ctrl_mem[active_channel]) + $signed(delta_full);
+                        if (next_full > $signed(OUT_MAX)) begin
+                            ctrl_mem[active_channel] <= OUT_MAX;
+                            pid_ctrl_q <= OUT_MAX;
+                            pid_clamped <= 1'b1;
+                        end else if (next_full < $signed(OUT_MIN)) begin
+                            ctrl_mem[active_channel] <= OUT_MIN;
+                            pid_ctrl_q <= OUT_MIN;
+                            pid_clamped <= 1'b1;
+                        end else begin
+                            ctrl_mem[active_channel] <= next_full[DW-1:0];
+                            pid_ctrl_q <= next_full[DW-1:0];
+                        end
+                        e_k2_mem[active_channel] <= e_k1_mem[active_channel];
+                        e_k1_mem[active_channel] <= active_error;
+                    end
+                    state <= S_IDLE;
+                end
+
+                default: begin
+                    state <= S_IDLE;
+                end
+                endcase
+            end
+        end
+    end
+
+endmodule

+ 269 - 0
src/rtl/pid_control_regfile.v

@@ -0,0 +1,269 @@
+`timescale 1ns/1ps
+
+module pid_control_regfile #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5,
+    parameter [7:0] REG_MAGIC = 8'h00,
+    parameter [7:0] REG_VERSION = 8'h01,
+    parameter [7:0] REG_CONTROL = 8'h02,
+    parameter [7:0] REG_SOURCE_SELECT = 8'h03,
+    parameter [7:0] REG_COMMAND = 8'h04,
+    parameter [7:0] REG_STATUS = 8'h05
+) (
+    input  wire                 clk,
+    input  wire                 rst_n,
+    input  wire                 reg_wr_valid,
+    input  wire [7:0]           reg_wr_addr,
+    input  wire [7:0]           reg_wr_data,
+    input  wire                 reg_rd_valid,
+    input  wire [7:0]           reg_rd_addr,
+    output reg  [7:0]           reg_rd_data,
+    output reg                  host_enable,
+    output reg  signed [DW-1:0] host_target_q,
+    output reg  signed [DW-1:0] host_a0,
+    output reg  signed [DW-1:0] host_a1,
+    output reg  signed [DW-1:0] host_a2,
+    output reg  [1:0]           host_mode,
+    output reg  [15:0]          host_config_seq,
+    output reg  [2:0]           source_select,
+    output reg                  clear_fault_latch,
+    output reg                  clear_history_all,
+    input  wire                 slave_sensor_ready,
+    output reg                  slave_sample_valid,
+    output reg                  slave_sample_fault,
+    output reg  [CHW-1:0]       slave_sample_channel,
+    output reg  signed [DW-1:0] slave_sample_temp_q,
+    output reg  [15:0]          slave_sample_seq,
+    input  wire                 sensor_ready,
+    input  wire                 pid_busy,
+    input  wire                 master_fault,
+    input  wire                 slave_fault,
+    input  wire                 fault_latched,
+    input  wire                 force_off_latched,
+    input  wire [2:0]           debug_source_id,
+    input  wire [2:0]           debug_cycle_phase,
+    input  wire [1:0]           debug_state,
+    input  wire [15:0]          debug_sample_seq,
+    input  wire [15:0]          debug_config_seq,
+    input  wire [CHW-1:0]       debug_channel,
+    input  wire                 debug_clamped,
+    input  wire                 debug_history_cleared,
+    input  wire                 debug_reset_seen,
+    input  wire                 pid_valid,
+    input  wire [CHW-1:0]       pid_channel,
+    input  wire [15:0]          pid_sample_seq,
+    input  wire signed [DW-1:0] pid_error_q,
+    input  wire signed [DW-1:0] pid_ctrl_q,
+    input  wire                 pid_done,
+    input  wire                 pid_fault,
+    input  wire                 act_enable,
+    input  wire [CHW-1:0]       act_channel,
+    input  wire [DW-1:0]        act_duty_or_level,
+    input  wire                 act_force_off,
+    input  wire [1:0]           act_reason,
+    input  wire [23:0]          ptc_pwm_out,
+    input  wire [5:0]           fan_pwm_logic_high,
+    input  wire [5:0]           fan_pwm_drive_low,
+    input  wire [15:0]          fan_tach_count,
+    input  wire [15:0]          fan_tach_window_edges,
+    input  wire [15:0]          fan_rpm_estimate
+);
+
+    reg [7:0] regs [0:127];
+    reg sample_pending;
+    reg [15:0] debug_trace_seq;
+    integer i;
+
+    function signed [DW-1:0] read_int18;
+        input [7:0] base;
+        reg [17:0] raw;
+        begin
+            raw = {regs[base + 8'd2][1:0], regs[base + 8'd1], regs[base]};
+            read_int18 = raw[17] ? {14'h3fff, raw} : {14'd0, raw};
+        end
+    endfunction
+
+    task write_int18;
+        input [7:0] base;
+        input signed [DW-1:0] value;
+        begin
+            regs[base] <= value[7:0];
+            regs[base + 8'd1] <= value[15:8];
+            regs[base + 8'd2] <= {6'd0, value[17:16]};
+        end
+    endtask
+
+    task commit_host_config;
+        begin
+            host_enable <= regs[8'h10][0] & regs[REG_CONTROL][0];
+            host_mode <= regs[8'h11][1:0];
+            host_target_q <= read_int18(8'h12);
+            host_a0 <= read_int18(8'h15);
+            host_a1 <= read_int18(8'h18);
+            host_a2 <= read_int18(8'h1b);
+            host_config_seq <= host_config_seq + 16'd1;
+        end
+    endtask
+
+    task commit_slave_sample;
+        begin
+            sample_pending <= 1'b1;
+        end
+    endtask
+
+    always @(*) begin
+        if (reg_rd_addr == REG_MAGIC) begin
+            reg_rd_data = 8'h50;
+        end else if (reg_rd_addr == REG_VERSION) begin
+            reg_rd_data = 8'h01;
+        end else begin
+            reg_rd_data = regs[reg_rd_addr[6:0]];
+        end
+    end
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            for (i = 0; i < 128; i = i + 1) begin
+                regs[i] <= 8'd0;
+            end
+            regs[REG_MAGIC] <= 8'h50;
+            regs[REG_VERSION] <= 8'h01;
+            regs[REG_CONTROL] <= 8'h01;
+            regs[REG_SOURCE_SELECT] <= 8'h05;
+            regs[8'h10] <= 8'h01;
+            regs[8'h11] <= 8'h03;
+            regs[8'h12] <= 8'd70;
+            regs[8'h13] <= 8'd0;
+            regs[8'h14] <= 8'd0;
+            regs[8'h15] <= 8'd4;
+            regs[8'h16] <= 8'd0;
+            regs[8'h17] <= 8'd0;
+            regs[8'h18] <= 8'hff;
+            regs[8'h19] <= 8'hff;
+            regs[8'h1a] <= 8'h03;
+            regs[8'h1b] <= 8'd1;
+            regs[8'h1c] <= 8'd0;
+            regs[8'h1d] <= 8'd0;
+            host_enable <= 1'b1;
+            host_target_q <= 18'sd70;
+            host_a0 <= 18'sd4;
+            host_a1 <= -18'sd1;
+            host_a2 <= 18'sd1;
+            host_mode <= 2'd3;
+            host_config_seq <= 16'd1;
+            source_select <= 3'd5;
+            clear_fault_latch <= 1'b0;
+            clear_history_all <= 1'b0;
+            slave_sample_valid <= 1'b0;
+            slave_sample_fault <= 1'b0;
+            slave_sample_channel <= {CHW{1'b0}};
+            slave_sample_temp_q <= {DW{1'b0}};
+            slave_sample_seq <= 16'd0;
+            sample_pending <= 1'b0;
+            debug_trace_seq <= 16'd0;
+        end else begin
+            slave_sample_valid <= 1'b0;
+            clear_fault_latch <= 1'b0;
+            clear_history_all <= 1'b0;
+
+            regs[REG_STATUS] <= {
+                1'b0,
+                slave_fault,
+                master_fault,
+                sample_pending,
+                force_off_latched,
+                fault_latched,
+                sensor_ready,
+                pid_busy
+            };
+            host_enable <= regs[8'h10][0] & regs[REG_CONTROL][0];
+
+            if (reg_wr_valid) begin
+                case (reg_wr_addr)
+                    REG_MAGIC, REG_VERSION: begin
+                    end
+                    REG_CONTROL: begin
+                        regs[REG_CONTROL] <= {5'd0, 2'b00, reg_wr_data[0]};
+                        if (reg_wr_data[1]) begin
+                            clear_fault_latch <= 1'b1;
+                        end
+                        if (reg_wr_data[2]) begin
+                            clear_history_all <= 1'b1;
+                        end
+                    end
+                    REG_SOURCE_SELECT: begin
+                        regs[REG_SOURCE_SELECT] <= {5'd0, reg_wr_data[2:0]};
+                        source_select <= reg_wr_data[2:0];
+                    end
+                    REG_COMMAND: begin
+                        if (reg_wr_data[0]) begin
+                            commit_host_config();
+                        end
+                        if (reg_wr_data[1]) begin
+                            commit_slave_sample();
+                        end
+                    end
+                    default: begin
+                        if (reg_wr_addr < 8'h80) begin
+                            regs[reg_wr_addr[6:0]] <= reg_wr_data;
+                        end
+                    end
+                endcase
+            end
+
+            if (sample_pending && slave_sensor_ready && source_select == 3'd2) begin
+                sample_pending <= 1'b0;
+                slave_sample_valid <= 1'b1;
+                slave_sample_channel <= regs[8'h20][CHW-1:0];
+                slave_sample_fault <= regs[8'h21][0];
+                slave_sample_temp_q <= read_int18(8'h22);
+                slave_sample_seq <= slave_sample_seq + 16'd1;
+            end
+
+            if (pid_valid || pid_done) begin
+                regs[8'h30] <= {{(8-CHW){1'b0}}, pid_channel};
+                regs[8'h31] <= {3'd0, debug_history_cleared, debug_clamped, pid_fault, pid_done, pid_valid};
+                regs[8'h32] <= pid_sample_seq[7:0];
+                regs[8'h33] <= pid_sample_seq[15:8];
+                write_int18(8'h36, pid_error_q);
+                write_int18(8'h39, pid_ctrl_q);
+            end
+
+            regs[8'h40] <= {{(8-CHW){1'b0}}, act_channel};
+            regs[8'h41] <= {4'd0, act_reason, act_force_off, act_enable};
+            write_int18(8'h42, $signed({1'b0, act_duty_or_level[DW-2:0]}));
+            regs[8'h48] <= ptc_pwm_out[7:0];
+            regs[8'h49] <= ptc_pwm_out[15:8];
+            regs[8'h4a] <= ptc_pwm_out[23:16];
+            regs[8'h4b] <= {2'd0, fan_pwm_logic_high};
+            regs[8'h4c] <= {2'd0, fan_pwm_drive_low};
+            regs[8'h4d] <= fan_tach_count[7:0];
+            regs[8'h4e] <= fan_tach_count[15:8];
+            regs[8'h4f] <= fan_rpm_estimate[7:0];
+
+            debug_trace_seq <= debug_trace_seq + 16'd1;
+            regs[8'h60] <= debug_trace_seq[7:0];
+            regs[8'h61] <= debug_trace_seq[15:8];
+            regs[8'h64] <= {5'd0, debug_source_id};
+            regs[8'h65] <= {5'd0, debug_cycle_phase};
+            regs[8'h66] <= {6'd0, debug_state};
+            regs[8'h68] <= debug_sample_seq[7:0];
+            regs[8'h69] <= debug_sample_seq[15:8];
+            regs[8'h6a] <= debug_config_seq[7:0];
+            regs[8'h6b] <= debug_config_seq[15:8];
+            regs[8'h6c] <= {{(8-CHW){1'b0}}, debug_channel};
+            regs[8'h6d] <= {3'd0, debug_reset_seen, act_force_off, pid_fault, debug_history_cleared, debug_clamped};
+            regs[8'h70] <= ptc_pwm_out[7:0];
+            regs[8'h71] <= ptc_pwm_out[15:8];
+            regs[8'h72] <= ptc_pwm_out[23:16];
+            regs[8'h73] <= {2'd0, fan_pwm_logic_high};
+            regs[8'h74] <= {2'd0, fan_pwm_drive_low};
+            regs[8'h75] <= fan_tach_window_edges[7:0];
+            regs[8'h76] <= fan_tach_window_edges[15:8];
+            regs[8'h77] <= fan_rpm_estimate[15:8];
+        end
+    end
+
+    wire unused_reg_rd_valid = reg_rd_valid;
+
+endmodule

+ 85 - 0
src/rtl/pid_core.v

@@ -0,0 +1,85 @@
+`timescale 1ns/1ps
+
+module pid_core #(
+    parameter integer DW = 18,
+    parameter signed [DW-1:0] A0 = 18'sd6,
+    parameter signed [DW-1:0] A1 = -18'sd2,
+    parameter signed [DW-1:0] A2 = 18'sd1,
+    parameter signed [DW-1:0] OUT_MIN = 18'sd0,
+    parameter signed [DW-1:0] OUT_MAX = 18'sd131071
+) (
+    input  wire                         clk,
+    input  wire                         rst_n,
+    input  wire                         sample_tick,
+    input  wire signed [DW-1:0]         error_in,
+    output reg  signed [DW-1:0]         ctrl_out,
+    output reg                          done,
+    output wire                         busy
+);
+
+    localparam S_IDLE   = 2'd0;
+    localparam S_CALC   = 2'd1;
+    localparam S_UPDATE = 2'd2;
+
+    reg [1:0] state;
+    reg signed [DW-1:0] e_k1;
+    reg signed [DW-1:0] e_k2;
+    reg signed [(2*DW):0] delta_full;
+    reg signed [(2*DW):0] next_full;
+    reg signed [DW-1:0] captured_error;
+
+    assign busy = (state != S_IDLE);
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            state <= S_IDLE;
+            e_k1 <= {DW{1'b0}};
+            e_k2 <= {DW{1'b0}};
+            delta_full <= {(2*DW+1){1'b0}};
+            next_full <= {(2*DW+1){1'b0}};
+            captured_error <= {DW{1'b0}};
+            ctrl_out <= {DW{1'b0}};
+            done <= 1'b0;
+        end else begin
+            done <= 1'b0;
+
+            case (state)
+                S_IDLE: begin
+                    if (sample_tick) begin
+                        captured_error <= error_in;
+                        state <= S_CALC;
+                    end
+                end
+
+                S_CALC: begin
+                    delta_full <=
+                        $signed(A0) * $signed(captured_error) +
+                        $signed(A1) * $signed(e_k1) +
+                        $signed(A2) * $signed(e_k2);
+                    state <= S_UPDATE;
+                end
+
+                S_UPDATE: begin
+                    next_full = $signed(ctrl_out) + $signed(delta_full);
+                    if (next_full > $signed(OUT_MAX)) begin
+                        ctrl_out <= OUT_MAX;
+                    end else if (next_full < $signed(OUT_MIN)) begin
+                        ctrl_out <= OUT_MIN;
+                    end else begin
+                        ctrl_out <= next_full[DW-1:0];
+                    end
+
+                    e_k2 <= e_k1;
+                    e_k1 <= captured_error;
+                    done <= 1'b1;
+                    state <= S_IDLE;
+                end
+
+                default: begin
+                    state <= S_IDLE;
+                end
+            endcase
+        end
+    end
+
+endmodule

+ 136 - 0
src/rtl/ptc_output_bank.v

@@ -0,0 +1,136 @@
+`timescale 1ns/1ps
+
+module ptc_output_bank #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5,
+    parameter integer CHANNEL_COUNT = 24,
+    parameter [DW-1:0] OUT_MIN = 18'd0,
+    parameter [DW-1:0] OUT_MAX = 18'd127,
+    parameter integer PWM_PERIOD_TICKS = 2500000,
+    parameter integer PWM_COUNTER_WIDTH = 22
+) (
+    input  wire                         clk,
+    input  wire                         rst_n,
+    input  wire                         pid_valid,
+    input  wire [CHW-1:0]               pid_channel,
+    input  wire signed [DW-1:0]         pid_ctrl_q,
+    input  wire                         pid_fault,
+    input  wire                         global_enable,
+    input  wire                         fault_latched,
+    input  wire [3:0]                   fault_code,
+    output reg                          ptc_enable,
+    output reg  [CHW-1:0]               ptc_channel,
+    output reg  [DW-1:0]                ptc_duty_or_level,
+    output reg                          ptc_force_off,
+    output reg  [3:0]                   ptc_reason,
+    output reg  [CHANNEL_COUNT-1:0]     ptc_bank_enable,
+    output reg  [CHANNEL_COUNT-1:0]     ptc_bank_force_off,
+    output reg  [CHANNEL_COUNT*DW-1:0]  ptc_bank_duty_or_level,
+    output reg  [CHANNEL_COUNT-1:0]     ptc_pwm_out
+);
+
+    localparam [3:0] FAULT_OK = 4'd0;
+    localparam [3:0] FAULT_HOST_DISABLED = 4'd1;
+    localparam [3:0] FAULT_SENSOR_FAULT = 4'd2;
+    localparam [3:0] FAULT_INVALID_CHANNEL = 4'd6;
+    localparam [CHW-1:0] LAST_CHANNEL = CHANNEL_COUNT - 1;
+    localparam [PWM_COUNTER_WIDTH-1:0] PWM_PERIOD_LIMIT = PWM_PERIOD_TICKS;
+
+    reg [DW-1:0] duty_mem [0:CHANNEL_COUNT-1];
+    reg [DW-1:0] clamped_duty;
+    reg [PWM_COUNTER_WIDTH-1:0] pwm_counter;
+    reg [PWM_COUNTER_WIDTH-1:0] high_ticks;
+    integer i;
+
+    always @(*) begin
+        if (pid_ctrl_q < $signed(OUT_MIN)) begin
+            clamped_duty = OUT_MIN;
+        end else if (pid_ctrl_q > $signed(OUT_MAX)) begin
+            clamped_duty = OUT_MAX;
+        end else begin
+            clamped_duty = pid_ctrl_q[DW-1:0];
+        end
+    end
+
+    always @(*) begin
+        for (i = 0; i < CHANNEL_COUNT; i = i + 1) begin
+            ptc_bank_duty_or_level[(i*DW) +: DW] = duty_mem[i];
+        end
+    end
+
+    always @(*) begin
+        ptc_pwm_out = {CHANNEL_COUNT{1'b0}};
+        high_ticks = {PWM_COUNTER_WIDTH{1'b0}};
+        for (i = 0; i < CHANNEL_COUNT; i = i + 1) begin
+            if (ptc_bank_enable[i] && !ptc_bank_force_off[i]) begin
+                if (duty_mem[i] >= OUT_MAX) begin
+                    ptc_pwm_out[i] = 1'b1;
+                end else if (duty_mem[i] <= OUT_MIN) begin
+                    ptc_pwm_out[i] = 1'b0;
+                end else begin
+                    high_ticks = (PWM_PERIOD_TICKS * duty_mem[i]) / OUT_MAX;
+                    ptc_pwm_out[i] = pwm_counter < high_ticks;
+                end
+            end
+        end
+    end
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            pwm_counter <= {PWM_COUNTER_WIDTH{1'b0}};
+            ptc_enable <= 1'b0;
+            ptc_channel <= {CHW{1'b0}};
+            ptc_duty_or_level <= {DW{1'b0}};
+            ptc_force_off <= 1'b1;
+            ptc_reason <= FAULT_HOST_DISABLED;
+            ptc_bank_enable <= {CHANNEL_COUNT{1'b0}};
+            ptc_bank_force_off <= {CHANNEL_COUNT{1'b1}};
+            for (i = 0; i < CHANNEL_COUNT; i = i + 1) begin
+                duty_mem[i] <= {DW{1'b0}};
+            end
+        end else begin
+            if (pwm_counter == PWM_PERIOD_LIMIT - {{(PWM_COUNTER_WIDTH-1){1'b0}}, 1'b1}) begin
+                pwm_counter <= {PWM_COUNTER_WIDTH{1'b0}};
+            end else begin
+                pwm_counter <= pwm_counter + {{(PWM_COUNTER_WIDTH-1){1'b0}}, 1'b1};
+            end
+
+            if (!global_enable || fault_latched) begin
+                ptc_enable <= 1'b0;
+                ptc_duty_or_level <= {DW{1'b0}};
+                ptc_force_off <= 1'b1;
+                ptc_reason <= fault_code;
+                ptc_bank_enable <= {CHANNEL_COUNT{1'b0}};
+                ptc_bank_force_off <= {CHANNEL_COUNT{1'b1}};
+                for (i = 0; i < CHANNEL_COUNT; i = i + 1) begin
+                    duty_mem[i] <= {DW{1'b0}};
+                end
+            end else if (pid_valid) begin
+                ptc_channel <= pid_channel;
+                if (pid_channel > LAST_CHANNEL) begin
+                    ptc_enable <= 1'b0;
+                    ptc_duty_or_level <= {DW{1'b0}};
+                    ptc_force_off <= 1'b1;
+                    ptc_reason <= FAULT_INVALID_CHANNEL;
+                end else if (pid_fault) begin
+                    ptc_enable <= 1'b0;
+                    ptc_duty_or_level <= {DW{1'b0}};
+                    ptc_force_off <= 1'b1;
+                    ptc_reason <= FAULT_SENSOR_FAULT;
+                    ptc_bank_enable[pid_channel] <= 1'b0;
+                    ptc_bank_force_off[pid_channel] <= 1'b1;
+                    duty_mem[pid_channel] <= {DW{1'b0}};
+                end else begin
+                    ptc_enable <= 1'b1;
+                    ptc_duty_or_level <= clamped_duty;
+                    ptc_force_off <= 1'b0;
+                    ptc_reason <= FAULT_OK;
+                    ptc_bank_enable[pid_channel] <= 1'b1;
+                    ptc_bank_force_off[pid_channel] <= 1'b0;
+                    duty_mem[pid_channel] <= clamped_duty;
+                end
+            end
+        end
+    end
+
+endmodule

+ 106 - 0
src/rtl/safety_supervisor.v

@@ -0,0 +1,106 @@
+`timescale 1ns/1ps
+
+module safety_supervisor #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5,
+    parameter integer CHANNEL_COUNT = 24,
+    parameter signed [DW-1:0] OVERTEMP_LIMIT_Q = 18'sd90,
+    parameter integer HOST_TIMEOUT_TICKS = 10
+) (
+    input  wire                 clk,
+    input  wire                 rst_n,
+    input  wire                 clear_fault_latch,
+    input  wire                 host_enable,
+    input  wire                 host_watchdog_kick,
+    input  wire                 sensor_valid,
+    input  wire [CHW-1:0]       sensor_channel,
+    input  wire signed [DW-1:0] sensor_temp_q,
+    input  wire                 sensor_fault,
+    input  wire                 sensor_stale,
+    input  wire                 interlock,
+    output reg                  global_enable,
+    output reg                  fault_latched,
+    output reg  [3:0]           fault_code,
+    output reg                  safety_sensor_stale,
+    output reg                  overtemp,
+    output reg                  comm_timeout,
+    output reg                  safety_interlock
+);
+
+    localparam [3:0] FAULT_OK = 4'd0;
+    localparam [3:0] FAULT_HOST_DISABLED = 4'd1;
+    localparam [3:0] FAULT_SENSOR_FAULT = 4'd2;
+    localparam [3:0] FAULT_SENSOR_STALE = 4'd3;
+    localparam [3:0] FAULT_HOST_TIMEOUT = 4'd4;
+    localparam [3:0] FAULT_OVERTEMP = 4'd5;
+    localparam [3:0] FAULT_INVALID_CHANNEL = 4'd6;
+    localparam [3:0] FAULT_INTERLOCK = 4'd7;
+    localparam [CHW-1:0] LAST_CHANNEL = CHANNEL_COUNT - 1;
+    localparam [31:0] HOST_TIMEOUT_LIMIT = HOST_TIMEOUT_TICKS;
+
+    reg [31:0] watchdog_age;
+    reg [3:0] next_fault_code;
+    wire invalid_channel = sensor_channel > LAST_CHANNEL;
+    wire host_timed_out = watchdog_age > HOST_TIMEOUT_LIMIT;
+    wire system_latch_fault = next_fault_code == FAULT_HOST_TIMEOUT ||
+                              next_fault_code == FAULT_OVERTEMP ||
+                              next_fault_code == FAULT_INTERLOCK;
+    wire [3:0] active_fault_code = fault_latched ? fault_code : next_fault_code;
+
+    always @(*) begin
+        if (interlock) begin
+            next_fault_code = FAULT_INTERLOCK;
+        end else if (sensor_valid && !invalid_channel && sensor_temp_q >= OVERTEMP_LIMIT_Q) begin
+            next_fault_code = FAULT_OVERTEMP;
+        end else if (invalid_channel) begin
+            next_fault_code = FAULT_INVALID_CHANNEL;
+        end else if (sensor_fault) begin
+            next_fault_code = FAULT_SENSOR_FAULT;
+        end else if (sensor_stale) begin
+            next_fault_code = FAULT_SENSOR_STALE;
+        end else if (host_timed_out) begin
+            next_fault_code = FAULT_HOST_TIMEOUT;
+        end else if (!host_enable) begin
+            next_fault_code = FAULT_HOST_DISABLED;
+        end else begin
+            next_fault_code = FAULT_OK;
+        end
+    end
+
+    always @(posedge clk or negedge rst_n) begin
+        if (!rst_n) begin
+            watchdog_age <= 32'd0;
+            global_enable <= 1'b0;
+            fault_latched <= 1'b0;
+            fault_code <= FAULT_OK;
+            safety_sensor_stale <= 1'b0;
+            overtemp <= 1'b0;
+            comm_timeout <= 1'b0;
+            safety_interlock <= 1'b0;
+        end else begin
+            if (host_watchdog_kick) begin
+                watchdog_age <= 32'd0;
+            end else if (watchdog_age != 32'hffff_ffff) begin
+                watchdog_age <= watchdog_age + 32'd1;
+            end
+
+            safety_sensor_stale <= sensor_stale;
+            overtemp <= sensor_valid && !invalid_channel && sensor_temp_q >= OVERTEMP_LIMIT_Q;
+            comm_timeout <= host_timed_out;
+            safety_interlock <= interlock;
+
+            if (clear_fault_latch) begin
+                fault_latched <= 1'b0;
+                fault_code <= FAULT_OK;
+            end else if (system_latch_fault) begin
+                fault_latched <= 1'b1;
+                fault_code <= next_fault_code;
+            end else if (!fault_latched) begin
+                fault_code <= next_fault_code;
+            end
+
+            global_enable <= host_enable && (active_fault_code == FAULT_OK);
+        end
+    end
+
+endmodule

+ 105 - 0
src/rtl/sensor_domain.v

@@ -0,0 +1,105 @@
+`timescale 1ns/1ps
+
+module sensor_domain #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5
+) (
+    input  wire                 clk,
+    input  wire                 rst_n,
+    input  wire [2:0]           source_select,
+    input  wire                 sensor_ready,
+    input  wire                 fake_sensor_valid,
+    output wire                 fake_sensor_ready,
+    input  wire                 fake_sensor_fault,
+    input  wire [CHW-1:0]       fake_sensor_channel,
+    input  wire signed [DW-1:0] fake_sensor_temp_q,
+    input  wire [15:0]          fake_sensor_sample_seq,
+    input  wire                 fake_sensor_stale,
+    input  wire [7:0]           fake_sensor_raw_status,
+    input  wire                 master_sensor_valid,
+    output wire                 master_sensor_ready,
+    input  wire                 master_sensor_fault,
+    input  wire [CHW-1:0]       master_sensor_channel,
+    input  wire signed [DW-1:0] master_sensor_temp_q,
+    input  wire [15:0]          master_sensor_sample_seq,
+    input  wire                 master_sensor_stale,
+    input  wire [7:0]           master_sensor_raw_status,
+    input  wire                 slave_sensor_valid,
+    output wire                 slave_sensor_ready,
+    input  wire                 slave_sensor_fault,
+    input  wire [CHW-1:0]       slave_sensor_channel,
+    input  wire signed [DW-1:0] slave_sensor_temp_q,
+    input  wire [15:0]          slave_sensor_sample_seq,
+    input  wire                 slave_sensor_stale,
+    input  wire [7:0]           slave_sensor_raw_status,
+    input  wire                 bmc_sensor_valid,
+    output wire                 bmc_sensor_ready,
+    input  wire                 bmc_sensor_fault,
+    input  wire [CHW-1:0]       bmc_sensor_channel,
+    input  wire signed [DW-1:0] bmc_sensor_temp_q,
+    input  wire [15:0]          bmc_sensor_sample_seq,
+    input  wire                 bmc_sensor_stale,
+    input  wire [7:0]           bmc_sensor_raw_status,
+    output wire                 sensor_valid,
+    output wire                 sensor_fault,
+    output wire [CHW-1:0]       sensor_channel,
+    output wire signed [DW-1:0] sensor_temp_q,
+    output wire [15:0]          sensor_sample_seq,
+    output wire [2:0]           sensor_source_id,
+    output wire                 sensor_stale,
+    output wire [7:0]           sensor_raw_status
+);
+
+    sensor_source_mux u_sensor_source_mux (
+        .clk(clk),
+        .rst_n(rst_n),
+        .source_select(source_select),
+        .sensor_ready(sensor_ready),
+        .fake_sensor_valid(fake_sensor_valid),
+        .fake_sensor_ready(fake_sensor_ready),
+        .fake_sensor_fault(fake_sensor_fault),
+        .fake_sensor_channel(fake_sensor_channel),
+        .fake_sensor_temp_q(fake_sensor_temp_q),
+        .fake_sensor_sample_seq(fake_sensor_sample_seq),
+        .master_sensor_valid(master_sensor_valid),
+        .master_sensor_ready(master_sensor_ready),
+        .master_sensor_fault(master_sensor_fault),
+        .master_sensor_channel(master_sensor_channel),
+        .master_sensor_temp_q(master_sensor_temp_q),
+        .master_sensor_sample_seq(master_sensor_sample_seq),
+        .slave_sensor_valid(slave_sensor_valid),
+        .slave_sensor_ready(slave_sensor_ready),
+        .slave_sensor_fault(slave_sensor_fault),
+        .slave_sensor_channel(slave_sensor_channel),
+        .slave_sensor_temp_q(slave_sensor_temp_q),
+        .slave_sensor_sample_seq(slave_sensor_sample_seq),
+        .bmc_sensor_valid(bmc_sensor_valid),
+        .bmc_sensor_ready(bmc_sensor_ready),
+        .bmc_sensor_fault(bmc_sensor_fault),
+        .bmc_sensor_channel(bmc_sensor_channel),
+        .bmc_sensor_temp_q(bmc_sensor_temp_q),
+        .bmc_sensor_sample_seq(bmc_sensor_sample_seq),
+        .sensor_valid(sensor_valid),
+        .sensor_fault(sensor_fault),
+        .sensor_channel(sensor_channel),
+        .sensor_temp_q(sensor_temp_q),
+        .sensor_sample_seq(sensor_sample_seq),
+        .sensor_source_id(sensor_source_id)
+    );
+
+    wire selected_fake = source_select == 3'd0 || source_select == 3'd6 ||
+        (source_select != 3'd1 && source_select != 3'd2 && source_select != 3'd5);
+    wire selected_master = source_select == 3'd1;
+    wire selected_slave = source_select == 3'd2;
+    wire selected_bmc = source_select == 3'd5;
+
+    assign sensor_stale = selected_fake ? fake_sensor_stale :
+        (selected_master ? master_sensor_stale :
+        (selected_slave ? slave_sensor_stale :
+        (selected_bmc ? bmc_sensor_stale : fake_sensor_stale)));
+    assign sensor_raw_status = selected_fake ? fake_sensor_raw_status :
+        (selected_master ? master_sensor_raw_status :
+        (selected_slave ? slave_sensor_raw_status :
+        (selected_bmc ? bmc_sensor_raw_status : fake_sensor_raw_status)));
+
+endmodule

+ 121 - 0
src/rtl/sensor_source_mux.v

@@ -0,0 +1,121 @@
+`timescale 1ns/1ps
+
+module sensor_source_mux #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5,
+    parameter [2:0] SOURCE_FAKE = 3'd0,
+    parameter [2:0] SOURCE_I2C_MASTER = 3'd1,
+    parameter [2:0] SOURCE_I2C_SLAVE_INJECT = 3'd2,
+    parameter [2:0] SOURCE_BMC_UART_TEXT = 3'd5,
+    parameter [2:0] SOURCE_FAKE_STRESS = 3'd6
+) (
+    input  wire                 clk,
+    input  wire                 rst_n,
+    input  wire [2:0]           source_select,
+    input  wire                 sensor_ready,
+    input  wire                 fake_sensor_valid,
+    output wire                 fake_sensor_ready,
+    input  wire                 fake_sensor_fault,
+    input  wire [CHW-1:0]       fake_sensor_channel,
+    input  wire signed [DW-1:0] fake_sensor_temp_q,
+    input  wire [15:0]          fake_sensor_sample_seq,
+    input  wire                 master_sensor_valid,
+    output wire                 master_sensor_ready,
+    input  wire                 master_sensor_fault,
+    input  wire [CHW-1:0]       master_sensor_channel,
+    input  wire signed [DW-1:0] master_sensor_temp_q,
+    input  wire [15:0]          master_sensor_sample_seq,
+    input  wire                 slave_sensor_valid,
+    output wire                 slave_sensor_ready,
+    input  wire                 slave_sensor_fault,
+    input  wire [CHW-1:0]       slave_sensor_channel,
+    input  wire signed [DW-1:0] slave_sensor_temp_q,
+    input  wire [15:0]          slave_sensor_sample_seq,
+    input  wire                 bmc_sensor_valid,
+    output wire                 bmc_sensor_ready,
+    input  wire                 bmc_sensor_fault,
+    input  wire [CHW-1:0]       bmc_sensor_channel,
+    input  wire signed [DW-1:0] bmc_sensor_temp_q,
+    input  wire [15:0]          bmc_sensor_sample_seq,
+    output reg                  sensor_valid,
+    output reg                  sensor_fault,
+    output reg  [CHW-1:0]       sensor_channel,
+    output reg  signed [DW-1:0] sensor_temp_q,
+    output reg  [15:0]          sensor_sample_seq,
+    output reg  [2:0]           sensor_source_id
+);
+
+    wire selected_fake_source = source_select == SOURCE_FAKE || source_select == SOURCE_FAKE_STRESS || (
+        source_select != SOURCE_I2C_MASTER &&
+        source_select != SOURCE_I2C_SLAVE_INJECT &&
+        source_select != SOURCE_BMC_UART_TEXT
+    );
+
+    assign fake_sensor_ready = sensor_ready && selected_fake_source;
+    assign master_sensor_ready = sensor_ready && (source_select == SOURCE_I2C_MASTER);
+    assign slave_sensor_ready = sensor_ready && (source_select == SOURCE_I2C_SLAVE_INJECT);
+    assign bmc_sensor_ready = sensor_ready && (source_select == SOURCE_BMC_UART_TEXT);
+
+    always @(*) begin
+        sensor_valid = 1'b0;
+        sensor_fault = 1'b0;
+        sensor_channel = {CHW{1'b0}};
+        sensor_temp_q = {DW{1'b0}};
+        sensor_sample_seq = 16'd0;
+        sensor_source_id = source_select;
+        case (source_select)
+            SOURCE_FAKE: begin
+                sensor_valid = fake_sensor_valid;
+                sensor_fault = fake_sensor_fault;
+                sensor_channel = fake_sensor_channel;
+                sensor_temp_q = fake_sensor_temp_q;
+                sensor_sample_seq = fake_sensor_sample_seq;
+                sensor_source_id = SOURCE_FAKE;
+            end
+            SOURCE_I2C_MASTER: begin
+                sensor_valid = master_sensor_valid;
+                sensor_fault = master_sensor_fault;
+                sensor_channel = master_sensor_channel;
+                sensor_temp_q = master_sensor_temp_q;
+                sensor_sample_seq = master_sensor_sample_seq;
+                sensor_source_id = SOURCE_I2C_MASTER;
+            end
+            SOURCE_I2C_SLAVE_INJECT: begin
+                sensor_valid = slave_sensor_valid;
+                sensor_fault = slave_sensor_fault;
+                sensor_channel = slave_sensor_channel;
+                sensor_temp_q = slave_sensor_temp_q;
+                sensor_sample_seq = slave_sensor_sample_seq;
+                sensor_source_id = SOURCE_I2C_SLAVE_INJECT;
+            end
+            SOURCE_BMC_UART_TEXT: begin
+                sensor_valid = bmc_sensor_valid;
+                sensor_fault = bmc_sensor_fault;
+                sensor_channel = bmc_sensor_channel;
+                sensor_temp_q = bmc_sensor_temp_q;
+                sensor_sample_seq = bmc_sensor_sample_seq;
+                sensor_source_id = SOURCE_BMC_UART_TEXT;
+            end
+            SOURCE_FAKE_STRESS: begin
+                sensor_valid = fake_sensor_valid;
+                sensor_fault = fake_sensor_fault;
+                sensor_channel = fake_sensor_channel;
+                sensor_temp_q = fake_sensor_temp_q;
+                sensor_sample_seq = fake_sensor_sample_seq;
+                sensor_source_id = SOURCE_FAKE_STRESS;
+            end
+            default: begin
+                sensor_valid = fake_sensor_valid;
+                sensor_fault = fake_sensor_fault;
+                sensor_channel = fake_sensor_channel;
+                sensor_temp_q = fake_sensor_temp_q;
+                sensor_sample_seq = fake_sensor_sample_seq;
+                sensor_source_id = SOURCE_FAKE;
+            end
+        endcase
+    end
+
+    wire unused_clk = clk;
+    wire unused_rst_n = rst_n;
+
+endmodule

+ 110 - 0
src/rtl/source_arbitrator.v

@@ -0,0 +1,110 @@
+`timescale 1ns/1ps
+
+module source_arbitrator #(
+    parameter integer DW = 18,
+    parameter integer CHW = 5
+) (
+    input  wire                 clk,
+    input  wire                 rst_n,
+    input  wire [2:0]           source_select,
+    input  wire                 sensor_ready,
+    input  wire                 fake_sensor_valid,
+    output wire                 fake_sensor_ready,
+    input  wire                 fake_sensor_fault,
+    input  wire [CHW-1:0]       fake_sensor_channel,
+    input  wire signed [DW-1:0] fake_sensor_temp_q,
+    input  wire [15:0]          fake_sensor_sample_seq,
+    input  wire                 master_sensor_valid,
+    output wire                 master_sensor_ready,
+    input  wire                 master_sensor_fault,
+    input  wire [CHW-1:0]       master_sensor_channel,
+    input  wire signed [DW-1:0] master_sensor_temp_q,
+    input  wire [15:0]          master_sensor_sample_seq,
+    input  wire                 slave_sensor_valid,
+    output wire                 slave_sensor_ready,
+    input  wire                 slave_sensor_fault,
+    input  wire [CHW-1:0]       slave_sensor_channel,
+    input  wire signed [DW-1:0] slave_sensor_temp_q,
+    input  wire [15:0]          slave_sensor_sample_seq,
+    input  wire                 rs232_sensor_valid,
+    output wire                 rs232_sensor_ready,
+    input  wire                 rs232_sensor_fault,
+    input  wire [CHW-1:0]       rs232_sensor_channel,
+    input  wire signed [DW-1:0] rs232_sensor_temp_q,
+    input  wire [15:0]          rs232_sensor_sample_seq,
+    input  wire                 rs485_sensor_valid,
+    output wire                 rs485_sensor_ready,
+    input  wire                 rs485_sensor_fault,
+    input  wire [CHW-1:0]       rs485_sensor_channel,
+    input  wire signed [DW-1:0] rs485_sensor_temp_q,
+    input  wire [15:0]          rs485_sensor_sample_seq,
+    output reg                  sensor_valid,
+    output reg                  sensor_fault,
+    output reg  [CHW-1:0]       sensor_channel,
+    output reg  signed [DW-1:0] sensor_temp_q,
+    output reg  [15:0]          sensor_sample_seq,
+    output reg  [2:0]           sensor_source_id
+);
+
+    localparam [2:0] SOURCE_FAKE = 3'd0;
+    localparam [2:0] SOURCE_I2C_MASTER = 3'd1;
+    localparam [2:0] SOURCE_I2C_SLAVE_INJECT = 3'd2;
+    localparam [2:0] SOURCE_RS232_UART_INJECT = 3'd3;
+    localparam [2:0] SOURCE_RS485_INJECT = 3'd4;
+
+    assign fake_sensor_ready = sensor_ready && (
+        source_select == SOURCE_FAKE ||
+        source_select > SOURCE_RS485_INJECT
+    );
+    assign master_sensor_ready = sensor_ready && (source_select == SOURCE_I2C_MASTER);
+    assign slave_sensor_ready = sensor_ready && (source_select == SOURCE_I2C_SLAVE_INJECT);
+    assign rs232_sensor_ready = sensor_ready && (source_select == SOURCE_RS232_UART_INJECT);
+    assign rs485_sensor_ready = sensor_ready && (source_select == SOURCE_RS485_INJECT);
+
+    always @(*) begin
+        sensor_valid = fake_sensor_valid;
+        sensor_fault = fake_sensor_fault;
+        sensor_channel = fake_sensor_channel;
+        sensor_temp_q = fake_sensor_temp_q;
+        sensor_sample_seq = fake_sensor_sample_seq;
+        sensor_source_id = SOURCE_FAKE;
+        case (source_select)
+            SOURCE_I2C_MASTER: begin
+                sensor_valid = master_sensor_valid;
+                sensor_fault = master_sensor_fault;
+                sensor_channel = master_sensor_channel;
+                sensor_temp_q = master_sensor_temp_q;
+                sensor_sample_seq = master_sensor_sample_seq;
+                sensor_source_id = SOURCE_I2C_MASTER;
+            end
+            SOURCE_I2C_SLAVE_INJECT: begin
+                sensor_valid = slave_sensor_valid;
+                sensor_fault = slave_sensor_fault;
+                sensor_channel = slave_sensor_channel;
+                sensor_temp_q = slave_sensor_temp_q;
+                sensor_sample_seq = slave_sensor_sample_seq;
+                sensor_source_id = SOURCE_I2C_SLAVE_INJECT;
+            end
+            SOURCE_RS232_UART_INJECT: begin
+                sensor_valid = rs232_sensor_valid;
+                sensor_fault = rs232_sensor_fault;
+                sensor_channel = rs232_sensor_channel;
+                sensor_temp_q = rs232_sensor_temp_q;
+                sensor_sample_seq = rs232_sensor_sample_seq;
+                sensor_source_id = SOURCE_RS232_UART_INJECT;
+            end
+            SOURCE_RS485_INJECT: begin
+                sensor_valid = rs485_sensor_valid;
+                sensor_fault = rs485_sensor_fault;
+                sensor_channel = rs485_sensor_channel;
+                sensor_temp_q = rs485_sensor_temp_q;
+                sensor_sample_seq = rs485_sensor_sample_seq;
+                sensor_source_id = SOURCE_RS485_INJECT;
+            end
+        endcase
+    end
+
+    wire unused_clk = clk;
+    wire unused_rst_n = rst_n;
+
+endmodule

+ 0 - 0
src/rtl/uart_rx_8n1.v


Некоторые файлы не были показаны из-за большого количества измененных файлов