restorePortableExecutionImage method

void restorePortableExecutionImage(
  1. String image
)

Restores a compatible portable execution image at the same clock phase.

Implementation

void restorePortableExecutionImage(String image) {
  _requirePortableBoundary();
  final lineEnd = image.indexOf('\n');
  if (lineEnd < 0) {
    throw const FormatException('Invalid CSR execution image.');
  }
  final header = image.substring(0, lineEnd).trim().split(RegExp(r'\s+'));
  if (header.length != 4 ||
      header[0] != 'RHCL_CSR_EXEC_V1' ||
      header[1] != description.portableExecutionIdentity ||
      (header[2] != '0' && header[2] != '1') ||
      (header[3] != '0' && header[3] != '1')) {
    throw const FormatException('Invalid CSR execution image header.');
  }
  if (header[2] != '${_clk.value.toInt()}') {
    throw StateError('CSR execution image clock phase does not match.');
  }
  restorePortableSnapshot(image.substring(lineEnd + 1));
  _resetSeen = header[3] == '1';
}