Kaynağa Gözat

feat(v3.0.4): unify all CPLD PWM to 20Hz and add GUI/Web 4-chamber thermal test platform

Prod2U Recovery 1 ay önce
ebeveyn
işleme
bc4d15bd55
69 değiştirilmiş dosya ile 5015 ekleme ve 316 silme
  1. 2 2
      ACTIVE_6400_MANUAL_I2C_LOCK.yaml
  2. 1 1
      README.zh-CN.md
  3. 1 1
      VERSION
  4. 2 2
      VERSION.json
  5. 1 1
      constraints/prod2u_6400_v2.adc
  6. 2 2
      contracts/6400-manual.yaml
  7. 3 3
      contracts/6400-v2-manual.yaml
  8. 4 4
      contracts/fan-control-parameters.yaml
  9. 1 1
      contracts/mrdimm-status.yaml
  10. 3 3
      contracts/mrdimm-wire.yaml
  11. 1 1
      docs/evidence/6400-v2-electrical-alignment.md
  12. 17 17
      docs/pwm-scope.md
  13. 31 0
      docs/releases/v3.0.4.md
  14. 1 1
      generated/6400-v2/channel-map.json
  15. 1 1
      generated/6400-v2/contract-sha256.txt
  16. 1 1
      generated/6400-v2/fan-control-parameters.json
  17. 1 1
      generated/6400-v2/golden-vectors.json
  18. 1 1
      generated/6400-v2/host-contract.json
  19. 1 1
      generated/6400-v2/manual-uart-contract.json
  20. 5 5
      generated/6400-v2/prod2u_6400_v2_params.vh
  21. 1 1
      generated/6400-v2/snapshot-layout.json
  22. 1 1
      generated/6400/channel-map.json
  23. 1 1
      generated/6400/contract-sha256.txt
  24. 1 1
      generated/6400/fan-control-parameters.json
  25. 1 1
      generated/6400/golden-vectors.json
  26. 1 1
      generated/6400/host-contract.json
  27. 1 1
      generated/6400/manual-uart-contract.json
  28. 5 5
      generated/6400/prod2u_6400_v1_params.vh
  29. 1 1
      generated/6400/snapshot-layout.json
  30. 1 1
      generated/mrdimm/contract-sha256.txt
  31. 1 1
      generated/mrdimm/golden-vectors.json
  32. 4 4
      generated/mrdimm/prod2u_mrdimm_params.vh
  33. 1 1
      generated/mrdimm/snapshot-layout.json
  34. 1 1
      products/6400-v2/project.json
  35. 3 3
      projects/mrdimm-chamber/project.json
  36. 4 4
      projects/prod2u-6400-front-back/project.json
  37. 2 2
      src/actuator/pwm_bitmap_engine.v
  38. 2 2
      src/actuator/ssr_time_proportion.v
  39. 2 2
      src/control/mrdimm_output_core.v
  40. 4 4
      src/generated/6400/host-contract.json
  41. 6 6
      src/generated/6400/prod2u_6400_front_back_params.vh
  42. 5 5
      src/generated/6400/project-summary.json
  43. 2 2
      src/generated/6400/td-source-manifest.json
  44. 6 4
      src/top/prod2u_6400_final_top.v
  45. 14 9
      src/top/prod2u_6400_v2_top.v
  46. 2 2
      src/top/prod2u_mrdimm_final_top.v
  47. 4 4
      tests/sim/mrdimm_pwm_contract_tb.v
  48. 55 19
      tests/sim/prod2u_6400_v2_connector_tb.v
  49. 78 34
      tests/sim/prod2u_v3_protocol_tb.v
  50. 76 56
      tests/sim/pwm_bitmap_engine_tb.v
  51. 16 8
      tests/sim/ssr_time_proportion_tb.v
  52. 6 6
      tests/unit/test_6400_contract.py
  53. 1 1
      tests/unit/test_6400_v2_electrical_contract.py
  54. 242 2
      tests/unit/test_gui_v3_ssr_diagnostic.py
  55. 32 0
      tests/unit/test_pwm_scope_stream.py
  56. 2 2
      tools/board-viewer/generate_v2_0_assets.py
  57. 4 4
      tools/board-viewer/generated-v2_0/board-data.json
  58. 5 5
      tools/board-viewer/generated-v2_0/build-info.json
  59. 1 1
      tools/board-viewer/generated-v2_0/import-report.json
  60. 3 3
      tools/board-viewer/generated-v2_0_fan/build-info.json
  61. 1 1
      tools/board-viewer/generated-v2_0_fan/import-report.json
  62. 8 8
      tools/generate_6400.py
  63. 2982 6
      tools/prod2u_gui.py
  64. 101 35
      tools/pwm_scope.py
  65. 1 1
      tools/run_6400_connector.py
  66. 1 1
      tools/run_6400_mutation.py
  67. 2 2
      tools/run_v3_protocol.py
  68. 1239 0
      tools/thermal_test_server.py
  69. 2 2
      tools/validate_active_6400_lock.py

+ 2 - 2
ACTIVE_6400_MANUAL_I2C_LOCK.yaml

@@ -26,8 +26,8 @@ outputs:
   ptc_count: 24
   ptc_count: 24
   front_fan_count: 4
   front_fan_count: 4
   rear_fan_count: 4
   rear_fan_count: 4
-  ptc_pwm_hz: 500
-  fan_pwm_hz: 500
+  ptc_pwm_hz: 20
+  fan_pwm_hz: 20
   fan_board_invert_mask: 0x0F
   fan_board_invert_mask: 0x0F
 defaults: {ptc_percent: 0, fan_percent: 20}
 defaults: {ptc_percent: 0, fan_percent: 20}
 watchdog_seconds: 30
 watchdog_seconds: 30

+ 1 - 1
README.zh-CN.md

@@ -16,7 +16,7 @@
 ## 日常使用约定
 ## 日常使用约定
 
 
 - MRDIMM 每轴只有一个当前运动段;MCU 等该轴 `MOTOR_DONE` 再发下一段,其他轴可以同时运行。动作 `00` 为 NOTHING,`01/02` 为两个方向,`FF` 为 STOP_CLEAR。无上电自动标定、百分比定位或多段队列。`STOP_CLEAR` 只停止电机;关闭 PTC 要把对应 PTC 占空比显式写 0 并等 SET_ACK。
 - MRDIMM 每轴只有一个当前运动段;MCU 等该轴 `MOTOR_DONE` 再发下一段,其他轴可以同时运行。动作 `00` 为 NOTHING,`01/02` 为两个方向,`FF` 为 STOP_CLEAR。无上电自动标定、百分比定位或多段队列。`STOP_CLEAR` 只停止电机;关闭 PTC 要把对应 PTC 占空比显式写 0 并等 SET_ACK。
-- 6400 V2 的 SET 是 32 字节,GET_DATA 是 83 字节;MRDIMM 的 SET 是 68 字节,GET_DATA 是 63 字节。当前帧是 `A5 5A | TYPE:u8 | LENGTH:u8 | PAYLOAD | CRC16`,不要使用旧 16 位长度或旧三轴协议。
+- 6400 V2 的 SET 是 35 字节(含末尾3字节SSR),GET_DATA 是 86 字节(6400 V1.1 保持 SET 32 / GET_DATA 83);MRDIMM 的 SET 是 68 字节,GET_DATA 是 63 字节;支持 `0x03` HEARTBEAT 请求与 `0x83` 应答;全部 PWM(FAN/PTC/SSR)统一为 20Hz(50ms 周期)。当前帧是 `A5 5A | TYPE:u8 | LENGTH:u8 | PAYLOAD | CRC16`,不要使用旧 16 位长度或旧三轴协议。
 - 上电后无请求也会自动输出:MRDIMM 约每 5 秒一帧 `0x51` 存活帧;6400 V2 约每 5 秒一帧 `0x42` 完整状态。GUI 区分 AUTO 与主动 GET 的 ACK/DATA;正式版本保留自动输出。
 - 上电后无请求也会自动输出:MRDIMM 约每 5 秒一帧 `0x51` 存活帧;6400 V2 约每 5 秒一帧 `0x42` 完整状态。GUI 区分 AUTO 与主动 GET 的 ACK/DATA;正式版本保留自动输出。
 - CT/BMC 只采集上报,不替使用者自动调温。正常使用时定期维持控制通信,30 秒通信超时后输出回到 PTC0/FAN20,MRDIMM 电机停止。具体请求语义以当前产品合同和协议说明为准。
 - CT/BMC 只采集上报,不替使用者自动调温。正常使用时定期维持控制通信,30 秒通信超时后输出回到 PTC0/FAN20,MRDIMM 电机停止。具体请求语义以当前产品合同和协议说明为准。
 
 

+ 1 - 1
VERSION

@@ -1 +1 @@
-3.0.3
+3.0.4

+ 2 - 2
VERSION.json

