Convert Figma logo to code with AI

riscv-software-src logoriscv-tools

RISC-V Tools (ISA Simulator and Tests)

1,141
446
1,141
107

Top Related Projects

GNU toolchain for RISC-V, including GCC

Spike, a RISC-V ISA Simulator

SonicBOOM: The Berkeley Out-of-Order Machine

The Ultra-Low Power RISC-V Core

Quick Overview

RISCV-tools is a collection of software development tools for the RISC-V instruction set architecture. It includes compilers, debuggers, simulators, and other essential tools for RISC-V software development and hardware design. This repository serves as a central hub for RISC-V toolchain development and maintenance.

Pros

  • Comprehensive suite of tools for RISC-V development
  • Regularly updated and maintained by the RISC-V community
  • Supports various RISC-V extensions and configurations
  • Facilitates both software and hardware development for RISC-V platforms

Cons

  • Complex setup process for newcomers
  • Large repository size due to multiple submodules
  • May require significant computational resources for full build
  • Documentation can be sparse or outdated for some components

Getting Started

To get started with RISCV-tools:

  1. Clone the repository and its submodules:

    git clone https://github.com/riscv-software-src/riscv-tools.git
    cd riscv-tools
    git submodule update --init --recursive
    
  2. Set up the build environment (example for Ubuntu):

    sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
    
  3. Build the toolchain:

    ./build.sh
    
  4. Add the built tools to your PATH:

    export PATH=$PATH:/path/to/riscv-tools/build/bin
    

Note: The build process can take several hours depending on your system. Ensure you have sufficient disk space and computational resources available.

Competitor Comparisons

GNU toolchain for RISC-V, including GCC

Pros of riscv-gnu-toolchain

  • More actively maintained with frequent updates
  • Focused specifically on GNU toolchain for RISC-V
  • Better documentation and build instructions

Cons of riscv-gnu-toolchain

  • Limited to GNU toolchain, less comprehensive than riscv-tools
  • May require more manual configuration for specific use cases
  • Potentially steeper learning curve for beginners

Code Comparison

riscv-gnu-toolchain:

./configure --prefix=/opt/riscv
make linux

riscv-tools:

git submodule update --init --recursive
export RISCV=/path/to/install/riscv/toolchain
./build.sh

The riscv-gnu-toolchain repository focuses on building the GNU toolchain for RISC-V, while riscv-tools is a more comprehensive collection of RISC-V software development tools. riscv-gnu-toolchain offers a more streamlined approach for those specifically interested in the GNU toolchain, while riscv-tools provides a broader set of tools but may require more setup and configuration.

Both repositories serve different purposes and cater to different user needs within the RISC-V ecosystem. The choice between them depends on the specific requirements of the project and the developer's familiarity with RISC-V tools.

Spike, a RISC-V ISA Simulator

Pros of riscv-isa-sim

  • Focused specifically on RISC-V instruction set simulation
  • Lighter weight and more modular
  • Easier to integrate into other projects

Cons of riscv-isa-sim

  • Less comprehensive toolchain compared to riscv-tools
  • May require additional components for a complete development environment
  • Limited to simulation, lacking some real hardware debugging features

Code Comparison

riscv-isa-sim (Spike):

void processor_t::step(size_t n)
{
  for (size_t i = 0; i < n; i++)
    step(1);
  update_histogram(n);
}

riscv-tools (GDB):

static void
riscv_software_single_step (struct regcache *regcache)
{
  struct gdbarch *gdbarch = regcache->arch ();
  CORE_ADDR pc = regcache_read_pc (regcache);
  CORE_ADDR next_pc = riscv_next_pc (regcache, pc);
  regcache_write_pc (regcache, next_pc);
}

The riscv-isa-sim code shows a simple stepping mechanism for the simulator, while the riscv-tools code demonstrates a more complex single-step implementation for debugging purposes.

SonicBOOM: The Berkeley Out-of-Order Machine

Pros of riscv-boom

  • Focuses on a specific RISC-V out-of-order core implementation
  • More actively maintained with frequent updates
  • Provides a complete SoC design for FPGA prototyping

Cons of riscv-boom

  • Narrower scope, limited to BOOM core and related components
  • Steeper learning curve for newcomers to out-of-order architectures
  • Requires more computational resources for simulation and synthesis

