Prod2U CPLD Operating Rules
This checkout implements the Prod2U door-temperature controller. The active product contract is projects/prod2u-door-temp/project.json, projects/prod2u-door-temp/requirements.zh-CN.md, and docs/prod2u-door-temp-protocol.zh-CN.md. Generated contracts, constraints, source manifests, tests, TD inputs, and packages must derive from that contract.
Current authority is limited to the above contract files, this AGENTS.md, and generated artifacts. Historical design documents are not active authority.
Execution priorities
- Core limit one-shot behavior and startup close/seek first.
- Keep behavior simple and deterministic inside the declared constraints.
- Form a minimally usable, synthesizable version quickly.
- Reduce LUT and Slice after core function is correct.
- Reduce LUT and Packed Slice after core function is correct.
- Generalization, security, exception coverage, compatibility, long-term maintenance, performance tuning, and perfect documentation are lower priority.
"Reliable" means deterministic under these assumptions: host obeys command order; no new command is sent while a motor is running; duty is 0..100; motor command is 00/01/02; no undeclared concurrency; hardware wiring matches the current project/ADC.
Model and effort policy
MODEL_POLICY=unconstrained.
REASONING_EFFORT_POLICY=unconstrained.
MODEL_OR_EFFORT_IS_ACCEPTANCE_GATE=false.
Dynamic agent rules
- 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.
Git and worktree rules
- 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.
- 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.
Product contract
- UART: 25 MHz, 115200 8N1, 217 clocks/bit, A5 5A framing, CRC-16/CCITT-FALSE.
- Supported frame types:
0x01 SET_ALL, 0x02 GET_TEMPERATURE, 0x82 TEMPERATURE_DATA.
- SET_ALL payload: 4 FAN + 4 chamber PTC (each duplicated to 2 physical PTC PWM) + Z/X/Y door bytes (11 bytes total).
- Door byte
00: no new jog; while busy, ignore (does not stop or override running motion). 01 open / 02 close.
- PTC active high; FAN active low at FPGA output.
- PWM ~20 Hz.
- Watchdog 10 s -> PTC 0, FAN 20.
- Ordinary motor move: 450 steps at 1000 steps/s. 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, preemption, legacy protocol compatibility, background temperature scan, or solenoid actuator.
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); busy ignores new start.
- Startup (once per power-on/reset/reconfig): PTC 0%, FAN 10%, all axes DIR=1 close; up to 5000 steps @ 1000 steps/s per axis; if limit not hit, 500-step backoff and mark missed; X/Y/Z may move concurrently and stop independently.
startup_done is sticky until next FPGA power-on, global hardware reset, or reconfiguration.
- After
startup_done: startup motor controls idle; ordinary host jog and runtime limit policy apply; limit FSM does not restart.
- During
startup_done == 0: SET_ALL and GET_TEMPERATURE are dropped; no caching, no response, watchdog is not fed; frame parser stays reset/flushed.
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 close/seek and runtime limit hard-stop 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.