Skip to content

RISC-V Overview

RISC-V is an open Instruction Set Architecture (ISA) based on the principles of Reduced Instruction Set Computing (RISC)

It defines how software communicates with the processor through:

  • machine instructions
  • registers
  • memory

ÆRIS implements the RV32I set, which is the base integer set of the RISC-V architecture and represents the most common starting point for learning the architecture


The simulator implements RV32I, the base integer set of the RISC-V architecture

PropertyValue
Word size32 bits
Register width32 bits
Number of registers32
Instruction size32 bits
Instruction setBase integer

The RV32I set includes instructions for:

  • arithmetic operations
  • memory access
  • conditional branches
  • jumps
  • system calls

RISC-V defines 32 general-purpose registers:

x0 - x31

Each register stores a 32-bit value

In addition to the numeric name, many registers have ABI names, which indicate their conventional use

RISC-V Registers

RegisterABI NameTypical Use
x0zeroconstant zero
x1rareturn address
x2spstack pointer
x3gpglobal pointer
x4tpthread pointer
x5–x7t0–t2temporaries
x8–x9s0–s1saved registers
x10–x17a0–a7function arguments
x18–x27s2–s11saved registers
x28–x31t3–t6temporaries

All RV32I instructions are 32 bits, but the internal organization of these bits depends on the instruction format

The main formats are:

FormatPurpose
R-typeoperations between registers
I-typeoperations with immediate and loads
S-typestores
B-typeconditional branches
U-typeupper immediate
J-typejumps

Instruction Formats

Each format positions the instruction fields in different locations within the 32-bit word

Common fields include:

  • opcode
  • source registers
  • destination register
  • immediate

The Program Counter (PC) stores the address of the current instruction

Normally:
PC = PC + 4

This happens because each instruction occupies 4 bytes.

Branch and jump instructions modify the value of the PC to change the program execution flow


The ecall instruction allows the program to request services from the execution environment

In ÆRIS, syscalls are used to interact with the console

Example:

li a7, 1
li a0, 42
ecall

This code prints the integer stored in a0