gem5 Documentation

repository·stable·Indexed 25 days ago

https://github.com/gem5/gem5

A modular platform for computer-system architecture research supporting system-level architecture and processor microarchitecture. It is used to evaluate hardware designs, system software, and system optimizations. The repository includes documentation for building RISCV binaries, using LupIO devices, and integrated external tools such as DRAMPower for memory power analysis and GoogleTest/GoogleMock for system testing.

Tokens
135K
Snippets
318
Records
736
Agent score
83%

What's inside gem5

  1. Overview of pyfdt capabilities

    stable

    pyfdt is a Python library for manipulating Flattened Device Trees (FDT), heavily based on fdtdump.

    Supported Inputs

    • Device Tree Blob (.dtb)
    • Filesystem
    • JSON

    Supported Outputs

    • Device Tree Blob (DTB)
    • Device Tree Structure (text DTS)
    • JSON

    Core Functionalities

    • Node/Attribute Manipulation: Add, delete, or pop nodes and attributes; create attributes dynamically using native Python types.
    • Tree Traversal: Walk through the tree and resolve/generate paths.
    • Parsing/Generation: Parse from DTB or filesystem; output to DTB, DTS, or JSON.
    • Tree Operations: Compare two trees or merge two trees.
    • Filesystem Integration: The Device Tree filesystem 'output' can be accessed via the fusemount.py FUSE sample using the fusepy library.
  2. Overview of the Googletest Mocking (gMock) Framework

    stable

    gMock is a C++ framework for writing and using mock classes to improve system design and testing. It provides a declarative syntax for defining mocks and supports several advanced testing patterns:

    • Partial (hybrid) mocks: A combination of real and mock objects.
    • Function handling: Supports functions of arbitrary types and overloaded functions.
    • Argument validation: Includes a rich set of matchers for validating function arguments.
    • Behavior control: Uses intuitive syntax to control mock behavior.
    • Automatic verification: Automatically verifies expectations without requiring manual record-and-replay.
    • Ordering constraints: Allows expressing arbitrary (partial) ordering constraints on function calls.
    • Extensibility: Users can define new matchers and actions.
    • Exception safety: Does not use exceptions.

    Note: gMock is part of the GoogleTest C++ testing framework and is subject to its requirements.

  3. Overview of the gem5 source tree

    stable

    The gem5 repository is organized into several key directories:

    • build_opts: Pre-made default configurations for gem5 builds.
    • build_tools: Internal tools used by the build process.
    • configs: Example simulation configuration scripts.
    • ext: External packages required for the build.
    • include: Header files for use in other programs.
    • site_scons: Modular components of the SCons build system.
    • src: The core simulator source code, including C++ source, Python wrappers, and the Python standard library.
    • system: Source for optional system software used in simulations.
    • tests: Regression tests.
    • util: Utility programs and files.
  4. Overview of pybind11

    stable
    pybind11 is a lightweight, header-only C++ library designed to create seamless Python bindings for existing C++ code. It uses compile-time introspection to minimize boilerplate, making it a compact alternative to Boost.Python. It is highly efficient, utilizing C++11 move semantics and constexpr for precomputing function signatures, which results in smaller binaries and faster compile times.
  5. Overview of the gem5 SystemC redistribution

    stable

    The /ext/systemc directory contains a custom redistribution of the Accellera SystemC 2.3.1 library. This version is specifically modified for use with gem5 in the following ways:

    • Build System: Replaces the standard Accellera Autoconf build system with the SCons build system used by gem5.
    • Dependencies: Boost library dependencies have been stripped out and replaced with calls to the C++11 STL to simplify integration.
    • Included Tools: Includes the TLM 2.0 protocol-checker from Doulos.
    • Licensing: Uses the Apache2.0 license (compatible with gem5).
  6. Overview of GoogleTest

    stable

    GoogleTest is a C++ testing framework that includes both GoogleTest and GoogleMock. It provides an xUnit-style framework with features such as:

    • Test discovery: Automatically finding tests in your code.
    • Assertions: A rich set of built-in assertions and support for user-defined assertions.
    • Test Types: Support for death tests, value-parameterized tests, and type-parameterized tests.
    • Failure Modes: Support for both fatal and non-fatal failures.
    • Reporting: XML test report generation.
    • Execution Options: Various options for running tests.
  7. Interact with simulated serial ports using gem5 Terminal Clients

    stable

    The gem5 Terminal Client allows you to interact with a simulated system's serial port. This is used for debugging operating systems, interacting with console applications, monitoring boot messages, and sending commands to the simulated system.

    There are two implementations available:

    • term.c: The original C implementation.
    • gem5term: A Python implementation with identical functionality.

    Important Note on Reproducibility: Do not use the terminal client to run experiments, as it is intended for interactive use only. For reproducible experiments, use a workload object with a runscript that is executed as part of the simulation.

  8. Understand the constraints of the pybind11 conduit directory

    stable
    The C++ code within the ext/pybind11/include/pybind11/conduit/ directory is designed to be highly portable. It depends only on <Python.h> and has no other external dependencies. When adding code to this directory, ensure you do not introduce any other external dependencies to maintain this property.
  9. Verify GoogleTest platform compatibility

    stable

    To use GoogleTest, your environment must meet the following minimum requirements:

    • C++ Standard: The codebase and compiler must be compliant with C++11 or newer.
    • Operating Systems: Officially supported on Linux, macOS, and Windows. Other platforms are community-supported.
    • Compilers:
      • gcc: 5.0 or newer
      • clang: 5.0 or newer (Note: Xcode 9.3+ on macOS provides clang 5.0+)
      • MSVC: 2015 or newer
    • Build Systems:
      • Bazel: Officially supported and used internally.
      • CMake: Supported on a best-effort/community basis.
  10. Understand gMock concepts and terminology

    stable

    gMock is a C++ library for creating mock objects to test interactions between modules. It is important to distinguish between Fakes and Mocks:

    • Fake objects: Have working implementations but use shortcuts (e.g., an in-memory file system) to be faster or simpler than production versions.
    • Mock objects: Are pre-programmed with expectations. They act as a specification of the calls they expect to receive (method names, order, frequency, arguments, and return values).

    Use gMock to:

    • Remove unnecessary dependencies (databases, networks).
    • Test how code handles specific failures (e.g., checksum errors).
    • Verify interactions between modules without observing side effects.
  11. Understand Googletest terminology

    stable

    Be aware of the distinction between Googletest terms and standard ISTQB terminology to avoid confusion:

    • TEST(): In Googletest, this is a single test. In ISTQB, this corresponds to a Test Case.
    • TestSuite: In Googletest, this is a group of related tests. Historically, Googletest used the term TestCase for this, but TestSuite is now the preferred API and term.

    Always use the TestSuite nomenclature when grouping related tests to align with current Googletest best practices.