| 12345678910111213141516171819202122232425262728 |
- """Passive CT diagnostics against actual I2C pins, at production bus timing."""
- import pytest
- from pathlib import Path
- import shutil
- import subprocess
- ROOT = Path(__file__).resolve().parents[2]
- @pytest.mark.parametrize("bench, marker", [("ct7428_diagnostics_tb", "36 external-pin reads"), ("ct7428_status_registers_tb", "28 external-pin reads")])
- def test_ct_diagnostics_success_nack_stuck_recovery(tmp_path, bench, marker):
- sources = [
- 'src/rtl/prod2u_p4_i2c_stop_start_read.v',
- 'src/modules/i2c_word_reader.v',
- 'src/acquisition/ct7428_scan.v',
- 'tests/sim/ct7428_normal_slave_bfm.v',
- f'tests/sim/{bench}.v',
- ]
- assert shutil.which('iverilog') and shutil.which('vvp'), 'Icarus tools required'
- executable = tmp_path / 'ct_diag.vvp'
- compile_result = subprocess.run(
- ['iverilog', '-g2012', '-Wall', '-s', bench, '-o', str(executable), *sources],
- cwd=ROOT, text=True, capture_output=True, timeout=30)
- assert compile_result.returncode == 0, compile_result.stdout + compile_result.stderr
- result = subprocess.run(['vvp', str(executable)], cwd=ROOT, text=True,
- capture_output=True, timeout=30)
- assert result.returncode == 0, result.stdout + result.stderr
- assert f'PASS {bench}: {marker}' in result.stdout
|