Convert Figma logo to code with AI

lowRISC logoibex

Ibex is a small 32 bit RISC-V CPU core, previously known as zero-riscy.

1,331
515
1,331
208

Top Related Projects

SonicBOOM: The Berkeley Out-of-Order Machine

Rocket Chip Generator

A FPGA friendly 32 bit RISC-V CPU implementation

2,205

The CORE-V CVA6 is an Application class 6-stage RISC-V CPU capable of booting Linux

1,103

Source files for SiFive's Freedom platforms

Quick Overview

Ibex is an open-source, 32-bit RISC-V CPU core written in SystemVerilog. Developed by lowRISC, it is designed for embedded systems and IoT applications, offering a balance between performance, power efficiency, and area usage.

Pros

  • Open-source and highly customizable
  • Supports the RISC-V ISA, which is gaining popularity in the industry
  • Suitable for a wide range of applications, from simple microcontrollers to more complex embedded systems
  • Well-documented and actively maintained by the lowRISC community

Cons

  • May require specialized knowledge in hardware design and SystemVerilog
  • Performance may be limited compared to more advanced commercial CPU cores
  • Ecosystem and toolchain support may not be as mature as established architectures like ARM

Code Examples

As Ibex is a hardware design project written in SystemVerilog, it doesn't have typical software code examples. However, here are a few snippets from the Ibex codebase to illustrate its structure:

  1. Module declaration for the Ibex core:
