Explorar el Código

chore: freeze baseline and refactor operating rules

Codex Resource Selftest hace 4 meses
padre
commit
3eb23eb650

+ 31 - 58
AGENTS.md

@@ -1,69 +1,42 @@
-# CPLD Agent Instructions
+# CPLD UART Refactor Operating Rules
 
-本仓库只有一个生产 CPLD 工程:Prod2U Profile 4 Normal v3。
+This repository is the active `dev` branch for the Prod2U multi-project UART refactor.
 
-## 工程边界
+## Authority
 
-- 唯一生产顶层是 `src/top/prod2u_p4_normal_v3_top.v`。
-- 活 RTL 只放在 `src/rtl/`,活验证只放在 `tests/`、`tools/`、`td/`、`config/`、`constraints/`、`schemas/`。
-- `td/prod2u_p4_normal_v3.prj` 及同名 syn/phy/bitgen 脚本是唯一 TD 工程入口。
-- `reference/original/**`、`receipts/**` 和用户 `.planning/` 不得纳入当前构建证据。仅允许在明确的非生产资产治理提交中更新原始资料清单或本地忽略资产,且必须证明生产构建输入未变化。
-- `td/build/`、`tmp/`、bit/bid/data/log/timing/area 和工具运行目录均为生成物,不得提交。
-- 当前是临时快速开发:优先最小、可用、易验证的逻辑,不为低概率边界增加缓存、锁或复杂恢复。
-- 未回答的需求或边界问题必须再次询问,不得自行采用默认值;Git 暂存和提交只由单一协调者执行。
+- `CPLD_多项目_UART协议_项目适配_Codex并行Harness_详细设计_v1.0.md` is the design authority.
+- `BASELINE_REPORT.md` records the frozen 1920ab3e source/tag and 7c5918ac bitstream baseline.
+- `projects/<project_id>/project.json` is the only machine configuration source.
+- Hardware facts must match the selected baseline package, current production constraints, and TD project. Conflicts are blockers.
 
-## 资产治理
+## Protocol
 
-- 板卡查看器、分析/交接打包器和只读磁盘审计工具属于非生产辅助能力,不得成为新的 RTL、TD 或固件入口。
-- 历史协议资料只放在 `reference/historical/`,必须明确绑定旧提交或旧包,不得作为当前 `1920ab3e` 协议合同。
-- 原始 `.brd`、厂商资料、license 和私有压缩包只在 `reference/original/` 本地保留并由 `.gitignore` 排除;Git 只提交路径、用途和 SHA-256 清单。
-- C 盘审计工具只允许读取并输出 JSON 清单,不得提供删除、移动、改名、Git 引用修改或硬件操作入口。
+- UART is fixed at 115200 8N1, no flow control, 25 MHz, 217 clocks per bit.
+- Frames are `A5 5A type payload_length payload crc16_le`.
+- CRC is CRC-16/CCITT-FALSE over type, length, and payload only.
+- The only supported types are `0x01 SET_ALL`, `0x02 GET_TEMPERATURE`, and `0x82 TEMPERATURE_DATA`.
+- Do not restore Binary921, 921600, ACK, ERROR, BUSY, JOG, STOP, watchdog, replay, pagination, limits, or runtime project discovery.
 
-## 功能合同
+## Safety and evidence
 
