NUMERIC rows cite document title, revision, section/table, and page. USB Zdiff, Type-C Rp/Rd, 10BASE-T, and 1000BASE-T stay UNKNOWN. PDFs are not in git.
149 lines
5.9 KiB
Python
149 lines
5.9 KiB
Python
"""Recovered-PDF pack: USB Electrical CTS, Type-C FTS, DVI 1.0, IEEE 802.3-2012 §2."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
from backend.periscopex.models import (
|
|
Component,
|
|
ComponentType,
|
|
DesignGraph,
|
|
Net,
|
|
NetType,
|
|
PinConnection,
|
|
)
|
|
from backend.periscopex.protocol_catalog import load_catalog
|
|
from backend.periscopex.protocol_recognize import recognize_physical_buses
|
|
|
|
|
|
def _cite_ok(c) -> None:
|
|
assert c.value_kind == "NUMERIC"
|
|
assert c.value is not None
|
|
src = c.source
|
|
assert src is not None
|
|
assert src.document
|
|
assert src.organization
|
|
assert src.revision
|
|
assert src.page
|
|
assert src.section or src.table
|
|
|
|
|
|
def test_usb_cts_hs_numeric_cited_no_zdiff_90():
|
|
cat = load_catalog()
|
|
hs = next(p for p in cat.physical_interfaces if p.id == "usb2-hs-dpair")
|
|
by = {c.parameter: c for c in hs.constraints}
|
|
_cite_ok(by["data_rate"])
|
|
assert by["data_rate"].value == 480.0
|
|
assert by["data_rate"].unit == "Mb/s"
|
|
assert by["data_rate"].source.document == "USB 2.0 Electrical Compliance Test Specification"
|
|
assert "1.08" in by["data_rate"].source.revision
|
|
assert "EL_2" in (by["data_rate"].source.section or "")
|
|
assert by["rise_time"].value == 300.0
|
|
assert by["fall_time"].value == 300.0
|
|
assert by["pull_up"].value == 1500.0
|
|
assert by["dc_resistance"].value == 17.0
|
|
assert by["dc_resistance_captive_cable_device"].value == 23.0
|
|
assert by["dc_resistance_host_hub_downstream"].value == 13.0
|
|
for key in (
|
|
"data_rate", "rise_time", "fall_time", "pull_up", "dc_resistance",
|
|
"dc_resistance_captive_cable_device", "dc_resistance_host_hub_downstream",
|
|
):
|
|
_cite_ok(by[key])
|
|
assert by[key].source.organization == "USB-IF"
|
|
z = by["differential_impedance"]
|
|
assert z.value_kind == "UNKNOWN"
|
|
assert z.value is None
|
|
ls = next(p for p in cat.physical_interfaces if p.id == "usb2-ls-dpair")
|
|
ls_rate = next(c for c in ls.constraints if c.parameter == "data_rate")
|
|
assert ls_rate.value_kind == "UNKNOWN"
|
|
blob = json.dumps(z.model_dump())
|
|
assert "90" not in blob
|
|
|
|
|
|
def test_type_c_rp_rd_unknown_fts_does_not_state_ohms():
|
|
cat = load_catalog()
|
|
rec = next(p for p in cat.physical_interfaces if p.id == "usb-c-receptacle")
|
|
by = {c.parameter: c for c in rec.constraints}
|
|
for p in ("rp", "rd", "ra", "cc"):
|
|
assert by[p].value_kind == "UNKNOWN"
|
|
assert "Cable and Connector" in (by[p].needed_document or "")
|
|
assert by["voltage"].value_kind == "UNKNOWN"
|
|
_cite_ok(by["gnd_ir_drop_cable"])
|
|
assert by["gnd_ir_drop_cable"].value == 250.0
|
|
assert by["gnd_ir_drop_cable"].source_type == "CABLE"
|
|
assert by["gnd_ir_drop_cable"].mandatory == "OPTIONAL"
|
|
_cite_ok(by["vbus_ir_drop_cable"])
|
|
assert by["vbus_ir_drop_cable"].value == 500.0
|
|
assert "Functional Test" in by["vbus_ir_drop_cable"].source.document
|
|
|
|
|
|
def test_dvi_not_hdmi_numeric_from_dvi_10():
|
|
cat = load_catalog()
|
|
logical = {p.id for p in cat.logical_protocols}
|
|
assert "dvi" in logical
|
|
assert "mini-hdmi" not in logical
|
|
dvi = next(p for p in cat.physical_interfaces if p.id == "dvi-1.0-tmds")
|
|
assert dvi.logical_protocol_id == "dvi"
|
|
assert dvi.connector == "DVI"
|
|
by = {c.parameter: c for c in dvi.constraints}
|
|
_cite_ok(by["termination"])
|
|
assert by["termination"].value == 50.0
|
|
assert by["termination"].source.table == "Table 4-2"
|
|
_cite_ok(by["differential_impedance"])
|
|
assert by["differential_impedance"].value == 100.0
|
|
assert by["differential_impedance"].source.table == "Table 4-7"
|
|
assert by["differential_impedance"].source.organization == "DDWG"
|
|
hdmi = next(p for p in cat.physical_interfaces if p.id == "hdmi-1.4-tmds-type-a")
|
|
hz = next(c for c in hdmi.constraints if c.parameter == "differential_impedance")
|
|
assert hz.value_kind == "UNKNOWN"
|
|
g = DesignGraph(
|
|
components={
|
|
"J3": Component(
|
|
reference="J3", value="DVI-D receptacle",
|
|
footprint="DVI_D",
|
|
component_type=ComponentType.CONNECTOR,
|
|
pins={"1": "TX0+"},
|
|
),
|
|
},
|
|
nets={"TX0+": Net(
|
|
name="TX0+", net_type=NetType.SIGNAL,
|
|
pins=[PinConnection(component_ref="J3", pin_number="1")],
|
|
)},
|
|
)
|
|
insts = recognize_physical_buses(g)
|
|
logs = {i.logical_protocol_id for i in insts}
|
|
assert "dvi" in logs
|
|
assert "hdmi-1.4" not in logs
|
|
assert "hdmi-2.0" not in logs
|
|
|
|
|
|
def test_ieee8023_section2_100base_tx_not_10base_or_1000():
|
|
cat = load_catalog()
|
|
tx = next(p for p in cat.physical_interfaces if p.id == "100base-tx-mdi")
|
|
by = {c.parameter: c for c in tx.constraints}
|
|
_cite_ok(by["data_rate"])
|
|
assert by["data_rate"].value == 100.0
|
|
assert by["data_rate"].source.document.startswith("IEEE Std 802.3-2012")
|
|
assert by["data_rate"].source.revision == "2012"
|
|
assert by["data_rate"].source.section == "21.1"
|
|
_cite_ok(by["cable_channel"])
|
|
assert by["cable_channel"].value == 100.0
|
|
assert by["cable_channel"].source_type == "CABLE"
|
|
assert by["cable_channel"].source.section == "25.4.9.2.2"
|
|
z = by["differential_impedance"]
|
|
assert z.value_kind == "UNKNOWN"
|
|
assert "TP-PMD" in (z.needed_document or "")
|
|
ten = next(p for p in cat.physical_interfaces if p.id == "10base-t-mdi")
|
|
tdr = next(c for c in ten.constraints if c.parameter == "data_rate")
|
|
assert tdr.value_kind == "UNKNOWN"
|
|
assert "Clause 14" in (tdr.needed_document or "")
|
|
gbe = next(p for p in cat.physical_interfaces if p.id == "1000base-t-mdi")
|
|
gdr = next(c for c in gbe.constraints if c.parameter == "data_rate")
|
|
assert gdr.value_kind == "UNKNOWN"
|
|
assert "Clause 40" in (gdr.needed_document or "")
|
|
fx = next(p for p in cat.physical_interfaces if p.id == "100base-fx-pcb")
|
|
fxr = next(c for c in fx.constraints if c.parameter == "data_rate")
|
|
_cite_ok(fxr)
|
|
assert fxr.value == 100.0
|
|
assert fxr.source.section == "26.1"
|