CDC/RDC crossing classification model — checker
Phase 7 Wave 4 Python 3 checker file.
Download original fileimport json
from pathlib import Path
d = json.loads(Path('starter.json').read_text())
allowed = {'single_bit': {'two_flop'}, 'pulse': {'toggle', 'handshake'}, 'bus': {'handshake', 'async_fifo'}, 'reset': {'async_assert_sync_release'}}
assert all(item['scheme'] in allowed[item['kind']] for item in d['crossings'])
assert any(item['kind'] == 'bus' and item['scheme'] == 'per_bit_sync' for item in d['unsafe'])
assert {item['kind'] for item in d['crossings']} == set(allowed)
print(f"PASS cdc_rdc safe={len(d['crossings'])} unsafe_detected={len(d['unsafe'])} classes={len(allowed)}")