-- 保留 24 路 PTC、4 路 FAN、solenoid、UART 和 X/Y 电机;LS1/LS2 仅保留物理引脚,Z 只保留协议位置。
-- binary921-v3 输入 envelope、Profile ID 4、50 字节输出 snapshot 和 10 字节 MOTION_STATUS 保持兼容。
-- X/Y 固定 `DIR=0` 打开、`DIR=1` 关闭,使用独立执行器并允许同时运动。
-- 只有 `0x35 JOG` 驱动电机。Snapshot 的 X/Y/Z 字节保持线格式兼容、允许任意 `u8`,但完全忽略且无电机作用;旧标准 OPEN/CLOSE CLI 仅发送这些无作用字段。
-- JOG 步数字段策略为 `RAW_U16_TRUSTED_HOST_NO_CPLD_CAP`:CPLD 不检查、钳位或修正原始 16 位 `steps`;上位机构造器负责只发送 `1..65535`。`speed_code=0..3` 仅校验,执行时忽略并统一固定 1000 step/s;非法 axis/方向/速度/保留字段在普通槽可用时返回 BAD_VALUE。
-- RX 快速路径策略为 `RX_FAST_JOG_BYPASSES_NORMAL_REQUEST_SLOT`:完整、CRC 正确且字段合法的 JOG 不进入普通请求槽,普通槽挂起、core 非 IDLE、旧响应或 TX 停顿都不能延迟运动启动;槽满时新的非快速完整帧静默丢弃。
-- JOG ACK 仅在首个实际 STEP 上升沿已经发出后返回。同轴新 JOG 立即将旧 STEP 拉低、丢弃旧剩余步数并重新等待完整 1 ms DIR setup;旧脉冲允许被截短。
-- JOG 忽略限位;同轴新 JOG 直接替换旧命令,不保留待处理队列。
-- 上位机规则为 `HOST_MUST_NOT_REPEAT_SAME_AXIS_BEFORE_COMPLETION`,完成由上位机计时;违规重发采用 `LATEST_COMMAND_WINS_OLD_ACK_NOT_GUARANTEED`。下位机完成事件为 `NONE_HOST_TRACKS_TIME`,只保留一个快速 ACK 记录。
-- `busy_mask`、`fault_mask` 和 `position_valid_mask` 是恒为 0 的只读遥测,current/target 恒为 `0xFF`,EN active 恒为 1。
-- LS1/LS2 不接入同步、滤波、状态机或任何运动判断。JOG 不 arm/refresh watchdog;DISABLE 和 watchdog 只把 PTC/FAN/solenoid 置安全值,不停止电机。电机只会因复位、断电或重新配置停止。
-- 合法 JOG 无需先发送 DISABLE;GET_STATUS 和 GET_MOTOR_STATUS 都不能复活、暂停或停止电机运动。
-- X/LS1 绑定 B9,Y/LS2 绑定 A11;`0V=未触发`、`3.3V=关闭端触发`,A5 不得分配。
-- MARK_CLOSED、方向学习、距离模型、恢复步数、永久锁定和运行中反向均不属于当前产品。
-- 生产响应为普通命令 HOST_ACK;GET_MOTOR_STATUS 为 ACK 后紧跟 MOTION_STATUS。
-- 对外版本只使用 8 位小写 Git commit。刷机包名同时绑定 8 位 commit 和 bitstream SHA-256 前 16 位。
+- Never call ChatGPT Adviser or create Adviser artifacts.
+- Never open COM/JTAG, program hardware, install drivers, or modify global PATH.
+- Distinguish source, offline simulation, formal, TD, package, and physical hardware evidence.
+- A blocked, dry-run, fixture, or partial receipt is not a pass.
+- Preserve ignored generated evidence unless the user explicitly requests its removal.
 
-## 验证边界
+## Ownership
 
