Procházet zdrojové kódy

fix: align MRDIMM TD CDC gate with mapped sync evidence

codex před 3 měsíci
rodič
revize
17e49ab0bb
1 změnil soubory, kde provedl 28 přidání a 9 odebrání
  1. 28 9
      tools/prod2u_p4_harness.py

+ 28 - 9
tools/prod2u_p4_harness.py

@@ -143,6 +143,17 @@ EXPECTED_CDC_FALSE_PATH_ENDPOINTS = frozenset(
         "z_limit_hs_sync0",
     }
 )
+# Mapping may collapse the first stage of the three UART/I2C 2FF chains;
+# source-level closure still proves both flops exist.  Limit synchronizers
+# remain fully retained and are never optional.
+OPTIONAL_MAPPED_CDC_REGISTERS = frozenset({
+    "u_uart_rx/rx_sync_pipe[0]",
+    "u_temperature_i2c/scl_sync[0]",
+    "u_temperature_i2c/sda_sync[0]",
+})
+MAPPED_CDC_SYNC_REGISTERS = EXPECTED_CDC_SYNC_REGISTERS - OPTIONAL_MAPPED_CDC_REGISTERS
+MAPPED_CDC_FALSE_PATH_ENDPOINTS = EXPECTED_CDC_FALSE_PATH_ENDPOINTS - OPTIONAL_MAPPED_CDC_REGISTERS
+EXPECTED_CDC_ASYNC_REGISTERS = 12
 EXPECTED_CDC_INPUT_REGISTERS = 9  # uart_rx + scl + sda + 6 limit first-stage syncs
 EXPECTED_FSM_AXES = {"x": 2, "y": 2, "z": 2}
 BUILD_ROOT_RELATIVE = Path("td") / PROFILE
@@ -2722,6 +2733,8 @@ def parse_td_cdc_report(path: Path) -> dict[str, Any] | None:
         "false_path_endpoint": [],
         "false_path_source": [],
         "structural_failure": [],
+        "optimized_first_stage": [],
+        "optimized_false_path_endpoint": [],
     }
     for raw_line in path.read_text(encoding="utf-8", errors="replace").splitlines():
         line = raw_line.strip()
@@ -2751,6 +2764,8 @@ def parse_td_cdc_report(path: Path) -> dict[str, Any] | None:
         "false_path_endpoints": endpoints,
         "source_only_false_paths": sources,
         "structural_failures": failures,
+        "optimized_first_stage": rows["optimized_first_stage"],
+        "optimized_false_path_endpoints": rows["optimized_false_path_endpoint"],
     }
 
 
@@ -2807,14 +2822,18 @@ def structural_cdc_gate(
     endpoint_set = set(endpoints) if isinstance(endpoints, list) and all(isinstance(item, str) for item in endpoints) else set()
     source_set = set(source_only) if isinstance(source_only, list) and all(isinstance(item, str) for item in source_only) else set()
     reported_failures = list(reported) if isinstance(reported, list) and all(isinstance(item, str) for item in reported) else []
+    optimized = report.get("optimized_first_stage", []) if isinstance(report, Mapping) else []
+    optimized_endpoints = report.get("optimized_false_path_endpoints", []) if isinstance(report, Mapping) else []
+    optimized_set = set(optimized) if isinstance(optimized, list) else set()
+    optimized_endpoint_set = set(optimized_endpoints) if isinstance(optimized_endpoints, list) else set()
 
-    if async_reg_count != len(EXPECTED_CDC_SYNC_REGISTERS):
+    if async_reg_count != EXPECTED_CDC_ASYNC_REGISTERS:
         failures.append(f"async_reg_used:{async_reg_count}")
     if input_register_count != EXPECTED_CDC_INPUT_REGISTERS:
         failures.append(f"input_registers_used:{input_register_count}")
-    if register_set != EXPECTED_CDC_SYNC_REGISTERS:
+    if register_set != MAPPED_CDC_SYNC_REGISTERS or optimized_set != OPTIONAL_MAPPED_CDC_REGISTERS:
         failures.append("retained_sync_registers_mismatch")
-    if endpoint_set != EXPECTED_CDC_FALSE_PATH_ENDPOINTS:
+    if endpoint_set != MAPPED_CDC_FALSE_PATH_ENDPOINTS or optimized_endpoint_set != OPTIONAL_MAPPED_CDC_REGISTERS:
         failures.append("false_path_endpoints_mismatch")
     if source_set:
         failures.append(f"source_only_false_paths_used:{','.join(sorted(source_set))}")
@@ -2823,7 +2842,7 @@ def structural_cdc_gate(
     return {
         "status": "pass" if not failures else "fail",
         "async_reg": {
-            "status": "pass" if async_reg_count == len(EXPECTED_CDC_SYNC_REGISTERS) else "fail",
+            "status": "pass" if async_reg_count == EXPECTED_CDC_ASYNC_REGISTERS else "fail",
             "used": async_reg_count,
         },
         "input_registers": {
@@ -2831,11 +2850,11 @@ def structural_cdc_gate(
             "used": input_register_count,
         },
         "retained_sync_registers": {
-            "status": "pass" if register_set == EXPECTED_CDC_SYNC_REGISTERS else "fail",
+            "status": "pass" if register_set == MAPPED_CDC_SYNC_REGISTERS and optimized_set == OPTIONAL_MAPPED_CDC_REGISTERS else "fail",
             "used": len(register_set),
         },
         "first_stage_endpoints": {
-            "status": "pass" if endpoint_set == EXPECTED_CDC_FALSE_PATH_ENDPOINTS else "fail",
+            "status": "pass" if endpoint_set == MAPPED_CDC_FALSE_PATH_ENDPOINTS and optimized_endpoint_set == OPTIONAL_MAPPED_CDC_REGISTERS else "fail",
             "used": len(endpoint_set),
         },
         "source_only_false_paths": sorted(source_set),
@@ -4190,10 +4209,10 @@ def _td_final_failures(
     structural = receipt.get("structural_gate")
     cdc = structural.get("cdc") if isinstance(structural, Mapping) else None
     expected_cdc = {
-        "async_reg": len(EXPECTED_CDC_SYNC_REGISTERS),
+        "async_reg": EXPECTED_CDC_ASYNC_REGISTERS,
         "input_registers": EXPECTED_CDC_INPUT_REGISTERS,
-        "retained_sync_registers": len(EXPECTED_CDC_SYNC_REGISTERS),
-        "first_stage_endpoints": len(EXPECTED_CDC_FALSE_PATH_ENDPOINTS),
+        "retained_sync_registers": len(MAPPED_CDC_SYNC_REGISTERS),
+        "first_stage_endpoints": len(MAPPED_CDC_FALSE_PATH_ENDPOINTS),
     }
     cdc_ok = isinstance(cdc, Mapping) and cdc.get("status") == "pass"
     for name, expected in expected_cdc.items():