Difference between revisions of "Defining CPU Models (as of M5 2.0 - beta 3)"

From gem5
Jump to: navigation, search
(Making M5 Recognize MyCPU)
Line 8: Line 8:
  
 
== Making M5 Recognize MyCPU ==
 
== Making M5 Recognize MyCPU ==
'''After you create a separate directory for your code (e.g. 'm5/src/cpu/my_cpu'), there are a couple files that need to be updated:'''
+
'''After you create a separate directory for your code (e.g. 'm5/src/cpu/mycpu'), there are a couple files that need to be updated:'''
*'''''m5/SConstruct''''': Add the name of your CPU model to the 'ALL_CPU_LIST'  
+
*'''''m5/SConstruct''''': Add the name of your CPU model (MyCPU) to the 'ALL_CPU_LIST'  
  
 
*'''''m5/src/cpu/SConscript''''': Add your CPU model and the relevant files that need to be built in here
 
*'''''m5/src/cpu/SConscript''''': Add your CPU model and the relevant files that need to be built in here
Line 17: Line 17:
 
*'''''m5/src/cpu/cpu_models.py''''': Add in CPU Model-specific information for the ISA Parser. The ISA Parser will use this when referring to the "Execution Context" for executing instructions. For instance, the AtomicSimpleCPU's instructions get all of their information from the actual CPU (since it's a 1 CPI machine). Thus, instructions only need to know the current state or "Execution Context" of the 'AtomicSimpleCPU' object. However, the instructions in a O3CPU needed to know the register values (& other state) only known to that current instruction so it's "Execution Context" is the O3DynInst object. (check out the [[The M5 ISA description language | ISA Description Language documentation]] page for more details)  
 
*'''''m5/src/cpu/cpu_models.py''''': Add in CPU Model-specific information for the ISA Parser. The ISA Parser will use this when referring to the "Execution Context" for executing instructions. For instance, the AtomicSimpleCPU's instructions get all of their information from the actual CPU (since it's a 1 CPI machine). Thus, instructions only need to know the current state or "Execution Context" of the 'AtomicSimpleCPU' object. However, the instructions in a O3CPU needed to know the register values (& other state) only known to that current instruction so it's "Execution Context" is the O3DynInst object. (check out the [[The M5 ISA description language | ISA Description Language documentation]] page for more details)  
  
*'''''m5/src/python/objects/my_cpu.py''''': Create a python file (e.g. MyCPU.py) so that your CPU can be recognized as a simulation object. A good example to follow is the file 'O3CPU.py'.
+
*'''''m5/src/python/objects/MyCPU.py''''': Create a python file (e.g. MyCPU.py) so that your CPU can be recognized as a simulation object. A good example to follow is the file 'O3CPU.py'.
  
 
*'''''m5/src/python/objects/__init__.py''''': Add the base name of your python file into the 'file_bases' list.
 
*'''''m5/src/python/objects/__init__.py''''': Add the base name of your python file into the 'file_bases' list.

Revision as of 14:45, 18 May 2007

Overview

First, make sure you have basic understanding of how the CPU models function within the M5 framework. A good start is the CPU Models page.

Create Files for MyCPU

The easiest way is to derive a new C++ class of your CPU Model from M5 CPU Models that are already defined and the easiest model to start with is probably the 'AtomicSimpleCPU' located in the 'm5/src/cpu/simple' directory.

For example, one could copy the files from the 'm5/src/cpu/simple' and place them in their own CPU directory: m5/src/cpu/mycpu.

Making M5 Recognize MyCPU

After you create a separate directory for your code (e.g. 'm5/src/cpu/mycpu'), there are a couple files that need to be updated:

  • m5/SConstruct: Add the name of your CPU model (MyCPU) to the 'ALL_CPU_LIST'
  • m5/src/cpu/SConscript: Add your CPU model and the relevant files that need to be built in here
  • m5/src/cpu/static_inst.hh: Put a forward class declaration of your model in here
  • m5/src/cpu/cpu_models.py: Add in CPU Model-specific information for the ISA Parser. The ISA Parser will use this when referring to the "Execution Context" for executing instructions. For instance, the AtomicSimpleCPU's instructions get all of their information from the actual CPU (since it's a 1 CPI machine). Thus, instructions only need to know the current state or "Execution Context" of the 'AtomicSimpleCPU' object. However, the instructions in a O3CPU needed to know the register values (& other state) only known to that current instruction so it's "Execution Context" is the O3DynInst object. (check out the ISA Description Language documentation page for more details)
  • m5/src/python/objects/MyCPU.py: Create a python file (e.g. MyCPU.py) so that your CPU can be recognized as a simulation object. A good example to follow is the file 'O3CPU.py'.
  • m5/src/python/objects/__init__.py: Add the base name of your python file into the 'file_bases' list.

Building MyCPU

Now build your model:

scons build/ALPHA_SE/m5.debug CPU_MODELS=MY_CPU

If you have dual-core CPU use this to speed-up the compilation:

scons -j2 build/ALPHA_SE/m5.debug CPU_MODELS=MY_CPU


Creating Configuration Options For MyCPU

Create and edit configuration files for your model:

  • m5/configs/test/MyCPUConfig.py: Define a configuration class w/corresponding parameters for your model. Look to 'FullO3Config.py' in the same directory for an example of how to do this.
  • m5/configs/test/test.py: Import your model's configuration at the top of the file (i.e. 'import MyCPUConfig') and add in a parser option for your CPU model (e.g. '--my_cpu').


Testing MyCPU

Test your model:

build/ALPHA_SE/m5.debug configs/example/se.py --my_cpu --cmd=<bin_path>