-- 离线 gate 覆盖源码完整性、协议、模型、RTL、formal、CDC、STA、TD、资源和包自检。
-- TD 结构要求 BRAM/DSP 数量可解析、`IO=43`、正 setup/hold、非空 bitstream、UART 与温度 I2C 共 6 个 CDC 同步寄存器、3 个首级 endpoint,以及 X/Y 两位顺序 `motion_phase`。
-- 资源候选先比较 post-route LE,再比较 LUT;FF、BRAM 和 DSP 数量不作为惩罚项。
-- strict offline、两次 TD、打包自检和 final gate 必须显式绑定同一个 32 位小写十六进制 `verification_run_id`;包内验证 receipt 不得来自其他批次。
-- normal dual-TD 的两次构建必须使用不同仓外 work-root 和不同 TD `run_id`,但 synthesis manifest、synthesis input hash 和 bitstream SHA-256 必须完全相同。
-- 总 LUT/FF/slice 差值仅为 advisory,不得改变 bitgen 状态。
-- Windows 运行 Verilator 前使用 `tools/activate_verification_toolchain.ps1` 或仓库 resolver,不得修改全局 PATH。
-- blocked、fail、dry-run、fixture 或缺少证据均不等于 pass;离线通过不等于实板机械验收。只要 TD 已产生非空 bitstream,验证失败不得阻止临时镜像打包,但必须原样随包记录。
+- Each temporary agent worktree owns an exclusive path set.
+- Only the coordinator integrates commits into `dev` and modifies the production top.
+- Tests do not modify production RTL.
+- Common UART/CRC/frame modules do not know project channel counts or pins.
+- Project modules do not parse UART bytes directly.
 
-## 硬件边界
+## Delivery
 
-- 禁止 Flash、驱动安装/重装、真实 PTC 加热、温度实验和 Z 轴运动。
-- 本仓库默认只生成和验证刷机包,不打开 COM5/JTAG,不执行编程。
-- 明确授权的板测最多一次 `PROGRAM_SRAM @ 200 kHz`,异常不得自动重试;编程后立即发送 DISABLE。
-- JOG 完全无机械保护且单条可执行 65535 步;DISABLE、watchdog 和限位均不能停电机。任何异常必须立即断电或复位/重新配置。
-
-## 安全边界
-
-- 禁止 flash、驱动安装/重装、真实 PTC/fan/BMC 未受控动作。
-- 任何出现 `PROGRAM_FLASH`、`ERASE_FLASH`、`PROGRAM_SPIBIN`、`DIRECT_FLASH_WRITE` 或真实热闭环动作的路径必须 fail closed。
-- `uart-preflight` 只能枚举串口,禁止打开未知 COM 口或切换 DTR/RTS;本轮资产工具和审计工具不得连接串口、JTAG 或硬件。
-- `uart-board-sram-test` 类 receipt 只允许 `PROGRAM_SRAM`,必须记录 bitstream hash、串口 transcript hash、debug UART 事件流、register dump 和 counterparty。
-
-## 资产更新要求
-
-- 新增真实板级 PID、flash、驱动、外部仪器或生产硬件动作时,必须同时新增独立 gate、receipt schema、rollback/安全边界和中文 runbook。
-- 板卡查看器、handoff/analysis 打包器和 C 盘审计 CLI 只能读文件并输出验证结果,不得成为生产构建入口或提供自动删除入口。
+- Every run uses one 32-character lowercase `run_id`.
+- Receipts bind run ID, commit, project configuration SHA-256, and bitstream SHA-256.
+- Generate an `UNVERIFIED` package immediately after a non-empty TD bitstream.
+- Promote the same bitstream to `VERIFIED` only after all applicable tests pass.
+- Do not delete the old production RTL until the new top produces a non-empty bitstream.

+ 77 - 0
BASELINE_REPORT.md

