项目作者: ultraembedded

项目描述 :
Instruction accurate instruction set simulator for RISC-V, MIPS and ARM-v6m
高级语言: C++
项目地址: git://github.com/ultraembedded/exactstep.git
创建时间: 2019-10-21T20:40:07Z
项目社区:https://github.com/ultraembedded/exactstep

开源协议:BSD 3-Clause "New" or "Revised" License

下载


ExactStep - Instruction Accurate Instruction Set Simulator

Build

Github: https://github.com/ultraembedded/exactstep

ExactStep is a simple multi-target instruction set simulator supporting RISC-V (RV32IMAC, RV64IMAC), MIPS (mips-i), and ARM-v6m (with others to come soon).
The emphasis of this project is on ease of extension, allowing its use as a library for cosimulation, peripheral development and System-C bus interfacing, rather than on raw execution performance.

Unlike QEMU and other CPU emulators which make use of dynamic binary translation, ExactStep executes one instruction per call to cpu::step().

Cloning

  1. git clone https://github.com/ultraembedded/exactstep.git

Building

This project uses make and ELF, BFD, FDT libraries.

If you are using a Debian based Linux distro (Ubuntu / Linux Mint), you can install the required dependencies using;

  1. sudo apt-get install libelf-dev binutils-dev libfdt-dev

To build the default command line simulator and RISC-V Linux simulators;

  1. cd exactstep
  2. make

ExactStep: Usage

exactstep supports various emulated CPU architectures (RISC-V, MIPS, ARM), and is used to run bare-metal executables compiled for those ISAs;

  1. ./exactstep
  2. Usage:
  3. --elf | -f FILE File to load (ELF or BIN)
  4. --march | -m MISA Machine variant (e.g. RV32IMAC, RV64I, armv6, mips, ...)
  5. --platform | -P PLATFORM Platform to simulate (basic|virt)
  6. --dtb | -D FILE Device tree blob (binary)
  7. --trace | -t 1/0 Enable instruction trace
  8. --trace-mask | -v 0xXX Trace mask (verbosity level)
  9. --cycles | -c NUM Max instructions to execute
  10. --stop-pc | -r PC Stop at PC address
  11. --trace-pc | -e PC Trace from PC address
  12. --elf-phys | -E Load to ELF section to physical addresses (suitable for bootloaders)
  13. --mem-base | -b VAL Memory base address (for binary loads)
  14. --mem-size | -s VAL Memory size (for binary loads)
  15. --dump-file | -p FILE File to dump memory contents to after completion
  16. --dump-start | -j SYM/A Symbol name for memory dump start (or 0xADDR)
  17. --dump-end | -k SYM/A Symbol name for memory dump end (or 0xADDR)
  18. --dump-reg-f | -R FILE File to dump register file contents to after completion
  19. --dump-reg-s | -S NUM Number of register file entries to dump
  20. --vda | -V FILE Disk image for VirtIO block device (/dev/vda)
  21. --tap | -T TAP Tap device for VirtIO net device

The default architecture is a RV32IMAC CPU model. To run a basic ELF;

  1. ./exactstep -f your_elf.elf

Exactstep-riscv-linux: Usage

exactstep-riscv-linux is a RISC-V (32-bit or 64-bit) specific simulator which contains a built-in SBI (Supervisor Binary Interface) implementation that enables booting RISC-V Linux kernels compiled for supervisor mode.
Root filesystems can also be provided by initrd, VirtIO block device, or VirtIO network (nfs) boot.

  1. ./exactstep-riscv-linux
  2. Usage:
  3. --elf | -f FILE File to load (ELF)
  4. --bin | -b FILE File to load (binary)
  5. --march | -m MISA Machine variant (e.g. RV32IMAC, RV64I, ...)
  6. --platform | -P PLATFORM Platform to simulate (basic|virt)
  7. --dtb | -D FILE Device tree blob (binary)
  8. --dtb-base | -B 0xaddr Device tree blob load address
  9. --trace | -t 1/0 Enable instruction trace
  10. --trace-mask | -v 0xXX Trace mask (verbosity level)
  11. --cycles | -c NUM Max instructions to execute
  12. --stop-pc | -r PC Stop at PC address
  13. --trace-pc | -e PC Trace from PC address
  14. --vda | -V FILE Disk image for VirtIO block device (/dev/vda)
  15. --tap | -T TAP Tap device for VirtIO net device
  16. --initrd | -i FILE initrd binary (optional)

Example usage (with a device tree compiled to a DTB file using the Linux Kernel dtc util);

  1. ./exactstep-riscv-linux --elf ./vmlinux-rv32ima-5.0 --dtb ./config.dtb --initrd ./initrd.cpio

Running RISC-V Compliance Tests

ExactStep passes the RISC-V Compliance Tests for the rv32i, rv32im, rv32imc, rv64i, rv64im categories;

  1. # Get compliance test suite
  2. git clone https://github.com/ultraembedded/riscv-compliance.git
  3. cd riscv-compliance
  4. # Set path to built exactstep executable
  5. export TARGET_SIM=/path/to/github/exactstep/exactstep
  6. # Run test suite
  7. make RISCV_TARGET=exactstep

Running RISC-V Linux

  1. # Get prebuilt bootloader + kernel + rootfs images
  2. git clone https://github.com/ultraembedded/riscv-linux-prebuilt.git
  3. cd riscv-linux-prebuilt
  4. # Boot Linux (with Busybox userspace)
  5. exactstep --march RV64IMAC --elf opensbi-kernel-busybox/qemu-virt-rv64-5.4-rc7-busybox-1.32.0.elf --dtb opensbi-kernel-busybox/qemu-virt-rv64-config.dtb

License

BSD 3-Clause