pylab_ml.common.file_io.readMemFile

readMemFile(filename, typ=None, interpret=None)[source]

Read a memory file in the specified format (verilog, txt, or QEMem).

eg. readMemFile(‘memory.txt’, typ=’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 determine the type of the memory file based on the file extension if the ‘typ’ parameter is not provided. It will then call the appropriate function to read the memory data based on the determined type (verilog, txt, or QEMem). The function will return the starting address and a list of memory data, with None entries for unused/initialized values.

Parameters:
  • filename (str) – The name of the memory file to read.

  • typ (str, optional) – The type of the memory file (e.g., ‘verilog’, ‘txt’, ‘QEMem’). If None, the type will be determined based on the file extension. Default is None.

  • interpret (dict, optional) – A dictionary with keys ‘adr’ and ‘dat’ to specify the base for interpreting addresses and data in text files. Default is None.

Returns:

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

  • list – data : A list of memory data, with None entries for unused/initialized values.