Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* text=auto
* text=auto eol=lf

# Source and documentation files are kept LF-normalized in Git.
*.sv text eol=lf
Expand Down
3 changes: 3 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Purpose

For all metric evidence work, follow the repository-root `AGENTS.md` contract
and `docs/METRICS_CURRENT.json`; legacy `summary.json` files are not current.

Help AI coding agents understand and work efficiently in this SAR ADC digital
processing project (RTL changes, testbench updates, simulation debugging,
constraint modifications).
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/numerical-metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ on:
permissions:
contents: read
jobs:
evidence:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Independent frozen-byte comparison with f180d8a.
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install pytest==8.3.5
- run: python -m pytest analysis/test_metric_evidence.py -q
- run: python scripts/check_repo_consistency.py
metrics:
runs-on: ubuntu-latest
timeout-minutes: 15
Expand Down
22 changes: 22 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Metric evidence contract

For current ADC metrics, use `docs/METRICS_CURRENT.json` and
`analysis.metric_evidence.load_current_metrics()` (or `python -m
analysis.metric_evidence`). Do not pick the newest directory, glob `summary.json`,
or treat old `outputs` / `outputs_revalidation` / delivery copies as current.

Only `physical_cdac.ideal` and `physical_cdac.main` have permanent current
machine-readable evidence. Missing scopes must fail; do not substitute old
full-SAR, self-calibration, sigma/amplitude or ablation tables. A current result
must keep its evidence ID, metric definition, conditions and provenance.

Historical JSON/CSV/NPZ/PDF/TeX and delivery/archive packages are frozen. Do not
rewrite their numbers or refresh their checksum lists. Historical report
reproduction requires `--historical-evidence --outdir NEW_DIRECTORY`; those
outputs must be labelled historical and the spectral erratum still applies.
Campaign producers retain legacy output defaults: always pass a fresh `--outdir`
when rerunning, and use `--no-resume` for the full-SAR campaign.

Run `python -m pytest analysis/test_metric_evidence.py -q` and
`python scripts/check_repo_consistency.py` before publishing metric-related edits.
See `docs/METRIC_ENTRYPOINT_AUDIT_20261005.md` for coverage and limitations.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
> **2026-10-02 数值勘误**:历史频谱汇总发现 SNR / SNDR 口径矛盾;本轮已完成两组核心矩阵重算。
> 当前频谱代码已加入独立功率分区与解析对照检查;完整行为与物理 CDAC 矩阵已重新执行。
> 最新结果见 [本轮再验证](docs/REVALIDATION_20261002.md),旧交付报告的历史数字仍按 [指标勘误](docs/METRIC_ERRATUM_20261002.md) 处理。
>
> **机器读取当前指标**:唯一清单是 [METRICS_CURRENT.json](docs/METRICS_CURRENT.json)。
> 使用 `python -m analysis.metric_evidence --scope physical_cdac.ideal` 或
> `physical_cdac.main`;旧 summary、未知 scope、哈希/版本/源码身份不符直接失败。
> `python -m analysis.metric_evidence --check` 校验当前快照和冻结证据。
> 全量入口审计、历史复现方式与验收条件见 [防误用审计](docs/METRIC_ENTRYPOINT_AUDIT_20261005.md)。

本仓库维护 Split-Sampling SAR ADC 的数字后端处理逻辑,重点覆盖前台校准、SAR 码重构、SRM 残差估计,以及 FPGA/Vivado 验证入口。

Expand Down Expand Up @@ -70,11 +76,11 @@ powershell -NoProfile -ExecutionPolicy Bypass -File scripts\run_all_xsim.ps1
$py = "C:\Users\Administrator\Desktop\ADCToolbox_EVAL_20260728\envs\upstream-main\Scripts\python.exe"

& $py -m pytest analysis\full_sar_behavioral_20260729\test_full_sar_model.py -q
& $py analysis\full_sar_behavioral_20260729\run_campaign.py --chips 512 --workers 6
& $py analysis\full_sar_behavioral_20260729\run_campaign.py --chips 512 --workers 6 --no-resume --outdir campaign-full-new
```

运行支持逐芯片检查点和断点续跑;正式聚合结果位于
`analysis/full_sar_behavioral_20260729/outputs/`。
运行支持逐芯片检查点和带身份校验的断点续跑。上述命令写入新目录;
`analysis/full_sar_behavioral_20260729/outputs/` 是冻结历史证据,不能作为当前频谱口径。

### 物理CDAC失配正式再验证

Expand All @@ -83,10 +89,11 @@ $py = "C:\Users\Administrator\Desktop\ADCToolbox_EVAL_20260728\envs\upstream-mai
analysis\physical_cdac_mismatch_20260729\test_physical_cdac.py `
analysis\physical_cdac_mismatch_20260729\test_revalidation.py -q
& $py analysis\physical_cdac_mismatch_20260729\run_revalidation.py `
--chips 512 --sensitivity-chips 128 --amplitude-chips 128 --workers 6
--chips 512 --sensitivity-chips 128 --amplitude-chips 128 --workers 6 --outdir physical-cdac-new
```