Code Comparison

riscv-boom:

class BoomCore(implicit p: Parameters) extends BoomModule()(p)
  with HasBoomCoreParameters
  with HasL1ICacheBankedParameters
{
  val io = IO(new BoomCoreIO)
  // Core implementation...
}

riscv-tools:

#define MSTATUS_UIE         0x00000001
#define MSTATUS_SIE         0x00000002
#define MSTATUS_HIE         0x00000004
#define MSTATUS_MIE         0x00000008
#define MSTATUS_UPIE        0x00000010

The riscv-boom code snippet shows a Scala class definition for the BOOM core, while the riscv-tools example displays C preprocessor definitions for RISC-V status register bits. This highlights the different focus areas of the two projects: riscv-boom on core implementation and riscv-tools on software development support.

The Ultra-Low Power RISC-V Core

Pros of e203_hbirdv2

  • Specifically designed for MCU applications, offering a more focused and optimized solution
  • Includes a complete SoC design with peripherals, making it easier to implement in embedded systems
  • Provides FPGA bitstreams and demo projects, enabling quick prototyping and testing

Cons of e203_hbirdv2

  • Less comprehensive toolchain support compared to riscv-tools
  • Limited to a specific core implementation, reducing flexibility for different RISC-V configurations
  • Smaller community and potentially less frequent updates

Code Comparison

e203_hbirdv2:

module e203_cpu_top (
  input  clk,
  input  rst_n,
  // Other ports...
);
  // CPU implementation
endmodule

riscv-tools:

#define REGBYTES 8
#define STORE sd
#define LOAD ld

.macro SAVE_GP
  addi sp, sp, -32*REGBYTES
  STORE x1, 1*REGBYTES(sp)
  // More register saves...
.endm

The e203_hbirdv2 code snippet shows the top-level module of the CPU implementation in Verilog, while the riscv-tools example demonstrates assembly macros for context saving, highlighting the different focus areas of these projects.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

riscv-tools Build Status

This repository houses a set of RISC-V simulators and other tools, including the following projects:

  • Spike, the ISA simulator
  • riscv-tests, a battery of ISA-level tests
  • riscv-opcodes, the enumeration of all RISC-V opcodes executable by the simulator
  • riscv-pk, which contains bbl, a boot loader for Linux and similar OS kernels, and pk, a proxy kernel that services system calls for a target-machine application by forwarding them to the host machine

Several RISC-V tools that were previously maintained through this repository have since been upstreamed to their parent projects and are no longer included here. Your favorite software distribution should already have packages for these upstream tools, but if it doesn't then here are a handful of my favorites:

  • Your favorite software distribution may already have packages that include a RISC-V cross compiler, which is probably the fastest way to get started. As of writing this README (March, 2019) I can trivially find packages for ALT Linux, Arch Linux, Debian, Fedora, FreeBSD, Mageia, OpenMandriva, openSUSE, and Ubuntu. pkgs.org appears to be a good place to find an up to date list, just search for "riscv".
  • crosstool-ng can build RISC-V cross compilers of various flavors.
  • The RISC-V Port of OpenEmbedded builds a cross compiler, Linux kernel, and enough of userspace to do many interesting things.
  • buildroot is a lighter weight cross compiled Linux distribution.

This repository uses crosstool-ng to configure a riscv64-unknown-elf toolchain.

Quickstart

$ git submodule update --init --recursive
$ export RISCV=/path/to/install/riscv/toolchain
$ ./build.sh

Ubuntu packages needed:

$ sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev libusb-1.0-0-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev device-tree-compiler pkg-config libexpat-dev

Fedora packages needed:

$ sudo dnf install autoconf automake @development-tools curl dtc libmpc-devel mpfr-devel gmp-devel libusb-devel gawk gcc-c++ bison flex texinfo gperf libtool patchutils bc zlib-devel expat-devel

Note: This requires a compiler with C++11 support (e.g. GCC >= 4.8). To use a compiler different than the default, use:

$ CC=gcc-5 CXX=g++-5 ./build.sh

Note for OS X: We recommend using Homebrew to install the dependencies (libusb dtc gawk gnu-sed gmp mpfr libmpc isl wget automake md5sha1sum) or even to install the tools directly. This repo will build with Apple's command-line developer tools (clang) in addition to gcc.