@@ -0,0 +1,77 @@
+# Prod2U CPLD 重构基线报告
+
+## 基线身份
+
+- Run ID: `3d8b6fec3bc44ad1a9ac73930c201107`
+- Reported at UTC: `2026-07-24T01:28:56.0438125Z`
+- Active branch before cleanup: `dev`
+- Active workspace commit before cleanup: `2980a4febeac8f59b476cd015dd50da33125bb44`
+- Selected working baseline commit: `1920ab3e33d1e50553ac8132698220bee65b4730`
+- Existing source tag: `p4-normal-1920ab3e-7c5918ac-rc1`
+- Planned archive tag: `archive/p4-normal-1920ab3e-7c5918ac`
+
+## Working bitstream
+
+- Package root: `C:\Users\Administrator\CodexTemp\p4-normal-images\1920ab3e\prod2u-p4-normal-1920ab3e-7c5918ac0d76556f`
+- Bitstream: `fw.bit`
+- Size: `162762` bytes
+- SHA-256: `7c5918ac0d76556f374e332b6ecf2e3c9c6b99b03e332dee45075cd349fa2c1c`
+- Package info SHA-256: `fde8502789c0d74dd79a4ef406d42d1cb27916e22b407402f85d36bd038ccd77`
+- Package verification run: `ff53c568d2034c86b822c6733706fc7d`
+- Package mode: `urgent_single_td`
+- Package metadata: `verification_complete=false`, `confirmation_td_present=false`
+
+The user reports that this baseline was manually verified. The package metadata and receipts do not establish final hardware acceptance, confirmation TD, Flash programming, or thermal qualification; those claims remain excluded from this report.
+
+## Hardware facts retained for migration
+
+- Device: `EF2L45BG256B`, 25 MHz clock on `J1`.
+- Host UART: RX `N11`, TX `M10`.
+- Temperature I2C: SCL `M8`, SDA `N9`.
+- CT7428 addresses: `0x49`, `0x48`, `0x4B`; registers `0..8` per device.
+- Inlet/X motor: STEP `C11`, DIR `B12`.
+- Outlet/Y motor: STEP `D15`, DIR `H14`.
+- Shared motor enable: `A10`, constant low enabled.
+- Z pins retained as reserved outputs: STEP `H12`, DIR `F14`, driven constant zero.
+- LS1/LS2 pads retained without synchronization or motion logic: `B9`, `A11`.
+- Solenoid pad retained at `P5` with the new safe non-action constant.
+
+All remaining PTC/FAN polarity, I2C transaction order, byte order, and temperature conversion details must match the selected baseline source and current TD constraints. Conflicts are blockers, not guesses.
+
+## Baseline artifact hashes
+
+| Artifact | SHA-256 |
+|---|---|
+| `fw.bit` | `7c5918ac0d76556f374e332b6ecf2e3c9c6b99b03e332dee45075cd349fa2c1c` |
+| `package-info.json` | `fde8502789c0d74dd79a4ef406d42d1cb27916e22b407402f85d36bd038ccd77` |
+| `config/prod2u_p4_normal_v3_hw_binding.json` | `04361389313289f74b7feada4623372b9a45e17c95dd4b1b097d97d731888862` |
+| `config/prod2u_p4_verification_targets_v1.json` | `c7eb8fc466b7c4e7bff9c9d293229e4a16b02666c826d0e4d08c7055a8c1dd51` |
+| `evidence/td-primary-receipt.json` | `ab3db15396d3ee0eafd4e373ae6b9d43c0bccf24a6c8d0f949c3446e054c3700` |
+| `evidence/validation-summary.json` | `4680bc160d1ca5ed56c4de9d672482cf841a71dad326e9030c0101026e3682da` |
+| `evidence/package-selftest-result.json` | `a9d6a6e2094207be57864b6b113e48ec82b6518305f4aee0863e26e3ec58cc4b` |
+| `evidence/td-primary/syn_qor.qor` | `1fdbc3aa1dc1232fdd9b7e130d3becddde61d8a2049a696dd37680d3ece4028c` |
+| `evidence/td-primary/phy_area.area` | `f3aeb4c711fa73c8b7f583ec8f50b85e3dc704ea4be91fa324f2eeee840f3bc6` |
+| `evidence/td-primary/timing.timing` | `75654aa6a38c015993fdbfc5d30d0cb2a2bc83b3b4ef33d2e322e99e68357368` |
+| `evidence/td-primary/phy_cdc.rpt` | `bbd665cea788c0fc364e382b357bc7e6330bff2774d14e42cd63b1f10eedbecc` |
+
+## Prior TD resource reference
+
+- IO: `43`
+- Synthesis registers: `1743`
+- Synthesis LUTs: `1936`
+- Synthesis slices: `104`
+- Synthesis RAMs: `1`
+- Synthesis DSPs: `0`
+- Setup WNS: `28018` ps
+- Setup TNS: `0`
+- Async registers reported: `6`
+
+These are historical comparison values only. They are not the new architecture's acceptance result.
+
+## Cleanup boundary
+
+- Preserve the authoritative detailed design file.
+- Restore all other tracked working-tree modifications.
+- Remove other untracked candidate and Adviser files.
+- Do not delete ignored generated evidence during cleanup.
+- Do not open hardware interfaces or modify global tooling.

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 2684 - 0
CPLD_多项目_UART协议_项目适配_Codex并行Harness_详细设计_v1.0.md


