test_prod2u_p4_fast_jog_rx_contract.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env python3
  2. """Run the independent RX fast-JOG contract directly with Icarus."""
  3. from __future__ import annotations
  4. import subprocess
  5. import tempfile
  6. from pathlib import Path
  7. from tools import prod2u_p4_harness as harness
  8. ROOT = Path(__file__).resolve().parents[2]
  9. TESTBENCH = ROOT / "tests/sim/prod2u_p4_normal_v3_rx_fast_jog_tb.v"
  10. SOURCES = (
  11. ROOT / "src/rtl/binary921_crc16.v",
  12. ROOT / "src/rtl/prod2u_p4_normal_v3_rx.v",
  13. TESTBENCH,
  14. )
  15. def test_rx_fast_jog_bypasses_held_normal_request_slot() -> None:
  16. iverilog = harness.resolve_tool("iverilog")
  17. vvp = harness.resolve_tool("vvp")
  18. assert iverilog is not None, "Icarus Verilog is required"
  19. assert vvp is not None, "vvp is required"
  20. with tempfile.TemporaryDirectory(prefix="p4-rx-fast-jog-") as temporary:
  21. executable = Path(temporary) / "rx_fast_jog.vvp"
  22. compile_result = subprocess.run(
  23. [
  24. str(iverilog),
  25. "-g2005-sv",
  26. "-s",
  27. "prod2u_p4_normal_v3_rx_fast_jog_tb",
  28. "-o",
  29. str(executable),
  30. *(str(path) for path in SOURCES),
  31. ],
  32. cwd=ROOT,
  33. env=harness.tool_env(),
  34. capture_output=True,
  35. text=True,
  36. timeout=60,
  37. check=False,
  38. )
  39. compile_output = compile_result.stdout + compile_result.stderr
  40. assert compile_result.returncode == 0, compile_output
  41. run_result = subprocess.run(
  42. [str(vvp), str(executable)],
  43. cwd=ROOT,
  44. env=harness.tool_env(),
  45. capture_output=True,
  46. text=True,
  47. timeout=60,
  48. check=False,
  49. )
  50. output = run_result.stdout + run_result.stderr
  51. assert run_result.returncode == 0, output
  52. assert "PASS: prod2u_p4_normal_v3_rx_fast_jog_tb" in output