@@ -1,6 +1,6 @@
 {
 {
   "schema": "prod2u-version-v3",
   "schema": "prod2u-version-v3",
-  "version": "3.0.3",
+  "version": "3.0.4",
   "release_branch": "dev",
   "release_branch": "dev",
   "clock_hz": 25000000,
   "clock_hz": 25000000,
   "host_baud": 921600,
   "host_baud": 921600,
@@ -24,7 +24,7 @@
       "ptc_count": 24,
       "ptc_count": 24,
       "fan_count": 8,
       "fan_count": 8,
       "ssr_count": 3,
       "ssr_count": 3,
-      "ssr_pwm_hz": 500
+      "ssr_pwm_hz": 20
     },
     },
     "mrdimm-chamber": {
     "mrdimm-chamber": {
       "board": "FCB V1.2",
       "board": "FCB V1.2",

+ 1 - 1
constraints/prod2u_6400_v2.adc

@@ -21,7 +21,7 @@ set_pin_assignment { temp_sda } { LOCATION = A15; IOSTANDARD = LVCMOS33; PULLTYP
 set_pin_assignment { temp_scl_alt } { LOCATION = M8; IOSTANDARD = LVCMOS33; PULLTYPE = NONE; }
 set_pin_assignment { temp_scl_alt } { LOCATION = M8; IOSTANDARD = LVCMOS33; PULLTYPE = NONE; }
 set_pin_assignment { temp_sda_alt } { LOCATION = N9; IOSTANDARD = LVCMOS33; PULLTYPE = NONE; }
 set_pin_assignment { temp_sda_alt } { LOCATION = N9; IOSTANDARD = LVCMOS33; PULLTYPE = NONE; }
 
 
-# Controlled SSR: 500 Hz; field CON165.1/.2/.4 = CAD .14/.13/.11 (2026-10-27)
+# Controlled SSR: 20 Hz; field CON165.1/.2/.4 = CAD .14/.13/.11 (2026-10-27)
 set_pin_assignment { ssr1_out } { LOCATION = E14; IOSTANDARD = LVCMOS33; }
 set_pin_assignment { ssr1_out } { LOCATION = E14; IOSTANDARD = LVCMOS33; }
 set_pin_assignment { ssr2_out } { LOCATION = E8; IOSTANDARD = LVCMOS33; }
 set_pin_assignment { ssr2_out } { LOCATION = E8; IOSTANDARD = LVCMOS33; }
 set_pin_assignment { ssr4_out } { LOCATION = D9; IOSTANDARD = LVCMOS33; }
 set_pin_assignment { ssr4_out } { LOCATION = D9; IOSTANDARD = LVCMOS33; }

+ 2 - 2
contracts/6400-manual.yaml

@@ -63,8 +63,8 @@ outputs:
   ptc_count: 24
   ptc_count: 24
   front_fan_count: 4
   front_fan_count: 4
   rear_fan_count: 4
   rear_fan_count: 4
-  ptc_pwm_hz: 500
-  fan_pwm_hz: 500
+  ptc_pwm_hz: 20
+  fan_pwm_hz: 20
   fan_board_invert_mask: 0xFF
   fan_board_invert_mask: 0xFF
   fan_board_invert_mask_is_the_only_inversion_point: true
   fan_board_invert_mask_is_the_only_inversion_point: true
   ptc_active_level: high
   ptc_active_level: high

+ 3 - 3
contracts/6400-v2-manual.yaml

@@ -63,8 +63,8 @@ outputs:
   ptc_count: 24
   ptc_count: 24
   front_fan_count: 4
   front_fan_count: 4
   rear_fan_count: 4
   rear_fan_count: 4
-  ptc_pwm_hz: 500
-  fan_pwm_hz: 500
+  ptc_pwm_hz: 20
+  fan_pwm_hz: 20
   fan_board_invert_mask: 255
   fan_board_invert_mask: 255
   fan_board_invert_mask_is_the_only_inversion_point: true
   fan_board_invert_mask_is_the_only_inversion_point: true
   ptc_active_level: high
   ptc_active_level: high
@@ -100,7 +100,7 @@ outputs:
     connector: CON155.12
     connector: CON155.12
     ball: C7
     ball: C7
   ssr_count: 3
   ssr_count: 3
-  ssr_pwm_hz: 500
+  ssr_pwm_hz: 20
   default_ssr_percent: 0
   default_ssr_percent: 0
   ssr_active_level: high
   ssr_active_level: high
   ssr_commit: atomically_latch_duty_keep_phase_free_running
   ssr_commit: atomically_latch_duty_keep_phase_free_running

+ 4 - 4
contracts/fan-control-parameters.yaml

@@ -9,12 +9,12 @@ manual_front_rear_independent: true
 connector_duty_semantics: high_level_percent
 connector_duty_semantics: high_level_percent
 board_invert_mask: 0xFF
 board_invert_mask: 0xFF
 pwm:
 pwm:
-  ptc_hz: 500
-  fan_hz: 500
+  ptc_hz: 20
+  fan_hz: 20
   clock_hz: 25000000
   clock_hz: 25000000
   phases: 100
   phases: 100
-  ptc_phase_clks: 500
-  fan_phase_clks: 500
+  ptc_phase_clks: 12500
+  fan_phase_clks: 12500
   carrier_backend: shared_equal_frequency_control_reset_independent_v2
   carrier_backend: shared_equal_frequency_control_reset_independent_v2
   evidence: EXPERIMENTAL_CONFIGURATION_NOT_FAN_DATASHEET_VERIFIED
   evidence: EXPERIMENTAL_CONFIGURATION_NOT_FAN_DATASHEET_VERIFIED
 pwm_high_level_status: PWM_HIGH_LEVEL_UNVERIFIED
 pwm_high_level_status: PWM_HIGH_LEVEL_UNVERIFIED

+ 1 - 1
contracts/mrdimm-status.yaml

@@ -46,7 +46,7 @@ fan_ptc_mapping:
   logical_ptc_count: 4
   logical_ptc_count: 4
   physical_ptc_count: 24
   physical_ptc_count: 24
   ptc_map: logical PTC0..3 each drive six physical PTC outputs (chamber N = physical 6N through 6N+5)
   ptc_map: logical PTC0..3 each drive six physical PTC outputs (chamber N = physical 6N through 6N+5)
-  pwm_hz: 500
+  pwm_hz: 20
   fan_duty_semantics: connector_requested_duty_not_rpm_not_airflow
   fan_duty_semantics: connector_requested_duty_not_rpm_not_airflow
 motor_axes:
 motor_axes:
   axis_count: 12
   axis_count: 12

+ 3 - 3
contracts/mrdimm-wire.yaml

@@ -194,7 +194,7 @@ retry_semantics:
   get_all: retryable_after_resync
   get_all: retryable_after_resync
   motor_done_is_not_a_host_request: true
   motor_done_is_not_a_host_request: true
 pwm:
 pwm:
-  fan_hz: 500
-  ptc_hz: 500
+  fan_hz: 20
+  ptc_hz: 20
   phases: 100
   phases: 100
-  period_clks: 50000
+  period_clks: 1250000

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
docs/evidence/6400-v2-electrical-alignment.md


+ 17 - 17
docs/pwm-scope.md

@@ -1,6 +1,6 @@
 # 6400V2.0 示波器与温度测试
 # 6400V2.0 示波器与温度测试
 
 
-脚本版本 1.0.3,适配当前软件 3.0.3 的 SET35 / GET86。板号始终为 6400V2.0。
+脚本版本 1.0.5,适配当前软件 3.0.4 的 SET35 / GET86(全板统一 20Hz PWM)。板号始终为 6400V2.0。
 
 
 在 192.168.2.79 执行:
 在 192.168.2.79 执行:
 
 
@@ -12,7 +12,7 @@ python3 pwm_scope.py
 默认 15 分钟,每秒一轮 SET ALL → SET_ACK → GET ALL → GET_ACK + GET_DATA。
 默认 15 分钟,每秒一轮 SET ALL → SET_ACK → GET ALL → GET_ACK + GET_DATA。
 串口固定为已确认温控板的 USB1 物理路径,921600 8N1;不会扫描或打开其他串口。
 串口固定为已确认温控板的 USB1 物理路径,921600 8N1;不会扫描或打开其他串口。
 收到自动 0x42 / 0x52 时正常记录,不把自动上报当作 GET 应答。
 收到自动 0x42 / 0x52 时正常记录,不把自动上报当作 GET 应答。
-终端交互模式下顶部固定显示对齐的 35 路 PWM 映射表(含 500Hz 导通脉宽 µs 与极性说明)与 CT0~CT8 探头映射表,底部以原位刷新面板实时显示进度、35 路回读核对、各腔进/出风温度与 0x52 诊断寄存器摘要。
+终端交互模式下顶部固定显示对齐的 35 路 PWM 映射表(含 20Hz 导通脉宽 µs 与极性说明)与 CT0~CT8 探头映射表,底部以原位刷新面板实时显示进度、35 路回读核对、各腔进/出风温度与 0x52 诊断寄存器摘要。
 运行期间不要让其他 GUI/串口工具同时连接此端口。
 运行期间不要让其他 GUI/串口工具同时连接此端口。
 
 
 到时或 Ctrl+C 只停止发送、关闭串口,不额外归零、不恢复输出。
 到时或 Ctrl+C 只停止发送、关闭串口,不额外归零、不恢复输出。
@@ -37,11 +37,11 @@ python3 pwm_scope.py --scroll --no-color
 依赖 Python3 与 pyserial,.79 当前系统已安装,无须额外安装。
 依赖 Python3 与 pyserial,.79 当前系统已安装,无须额外安装。
 日志写入脚本旁 logs/,每次独立 JSONL,包含原始 TX/RX、解码 CT/BMC、诊断及错误。
 日志写入脚本旁 logs/,每次独立 JSONL,包含原始 TX/RX、解码 CT/BMC、诊断及错误。
 
 
-## 35 路互不相同的占空比
+## 35 路占空比与风扇 5 秒交替规则
 
 
-SET payload 索引从 0 开始,占空比 = 索引 + 1(%)。
-PTC 与风扇 500Hz、周期 2ms;1%对应 20µs。
-SSR 同为 500Hz、周期 2ms,33/34/35% 对应 660/680/700µs 导通时间。
+PTC0..23(字节 0..23)占空比依次为 1%..24%;SSR1/2/4(字节 32..34)占空比依次为 33%..35%。
+风扇 8 路(字节 24..31)默认以 **5 秒 50%(导通脉宽 25000µs)、5 秒 0%(导通脉宽 0µs)交替往复** 下发并回读核对。
+PTC、风扇、SSR 统一为 20Hz、周期 50ms;1% 对应 500µs。
 板上其他未纳入协议的备用输出保持原样,不计入这 35 路。
 板上其他未纳入协议的备用输出保持原样,不计入这 35 路。
 
 
 | 输出 | 占空比 | 主板连接器 | FPGA 球位 |
 | 输出 | 占空比 | 主板连接器 | FPGA 球位 |
@@ -51,14 +51,14 @@ SSR 同为 500Hz、周期 2ms,33/34/35% 对应 660/680/700µs 导通时间。
 | PTC12..17,腔3 | 13/14/15/16/17/18% | CON149.1/3/5/7/9/11 | P10/R10/T13/T12/L3/N2 |
 | PTC12..17,腔3 | 13/14/15/16/17/18% | CON149.1/3/5/7/9/11 | P10/R10/T13/T12/L3/N2 |
 | PTC18,腔4第1路 | 19% | CON149.19 | K5 |
 | PTC18,腔4第1路 | 19% | CON149.19 | K5 |
 | PTC19..23,腔4第2..6路 | 20/21/22/23/24% | CON150.1/5/9/13/17 | L4/H4/J6/H5/C15 |
 | PTC19..23,腔4第2..6路 | 20/21/22/23/24% | CON150.1/5/9/13/17 | L4/H4/J6/H5/C15 |
-| 腔1进风 | 25% | CON154.5 | C4 |
-| 腔2进风 | 26% | CON154.11 | B1 |
-| 腔3进风 | 27% | CON155.5 | P12 |
-| 腔4进风 | 28% | CON155.11 | D8 |
-| 腔1排风 | 29% | CON154.6 | B5 |
-| 腔2排风 | 30% | CON154.12 | A14 |
-| 腔3排风 | 31% | CON155.6 | A10 |
-| 腔4排风 | 32% | CON155.12 | C7 |
+| 腔1进风 | 50% / 0% (5s交替) | CON154.5 | C4 |
+| 腔2进风 | 50% / 0% (5s交替) | CON154.11 | B1 |
+| 腔3进风 | 50% / 0% (5s交替) | CON155.5 | P12 |
+| 腔4进风 | 50% / 0% (5s交替) | CON155.11 | D8 |
+| 腔1排风 | 50% / 0% (5s交替) | CON154.6 | B5 |
+| 腔2排风 | 50% / 0% (5s交替) | CON154.12 | A14 |
+| 腔3排风 | 50% / 0% (5s交替) | CON155.6 | A10 |
+| 腔4排风 | 50% / 0% (5s交替) | CON155.12 | C7 |
 | SSR1,腔1 | 33% | CON165.1 | E14 |
 | SSR1,腔1 | 33% | CON165.1 | E14 |
 | SSR2,腔2+3共用 | 34% | CON165.2 | E8 |
 | SSR2,腔2+3共用 | 34% | CON165.2 | E8 |
 | SSR4,腔4 | 35% | CON165.4 | D9 |
 | SSR4,腔4 | 35% | CON165.4 | D9 |
@@ -128,12 +128,12 @@ DIAG decode_mask 仅代表通信/数值可解码,不代表探头已经正确
 - 漏电造成的最终残压 V≈I_leak×R;SSR本身的关断延迟还须额外计入。
 - 漏电造成的最终残压 V≈I_leak×R;SSR本身的关断延迟还须额外计入。
 - 若C=100nF,330Ω约152µs降到1%;100Ω约46µs。
 - 若C=100nF,330Ω约152µs降到1%;100Ω约46µs。
 - 若C=1µF,330Ω约1.52ms;100Ω约0.46ms。
 - 若C=1µF,330Ω约1.52ms;100Ω约0.46ms。
-500Hz周期2ms,当前SSR1/2/4=33/34/35%,高电平660/680/700µs,关断窗口1340/1320/1300µs。
+20Hz周期50ms,当前SSR1/2/4=33/34/35%,高电平16500/17000/17500µs(16.5/17.0/17.5ms),关断窗口33500/33000/32500µs(33.5/33.0/32.5ms)。
 因此330Ω适合作为首测值;若电容约1µF或漏电较大,100Ω更容易看到低电平。
 因此330Ω适合作为首测值;若电容约1µF或漏电较大,100Ω更容易看到低电平。
 实际等效电容、漏电和SSR型号还未取得,不能无条件保证某个电阻覆盖所有占空比;
 实际等效电容、漏电和SSR型号还未取得,不能无条件保证某个电阻覆盖所有占空比;
-99%只有20µs关断时间,不能拿33%时的结果替代。
+99%有500µs关断时间,不能拿33%时的结果替代。
 
 
-同时看两个位置:CON165.1/.2/.4对控制GND的500Hz驱动,以及假负载两端的24V PWM。
+同时看两个位置:CON165.1/.2/.4对控制GND的20Hz驱动,以及假负载两端的24V PWM。
 若控制端周期正确但功率端加假负载仍不跟随,再核对SSR开通/关断时间和3.3V输入驱动。
 若控制端周期正确但功率端加假负载仍不跟随,再核对SSR开通/关断时间和3.3V输入驱动。
 电阻能改善电容放电和漏电残压,不能让慢速SSR自动具备500Hz开关能力。
 电阻能改善电容放电和漏电残压,不能让慢速SSR自动具备500Hz开关能力。
 本轮不再以缺少SSR型号为理由将软件降回1Hz。
 本轮不再以缺少SSR型号为理由将软件降回1Hz。

+ 31 - 0
docs/releases/v3.0.4.md

@@ -0,0 +1,31 @@
+# 6400V2.0 / MRDIMM V1.2 软件 3.0.4
+
+## 1. 核心变更概览
+
+1. **全产品 CPLD PWM 频率统一为 20Hz(50ms 周期)**:
+   - 覆盖 `6400-v2`(24 路 PTC + 8 路进/排风扇 + 3 路 SSR)、`6400-front-rear`(24 路 PTC + 8 路风扇)、`mrdimm-chamber`(4 路风扇 + 4 路逻辑 PTC / 24 路物理 PTC)。
+   - 25 MHz 单一主时钟下,1% 占空比步进周期由 `500` 时钟(20us / 500Hz)统一调整为 `12,500` 时钟(500us),100 步完整 PWM 周期为 `1,250,000` 时钟(50ms = 20Hz)。
+   - 保持逻辑极简:仅调整计数器分频常数(`PHASE_CLKS = 12500`),不增加额外控制状态机,LUT 占用仅因分频计数器位宽由 9-bit 增至 14-bit 微增约 15 LUT。
+
+2. **6400 V2.0(项目名 `6400V2.0`)风扇、腔体与 SSR 映射核准**:
+   - **新风风扇(进风 / Front0..3,SET_ALL 字节 24..27)**:腔体 1..4 分别对应 `CON154.1 (C4)`、`CON154.5 (B1)`、`CON155.1 (P12)`、`CON155.5 (D8)`。
+   - **排风风扇(出风 / Rear0..3,SET_ALL 字节 28..31)**:腔体 1..4 分别对应 `CON154.3 (B5)`、`CON154.7 (A14)`、`CON155.3 (A10)`、`CON155.7 (C7)`。
+   - **三路可控 SSR(20Hz,SET_ALL 字节 32..34 / GET_DATA 字节 83..85)**:
+     - `SSR1`(腔体 1):现场 `CON165.1`(CAD `CON165.14`)-> FPGA `E14`
+     - `SSR2`(腔体 2+3 共用):现场 `CON165.2`(CAD `CON165.13`)-> FPGA `E8`
+     - `SSR4`(腔体 4):现场 `CON165.4`(CAD `CON165.11`)-> FPGA `D9`
+     - 旧 `F3 / F1 / G4` 固定输出低电平(`ssr_unused_zero = 3'b000`)。
+
+3. **CPLD GUI EXE(`tools/prod2u_gui.py`)温度曲线绘制与高温罩四腔温度测试**:
+   - **四腔体温度实时曲线与自定义映射(`📈 腔体温度曲线`)**:
+     - 直接图形化绘制并导出(PNG / SVG / CSV)四个腔体的内存温度(BMC)与 Sensor 温度(CT7428)曲线图;
+     - 提供默认四腔体映射(腔体 `i` 默认 `BMC[(i-1)*6 .. i*6-1]` + `CT[2*i-1, 2*i]`),支持在界面上自定义修改任意腔体映射并支持一键交换腔体 1/2 与 3/4。
+   - **高温罩温度测试(`🔥 高温罩温度测试`)**:
+     - 支持独立设定每个腔体(腔体 1..4)的预期目标温度(默认 `70.0°C`)以及整个高温罩四个腔体的通过温度最低值(默认 `70.0°C`);
+     - 独立统计并计算各腔体 Sensor 温度与内存温度达到目标温度所需的时间(秒数与 `MM:SS` 格式),以及整个高温罩四腔全部达标总耗时;
+     - **持续记录保证**:某个腔体率先达到目标温度后,锁定该腔体达标耗时并继续不间断记录全部四个腔体的后续温度数据与达标后样本数(`post_target_samples`);
+     - 支持风扇介入策略配置(立即介入、按加热时间介入 `s`、按参考温度介入 `°C`、手动介入),自动触发并下发 `SET_ALL` 切换风扇转速。
+
+4. **192.168.2.25 全权限容器后端与网页前端(`tools/thermal_test_server.py`)**:
+   - 在 `192.168.2.25`(`root@192.168.2.25`)部署特权容器 `prod2u-thermal-test-backend`(`--privileged --cap-add=ALL --network=host --pid=host --ipc=host --uts=host -v /dev:/dev -v /sys:/sys`),具备完整内核、设备与网络栈权限,监听 `http://192.168.2.25:8766/`;
+   - 提供 Web 前端看板与 REST API(`/api/status`、`/api/runs`、`/api/test/start`、`/api/runs/<id>/recalculate`、`/api/runs/<id>/export/{csv,json,png,svg}`、`/api/compare/csv`),用于远程执行测试、对比不同风扇转速与介入时机/参考温度下的四腔升温达标耗时并导出数据。

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
generated/6400-v2/channel-map.json


+ 1 - 1
generated/6400-v2/contract-sha256.txt

@@ -1 +1 @@
-8a5b3ae1466eee7167f9e9dba2a649085ae271883f86f80b8eb87d6963503bba
+9ae08e229b88226767aa70f6fe1ec55dbfcdcbbcc8c8d66e614c04c10660d427

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
generated/6400-v2/fan-control-parameters.json


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
generated/6400-v2/golden-vectors.json


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
generated/6400-v2/host-contract.json


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
generated/6400-v2/manual-uart-contract.json


+ 5 - 5
generated/6400-v2/prod2u_6400_v2_params.vh

@@ -1,6 +1,6 @@
 `ifndef PROD2U_6400_V2_PARAMS_VH
 `ifndef PROD2U_6400_V2_PARAMS_VH
 `define PROD2U_6400_V2_PARAMS_VH
 `define PROD2U_6400_V2_PARAMS_VH
-// Generated from raw manual/wire/snapshot/fan/channel-map contracts; SHA256 8a5b3ae1466eee7167f9e9dba2a649085ae271883f86f80b8eb87d6963503bba
+// Generated from raw manual/wire/snapshot/fan/channel-map contracts; SHA256 9ae08e229b88226767aa70f6fe1ec55dbfcdcbbcc8c8d66e614c04c10660d427
 `define FB_CLOCK_HZ 25000000
 `define FB_CLOCK_HZ 25000000
 `define FB_PTC_COUNT 24
 `define FB_PTC_COUNT 24
 `define FB_FRONT_FAN_COUNT 4
 `define FB_FRONT_FAN_COUNT 4
@@ -13,10 +13,10 @@
 `define FB_HOST_CLKS_PER_BIT 27
 `define FB_HOST_CLKS_PER_BIT 27
 `define FB_BMC_CLKS_PER_BIT 217
 `define FB_BMC_CLKS_PER_BIT 217
 `define FB_PWM_PHASES 100
 `define FB_PWM_PHASES 100
-`define FB_PTC_PWM_HZ 500
-`define FB_FAN_PWM_HZ 500
-`define FB_PWM_PHASE_CLKS 500
-`define FB_PWM_PERIOD_CLKS 50000
+`define FB_PTC_PWM_HZ 20
+`define FB_FAN_PWM_HZ 20
+`define FB_PWM_PHASE_CLKS 12500
+`define FB_PWM_PERIOD_CLKS 1250000
 `define FAN_BOARD_INVERT_MASK 8'hFF
 `define FAN_BOARD_INVERT_MASK 8'hFF
 `define CONTROL_WATCHDOG_SECONDS 30
 `define CONTROL_WATCHDOG_SECONDS 30
 `define FB_FRAME_LENGTH_WIDTH 8
 `define FB_FRAME_LENGTH_WIDTH 8

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
generated/6400-v2/snapshot-layout.json


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
generated/6400/channel-map.json


+ 1 - 1
generated/6400/contract-sha256.txt

@@ -1 +1 @@
-9a6b6cc216c290dab7f6348f0c642f5da08065db8746182e9b07c75411b72f0a
+526c454779d2e31738c5ba9fe8f3e7ce56819b968445f9968a54221cf2a9d891

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
generated/6400/fan-control-parameters.json


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
generated/6400/golden-vectors.json


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
generated/6400/host-contract.json


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
generated/6400/manual-uart-contract.json


+ 5 - 5
generated/6400/prod2u_6400_v1_params.vh

@@ -1,6 +1,6 @@
 `ifndef PROD2U_6400_V1_PARAMS_VH
 `ifndef PROD2U_6400_V1_PARAMS_VH
 `define PROD2U_6400_V1_PARAMS_VH
 `define PROD2U_6400_V1_PARAMS_VH
-// Generated from raw manual/wire/snapshot/fan/channel-map contracts; SHA256 9a6b6cc216c290dab7f6348f0c642f5da08065db8746182e9b07c75411b72f0a
+// Generated from raw manual/wire/snapshot/fan/channel-map contracts; SHA256 526c454779d2e31738c5ba9fe8f3e7ce56819b968445f9968a54221cf2a9d891
 `define FB_CLOCK_HZ 25000000
 `define FB_CLOCK_HZ 25000000
 `define FB_PTC_COUNT 24
 `define FB_PTC_COUNT 24
 `define FB_FRONT_FAN_COUNT 4
 `define FB_FRONT_FAN_COUNT 4
@@ -13,10 +13,10 @@
 `define FB_HOST_CLKS_PER_BIT 27
 `define FB_HOST_CLKS_PER_BIT 27
 `define FB_BMC_CLKS_PER_BIT 217
 `define FB_BMC_CLKS_PER_BIT 217
 `define FB_PWM_PHASES 100
 `define FB_PWM_PHASES 100
-`define FB_PTC_PWM_HZ 500
-`define FB_FAN_PWM_HZ 500
-`define FB_PWM_PHASE_CLKS 500
-`define FB_PWM_PERIOD_CLKS 50000
+`define FB_PTC_PWM_HZ 20
+`define FB_FAN_PWM_HZ 20
+`define FB_PWM_PHASE_CLKS 12500
+`define FB_PWM_PERIOD_CLKS 1250000
 `define FAN_BOARD_INVERT_MASK 8'hFF
 `define FAN_BOARD_INVERT_MASK 8'hFF
 `define CONTROL_WATCHDOG_SECONDS 30
 `define CONTROL_WATCHDOG_SECONDS 30
 `define FB_FRAME_LENGTH_WIDTH 8
 `define FB_FRAME_LENGTH_WIDTH 8

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
generated/6400/snapshot-layout.json


+ 1 - 1
generated/mrdimm/contract-sha256.txt

@@ -1 +1 @@
-f0dddb226c396e49a2ee2c17630a94fb8ffce62dc85f62d4c87e4d4bb8e476b6
+077a8224f82717e1ddc32be20eeb70325cb297388cbd3b489eab869cd412b13d

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
generated/mrdimm/golden-vectors.json


+ 4 - 4
generated/mrdimm/prod2u_mrdimm_params.vh

@@ -1,6 +1,6 @@
 `ifndef PROD2U_MRDIMM_PARAMS_VH
 `ifndef PROD2U_MRDIMM_PARAMS_VH
 `define PROD2U_MRDIMM_PARAMS_VH
 `define PROD2U_MRDIMM_PARAMS_VH
-// Generated from raw wire/status/project contracts; SHA256 f0dddb226c396e49a2ee2c17630a94fb8ffce62dc85f62d4c87e4d4bb8e476b6
+// Generated from raw wire/status/project contracts; SHA256 077a8224f82717e1ddc32be20eeb70325cb297388cbd3b489eab869cd412b13d
 `define MR_CLOCK_HZ 25000000
 `define MR_CLOCK_HZ 25000000
 `define MR_HOST_BAUD 921600
 `define MR_HOST_BAUD 921600
 `define MR_HOST_CLKS_PER_BIT 27
 `define MR_HOST_CLKS_PER_BIT 27
@@ -29,10 +29,10 @@
 `define MR_FAN_COUNT 4
 `define MR_FAN_COUNT 4
 `define MR_PTC_COUNT 4
 `define MR_PTC_COUNT 4
 `define MR_PTC_PHYSICAL 24
 `define MR_PTC_PHYSICAL 24
-`define MR_PWM_HZ 500
+`define MR_PWM_HZ 20
 `define MR_PWM_PHASES 100
 `define MR_PWM_PHASES 100
-`define MR_PWM_PHASE_CLKS 500
-`define MR_PWM_PERIOD_CLKS 50000
+`define MR_PWM_PHASE_CLKS 12500
+`define MR_PWM_PERIOD_CLKS 1250000
 `define MR_LIMIT_ACTIVE_HIGH 1
 `define MR_LIMIT_ACTIVE_HIGH 1
 `define MR_BOOT_FAN_PERCENT 20
 `define MR_BOOT_FAN_PERCENT 20
 `define MR_BOOT_PTC_PERCENT 0
 `define MR_BOOT_PTC_PERCENT 0

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
generated/mrdimm/snapshot-layout.json


+ 1 - 1
products/6400-v2/project.json

@@ -84,7 +84,7 @@
   },
   },
   "ssr_control": {
   "ssr_control": {
     "count": 3,
     "count": 3,
-    "pwm_hz": 500,
+    "pwm_hz": 20,
     "default_percent": 0,
     "default_percent": 0,
     "set_offset": 32,
     "set_offset": 32,
     "get_offset": 83,
     "get_offset": 83,

+ 3 - 3
projects/mrdimm-chamber/project.json

@@ -78,9 +78,9 @@
     "chamber_ptc_count": 4,
     "chamber_ptc_count": 4,
     "physical_ptc_count": 24,
     "physical_ptc_count": 24,
     "ptc_map": "4 logical chambers mapped onto 24 physical PTC outputs (6 heaters per chamber: Chamber 1 on CON18, Chamber 2 on CON27, Chamber 3 on CON28, Chamber 4 on CON29)",
     "ptc_map": "4 logical chambers mapped onto 24 physical PTC outputs (6 heaters per chamber: Chamber 1 on CON18, Chamber 2 on CON27, Chamber 3 on CON28, Chamber 4 on CON29)",
-    "ptc_pwm_hz": 500,
-    "fan_pwm_hz": 500,
-    "pwm_period_clks": 50000,
+    "ptc_pwm_hz": 20,
+    "fan_pwm_hz": 20,
+    "pwm_period_clks": 1250000,
     "boot": {
     "boot": {
       "ptc_percent": 0,
       "ptc_percent": 0,
       "fan_percent": 20
       "fan_percent": 20

+ 4 - 4
projects/prod2u-6400-front-back/project.json

@@ -521,10 +521,10 @@
     "pwm_internal_width": 7,
     "pwm_internal_width": 7,
     "pwm_max_duty": 100,
     "pwm_max_duty": 100,
     "pwm_phase_count": 100,
     "pwm_phase_count": 100,
-    "pwm_phase_clks": 500,
-    "pwm_period_clks": 50000,
-    "pwm_frequency_hz": 500,
-    "pwm_actual_frequency_hz": 500.0,
+    "pwm_phase_clks": 12500,
+    "pwm_period_clks": 1250000,
+    "pwm_frequency_hz": 20,
+    "pwm_actual_frequency_hz": 20.0,
     "ptc_polarity": "active_high",
     "ptc_polarity": "active_high",
     "fan_polarity": "active_low",
     "fan_polarity": "active_low",
     "ptc_default": 0,
     "ptc_default": 0,

+ 2 - 2
src/actuator/pwm_bitmap_engine.v

@@ -5,8 +5,8 @@
 module pwm_bitmap_engine #(
 module pwm_bitmap_engine #(
     parameter integer CHANNEL_COUNT = 32,
     parameter integer CHANNEL_COUNT = 32,
     parameter integer PHASE_COUNT = 100,
     parameter integer PHASE_COUNT = 100,
-    parameter integer PTC_PHASE_CLKS = 500,
-    parameter integer FAN_PHASE_CLKS = 500,
+    parameter integer PTC_PHASE_CLKS = 12500,
+    parameter integer FAN_PHASE_CLKS = 12500,
     parameter integer ADDR_WIDTH = 5,
     parameter integer ADDR_WIDTH = 5,
     parameter [7:0] RESET_FAN_DUTY = 8'd20,
     parameter [7:0] RESET_FAN_DUTY = 8'd20,
     parameter [CHANNEL_COUNT-1:0] RESET_FAN_MASK=32'hFF000000
     parameter [CHANNEL_COUNT-1:0] RESET_FAN_MASK=32'hFF000000

+ 2 - 2
src/actuator/ssr_time_proportion.v

@@ -1,9 +1,9 @@
 `timescale 1ns/1ps
 `timescale 1ns/1ps
-// Three DC SSR heater controls at 500 Hz, matching PTC/fan frequency.
+// Three DC SSR heater controls at 20 Hz, matching PTC/fan frequency.
 // Common free-running phase,
 // Common free-running phase,
 // independent percentages; SSR2 is one physical output shared by chambers 2+3.
 // independent percentages; SSR2 is one physical output shared by chambers 2+3.
 module ssr_time_proportion #(
 module ssr_time_proportion #(
-    parameter integer PHASE_CLKS = 500 // 20 us at 25 MHz; 100 steps = 2 ms (500 Hz)
+    parameter integer PHASE_CLKS = 12500 // 500 us at 25 MHz; 100 steps = 50 ms (20 Hz)
 )(
 )(
     input wire clk,
     input wire clk,
     input wire rst_n,
     input wire rst_n,

+ 2 - 2
src/control/mrdimm_output_core.v

@@ -25,8 +25,8 @@ module mrdimm_output_core #(
     parameter [7:0] EXPIRE_FAN_PERCENT = 8'd20,
     parameter [7:0] EXPIRE_FAN_PERCENT = 8'd20,
     parameter [7:0] EXPIRE_PTC_PERCENT = 8'd0,
     parameter [7:0] EXPIRE_PTC_PERCENT = 8'd0,
     parameter [7:0] LEASE_SECONDS = 8'd30,
     parameter [7:0] LEASE_SECONDS = 8'd30,
-    parameter integer PWM_PERIOD_CLKS = 50000,
-    parameter integer PWM_CLKS_PER_PERCENT = 500
+    parameter integer PWM_PERIOD_CLKS = 1250000,
+    parameter integer PWM_CLKS_PER_PERCENT = 12500
 ) (
 ) (
     input  wire       clk,
     input  wire       clk,
     input  wire       rst_n,
     input  wire       rst_n,

+ 4 - 4
src/generated/6400/host-contract.json

@@ -564,13 +564,13 @@
     "ptc_count": 24,
     "ptc_count": 24,
     "ptc_default": 0,
     "ptc_default": 0,
     "ptc_polarity": "active_high",
     "ptc_polarity": "active_high",
-    "pwm_actual_frequency_hz": 500.0,
+    "pwm_actual_frequency_hz": 20.0,
     "pwm_bits": 8,
     "pwm_bits": 8,
-    "pwm_frequency_hz": 500,
+    "pwm_frequency_hz": 20,
     "pwm_internal_width": 7,
     "pwm_internal_width": 7,
     "pwm_max_duty": 100,
     "pwm_max_duty": 100,
-    "pwm_period_clks": 50000,
-    "pwm_phase_clks": 500,
+    "pwm_period_clks": 1250000,
+    "pwm_phase_clks": 12500,
     "pwm_phase_count": 100
     "pwm_phase_count": 100
   },
   },
   "profile": "thermal-24ptc-8fan-v1",
   "profile": "thermal-24ptc-8fan-v1",

+ 6 - 6
src/generated/6400/prod2u_6400_front_back_params.vh

@@ -10,9 +10,9 @@
 `define P4_PWM_INTERNAL_WIDTH 7
 `define P4_PWM_INTERNAL_WIDTH 7
 `define P4_PWM_MAX_DUTY 100
 `define P4_PWM_MAX_DUTY 100
 `define P4_PWM_PHASE_COUNT 100
 `define P4_PWM_PHASE_COUNT 100
-`define P4_PWM_FREQUENCY_HZ 500
-`define P4_PWM_PHASE_CLKS 500
-`define P4_PWM_PERIOD_CLKS 50000
+`define P4_PWM_FREQUENCY_HZ 20
+`define P4_PWM_PHASE_CLKS 12500
+`define P4_PWM_PERIOD_CLKS 1250000
 `define P4_CMD_SET_ALL 8'h01
 `define P4_CMD_SET_ALL 8'h01
 `define P4_CMD_GET_TEMPERATURE 8'h02
 `define P4_CMD_GET_TEMPERATURE 8'h02
 `define P4_CMD_TEMPERATURE_DATA 8'h82
 `define P4_CMD_TEMPERATURE_DATA 8'h82
@@ -51,9 +51,9 @@
 `define FB_PWM_INTERNAL_WIDTH 7
 `define FB_PWM_INTERNAL_WIDTH 7
 `define FB_PWM_MAX_DUTY 100
 `define FB_PWM_MAX_DUTY 100
 `define FB_PWM_PHASE_COUNT 100
 `define FB_PWM_PHASE_COUNT 100
-`define FB_PWM_FREQUENCY_HZ 500
-`define FB_PWM_PHASE_CLKS 500
-`define FB_PWM_PERIOD_CLKS 50000
+`define FB_PWM_FREQUENCY_HZ 20
+`define FB_PWM_PHASE_CLKS 12500
+`define FB_PWM_PERIOD_CLKS 1250000
 `define FB_CMD_SET_ALL 8'h01
 `define FB_CMD_SET_ALL 8'h01
 `define FB_CMD_GET_TEMPERATURE 8'h02
 `define FB_CMD_GET_TEMPERATURE 8'h02
 `define FB_CMD_TEMPERATURE_DATA 8'h82
 `define FB_CMD_TEMPERATURE_DATA 8'h82

+ 5 - 5
src/generated/6400/project-summary.json

@@ -1,11 +1,11 @@
 {
 {
-  "actual_frequency_hz": 500.0,
+  "actual_frequency_hz": 20.0,
   "profile": "thermal-24ptc-8fan-v1",
   "profile": "thermal-24ptc-8fan-v1",
-  "project_config_sha256": "ab1467dc7282e0e6207e0959dffa0453a9ee8f32aba37a8c6f5e03f05c0acd2d",
+  "project_config_sha256": "dc7044baa527aef39e923875ecb67437b560ceb97927979178f62c18d02bc4e9",
   "project_id": "prod2u-6400-front-back",
   "project_id": "prod2u-6400-front-back",
-  "pwm_frequency_hz": 500,
-  "pwm_period_clks": 50000,
-  "pwm_phase_clks": 500,
+  "pwm_frequency_hz": 20,
+  "pwm_period_clks": 1250000,
+  "pwm_phase_clks": 12500,
   "release_blocked": false,
   "release_blocked": false,
   "release_status": "release-ready",
   "release_status": "release-ready",
   "set_all_frame_len": 38,
   "set_all_frame_len": 38,

+ 2 - 2
src/generated/6400/td-source-manifest.json

@@ -57,11 +57,11 @@
   },
   },
   "generated_from": "project.json",
   "generated_from": "project.json",
   "lifecycle": "historical_only",
   "lifecycle": "historical_only",
-  "project_config_sha256": "ab1467dc7282e0e6207e0959dffa0453a9ee8f32aba37a8c6f5e03f05c0acd2d",
+  "project_config_sha256": "dc7044baa527aef39e923875ecb67437b560ceb97927979178f62c18d02bc4e9",
   "project_id": "prod2u-6400-front-back",
   "project_id": "prod2u-6400-front-back",
   "release_status": "release-ready",
   "release_status": "release-ready",
   "schema": "prod2u-simple-source-manifest-template-v1",
   "schema": "prod2u-simple-source-manifest-template-v1",
-  "source_manifest_sha256": "11385a146a9c15ab3a8e6dd7749c43800ff6ba6d8ff401e071969739e9fada09",
+  "source_manifest_sha256": "4a320a1916ddec6901e9feffde6b7cefa03bd011689ae201640454080440c1a8",
   "sources": [
   "sources": [
     "src/generated/6400/prod2u_6400_front_back_params.vh",
     "src/generated/6400/prod2u_6400_front_back_params.vh",
     "src/common/uart_rx_byte.v",
     "src/common/uart_rx_byte.v",

+ 6 - 4
src/top/prod2u_6400_final_top.v

@@ -122,6 +122,7 @@ module prod2u_6400_final_top (
     wire        wd_expired;
     wire        wd_expired;
 
 
     wire        pwm_phase_boundary;
     wire        pwm_phase_boundary;
+    wire        pwm_phase_boundary_advance;
     wire [6:0]  pwm_phase_value;
     wire [6:0]  pwm_phase_value;
 
 
     always @(posedge sys_clk or negedge sys_rst_n) begin
     always @(posedge sys_clk or negedge sys_rst_n) begin
@@ -135,14 +136,15 @@ module prod2u_6400_final_top (
             commit_ack_r  <= 1'b0;
             commit_ack_r  <= 1'b0;
             wd_reload_d   <= wd_reload;
             wd_reload_d   <= wd_reload;
 
 
-            if (commit_req && !commit_pending && (pwm_phase_value == 7'd98) && pwm_phase_boundary) begin
+            if (!commit_req) begin
+                commit_pending <= 1'b0;
+            end else if (!commit_pending && !stage_we && pwm_scan_idle && !pwm_phase_boundary_advance) begin
                 duty_commit_r  <= 1'b1;
                 duty_commit_r  <= 1'b1;
                 commit_pending <= 1'b1;
                 commit_pending <= 1'b1;
             end
             end
 
 
-            if (commit_pending && (pwm_phase_value == 7'd99) && pwm_phase_boundary) begin
+            if (duty_commit_r) begin
                 commit_ack_r   <= 1'b1;
                 commit_ack_r   <= 1'b1;
-                commit_pending <= 1'b0;
             end
             end
         end
         end
     end
     end
@@ -309,7 +311,7 @@ module prod2u_6400_final_top (
         .duty_rd_addr(pwm_addr), .duty_rd_data(pwm_duty),
         .duty_rd_addr(pwm_addr), .duty_rd_data(pwm_duty),
         .logical_bitmap(logical_bitmap),
         .logical_bitmap(logical_bitmap),
         .phase_boundary(pwm_phase_boundary),
         .phase_boundary(pwm_phase_boundary),
-        .phase_boundary_advance(),
+        .phase_boundary_advance(pwm_phase_boundary_advance),
         .deadline_miss(pwm_deadline_miss),
         .deadline_miss(pwm_deadline_miss),
         .phase_value(pwm_phase_value),
         .phase_value(pwm_phase_value),
         .scan_idle(pwm_scan_idle)
         .scan_idle(pwm_scan_idle)

+ 14 - 9
src/top/prod2u_6400_v2_top.v

@@ -12,7 +12,7 @@
 //    chamber 2 = CON56/57, chamber 3 = CON79/80, chamber 4 = CON81/82).
 //    chamber 2 = CON56/57, chamber 3 = CON79/80, chamber 4 = CON81/82).
 //    Channels 9..26 in temp_ram return 0xFF without polling non-existent chips.
 //    Channels 9..26 in temp_ram return 0xFF without polling non-existent chips.
 // 4. Three controlled SSR heaters (SSR1=ch1, SSR2=shared ch2+3, SSR4=ch4),
 // 4. Three controlled SSR heaters (SSR1=ch1, SSR2=shared ch2+3, SSR4=ch4),
-//    500 Hz PWM (2 ms period), default/watchdog 0; SET35 and GET86 append three bytes.
+//    20 Hz PWM (50 ms period), default/watchdog 0; SET35 and GET86 append three bytes.
 // 5. Dual-bank duty register architecture: u_duty_bank dedicated to PWM scanning,
 // 5. Dual-bank duty register architecture: u_duty_bank dedicated to PWM scanning,
 //    u_telemetry_bank dedicated to GET telemetry. Eliminates address contention.
 //    u_telemetry_bank dedicated to GET telemetry. Eliminates address contention.
 // 6. Temperature write conflict arbiter with pending register so simultaneous
 // 6. Temperature write conflict arbiter with pending register so simultaneous
@@ -22,7 +22,8 @@ module prod2u_6400_v2_top #(
     parameter integer HOST_BAUD = `PROD2U_HOST_BAUD,
     parameter integer HOST_BAUD = `PROD2U_HOST_BAUD,
     parameter [7:0] FAN_BOARD_INVERT_MASK = 8'hFF,
     parameter [7:0] FAN_BOARD_INVERT_MASK = 8'hFF,
     parameter integer WD_TIMEOUT_CLKS = 750000000,
     parameter integer WD_TIMEOUT_CLKS = 750000000,
-    parameter integer SSR_PHASE_CLKS = 500
+    parameter integer SSR_PHASE_CLKS = 12500,
+    parameter integer PWM_PHASE_CLKS = 12500
 ) (
 ) (
     input  wire        sys_clk,
     input  wire        sys_clk,
     input  wire        host_ttl_rx,
     input  wire        host_ttl_rx,
@@ -145,6 +146,7 @@ module prod2u_6400_v2_top #(
     wire        wd_expired;
     wire        wd_expired;
 
 
     wire        pwm_phase_boundary;
     wire        pwm_phase_boundary;
+    wire        pwm_phase_boundary_advance;
     wire [6:0]  pwm_phase_value;
     wire [6:0]  pwm_phase_value;
 
 
     always @(posedge sys_clk or negedge sys_rst_n) begin
     always @(posedge sys_clk or negedge sys_rst_n) begin
@@ -158,16 +160,17 @@ module prod2u_6400_v2_top #(
             commit_ack_r  <= 1'b0;
             commit_ack_r  <= 1'b0;
             wd_reload_d   <= wd_reload;
             wd_reload_d   <= wd_reload;
 
 
-            // Flip active bank at phase 98->99 boundary: phase 99 pre-fetches for build_phase == 0
-            if (commit_req && !commit_pending && (pwm_phase_value == 7'd98) && pwm_phase_boundary) begin
+            // Flip active bank once staging finishes and PWM scanner is idle
+            if (!commit_req) begin
+                commit_pending <= 1'b0;
+            end else if (!commit_pending && !stage_we && pwm_scan_idle && !pwm_phase_boundary_advance) begin
                 duty_commit_r  <= 1'b1;
                 duty_commit_r  <= 1'b1;
                 commit_pending <= 1'b1;
                 commit_pending <= 1'b1;
             end
             end
 
 
-            // Drive adoption at phase 99->0 boundary: output pins actively drive the new period
-            if (commit_pending && (pwm_phase_value == 7'd99) && pwm_phase_boundary) begin
+            // Acknowledge adoption on next cycle once duty banks have flipped
+            if (duty_commit_r) begin
                 commit_ack_r   <= 1'b1;
                 commit_ack_r   <= 1'b1;
-                commit_pending <= 1'b0;
             end
             end
         end
         end
     end
     end
@@ -378,7 +381,7 @@ module prod2u_6400_v2_top #(
     wire        wd_counting;
     wire        wd_counting;
 
 
     wire [7:0] diagnostic_flags = {3'b0, bank_valid, wd_expired, q_overflow, bmc_framing_error_seen, bmc_round_failed};
     wire [7:0] diagnostic_flags = {3'b0, bank_valid, wd_expired, q_overflow, bmc_framing_error_seen, bmc_round_failed};
-    wire [159:0] diagnostic_data = {diagnostic_flags, 3'b0, bmc_valid_count, ct_diagnostic_data, 8'd3, 8'd0, 8'd3, 8'h64, 8'd1};
+    wire [159:0] diagnostic_data = {diagnostic_flags, 3'b0, bmc_valid_count, ct_diagnostic_data, 8'd4, 8'd0, 8'd3, 8'h64, 8'd1};
     m6400_transaction_core #(
     m6400_transaction_core #(
         .DUTY_COUNT(35),
         .DUTY_COUNT(35),
         .GET_DUTY_PREFIX_COUNT(32),
         .GET_DUTY_PREFIX_COUNT(32),
@@ -442,6 +445,8 @@ module prod2u_6400_v2_top #(
 
 
     pwm_bitmap_engine #(
     pwm_bitmap_engine #(
         .CHANNEL_COUNT(32),
         .CHANNEL_COUNT(32),
+        .PTC_PHASE_CLKS(PWM_PHASE_CLKS),
+        .FAN_PHASE_CLKS(PWM_PHASE_CLKS),
         .ADDR_WIDTH(5),
         .ADDR_WIDTH(5),
         .RESET_FAN_DUTY(8'd20),
         .RESET_FAN_DUTY(8'd20),
         .RESET_FAN_MASK(32'hFF000000)
         .RESET_FAN_MASK(32'hFF000000)
@@ -451,7 +456,7 @@ module prod2u_6400_v2_top #(
         .duty_rd_addr(pwm_addr), .duty_rd_data(pwm_duty),
         .duty_rd_addr(pwm_addr), .duty_rd_data(pwm_duty),
         .logical_bitmap(logical_bitmap),
         .logical_bitmap(logical_bitmap),
         .phase_boundary(pwm_phase_boundary),
         .phase_boundary(pwm_phase_boundary),
-        .phase_boundary_advance(),
+        .phase_boundary_advance(pwm_phase_boundary_advance),
         .deadline_miss(pwm_deadline_miss),
         .deadline_miss(pwm_deadline_miss),
         .phase_value(pwm_phase_value),
         .phase_value(pwm_phase_value),
         .scan_idle(pwm_scan_idle)
         .scan_idle(pwm_scan_idle)

+ 2 - 2
src/top/prod2u_mrdimm_final_top.v

@@ -12,8 +12,8 @@ module prod2u_mrdimm_final_top #(
     parameter integer CLOCK_HZ = 25000000,
     parameter integer CLOCK_HZ = 25000000,
     parameter integer HOST_BAUD = `PROD2U_HOST_BAUD,
     parameter integer HOST_BAUD = `PROD2U_HOST_BAUD,
     parameter integer BMC_BAUD = 115200,
     parameter integer BMC_BAUD = 115200,
-    parameter integer PWM_PERIOD_CLKS = 50000,
-    parameter integer PWM_CLKS_PER_PERCENT = 500,
+    parameter integer PWM_PERIOD_CLKS = 1250000,
+    parameter integer PWM_CLKS_PER_PERCENT = 12500,
     parameter integer HOST_TIMEOUT_CYCLES = 250000
     parameter integer HOST_TIMEOUT_CYCLES = 250000
 ) (
 ) (
     input  wire        sys_clk,
     input  wire        sys_clk,

+ 4 - 4
tests/sim/mrdimm_pwm_contract_tb.v

@@ -20,12 +20,12 @@ assign ap[3]=ap_packed[3*8 +:8];
  task count_period(input reset_values);
  task count_period(input reset_values);
  begin
  begin
   for(i=0;i<8;i=i+1)highs[i]=0;
   for(i=0;i<8;i=i+1)highs[i]=0;
-  for(n=0;n<50000;n=n+1)begin
+  for(n=0;n<1250000;n=n+1)begin
    for(i=0;i<4;i=i+1)begin if(fan[i])highs[i]=highs[i]+1;if(ptc[i])highs[i+4]=highs[i+4]+1;end
    for(i=0;i<4;i=i+1)begin if(fan[i])highs[i]=highs[i]+1;if(ptc[i])highs[i+4]=highs[i+4]+1;end
    @(negedge clk);
    @(negedge clk);
   end
   end
   for(i=0;i<8;i=i+1)
   for(i=0;i<8;i=i+1)
-   if(highs[i]!=(reset_values?(i<4?10000:0):duties[i]*500))$fatal(1,"PWM channel%0d high%0d",i,highs[i]);
+   if(highs[i]!=(reset_values?(i<4?250000:0):duties[i]*12500))$fatal(1,"PWM channel%0d high%0d",i,highs[i]);
  end endtask
  end endtask
  initial begin
  initial begin
   duties[0]=0;duties[1]=1;duties[2]=20;duties[3]=50;duties[4]=99;duties[5]=100;duties[6]=20;duties[7]=1;
   duties[0]=0;duties[1]=1;duties[2]=20;duties[3]=50;duties[4]=99;duties[5]=100;duties[6]=20;duties[7]=1;
@@ -33,7 +33,7 @@ assign ap[3]=ap_packed[3*8 +:8];
   keepalive=1;@(negedge clk);keepalive=0;if(active)$fatal(1,"inactive keepalive started lease");
   keepalive=1;@(negedge clk);keepalive=0;if(active)$fatal(1,"inactive keepalive started lease");
   for(i=0;i<8;i=i+1)begin wr=1;addr=i;data=duties[i];@(negedge clk);end
   for(i=0;i<8;i=i+1)begin wr=1;addr=i;data=duties[i];@(negedge clk);end
   wr=0;commit=1;@(negedge clk);commit=0;if(!done||!ok||remaining!=30)$fatal(1,"commit/lease");
   wr=0;commit=1;@(negedge clk);commit=0;if(!done||!ok||remaining!=30)$fatal(1,"commit/lease");
-  repeat(51000)@(negedge clk);count_period(0);
+  repeat(1260000)@(negedge clk);count_period(0);
   for(i=0;i<29;i=i+1)begin tick=1;@(negedge clk);tick=0;@(negedge clk);end
   for(i=0;i<29;i=i+1)begin tick=1;@(negedge clk);tick=0;@(negedge clk);end
   if(remaining!=1)$fatal(1,"lease ticks");
   if(remaining!=1)$fatal(1,"lease ticks");
   tick=1;keepalive=1;@(negedge clk);tick=0;keepalive=0;
   tick=1;keepalive=1;@(negedge clk);tick=0;keepalive=0;
@@ -43,5 +43,5 @@ assign ap[3]=ap_packed[3*8 +:8];
   rst_n=1;repeat(123)@(negedge clk);count_period(1);
   rst_n=1;repeat(123)@(negedge clk);count_period(1);
   $display("mrdimm_pwm_contract_tb PASS");$finish;
   $display("mrdimm_pwm_contract_tb PASS");$finish;
  end
  end
- initial begin #20000000;$fatal(1,"PWM deadline");end
+ initial begin #500000000;$fatal(1,"PWM deadline");end
 endmodule
 endmodule

+ 55 - 19
tests/sim/prod2u_6400_v2_connector_tb.v

@@ -5,7 +5,7 @@
 // ADC.  Expected physical connector order below is fixed from BRD + PDF.
 // ADC.  Expected physical connector order below is fixed from BRD + PDF.
 module prod2u_6400_v2_connector_tb;
 module prod2u_6400_v2_connector_tb;
     localparam real BIT_NS = 1000000000.0 / 921600.0;
     localparam real BIT_NS = 1000000000.0 / 921600.0;
-    localparam integer MEASURE_CYCLES = 100000; // two real 500 Hz periods
+    localparam integer MEASURE_CYCLES = 1250000; // one complete 20 Hz period (100 * 12,500 clocks)
     reg clk = 0;
     reg clk = 0;
     always #20 clk = ~clk;
     always #20 clk = ~clk;
     reg host_ttl_rx = 1, host_rs232_rx = 1;
     reg host_ttl_rx = 1, host_rs232_rx = 1;
@@ -32,6 +32,45 @@ module prod2u_6400_v2_connector_tb;
     integer i, j, cycle_count;
     integer i, j, cycle_count;
     reg [2:0] expected_ssr = 0;
     reg [2:0] expected_ssr = 0;
     reg [15:0] get_crc;
     reg [15:0] get_crc;
+    reg measuring = 0;
+    reg [7:0] prev_fan = 0;
+    reg [23:0] prev_ptc = 0;
+    integer run_len = 0;
+    integer run_start_cycle = 0;
+
+    task flush_run;
+        integer fk, cur_cycle;
+        begin
+            cur_cycle = $time / 40;
+            run_len = cur_cycle - run_start_cycle;
+            run_start_cycle = cur_cycle;
+            if (run_len > 0) begin
+                for (fk = 0; fk < 8; fk = fk + 1) begin
+                    if (prev_fan[fk] !== 0 && prev_fan[fk] !== 1)
+                        $fatal(1, "undefined fan connector channel %0d", fk+1);
+                    if (prev_fan[fk]) fan_high[fk] = fan_high[fk] + run_len;
+                end
+                for (fk = 0; fk < 24; fk = fk + 1) begin
+                    if (prev_ptc[fk] !== 0 && prev_ptc[fk] !== 1)
+                        $fatal(1, "undefined PTC connector channel %0d", fk+1);
+                    if (prev_ptc[fk]) ptc_high[fk] = ptc_high[fk] + run_len;
+                end
+                run_len = 0;
+            end
+        end
+    endtask
+
+    always @(fan_connector_pwm or ptc_connector_pwm or spare_connector_pwm or ssr_connector) begin
+        if (measuring) begin
+            if (spare_connector_pwm !== 11'b0 || ssr_connector !== expected_ssr)
+                $fatal(1, "spare PTC/SSR connector output changed: %b/%b", spare_connector_pwm, ssr_connector);
+            if (fan_connector_pwm !== prev_fan || ptc_connector_pwm !== prev_ptc) begin
+                flush_run;
+                prev_fan = fan_connector_pwm;
+                prev_ptc = ptc_connector_pwm;
+            end
+        end
+    end
 
 
     function [15:0] crc_byte;
     function [15:0] crc_byte;
         input [15:0] prior;
         input [15:0] prior;
@@ -92,27 +131,24 @@ module prod2u_6400_v2_connector_tb;
     endtask
     endtask
 
 
     task measure_connectors;
     task measure_connectors;
-        integer k, n;
+        integer k;
         begin
         begin
             for (k = 0; k < 8; k = k + 1) fan_high[k] = 0;
             for (k = 0; k < 8; k = k + 1) fan_high[k] = 0;
             for (k = 0; k < 24; k = k + 1) ptc_high[k] = 0;
             for (k = 0; k < 24; k = k + 1) ptc_high[k] = 0;
             // Window starts at arbitrary external clock phase; its exact
             // Window starts at arbitrary external clock phase; its exact
-            // length covers two periods without inspecting DUT PWM state.
-            for (n = 0; n < MEASURE_CYCLES; n = n + 1) begin
-                @(negedge clk);
-                if (spare_connector_pwm !== 11'b0 || ssr_connector !== expected_ssr)
-                    $fatal(1, "spare PTC/SSR connector output changed: %b/%b", spare_connector_pwm, ssr_connector);
-                for (k = 0; k < 8; k = k + 1) begin
-                    if (fan_connector_pwm[k] !== 0 && fan_connector_pwm[k] !== 1)
-                        $fatal(1, "undefined fan connector channel %0d", k+1);
-                    if (fan_connector_pwm[k]) fan_high[k] = fan_high[k] + 1;
-                end
-                for (k = 0; k < 24; k = k + 1) begin
-                    if (ptc_connector_pwm[k] !== 0 && ptc_connector_pwm[k] !== 1)
-                        $fatal(1, "undefined PTC connector channel %0d", k+1);
-                    if (ptc_connector_pwm[k]) ptc_high[k] = ptc_high[k] + 1;
-                end
-            end
+            // length covers one full period without inspecting DUT PWM state.
+            @(negedge clk);
+            #1;
+            if (spare_connector_pwm !== 11'b0 || ssr_connector !== expected_ssr)
+                $fatal(1, "spare PTC/SSR connector output changed: %b/%b", spare_connector_pwm, ssr_connector);
+            prev_fan = fan_connector_pwm;
+            prev_ptc = ptc_connector_pwm;
+            run_len = 0;
+            run_start_cycle = $time / 40;
+            measuring = 1;
+            #(MEASURE_CYCLES * 40);
+            measuring = 0;
+            flush_run;
             for (k = 0; k < 8; k = k + 1)
             for (k = 0; k < 8; k = k + 1)
                 if (fan_high[k] != expected_fan[k] * (MEASURE_CYCLES/100))
                 if (fan_high[k] != expected_fan[k] * (MEASURE_CYCLES/100))
                     $fatal(1, "physical FAN_PWM%0d high clocks=%0d expected=%0d (%0d percent); check ADC permutation and one MOS inversion",
                     $fatal(1, "physical FAN_PWM%0d high clocks=%0d expected=%0d (%0d percent); check ADC permutation and one MOS inversion",
@@ -202,7 +238,7 @@ module prod2u_6400_v2_connector_tb;
         $finish;
         $finish;
     end
     end
     initial begin
     initial begin
-        #50000000;
+        #500000000;
         $fatal(1, "prod2u_6400_v2_connector_tb timeout");
         $fatal(1, "prod2u_6400_v2_connector_tb timeout");
     end
     end
 endmodule
 endmodule

+ 78 - 34
tests/sim/prod2u_v3_protocol_tb.v

@@ -15,7 +15,7 @@ module prod2u_v3_protocol_tb;
     wire [2:0] ssr;
     wire [2:0] ssr;
     wire [31:0] ct_reads;
     wire [31:0] ct_reads;
     wire [8:0] ct_seen;
     wire [8:0] ct_seen;
-    prod2u_6400_v2_top #(.HOST_BAUD(921600), .WD_TIMEOUT_CLKS(500000)) dut (
+    prod2u_6400_v2_top #(.HOST_BAUD(921600), .WD_TIMEOUT_CLKS(1400000)) dut (
         .sys_clk(clk), .host_ttl_rx(host_rx), .host_ttl_tx(host_tx),
         .sys_clk(clk), .host_ttl_rx(host_rx), .host_ttl_tx(host_tx),
         .host_rs232_rx(1'b1), .host_rs232_tx(broadcast_tx),
         .host_rs232_rx(1'b1), .host_rs232_tx(broadcast_tx),
         .bmc_rs232_rx(1'b1), .bmc_rs232_tx(),
         .bmc_rs232_rx(1'b1), .bmc_rs232_tx(),
@@ -23,9 +23,10 @@ module prod2u_v3_protocol_tb;
         .temp_scl(scl), .temp_sda(sda), .temp_scl_alt(), .temp_sda_alt(),
         .temp_scl(scl), .temp_sda(sda), .temp_scl_alt(), .temp_sda_alt(),
         .ssr1_out(ssr[0]), .ssr2_out(ssr[1]), .ssr4_out(ssr[2]), .ptc_spare_zero()
         .ssr1_out(ssr[0]), .ssr2_out(ssr[1]), .ssr4_out(ssr[2]), .ptc_spare_zero()
     );
     );
-    defparam dut.u_core.BEACON_PERIOD = 100000;
-    always @(posedge clk) begin
-        if (dut.ssr_unused_zero !== 3'b000) $fatal(1, "retired SSR pads must stay low");
+    defparam dut.u_core.BEACON_PERIOD = 400000;
+    always @(dut.ssr_unused_zero) begin
+        #1;
+        if ($time > 100 && dut.ssr_unused_zero !== 3'b000) $fatal(1, "retired SSR pads must stay low");
     end
     end
     ct7428_normal_slave_bfm #(.DIAGNOSTIC_REGISTERS(1)) ct (.scl(scl), .sda(sda),
     ct7428_normal_slave_bfm #(.DIAGNOSTIC_REGISTERS(1)) ct (.scl(scl), .sda(sda),
         .completed_reads(ct_reads), .registers_seen(ct_seen));
         .completed_reads(ct_reads), .registers_seen(ct_seen));
@@ -154,7 +155,7 @@ module prod2u_v3_protocol_tb;
                     if(!pending_auto) $fatal(1,"unexpected unpaired diagnostic");
                     if(!pending_auto) $fatal(1,"unexpected unpaired diagnostic");
                     pending_auto=0;diag_count=diag_count+1;
                     pending_auto=0;diag_count=diag_count+1;
                     if(wire_bytes[p]!==1 || wire_bytes[p+1]!==8'h64 ||
                     if(wire_bytes[p]!==1 || wire_bytes[p+1]!==8'h64 ||
-                       wire_bytes[p+2]!==3 || wire_bytes[p+3]!==0 || wire_bytes[p+4]!==3)
+                       wire_bytes[p+2]!==3 || wire_bytes[p+3]!==0 || wire_bytes[p+4]!==4)
                         $fatal(1,"diagnostic format/product/version identity");
                         $fatal(1,"diagnostic format/product/version identity");
                     if(wire_bytes[rx_base+3]!==20) $fatal(1,"diagnostic length");
                     if(wire_bytes[rx_base+3]!==20) $fatal(1,"diagnostic length");
                     if(wire_bytes[p+5][5]) begin
                     if(wire_bytes[p+5][5]) begin
@@ -173,8 +174,11 @@ module prod2u_v3_protocol_tb;
             rx_base=byte_count;rx_size=0;
             rx_base=byte_count;rx_size=0;
         end
         end
     end
     end
-    always @(negedge clk) if($time>100000 && host_tx!==broadcast_tx)
-        $fatal(1,"host UART broadcast outputs diverged");
+    always @(host_tx or broadcast_tx) begin
+        #1;
+        if($time>100000 && host_tx!==broadcast_tx)
+            $fatal(1,"host UART broadcast outputs diverged");
+    end
 
 
     task await_type;
     task await_type;
         input integer wanted;
         input integer wanted;
@@ -213,28 +217,62 @@ module prod2u_v3_protocol_tb;
                 if(wire_bytes[base+83+j]!==expected[32+j]) $fatal(1,"SSR append offset%0d=%0d expected%0d",83+j,wire_bytes[base+83+j],expected[32+j]);
                 if(wire_bytes[base+83+j]!==expected[32+j]) $fatal(1,"SSR append offset%0d=%0d expected%0d",83+j,wire_bytes[base+83+j],expected[32+j]);
         end
         end
     endtask
     endtask
-    task measure_ssr;
-        integer counts[0:2];integer j,n;
-        integer last_rise[0:2]; reg [2:0] previous;
-        begin
-            for(j=0;j<3;j=j+1)begin counts[j]=0;last_rise[j]=-1;end
-            previous=ssr;
-            for(n=0;n<200000;n=n+1)begin
-                @(negedge clk);
-                for(j=0;j<3;j=j+1)begin
-                    if(ssr[j]!==0 && ssr[j]!==1)$fatal(1,"undefinedSSR%0d",j);
-                    if(ssr[j])counts[j]=counts[j]+1;
-                    if(ssr[j] && !previous[j])begin
-                        if(last_rise[j]>=0 && n-last_rise[j]!=50000)
-                            $fatal(1,"SSR%0d period=%0d clocks, expected50000 (2ms)",j,n-last_rise[j]);
-                        last_rise[j]=n;
+    reg measuring_ssr = 0;
+    integer ssr_counts[0:2];
+    integer ssr_last_rise[0:2];
+    integer ssr_high_since[0:2];
+    reg [2:0] ssr_previous = 0;
+
+    always @(ssr) begin
+        if (measuring_ssr) begin
+            if (^ssr === 1'bx) $fatal(1, "undefined SSR");
+            begin : ssr_edge_block
+                integer cur_cycle, ch_idx;
+                cur_cycle = $time / 40;
+                for (ch_idx = 0; ch_idx < 3; ch_idx = ch_idx + 1) begin
+                    if (ssr_previous[ch_idx] && !ssr[ch_idx]) begin
+                        ssr_counts[ch_idx] = ssr_counts[ch_idx] + (cur_cycle - ssr_high_since[ch_idx]);
+                    end else if (!ssr_previous[ch_idx] && ssr[ch_idx]) begin
+                        ssr_high_since[ch_idx] = cur_cycle;
+                        if (ssr_last_rise[ch_idx] >= 0 && cur_cycle - ssr_last_rise[ch_idx] != 1250000)
+                            $fatal(1, "SSR%0d period=%0d clocks, expected 1250000 (50ms / 20Hz)", ch_idx, cur_cycle - ssr_last_rise[ch_idx]);
+                        ssr_last_rise[ch_idx] = cur_cycle;
                     end
                     end
-                    previous[j]=ssr[j];
                 end
                 end
+                ssr_previous = ssr;
             end
             end
-            for(j=0;j<3;j=j+1)
-                if(counts[j]!=expected[32+j]*2000)
-                    $fatal(1,"SSR%0d highclocks%0d expected%0d",j,counts[j],expected[32+j]*2000);
+        end
+    end
+
+    task measure_ssr_periods;
+        input integer periods;
+        integer j, start_cycle, end_cycle;
+        begin
+            @(negedge clk);
+            #1;
+            if (^ssr === 1'bx) $fatal(1, "undefined SSR");
+            start_cycle = $time / 40;
+            for(j=0;j<3;j=j+1)begin
+                ssr_counts[j]=0;
+                ssr_last_rise[j]=-1;
+                ssr_high_since[j]=start_cycle;
+            end
+            ssr_previous=ssr;
+            measuring_ssr=1;
+            #(periods * 1250000 * 40);
+            measuring_ssr=0;
+            end_cycle = $time / 40;
+            for(j=0;j<3;j=j+1) begin
+                if (ssr_previous[j])
+                    ssr_counts[j] = ssr_counts[j] + (end_cycle - ssr_high_since[j]);
+                if(ssr_counts[j]!=expected[32+j]*12500*periods)
+                    $fatal(1,"SSR%0d highclocks%0d expected%0d",j,ssr_counts[j],expected[32+j]*12500*periods);
+            end
+        end
+    endtask
+    task measure_ssr;
+        begin
+            measure_ssr_periods(1);
         end
         end
     endtask
     endtask
     task commit_set;
     task commit_set;
@@ -256,10 +294,14 @@ module prod2u_v3_protocol_tb;
         send_values[24]=0;send_values[25]=100;send_values[26]=1;send_values[27]=99;
         send_values[24]=0;send_values[25]=100;send_values[26]=1;send_values[27]=99;
         send_values[28]=20;send_values[29]=40;send_values[30]=60;send_values[31]=80;
         send_values[28]=20;send_values[29]=40;send_values[30]=60;send_values[31]=80;
         send_values[32]=0;send_values[33]=37;send_values[34]=100;
         send_values[32]=0;send_values[33]=37;send_values[34]=100;
-        commit_set;get_and_check;measure_ssr;
+        commit_set;get_and_check;
         fork
         fork
-            measure_ssr;
-            begin repeat(3) commit_set; end
+            measure_ssr_periods(2);
+            begin
+                #(600000 * 40); commit_set;
+                #(600000 * 40); commit_set;
+                #(600000 * 40); commit_set;
+            end
         join
         join
         get_and_check;
         get_and_check;
         $display("PASS V3 SET35/GET86 independent CRC, stable temperature offsets, SSR0/37/100 duties");
         $display("PASS V3 SET35/GET86 independent CRC, stable temperature offsets, SSR0/37/100 duties");
@@ -276,7 +318,8 @@ module prod2u_v3_protocol_tb;
         get_and_check;
         get_and_check;
         send_values[33]=100;
         send_values[33]=100;
         start_frames=frame_count;send_frame(8'h01,35,1);
         start_frames=frame_count;send_frame(8'h01,35,1);
-        repeat(100000)@(negedge clk);
+        #(100000 * 40);
+        @(negedge clk);
         for(i=start_frames;i<frame_count;i=i+1)
         for(i=start_frames;i<frame_count;i=i+1)
             if(frame_type[i]!=8'h42 && frame_type[i]!=8'h52)$fatal(1,"badCRC generatedreply");
             if(frame_type[i]!=8'h42 && frame_type[i]!=8'h52)$fatal(1,"badCRC generatedreply");
         get_and_check;
         get_and_check;
@@ -284,17 +327,18 @@ module prod2u_v3_protocol_tb;
 
 
         for(i=0;i<32;i=i+1)send_values[i]=100-2*i;
         for(i=0;i<32;i=i+1)send_values[i]=100-2*i;
         send_values[32]=100;send_values[33]=1;send_values[34]=99;
         send_values[32]=100;send_values[33]=1;send_values[34]=99;
-        commit_set;get_and_check;measure_ssr;
+        commit_set;get_and_check;
         // AUTO remains active throughout this silence; it must never feed WD.
         // AUTO remains active throughout this silence; it must never feed WD.
-        repeat(600000)@(negedge clk);
+        #(1500000 * 40);
+        @(negedge clk);
         if(ssr!==0 || ptc!==0)$fatal(1,"watchdog failed tozero heating outputs");
         if(ssr!==0 || ptc!==0)$fatal(1,"watchdog failed tozero heating outputs");
         for(i=0;i<35;i=i+1)expected[i]=(i>=24 && i<32)?20:0;
         for(i=0;i<35;i=i+1)expected[i]=(i>=24 && i<32)?20:0;
-        get_and_check;measure_ssr;
+        get_and_check;
         if(ssr!==0 || ptc!==0)$fatal(1,"GET resurrected expired heating outputs");
         if(ssr!==0 || ptc!==0)$fatal(1,"GET resurrected expired heating outputs");
         commit_set;get_and_check;measure_ssr;
         commit_set;get_and_check;measure_ssr;
         if(auto_count<4 || diag_count<4)$fatal(1,"insufficient automatic status/diagnostics");
         if(auto_count<4 || diag_count<4)$fatal(1,"insufficient automatic status/diagnostics");
         $display("PASS prod2u_v3_protocol_tb: nominalUART,allCRC,GET86temp-offsets,SSR0/1/37/99/100,SET35atomicity,legacy32NACK,badCRC/value,recovery,watchdog,AUTO42+52=%0d/%0d",auto_count,diag_count);
         $display("PASS prod2u_v3_protocol_tb: nominalUART,allCRC,GET86temp-offsets,SSR0/1/37/99/100,SET35atomicity,legacy32NACK,badCRC/value,recovery,watchdog,AUTO42+52=%0d/%0d",auto_count,diag_count);
         $finish;
         $finish;
     end
     end
-    initial begin #150000000;$fatal(1,"V3 real-top regressiontimeout");end
+    initial begin #1200000000;$fatal(1,"V3 real-top regressiontimeout");end
 endmodule
 endmodule

+ 76 - 56
tests/sim/pwm_bitmap_engine_tb.v

@@ -1,7 +1,9 @@
 `timescale 1ns/1ps
 `timescale 1ns/1ps
 
 
-// L6 acceptance: exercise the production 500-clock phase and all 100 phases.
+// L6 acceptance: exercise the production 12500-clock phase (20 Hz) and all 100 phases.
 module pwm_bitmap_engine_tb;
 module pwm_bitmap_engine_tb;
+    localparam integer PHASE_CLKS = 12500;
+    localparam integer PERIOD_CLKS = 100 * PHASE_CLKS;
     reg clk = 0;
     reg clk = 0;
     reg rst_n = 0;
     reg rst_n = 0;
     reg runtime_duty_ready = 0;
     reg runtime_duty_ready = 0;
@@ -31,6 +33,10 @@ module pwm_bitmap_engine_tb;
     integer period;
     integer period;
     reg previous_valid;
     reg previous_valid;
     reg idle_seen;
     reg idle_seen;
+    reg check_safe_mode = 0;
+    reg check_runtime_mode = 0;
+    integer safe_fan0_count = 0;
+    integer runtime_sample_idx = 0;
 
 
     always #20 clk = ~clk;
     always #20 clk = ~clk;
     always @(posedge clk) duty_data <= duty[addr];
     always @(posedge clk) duty_data <= duty[addr];
@@ -48,26 +54,51 @@ module pwm_bitmap_engine_tb;
     );
     );
 
 
     // Outputs may change only on the common phase boundary.  Therefore every
     // Outputs may change only on the common phase boundary.  Therefore every
-    // physical pulse is an integer multiple of the 500-clock phase and no
+    // physical pulse is an integer multiple of the 12500-clock phase and no
     // safety update can create a narrow asynchronous pulse.
     // safety update can create a narrow asynchronous pulse.
     always @(negedge clk) begin
     always @(negedge clk) begin
-        if (!rst_n) begin
-            previous_bitmap = bitmap;
-            previous_valid = 0;
-            cycle_index = 0;
-            last_boundary_cycle = -1;
-            boundary_count = 0;
-            idle_seen = 0;
+        if (check_safe_mode) begin
+            if (ptc_pins !== 0) $fatal(1, "PTC high during safe mode check");
+            if (fan_connector_pwm !== {8{fan_connector_pwm[0]}})
+                $fatal(1, "safe mode fan channels diverged: %b", fan_connector_pwm);
+            if (fan_connector_pwm[0])
+                safe_fan0_count = safe_fan0_count + 1;
+        end
+        if (check_runtime_mode && boundary) begin
+            if (miss) $fatal(1, "unexpected scan deadline miss");
+            if (fan_connector_pwm !== bitmap[31:24])
+                $fatal(1, "fan connector polarity mismatch");
+            if (fan_balls[3:0] !== ~bitmap[27:24])
+                $fatal(1, "front fan board inversion mismatch");
+            if (fan_balls[7:4] !== bitmap[31:28])
+                $fatal(1, "rear fan direct path mismatch");
+            if (ptc_pins !== bitmap[23:0])
+                $fatal(1, "PTC polarity mismatch");
             for (channel = 0; channel < 32; channel = channel + 1)
             for (channel = 0; channel < 32; channel = channel + 1)
-                last_edge_cycle[channel] = -1;
+                if (bitmap[channel]) high_count[channel] = high_count[channel] + PHASE_CLKS;
+            for (channel = 0; channel < 8; channel = channel + 1)
+                if (fan_connector_pwm[channel])
+                    fan_active_count[channel] = fan_active_count[channel] + PHASE_CLKS;
+        end
+        if (!rst_n) begin
+            if (previous_valid) begin
+                previous_bitmap = bitmap;
+                previous_valid = 0;
+                cycle_index = 0;
+                last_boundary_cycle = -1;
+                boundary_count = 0;
+                idle_seen = 0;
+                for (channel = 0; channel < 32; channel = channel + 1)
+                    last_edge_cycle[channel] = -1;
+            end
         end else begin
         end else begin
             cycle_index = cycle_index + 1;
             cycle_index = cycle_index + 1;
             if (idle) idle_seen = 1;
             if (idle) idle_seen = 1;
             if (boundary) begin
             if (boundary) begin
                 if (last_boundary_cycle >= 0 &&
                 if (last_boundary_cycle >= 0 &&
-                    cycle_index - last_boundary_cycle != 500)
-                    $fatal(1, "phase boundary spacing=%0d expected=500",
-                        cycle_index - last_boundary_cycle);
+                    cycle_index - last_boundary_cycle != PHASE_CLKS)
+                    $fatal(1, "phase boundary spacing=%0d expected=%0d",
+                        cycle_index - last_boundary_cycle, PHASE_CLKS);
                 last_boundary_cycle = cycle_index;
                 last_boundary_cycle = cycle_index;
                 boundary_count = boundary_count + 1;
                 boundary_count = boundary_count + 1;
             end
             end
@@ -77,7 +108,7 @@ module pwm_bitmap_engine_tb;
                 for (channel = 0; channel < 32; channel = channel + 1) begin
                 for (channel = 0; channel < 32; channel = channel + 1) begin
                     if (bitmap[channel] !== previous_bitmap[channel]) begin
                     if (bitmap[channel] !== previous_bitmap[channel]) begin
                         if (last_edge_cycle[channel] >= 0 &&
                         if (last_edge_cycle[channel] >= 0 &&
-                            cycle_index - last_edge_cycle[channel] < 500)
+                            cycle_index - last_edge_cycle[channel] < PHASE_CLKS)
                             $fatal(1, "channel %0d pulse narrower than one phase", channel);
                             $fatal(1, "channel %0d pulse narrower than one phase", channel);
                         last_edge_cycle[channel] = cycle_index;
                         last_edge_cycle[channel] = cycle_index;
                     end
                     end
@@ -142,17 +173,16 @@ module pwm_bitmap_engine_tb;
         // safe carrier must continue at connector FAN20 / PTC0.
         // safe carrier must continue at connector FAN20 / PTC0.
         repeat (2) @(negedge clk);
         repeat (2) @(negedge clk);
         for (period = 0; period < 3; period = period + 1) begin
         for (period = 0; period < 3; period = period + 1) begin
+            safe_fan0_count = fan_connector_pwm[0] ? 1 : 0;
+            #1;
+            check_safe_mode = 1;
+            #((PERIOD_CLKS - 1) * 40);
+            check_safe_mode = 0;
+            #39;
             for (channel = 0; channel < 8; channel = channel + 1)
             for (channel = 0; channel < 8; channel = channel + 1)
-                fan_active_count[channel] = 0;
-            for (sample = 0; sample < 50000; sample = sample + 1) begin
-                if (ptc_pins !== 0) $fatal(1, "PTC high during control reset");
-                for (channel = 0; channel < 8; channel = channel + 1)
-                    if (fan_connector_pwm[channel])
-                        fan_active_count[channel] = fan_active_count[channel] + 1;
-                @(negedge clk);
-            end
+                fan_active_count[channel] = safe_fan0_count;
             for (channel = 0; channel < 8; channel = channel + 1)
             for (channel = 0; channel < 8; channel = channel + 1)
-                if (fan_active_count[channel] != 10000)
+                if (fan_active_count[channel] != 20 * PHASE_CLKS)
                     $fatal(1, "reset period %0d fan %0d high=%0d", period, channel,
                     $fatal(1, "reset period %0d fan %0d high=%0d", period, channel,
                         fan_active_count[channel]);
                         fan_active_count[channel]);
         end
         end
@@ -162,17 +192,16 @@ module pwm_bitmap_engine_tb;
         // though the RAM model contains non-safe values, two complete
         // though the RAM model contains non-safe values, two complete
         // carriers must remain connector-safe and no runtime scan may commit.
         // carriers must remain connector-safe and no runtime scan may commit.
         for (period = 0; period < 2; period = period + 1) begin
         for (period = 0; period < 2; period = period + 1) begin
+            safe_fan0_count = fan_connector_pwm[0] ? 1 : 0;
+            #1;
+            check_safe_mode = 1;
+            #((PERIOD_CLKS - 1) * 40);
+            check_safe_mode = 0;
+            #39;
             for (channel = 0; channel < 8; channel = channel + 1)
             for (channel = 0; channel < 8; channel = channel + 1)
-                fan_active_count[channel] = 0;
-            for (sample = 0; sample < 50000; sample = sample + 1) begin
-                if (ptc_pins !== 0) $fatal(1, "PTC high before runtime ready");
-                for (channel = 0; channel < 8; channel = channel + 1)
-                    if (fan_connector_pwm[channel])
-                        fan_active_count[channel] = fan_active_count[channel] + 1;
-                @(negedge clk);
-            end
+                fan_active_count[channel] = safe_fan0_count;
             for (channel = 0; channel < 8; channel = channel + 1)
             for (channel = 0; channel < 8; channel = channel + 1)
-                if (fan_active_count[channel] != 10000)
+                if (fan_active_count[channel] != 20 * PHASE_CLKS)
                     $fatal(1, "pre-ready period %0d fan %0d high=%0d", period,
                     $fatal(1, "pre-ready period %0d fan %0d high=%0d", period,
                         channel, fan_active_count[channel]);
                         channel, fan_active_count[channel]);
         end
         end
@@ -190,41 +219,32 @@ module pwm_bitmap_engine_tb;
         end
         end
         wait_for_boundary();
         wait_for_boundary();
 
 
-        // Start at phase zero and count one exact 2 ms / 50,000-clock carrier.
+        // Start at phase zero and count one exact 50 ms / 1,250,000-clock carrier (20 Hz).
         wait_for_phase_zero();
         wait_for_phase_zero();
-        for (channel = 0; channel < 32; channel = channel + 1)
+        for (channel = 0; channel < 32; channel = channel + 1) begin
             high_count[channel] = 0;
             high_count[channel] = 0;
-        for (channel = 0; channel < 8; channel = channel + 1)
+            if (bitmap[channel]) high_count[channel] = PHASE_CLKS;
+        end
+        for (channel = 0; channel < 8; channel = channel + 1) begin
             fan_active_count[channel] = 0;
             fan_active_count[channel] = 0;
-        for (sample = 0; sample < 50000; sample = sample + 1) begin
-            if (miss) $fatal(1, "unexpected scan deadline miss");
-            for (channel = 0; channel < 32; channel = channel + 1)
-                if (bitmap[channel]) high_count[channel] = high_count[channel] + 1;
-            for (channel = 0; channel < 8; channel = channel + 1) begin
-                if (fan_connector_pwm[channel])
-                    fan_active_count[channel] = fan_active_count[channel] + 1;
-                if (fan_connector_pwm[channel] !== bitmap[channel + 24])
-                    $fatal(1, "fan connector polarity mismatch channel=%0d", channel);
-                if (channel < 4 && fan_balls[channel] !== ~bitmap[channel + 24])
-                    $fatal(1, "front fan board inversion mismatch channel=%0d", channel);
-                if (channel >= 4 && fan_balls[channel] !== bitmap[channel + 24])
-                    $fatal(1, "rear fan direct path mismatch channel=%0d", channel);
-            end
-            if (ptc_pins !== bitmap[23:0])
-                $fatal(1, "PTC polarity mismatch");
-            if (sample != 49999) @(negedge clk);
+            if (fan_connector_pwm[channel]) fan_active_count[channel] = PHASE_CLKS;
         end
         end
+        #1;
+        check_runtime_mode = 1;
+        #((PERIOD_CLKS - 1) * 40);
+        check_runtime_mode = 0;
+        #39;
 
 
         for (channel = 0; channel < 32; channel = channel + 1) begin
         for (channel = 0; channel < 32; channel = channel + 1) begin
-            if (high_count[channel] != duty[channel] * 500)
+            if (high_count[channel] != duty[channel] * PHASE_CLKS)
                 $fatal(1, "channel %0d duty=%0d high=%0d expected=%0d",
                 $fatal(1, "channel %0d duty=%0d high=%0d expected=%0d",
-                    channel, duty[channel], high_count[channel], duty[channel] * 500);
+                    channel, duty[channel], high_count[channel], duty[channel] * PHASE_CLKS);
         end
         end
         for (channel = 0; channel < 8; channel = channel + 1) begin
         for (channel = 0; channel < 8; channel = channel + 1) begin
-            if (fan_active_count[channel] != duty[channel + 24] * 500)
+            if (fan_active_count[channel] != duty[channel + 24] * PHASE_CLKS)
                 $fatal(1, "active-low fan %0d duty=%0d active=%0d expected=%0d",
                 $fatal(1, "active-low fan %0d duty=%0d active=%0d expected=%0d",
                     channel, duty[channel + 24], fan_active_count[channel],
                     channel, duty[channel + 24], fan_active_count[channel],
-                    duty[channel + 24] * 500);
+                    duty[channel + 24] * PHASE_CLKS);
         end
         end
         if (!idle_seen) $fatal(1, "32-channel scan never completed before deadline");
         if (!idle_seen) $fatal(1, "32-channel scan never completed before deadline");
         if (boundary_count < 100) $fatal(1, "full 100-phase carrier was not observed");
         if (boundary_count < 100) $fatal(1, "full 100-phase carrier was not observed");

+ 16 - 8
tests/sim/ssr_time_proportion_tb.v

@@ -7,8 +7,17 @@ module ssr_time_proportion_tb;
     reg [7:0] stage_data = 0;
     reg [7:0] stage_data = 0;
     wire [2:0] ssr_on;
     wire [2:0] ssr_on;
     integer i, h0, h1, h2;
     integer i, h0, h1, h2;
-    // Production 25 MHz clock and default 500 Hz PWM; no timer override.
+    reg measuring = 0;
+    // Production 25 MHz clock and default 20 Hz PWM (1,250,000 clocks/period); no timer override.
     ssr_time_proportion dut (.*);
     ssr_time_proportion dut (.*);
+    always @(negedge clk) begin
+        if (measuring) begin
+            if (^ssr_on === 1'bx) $fatal(1,"undefined SSR outputs");
+            h0 <= h0 + ssr_on[0];
+            h1 <= h1 + ssr_on[1];
+            h2 <= h2 + ssr_on[2];
+        end
+    end
     task stage;
     task stage;
         input [5:0] addr;
         input [5:0] addr;
         input [7:0] value;
         input [7:0] value;
@@ -26,13 +35,12 @@ module ssr_time_proportion_tb;
     task measure;
     task measure;
         input integer v0, v1, v2;
         input integer v0, v1, v2;
         begin
         begin
+            @(negedge clk);
             h0=0; h1=0; h2=0;
             h0=0; h1=0; h2=0;
-            for(i=0;i<50000;i=i+1) begin
-                @(negedge clk);
-                if (^ssr_on === 1'bx) $fatal(1,"undefined SSR outputs");
-                h0=h0+ssr_on[0];h1=h1+ssr_on[1];h2=h2+ssr_on[2];
-            end
-            if(h0!=v0*500 || h1!=v1*500 || h2!=v2*500)
+            measuring = 1;
+            #(1250000 * 40);
+            measuring = 0;
+            if(h0!=v0*12500 || h1!=v1*12500 || h2!=v2*12500)
                 $fatal(1,"SSR duty mismatch %0d,%0d,%0d",h0,h1,h2);
                 $fatal(1,"SSR duty mismatch %0d,%0d,%0d",h0,h1,h2);
         end
         end
     endtask
     endtask
@@ -55,5 +63,5 @@ module ssr_time_proportion_tb;
         $display("ssr_time_proportion_tb PASS: zero boot, staging isolation, 0/1/20/50/99/100 duty, shared phase, timeout and direct recovery");
         $display("ssr_time_proportion_tb PASS: zero boot, staging isolation, 0/1/20/50/99/100 duty, shared phase, timeout and direct recovery");
         $finish;
         $finish;
     end
     end
-    initial begin #100000000; $fatal(1,"SSR timeout"); end
+    initial begin #1000000000; $fatal(1,"SSR timeout"); end
 endmodule
 endmodule

+ 6 - 6
tests/unit/test_6400_contract.py

@@ -42,15 +42,15 @@ class Contract6400Tests(unittest.TestCase):
         self.assertEqual(by_signal["FAN_PWM2"], "B5")
         self.assertEqual(by_signal["FAN_PWM2"], "B5")
         self.assertEqual(by_signal["FAN_PWM4"], "A14")
         self.assertEqual(by_signal["FAN_PWM4"], "A14")
 
 
-    def test_output_contract_is_24_ptc_plus_8_fan_with_500hz_pwm(self):
+    def test_output_contract_is_24_ptc_plus_8_fan_with_20hz_pwm(self):
         generated = generate_manual()
         generated = generate_manual()
         params = generated[ROOT / "generated/6400/prod2u_6400_v1_params.vh"].decode()
         params = generated[ROOT / "generated/6400/prod2u_6400_v1_params.vh"].decode()
         self.assertIn("`define FB_PTC_COUNT 24", params)
         self.assertIn("`define FB_PTC_COUNT 24", params)
         self.assertIn("`define FB_OUTPUT_COUNT 32", params)
         self.assertIn("`define FB_OUTPUT_COUNT 32", params)
-        self.assertIn("`define FB_PTC_PWM_HZ 500", params)
-        self.assertIn("`define FB_FAN_PWM_HZ 500", params)
-        self.assertIn("`define FB_PWM_PHASE_CLKS 500", params)
-        self.assertIn("`define FB_PWM_PERIOD_CLKS 50000", params)
+        self.assertIn("`define FB_PTC_PWM_HZ 20", params)
+        self.assertIn("`define FB_FAN_PWM_HZ 20", params)
+        self.assertIn("`define FB_PWM_PHASE_CLKS 12500", params)
+        self.assertIn("`define FB_PWM_PERIOD_CLKS 1250000", params)
         self.assertNotIn("FB_SNAPSHOT", params)
         self.assertNotIn("FB_SNAPSHOT", params)
         self.assertNotIn("FB_TEMP", params)
         self.assertNotIn("FB_TEMP", params)
         self.assertNotIn("FB_STATUS_", params)
         self.assertNotIn("FB_STATUS_", params)
@@ -70,7 +70,7 @@ class Contract6400Tests(unittest.TestCase):
     def test_generate_and_release_policy(self):
     def test_generate_and_release_policy(self):
         summary = generate_6400(ROOT)
         summary = generate_6400(ROOT)
         self.assertEqual(summary["watchdog_timeout_ticks"], 60000)
         self.assertEqual(summary["watchdog_timeout_ticks"], 60000)
-        self.assertEqual(summary["pwm_period_clks"], 50000)
+        self.assertEqual(summary["pwm_period_clks"], 1250000)
         self.assertFalse(summary["release_blocked"])
         self.assertFalse(summary["release_blocked"])
         project = json.loads((ROOT / "projects" / "prod2u-6400-front-back" / "project.json").read_text(encoding="utf-8"))
         project = json.loads((ROOT / "projects" / "prod2u-6400-front-back" / "project.json").read_text(encoding="utf-8"))
         validate_6400_project(project)
         validate_6400_project(project)

+ 1 - 1
tests/unit/test_6400_v2_electrical_contract.py

@@ -325,7 +325,7 @@ def test_con165_field_pin_routes_match_original_board_and_scope():
                 (2, 13, 'E8', 'ADC0_CH7', 'PE13', 'R1859', 'R1695'),
                 (2, 13, 'E8', 'ADC0_CH7', 'PE13', 'R1859', 'R1695'),
                 (4, 11, 'D9', 'ADC0_CH5', 'PE11', 'R1857', 'R1694')]
                 (4, 11, 'D9', 'ADC0_CH5', 'PE11', 'R1857', 'R1694')]
     project = json.loads((ROOT / 'products/6400-v2/project.json').read_text())
     project = json.loads((ROOT / 'products/6400-v2/project.json').read_text())
-    assert project['ssr_control']['pwm_hz'] == 500
+    assert project['ssr_control']['pwm_hz'] == 20
     for (field, cad, ball, fpga_net, middle, r0, r1), channel in zip(expected, project['ssr_control']['channels']):
     for (field, cad, ball, fpga_net, middle, r0, r1), channel in zip(expected, project['ssr_control']['channels']):
         assert field + cad == 15
         assert field + cad == 15
         assert channel['connector'] == f'CON165.{field}'
         assert channel['connector'] == f'CON165.{field}'

+ 242 - 2
tests/unit/test_gui_v3_ssr_diagnostic.py

@@ -21,8 +21,8 @@ def test_v2_set_appends_three_independent_heater_outputs():
     assert model.checked_request(frame).payload[32:35] == bytes([0, 37, 100])
     assert model.checked_request(frame).payload[32:35] == bytes([0, 37, 100])
     assert model.output_label("SSR", 1) == "SSR2 腔体2+3 共用"
     assert model.output_label("SSR", 1) == "SSR2 腔体2+3 共用"
     assert model.groups()[-1] == ("SSR", 3, 0)
     assert model.groups()[-1] == ("SSR", 3, 0)
-    assert "500 Hz" in model.group_label("SSR")
-    assert model.outputs["ssr_pwm_hz"] == 500
+    assert "20 Hz" in model.group_label("SSR")
+    assert model.outputs["ssr_pwm_hz"] == 20
     for wrong in (32, 43):
     for wrong in (32, 43):
         with pytest.raises(ValueError):
         with pytest.raises(ValueError):
             model.checked_request(gui.encode_frame(1, bytes(wrong)))
             model.checked_request(gui.encode_frame(1, bytes(wrong)))
@@ -107,3 +107,243 @@ def test_raw_register_diagnostic_is_not_reported_as_temperature():
     assert not d["is_temperature"] and d["raw_register"] == 0xff00
     assert not d["is_temperature"] and d["raw_register"] == 0xff00
     assert "状态寄存器(非温度)" in gui.diagnostic_summary(d)
     assert "状态寄存器(非温度)" in gui.diagnostic_summary(d)
     assert "None °C" not in gui.diagnostic_summary(d)
     assert "None °C" not in gui.diagnostic_summary(d)
+
+
+def test_chamber_mapping_defaults_customization_and_persistence(tmp_path):
+    cfg = gui.ChamberMappingConfig.default("6400-v2")
+    assert cfg.chambers[1]["bmc"] == [0, 1, 2, 3, 4, 5]
+    assert cfg.chambers[2]["bmc"] == [6, 7, 8, 9, 10, 11]
+    assert cfg.chambers[3]["bmc"] == [12, 13, 14, 15, 16, 17]
+    assert cfg.chambers[4]["bmc"] == [18, 19, 20, 21, 22, 23]
+    assert cfg.chambers[1]["ct"] == [1, 2]
+    assert cfg.chambers[2]["ct"] == [3, 4]
+    assert cfg.chambers[3]["ct"] == [5, 6]
+    assert cfg.chambers[4]["ct"] == [7, 8]
+
+    # Swap 1/2 <-> 3/4 Sensor CT pairs for field harness matching
+    cfg.swap_pairs(swap_bmc=False, swap_ct=True)
+    assert cfg.chambers[1]["ct"] == [5, 6]
+    assert cfg.chambers[3]["ct"] == [1, 2]
+    assert cfg.chambers[2]["ct"] == [7, 8]
+    assert cfg.chambers[4]["ct"] == [3, 4]
+
+    # Custom channel specification & JSON round-trip
+    cfg.set_chamber(1, "0-3,8", "1,3,9", name="腔体1(自定义)")
+    assert cfg.chambers[1]["bmc"] == [0, 1, 2, 3, 8]
+    assert cfg.chambers[1]["ct"] == [1, 3, 9]
+    assert gui.format_channel_spec(cfg.chambers[1]["bmc"]) == "0-3,8"
+
+    json_path = tmp_path / "chamber_map.json"
+    cfg.save(json_path)
+    loaded = gui.ChamberMappingConfig.load(json_path, product="6400-v2")
+    assert loaded.chambers[1]["name"] == "腔体1(自定义)"
+    assert loaded.chambers[1]["bmc"] == [0, 1, 2, 3, 8]
+    assert loaded.chambers[1]["ct"] == [1, 3, 9]
+
+    loaded.reset_to_default()
+    assert loaded.chambers[1]["bmc"] == [0, 1, 2, 3, 4, 5]
+    assert loaded.chambers[1]["ct"] == [1, 2]
+
+
+def test_chamber_curve_store_and_direct_image_export(tmp_path):
+    model = gui.Model("6400-v2")
+    cfg = gui.ChamberMappingConfig.default("6400-v2")
+    store = gui.TemperatureCurveStore()
+
+    for step in range(6):
+        payload = bytearray([0] * 24 + [20] * 8 + [255] * 51 + [0, 0, 0])
+        for ch in range(24):
+            payload[32 + ch] = 40 + (ch // 6) * 3 + step
+        payload[56 + 0] = 31  # U6 local CT0
+        for ch in range(1, 9):
+            payload[56 + ch] = 25 + ((ch - 1) // 2) * 2 + step
+        state = model.state(payload)
+        store.record_state(state, timestamp=1000.0 + step * 2.0, time_label=f"12:00:0{step*2}")
+
+    s1 = store.chamber_series(cfg, 1)
+    assert s1["sample_count"] == 6
+    assert s1["bmc_avg"][0] == 40.0
+    assert s1["bmc_avg"][-1] == 45.0
+    assert s1["ct_series"][1] == [25, 26, 27, 28, 29, 30]
+    assert s1["ct_series"][2] == [25, 26, 27, 28, 29, 30]
+
+    # Re-mapping dynamically re-projects historical samples without losing data
+    cfg.swap_pairs(swap_bmc=True, swap_ct=True)
+    s1_swapped = store.chamber_series(cfg, 1)
+    assert s1_swapped["bmc_avg"][0] == 46.0
+    assert s1_swapped["ct_series"][5] == [29, 30, 31, 32, 33, 34]
+
+    # Direct PNG/SVG/CSV rendering
+    png_bytes = gui.render_chamber_curves_png(store, cfg, product="6400-v2", board="6400V2.0")
+    assert png_bytes.startswith(b"\x89PNG\r\n\x1a\n") and len(png_bytes) > 5000
+    svg_text = gui.render_chamber_curves_svg(store, cfg, product="6400-v2", board="6400V2.0")
+    assert "<svg" in svg_text and "<polyline" in svg_text
+    csv_text = gui.export_chamber_curves_csv(store, cfg)
+    assert "C1_BMC_AVG" in csv_text and "C4_CT_AVG" in csv_text
+
+    # CLI --plot-log / --plot-out with pwm_scope JSONL format
+    log_path = tmp_path / "scope.jsonl"
+    log_path.write_text(
+        '{"event": "CYCLE", "elapsed": 1.0, "bmc": [41,41,41,41,41,41,43,43,43,43,43,43,45,45,45,45,45,45,47,47,47,47,47,47], "ct": [30,26,27,28,29,30,31,32,33]}\n'
+        '{"event": "CYCLE", "elapsed": 2.0, "bmc": [42,42,42,42,42,42,44,44,44,44,44,44,46,46,46,46,46,46,48,48,48,48,48,48], "ct": [30,27,28,29,30,31,32,33,34]}\n',
+        encoding="utf-8",
+    )
+    out_png = tmp_path / "out.png"
+    assert gui.main("6400-v2", ["prod2u_gui.py", "--plot-log", str(log_path), "--plot-out", str(out_png)]) == 0
+    assert out_png.read_bytes().startswith(b"\x89PNG\r\n\x1a\n")
+
+
+def test_pwm_unified_20hz_and_thermal_test_session_continuous_recording():
+    assert gui.PWM_FREQUENCY_HZ == 20
+    assert gui.PWM_PERIOD_MS == 50.0
+    assert gui.SOFTWARE_VERSION == "3.0.4"
+
+    cfg = gui.ChamberMappingConfig.default("6400-v2")
+    store = gui.TemperatureCurveStore()
+    session = gui.ThermalTestSession(
+        "6400-v2",
+        test_name="70C Target Continuous Record Test",
+        overall_pass_min_temp_c=70.0,
+        chamber_target_temp_c={1: 70.0, 2: 72.0, 3: 70.0, 4: 68.0},
+        fan_intervention_mode="ref_temp_c",
+        fan_intervention_ref_temp_c=60.0,
+        fan_intervention_ref_source="ct",
+        initial_fan_duty_percent=20,
+        active_fan_duty_percent=65,
+        ptc_duty_percent=100,
+        ssr_duty_percent=100,
+    )
+    session.start(start_timestamp=1000.0)
+
+    # Simulate 30 samples (0..290s, 10s step) where Chamber 1 reaches 70C early (at 80s),
+    # while Chambers 2, 3, 4 reach target later, and recording continues up to 290s.
+    for idx in range(30):
+        t_s = idx * 10.0
+        bmc = [0xFF] * 24
+        ct = [0xFF] * 27
+        ct[0] = 35
+        rates = {1: 0.60, 2: 0.40, 3: 0.35, 4: 0.30}
+        for ch_id in (1, 2, 3, 4):
+            ct_val = min(90, int(round(25.0 + rates[ch_id] * t_s)))
+            bmc_val = min(90, int(round(27.0 + (rates[ch_id] * 1.05) * t_s)))
+            for m_idx in cfg.chambers[ch_id]["bmc"]:
+                bmc[m_idx] = bmc_val
+            for s_idx in cfg.chambers[ch_id]["ct"]:
+                ct[s_idx] = ct_val
+        pt = store.record_raw_arrays(
+            bmc,
+            ct,
+            timestamp=1000.0 + t_s,
+            time_label=f"00:{int(t_s // 60):02d}:{int(t_s % 60):02d}",
+        )
+        action = session.process_sample(pt, cfg)
+        if action.get("fan_switched_now"):
+            assert session.fan_intervened is True
+            assert session.fan_intervened_elapsed_s == t_s
+
+    # Verify fan intervention triggered when reference temperature reached 60C
+    assert session.fan_intervened is True
+    assert session.fan_intervened_elapsed_s is not None
+    assert 50.0 <= session.fan_intervened_elapsed_s <= 70.0
+
+    # Verify Chamber 1 reached 70C first AND continued recording samples afterwards
+    c1 = session.chamber_stats[1]
+    c2 = session.chamber_stats[2]
+    c3 = session.chamber_stats[3]
+    c4 = session.chamber_stats[4]
+    assert c1["sensor_reached"] is True and c1["memory_reached"] is True
+    assert c1["both_reached"] is True
+    assert c1["sensor_time_to_target_s"] < c2["sensor_time_to_target_s"] < c3["sensor_time_to_target_s"]
+    assert c1["post_target_samples"] >= 15  # Continued recording for >15 samples after C1 hit target!
+    rep = session.summary()
+    assert rep["hood_summary"]["hood_all_reached"] is True
+    assert rep["hood_summary"]["hood_total_reach_time_s"] == max(
+        c1["chamber_time_to_target_s"],
+        c2["chamber_time_to_target_s"],
+        c3["chamber_time_to_target_s"],
+        c4["chamber_time_to_target_s"],
+    )
+
+    # Verify PNG/SVG/CSV exports include target lines and ThermalTestSession summary
+    png = gui.render_chamber_curves_png(store, cfg, product="6400-v2", board="6400V2.0", thermal_session=session)
+    assert png.startswith(b"\x89PNG\r\n\x1a\n")
+    svg = gui.render_chamber_curves_svg(store, cfg, product="6400-v2", board="6400V2.0", thermal_session=session)
+    assert "70.0" in svg
+    csv_report = session.export_summary_csv()
+    assert session.session_id in csv_report
+    assert "PASS" in csv_report
+
+
+def test_thermal_test_backend_server_api(tmp_path):
+    import json
+    import threading
+    import urllib.request
+    from tools import thermal_test_server as srv_mod
+
+    server, state = srv_mod.create_thermal_test_server("127.0.0.1", 0, storage_dir=tmp_path)
+    port = server.server_address[1]
+    thread = threading.Thread(target=server.serve_forever, daemon=True)
+    thread.start()
+    try:
+        base_url = f"http://127.0.0.1:{port}"
+        with urllib.request.urlopen(f"{base_url}/api/status", timeout=5) as resp:
+            st = json.loads(resp.read().decode("utf-8"))
+        assert st["status"] == "pass"
+        assert st["privileges"]["pwm_unified_hz"] == 20
+        assert st["total_runs"] >= 4
+
+        # Start a new simulated thermal test run exploring fan intervention at 55C
+        payload = json.dumps({
+            "mode": "simulate",
+            "test_name": "UnitTest_FanRef55C_75pct",
+            "overall_pass_min_temp_c": 70.0,
+            "chamber_target_temp_c": {"1": 70.0, "2": 70.0, "3": 70.0, "4": 70.0},
+            "fan_intervention_mode": "ref_temp_c",
+            "fan_intervention_ref_temp_c": 55.0,
+            "initial_fan_duty_percent": 20,
+            "active_fan_duty_percent": 75,
+            "duration_s": 480.0,
+            "step_s": 4.0,
+        }).encode("utf-8")
+        req = urllib.request.Request(
+            f"{base_url}/api/test/start",
+            data=payload,
+            headers={"Content-Type": "application/json"},
+            method="POST",
+        )
+        with urllib.request.urlopen(req, timeout=5) as resp:
+            created = json.loads(resp.read().decode("utf-8"))
+        assert created["status"] == "ok"
+        sid = created["session_id"]
+        assert created["report"]["hood_summary"]["hood_all_reached"] is True
+        assert created["report"]["chambers"]["1"]["post_target_samples"] > 0
+
+        # Recalculate with a new target temperature (65C) on historical data
+        recalc_req = urllib.request.Request(
+            f"{base_url}/api/runs/{sid}/recalculate",
+            data=json.dumps({
+                "overall_pass_min_temp_c": 65.0,
+                "chamber_target_temp_c": {"1": 65.0, "2": 65.0, "3": 65.0, "4": 65.0},
+            }).encode("utf-8"),
+            headers={"Content-Type": "application/json"},
+            method="POST",
+        )
+        with urllib.request.urlopen(recalc_req, timeout=5) as resp:
+            recalc = json.loads(resp.read().decode("utf-8"))
+        assert recalc["status"] == "ok"
+        assert recalc["report"]["hood_summary"]["hood_total_reach_time_s"] < created["report"]["hood_summary"]["hood_total_reach_time_s"]
+
+        # Verify Web UI and CSV/PNG exports
+        with urllib.request.urlopen(f"{base_url}/", timeout=5) as resp:
+            html = resp.read().decode("utf-8")
+        assert "高温罩四腔体温度测试" in html
+        with urllib.request.urlopen(f"{base_url}/api/runs/{sid}/export/png", timeout=5) as resp:
+            assert resp.read().startswith(b"\x89PNG\r\n\x1a\n")
+        with urllib.request.urlopen(f"{base_url}/api/compare/csv", timeout=5) as resp:
+            cmp_csv = resp.read().decode("utf-8")
+        assert "UnitTest_FanRef55C_75pct" in cmp_csv
+    finally:
+        server.shutdown()
+        server.server_close()
+
+

+ 32 - 0
tests/unit/test_pwm_scope_stream.py

@@ -133,5 +133,37 @@ class ScopeStreamTests(unittest.TestCase):
         self.assertNotIn('喂狗正常', text)
         self.assertNotIn('喂狗正常', text)
         for line in lines: self.assertEqual(scope.disp_width(line), scope.BOX_WIDTH)
         for line in lines: self.assertEqual(scope.disp_width(line), scope.BOX_WIDTH)
 
 
+    def test_fan_pwm_alternates_5s_50_percent_and_5s_0_percent(self):
+        for t in (0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 4.999, 10.0, 14.0):
+            self.assertEqual(scope.fan_duty_for_elapsed(t), 50, f"t={t}")
+        for t in (5.0, 5.5, 6.0, 7.0, 8.0, 9.0, 9.999, 15.0, 19.0):
+            self.assertEqual(scope.fan_duty_for_elapsed(t), 0, f"t={t}")
+        self.assertEqual(list(scope.DUTIES[:24]), list(range(1, 25)))
+        self.assertEqual(list(scope.DUTIES[24:32]), [50] * 8)
+        self.assertEqual(list(scope.DUTIES[32:35]), [33, 34, 35])
+        self.assertEqual(list(scope.DUTIES_FAN_ZERO[:24]), list(range(1, 25)))
+        self.assertEqual(list(scope.DUTIES_FAN_ZERO[24:32]), [0] * 8)
+        self.assertEqual(list(scope.DUTIES_FAN_ZERO[32:35]), [33, 34, 35])
+        for expected in (scope.DUTIES, scope.DUTIES_FAN_ZERO):
+            lines = scope.render_live_panel(
+                scope.Style(False), cycles=6, total_cycles=900,
+                elapsed=5.0, remaining=895.0, read_only=False, matches=True,
+                outputs=expected, ct=[25] * 9, errors=0, bad_crc=0,
+                diag=None, diag_slots={}, last_error=None, last_ack_age=0.1,
+                expected_outputs=expected,
+            )
+            for line in lines:
+                self.assertEqual(scope.disp_width(line), scope.BOX_WIDTH)
+
+    def test_resolve_port_follows_replugged_usb1_and_rejects_usb0(self):
+        old_path = "/dev/serial/by-path/pci-0000:00:14.0-usb-0:2:1.0-port0"
+        new_path = "/dev/serial/by-path/pci-0000:00:14.0-usb-0:3:1.0-port0"
+        with patch("os.path.exists", side_effect=lambda p: p == new_path), \
+             patch("os.path.realpath", side_effect=lambda p: "/dev/ttyUSB1" if p == new_path else p):
+            self.assertEqual(scope.resolve_port(old_path), new_path)
+        with patch("os.path.realpath", return_value="/dev/ttyUSB0"):
+            with self.assertRaises(RuntimeError):
+                scope.resolve_port("/dev/serial/by-path/pci-0000:00:14.0-usb-0:6:1.0-port0")
+
 
 
 if __name__ == '__main__': unittest.main()
 if __name__ == '__main__': unittest.main()

+ 2 - 2
tools/board-viewer/generate_v2_0_assets.py

@@ -1401,7 +1401,7 @@ def _build_v20_annotations(
                 if key in ssr_active_pins:
                 if key in ssr_active_pins:
                     ssr_label = ssr_active_pins[key]
                     ssr_label = ssr_active_pins[key]
                     pins_dict[pnum] = {
                     pins_dict[pnum] = {
-                        "summary": f"{key} ({net}) → FPGA U3.{ball} ({ssr_label} 500Hz PWM,高有效,默认关闭)",
+                        "summary": f"{key} ({net}) → FPGA U3.{ball} ({ssr_label} 20Hz PWM,高有效,默认关闭)",
                         "direction": "output",
                         "direction": "output",
                         "external_level": "3.3V SSR Control",
                         "external_level": "3.3V SSR Control",
                         "function_category": "gpio_output",
                         "function_category": "gpio_output",
@@ -1449,7 +1449,7 @@ def _build_v20_annotations(
                     }
                     }
         touchpoint_anns[ref] = {
         touchpoint_anns[ref] = {
             "summary": (
             "summary": (
-                "固态继电器 SSR 与光电接口座 1(现场Pin 1/2/4(CAD 14/13/11)对应 6400 V2.0 SSR1/SSR2/SSR4 500Hz PWM,2ms控制(腔体1/2+3共用/4,默认关闭) → U3.E14/E8/D9 驱动 -1-7E 110W / -2-7E 220W / -4-7E 110W;旧F3/F1/G4固定低,其余空余;现场针号=15-CAD针号)"
+                "固态继电器 SSR 与光电接口座 1(现场Pin 1/2/4(CAD 14/13/11)对应 6400 V2.0 SSR1/SSR2/SSR4 20Hz PWM,50ms控制(腔体1/2+3共用/4,默认关闭) → U3.E14/E8/D9 驱动 -1-7E 110W / -2-7E 220W / -4-7E 110W;旧F3/F1/G4固定低,其余空余;现场针号=15-CAD针号)"
                 if ref == "CON165"
                 if ref == "CON165"
                 else "光电限位与 GPIO 扩展座 2(空余插座:Pin 1..14 为 CON_PE15..28 ↔ U3.D16/E15/D14/R9/T10/L2/L1/M2/N3/K4/H2/H1/J2/K3)"
                 else "光电限位与 GPIO 扩展座 2(空余插座:Pin 1..14 为 CON_PE15..28 ↔ U3.D16/E15/D14/R9/T10/L2/L1/M2/N3/K4/H2/H1/J2/K3)"
             ),
             ),

+ 4 - 4
tools/board-viewer/generated-v2_0/board-data.json

@@ -21689,7 +21689,7 @@
         "height": 16.33999999999999
         "height": 16.33999999999999
       },
       },
       "side": "front",
       "side": "front",
-      "summary": "固态继电器 SSR 与光电接口座 1(现场Pin 1/2/4(CAD 14/13/11)对应 6400 V2.0 SSR1/SSR2/SSR4 500Hz PWM,2ms控制(腔体1/2+3共用/4,默认关闭) → U3.E14/E8/D9 驱动 -1-7E 110W / -2-7E 220W / -4-7E 110W;旧F3/F1/G4固定低,其余空余;现场针号=15-CAD针号)",
+      "summary": "固态继电器 SSR 与光电接口座 1(现场Pin 1/2/4(CAD 14/13/11)对应 6400 V2.0 SSR1/SSR2/SSR4 20Hz PWM,50ms控制(腔体1/2+3共用/4,默认关闭) → U3.E14/E8/D9 驱动 -1-7E 110W / -2-7E 220W / -4-7E 110W;旧F3/F1/G4固定低,其余空余;现场针号=15-CAD针号)",
       "connector": {
       "connector": {
         "profile": "CON_SMD_2D54_2X7P",
         "profile": "CON_SMD_2D54_2X7P",
         "review_status": "cross_verified",
         "review_status": "cross_verified",
@@ -21794,7 +21794,7 @@
             "R1698.2->1",
             "R1698.2->1",
             "R1860.2->1"
             "R1860.2->1"
           ],
           ],
-          "summary": "拓扑候选(未核装配/导通):CON165.14 (CON_PE14) → FPGA U3.E14 (现场CON165.1 SSR1 (ssr1_out, 驱动 -1-7E 110W/24V 辅助加热器) 500Hz PWM,高有效,默认关闭)",
+          "summary": "拓扑候选(未核装配/导通):CON165.14 (CON_PE14) → FPGA U3.E14 (现场CON165.1 SSR1 (ssr1_out, 驱动 -1-7E 110W/24V 辅助加热器) 20Hz PWM,高有效,默认关闭)",
           "path": [
           "path": [
             "CON165.14 (CON_PE14)",
             "CON165.14 (CON_PE14)",
             "R1698.2->1 (PE14)",
             "R1698.2->1 (PE14)",
@@ -21935,7 +21935,7 @@
             "R1695.1->2",
             "R1695.1->2",
             "R1859.2->1"
             "R1859.2->1"
           ],
           ],
-          "summary": "拓扑候选(未核装配/导通):CON165.13 (CON_PE13) → FPGA U3.E8 (现场CON165.2 SSR2 (ssr2_out, 腔体2+3共用,驱动 -2-7E 220W/24V 加热布) 500Hz PWM,高有效,默认关闭)",
+          "summary": "拓扑候选(未核装配/导通):CON165.13 (CON_PE13) → FPGA U3.E8 (现场CON165.2 SSR2 (ssr2_out, 腔体2+3共用,驱动 -2-7E 220W/24V 加热布) 20Hz PWM,高有效,默认关闭)",
           "path": [
           "path": [
             "CON165.13 (CON_PE13)",
             "CON165.13 (CON_PE13)",
             "R1695.1->2 (PE13)",
             "R1695.1->2 (PE13)",
@@ -22216,7 +22216,7 @@
             "R1694.1->2",
             "R1694.1->2",
             "R1857.2->1"
             "R1857.2->1"
           ],
           ],
-          "summary": "拓扑候选(未核装配/导通):CON165.11 (CON_PE11) → FPGA U3.D9 (现场CON165.4 SSR4 (ssr4_out, 驱动 -4-7E 110W/24V 辅助加热器) 500Hz PWM,高有效,默认关闭)",
+          "summary": "拓扑候选(未核装配/导通):CON165.11 (CON_PE11) → FPGA U3.D9 (现场CON165.4 SSR4 (ssr4_out, 驱动 -4-7E 110W/24V 辅助加热器) 20Hz PWM,高有效,默认关闭)",
           "path": [
           "path": [
             "CON165.11 (CON_PE11)",
             "CON165.11 (CON_PE11)",
             "R1694.1->2 (PE11)",
             "R1694.1->2 (PE11)",

+ 5 - 5
tools/board-viewer/generated-v2_0/build-info.json

@@ -1,6 +1,6 @@
 {
 {
   "schema": "board-viewer-build-info-v1",
   "schema": "board-viewer-build-info-v1",
-  "generated_at": "2026-10-27T02:16:11.999645+00:00",
+  "generated_at": "2026-10-29T16:19:52.676082+00:00",
   "generator_version": "2.1.0",
   "generator_version": "2.1.0",
   "toolchain": {
   "toolchain": {
     "python": "3.13.5",
     "python": "3.13.5",
@@ -9,7 +9,7 @@
   "sources": {
   "sources": {
     "generator_v20": {
     "generator_v20": {
       "path": "tools/board-viewer/generate_v2_0_assets.py",
       "path": "tools/board-viewer/generate_v2_0_assets.py",
-      "sha256": "adce0255f91f10157009f6d459bc4dd7def7996a9b540ce1217be868a1e21a26"
+      "sha256": "93e6f87d12b37ee72a06b1e3adaa23f1b3ab1fa31fd80da40fa4cc97d0bac250"
     },
     },
     "generator_annotations": {
     "generator_annotations": {
       "path": "tools/board-viewer/board_viewer/annotations.py",
       "path": "tools/board-viewer/board_viewer/annotations.py",
@@ -54,11 +54,11 @@
   },
   },
   "assets": {
   "assets": {
     "board-data.json": {
     "board-data.json": {
-      "sha256": "120c4b94a6122431ac38aa79a475a23edc1f2061b95f519aef1b7d6dc3483abe",
-      "bytes": 3926335
+      "sha256": "abdbaba9716d06a78e2ca1d6ea3a5d722a61488ab6b950633e2250997312833b",
+      "bytes": 3926332
     },
     },
     "import-report.json": {
     "import-report.json": {
-      "sha256": "6b1a2bd65d55bbbf824351c9de82168658b20ffd9db6bec420fd56a1087fd5e4",
+      "sha256": "ada2248aa0e9cd19785845633fb25265c84b84b42c63a0c08cdab8c211d56a0a",
       "bytes": 485
       "bytes": 485
     },
     },
     "board-mask-edge.svg": {
     "board-mask-edge.svg": {

+ 1 - 1
tools/board-viewer/generated-v2_0/import-report.json

@@ -5,7 +5,7 @@
   "source_format": "allegro_brd",
   "source_format": "allegro_brd",
   "output_file": "board-data.json",
   "output_file": "board-data.json",
   "errors": [],
   "errors": [],
-  "timestamp": "2026-10-27T02:16:11.984750+00:00",
+  "timestamp": "2026-10-29T16:19:52.660963+00:00",
   "stats": {
   "stats": {
     "connectors": 41,
     "connectors": 41,
     "jumpers": 18,
     "jumpers": 18,

+ 3 - 3
tools/board-viewer/generated-v2_0_fan/build-info.json

@@ -1,6 +1,6 @@
 {
 {
   "schema": "board-viewer-build-info-v1",
   "schema": "board-viewer-build-info-v1",
-  "generated_at": "2026-10-27T02:16:12.421813+00:00",
+  "generated_at": "2026-10-29T16:19:53.245599+00:00",
   "generator_version": "2.1.0",
   "generator_version": "2.1.0",
   "toolchain": {
   "toolchain": {
     "python": "3.13.5",
     "python": "3.13.5",
@@ -9,7 +9,7 @@
   "sources": {
   "sources": {
     "generator_v20": {
     "generator_v20": {
       "path": "tools/board-viewer/generate_v2_0_assets.py",
       "path": "tools/board-viewer/generate_v2_0_assets.py",
-      "sha256": "adce0255f91f10157009f6d459bc4dd7def7996a9b540ce1217be868a1e21a26"
+      "sha256": "93e6f87d12b37ee72a06b1e3adaa23f1b3ab1fa31fd80da40fa4cc97d0bac250"
     },
     },
     "generator_annotations": {
     "generator_annotations": {
       "path": "tools/board-viewer/board_viewer/annotations.py",
       "path": "tools/board-viewer/board_viewer/annotations.py",
@@ -50,7 +50,7 @@
       "bytes": 193774
       "bytes": 193774
     },
     },
     "import-report.json": {
     "import-report.json": {
-      "sha256": "1c04a81fed583121b0c55a4a1448843bed6780434ac43122eafc5f53562a60bf",
+      "sha256": "f48dd5505d0b4a3f756c4f63df5d813fb7220c68b260390d7950de212563dac2",
       "bytes": 390
       "bytes": 390
     },
     },
     "board-mask-edge.svg": {
     "board-mask-edge.svg": {

+ 1 - 1
tools/board-viewer/generated-v2_0_fan/import-report.json

@@ -5,7 +5,7 @@
   "source_format": "allegro_brd",
   "source_format": "allegro_brd",
   "output_file": "board-data.json",
   "output_file": "board-data.json",
   "errors": [],
   "errors": [],
-  "timestamp": "2026-10-27T02:16:12.420470+00:00",
+  "timestamp": "2026-10-29T16:19:53.243996+00:00",
   "stats": {
   "stats": {
     "connectors": 7,
     "connectors": 7,
     "fuses": 4
     "fuses": 4

+ 8 - 8
tools/generate_6400.py

@@ -123,11 +123,11 @@ def validate_6400(payload: Mapping[str, Any]) -> None:
     _require(outputs["ptc_count"] == 24 and outputs["fan_count"] == 8, "PTC/FAN count mismatch")
     _require(outputs["ptc_count"] == 24 and outputs["fan_count"] == 8, "PTC/FAN count mismatch")
     _require(outputs["output_count"] == 32, "output_count must be 32")
     _require(outputs["output_count"] == 32, "output_count must be 32")
     _require(len(outputs["ptc_channels"]) == 24 and len(outputs["fan_channels"]) == 8, "channel list length mismatch")
     _require(len(outputs["ptc_channels"]) == 24 and len(outputs["fan_channels"]) == 8, "channel list length mismatch")
-    _require(outputs["pwm_frequency_hz"] == 500, "PWM frequency must be 500")
+    _require(outputs["pwm_frequency_hz"] == 20, "PWM frequency must be 20")
     _require(outputs["pwm_phase_count"] == 100, "PWM phase count must be 100")
     _require(outputs["pwm_phase_count"] == 100, "PWM phase count must be 100")
-    _require(outputs["pwm_phase_clks"] == 500, "PWM phase clocks must be 500")
-    _require(outputs["pwm_period_clks"] == 50_000, "PWM period must be 50000")
-    _require(outputs["pwm_actual_frequency_hz"] == 500, "PWM actual frequency must be 500")
+    _require(outputs["pwm_phase_clks"] == 12500, "PWM phase clocks must be 12500")
+    _require(outputs["pwm_period_clks"] == 1_250_000, "PWM period must be 1250000")
+    _require(outputs["pwm_actual_frequency_hz"] == 20, "PWM actual frequency must be 20")
     _require(outputs["ptc_polarity"] == "active_high" and outputs["fan_polarity"] == "active_low", "polarity mismatch")
     _require(outputs["ptc_polarity"] == "active_high" and outputs["fan_polarity"] == "active_low", "polarity mismatch")
     _require(outputs["boot_targets"] == {"ptc": 0, "fan": 10}, "boot targets mismatch")
     _require(outputs["boot_targets"] == {"ptc": 0, "fan": 10}, "boot targets mismatch")
     _require(outputs["fan_board_inverts"] is True, "FAN board invert required")
     _require(outputs["fan_board_inverts"] is True, "FAN board invert required")
@@ -333,10 +333,10 @@ def generate_6400(
         "set_all_frame_len": 38,
         "set_all_frame_len": 38,
         "temperature_payload_len": 27,
         "temperature_payload_len": 27,
         "temperature_frame_len": 33,
         "temperature_frame_len": 33,
-        "pwm_frequency_hz": 500,
-        "pwm_period_clks": 50000,
-        "pwm_phase_clks": 500,
-        "actual_frequency_hz": 500.0,
+        "pwm_frequency_hz": 20,
+        "pwm_period_clks": 1250000,
+        "pwm_phase_clks": 12500,
+        "actual_frequency_hz": 20.0,
         "unresolved_pins": unresolved,
         "unresolved_pins": unresolved,
         "release_status": "release_blocked" if unresolved else "release-ready",
         "release_status": "release_blocked" if unresolved else "release-ready",
         "release_blocked": bool(unresolved),
         "release_blocked": bool(unresolved),

Dosya farkı çok büyük olduğundan ihmal edildi
+ 2982 - 6
tools/prod2u_gui.py


+ 101 - 35
tools/pwm_scope.py

@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
 #!/usr/bin/env python3
-"""6400V2.0 scope test 1.0.3: SET35 / GET86, 500Hz PWM, no shutdown command."""
+"""6400V2.0 scope test 1.0.5: SET35 / GET86, 20Hz PWM, fan 5s 50%/0% toggle, no shutdown command."""
 import argparse
 import argparse
 import binascii
 import binascii
 import datetime as dt
 import datetime as dt
@@ -13,10 +13,50 @@ import sys
 import time
 import time
 import unicodedata
 import unicodedata
 
 
-SCRIPT_VERSION = "1.0.3"
+SCRIPT_VERSION = "1.0.4"
 BOX_WIDTH = 90
 BOX_WIDTH = 90
-DEFAULT_PORT = "/dev/serial/by-path/pci-0000:00:14.0-usb-0:2:1.0-port0"
-DUTIES = bytes(range(1, 36))
+DEFAULT_PORT = "/dev/serial/by-path/pci-0000:00:14.0-usb-0:3:1.0-port0"
+FALLBACK_USB1_PORTS = (
+    "/dev/serial/by-path/pci-0000:00:14.0-usb-0:3:1.0-port0",
+    "/dev/serial/by-path/pci-0000:00:14.0-usb-0:2:1.0-port0",
+    "/dev/serial/by-id/usb-FTDI_USB__-__Serial-if00-port0",
+    "/dev/ttyUSB1",
+)
+PTC_DUTIES = bytes(range(1, 25))
+SSR_DUTIES = bytes((33, 34, 35))
+FAN_DUTY_HIGH = 50
+FAN_DUTY_LOW = 0
+FAN_HOLD_SECONDS = 5.0
+
+
+def resolve_port(port):
+    real = os.path.realpath(port)
+    if real == "/dev/ttyUSB0" or "BG00WPDX" in str(port):
+        raise RuntimeError("USB0属于其他项目,拒绝打开")
+    if os.path.exists(port):
+        return port
+    if port in FALLBACK_USB1_PORTS:
+        by_path_dir = Path("/dev/serial/by-path")
+        candidates = list(FALLBACK_USB1_PORTS)
+        if by_path_dir.is_dir():
+            candidates.extend(str(p) for p in sorted(by_path_dir.iterdir()))
+        for cand in candidates:
+            if os.path.exists(cand) and os.path.realpath(cand) == "/dev/ttyUSB1":
+                return cand
+    return port
+
+
+def fan_duty_for_elapsed(elapsed=0.0):
+    phase = int((max(0.0, float(elapsed)) + 1e-9) // FAN_HOLD_SECONDS) % 2
+    return FAN_DUTY_HIGH if phase == 0 else FAN_DUTY_LOW
+
+
+def build_duties(fan_duty=FAN_DUTY_HIGH):
+    return PTC_DUTIES + bytes([fan_duty]) * 8 + SSR_DUTIES
+
+
+DUTIES = build_duties(FAN_DUTY_HIGH)
+DUTIES_FAN_ZERO = build_duties(FAN_DUTY_LOW)
 CT_CONNECTORS = ("U6-local", "CON53", "CON55", "CON56", "CON57",
 CT_CONNECTORS = ("U6-local", "CON53", "CON55", "CON56", "CON57",
                  "CON79", "CON80", "CON81", "CON82")
                  "CON79", "CON80", "CON81", "CON82")
 CT_ROLES = ("U6芯片本地", "腔1进风口", "腔1出风口", "腔2进风口", "腔2出风口",
 CT_ROLES = ("U6芯片本地", "腔1进风口", "腔1出风口", "腔2进风口", "腔2出风口",
@@ -117,16 +157,16 @@ def output_rows():
     rows = []
     rows = []
     for i in range(24):
     for i in range(24):
         rows.append((i, f"PTC{i:02d} 腔{i // 6 + 1} 第{i % 6 + 1}路",
         rows.append((i, f"PTC{i:02d} 腔{i // 6 + 1} 第{i % 6 + 1}路",
-                     PTC_PINS[i], PTC_BALLS[i], 500))
+                     PTC_PINS[i], PTC_BALLS[i], 20))
     for j in range(8):
     for j in range(8):
         role = "进风" if j < 4 else "排风"
         role = "进风" if j < 4 else "排风"
         rows.append((24 + j, f"腔{j % 4 + 1}{role}",
         rows.append((24 + j, f"腔{j % 4 + 1}{role}",
-                     FAN_PINS[j], FAN_BALLS[j], 500))
+                     FAN_PINS[j], FAN_BALLS[j], 20))
     for j, (name, pin, ball) in enumerate((
     for j, (name, pin, ball) in enumerate((
             ("SSR1 腔1", "CON165.1", "E14"),
             ("SSR1 腔1", "CON165.1", "E14"),
             ("SSR2 腔2+3共用", "CON165.2", "E8"),
             ("SSR2 腔2+3共用", "CON165.2", "E8"),
             ("SSR4 腔4", "CON165.4", "D9"))):
             ("SSR4 腔4", "CON165.4", "D9"))):
-        rows.append((32 + j, name, pin, ball, 500))
+        rows.append((32 + j, name, pin, ball, 20))
     return rows
     return rows
 
 
 
 
@@ -171,13 +211,13 @@ def show_map(style=None):
     st = style or Style(enabled=sys.stdout.isatty() and not os.environ.get("NO_COLOR"))
     st = style or Style(enabled=sys.stdout.isatty() and not os.environ.get("NO_COLOR"))
     top, mid, sep, bot, row, _ = _box_helpers(st)
     top, mid, sep, bot, row, _ = _box_helpers(st)
 
 
-    print(top(f"6400V2.0 示波器与温度测试 (脚本 v{SCRIPT_VERSION} / 适配固件 3.0.3)"))
+    print(top(f"6400V2.0 示波器与温度测试 (脚本 v{SCRIPT_VERSION} / 适配固件 3.0.4)"))
     print(row(
     print(row(
         f"{st.bold('协议')}: SET35 / GET86 (921600 8N1)     "
         f"{st.bold('协议')}: SET35 / GET86 (921600 8N1)     "
-        f"{st.bold('统一频率')}: 500Hz (周期 2.00ms, 1% = 20µs)"
+        f"{st.bold('统一频率')}: 20Hz (周期 50.00ms, 1% = 0.50ms)"
     ))
     ))
     print(row(
     print(row(
-        f"{st.bold('规则')}: SET字节从0编号,35路占空比 = 字节编号 + 1 (%);退出仅停发等待30s看门狗"
+        f"{st.bold('规则')}: PTC=1~24%,风扇8路=5秒50%/5秒0%交替往复,SSR=33~35%;退出仅停发等30s看门狗"
     ))
     ))
     print(mid("35路 PWM 输出与测量点映射表"))
     print(mid("35路 PWM 输出与测量点映射表"))
     header = (
     header = (
@@ -198,17 +238,21 @@ def show_map(style=None):
             print(row(st.bold_yellow("▶ PTC 加热片 (24路) — 连接器脚为功率正端;示波器读数须结合测量位置与板上驱动极性")))
             print(row(st.bold_yellow("▶ PTC 加热片 (24路) — 连接器脚为功率正端;示波器读数须结合测量位置与板上驱动极性")))
         elif i == 24:
         elif i == 24:
             print(sep())
             print(sep())
-            print(row(st.bold_yellow("▶ 风扇 PWM (8路) — 连接器高电平占空比=D;FPGA引脚经2N7002反相,低电平占空比=D")))
+            print(row(st.bold_yellow("▶ 风扇 PWM (8路) — 默认5s 50%/5s 0%交替;接口高电平=D,FPGA脚经2N7002反相低电平=D")))
         elif i == 32:
         elif i == 32:
             print(sep())
             print(sep())
             print(row(st.bold_yellow("▶ SSR 加热块 (3路) — CON165为3.3V控制端;24V功率端空载测波形建议接330Ω/5W假负载")))
             print(row(st.bold_yellow("▶ SSR 加热块 (3路) — CON165为3.3V控制端;24V功率端空载测波形建议接330Ω/5W假负载")))
 
 
         duty = DUTIES[i]
         duty = DUTIES[i]
-        pulse_us = duty * 20
+        pulse_ms = duty * 0.5
         idx_s = pad(f"{i:2d}", 7, "center")
         idx_s = pad(f"{i:2d}", 7, "center")
         name_s = pad(name, 16)
         name_s = pad(name, 16)
-        duty_s = pad(f"{duty:2d}%", 6, "right")
-        pulse_s = pad(f"{pulse_us:3d}µs", 8, "right")
+        if 24 <= i < 32:
+            duty_s = pad("50%/0%", 6, "right")
+            pulse_s = pad("25.0/0ms", 8, "right")
+        else:
+            duty_s = pad(f"{duty:2d}%", 6, "right")
+            pulse_s = pad(f"{pulse_ms:5.1f}ms", 8, "right")
         hz_s = pad(f"{hz:3d}Hz", 6, "right")
         hz_s = pad(f"{hz:3d}Hz", 6, "right")
         pin_s = pad(pin, 9)
         pin_s = pad(pin, 9)
         ball_s = pad(ball, 5)
         ball_s = pad(ball, 5)
@@ -359,10 +403,12 @@ class Link:
             frames.append((kind, payload))
             frames.append((kind, payload))
         return frames
         return frames
 
 
-    def request(self, kind, end):
+    def request(self, kind, end, payload=None):
         if time.monotonic() >= end:
         if time.monotonic() >= end:
             raise TimeoutError("运行时间结束")
             raise TimeoutError("运行时间结束")
-        raw = frame(kind, DUTIES if kind == 1 else b"")
+        if payload is None:
+            payload = DUTIES if kind == 1 else b""
+        raw = frame(kind, payload)
         self.serial.write(raw)
         self.serial.write(raw)
         self.event("TX", type=f"{kind:02X}", hex=raw.hex(" "))
         self.event("TX", type=f"{kind:02X}", hex=raw.hex(" "))
         limit = min(end, time.monotonic() + 0.7)
         limit = min(end, time.monotonic() + 0.7)
@@ -410,7 +456,8 @@ def styled_temp(value, style, width=3):
 
 
 def render_live_panel(style, *, cycles, total_cycles, elapsed, remaining,
 def render_live_panel(style, *, cycles, total_cycles, elapsed, remaining,
                       read_only, matches, outputs, ct, errors, bad_crc,
                       read_only, matches, outputs, ct, errors, bad_crc,
-                      diag, diag_slots, last_error, last_ack_age=None):
+                      diag, diag_slots, last_error, last_ack_age=None,
+                      expected_outputs=None):
     top, mid, _, bot, row, split2 = _box_helpers(style)
     top, mid, _, bot, row, split2 = _box_helpers(style)
     total_dur = max(0.001, elapsed + remaining)
     total_dur = max(0.001, elapsed + remaining)
     ratio = min(1.0, elapsed / total_dur)
     ratio = min(1.0, elapsed / total_dur)
@@ -449,22 +496,30 @@ def render_live_panel(style, *, cycles, total_cycles, elapsed, remaining,
             f"错误: {err_str} │ 丢弃CRC: {crc_str} │ 看门狗: {watchdog}",
             f"错误: {err_str} │ 丢弃CRC: {crc_str} │ 看门狗: {watchdog}",
             left_w=33,
             left_w=33,
         ),
         ),
-        mid("35路 PWM 控制回读核对 (500Hz / 周期 2.00ms)"),
+        mid("35路 PWM 控制回读核对 (20Hz / 周期 50.00ms)"),
     ]
     ]
 
 
     if outputs and len(outputs) == 35:
     if outputs and len(outputs) == 35:
-        ptc_ok = list(outputs[:24]) == list(DUTIES[:24])
-        fan_ok = list(outputs[24:32]) == list(DUTIES[24:32])
+        ptc_ok = list(outputs[:24]) == list(PTC_DUTIES)
+        fan_vals = list(outputs[24:32])
+        if expected_outputs is not None and len(expected_outputs) == 35:
+            fan_ok = fan_vals == list(expected_outputs[24:32])
+        else:
+            fan_ok = fan_vals in ([FAN_DUTY_HIGH] * 8, [FAN_DUTY_LOW] * 8)
         ssr_vals = list(outputs[32:35])
         ssr_vals = list(outputs[32:35])
-        ssr_ok = ssr_vals == list(DUTIES[32:35])
+        ssr_ok = ssr_vals == list(SSR_DUTIES)
         b1 = style.green("✓") if ptc_ok or read_only else style.red("✗")
         b1 = style.green("✓") if ptc_ok or read_only else style.red("✗")
         b2 = style.green("✓") if fan_ok or read_only else style.red("✗")
         b2 = style.green("✓") if fan_ok or read_only else style.red("✗")
         b3 = style.green("✓") if ssr_ok or read_only else style.red("✗")
         b3 = style.green("✓") if ssr_ok or read_only else style.red("✗")
         if matches is None:
         if matches is None:
             b1 = b2 = b3 = style.yellow("?")
             b1 = b2 = b3 = style.yellow("?")
+        if len(set(fan_vals)) == 1:
+            fan_text = f"进/排风8路: {fan_vals[0]:2d}% ({fan_vals[0]*20:4d}µs, 5s 50/0%) {b2}"
+        else:
+            fan_text = f"进/排风8路: {outputs[24]:2d}%~{outputs[31]:2d}% ({outputs[24]*20:4d}~{outputs[31]*20:4d}µs) {b2}"
         lines.append(split2(
         lines.append(split2(
             f"PTC00..23 :  1%~24% ( 20~480µs) {b1}",
             f"PTC00..23 :  1%~24% ( 20~480µs) {b1}",
-            f"进/排风8路: {outputs[24]:2d}%~{outputs[31]:2d}% ({outputs[24]*20:3d}~{outputs[31]*20:3d}µs) {b2}",
+            fan_text,
             left_w=41,
             left_w=41,
         ))
         ))
         lines.append(row(
         lines.append(row(
@@ -525,7 +580,9 @@ def render_live_panel(style, *, cycles, total_cycles, elapsed, remaining,
 
 
 
 
 def run(args):
 def run(args):
-    if os.path.realpath(args.port) == "/dev/ttyUSB0":
+    port = resolve_port(args.port)
+    real_port = os.path.realpath(port)
+    if real_port == "/dev/ttyUSB0":
         raise RuntimeError("USB0属于其他项目,拒绝打开")
         raise RuntimeError("USB0属于其他项目,拒绝打开")
     is_tty = sys.stdout.isatty()
     is_tty = sys.stdout.isatty()
     use_color = is_tty and not os.environ.get("NO_COLOR") and not getattr(args, "no_color", False)
     use_color = is_tty and not os.environ.get("NO_COLOR") and not getattr(args, "no_color", False)
@@ -537,8 +594,7 @@ def run(args):
                 (dt.datetime.now().strftime("%Y%m%d-%H%M%S-%f") + ".jsonl"))
                 (dt.datetime.now().strftime("%Y%m%d-%H%M%S-%f") + ".jsonl"))
     log_path.parent.mkdir(parents=True, exist_ok=True)
     log_path.parent.mkdir(parents=True, exist_ok=True)
     show_map(style=style)
     show_map(style=style)
-    real_port = os.path.realpath(args.port)
-    print(f"{style.bold('串口')}:{args.port} -> {style.cyan(real_port)} / 921600 8N1")
+    print(f"{style.bold('串口')}:{port} -> {style.cyan(real_port)} / 921600 8N1")
     print(f"{style.bold('计划')}:运行 {style.bold(f'{args.minutes:g}')} 分钟,每 {style.bold(f'{args.interval:g}')} 秒一轮;日志:{style.dim(log_path)}")
     print(f"{style.bold('计划')}:运行 {style.bold(f'{args.minutes:g}')} 分钟,每 {style.bold(f'{args.interval:g}')} 秒一轮;日志:{style.dim(log_path)}")
     print(f"{style.yellow('提示')}:Ctrl+C停止。结束只关闭串口,不发归零/恢复命令;最后有效命令后约30秒由固件超时。", flush=True)
     print(f"{style.yellow('提示')}:Ctrl+C停止。结束只关闭串口,不发归零/恢复命令;最后有效命令后约30秒由固件超时。", flush=True)
     if live_mode:
     if live_mode:
@@ -551,6 +607,7 @@ def run(args):
     next_due = start
     next_due = start
     prev_panel_lines = 0
     prev_panel_lines = 0
     last_outputs = None
     last_outputs = None
+    last_expected_outputs = DUTIES
     last_ct = None
     last_ct = None
     last_matches = None
     last_matches = None
     last_error = None
     last_error = None
@@ -582,6 +639,7 @@ def run(args):
             diag_slots=link.diag_slots,
             diag_slots=link.diag_slots,
             last_error=last_error,
             last_error=last_error,
             last_ack_age=None if link.last_ack_at is None else now_m - link.last_ack_at,
             last_ack_age=None if link.last_ack_at is None else now_m - link.last_ack_at,
+            expected_outputs=last_expected_outputs,
         )
         )
         clear_live_panel()
         clear_live_panel()
         sys.stdout.write("\n".join(panel) + "\n")
         sys.stdout.write("\n".join(panel) + "\n")
@@ -589,33 +647,40 @@ def run(args):
         prev_panel_lines = len(panel)
         prev_panel_lines = len(panel)
 
 
     with log_path.open("x", encoding="utf-8") as log:
     with log_path.open("x", encoding="utf-8") as log:
-        link = Link(args.port, log)
-        link.event("START", port=args.port, minutes=args.minutes,
+        link = Link(port, log)
+        link.event("START", port=port, minutes=args.minutes,
                    interval=args.interval, read_only=args.read_only,
                    interval=args.interval, read_only=args.read_only,
-                   set_payload=list(DUTIES))
+                   set_payload=list(DUTIES),
+                   set_payload_fan0=list(DUTIES_FAN_ZERO),
+                   fan_hold_seconds=FAN_HOLD_SECONDS)
         if live_mode:
         if live_mode:
             sys.stdout.write("\x1b[?25l")
             sys.stdout.write("\x1b[?25l")
             sys.stdout.flush()
             sys.stdout.flush()
         try:
         try:
             link.synchronize(end)
             link.synchronize(end)
             print(f"启动同步:清理{link.startup_bytes}字节缓存(原始字节已记录);以下CRC为运行期统计。", flush=True)
             print(f"启动同步:清理{link.startup_bytes}字节缓存(原始字节已记录);以下CRC为运行期统计。", flush=True)
+            loop_start = next_due = time.monotonic()
             while time.monotonic() < end:
             while time.monotonic() < end:
                 cycles += 1
                 cycles += 1
                 last_matches = None
                 last_matches = None
+                fan_duty = fan_duty_for_elapsed(time.monotonic() - loop_start)
+                expected_duties = build_duties(fan_duty)
+                last_expected_outputs = expected_duties
                 try:
                 try:
                     if not args.read_only:
                     if not args.read_only:
-                        link.request(1, end)
+                        link.request(1, end, expected_duties)
                     data = link.request(2, end)
                     data = link.request(2, end)
                     outputs = data[:32] + data[83:86]
                     outputs = data[:32] + data[83:86]
-                    matches = outputs == DUTIES
+                    matches = outputs == expected_duties
                     if not args.read_only and not matches:
                     if not args.read_only and not matches:
-                        raise RuntimeError(f"输出回读不符:{list(outputs)}")
+                        raise RuntimeError(f"输出回读不符:{list(outputs)} (期望风扇={fan_duty}%)")
                     ct = list(data[56:65])
                     ct = list(data[56:65])
                     last_outputs = outputs
                     last_outputs = outputs
                     last_ct = ct
                     last_ct = ct
                     last_matches = matches
                     last_matches = matches
                     link.event("CYCLE", cycle=cycles,
                     link.event("CYCLE", cycle=cycles,
                                elapsed=round(time.monotonic() - start, 3),
                                elapsed=round(time.monotonic() - start, 3),
+                               fan_duty=fan_duty,
                                output_match=matches, outputs=list(outputs),
                                output_match=matches, outputs=list(outputs),
                                ct=ct, ct_reserved=list(data[65:83]),
                                ct=ct, ct_reserved=list(data[65:83]),
                                bmc=list(data[32:56]))
                                bmc=list(data[32:56]))
@@ -624,7 +689,7 @@ def run(args):
                     else:
                     else:
                         values = "  ".join(f"CT{i}/{name}={temp(value)}"
                         values = "  ".join(f"CT{i}/{name}={temp(value)}"
                                            for i, (name, value) in enumerate(zip(CT_CONNECTORS, ct)))
                                            for i, (name, value) in enumerate(zip(CT_CONNECTORS, ct)))
-                        mode = "GET OK" if args.read_only else "SET/GET 35路一致"
+                        mode = "GET OK" if args.read_only else f"SET/GET 35路一致 (风扇={fan_duty}%)"
                         print(f"[{dt.datetime.now():%H:%M:%S}] #{cycles} {mode}\n  {values}", flush=True)
                         print(f"[{dt.datetime.now():%H:%M:%S}] #{cycles} {mode}\n  {values}", flush=True)
                         if link.diag:
                         if link.diag:
                             d = link.diag
                             d = link.diag
@@ -644,7 +709,7 @@ def run(args):
                         draw_live_panel()
                         draw_live_panel()
                     else:
                     else:
                         print(f"[{dt.datetime.now():%H:%M:%S}] {exc}", flush=True)
                         print(f"[{dt.datetime.now():%H:%M:%S}] {exc}", flush=True)
-                next_due = max(next_due + args.interval, time.monotonic())
+                next_due = max(loop_start + cycles * args.interval, time.monotonic())
                 link.idle_until(min(next_due, end))
                 link.idle_until(min(next_due, end))
         except KeyboardInterrupt:
         except KeyboardInterrupt:
             print("\n已停止发送。", flush=True)
             print("\n已停止发送。", flush=True)
@@ -682,8 +747,9 @@ def main(argv=None):
     style = Style(enabled=use_color)
     style = Style(enabled=use_color)
     if args.dry_run:
     if args.dry_run:
         show_map(style=style)
         show_map(style=style)
-        print("SET_ALL:", frame(1, DUTIES).hex(" ").upper())
-        print("GET_ALL:", frame(2).hex(" ").upper())
+        print("SET_ALL (风扇50%):", frame(1, DUTIES).hex(" ").upper())
+        print("SET_ALL (风扇0%) :", frame(1, DUTIES_FAN_ZERO).hex(" ").upper())
+        print("GET_ALL          :", frame(2).hex(" ").upper())
         return 0
         return 0
     signal.signal(signal.SIGTERM, stop_sending)
     signal.signal(signal.SIGTERM, stop_sending)
     try:
     try:

+ 1 - 1
tools/run_6400_connector.py

@@ -23,7 +23,7 @@ PTC_BALLS = (
     "K5", "L4", "H4", "J6", "H5", "C15",
     "K5", "L4", "H4", "J6", "H5", "C15",
 )
 )
 SPARE_BALLS = ("M1", "N1", "P1", "R1", "P8", "P7", "T9", "P9", "P2", "M3", "L5")
 SPARE_BALLS = ("M1", "N1", "P1", "R1", "P8", "P7", "T9", "P9", "P2", "M3", "L5")
-SSR_BALLS = ("F3", "F1", "G4")
+SSR_BALLS = ("E14", "E8", "D9")
 
 
 
 
 def fixture_from_adc(adc: Path) -> tuple[str, dict[str, str]]:
 def fixture_from_adc(adc: Path) -> tuple[str, dict[str, str]]:

+ 1 - 1
tools/run_6400_mutation.py

@@ -66,7 +66,7 @@ MUTATIONS = (
     Mutation(
     Mutation(
         "pwm_deadline_shortened",
         "pwm_deadline_shortened",
         "src/actuator/pwm_bitmap_engine.v",
         "src/actuator/pwm_bitmap_engine.v",
-        "parameter integer PTC_PHASE_CLKS = 500,",
+        "parameter integer PTC_PHASE_CLKS = 12500,",
         "parameter integer PTC_PHASE_CLKS = 32,",
         "parameter integer PTC_PHASE_CLKS = 32,",
         "pwm",
         "pwm",
     ),
     ),

+ 2 - 2
tools/run_v3_protocol.py

@@ -32,8 +32,8 @@ def main():
     out.mkdir(parents=True, exist_ok=False)
     out.mkdir(parents=True, exist_ok=False)
     receipt = {'test': 'prod2u_v3_protocol_tb', 'status': 'NOT_RUN',
     receipt = {'test': 'prod2u_v3_protocol_tb', 'status': 'NOT_RUN',
                'scope': '25 MHz production top and nominal 921600 external UART; digital CT bus model; no hardware claim',
                'scope': '25 MHz production top and nominal 921600 external UART; digital CT bus model; no hardware claim',
-               'timer_only_elaboration_overrides': {'WD_TIMEOUT_CLKS': 500000,
-                                                    'u_core.BEACON_PERIOD': 100000},
+               'timer_only_elaboration_overrides': {'WD_TIMEOUT_CLKS': 1400000,
+                                                    'u_core.BEACON_PERIOD': 400000},
                'hierarchical_force_or_ram_injection': False,
                'hierarchical_force_or_ram_injection': False,
                'source_sha256': {str(p): hashlib.sha256(p.read_bytes()).hexdigest() for p in inputs},
                'source_sha256': {str(p): hashlib.sha256(p.read_bytes()).hexdigest() for p in inputs},
                'commands': []}
                'commands': []}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1239 - 0
tools/thermal_test_server.py


+ 2 - 2
tools/validate_active_6400_lock.py

@@ -66,8 +66,8 @@ def main() -> int:
     outputs = data.get("outputs", {})
     outputs = data.get("outputs", {})
     if (outputs.get("ptc_count"), outputs.get("front_fan_count"), outputs.get("rear_fan_count")) != (24, 4, 4):
     if (outputs.get("ptc_count"), outputs.get("front_fan_count"), outputs.get("rear_fan_count")) != (24, 4, 4):
         return fail("actuator counts")
         return fail("actuator counts")
-    if outputs.get("ptc_pwm_hz") != 500 or outputs.get("fan_pwm_hz") != 500:
-        return fail("PWM frequency must be 500 Hz for PTC and FAN")
+    if outputs.get("ptc_pwm_hz") != 20 or outputs.get("fan_pwm_hz") != 20:
+        return fail("PWM frequency must be 20 Hz for PTC and FAN")
     host = data.get("host_uart", {})
     host = data.get("host_uart", {})
     if host.get("baud") != 921600 or host.get("format") != "8N1" or host.get("connector") != "CON78":
     if host.get("baud") != 921600 or host.get("format") != "8N1" or host.get("connector") != "CON78":
         return fail("host UART")
         return fail("host UART")