+ 5 - 0
projects/AGENTS.md

@@ -0,0 +1,5 @@
+# Project Configuration Rules
+
+- Keep one `project.json` and one human requirements document per project.
+- Do not duplicate counts, pins, addresses, or protocol lengths in hand-written tools or tests.
+- Validate configuration before generating RTL, TD, host contracts, and golden vectors.

+ 8 - 0
src/common/AGENTS.md

@@ -0,0 +1,8 @@
+# Common RTL Rules
+
+- Verilog-2001 compatible.
+- UART RX/TX handle byte timing only.
+- CRC is serial and independent in RX and TX paths.
+- Frame RX/TX handle framing, lengths, payload RAM access, and CRC only.
+- No project counts, pins, motor semantics, temperature semantics, or legacy protocol behavior.
+- Use explicit valid/ready or one-cycle event contracts; no hidden queues.

+ 7 - 0
src/modules/AGENTS.md

@@ -0,0 +1,7 @@
+# Shared Module Rules
+
+- Modules implement reusable hardware resources only.
+- Use one shared PWM comparator path, one motor executor, one I2C reader, and RAM-backed storage.
+- No UART frame parsing.
+- No runtime project identification.
+- Keep reset defaults inactive and preserve reserved outputs at their defined constants.

+ 7 - 0
src/project/AGENTS.md

@@ -0,0 +1,7 @@
+# Project Adapter Rules
+
+- Project-specific counts and offsets come only from generated configuration.
+- Validate SET_ALL length and direction values before any target RAM write.
+- SET_ALL never emits a response.
+- GET_TEMPERATURE is accepted only while idle and produces exactly one temperature response after 27 reads.
+- Busy and invalid commands are silent drops.

+ 6 - 0
td/AGENTS.md

@@ -0,0 +1,6 @@
+# TD Rules
+
+- The generated project source manifest is the only active TD source list.
+- Record synthesis, place/route, timing, CDC, IO, resource, and bitstream evidence.
+- TD scripts must never contain programming or cable commands.
+- Keep production and verification work roots separate when producing independent receipts.

+ 7 - 0
tests/AGENTS.md

@@ -0,0 +1,7 @@
+# Test Rules
+
+- Tests target the new protocol and current project configuration only.
+- Test agents do not modify production RTL.
+- Cover positive, boundary, invalid, busy, timeout, and failure-continuation behavior.
+- Hardware access is forbidden; simulations use virtual UART/I2C/PWM/motor models.
+- Keep receipt status fail-closed and mark unavailable layers blocked or not_run.

+ 7 - 0
tools/AGENTS.md

@@ -0,0 +1,7 @@
+# Tool Rules
+
+- Tools are offline by default and must not access COM/JTAG or program hardware.
+- Do not install system components or alter global PATH.
+- Build, test, package, and receipt commands must bind run ID, commit, project hash, and output hashes.
+- Missing toolchains produce blocked evidence rather than a fabricated pass.
+- No ChatGPT Adviser integration or credentials/configuration is allowed.