"""Fixed AdvSIMD FP8 conversion layouts and complete-state mathematical cases. Numerical expectations use the independent Fraction model in fp8.py. Original execution is supplied separately by the FPMR-enabled architectural observer. """ from dataclasses import replace import struct import scalable_frame as frame from simd_fixtures import fp8 ENCODINGS = ( ('BF1CVTL_asimdmisc_V', 0x2ea17800, 'bfloat16', True, False), ('BF2CVTL_asimdmisc_V', 0x2ee17800, 'bfloat16', True, True), ('F1CVTL_asimdmisc_V', 0x2e217800, 'half', True, False), ('F2CVTL_asimdmisc_V', 0x2e617800, 'half', True, True), ('FCVTN_asimdsame2_D', 0x0e40f400, 'half', False, False), ('FCVTN_asimdsame2_H', 0x0e00f400, 'single', False, False), ) Q = 1 << 30 REQUIRED = (frame.Component.PRIMARY | frame.Component.SVCR | frame.Component.TPIDR2 | frame.Component.FPMR) def decode(word): for encoding in ENCODINGS: mask = 0xbffffc00 if encoding[3] else 0xbfe0fc00 if word & mask == encoding[1]: return encoding, word & 31, word >> 5 & 31, word >> 16 & 31, bool(word & Q) return None def execute(word, initial, *, full_a64=False): decoded = decode(word) if decoded is None: raise ValueError('outside allocated fixed FP8 conversions') encoding, destination, source, second, q = decoded if initial.valid & (frame.Component.PRIMARY | frame.Component.FPMR) != ( frame.Component.PRIMARY | frame.Component.FPMR): raise ValueError('fixed FP8 requires explicit FPMR and primary state') if initial.control('svcr') & frame.SVCR_SM and not full_a64: raise ValueError('fixed AdvSIMD in streaming mode requires FullA64') _, _, format_, widening, source2 = encoding primary = bytearray(initial.primary) fpcr, fpsr = struct.unpack_from('