|
@@ -1,119 +1,48 @@
|
|
|
-# Prod2U CPLD Operating Rules
|
|
|
|
|
|
|
+# CPLD temperature-control repository rules
|
|
|
|
|
|
|
|
-This checkout is a single mainline with two firmware targets. `mrdimm` (`prod2u-door-temp`) keeps the frozen door-percent + MSE contract. `6400` (`prod2u-6400-front-back`) is the 24 PTC + 8 FAN thermal controller. Registry: `projects/registry.json`. Users run `./fw list|generate|test|build|package <target>`.
|
|
|
|
|
|
|
+This repository contains profile-isolated CPLD products. The active 6400 contract is `docs/architecture/6400-v1-design-lock.md` plus generated contracts under `contracts/` and `generated/`. Legacy door behavior is authoritative only below `products/legacy-door-percent/`.
|
|
|
|
|
|
|
|
-MRDIMM authority: `projects/prod2u-door-temp/project.json`, `projects/prod2u-door-temp/requirements.zh-CN.md`, `docs/prod2u-door-temp-protocol.zh-CN.md`.
|
|
|
|
|
-6400 authority: `projects/prod2u-6400-front-back/project.json`, `projects/prod2u-6400-front-back/requirements.zh-CN.md`, `docs/prod2u-6400-front-back-protocol.zh-CN.md`.
|
|
|
|
|
|
|
+## Collaboration and Git
|
|
|
|
|
|
|
|
-Generated artifacts, source closures, TD inputs, and packages are per-target. Do not mix closures or emit one bitstream for both products. Historical design documents are not active authority.
|
|
|
|
|
|
|
+- One main writer owns production changes. Temporary reviewers are read-only and their conclusions must be rechecked locally.
|
|
|
|
|
+- Never reset, clean, stash, restore, overwrite, or delete unknown changes.
|
|
|
|
|
+- Implement on `feature/*` or `fix/*`, integrate accepted work to clean `dev`, and leave `master` for QA promotion.
|
|
|
|
|
+- Keep production, tests, generated artifacts, and documentation reviewable in staged commits. Do not push without explicit authority.
|
|
|
|
|
+- Historical receipts are evidence inputs only. Current acceptance requires current Linux-run receipts bound to full commit and hashes.
|
|
|
|
|
|
|
|
-## Execution priorities
|
|
|
|
|
|
|
+## Hardware and clocking
|
|
|
|
|
|
|
|
-1. Core limit one-shot behavior and startup calibration (seek-close then measure-open) first.
|
|
|
|
|
-2. Keep behavior simple and deterministic inside the declared constraints.
|
|
|
|
|
-3. Form a minimally usable, synthesizable version quickly.
|
|
|
|
|
-4. Reduce LUT and Slice after core function is correct.
|
|
|
|
|
-5. Reduce LUT and Packed Slice after core function is correct.
|
|
|
|
|
-6. Generalization, security, exception coverage, compatibility, long-term maintenance, performance tuning, and perfect documentation are lower priority.
|
|
|
|
|
|
|
+- Target EF2L45BG256B at 25 MHz in one clock domain.
|
|
|
|
|
+- Do not instantiate a PLL, create a derived/gated clock, or treat a clock as data. Use enables and counters.
|
|
|
|
|
+- Pin, polarity, connector, and sensor mapping claims require the current board evidence chain. Unknown TTL and CT placement fields stay explicit; never guess a ball or permutation.
|
|
|
|
|
+- Do not access COM/JTAG, program hardware, install drivers, or claim physical validation. Hardware, JTAG, COM, and real thermal performance remain NOT RUN.
|
|
|
|
|
|
|
|
-"Reliable" means deterministic under these assumptions: host may send a new door percent while an axis is moving (latest-wins; at most one already-started STEP finishes); duty and door percent are 0..100; mid positions are open-loop estimates from gated STEP rises and startup-measured travel; no undeclared command queue; hardware wiring matches the current project/ADC.
|
|
|
|
|
|
|
+## 6400 structure
|
|
|
|
|
|
|
|
-## Model and effort policy
|
|
|
|
|
|
|
+- Four lanes of six DIMMs and zones 6+12+6; 24 PTC, four front fans, four rear fans, 27 CT values, and 24 BMC values.
|
|
|
|
|
+- All 24 channels are controlled/protected. The 18+6 split is modelling-only.
|
|
|
|
|
+- No door motor, limit, calibration, solenoid, fan FG, Host watchdog, MCU/SoC, or online learning in 6400 profiles.
|
|
|
|
|
+- Production has target/ACK/snapshot only. Identification alone adds finite stimulus; safety always overrides it.
|
|
|
|
|
+- Host disconnection never stops autonomous control.
|
|
|
|
|
|
|
|
-- `MODEL_POLICY=unconstrained`.
|
|
|
|
|
-- `REASONING_EFFORT_POLICY=unconstrained`.
|
|
|
|
|
-- `MODEL_OR_EFFORT_IS_ACCEPTANCE_GATE=false`.
|
|
|
|
|
|
|
+## Resource policy
|
|
|
|
|
|
|
|
-## Dynamic agent rules
|
|
|
|
|
|
|
+- Correct deterministic safety first, then reduce LUT and packed Slice. DSP/eRAM/DFF/cycles may increase when useful.
|
|
|
|
|
+- Share PI arithmetic, PWM comparison/carrier, safety comparison, lane statistics, Host parser/engine/CRC/TX, CT I2C, BMC parsing, snapshot streaming, and schedulers where deadlines permit.
|
|
|
|
|
+- Keep independent minimal Host and BMC RX frontends for concurrent input.
|
|
|
|
|
+- Prefer synchronous inferred RAM and pointer-flip banks. Isolate vendor primitives in wrappers.
|
|
|
|
|
+- Do not introduce AXI/Wishbone/APB, a crossbar, per-channel controller instances, per-channel PWM counters, or large FF copies.
|
|
|
|
|
|
|
|
-- No fixed sub-agent roster, fixed Team A/B/C/D, fixed agent count, agent registry, message bus, dedicated agent database, complex run-state, role definitions copied for every tool, or heavy JSON evidence.
|
|
|
|
|
-- The root `AGENTS.md` is the single long-term, tool-independent rule source.
|
|
|
|
|
-- Tool-specific rules (`.devin/`, `.cursor/`, `.codex/`, `.agents/`) are only kept if they are thin tool adapters that point here; they must not reproduce the full product contract or define a static team.
|
|
|
|
|
-- Sub-agents are created dynamically only for independent, temporary tasks and end when that task ends. Different writers never modify the same file or logic without coordination.
|
|
|
|
|
|
|
+## Tool and evidence boundary
|
|
|
|
|
|
|
|
-## Git and worktree rules
|
|
|
|
|
|
|
+- Linux-native `/root/workspaces/thermal-system` is the editable authority. Debian containers provide builds, tests, formal, TD, and packaging.
|
|
|
|
|
+- Shell entrypoints are thin; deterministic logic belongs in Python modules or build tools. PowerShell may only dispatch into WSL.
|
|
|
|
|
+- Use `td2026`; scope vendor library variables to its subprocess. Durable toolchains live on persistent volumes such as `/data/prod2u`.
|
|
|
|
|
+- Distinguish SOURCE, SIMULATION, FORMAL, TD SYNTHESIS, PLACE & ROUTE, BITSTREAM, HARDWARE, JTAG, COM, and THERMAL PERFORMANCE.
|
|
|
|
|
+- A fail, blocked, not-run, placeholder, or historical receipt is never PASS.
|
|
|
|
|
|
|
|
-- Do not reset, clean, stash, restore, overwrite, or delete changes from unknown sources.
|
|
|
|
|
-- Work directly on `dev` only when it is clean and no other session is touching the same files.
|
|
|
|
|
-- When `dev` is dirty or another session is active, use a temporary branch/worktree.
|
|
|
|
|
-- Temporary branches/worktrees are conflict-prevention measures, not a long-lived branch system.
|
|
|
|
|
-- All accepted production code, tests, and docs must end up in `dev`.
|
|
|
|
|
-- `master` is QA-promoted only. Do not modify, merge, or push `master` from ordinary implementation work.
|
|
|
|
|
-- The final state of every task is a clean `dev` working tree with accepted changes committed/merged.
|
|
|
|
|
-- Delete temporary branches/worktrees created for this task once they are no longer needed.
|
|
|
|
|
|
|
+## Acceptance
|
|
|
|
|
|
|
|
-## Product contract
|
|
|
|
|
-
|
|
|
|
|
-> **破坏性协议迁移(勿按旧上位机假设发帧)**
|
|
|
|
|
-> 旧合同:门字节 `00`=不启动 jog / 心跳,`01`=开 450 步,`02`=关 450 步;busy 忽略新门命令;watchdog 10 s → FAN 20;startup 关门寻限 + 未命中则 500 步 backoff。
|
|
|
|
|
-> **新合同**:门字节为闭合百分比 `00`=全开 … `64`=全关;合法 SET_ALL latest-wins;位置按 gated STEP 计数;标定先 seek-close 再 measure-open;watchdog **30 s → PTC 0 / FAN 10**;新增 `GET_MOTOR_STATUS 0x03` / `MOTOR_STATUS_DATA 0x83`(31 字节 payload)。无 ACK / 无命令队列。旧上位机若继续把三门填 `00` 当心跳,将驱动三轴核对并运行到**全开**限位。
|
|
|
|
|
-
|
|
|
|
|
-- UART: 25 MHz, 115200 8N1, 217 clocks/bit, A5 5A framing, CRC-16/CCITT-FALSE.
|
|
|
|
|
-- Supported frame types: `0x01 SET_ALL`, `0x02 GET_TEMPERATURE`, `0x03 GET_MOTOR_STATUS`, `0x82 TEMPERATURE_DATA`, `0x83 MOTOR_STATUS_DATA`.
|
|
|
|
|
-- SET_ALL payload: 4 FAN + 4 chamber PTC (each duplicated to 2 physical PTC PWM) + Z/X/Y door **percent** bytes (11 bytes total).
|
|
|
|
|
-- Door byte `0..100`: close-percent target (`0`=full open, `100`=full close). Values `101..255` reject the whole frame.
|
|
|
|
|
-- After `startup_complete`: each valid SET_ALL commits thermal + three axis requested percents atomically and feeds the watchdog (including identical repeats). Different percent → latest-wins replan.
|
|
|
|
|
-- PTC active high; FAN active low at FPGA output.
|
|
|
|
|
-- PWM ~20 Hz.
|
|
|
|
|
-- Watchdog 30 s -> PTC 0, FAN 10 (enabled only after `startup_complete`).
|
|
|
|
|
-- Motion: open-loop percent positioning from startup-measured `travel_steps`; mid targets use half-up clamp to `1..travel-1`; endpoints 0/100 complete only on real open/close limits. X, Y, and Z may overlap.
|
|
|
|
|
-- Motor EN: CON120.2 / C11, NPN invert at board; FPGA constant 1 (`permanent_high`).
|
|
|
|
|
-- No ACK, BUSY, ERROR, command queue, legacy jog compatibility, background temperature scan, or solenoid actuator.
|
|
|
|
|
-
|
|
|
|
|
-## 6400 target contract
|
|
|
|
|
-
|
|
|
|
|
-- Alias `6400`, `project_id` `prod2u-6400-front-back`. Independent top, closure, generated dir, ADC, and TD project.
|
|
|
|
|
-- Shared frame types only: `0x01 SET_ALL` (32-byte payload), `0x02 GET_TEMPERATURE`, `0x82 TEMPERATURE_DATA`. No `0x03` / `0x83`, no motors, no limits, no startup seek.
|
|
|
|
|
-- PWM 500 Hz / 50,000 clocks; watchdog 30 s / 60,000 ticks after POR; PTC 0 / FAN 10 on timeout.
|
|
|
|
|
-- Exhaust FAN PWM is CON64/66/62/60 pin 4 (C1→C4 left-to-right). Pin 3 FG is unused. Production TD syn/phy/bitgen is wired and the released bitstream is bound by SHA256. Hardware validation is `NOT RUN`.
|
|
|
|
|
-- Execute by target: `./fw generate|test|build|package mrdimm|6400`. Do not mix closures into one bitstream.
|
|
|
|
|
-
|
|
|
|
|
-## Limit and startup contract
|
|
|
|
|
-
|
|
|
|
|
-- Six limits (active high at FPGA, `runtime_use=true`):
|
|
|
|
|
- - X: LS CON12.1 A5, HS CON12.2 B6
|
|
|
|
|
- - Y: LS CON12.3 C8, HS CON12.4 A8
|
|
|
|
|
- - Z: LS CON129.1 K16, HS CON129.2 J15
|
|
|
|
|
-- Motors: X STEP/DIR CON104.2/3 C12/B12; Y CON105.2/3 L12/J11; Z CON106.2/3 L14/K14.
|
|
|
|
|
-- Runtime: direction-select limit hard-stop each clock; truncate current STEP high pulse immediately after synchronized limit (`truncate_current_high_pulse_immediately_after_synchronized_limit`). Ordinary command / watchdog / endpoint-guard stops do **not** truncate a high pulse; they forbid the next rise.
|
|
|
|
|
-- Startup calibration (once per power-on/reset/reconfig): PTC 0%, FAN 10%; **serial X→Y→Z** seek-close (≤5000 gated STEP) then measure-open (≤5000) per axis; `travel_steps` latched on success; **no** 500-step backoff. Failed axes FAULT-lock until reset; partial success allowed. Runtime X/Y/Z may overlap after `startup_complete` / profile ready.
|
|
|
|
|
-- `startup_complete` is sticky until next FPGA power-on, global hardware reset, or reconfiguration.
|
|
|
|
|
-- During calibration: valid SET_ALL may update FAN/PTC but **ignores** door percents (no cache); GET_MOTOR_STATUS allowed; GET_TEMPERATURE dropped (no response); watchdog not enabled/fed.
|
|
|
|
|
-- After `startup_complete`: host must re-send desired percents; ordinary percent motion and runtime limit policy apply; calibration FSM does not restart.
|
|
|
|
|
-
|
|
|
|
|
-## Tooling preference
|
|
|
|
|
-
|
|
|
|
|
-- Linux container is the authoritative execution environment for bootstrap, verification, TD, and packaging.
|
|
|
|
|
-- Prefer thin `tools/*.sh` entrypoints that call Python modules; do not use Windows PowerShell / `.ps1` as the production path.
|
|
|
|
|
-- Container-local package installs (apt/pip/npm) are allowed when reconstructing the toolchain; do not modify the host outside the container.
|
|
|
|
|
-- Temporary/run state uses Linux XDG paths (`$XDG_CACHE_HOME`, `$XDG_STATE_HOME`, `$XDG_RUNTIME_DIR`, `$TMPDIR`), never Windows `C:\...` or Downloads as authority.
|
|
|
|
|
-- Durable toolchains (OSS CAD Suite archive + extract, Anlogic TD) must live on persistent volumes such as `/data/prod2u/` (or `OSS_CAD_SUITE_ROOT` / `PRODU2_TOOLCHAIN_BASE`), not overlay `~/.cache` which disappears on container rebuild.
|
|
|
|
|
-- TD command is `td2026` (Anlogic TD 2026.1 SP2 Linux). Do not call `td603`, Windows `td_commands_prompt.exe`, or hard-code `C:\Anlogic\...`.
|
|
|
|
|
-- Keep TD `LD_LIBRARY_PATH` / vendor Qt vars confined to the TD subprocess; they break apt and other tools if exported globally.
|
|
|
|
|
-- Final acceptance evidence must be produced by the current Linux run; historical Windows receipts are historical only.
|
|
|
|
|
-- Prefer Python for cross-platform scripts and deterministic automation.
|
|
|
|
|
-
|
|
|
|
|
-## Necessary tests
|
|
|
|
|
-
|
|
|
|
|
-- Product, protocol, generator, packaging, and Git protection Python tests.
|
|
|
|
|
-- Icarus testbenches for the active Prod2U top, including startup seek-close/measure-open calibration and runtime limit hard-stop / latest-wins behavior.
|
|
|
|
|
-- Verilator lint, cocotb UART tests, and formal checks when the environment is available and cost is reasonable.
|
|
|
|
|
-
|
|
|
|
|
-## Evidence boundaries
|
|
|
|
|
-
|
|
|
|
|
-- Distinguish source, simulation, formal, TD, package, and physical-hardware evidence.
|
|
|
|
|
-- `fail`, `blocked`, `not_run`, placeholder, or exploratory evidence is never a pass.
|
|
|
|
|
-- Receipts bind run ID, exact full commit, project hash, source-manifest hash, command, tool version, status, and applicable bitstream hash.
|
|
|
|
|
-
|
|
|
|
|
-## Remote ChatGPT adviser usage
|
|
|
|
|
-
|
|
|
|
|
-- If a task provides an exact ChatGPT conversation URL, the local top-level Agent may use the existing Playwright MCP / Microsoft Edge session to open that URL and continue the conversation.
|
|
|
|
|
-- Upload only the current core/source package; do not create new sessions, use share links, switch browsers, use the API, or send sub-agents separately.
|
|
|
|
|
-- Use natural language; do not force JSON, fixed turn budgets, or short timeouts.
|
|
|
|
|
-- If Playwright MCP is unavailable, record the blocker and continue locally; the adviser is not a hard gate.
|
|
|
|
|
-
|
|
|
|
|
-## Protected operations
|
|
|
|
|
-
|
|
|
|
|
-- Never access COM or JTAG, program hardware, install drivers, or modify global PATH.
|
|
|
|
|
-- Do not create fixed ChatGPT Adviser plugins, ledgers, or sessions.
|
|
|
|
|
-- Hardware validation is `not_run` unless explicitly authorized in a future task.
|
|
|
|
|
|
|
+- Generate all RTL/Host/Python/docs mappings from one contract source.
|
|
|
|
|
+- Run contract/generator tests, lint, module simulation, cocotb, fuzz, formal, HTH/Lab integration, soak/fault seeding, TD synthesis/P&R/timing/bitstream, and clean replay when their toolchains are available.
|
|
|
|
|
+- Preserve Legacy as buildable and prevent its sources/contracts from entering 6400 source closure.
|