正式证据位于 `analysis/physical_cdac_mismatch_20260729/outputs_revalidation/`。
上述命令写入新目录。`analysis/physical_cdac_mismatch_20260729/outputs_revalidation/`
保留冻结历史字节;当前已固化的理想对照和物理主矩阵应通过 current 清单读取。

### Vivado GUI 工程

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
"""Generate LaTeX report assets from calibration validation evidence."""
"""Explicitly reproduce LaTeX assets from frozen historical calibration evidence."""

from __future__ import annotations

import json
import sys
from pathlib import Path


ROOT = Path(__file__).resolve().parent
SUMMARY_PATH = ROOT / "outputs" / "summary.json"
REPORT_DIR = ROOT / "report"
sys.path.insert(0, str(ROOT.parents[1]))
from analysis.metric_evidence import require_historical_report


def esc(text: str) -> str:
Expand All @@ -28,11 +31,15 @@ def macro(name: str, value: str | float) -> str:


def build_assets() -> None:
global REPORT_DIR
REPORT_DIR = require_historical_report(SUMMARY_PATH)
print("HISTORICAL evidence reproduction; see docs/METRIC_ERRATUM_20261002.md.")
payload = json.loads(SUMMARY_PATH.read_text(encoding="utf-8"))
summary = payload["summary"]
REPORT_DIR.mkdir(parents=True, exist_ok=True)

lines = [
"% HISTORICAL evidence; see docs/METRIC_ERRATUM_20261002.md.",
"% Auto-generated from analysis/calibration_effectiveness_20260729/outputs/summary.json",
macro("ValNChips", str(payload["config"]["n_chips"])),
macro("ValFFT", str(payload["config"]["n_fft"])),
Expand Down Expand Up @@ -68,6 +75,7 @@ def build_assets() -> None:
"ORACLE": "Physical-weight oracle",
}
table = [
"% HISTORICAL evidence; see docs/METRIC_ERRATUM_20261002.md.",
r"\small",
r"\begin{tabularx}{\linewidth}{@{}>{\raggedright\arraybackslash}Xrrrr@{}}",
r"\toprule",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
"""Generate LaTeX metrics and tables from the authoritative campaign JSON."""
"""Explicitly reproduce LaTeX metrics and tables from frozen historical campaign JSON."""

from __future__ import annotations

import json
import sys
from pathlib import Path


REPORT_DIR = Path(__file__).resolve().parent
ROOT = REPORT_DIR.parent
SUMMARY_PATH = ROOT / "outputs" / "summary.json"
sys.path.insert(0, str(ROOT.parents[1]))
from analysis.metric_evidence import require_historical_report

HISTORICAL_NOTICE = "% HISTORICAL evidence; see docs/METRIC_ERRATUM_20261002.md.\n"


def metric(payload: dict, decoder: str, name: str, statistic: str) -> float:
Expand All @@ -35,6 +40,7 @@ def generate_metrics(payload: dict) -> str:
- metric(payload, "CAL_SRM", "dynamic_sndr_db", "median")
)
lines = [
"% HISTORICAL evidence; see docs/METRIC_ERRATUM_20261002.md.",
"% Generated from outputs/summary.json. Do not edit manually.",
command("ChipCount", str(payload["completed_chips"])),
command("DecoderRows", str(payload["decoder_rows"])),
Expand Down Expand Up @@ -195,7 +201,7 @@ def generate_dynamic_table(payload: dict) -> str:
metric(payload, decoder, "dynamic_enob", "median"),
)
)
return "\\newcommand{\\DynamicTableRows}{%\n" + "\n".join(rows) + "\n}\n"
return HISTORICAL_NOTICE + "\\newcommand{\\DynamicTableRows}{%\n" + "\n".join(rows) + "\n}\n"


def generate_static_table(payload: dict) -> str:
Expand All @@ -218,7 +224,7 @@ def generate_static_table(payload: dict) -> str:
metric(payload, decoder, "missing_codes", "max"),
)
)
return "\\newcommand{\\StaticTableRows}{%\n" + "\n".join(rows) + "\n}\n"
return HISTORICAL_NOTICE + "\\newcommand{\\StaticTableRows}{%\n" + "\n".join(rows) + "\n}\n"


def generate_representative_table(payload: dict) -> str:
Expand All @@ -241,16 +247,21 @@ def generate_representative_table(payload: dict) -> str:
)
)
return (
"\\newcommand{\\RepresentativeTableRows}{%\n"
HISTORICAL_NOTICE
+ "\\newcommand{\\RepresentativeTableRows}{%\n"
+ "\n".join(rows)
+ "\n}\n"
)


def main() -> None:
global REPORT_DIR
REPORT_DIR = require_historical_report(SUMMARY_PATH)
print("HISTORICAL evidence reproduction; see docs/METRIC_ERRATUM_20261002.md.")
payload = json.loads(SUMMARY_PATH.read_text(encoding="utf-8"))
if payload.get("status") != "complete" or payload.get("completed_chips") != 512:
raise RuntimeError("The formal 512-point campaign is not complete.")
REPORT_DIR.mkdir(parents=True, exist_ok=True)
(REPORT_DIR / "generated_metrics.tex").write_text(
generate_metrics(payload), encoding="utf-8"
)
Expand Down
Loading
Loading