Simics contains an embedded Python interpreter, and in Simics 6 this has been upgraded to Python 3.7.
In general, Python 2.7 code is not compatible with Python 3, so a
porting effort is required. Python provides a tool 2to3 which
converts source code from Python 2.7 syntax to Python 3 syntax. It
applies textual transformations, and this can also be done
selectively, to e.g. only apply transformations that maintain 2.7
compatibility.
As a start to the porting work, study official Python documentation where an overview of the new features in Python 3 is provided.
When building a Simics module, any Python source files (listed with
the PYTHON_FILES variable in the module Makefile) will be
built into .pyc files for Python 3. By setting the
variable PYTHON_2TO3 to 1 in the module Makefile,
the .py files are first converted to Python 3 syntax by
running the Python 2to3 tool, before being compiled for
Python 3. When loading the module, the respective Simics version will
use the corresponding .pyc files automatically.
The migration process can be as follows:
2to3 tool to convert all source code to Python
3 syntax.2to3 tool occasionally
makes mistakes).