Source Code

From gem5
Jump to: navigation, search

Source Browsing Tools

The gem5 source code is browsable online via several methods. You can browse the latest version or the developmen history in our Mercurial repository, search the code using our OpenGrok installation, or look at the Doxygen-generated documentation (note that the class list is perhaps the most useful starting point).

Once you have your own local copy of the tree, you use other tools to index and search that copy. Many gem5 developers use cscope, and have included a script in util/ to generate a cscope index.

Tour of the tree

  • AUTHORS - A list of people who have historically contributed to gem5.
  • LICENSE - The license terms that apply to gem5 as a whole, unless overridden by a more specific license.
  • README - Some very basic information introducing gem5 and explaining how to get started.
  • SConstruct - A part of the build system, as is the build_opts directory.
  • build_opts - holds files that define default settings for build different build configurations. These include X86_FS and MIPS_SE, for instance.
  • configs - Simulation configuration scripts which are written in python, described in more detail later. The files in this directory help make writing configurations easier by providing some basic prepackaged functionality, and include a few examples which can be used directly or as a starting point for your own scripts.
  • ext - Things gem5 depends on but which aren’t actually part of gem5. Specifically, dependencies that are harder to find, not likely to be available, or where a particular version is needed.
  • src - gem5 source code.
    • arch - ISA implementations.
      • generic - Common files for use in other ISAs.
      • - Parser that interprets ISA descriptions.
      • ISA directories - The files associated with the given ISA.
        • OS directories - Code for supporting an ISA/OS combination, generally in SE mode.
        • isa - ISA description files.
    • base - General data structures and facilities that could be useful for another project.
      • loader - Code for loading binaries and reading symbol tables.
      • stats - Code for keeping statistics and writing the data to a file or a database.
      • vnc - VNC support.
    • cpu - CPU models.
    • dev - Device models.
      • ISA directories - Device models specific to the given ISA
    • doxygen - Doxygen templates & output
    • kern - Operating system specific but architecture independent code (e.g. types of data structures).
      • OS directories - Code specific to the given simulated operating system.
    • mem - Memory system models and infrastructure.
      • cache - Code that implements a cache model in the classic memory system.
      • ruby - Code that implements the ruby memory model.
      • protocol - Ruby protocol definitions.
      • slicc - The slicc compiler.
    • python - Python code for configuration and higher level functions.
    • sim - Code that implements basic, fundamental simulator functionality.
  • system - Low level software like firmware or bootloaders for use in simulated systems.
    • alpha - Alpha console and palcode.
    • arm - A simple ARM bootloader.
  • tests - Files related to gem5’s regression tests.
    • configs - General configurations used for the tests.
    • test-progs - "Hello world" binaries for each ISA, other binaries are downloaded separately.
    • quick, long - Quick and long regression inputs, reference outputs, and test specific configuration files, arranged per test.
  • util - Utility scripts, programs and useful files which are not part of the gem5 binary but are generally useful when working on gem5.

Style rules

All of the code in gem5 is expected to follow a set rules described in our style guide. These rules make the code more consistent which make it easier to read, maintain, and extend the code. Specific coding style has been defined for things such as Indentation and Line Breaks , Spacing, Naming of Variables & Classes, and M5 Status Messages. There are also Documentation Guidelines which you should follow which allow documentation to be generated automatically using the Doxygen system.

Generated files - where do they end up

.m5 config files

If you would like to set some gem5 parameters to a value by default you can create a .m5 directory within your home directory and inside place a file called Within this file you may set any gem5 command line option to a new default. For example placing options.stdout_file=simout in will result in the simulators stdout always being re-directed to a file named simout.

jobfile to run multiple jobs