def residue(self):
        """Obtain the residual value left in the CRC register after processing a valid trailing CRC."""
        # Residue is computed by initialising to (possibly reflected) xor_output, feeding crc_width
        # worth of 0 bits, then taking the (possibly reflected) output without any XOR.
        if self._reflect_output:
            init = self._reflect(self._xor_output, self._crc_width)
        else:
            init = self._xor_output
        algo = self.algorithm
        algo.initial_crc = init
        algo.reflect_input = False
        algo.xor_output = 0
        return algo(self._crc_width).compute([0])
Obtain the residual value left in the CRC register after processing a valid trailing CRC.
amaranth/lib/crc/__init__.py