| 12345678910111213141516171819202122232425262728293031323334 |
- #!/usr/bin/env python3
- """Formal STEP gate must instantiate the same production gate module as top."""
- from __future__ import annotations
- import unittest
- from pathlib import Path
- ROOT = Path(__file__).resolve().parents[2]
- TOP = ROOT / "src/top/prod2u_p4_normal_v3_top.v"
- FORMAL = ROOT / "tests/formal/runtime_limit_hard_stop_formal.v"
- GATE = ROOT / "src/modules/prod2u_runtime_step_limit_gate.v"
- SBY = ROOT / "tests/formal/runtime_limit_hard_stop.sby"
- class TopStepGateMatchesFormalTests(unittest.TestCase):
- def test_top_and_formal_use_shared_gate_module(self) -> None:
- top = TOP.read_text(encoding="utf-8")
- formal = FORMAL.read_text(encoding="utf-8")
- gate = GATE.read_text(encoding="utf-8")
- sby = SBY.read_text(encoding="utf-8")
- self.assertIn("module prod2u_runtime_step_limit_gate", gate)
- self.assertIn("gate_hold", gate)
- self.assertIn("prod2u_runtime_step_limit_gate", top)
- self.assertIn("u_step_limit_gate", top)
- self.assertIn("assign x_step = gated_step[0]", top)
- self.assertIn("prod2u_runtime_step_limit_gate", formal)
- self.assertIn("prod2u_runtime_step_limit_gate.v", sby)
- # Vacuous hand-copied shell must not remain as the sole proof body.
- self.assertNotIn("assign gated_step[0] = engine_step[0] & ~selected_limit[0]", formal)
- if __name__ == "__main__":
- unittest.main()
|