|
|
@@ -0,0 +1,901 @@
|
|
|
+from __future__ import annotations
|
|
|
+
|
|
|
+import json
|
|
|
+import sys
|
|
|
+from pathlib import Path
|
|
|
+
|
|
|
+import pytest
|
|
|
+from jsonschema import Draft202012Validator
|
|
|
+
|
|
|
+
|
|
|
+ROOT = Path(__file__).resolve().parents[2]
|
|
|
+VIEWER_ROOT = ROOT / "tools" / "board-viewer"
|
|
|
+FIXTURE = Path(__file__).parent / "fixtures" / "parser_edge_cases.kicad_pcb"
|
|
|
+CONNECTOR_FIXTURE = Path(__file__).parent / "fixtures" / "connector_layouts.kicad_pcb"
|
|
|
+sys.path.insert(0, str(VIEWER_ROOT))
|
|
|
+
|
|
|
+from board_viewer.data import build_board_data # noqa: E402
|
|
|
+from board_viewer.annotations import AnnotationError # noqa: E402
|
|
|
+from board_viewer.pcb import Footprint, Pad, ParsedBoard, parse_kicad_pcb # noqa: E402
|
|
|
+
|
|
|
+
|
|
|
+def fixture_inventory() -> dict[str, object]:
|
|
|
+ return {
|
|
|
+ "schema": "fixture-pin-inventory-v1",
|
|
|
+ "board_id": "fixture-board",
|
|
|
+ "pins": [
|
|
|
+ {
|
|
|
+ "signal": "UART2_TX",
|
|
|
+ "function_net": "UART2_TX",
|
|
|
+ "fpga_ball": "M10",
|
|
|
+ "direction": "output",
|
|
|
+ "io_standard": "LVCMOS33",
|
|
|
+ "capability": ["gpio", "uart_tx", "rs232_via_transceiver"],
|
|
|
+ "reserved": False,
|
|
|
+ "board_connector": "CON1",
|
|
|
+ "connector_pin": 1,
|
|
|
+ "connector_signal": "RS232_TX2",
|
|
|
+ "external_level": "RS232",
|
|
|
+ "transceiver": "U23 TRSF3232EIPWR",
|
|
|
+ "pullup": "RTEST 4.7K to +3V3",
|
|
|
+ "series_link": "RTEST2 0R",
|
|
|
+ "esd": "ESDTEST",
|
|
|
+ "manually_verified": True,
|
|
|
+ "source_pages": [10, 5, 3],
|
|
|
+ "screenshot_index": "fixture-uart2",
|
|
|
+ "source_confidence": "manual_pdf_cross_check",
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+def fixture_annotations() -> dict[str, object]:
|
|
|
+ return {
|
|
|
+ "schema": "board-viewer-annotations-v1",
|
|
|
+ "board_id": "fixture-board",
|
|
|
+ "connector_profiles": {
|
|
|
+ "Fixture:Front": {
|
|
|
+ "references": ["CON1"],
|
|
|
+ "contact_pins": ["1"],
|
|
|
+ "shield_pads": [],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture connector profile"],
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "touchpoints": {
|
|
|
+ "CON1": {
|
|
|
+ "summary": "UART2 RS-232 接口",
|
|
|
+ "pins": {
|
|
|
+ "1": {
|
|
|
+ "summary": "UART2 发送,经电平转换",
|
|
|
+ "path": ["CON1.1", "U23", "UART2_TX", "FPGA M10"],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture schematic pages 3/5/10"],
|
|
|
+ "adc_pulltype": "PULLUP",
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "interfaces": [
|
|
|
+ {
|
|
|
+ "id": "uart2-rs232",
|
|
|
+ "name": "UART2 RS-232",
|
|
|
+ "touchpoint": "CON1",
|
|
|
+ "pins": ["1"],
|
|
|
+ "external_level": "RS232",
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture schematic pages 3/5/10"],
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "photo_overlay": None,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+def connector_layout_annotations() -> dict[str, object]:
|
|
|
+ return {
|
|
|
+ "schema": "board-viewer-annotations-v1",
|
|
|
+ "board_id": "connector-layout-fixture",
|
|
|
+ "connector_profiles": {
|
|
|
+ "CON_11251W00_NPX_SX_4P": {
|
|
|
+ "references": ["CON1", "CON2"],
|
|
|
+ "contact_pins": ["1", "2", "3", "4"],
|
|
|
+ "shield_pads": ["5", "6"],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture 4P symbol"],
|
|
|
+ },
|
|
|
+ "CON_51541_003_P1D25": {
|
|
|
+ "references": ["CON3"],
|
|
|
+ "contact_pins": ["1", "2", "3"],
|
|
|
+ "shield_pads": ["4", "5"],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture 3P symbol"],
|
|
|
+ },
|
|
|
+ "CON_3110_14P_P2D54": {
|
|
|
+ "references": ["CON4"],
|
|
|
+ "contact_pins": [str(number) for number in range(1, 15)],
|
|
|
+ "shield_pads": [],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture 14P symbol"],
|
|
|
+ },
|
|
|
+ "CON_C22930_1084N_X": {
|
|
|
+ "references": ["CON5", "CON6"],
|
|
|
+ "contact_pins": [str(number) for number in range(1, 9)],
|
|
|
+ "shield_pads": ["9", "10"],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture power connector symbol"],
|
|
|
+ },
|
|
|
+ "CON_PZGM_B03_08P": {
|
|
|
+ "references": ["CON7"],
|
|
|
+ "contact_pins": [str(number) for number in range(1, 9)],
|
|
|
+ "shield_pads": [],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture fan connector symbol"],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ "touchpoints": {},
|
|
|
+ "interfaces": [],
|
|
|
+ "photo_overlay": None,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+def build_connector_layout_payload(annotations: dict[str, object] | None = None) -> dict[str, object]:
|
|
|
+ return build_board_data(
|
|
|
+ parse_kicad_pcb(CONNECTOR_FIXTURE),
|
|
|
+ {"schema": "fixture", "board_id": "connector-layout-fixture", "pins": []},
|
|
|
+ annotations or connector_layout_annotations(),
|
|
|
+ board_name="Connector layout fixture",
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
+def jtag_fixture_board() -> ParsedBoard:
|
|
|
+ nets = {
|
|
|
+ "1": "N9532014",
|
|
|
+ "2": "GND",
|
|
|
+ "3": "N9532092",
|
|
|
+ "4": "N9532034",
|
|
|
+ "5": "N9532142",
|
|
|
+ "6": "Net_649",
|
|
|
+ "7": "Net_650",
|
|
|
+ "8": "Net_648",
|
|
|
+ "9": "N9532240",
|
|
|
+ "10": "GND",
|
|
|
+ }
|
|
|
+ coordinates = {
|
|
|
+ "1": (235.22, -41.08),
|
|
|
+ "2": (235.22, -38.54),
|
|
|
+ "3": (235.22, -36.00),
|
|
|
+ "4": (235.22, -33.46),
|
|
|
+ "5": (235.22, -30.92),
|
|
|
+ "6": (232.68, -41.08),
|
|
|
+ "7": (232.68, -38.54),
|
|
|
+ "8": (232.68, -36.00),
|
|
|
+ "9": (232.68, -33.46),
|
|
|
+ "10": (232.68, -30.92),
|
|
|
+ }
|
|
|
+ pads = [
|
|
|
+ Pad(
|
|
|
+ number=number,
|
|
|
+ pad_type="thru_hole",
|
|
|
+ shape="rect" if number == "1" else "circle",
|
|
|
+ x=coordinates[number][0],
|
|
|
+ y=coordinates[number][1],
|
|
|
+ width=1.6256,
|
|
|
+ height=1.6256,
|
|
|
+ rotation=270.0,
|
|
|
+ net=nets[number],
|
|
|
+ layers=("*.Cu", "*.Mask"),
|
|
|
+ drill_width=1.1176,
|
|
|
+ drill_height=1.1176,
|
|
|
+ mechanical=False,
|
|
|
+ electrical=True,
|
|
|
+ )
|
|
|
+ for number in nets
|
|
|
+ ]
|
|
|
+ footprint = Footprint(
|
|
|
+ reference="J3",
|
|
|
+ component_value="",
|
|
|
+ x=233.95,
|
|
|
+ y=-36.0,
|
|
|
+ rotation=270.0,
|
|
|
+ side="front",
|
|
|
+ layer="F.Cu",
|
|
|
+ pads=pads,
|
|
|
+ bounds={"x": 231.8672, "y": -41.8928, "width": 4.1656, "height": 11.7856},
|
|
|
+ )
|
|
|
+ return ParsedBoard(
|
|
|
+ footprints=[footprint],
|
|
|
+ footprint_count=1,
|
|
|
+ bounds={"x": 231.0, "y": -43.0, "width": 6.0, "height": 14.0},
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
+def jtag_fixture_annotations() -> dict[str, object]:
|
|
|
+ return {
|
|
|
+ "schema": "board-viewer-annotations-v1",
|
|
|
+ "board_id": "jtag-fixture",
|
|
|
+ "connector_profiles": {
|
|
|
+ "J3_FPGA_JTAG_2X5": {
|
|
|
+ "component_value": "",
|
|
|
+ "references": ["J3"],
|
|
|
+ "contact_pins": [str(number) for number in range(1, 11)],
|
|
|
+ "shield_pads": [],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture schematic J3 symbol and board-front coordinates"],
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "touchpoints": {
|
|
|
+ "J3": {
|
|
|
+ "summary": "FPGA JTAG 调试/配置接口(专用配置脚)",
|
|
|
+ "pins": {
|
|
|
+ "1": {
|
|
|
+ "summary": "TCK,调试器输出到 FPGA 专用 JTAG 时钟输入",
|
|
|
+ "path": ["J3.1", "R63 22R", "FPGA_TCK", "U3.A7"],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture schematic and board database"],
|
|
|
+ "direction": "input",
|
|
|
+ "external_level": "3.3V JTAG, referenced by J3.4 VREF",
|
|
|
+ "function_category": "jtag_tck",
|
|
|
+ "reserved": True,
|
|
|
+ "board_pull": "R71 4.7K to GND",
|
|
|
+ "external_components": ["R63 22R series", "D24 ESD", "R71 4.7K pull-down"],
|
|
|
+ "fpga": {
|
|
|
+ "ball": "A7",
|
|
|
+ "board_signal": "FPGA_TCK",
|
|
|
+ "io_standard": "Dedicated JTAG (VREF 3.3V)",
|
|
|
+ "capabilities": ["jtag", "jtag_tck"],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture U3 dedicated JTAG pin table"],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ "4": {
|
|
|
+ "summary": "VREF,目标板 3.3V 参考,不是给板子供电",
|
|
|
+ "path": ["J3.4", "R61 0R", "+3V3"],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture schematic and board database"],
|
|
|
+ "direction": "passive",
|
|
|
+ "external_level": "3.3V target reference",
|
|
|
+ "function_category": "reference_voltage",
|
|
|
+ "reserved": True,
|
|
|
+ "programming": {
|
|
|
+ "status": "not_programmable",
|
|
|
+ "conclusion": "VREF is not an FPGA I/O or a board power input.",
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture schematic J3 VREF path"],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ "6": {
|
|
|
+ "summary": "NC,连接器外无板内路径",
|
|
|
+ "path": ["J3.6", "NC"],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture schematic and board database"],
|
|
|
+ "direction": "passive",
|
|
|
+ "external_level": "not connected",
|
|
|
+ "function_category": "not_connected",
|
|
|
+ "reserved": True,
|
|
|
+ "programming": {
|
|
|
+ "status": "not_programmable",
|
|
|
+ "conclusion": "NC must remain unconnected.",
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture schematic J3 NC symbol"],
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "interfaces": [
|
|
|
+ {
|
|
|
+ "id": "fpga-jtag",
|
|
|
+ "name": "FPGA JTAG 调试/配置接口",
|
|
|
+ "touchpoint": "J3",
|
|
|
+ "pins": [str(number) for number in range(1, 11)],
|
|
|
+ "external_level": "3.3V JTAG; VREF is target-sense only",
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture schematic J3 symbol"],
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ "photo_overlay": None,
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+def test_reviewed_j_header_uses_board_front_matrix_and_curated_fpga_mapping() -> None:
|
|
|
+ payload = build_board_data(
|
|
|
+ jtag_fixture_board(),
|
|
|
+ {"schema": "fixture", "board_id": "jtag-fixture", "pins": []},
|
|
|
+ jtag_fixture_annotations(),
|
|
|
+ board_name="JTAG fixture",
|
|
|
+ )
|
|
|
+
|
|
|
+ j3 = payload["touchpoints"][0]
|
|
|
+ assert j3["connector"]["contact_grid"] == [
|
|
|
+ ["6", "1"],
|
|
|
+ ["7", "2"],
|
|
|
+ ["8", "3"],
|
|
|
+ ["9", "4"],
|
|
|
+ ["10", "5"],
|
|
|
+ ]
|
|
|
+ assert j3["connector"]["review_status"] == "cross_verified"
|
|
|
+ pin1 = next(pin for pin in j3["pins"] if pin["number"] == "1")
|
|
|
+ assert pin1["fpga"]["ball"] == "A7"
|
|
|
+ assert pin1["fpga"]["board_signal"] == "FPGA_TCK"
|
|
|
+ assert pin1["direction"] == "input"
|
|
|
+ assert pin1["programming"]["status"] == "verified_fpga"
|
|
|
+ assert pin1["recommendation"]["eligible"] is False
|
|
|
+ assert "reserved" in pin1["recommendation"]["reasons"]
|
|
|
+
|
|
|
+
|
|
|
+def test_jtag_annotations_schema_allows_reviewed_j_profiles_and_manual_fpga_paths() -> None:
|
|
|
+ schema_path = ROOT / "schemas" / "board_viewer_annotations.schema.json"
|
|
|
+ schema = json.loads(schema_path.read_text(encoding="utf-8"))
|
|
|
+
|
|
|
+ Draft202012Validator(schema).validate(jtag_fixture_annotations())
|
|
|
+
|
|
|
+
|
|
|
+def test_curated_non_io_status_keeps_vref_and_nc_out_of_fpga_programming() -> None:
|
|
|
+ payload = build_board_data(
|
|
|
+ jtag_fixture_board(),
|
|
|
+ {"schema": "fixture", "board_id": "jtag-fixture", "pins": []},
|
|
|
+ jtag_fixture_annotations(),
|
|
|
+ board_name="JTAG fixture",
|
|
|
+ )
|
|
|
+ pins = {pin["number"]: pin for pin in payload["touchpoints"][0]["pins"]}
|
|
|
+
|
|
|
+ assert pins["4"]["programming"]["status"] == "not_programmable"
|
|
|
+ assert pins["6"]["programming"]["status"] == "not_programmable"
|
|
|
+ assert pins["4"]["recommendation"]["eligible"] is False
|
|
|
+ assert pins["6"]["recommendation"]["eligible"] is False
|
|
|
+
|
|
|
+
|
|
|
+def test_connector_layouts_follow_board_front_top_to_bottom_then_left_to_right() -> None:
|
|
|
+ payload = build_connector_layout_payload()
|
|
|
+ by_reference = {item["reference"]: item for item in payload["touchpoints"]}
|
|
|
+ expected_grids = {
|
|
|
+ "CON1": [["4"], ["3"], ["2"], ["1"]],
|
|
|
+ "CON2": [["1"], ["2"], ["3"], ["4"]],
|
|
|
+ "CON3": [["3", "2", "1"]],
|
|
|
+ "CON4": [
|
|
|
+ ["13", "11", "9", "7", "5", "3", "1"],
|
|
|
+ ["14", "12", "10", "8", "6", "4", "2"],
|
|
|
+ ],
|
|
|
+ "CON5": [["5", "1"], ["6", "2"], ["7", "3"], ["8", "4"]],
|
|
|
+ "CON6": [["4", "8"], ["3", "7"], ["2", "6"], ["1", "5"]],
|
|
|
+ "CON7": [[str(number)] for number in range(8, 0, -1)],
|
|
|
+ }
|
|
|
+
|
|
|
+ for reference, expected_grid in expected_grids.items():
|
|
|
+ touchpoint = by_reference[reference]
|
|
|
+ connector = touchpoint["connector"]
|
|
|
+ assert connector["review_status"] == "cross_verified"
|
|
|
+ assert connector["view"] == "board_front"
|
|
|
+ assert connector["contact_grid"] == expected_grid
|
|
|
+ assert connector["rows"] == len(expected_grid)
|
|
|
+ assert connector["columns"] == len(expected_grid[0])
|
|
|
+ expected_order = [number for row in expected_grid for number in row]
|
|
|
+ assert connector["contact_order"] == expected_order
|
|
|
+ assert [pin["number"] for pin in touchpoint["pins"][: len(expected_order)]] == expected_order
|
|
|
+
|
|
|
+ pins = {pin["number"]: pin for pin in touchpoint["pins"] if pin["number"]}
|
|
|
+ for order, number in enumerate(expected_order, start=1):
|
|
|
+ row = next(index for index, values in enumerate(expected_grid, start=1) if number in values)
|
|
|
+ column = expected_grid[row - 1].index(number) + 1
|
|
|
+ assert pins[number]["pad_role"] == "contact"
|
|
|
+ assert pins[number]["board_order"] == order
|
|
|
+ assert pins[number]["row"] == row
|
|
|
+ assert pins[number]["column"] == column
|
|
|
+
|
|
|
+
|
|
|
+def test_connector_layout_separates_shield_and_mechanical_pads_from_contacts() -> None:
|
|
|
+ payload = build_connector_layout_payload()
|
|
|
+ by_reference = {item["reference"]: item for item in payload["touchpoints"]}
|
|
|
+
|
|
|
+ expected = {
|
|
|
+ "CON1": (4, {"5", "6"}, 0),
|
|
|
+ "CON2": (4, {"5", "6"}, 0),
|
|
|
+ "CON3": (3, {"4", "5"}, 0),
|
|
|
+ "CON4": (14, set(), 0),
|
|
|
+ "CON5": (8, {"9", "10"}, 2),
|
|
|
+ "CON6": (8, {"9", "10"}, 2),
|
|
|
+ "CON7": (8, set(), 1),
|
|
|
+ }
|
|
|
+ for reference, (contact_count, shield_numbers, mechanical_count) in expected.items():
|
|
|
+ touchpoint = by_reference[reference]
|
|
|
+ connector = touchpoint["connector"]
|
|
|
+ assert connector["contact_count"] == contact_count
|
|
|
+ assert connector["auxiliary_pad_count"] == len(shield_numbers) + mechanical_count
|
|
|
+ assert {pin["number"] for pin in touchpoint["pins"] if pin["pad_role"] == "shield"} == shield_numbers
|
|
|
+ assert sum(pin["pad_role"] == "mechanical" for pin in touchpoint["pins"]) == mechanical_count
|
|
|
+ assert len({pin["id"] for pin in touchpoint["pins"]}) == len(touchpoint["pins"])
|
|
|
+
|
|
|
+ assert payload["counts"]["connector_contacts"] == 49
|
|
|
+ assert payload["counts"]["connector_auxiliary_pads"] == 15
|
|
|
+
|
|
|
+
|
|
|
+def test_unknown_connector_profile_fails_closed_without_inventing_contact_order() -> None:
|
|
|
+ annotations = connector_layout_annotations()
|
|
|
+ annotations["connector_profiles"] = {}
|
|
|
+ payload = build_connector_layout_payload(annotations)
|
|
|
+ connector = next(item for item in payload["touchpoints"] if item["reference"] == "CON1")
|
|
|
+
|
|
|
+ assert connector["connector"]["review_status"] == "unknown"
|
|
|
+ assert connector["connector"]["contact_count"] == 0
|
|
|
+ assert connector["connector"]["contact_grid"] == []
|
|
|
+ assert all(pin["pad_role"] != "contact" for pin in connector["pins"])
|
|
|
+ assert all(pin["recommendation"]["eligible"] is False for pin in connector["pins"])
|
|
|
+
|
|
|
+
|
|
|
+def test_build_board_data_merges_board_inventory_and_manual_path_evidence() -> None:
|
|
|
+ payload = build_board_data(
|
|
|
+ parse_kicad_pcb(FIXTURE),
|
|
|
+ fixture_inventory(),
|
|
|
+ fixture_annotations(),
|
|
|
+ board_name="Fixture board",
|
|
|
+ )
|
|
|
+
|
|
|
+ assert payload["schema"] == "board-viewer-data-v1"
|
|
|
+ assert payload["board"]["id"] == "fixture-board"
|
|
|
+ assert payload["board"]["source_bounds"] == {"x": 0.0, "y": -10.0, "width": 30.0, "height": 10.0}
|
|
|
+ assert payload["board"]["view_box"] == {"x": 0.0, "y": 0.0, "width": 30.0, "height": 10.0}
|
|
|
+ assert payload["counts"] == {
|
|
|
+ "footprints": 2,
|
|
|
+ "touchpoints": 2,
|
|
|
+ "pads": 3,
|
|
|
+ "connector_contacts": 1,
|
|
|
+ "connector_auxiliary_pads": 1,
|
|
|
+ "categories": {"CON": 1, "J": 0, "PL": 0, "TP": 1},
|
|
|
+ "sides": {"front": 1, "back": 1},
|
|
|
+ }
|
|
|
+
|
|
|
+ connector = next(item for item in payload["touchpoints"] if item["reference"] == "CON1")
|
|
|
+ pin = next(item for item in connector["pins"] if item["number"] == "1")
|
|
|
+ assert connector["summary"] == "UART2 RS-232 接口"
|
|
|
+ assert pin["net"] == "RS232_TX2"
|
|
|
+ assert pin["view_position"] == {"x": 11.0, "y": 3.0}
|
|
|
+ assert pin["direction"] == "output"
|
|
|
+ assert pin["external_level"] == "RS232"
|
|
|
+ assert pin["function_category"] == "uart_tx"
|
|
|
+ assert pin["evidence_tier"] == "cross_verified"
|
|
|
+ assert pin["path"] == ["CON1.1", "U23", "UART2_TX", "FPGA M10"]
|
|
|
+ assert pin["adc_pulltype"] == "PULLUP"
|
|
|
+ assert pin["board_pull"] == "RTEST 4.7K to +3V3"
|
|
|
+ assert pin["external_components"] == ["U23 TRSF3232EIPWR", "RTEST2 0R", "ESDTEST"]
|
|
|
+ assert pin["fpga"] == {
|
|
|
+ "ball": "M10",
|
|
|
+ "board_signal": "UART2_TX",
|
|
|
+ "io_standard": "LVCMOS33",
|
|
|
+ "capabilities": ["gpio", "uart_tx", "rs232_via_transceiver"],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["inventory:fixture-uart2"],
|
|
|
+ }
|
|
|
+ assert pin["recommendation"]["eligible"] is True
|
|
|
+ programming = pin["programming"]
|
|
|
+ assert programming["status"] == "verified_fpga"
|
|
|
+ assert programming["evidence_tier"] == "cross_verified"
|
|
|
+ assert "FPGA 输出" in programming["conclusion"]
|
|
|
+ assert "M10" in programming["conclusion"]
|
|
|
+ assert "U23 TRSF3232EIPWR" in programming["conclusion"]
|
|
|
+ assert "RS232_TX2" in programming["network_explanation"]
|
|
|
+ assert "UART2_TX" in programming["network_explanation"]
|
|
|
+ assert "output" in programming["hdl_guidance"]
|
|
|
+ assert "LVCMOS33" in programming["hdl_guidance"]
|
|
|
+ assert any("对端设备的接收端" in item for item in programming["connection_guidance"])
|
|
|
+ assert any("不能直接接 3.3V TTL/CMOS" in item for item in programming["connection_guidance"])
|
|
|
+ assert "LOCATION = M10" in programming["constraints"]
|
|
|
+ assert "IOSTANDARD = LVCMOS33" in programming["constraints"]
|
|
|
+ assert any("RTEST 4.7K" in item for item in programming["constraints"])
|
|
|
+ assert any("当前工程约束" in item for item in programming["risks"])
|
|
|
+ assert payload["interfaces"][0]["pins"] == ["1"]
|
|
|
+
|
|
|
+
|
|
|
+def test_raw_and_mechanical_pins_remain_non_recommendable_without_verified_mapping() -> None:
|
|
|
+ payload = build_board_data(
|
|
|
+ parse_kicad_pcb(FIXTURE),
|
|
|
+ fixture_inventory(),
|
|
|
+ fixture_annotations(),
|
|
|
+ board_name="Fixture board",
|
|
|
+ )
|
|
|
+ connector = next(item for item in payload["touchpoints"] if item["reference"] == "CON1")
|
|
|
+ hole = next(item for item in connector["pins"] if item["number"] == "")
|
|
|
+ testpoint = next(item for item in payload["touchpoints"] if item["reference"] == "TP1")
|
|
|
+
|
|
|
+ assert hole["mechanical"] is True
|
|
|
+ assert hole["adc_pulltype"] is None
|
|
|
+ assert hole["summary"] == "机械焊盘"
|
|
|
+ assert hole["evidence_tier"] == "board_database"
|
|
|
+ assert hole["recommendation"]["eligible"] is False
|
|
|
+ assert hole["programming"]["status"] == "not_programmable"
|
|
|
+ assert "机械" in hole["programming"]["conclusion"]
|
|
|
+ assert "不能生成 ADC" in hole["programming"]["hdl_guidance"]
|
|
|
+ assert testpoint["pins"][0]["evidence_tier"] == "board_database"
|
|
|
+ assert testpoint["pins"][0]["summary"] == "板内网络 BACK_SIG"
|
|
|
+ assert testpoint["pins"][0]["fpga"] is None
|
|
|
+ assert testpoint["pins"][0]["recommendation"]["eligible"] is False
|
|
|
+ assert testpoint["pins"][0]["programming"]["status"] == "board_only"
|
|
|
+ assert "BACK_SIG" in testpoint["pins"][0]["programming"]["network_explanation"]
|
|
|
+ assert "没有已验证 FPGA 路径" in testpoint["pins"][0]["programming"]["conclusion"]
|
|
|
+ assert "不能据此写" in testpoint["pins"][0]["programming"]["hdl_guidance"]
|
|
|
+
|
|
|
+
|
|
|
+def test_cross_verified_power_pin_programming_preserves_direction_level_and_path() -> None:
|
|
|
+ annotations = fixture_annotations()
|
|
|
+ annotations["touchpoints"]["CON1"]["pins"]["1"].update(
|
|
|
+ {
|
|
|
+ "summary": "+12V 主电源输入,经 F1 保护",
|
|
|
+ "path": ["CON1.1 +12V_VIN", "F1", "+12V"],
|
|
|
+ "direction": "input",
|
|
|
+ "external_level": "12V power input",
|
|
|
+ "function_category": "power",
|
|
|
+ "reserved": True,
|
|
|
+ "fixed_load_conflict": True,
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
+ payload = build_board_data(
|
|
|
+ parse_kicad_pcb(FIXTURE),
|
|
|
+ {"schema": "fixture", "board_id": "fixture-board", "pins": []},
|
|
|
+ annotations,
|
|
|
+ board_name="Fixture board",
|
|
|
+ )
|
|
|
+ connector = next(item for item in payload["touchpoints"] if item["reference"] == "CON1")
|
|
|
+ pin = next(item for item in connector["pins"] if item["number"] == "1")
|
|
|
+ programming = pin["programming"]
|
|
|
+
|
|
|
+ assert programming["status"] == "not_programmable"
|
|
|
+ assert programming["evidence_tier"] == "cross_verified"
|
|
|
+ assert "+12V 主电源输入" in programming["conclusion"]
|
|
|
+ assert "CON1.1 +12V_VIN -> F1 -> +12V" in programming["network_explanation"]
|
|
|
+ assert "12V power input" in programming["network_explanation"]
|
|
|
+ assert any("电源输入" in item for item in programming["connection_guidance"])
|
|
|
+ assert any("不要反向供电" in item for item in programming["risks"])
|
|
|
+
|
|
|
+
|
|
|
+def test_curated_programming_annotation_overrides_copy_but_keeps_evidence_sources() -> None:
|
|
|
+ annotations = fixture_annotations()
|
|
|
+ annotations["touchpoints"]["CON1"]["pins"]["1"]["programming"] = {
|
|
|
+ "conclusion": "人工复核后的编程结论",
|
|
|
+ "connection_guidance": ["按已验证线束定义连接。"],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture curated programming note"],
|
|
|
+ }
|
|
|
+
|
|
|
+ payload = build_board_data(
|
|
|
+ parse_kicad_pcb(FIXTURE),
|
|
|
+ fixture_inventory(),
|
|
|
+ annotations,
|
|
|
+ board_name="Fixture board",
|
|
|
+ )
|
|
|
+ pin = next(
|
|
|
+ item
|
|
|
+ for touchpoint in payload["touchpoints"]
|
|
|
+ if touchpoint["reference"] == "CON1"
|
|
|
+ for item in touchpoint["pins"]
|
|
|
+ if item["number"] == "1"
|
|
|
+ )
|
|
|
+
|
|
|
+ assert pin["programming"]["conclusion"] == "人工复核后的编程结论"
|
|
|
+ assert pin["programming"]["connection_guidance"] == ["按已验证线束定义连接。"]
|
|
|
+ assert "fixture curated programming note" in pin["programming"]["sources"]
|
|
|
+ assert "LVCMOS33" in pin["programming"]["hdl_guidance"]
|
|
|
+
|
|
|
+
|
|
|
+def test_direct_bidirectional_gpio_guidance_does_not_require_an_inout_port() -> None:
|
|
|
+ inventory = fixture_inventory()
|
|
|
+ inventory["pins"][0]["direction"] = "bidir"
|
|
|
+ inventory["pins"][0]["capability"] = ["gpio", "digital_input", "digital_output"]
|
|
|
+ annotations = fixture_annotations()
|
|
|
+ annotations["touchpoints"]["CON1"]["pins"]["1"].update(
|
|
|
+ {
|
|
|
+ "summary": "可配置的直接 FPGA GPIO",
|
|
|
+ "direction": "bidirectional",
|
|
|
+ "function_category": "gpio",
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
+ payload = build_board_data(
|
|
|
+ parse_kicad_pcb(FIXTURE),
|
|
|
+ inventory,
|
|
|
+ annotations,
|
|
|
+ board_name="Fixture board",
|
|
|
+ )
|
|
|
+ connector = next(item for item in payload["touchpoints"] if item["reference"] == "CON1")
|
|
|
+ pin = next(item for item in connector["pins"] if item["number"] == "1")
|
|
|
+ programming = pin["programming"]
|
|
|
+
|
|
|
+ assert programming["status"] == "verified_fpga"
|
|
|
+ assert "input、output 或 inout" in programming["hdl_guidance"]
|
|
|
+ assert "只有真正需要双向共享" in programming["hdl_guidance"]
|
|
|
+ assert "方向应为 bidirectional" not in programming["hdl_guidance"]
|
|
|
+ assert any("不要因为物理上可双向" in item for item in programming["risks"])
|
|
|
+
|
|
|
+
|
|
|
+def test_verified_mapping_keeps_semantic_signal_distinct_from_board_net() -> None:
|
|
|
+ inventory = fixture_inventory()
|
|
|
+ item = inventory["pins"][0]
|
|
|
+ item.update(
|
|
|
+ {
|
|
|
+ "signal": "MOTOR_EN_N",
|
|
|
+ "function_net": "RS232_TX2",
|
|
|
+ "connector_signal": "RS232_TX2",
|
|
|
+ "external_level": "3.3V LVCMOS",
|
|
|
+ "transceiver": None,
|
|
|
+ "capability": ["gpio", "motor_enable_n"],
|
|
|
+ }
|
|
|
+ )
|
|
|
+ annotations = fixture_annotations()
|
|
|
+ annotations["touchpoints"]["CON1"]["pins"] = {}
|
|
|
+
|
|
|
+ payload = build_board_data(
|
|
|
+ parse_kicad_pcb(FIXTURE), inventory, annotations, board_name="Fixture board"
|
|
|
+ )
|
|
|
+ pin = next(
|
|
|
+ item
|
|
|
+ for touchpoint in payload["touchpoints"]
|
|
|
+ if touchpoint["reference"] == "CON1"
|
|
|
+ for item in touchpoint["pins"]
|
|
|
+ if item["number"] == "1"
|
|
|
+ )
|
|
|
+
|
|
|
+ assert pin["net"] == "RS232_TX2"
|
|
|
+ assert pin["fpga"]["board_signal"] == "MOTOR_EN_N"
|
|
|
+ assert "MOTOR_EN_N" in pin["programming"]["conclusion"]
|
|
|
+ assert "RS232_TX2" in pin["programming"]["network_explanation"]
|
|
|
+
|
|
|
+
|
|
|
+def test_direct_inventory_mapping_fails_closed_when_connector_net_does_not_match_board() -> None:
|
|
|
+ inventory = fixture_inventory()
|
|
|
+ inventory["pins"][0]["connector_signal"] = "WRONG_CONNECTOR_NET"
|
|
|
+
|
|
|
+ with pytest.raises(ValueError, match="connector net mismatch CON1.1"):
|
|
|
+ build_board_data(
|
|
|
+ parse_kicad_pcb(FIXTURE),
|
|
|
+ inventory,
|
|
|
+ fixture_annotations(),
|
|
|
+ board_name="Fixture board",
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
+def test_generated_payload_matches_versioned_json_schema() -> None:
|
|
|
+ schema_path = ROOT / "schemas" / "board_viewer_data.schema.json"
|
|
|
+ schema = json.loads(schema_path.read_text(encoding="utf-8"))
|
|
|
+ payload = build_board_data(
|
|
|
+ parse_kicad_pcb(FIXTURE),
|
|
|
+ fixture_inventory(),
|
|
|
+ fixture_annotations(),
|
|
|
+ board_name="Fixture board",
|
|
|
+ )
|
|
|
+
|
|
|
+ Draft202012Validator(schema).validate(payload)
|
|
|
+
|
|
|
+
|
|
|
+def test_versioned_annotations_match_their_json_schema() -> None:
|
|
|
+ schema_path = ROOT / "schemas" / "board_viewer_annotations.schema.json"
|
|
|
+ schema = json.loads(schema_path.read_text(encoding="utf-8"))
|
|
|
+
|
|
|
+ Draft202012Validator(schema).validate(fixture_annotations())
|
|
|
+
|
|
|
+
|
|
|
+def templated_mcu_annotations() -> dict[str, object]:
|
|
|
+ annotations = fixture_annotations()
|
|
|
+ annotations["annotation_templates"] = {
|
|
|
+ "mcu-testpoint": {
|
|
|
+ "summary": "GD32 ${signal} 固件测试点",
|
|
|
+ "pins": {
|
|
|
+ "1": {
|
|
|
+ "summary": "${signal},直连 ${device}.${package_pin}",
|
|
|
+ "path": ["${reference}.1 ${signal}", "${device}.${package_pin}"],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture schematic MCU page"],
|
|
|
+ "direction": "unknown",
|
|
|
+ "external_level": "3.3V MCU GPIO",
|
|
|
+ "function_category": "mcu_gpio",
|
|
|
+ "mcu": {
|
|
|
+ "device": "${device}",
|
|
|
+ "family": "GD32F303CGT6",
|
|
|
+ "pin": "${package_pin}",
|
|
|
+ "signal": "${signal}",
|
|
|
+ "capabilities": ["gpio"],
|
|
|
+ "evidence_tier": "cross_verified",
|
|
|
+ "sources": ["fixture schematic MCU page"],
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ }
|
|
|
+ annotations["template_instances"] = {
|
|
|
+ "TP1": {
|
|
|
+ "template": "mcu-testpoint",
|
|
|
+ "variables": {
|
|
|
+ "reference": "TP1",
|
|
|
+ "device": "U27",
|
|
|
+ "package_pin": "10",
|
|
|
+ "signal": "PA0",
|
|
|
+ },
|
|
|
+ }
|
|
|
+ }
|
|
|
+ annotations["touchpoints"]["TP1"] = {
|
|
|
+ "summary": "GD32 PA0 调试测试点",
|
|
|
+ "pins": {},
|
|
|
+ }
|
|
|
+ return annotations
|
|
|
+
|
|
|
+
|
|
|
+def test_annotation_templates_expand_and_explicit_touchpoint_overrides_win() -> None:
|
|
|
+ payload = build_board_data(
|
|
|
+ parse_kicad_pcb(FIXTURE),
|
|
|
+ fixture_inventory(),
|
|
|
+ templated_mcu_annotations(),
|
|
|
+ board_name="Fixture board",
|
|
|
+ )
|
|
|
+
|
|
|
+ testpoint = next(item for item in payload["touchpoints"] if item["reference"] == "TP1")
|
|
|
+ pin = testpoint["pins"][0]
|
|
|
+ assert testpoint["summary"] == "GD32 PA0 调试测试点"
|
|
|
+ assert pin["summary"] == "PA0,直连 U27.10"
|
|
|
+ assert pin["path"] == ["TP1.1 PA0", "U27.10"]
|
|
|
+ assert pin["mcu"]["device"] == "U27"
|
|
|
+ assert pin["mcu"]["pin"] == "10"
|
|
|
+ assert pin["mcu"]["signal"] == "PA0"
|
|
|
+
|
|
|
+
|
|
|
+def test_annotation_template_missing_variable_fails_closed() -> None:
|
|
|
+ annotations = templated_mcu_annotations()
|
|
|
+ del annotations["template_instances"]["TP1"]["variables"]["package_pin"]
|
|
|
+
|
|
|
+ with pytest.raises(AnnotationError, match="missing template variable package_pin"):
|
|
|
+ build_board_data(
|
|
|
+ parse_kicad_pcb(FIXTURE),
|
|
|
+ fixture_inventory(),
|
|
|
+ annotations,
|
|
|
+ board_name="Fixture board",
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
+def test_verified_mcu_mapping_generates_firmware_guidance_but_never_fpga_adc() -> None:
|
|
|
+ payload = build_board_data(
|
|
|
+ parse_kicad_pcb(FIXTURE),
|
|
|
+ fixture_inventory(),
|
|
|
+ templated_mcu_annotations(),
|
|
|
+ board_name="Fixture board",
|
|
|
+ )
|
|
|
+
|
|
|
+ testpoint = next(item for item in payload["touchpoints"] if item["reference"] == "TP1")
|
|
|
+ pin = testpoint["pins"][0]
|
|
|
+ programming = pin["programming"]
|
|
|
+ assert programming["status"] == "verified_mcu"
|
|
|
+ assert "GD32" in programming["conclusion"]
|
|
|
+ assert "U27.10" in programming["conclusion"]
|
|
|
+ assert "PA0" in programming["hdl_guidance"]
|
|
|
+ assert pin["fpga"] is None
|
|
|
+ assert pin["recommendation"]["eligible"] is False
|
|
|
+
|
|
|
+
|
|
|
+def test_annotation_schema_allows_templates_and_verified_mcu_metadata() -> None:
|
|
|
+ schema_path = ROOT / "schemas" / "board_viewer_annotations.schema.json"
|
|
|
+ schema = json.loads(schema_path.read_text(encoding="utf-8"))
|
|
|
+
|
|
|
+ Draft202012Validator(schema).validate(templated_mcu_annotations())
|
|
|
+
|
|
|
+
|
|
|
+def test_product_annotations_fix_uart1_uart2_connector_paths() -> None:
|
|
|
+ annotation_path = ROOT / "config" / "board_viewer_annotations.fcb_fpga_mcu0611.json"
|
|
|
+ annotations = json.loads(annotation_path.read_text(encoding="utf-8"))
|
|
|
+
|
|
|
+ con77 = annotations["touchpoints"]["CON77"]
|
|
|
+ con78 = annotations["touchpoints"]["CON78"]
|
|
|
+ assert con77["summary"] == "UART1 RS-232 接口,经 U22 电平转换"
|
|
|
+ assert con78["summary"] == "UART2 RS-232 接口,经 U23 电平转换"
|
|
|
+ assert con77["pins"]["1"]["path"] == ["CON77.1 RS232_TX1", "U22 TRSF3232EIPWR", "UART1_TX", "FPGA L10"]
|
|
|
+ assert con77["pins"]["2"]["path"] == ["CON77.2 RS232_RX1", "U22 TRSF3232EIPWR", "UART1_RX", "FPGA M9"]
|
|
|
+ assert con78["pins"]["1"]["path"] == ["CON78.1 RS232_TX2", "U23 TRSF3232EIPWR", "UART2_TX", "FPGA M10"]
|
|
|
+ assert con78["pins"]["2"]["path"] == ["CON78.2 RS232_RX2", "U23 TRSF3232EIPWR", "UART2_RX", "FPGA N11"]
|
|
|
+ for connector in (con77, con78):
|
|
|
+ for number in ("3", "4"):
|
|
|
+ assert connector["pins"][number]["function_category"] == "ground"
|
|
|
+ assert connector["pins"][number]["external_level"] == "0V"
|
|
|
+ for number in ("5", "6"):
|
|
|
+ assert connector["pins"][number]["function_category"] == "ground"
|
|
|
+ assert "shield" in " ".join(connector["pins"][number]["path"]).lower()
|
|
|
+
|
|
|
+ interfaces = {item["id"]: item for item in annotations["interfaces"]}
|
|
|
+ assert set(interfaces) == {
|
|
|
+ "uart1-rs232",
|
|
|
+ "uart2-rs232",
|
|
|
+ "fpga-jtag",
|
|
|
+ "fpga-bank1-debug",
|
|
|
+ "gd32-swd",
|
|
|
+ }
|
|
|
+ assert interfaces["uart1-rs232"]["pins"] == ["1", "2", "3", "4"]
|
|
|
+ assert interfaces["uart2-rs232"]["pins"] == ["1", "2", "3", "4"]
|
|
|
+
|
|
|
+ expected_profile_references = {
|
|
|
+ "CON_11251W00_NPX_SX_4P": {
|
|
|
+ "CON12", "CON30", "CON31", "CON32", "CON33", "CON34", "CON35", "CON36",
|
|
|
+ "CON37", "CON38", "CON39", "CON40", "CON54", "CON58", "CON59", "CON60",
|
|
|
+ "CON61", "CON62", "CON63", "CON64", "CON65", "CON66", "CON67", "CON68",
|
|
|
+ "CON69", "CON70", "CON77", "CON78",
|
|
|
+ },
|
|
|
+ "CON_51541_003_P1D25": {
|
|
|
+ "CON53", "CON55", "CON56", "CON57", "CON79", "CON80", "CON81", "CON82",
|
|
|
+ "CON83", "CON84", "CON85", "CON86", "CON87", "CON88", "CON89", "CON90",
|
|
|
+ "CON91", "CON92", "CON93", "CON94", "CON95", "CON96", "CON97", "CON98",
|
|
|
+ },
|
|
|
+ "CON_3110_14P_P2D54": {"CON18", "CON27", "CON28", "CON29"},
|
|
|
+ "CON_C22930_1084N_X": {"CON2", "CON23"},
|
|
|
+ "CON_PZGM_B03_08P": {"CON8", "CON24", "CON25", "CON26"},
|
|
|
+ "J3_FPGA_JTAG_2X5": {"J3"},
|
|
|
+ "J19_FPGA_BANK1_DEBUG_1X5": {"J19"},
|
|
|
+ "J25_GD32_SWD_1X5": {"J25"},
|
|
|
+ }
|
|
|
+ profiles = annotations["connector_profiles"]
|
|
|
+ assert set(profiles) == set(expected_profile_references)
|
|
|
+ for profile_name, references in expected_profile_references.items():
|
|
|
+ assert set(profiles[profile_name]["references"]) == references
|
|
|
+ assert profiles[profile_name]["evidence_tier"] == "cross_verified"
|
|
|
+ all_profile_references = set().union(*expected_profile_references.values())
|
|
|
+ assert len(all_profile_references) == 65
|
|
|
+ assert sum(reference.startswith("CON") for reference in all_profile_references) == 62
|
|
|
+ assert "CON5" not in all_profile_references
|
|
|
+
|
|
|
+ schema = json.loads((ROOT / "schemas" / "board_viewer_annotations.schema.json").read_text(encoding="utf-8"))
|
|
|
+ Draft202012Validator(schema).validate(annotations)
|
|
|
+
|
|
|
+
|
|
|
+def test_product_annotations_cover_debug_headers_and_non_connector_j_pl_items() -> None:
|
|
|
+ annotation_path = ROOT / "config" / "board_viewer_annotations.fcb_fpga_mcu0611.json"
|
|
|
+ annotations = json.loads(annotation_path.read_text(encoding="utf-8"))
|
|
|
+
|
|
|
+ expected_j_pl = {
|
|
|
+ "J3", "J8", "J9", "J11", "J12", "J13", "J14", "J17", "J18",
|
|
|
+ "J19", "J20", "J21", "J22", "J25", "J26", "J27",
|
|
|
+ "PL2001", "PL2002", "PL2003",
|
|
|
+ }
|
|
|
+ assert expected_j_pl.issubset(annotations["touchpoints"])
|
|
|
+
|
|
|
+ profiles = annotations["connector_profiles"]
|
|
|
+ assert profiles["J3_FPGA_JTAG_2X5"]["references"] == ["J3"]
|
|
|
+ assert profiles["J19_FPGA_BANK1_DEBUG_1X5"]["references"] == ["J19"]
|
|
|
+ assert profiles["J25_GD32_SWD_1X5"]["references"] == ["J25"]
|
|
|
+ assert all(profiles[name]["component_value"] == "" for name in (
|
|
|
+ "J3_FPGA_JTAG_2X5",
|
|
|
+ "J19_FPGA_BANK1_DEBUG_1X5",
|
|
|
+ "J25_GD32_SWD_1X5",
|
|
|
+ ))
|
|
|
+
|
|
|
+ j3 = annotations["touchpoints"]["J3"]
|
|
|
+ assert "FPGA JTAG" in j3["summary"]
|
|
|
+ assert "EF2L45BG256B" in j3["summary"]
|
|
|
+ expected_jtag = {
|
|
|
+ "1": ("TCK", "A7", "input", "R63"),
|
|
|
+ "3": ("TDO", "C6", "output", "R65"),
|
|
|
+ "5": ("TMS", "B8", "input", "R67"),
|
|
|
+ "9": ("TDI", "A6", "input", "R69"),
|
|
|
+ }
|
|
|
+ for number, (signal, ball, direction, series_resistor) in expected_jtag.items():
|
|
|
+ pin = j3["pins"][number]
|
|
|
+ assert signal in pin["summary"]
|
|
|
+ assert pin["fpga"]["ball"] == ball
|
|
|
+ assert pin["direction"] == direction
|
|
|
+ assert pin["reserved"] is True
|
|
|
+ assert series_resistor in " ".join(pin["path"] + pin["external_components"])
|
|
|
+ assert "专用" in pin["programming"]["hdl_guidance"]
|
|
|
+ assert "不是给板子供电" in " ".join(
|
|
|
+ [
|
|
|
+ j3["pins"]["4"]["summary"],
|
|
|
+ j3["pins"]["4"]["programming"]["conclusion"],
|
|
|
+ *j3["pins"]["4"]["programming"]["connection_guidance"],
|
|
|
+ ]
|
|
|
+ )
|
|
|
+ for number in ("6", "7", "8"):
|
|
|
+ assert j3["pins"][number]["function_category"] == "not_connected"
|
|
|
+ assert j3["pins"][number]["reserved"] is True
|
|
|
+
|
|
|
+ assert "非专用JTAG" in annotations["touchpoints"]["J19"]["summary"]
|
|
|
+ j25 = annotations["touchpoints"]["J25"]
|
|
|
+ assert "GD32F303CGT6" in j25["summary"]
|
|
|
+ for number in ("2", "3", "5"):
|
|
|
+ assert "GD32F303CGT6" in j25["pins"][number]["programming"]["conclusion"]
|
|
|
+ for reference in ("PL2001", "PL2002", "PL2003"):
|
|
|
+ assert "非连接器" in annotations["touchpoints"][reference]["summary"]
|
|
|
+
|
|
|
+ interfaces = {item["id"]: item for item in annotations["interfaces"]}
|
|
|
+ assert interfaces["fpga-jtag"]["touchpoint"] == "J3"
|
|
|
+ assert interfaces["fpga-bank1-debug"]["touchpoint"] == "J19"
|
|
|
+ assert interfaces["gd32-swd"]["touchpoint"] == "J25"
|