# AGENTS.md — Prod2U CPLD (`cpld-temperature-control`) > **Precedence**: Active release docs (`README.zh-CN.md`, `docs/releases/v3.3.0.md`, `docs/releases/v3.2.0.md`) supersede historical dates/parameters in archived notes (`docs/operating-rules-2026-09-recovery.md`). > Keep this file concise (target < 8 KB; hard platform limit 24 KB). Put detailed specs in `docs/`. ## 1. Current Baseline (`v3.3.0` on `dev`; `6400-v1.1` standalone branch) - **Priority Order**: (1) Simple, direct, serial/high-reuse, reliable logic & code (no excessive safety interlocks/redundancy); (2) Minimize LUT / Slice (freely trade BRAM/FF/IO for lower LUT); (3) Throughput/latency last (parallel outputs only need concurrent enable, no sync trigger). - **Branches & Scope**: `dev` is the active production release branch (`6400-v2` + `mrdimm`); `6400-v1.1` is a **standalone branch NEVER merged into `dev`** (6400 V1.1 No-MCU + Windows Adaptive PID + BMC NET direct DIMM acquisition); `master` is QA promotion. Three active repos: `cpld-temperature-control`, `hth-platform`, `engineering-manifests`. - **Active Products** (build & ship separately; no runtime board ID): - **6400 V2.0 (`6400-v2`, `dev`)**: 24 PTC, 4 Front (进风) + 4 Rear (出风), 3 SSR (`SSR1/SSR2/SSR4`), CT/BMC telemetry, 3 buttons (`EPB1=F8`, `SB1=C11`, `SB2=A11`), 4000 Hz 80% buzzer (`H6`). Wire: `SET_ALL` = **36B** (bytes 32..34 SSR, byte 35 buzzer `0/1`; legacy 35B compat), `GET_DATA` = **90B** (bytes 86..88 `estop_btn`/`hood_open_btn`/`hood_close_btn` on `GET_ALL` only, NO EPB1 interlock; byte 89 `buzzer_state`; host tools compat 88B/86B), `DIAGNOSTIC` = **20B** (`0x52`, 1s auto, fw `3.3.0`). V3.0 aligned CON165 pinout: `SSR1=CON165.14->E14`, `SSR2=CON165.13->E8`, `CON165.12=NC` (old `F7` removed), `SSR4=CON165.11->D9`, `EPB1=CON165.10->F8` (`R1696/R1856`, `R1724=NC`), `SB1=CON165.9->C11` (`R1693/R1855`, `R1717=NC`), `SB2=CON165.8->A11` (`R1692/R1854`, `R1723=NC`), all 3 `LVCMOS33 + PULLDOWN`; `buzzer_out=CON146.1->H6` (`CON146.2=GND`); old `F3/F1/G4` fixed low. - **MRDIMM V1.2 (`mrdimm`, `dev`)**: 12 independent finite-step motor axes (BRAM-backed serial ALU: 4× BRAM32K + 1× BRAM9K), 4 FAN, 4 logical PTC (-> 24 physical PTC), CT/BMC telemetry, hood switch (`L3` `CON140.3` `PULLDOWN`), 4000 Hz 80% buzzer (`H6` `CON146.1`). Wire: `SET_ALL` = **69B** (byte 68 buzzer `0/1`; legacy 68B compat), `GET_DATA` = **65B** (byte 63 `hood_switch` on `GET_ALL` only, byte 64 `buzzer_state`), `MOTOR_DONE` = **4B**, `DIAGNOSTIC` = **8B** (`0x52` format 2, 5s auto with `0x51`, fw `3.3.0`). - **6400 V1.1 (`6400-front-rear`, standalone branch `6400-v1.1` ONLY)**: No-MCU CPLD (24 PTC + 8 FAN `8'h0F` @ 20 Hz + 3-chip 27-ch CT7428 on `M8/N9`, BMC UART removed); `SET_ALL` = 32B, `GET_DATA` = 83B (`32..55`=`0xFF`), `DIAGNOSTIC` = 20B (`0x52` format 3, `board_id=0x61`, fw `3.3.0`). Windows host EXE runs multi-chamber Adaptive PID & acquires 24 DIMM temps directly via BMC NET (IPMI v2.0 RMCP+ UDP:623). - **PWM & Clocks (`v3.3.0`)**: - Target `EF2L45BG256B` at **25 MHz** single clock domain. **No PLL, no derived/gated clocks, no clock used as data** (use enables/counters). - All heating/fan CPLD PWM (FAN, PTC, SSR) unified at **20 Hz** (`50 ms` period, `1%` step = `12,500` clks; SSR shares `u_pwm` phase). Buzzer (`buzzer_pwm_4khz`, `U3.H6`) outputs **4000 Hz, 80% duty** (`6250` clks period, `5000` HIGH, `1250` LOW) when `0x01`. Power-on / 30s watchdog default output: **PTC 0%, FAN 20%, SSR 0%, Buzzer 0**, MRDIMM STEP low. - **UART & Sensors**: - Host RS232/TTL (`host_uart_endpoint` with byte-level `0xA5` claim): 8N1 per-build fixed baud (`921600` target, `460800`/`230400`/`115200` fallback); MRDIMM RS232 CON78.1/2 (`N11` `PULLUP`), TTL CON140.1(T11)/2(P13) (**CON146 is 12V/24V, NOT TTL**). Never drop `DONE` by flushing RX before send. - BMC UART fixed `115200 8N1` (optional). CT7428 sensor I2C uses `B14/SCL`, `A15/SDA`; MRDIMM onboard MCU I2C0 must remain Hi-Z. ## 2. Workspace, Git & Hardware Safety Rules - **Git hygiene**: One writer per tree. **Never `git reset`, `clean`, `stash`, `restore`, overwrite, or delete unknown changes.** Stage explicitly (`git add `, never `git add -A`). Do not push without explicit user authorization. - **USB / JTAG / Serial strict lock**: - **USB0 IS STRICTLY FORBIDDEN** (unrelated project — never open or touch USB0). - 6400 V2.0 JTAG & USB1 UART are on `USB1` only. Identify COM port & board type before acting; never perform JTAG/COM programming or claim physical hardware validation without explicit user authorization. - SRAM debug uses **200 KHz** (`-spd 3`), explicit `-vec` download, and matching `.bmk` readback verify. SPI Flash requires `program_spi -v` + refresh + SRAM readback. - **No fabricated evidence**: Never fake commit history or mark fail/blocked/not-run/placeholder/historical receipts as PASS. Accepted software results require a real Linux run bound to commit + artifact hashes; record real hardware vs simulation separately. ## 3. Protocol, Architecture & Removed Features - **Frame**: `A5 5A | TYPE:u8 | LENGTH:u8 | PAYLOAD | CRC16_LE` (CCITT-FALSE `0x1021`, init `0xFFFF`, over TYPE+LENGTH+PAYLOAD). Independent RX/TX CRC accumulators. - **Atomic semantics**: `SET_ACCEPT` reloads 30s watchdog and applies output cleanly; `STOP_CLEAR` (`0xFF`) stops STEP immediately without affecting other axes; bad frames/length consume declared bytes to sink, never corrupt state or feed watchdog. Button inputs (`EPB1`/`SB1`/`SB2` on `6400-v2`, `hood_switch` on `mrdimm`) are sampled ONLY on `GET_ALL` (forced `0` on autonomous frames) with NO CPLD safety interlock. After watchdog expiry, any valid `SET` recovers directly (`GET` alone does not clear default output). - **Removed features (must NOT reappear in active closure)**: PID/PI loops, auto thermal cutoff/recovery, CT warm-up, position %, global snapshot lock, external age/epoch/stale fields, cumulative position, Tag, sequence numbers, event history, synchronised start, unbounded SEEK/CONTINUOUS/HOLD, Host I2C (CT7428 sensor-only I2C master stays). Temperature is **acquisition-only integer `u8` °C** (`00..FE`, `FF` = invalid). - **MRDIMM 12-axis**: Maintain all 12 axes in production top (non-optimized); limits active-level blocking in moving direction only; count final STEP rising edges (`65535` = `FF FF`). ## 4. Verification, Packaging & Tool Recovery Guardrails - **TD Fit Gate**: Invoke `./tools/td2026` (`/data/prod2u/toolchain/TD_Release_2026.1_SP2_NL`, license valid to `2027-09-30`; NEVER use expired `/data/anlogic/...`). LUT, Slice subtypes, BRAM/ERAM, DSP, and IO must sit strictly below physical device limits (e.g. LUT < 4480) AND pass 25 MHz setup/hold with a generated `.bit`. Never disable axes or fake fit; never bypass vendor license checks. - **Remote Services & Delivery**: Board viewer on `http://192.168.2.25:8765/` (`board-viewer.service`, `/srv/board-viewer`); privileged thermal test platform `prod2u-thermal-test-backend` on `root@192.168.2.25:8766` (`tools/thermal_test_server.py`); Windows EXE, source/debug packages & maintained protocol doc (`docs/CPLD_通讯协议v2.0.md`) delivery target `administrator@192.168.2.24` (`C:\Prod2U_Releases\`). - **Tool/Network Bounds**: Reuse `remote_job.py` / `remote_transfer.py` in background; network retry max 5; formal run 600s max killing full process group on timeout. Packaging maintains `tools/package_prod2u.py` & `tools/package_unified_analysis.py` (deterministic POSIX paths, explicit checksums; auto-bundles `docs/CPLD_通讯协议v2.0.md` on every release — keep it updated on every iteration). ## 5. Reference Docs (Read On Demand) - Current release, protocol & wiring: `README.zh-CN.md`, `docs/CPLD_通讯协议v2.0.md`, `docs/releases/v3.2.0.md`, `docs/releases/v3.1.0.md`, `docs/evidence/6400-v2-electrical-alignment.md` - Detailed legacy specs & recovery notes: `docs/operating-rules-2026-09-recovery.md` - Protocol & scope guides: `docs/prod2u-dual-product-protocol.zh-CN.md`, `docs/pwm-scope.md`, `docs/TD_USAGE.zh-CN.md`