Four-person daily workspace.yaml and ws commands (v0.2.0)
|
|
hai 4 meses | |
|---|---|---|
| config | hai 4 meses | |
| constraints | hai 4 meses | |
| docs | hai 4 meses | |
| receipts | hai 4 meses | |
| reference | hai 5 meses | |
| requirements | hai 4 meses | |
| schemas | hai 4 meses | |
| src | hai 4 meses | |
| td | hai 4 meses | |
| tests | hai 4 meses | |
| tools | hai 4 meses | |
| .gitattributes | hai 4 meses | |
| .gitignore | hai 4 meses | |
| AGENTS.md | hai 4 meses | |
| README.zh-CN.md | hai 4 meses |
本仓库是单一生产顶层 CPLD 工程,入口固定为:
src/top/prod2u_p4_normal_v3_top.vtd/prod2u_p4_normal_v3.prjconstraints/prod2u_p4_normal_v3.adc、constraints/prod2u_p4_normal_v3.sdcconfig/prod2u_p4_normal_host_contract_v4.jsonschemas/prod2u_p4_normal_host_contract_v4.schema.jsonCPLD 只执行主机提交的 PTC/FAN 输出,不提供本地热闭环或热保护。协议保留 PTC 0-100% 主机直控能力,但现场 gate 禁止 PTC 加热并要求负载隔离。生产 Trace 是主动数据面,因此旧版 v3 host 不兼容;host 必须按 v4 contract 持续解析 Trace、ACK 和 follow-up。
0 V 表示打开端、限位无效,3.3 V 表示关闭端、限位有效。X/Y 命令和运动资格逐轴独立;一轴的未确认方向学习不得把另一空闲轴伪报为 BUSY。LS1/X:CON30.3 -> FAN_GPIO3 -> R662 -> BANK0_GPIO3 -> B9 和 LS2/Y:CON12.3 -> FAN_GPIO1 -> R660 -> BANK0_GPIO1 -> A11。A5 必须保持未分配;不满足该映射的旧位流不得用于限位保护或运动验证。limit_ready=1 且 guard/fast/active 全低时才可接受。另一轴开始驱动或同轴反向时,旧的未确认学习资格被取消,但相应命令仍按本轴状态判定;取消优先于随后到达的限位确认,限位仍可停步但不能据此学习 DIR。LOCKED_FAULT。离开 CLOSED 后的限位释放预算按完整步周期跨 JOG 和换速累计 4000 ms。distance-valid 且未 distance-saturated 时,标准 CLOSE 使用可信距离;距离无效时执行一次 3200 步有界 homing;距离饱和时拒绝标准 CLOSE,只允许受监管的关向 JOG 寻找限位。29 00 00 00 返回 UNSUPPORTED_IN_PROFILE=0x01,只产生 COMMAND_RESULT/HOST_ACK,不改变输出、轴状态、DISABLE 或 watchdog,也不 arm/refresh watchdog。最终集成后的统一入口为 tools/prod2u_p4_harness.py。下列顺序从已经创建、工作树 clean,且已完成同一 C1 真实四次 RX-BRAM A/B decision 的单一 bugfix commit C1 开始;先从 C1 在仓外重建只逆转 8 个资源优化 RTL 的 clean U clone,并生成 canonical patch、完整 Git bundle 和 8 项行为等价 aggregate。baseline A/B(U-A/U-B)测量 pre-optimization baseline,amend 后的最终提交再执行 O-A/O-B。同一个固定 PROD2U_P4_BUILD_EPOCH 和 VerificationRunId 必须来自该 decision,并贯穿 U-A/U-B、最终离线 gate、O-A/O-B 和交付包;baseline 写入版本化配置后只 amend 当前提交,因此最终历史只保留一笔 bugfix commit:
Set-Location 'C:\Users\Administrator\CodexTemp\p4-normal-actuator-temp-921600-from-831'
$EvidenceRoot = 'C:\Users\Administrator\CodexTemp\p4-normal-v3-final-evidence'
$PackageRoot = 'C:\Users\Administrator\CodexTemp\p4-normal-v3-final-package'
$BaselineRoot = 'C:\Users\Administrator\CodexTemp\p4-normal-v3-resource-baseline'
$UCloneRoot = 'C:\Users\Administrator\CodexTemp\p4-normal-v3-trace-only-u'
$LineageRoot = 'C:\Users\Administrator\CodexTemp\p4-normal-v3-resource-lineage'
$ReversalPatch = 'C:\Users\Administrator\CodexTemp\p4-normal-v3-trace-only-preoptimization.patch'
$ReconstructionPatch = Join-Path $LineageRoot 'trace-only-preoptimization.patch'
$ReconstructionBundle = Join-Path $LineageRoot 'trace-only-preoptimization.bundle'
$BehaviorReceipt = Join-Path $LineageRoot 'behavior-equivalence.json'
$ProducerReceipt = Join-Path $EvidenceRoot 'resource-baseline-producer-receipt.json'
$RxBramDecisionReceipt = 'C:\Users\Administrator\CodexTemp\p4-normal-v3-rx-ab\decision.json'
$BaselineConfig = 'config/prod2u_p4_normal_v3_resource_baseline.json'
$WheelhouseRoot = '<validated wheelhouse directory>'
if (-not (Test-Path -LiteralPath $RxBramDecisionReceipt -PathType Leaf)) { throw '必须先完成当前 C1 的真实四次 RX-BRAM A/B 与 decision' }
$RxDecision = Get-Content -LiteralPath $RxBramDecisionReceipt -Raw -Encoding UTF8 | ConvertFrom-Json
$RxStorageVariant = [string]$RxDecision.selection.rx_storage_variant
$VerificationRunId = [string]$RxDecision.verification_run_id
$env:PROD2U_P4_BUILD_EPOCH = ([uint32]$RxDecision.build_epoch_utc).ToString()
try {
if (git status --porcelain) { throw 'bugfix commit 后工作树必须 clean' }
if (@(git diff --cached --name-only).Count -ne 0) { throw 'C1 暂存区必须为空' }
$C1Commit = (git rev-parse HEAD).Trim().ToLowerInvariant()
if (-not (Test-Path -LiteralPath $ReversalPatch -PathType Leaf)) { throw "仓外 input patch 不存在:$ReversalPatch" }
if (((Get-Item -LiteralPath $ReversalPatch).Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { throw '仓外 input patch 禁止使用 reparse point' }
foreach ($FreshPath in @($EvidenceRoot, $PackageRoot, $BaselineRoot, $UCloneRoot, $LineageRoot)) {
if (Test-Path -LiteralPath $FreshPath) { throw "必须使用不存在的新路径:$FreshPath" }
}
New-Item -ItemType Directory -Force -Path $EvidenceRoot, $BaselineRoot, $PackageRoot | Out-Null
# 从 clean C1 一次性生成 U 单父提交、canonical patch、U-only bundle、3 项差分、U Verilator、7 项 formal、10 proof aggregate 和可重放 audit。
python tools\prod2u_p4_harness.py resource-baseline-produce --final-root (Get-Location).Path --baseline-root $UCloneRoot --evidence-root $LineageRoot --reversal-patch "$ReversalPatch" --build-epoch ([uint32]$env:PROD2U_P4_BUILD_EPOCH) --json --report-file $ProducerReceipt
if ($LASTEXITCODE -ne 0) { throw 'U lineage production failed' }
# U-A/U-B:同一 clean U commit、同一 BUILD_EPOCH、不同 work-root;lineage artifact 只能来自上面的 producer。
Push-Location $UCloneRoot
try {
python tools\prod2u_p4_harness.py td-build --run --baseline-measurement --top prod2u_p4_normal_v3 --work-root "$BaselineRoot\u-a" --verification-run-id $VerificationRunId --reconstruction-patch "$ReconstructionPatch" --reconstruction-bundle "$ReconstructionBundle" --behavior-equivalence-receipt "$BehaviorReceipt" --json --report-file "$BaselineRoot\u-a.json"
if ($LASTEXITCODE -ne 0) { throw 'first clean TD baseline build failed' }
python tools\prod2u_p4_harness.py td-build --run --baseline-measurement --top prod2u_p4_normal_v3 --work-root "$BaselineRoot\u-b" --verification-run-id $VerificationRunId --reconstruction-patch "$ReconstructionPatch" --reconstruction-bundle "$ReconstructionBundle" --behavior-equivalence-receipt "$BehaviorReceipt" --json --report-file "$BaselineRoot\u-b.json"
if ($LASTEXITCODE -ne 0) { throw 'second clean TD baseline build failed' }
}
finally { Pop-Location }
Set-Location 'C:\Users\Administrator\CodexTemp\p4-normal-actuator-temp-921600-from-831'
python tools\prod2u_p4_resource_policy.py baseline --td-receipt "$BaselineRoot\u-a.json" --td-receipt "$BaselineRoot\u-b.json" --producer-receipt "$ProducerReceipt" --report-file $BaselineConfig
if ($LASTEXITCODE -ne 0) { throw 'resource baseline generation failed' }
if ((git rev-parse HEAD).Trim().ToLowerInvariant() -ne $C1Commit) { throw 'U 构建期间 C1 HEAD 发生变化' }
if (@(git diff --cached --name-only).Count -ne 0) { throw 'baseline amend 前暂存区必须为空' }
$ChangedPaths = @(git status --porcelain=v1 -uall | ForEach-Object { $_.Substring(3).Replace('\', '/') })
if ($ChangedPaths.Count -ne 1 -or $ChangedPaths[0] -ne $BaselineConfig) { throw 'baseline amend 前只允许 baseline 配置变化' }
git add -- $BaselineConfig
$StagedPaths = @(git diff --cached --name-only)
if ($StagedPaths.Count -ne 1 -or $StagedPaths[0] -ne $BaselineConfig) { throw 'baseline amend 暂存范围异常' }
if (@(git diff --name-only).Count -ne 0) { throw 'baseline amend 前存在未暂存变化' }
git diff --cached --check
if ($LASTEXITCODE -ne 0) { throw 'baseline staged diff check failed' }
git commit --amend --no-edit
if ($LASTEXITCODE -ne 0 -or (git status --porcelain)) { throw 'single bugfix commit amend failed' }
$FinalCommit = (git rev-parse HEAD).Trim().ToLowerInvariant()
$AmendedPaths = @(git diff --name-only $C1Commit $FinalCommit)
if ($AmendedPaths.Count -ne 1 -or $AmendedPaths[0] -ne $BaselineConfig) { throw 'C1 到最终提交只允许 baseline 配置变化' }
python tools\prod2u_p4_harness.py p4-normal-v3-strict-offline-gate --work-root "$EvidenceRoot\offline" --verification-run-id $VerificationRunId --json --report-file "$EvidenceRoot\offline-receipt.json"
if ($LASTEXITCODE -ne 0) { throw 'final offline gate failed' }
# O-A/O-B:amend 后同一 clean final commit、同一 BUILD_EPOCH、不同 work-root。
python tools\prod2u_p4_harness.py td-build --run --top prod2u_p4_normal_v3 --work-root "$EvidenceRoot\o-a" --verification-run-id $VerificationRunId --rx-storage-variant $RxStorageVariant --rx-bram-decision-receipt $RxBramDecisionReceipt --json --report-file "$EvidenceRoot\o-a-receipt.json"
if ($LASTEXITCODE -ne 0) { throw 'first optimized TD build failed' }
python tools\prod2u_p4_harness.py td-build --run --top prod2u_p4_normal_v3 --work-root "$EvidenceRoot\o-b" --verification-run-id $VerificationRunId --rx-storage-variant $RxStorageVariant --rx-bram-decision-receipt $RxBramDecisionReceipt --json --report-file "$EvidenceRoot\o-b-receipt.json"
if ($LASTEXITCODE -ne 0) { throw 'optimized confirmation TD build failed' }
$TdReceipt = Get-Content "$EvidenceRoot\o-a-receipt.json" -Raw -Encoding UTF8 | ConvertFrom-Json
$PackageOutput = & powershell.exe -NoProfile -ExecutionPolicy Bypass -File tools\package_prod2u_p4_normal_v3.ps1 -OutputDir $PackageRoot -NormalBitstream ([string]$TdReceipt.bitstream.path) -TdReceipt "$EvidenceRoot\o-a-receipt.json" -BuildEpoch ([long]$env:PROD2U_P4_BUILD_EPOCH) -Commit $FinalCommit -WheelhouseRoot $WheelhouseRoot
if ($LASTEXITCODE -ne 0) { throw 'package generation failed' }
$PackageDir = [string](($PackageOutput -join "`n") | ConvertFrom-Json).package
python tools\prod2u_p4_harness.py package-selftest --package-dir $PackageDir --verification-run-id $VerificationRunId --json --report-file "$EvidenceRoot\package-receipt.json"
if ($LASTEXITCODE -ne 0) { throw 'package selftest failed' }
python tools\prod2u_p4_harness.py p4-normal-v3-final-gate --offline-receipt "$EvidenceRoot\offline-receipt.json" --td-receipt "$EvidenceRoot\o-a-receipt.json" --confirmation-td-receipt "$EvidenceRoot\o-b-receipt.json" --package-receipt "$EvidenceRoot\package-receipt.json" --rx-bram-decision-receipt $RxBramDecisionReceipt --baseline-td-receipt "$BaselineRoot\u-a.json" --baseline-td-receipt "$BaselineRoot\u-b.json" --reconstruction-patch "$ReconstructionPatch" --reconstruction-bundle "$ReconstructionBundle" --behavior-equivalence-receipt "$BehaviorReceipt" --verification-run-id $VerificationRunId --json --report-file "$EvidenceRoot\final-receipt.json"
if ($LASTEXITCODE -ne 0) { throw 'final gate failed' }
}
finally {
Remove-Item Env:PROD2U_P4_BUILD_EPOCH -ErrorAction SilentlyContinue
}
resource-baseline-produce 的 input patch 必须由 --reversal-patch 显式提供,并位于仓外、非 reparse、非空且只修改版本化 manifest 声明的 8 个 RTL。最终 gate 不只读取两份 baseline receipt 摘要,还会重新打开、重算 SHA-256 并重解析其中绑定的 12 个 TD measurement artifact;任一原始 syn/phy area、timing 或相关测量文件被替换都会失败。
U clone、input patch、canonical patch、bundle、producer evidence、10 proof、TD 输出、bitstream、package 和 final receipt 全部留在仓外。Git 只保存 measured baseline 配置和用于验证这些外部证据的代码,不保存 lineage patch、构建目录或交付 receipt。
两项 baseline TD receipt 固定对应 U-A/U-B,主 TD 与 confirmation TD receipt 固定对应 O-A/O-B。U lineage 只能由 resource-baseline-produce 生成,禁止手工 clone、手写 SHA、fixture aggregate 或缺 raw evidence 的 proof。每个 proof 都绑定共享 producer evidence,以及实际 trace/status/log 的仓外相对路径和 SHA-256;final gate 会从 U-only bundle 临时 clone U,重放 parent/diff/结构、patch、producer evidence、aggregate、10 proof 和底层 raw artifact。新 gate 不接受 receipts/** 中的历史 receipt。
测试、formal、TD 和 bitstream 只构成离线证据,不代表 COM5、JTAG 或实板运动已经执行。
config/prod2u_p4_normal_v3_resource_baseline.json 初始状态是 pending_measurement,只声明 Trace-only 的阻断性结构目标和 advisory_only 策略,不包含任何伪造的资源数值。此状态下 TD build 可以继续执行结构、时序和 bitgen 检查,但 resource_delta.available=false,最终 gate 必须因缺少 measured baseline 而失败。无温度 Trace-only 基线必须来自同一 clean commit 的两次独立 TD build。两次构建使用同一固定 build identity 和不同 work-root;生成 baseline、amend 单一 commit、最终 TD、打包与 final gate 期间不得改变或提前清除 epoch。
baseline 命令只读取两份 TD receipt 文件,并校验同 commit、同 BUILD_ID、同 synthesis-input hash、不同 run ID/work-root/生成时间/receipt hash,以及 clean、CDC、IREG、Trace BRAM、DSP、IO、warning 和正时序证据;它不接受手工资源字典。成功后输出 status=measured,报告先写同目录临时文件再原子替换,失败时不会覆盖已有 baseline。
RX-BRAM A/B 只是可选优化。Trace-only 和 RX-BRAM 必须各有两次同 commit clean TD 结果,四个 run ID 必须独立,两种实现的 synthesis-input hash 必须可区分。候选两次构建的 LUT、FF、packed slices 最大值都必须严格低于 Trace-only 两次构建的最小值;候选的最低 Fmax/setup/hold 不得低于 Trace-only 的最低值,并且两组都必须保持 DSP=0、IO=41、零 critical warning、Trace BRAM=1,候选额外 RX BRAM=1,DISABLE 旁路周期完全等价。任一证据缺失或失败都回退到 Trace-only,总 BRAM 保持1。
RX-BRAM 当前未启用:候选补丁和验证基础设施已存在,但尚未通过真实四次 clean TD A/B、完整 transaction formal 和独立 DISABLE 周期等价证据,因此版本化配置必须保持 enabled=false、selection=no_candidate、active_total_bram9k=1。尚未通过真实四次 clean TD A/B 前,不得把 synthetic 策略结果解释为候选已选中。
RX-BRAM candidate input patch 同样只允许仓外保存,通过 tools/prod2u_p4_rx_bram_ab.py candidate-produce --candidate-patch ... 显式提供;版本化 RX manifest 只拥有 changed-path 和 proof assets,不拥有 patch。
tools/prod2u_p4_resource_policy.py 及其 synthetic 输入只验证选择规则;策略单测不等于 TD 综合实测,不得作为启用 RX-BRAM 的证据。
PROGRAM_SRAM @ 200 kHz,异常不重试。reference/original/**、receipts/** 保持只读;.planning/ 不纳入 Git。