module ibex_core #(
  parameter bit          PMPEnable         = 1'b0,
  parameter int unsigned PMPGranularity    = 0,
  parameter int unsigned PMPNumRegions     = 4,
  parameter int unsigned MHPMCounterNum    = 0,
  parameter int unsigned MHPMCounterWidth  = 40,
  parameter bit          RV32E             = 1'b0,
  parameter bit          RV32M             = 1'b1,
  parameter bit          RV32B             = 1'b0,
  parameter bit          BranchTargetALU   = 1'b0,
  parameter bit          WritebackStage    = 1'b0,
  parameter bit          ICache            = 1'b0,
  parameter bit          ICacheECC         = 1'b0,
  parameter bit          BranchPredictor   = 1'b0,
  parameter bit          DbgTriggerEn      = 1'b0,
  parameter int unsigned DbgHwBreakNum     = 1,
  parameter bit          SecureIbex        = 1'b0,
  parameter int unsigned DmHaltAddr        = 32'h1A110800,
  parameter int unsigned DmExceptionAddr   = 32'h1A110808
) (
  // Clock and Reset
  input  logic        clk_i,
  input  logic        rst_ni,

  // ... (other port declarations)
);
  1. Instantiation of the ALU module:
  ibex_alu #(
    .RV32B(RV32B)
  ) alu_i (
    .operator_i         (alu_operator),
    .operand_a_i        (alu_operand_a),
    .operand_b_i        (alu_operand_b),
    .instr_first_cycle_i(alu_instr_first_cycle),
    .imd_val_q_i        (imd_val_q),
    .imd_val_d_o        (imd_val_d),
    .imd_val_we_o       (imd_val_we),
    .result_o           (alu_result),
    .comparison_result_o(alu_cmp_result),
    .is_equal_result_o  (alu_is_equal_result)
  );
  1. Control and Status Register (CSR) read logic:
  always_comb begin
    csr_rdata = '0;
    illegal_csr_insn_o = 1'b0;

    unique case (csr_addr_i)
      // Machine Status
      CSR_MSTATUS: begin
        csr_rdata = {
          14'b0,
          mstatus_q.mprv,
          4'b0,
          mstatus_q.mpp,
          3'b0,
          mst

Competitor Comparisons

SonicBOOM: The Berkeley Out-of-Order Machine

Pros of riscv-boom

  • Higher performance: Out-of-order superscalar design for better IPC
  • More advanced features: Branch prediction, speculative execution, etc.
  • Scalable: Configurable pipeline depth and issue width

Cons of riscv-boom

  • Higher complexity: More difficult to understand and modify
  • Increased area and power consumption
  • Potentially longer verification and testing cycles

Code Comparison

ibex (simple in-order core):

always_comb begin
  alu_operator_o = ALU_SLTU;
  alu_op_a_mux_sel_o = OP_A_REG_A;
  alu_op_b_mux_sel_o = OP_B_IMM;
  imm_b_mux_sel_o = IMM_B_I;
  regfile_we = 1'b1;
end

riscv-boom (out-of-order superscalar core):

class Execute(implicit p: Parameters) extends BoomModule()(p) with HasBoomCoreParameters {
  val io = IO(new Bundle {
    val req = Flipped(Vec(memWidth, Valid(new FuncUnitReq)))
    val resp = Vec(memWidth, Valid(new FuncUnitResp))
    val bp = Input(Vec(memWidth, new BranchPrediction))
    val brinfo = Input(new BrResolutionInfo)
  })
  // ... (complex out-of-order execution logic)
}

The code snippets illustrate the difference in complexity between the two designs, with ibex using simpler Verilog constructs and riscv-boom employing more advanced Scala-based hardware description.

Rocket Chip Generator

Pros of Rocket Chip

  • More advanced and feature-rich RISC-V core, supporting RV64G ISA
  • Highly configurable and scalable, suitable for a wide range of applications
  • Extensive ecosystem and community support through CHIPS Alliance

Cons of Rocket Chip

  • Higher complexity and steeper learning curve
  • Larger codebase and potentially higher resource usage
  • May be overkill for simpler embedded applications

Code Comparison

Ibex (SystemVerilog):

module ibex_core #(
  parameter bit          RV32E           = 0,
  parameter bit          RV32M           = 1,
  parameter int unsigned DmHaltAddr      = 32'h1A110800,
  parameter int unsigned DmExceptionAddr = 32'h1A110808
) (
  // Clock and Reset
  input  logic        clk_i,
  input  logic        rst_ni,

Rocket Chip (Chisel):

class Rocket(implicit p: Parameters) extends CoreModule()(p)
    with HasRocketCoreParameters
    with HasCoreIO {
  val clock_en_reg = Reg(Bool())
  val long_latency_stall = Reg(Bool())
  val pipelined_csr_unit = Module(new CSRFile())
  val decode_units = Seq.fill(decodeWidth) { Module(new DecodeUnit) }

The code snippets highlight the different design approaches and languages used in each project. Ibex uses SystemVerilog, while Rocket Chip is implemented in Chisel, a hardware construction language embedded in Scala.

A FPGA friendly 32 bit RISC-V CPU implementation

Pros of VexRiscv

  • Written in SpinalHDL, allowing for more flexible and modular design
  • Highly configurable with various optional features and extensions
  • Better performance in some benchmarks due to optimized design

Cons of VexRiscv

  • Less mature and less widely adopted compared to Ibex
  • Documentation may be less comprehensive
  • Potentially steeper learning curve due to SpinalHDL

Code Comparison

Ibex (SystemVerilog):

module ibex_core #(
  parameter bit          PMPEnable         = 1'b0,
  parameter int unsigned PMPGranularity    = 0,
  parameter int unsigned PMPNumRegions     = 4,
  parameter int unsigned MHPMCounterNum    = 0,
  parameter int unsigned MHPMCounterWidth  = 40,
  parameter bit          RV32E             = 1'b0,
  parameter bit          RV32M             = 1'b1,
  parameter bit          RV32B             = 1'b0,
  parameter bit          BranchPredictor   = 1'b0
) (
  // Clock and Reset
  input  logic        clk_i,
  input  logic        rst_ni,
  // ...
);

VexRiscv (SpinalHDL):

case class VexRiscvConfig(
  withMemoryStage : Boolean = true,
  withWriteBackStage : Boolean = true,
  withRvc : Boolean = true,
  withRvf : Boolean = false,
  withRvd : Boolean = false,
  withRvm : Boolean = true,
  withRva : Boolean = false,
  withRvc : Boolean = true,
  // ...
)
2,205

The CORE-V CVA6 is an Application class 6-stage RISC-V CPU capable of booting Linux

Pros of CVA6

  • More advanced 64-bit RISC-V core with out-of-order execution
  • Supports RV64GC instruction set, offering broader functionality
  • Higher performance suitable for more demanding applications

Cons of CVA6

  • Higher complexity and resource usage
  • Potentially longer development and verification cycles
  • May be overkill for simpler embedded applications

Code Comparison

CVA6 (more complex pipeline):

always_comb begin : commit_instr
  // Complex out-of-order commit logic
  for (int i = 0; i < NR_COMMIT_PORTS; i++) begin
    // ... (additional logic)
  end
end

Ibex (simpler pipeline):

always_comb begin : ex_wb_pipe_reg
  // Straightforward in-order execution
  ex_wb_pipe_o = ex_wb_pipe_i;
  if (ex_valid_i) begin
    // ... (simpler logic)
  end
end

The code snippets illustrate the difference in complexity between CVA6's out-of-order execution and Ibex's simpler in-order pipeline. CVA6 offers higher performance at the cost of increased complexity, while Ibex provides a more straightforward design suitable for less demanding applications.

1,103

Source files for SiFive's Freedom platforms

Pros of Freedom

  • More comprehensive SoC design, including peripherals and memory controllers
  • Supports multiple RISC-V configurations (E31, S51, U54)
  • Includes tools for FPGA development and simulation

Cons of Freedom

  • Larger and more complex codebase, potentially harder to understand and modify
  • Less focused on a single core implementation
  • May require more resources to synthesize and implement

Code Comparison

Ibex (SystemVerilog):

module ibex_core #(
  parameter bit          PMPEnable         = 1'b0,
  parameter int unsigned PMPGranularity    = 0,
  parameter int unsigned PMPNumRegions     = 4,
  parameter int unsigned MHPMCounterNum    = 0,
  parameter int unsigned MHPMCounterWidth  = 40
) (
  // Clock and Reset
  input  logic        clk_i,
  input  logic        rst_ni,

Freedom (Chisel):

class FreedomU500Config extends Config(
  new WithNBigCores(1) ++
  new WithNSmallCores(0) ++
  new WithCoherentBusTopology ++
  new BaseConfig)

class FreedomU500DevKitConfig extends Config(
  new WithJtagDTM ++
  new WithNMemoryChannels(1) ++
  new WithNBanks(8) ++
  new FreedomU500Config)

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

Ibex OpenTitan configuration Nightly Regression

Ibex RISC-V Core

Ibex is a production-quality open source 32-bit RISC-V CPU core written in SystemVerilog. The CPU core is heavily parametrizable and well suited for embedded control applications. Ibex is being extensively verified and has seen multiple tape-outs. Ibex supports the Integer (I) or Embedded (E), Integer Multiplication and Division (M), Compressed (C), and B (Bit Manipulation) extensions.

Ibex was initially developed as part of the PULP platform under the name "Zero-riscy", and has been contributed to lowRISC who maintains it and develops it further. It is under active development.

Configuration

Ibex offers several configuration parameters to meet the needs of various application scenarios. The options include different choices for the architecture of the multiplier unit, as well as a range of performance and security features. The table below indicates performance, area and verification status for a few selected configurations. These are configurations on which lowRISC is focusing for performance evaluation and design verification (see supported configs).

Config"micro""small""maxperf""maxperf-pmp-bmfull"
FeaturesRV32ECRV32IMC, 3 cycle multRV32IMC, 1 cycle mult, Branch target ALU, Writeback stageRV32IMCB, 1 cycle mult, Branch target ALU, Writeback stage, 16 PMP regions
Performance (CoreMark/MHz)0.9042.473.133.13
Area - Yosys (kGE)16.8526.6032.4866.02
Area - Commercial (estimated kGE)~15~24~30~61
Verification statusRedGreenGreenGreen

Notes:

  • Performance numbers are based on CoreMark running on the Ibex Simple System platform. Note that different ISAs (use of B and C extensions) give the best results for different configurations. See the Benchmarks README for more information.
  • Yosys synthesis area numbers are based on the Ibex basic synthesis flow using the latch-based register file.
  • Commercial synthesis area numbers are a rough estimate of what might be achievable with a commercial synthesis flow and technology library.
  • For comparison, the original "Zero-riscy" core yields an area of 23.14kGE using our Yosys synthesis flow.
  • Verification status is a rough guide to the overall maturity of a particular configuration. Green indicates that verification is close to complete. Amber indicates that some verification has been performed, but the configuration is still experimental. Red indicates a configuration with minimal/no verification. Users must make their own assessment of verification readiness for any tapeout.
  • v.1.0.0 of the RISC-V Bit-Manipulation Extension is supported as well as the remaining sub-extensions of draft v.0.93 of the bitmanip spec. The latter are not ratified and there may be changes before ratification. See Standards Compliance in the Ibex documentation for more information.

Documentation

The Ibex user manual can be read online at ReadTheDocs. It is also contained in the doc folder of this repository.

Examples

The Ibex repository includes Simple System. This is an intentionally simple integration of Ibex with a basic system that targets simulation. It is intended to provide an easy way to get bare metal binaries running on Ibex in simulation.

A more complete example can be found in the Ibex Demo System repository. In particular it includes a integration of the PULP RISC-V debug module. It targets the Arty A7 FPGA board from Digilent and supports debugging via OpenOCD and GDB over USB (no external JTAG probe required). The Ibex Demo System is maintained by lowRISC but is not an official part of Ibex.

Contributing

We highly appreciate community contributions. To ease our work of reviewing your contributions, please:

  • Create your own branch to commit your changes and then open a Pull Request.
  • Split large contributions into smaller commits addressing individual changes or bug fixes. Do not mix unrelated changes into the same commit!
  • Write meaningful commit messages. For more information, please check out the contribution guide.
  • If asked to modify your changes, do fixup your commits and rebase your branch to maintain a clean history.

When contributing SystemVerilog source code, please try to be consistent and adhere to our Verilog coding style guide.

When contributing C or C++ source code, please try to adhere to the OpenTitan C++ coding style guide. All C and C++ code should be formatted with clang-format before committing. Either run clang-format -i filename.cc or git clang-format on added files.

To get started, please check out the "Good First Issue" list.

Issues and Troubleshooting

If you find any problems or issues with Ibex or the documentation, please check out the issue tracker and create a new issue if your problem is not yet tracked.

Questions?

Do not hesitate to contact us, e.g., on our public Ibex channel on Zulip!

License

Unless otherwise noted, everything in this repository is covered by the Apache License, Version 2.0 (see LICENSE for full text).

Credits

Many people have contributed to Ibex through the years. Please have a look at the credits file and the commit history for more information.