test_6400_architecture_td_ab_parser.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. from __future__ import annotations
  2. import importlib.util
  3. from pathlib import Path
  4. ROOT = Path(__file__).resolve().parents[2]
  5. SCRIPT = ROOT / "tools/run_6400_architecture_td_ab.py"
  6. SPEC = importlib.util.spec_from_file_location("architecture_td_ab", SCRIPT)
  7. assert SPEC is not None and SPEC.loader is not None
  8. architecture_td_ab = importlib.util.module_from_spec(SPEC)
  9. SPEC.loader.exec_module(architecture_td_ab)
  10. def _write_candidate(tmp_path: Path, top: str, timing: str, log: str) -> Path:
  11. (tmp_path / f"{top}_gate.area").write_text(
  12. "#lut 8\n#reg 0\n#bram 0\n#dsp 0\n",
  13. encoding="utf-8",
  14. )
  15. (tmp_path / f"{top}_pr.area").write_text("", encoding="utf-8")
  16. (tmp_path / f"{top}_pr.timing").write_text(timing, encoding="utf-8")
  17. (tmp_path / "td.log").write_text(log, encoding="utf-8")
  18. return tmp_path
  19. def test_lut_fallback_and_no_reg_to_reg_timing_are_explicit(tmp_path: Path) -> None:
  20. root = _write_candidate(
  21. tmp_path,
  22. "candidate",
  23. """Timing Status
  24. SWNS: 0.000ns, STNS: 0.000ns
  25. HWNS: 0.000ns, HTNS: 0.000ns
  26. Intra clock domain timing
  27. --------------------------------------------------
  28. """,
  29. "PDS: 2 mslices, 3 lslices\n",
  30. )
  31. metrics = architecture_td_ab.parse_candidate("candidate", root)["metrics"]
  32. evaluation = architecture_td_ab.evaluate_timing(metrics)
  33. assert metrics["total_luts"] == 8
  34. assert metrics["total_luts_source"] == "#lut_fallback"
  35. assert metrics["fmax_mhz"] is None
  36. assert metrics["violation_endpoint_counts"] == []
  37. assert metrics["timing_applicability"] == architecture_td_ab.TIMING_NOT_APPLICABLE
  38. assert evaluation["status"] == "PASS"
  39. assert evaluation["fmax_requirement"] == "NOT_APPLICABLE"
  40. def test_measured_timing_parses_every_violation_endpoint_count(tmp_path: Path) -> None:
  41. root = _write_candidate(
  42. tmp_path,
  43. "candidate",
  44. """Timing Status
  45. SWNS: 36.587ns, STNS: 0.000ns
  46. HWNS: 0.384ns, HTNS: 0.000ns
  47. From Clock : ab_clk
  48. To Clock : ab_clk
  49. Fmax : 292.997MHz
  50. Max : SWNS 36.587ns, 0 Viol Endpoints, 37 Total Endpoints
  51. Min : HWNS 0.384ns, 0 Viol Endpoints, 37 Total Endpoints
  52. """,
  53. "PDS: 8 mslices, 9 lslices\n",
  54. )
  55. metrics = architecture_td_ab.parse_candidate("candidate", root)["metrics"]
  56. evaluation = architecture_td_ab.evaluate_timing(metrics)
  57. assert metrics["violation_endpoint_counts"] == [0, 0]
  58. assert metrics["register_to_register_path_present"] is True
  59. assert metrics["fmax_mhz"] == 292.997
  60. assert evaluation["status"] == "PASS"
  61. assert evaluation["meets_25mhz"] is True
  62. def test_expected_unassigned_io_warning_is_not_a_blocker(tmp_path: Path) -> None:
  63. log = tmp_path / "td.log"
  64. log.write_text(
  65. """SYN-6021 CRITICAL-WARNING: 82 out of 83 logical ports has no user assigned specific location constraint.
  66. Bitgen will abort. If insist on bitgen with risk, please set unconstr_io.
  67. No ADC ports: control[31:0], error[15:0].
  68. control[0]:N8, error[0]:T7
  69. RUN-1001 : Exported violations
  70. RUN-1001 : No hold violation.
  71. """,
  72. encoding="utf-8",
  73. )
  74. audit = architecture_td_ab.warning_audit(log)
  75. assert audit["status"] == "PASS"
  76. assert audit["blocking_count"] == 0
  77. assert audit["allowlisted_expected_count"] == 3
  78. assert not any("error[0]" in line for line in audit["noteworthy"])
  79. def test_actual_td_error_remains_blocking(tmp_path: Path) -> None:
  80. log = tmp_path / "td.log"
  81. log.write_text("PDS-9001 ERROR: routing failed\n", encoding="utf-8")
  82. audit = architecture_td_ab.warning_audit(log)
  83. assert audit["status"] == "FAIL"
  84. assert audit["blocking_count"] == 1