This makes a couple of changes to how the assembler works.

- Comments are removed earlier in the scanning, and do not have to be
  accounted for in later regex matches.
- Multiline instructions are allowed if the newline is escaped.
  - This is done to support cases where the target architecture is a VLIW
    where the instructions in one bundle may be spread over multiple lines.
- The class impelementing the OpcodeAssemblerInterface is responsible to
  add any symbols that occur on the same line(s) as instructions. Labels that
  occur on an unescaped line by itself will be handled by SimpleAssembler.
  - If the target ISA is a VLIW, the class implementing the
    OpcodeAssemblerInterface is responsible for breaking the multiple
    instructions up into separate strings and passing each such string to the
    corresponding "slot matcher".

PiperOrigin-RevId: 716315088
Change-Id: I25b0eb1fef92481f4a72c0b7bcec407b50543e1e
9 files changed
tree: 87fe53b8f7b6bdcaacd24abbe994123f67c7da0a
  1. .github/
  2. external/
  3. kokoro/
  4. mpact/
  5. .bazeliskrc
  6. .bazelrc
  7. .bazelversion
  8. .gitignore
  9. BUILD
  10. build.sh
  11. CODE_OF_CONDUCT.md
  12. CONTRIBUTING.md
  13. deps.bzl
  14. LICENSE
  15. protobuf_deps.bzl
  16. README.md
  17. repos.bzl
  18. SECURITY.md
  19. WORKSPACE
README.md

MPACT-Sim - Retargetable Instruction Set Simulator Infrastructure

MPACT-Sim is a toolkit that reduces the effort to create instruction set simulators, and make the resulting simulators easy to change and extend.

This repository contains the C++ code for MPACT-Sim, tools and library support for making it simple to create easily retargetable simulators for a wide range of instruction set architectures.

The toolkit consists of three major components. The first is the isa and binary decoder generators, that take in descriptors of the isa and the binary encoding of instructions and produce C++ code used in writing a decoder. The second is the generic classes that implement the instruction objects, registers, and other simulated state objects, and the code necessary to manipulate them, as well as supporting writing the semantics of the instructions. Lastly, there are utility classes that make it easier to put together a finished simulator, including memory classes and an ELF loader.

Building

Bazel

MPACT-Sim utilizes the Bazel build system. The easiest way to install bazel is to use Bazelisk, a wrapper for Bazel that automates selecting and downloading the right version of bazel. Use brew install bazelisk on macOS, choco install bazelisk on Windows, and on linux, download the Bazelisk binary, add it to your PATH, then alias bazel to the bazelisk binary.

You need to use bazel version >= 7.0 to build this project.

Java

MPACT-Sim depends on Java, so a reasonable JRE has to be installed. For macOS, run brew install java, on linux sudo apt install default-jre, and on Windows follow the appropriate instructions at java.com.

Build and Test

To build the mpact-sim libraries, use the command bazel build ...:all from the top level directory. To run the tests, use the command bazel test ...:all

Directory Listing

  • mpact/sim/decoder
    This directory contains the code that implements the tools that parse .isa and .bin_fmt files, which define the instructions and instruction encodings of an ISA, and generate C++ code for the instruction decoder for an MPACT-Sim simulator.

    The tools are built automatically and the process is largely invisible when using bazel with the appropriate build targets - see the tests in mpact/sim/decoder/test for examples.

  • mpact/sim/decoder/vscode
    This directory contains files necessary to build syntax highlighting extensions for VS Code for .isa and .bin_fmt files. Look in the mpact/sim/decoder/vscode/README.md file for directions.

  • mpact/sim/generic
    This directory contains all the generic classes provided for use in writing MPACT-Sim instruction set simulators.

  • mpact/sim/util
    This directory contains code for a generic ELF program loader, and for a set of classes that can be used to implement memories used in an instruction set simulator.