pylab_ml.common.file_io.readtxtMemFile

readtxtMemFile(fileName, memSize=None, bitsize_source=None, bitsize_target=None, numerative=None, raw_data=False)[source]

Read a file with memory data in simple hex or integer format.

eg. readtxtMemFile(‘memory.txt’) will read the memory data from the file ‘memory.txt’ in text format and return the starting address and a list of memory data. The function will read the file line by line, parse the address and data values, and fill a list with the memory data. The function will also handle different bit sizes for the source and target data, and can return raw data if specified.

Parameters:
  • fileName (string) – The name of the text file containing memory data. The file should have lines in the format “address data”, where address and data can be in hex or decimal format.

  • memSize (int) – Size from the reserved memory array.

  • bitsize_source (int) – Size from one datum, eg. 8-bit, 16-bit, must be multiple times of 8 This has an effect on the address counting. If None, each datum will be assigned to an address, otherwise each 8-bit datum has an address. Only little endian is supported yet.

  • bitsize_target (int) – Size from one datum in the array result. Needed if negative values in the sourcefile.

  • numerative ({adr : base, dat : base}) – Base for interpreting addresses and data in text files, e.g. 10 for decimal, 16 for hex. If None then default is 10 for both.

  • raw_data (bool) – If True then return with a list of adr + data. If False then return with a coherent memory, beginning with startadr.

Returns:

  • int – minadr : The starting address of the memory data.

  • list – array : A list of memory data, with None entries for unused/initialized values. data : A list of tuples containing address and data pairs if raw_data is True, with None entries for unused/initialized values.