test_top_step_gate_matches_formal.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python3
  2. """Formal STEP gate must instantiate the same production gate module as top."""
  3. from __future__ import annotations
  4. import unittest
  5. from pathlib import Path
  6. ROOT = Path(__file__).resolve().parents[2]
  7. TOP = ROOT / "src/top/prod2u_p4_normal_v3_top.v"
  8. FORMAL = ROOT / "tests/formal/runtime_limit_hard_stop_formal.v"
  9. GATE = ROOT / "src/modules/prod2u_runtime_step_limit_gate.v"
  10. SBY = ROOT / "tests/formal/runtime_limit_hard_stop.sby"
  11. class TopStepGateMatchesFormalTests(unittest.TestCase):
  12. def test_top_and_formal_use_shared_gate_module(self) -> None:
  13. top = TOP.read_text(encoding="utf-8")
  14. formal = FORMAL.read_text(encoding="utf-8")
  15. gate = GATE.read_text(encoding="utf-8")
  16. sby = SBY.read_text(encoding="utf-8")
  17. self.assertIn("module prod2u_runtime_step_limit_gate", gate)
  18. self.assertIn("gate_hold", gate)
  19. self.assertIn("prod2u_runtime_step_limit_gate", top)
  20. self.assertIn("u_step_limit_gate", top)
  21. self.assertIn("assign x_step = gated_step[0]", top)
  22. self.assertIn("prod2u_runtime_step_limit_gate", formal)
  23. self.assertIn("prod2u_runtime_step_limit_gate.v", sby)
  24. # Vacuous hand-copied shell must not remain as the sole proof body.
  25. self.assertNotIn("assign gated_step[0] = engine_step[0] & ~selected_limit[0]", formal)
  26. if __name__ == "__main__":
  27. unittest.main()