| 12345678910111213141516171819202122232425262728293031323334353637 |
- #!/usr/bin/env python3
- """Generated motion params must bind into the production top instance."""
- from __future__ import annotations
- import re
- import unittest
- from pathlib import Path
- ROOT = Path(__file__).resolve().parents[2]
- TOP = ROOT / "src/top/prod2u_p4_normal_v3_top.v"
- PARAMS = ROOT / "src/generated/prod2u_door_temp_params.vh"
- CONTROLLER = ROOT / "src/modules/door_motion_controller.v"
- class MotionParamsBindingTests(unittest.TestCase):
- def test_generated_defines_match_contract(self) -> None:
- text = PARAMS.read_text(encoding="utf-8")
- self.assertIn("`define P4_MOTION_SERVICE_CLKS 625", text)
- self.assertIn("`define P4_PHASE_FACTOR 5120", text)
- self.assertIn("`define P4_CAL_RAMP_UNIT 8", text)
- def test_top_passes_generated_motion_params(self) -> None:
- text = TOP.read_text(encoding="utf-8")
- self.assertIn(".MOTION_SERVICE_CLKS(`P4_MOTION_SERVICE_CLKS)", text)
- self.assertIn(".PHASE_FACTOR(`P4_PHASE_FACTOR)", text)
- self.assertIn(".CAL_RAMP_UNIT(`P4_CAL_RAMP_UNIT)", text)
- def test_controller_exposes_params(self) -> None:
- text = CONTROLLER.read_text(encoding="utf-8")
- self.assertIn("parameter integer MOTION_SERVICE_CLKS", text)
- self.assertIn("parameter integer PHASE_FACTOR", text)
- self.assertIn("parameter integer CAL_RAMP_UNIT", text)
- if __name__ == "__main__":
- unittest.main()
|