• Stars
    star
    291
  • Rank 141,672 (Top 3 %)
  • Language
    Python
  • License
    ISC License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

32-bit RISC-V system on chip for iCE40 FPGAs

Icicle 2

Introduction

Icicle is a 32-bit RISC-V soft processor and system-on-chip, primarily designed for iCE40 (including the UltraPlus series) FPGAs. It can be built with open-source tools.

The original version of Icicle was written in SystemVerilog. This version is written in Amaranth, making the code cleaner and more flexible. Changes to the microarchitecture have made the core significantly smaller and faster.

The Pipeline and Stage classes are inspired by Minerva's pipeline system, though there are some significant differences.

Features

  • RV32I instruction set
  • Separate Wishbone instruction and data memory buses

Microarchitecture

Icicle uses a 6-stage pipeline, similar to a classic RISC pipeline. The main differences are summarized below:

  • The addition of a PC generation stage, instead of generating the PC during the fetch stage. PC generation in the fetch stage was often on the critical path in the previous version of Icicle.
  • The ALU result multiplexer has been moved to the memory stage. The execute stage was often on the critical path in previous versions of Icicle. The multiplexing can proceed in parallel with memory access, as the load-store unit can be hard-wired to the adder's output - it never uses the output from the logic unit or barrel shifter. Despite more registers being required to retain the adder, logic and shifter outputs between stages, the size of the core is not significantly increased, as the registers can be packed in the same logic cell as the prior LUT.
  • Similar to above, the register write data multiplexer has been moved to the writeback stage. The memory stage was often on the critical patch in previous versions of Icicle, and there is plenty of slack in the writeback stage: it has very little logic and the register file inputs are only required at the end of the clock cycle.

The pipeline is fully interlocked. Adding bypassing support would be complicated by the multiplexer changes described above. Furthermore, enabling bypassing in the previous version of Icicle increased the size of the core and reduced the clock frequency by a relatively significant amount on iCE40 FPGAs, which are the primary target.

Icicle is theoretically capable of issuing and retiring one instruction per cycle, if the memory bus can keep up. In reality, the IPC will be slightly lower than this due to stalls and flushes caused by data hazards and branch mispredictions.

The system-on-chip examples distributed with Icicle are currently only capable of issuing one instruction every two cycles, as:

  • FPGA block RAMs are synchronous.
  • Additional multiplexing logic needs to be added after the read port.
  • Only a single memory bus transaction may be in flight at once.

This could be improved with:

  • Negative-edge block RAMs, which Amaranth does not yet support.
  • Using a pipelined memory bus that makes requests during one cycle and does not expect the response until the following cycle.
  • Adding instruction and data caches and burst support.

Dependencies

Building

Run the following command to install Icicle locally, including its dependencies:

pip install -e .

The icicle command is a thin wrapper around amaranth.cli. Run the following command to compile the Icicle processor core to Verilog:

icicle generate -t v > icicle.v

The icicle command has some flags for customizing the generated core. Run icicle --help for full usage information.

System-on-chip examples

Icicle ships with example system-on-chip designs for several development boards. A single command will build and flash the system-on-chip to your FPGA. Simply connect the development board to your computer and run the appropriate command from the table below, appending the --flash flag:

Board Command Notes
iCEBreaker icicle-icebreaker
iCE40-HX8K Breakout Board icicle-ice40-hx8k-b-evn Configure jumpers for SRAM programming.
ECP5 Evaluation Board icicle-ecp5-5g-evn

For example, run the following command to build and flash to the iCEBreaker board:

icicle-icebreaker --flash

The iCEBreaker board is Icicle's primary target. It is inexpensive, beginner-friendly and fully compatible with the open-source toolchain.

Example programs

Icicle also ships with some example programs to demonstrate the system-on-chip. Run the following commands to build them and flash the blinky example to the iCEBreaker board:

make -C examples PLATFORM=icebreaker
iceprog -o 1M examples/blinky.bin

Testing

There are a small number of non-exhaustive tests that simulate portions of the processor core. These were primarily used to test standalone modules during development before the full formal verification infrastructure was ready.

They are still useful as they are significantly quicker than verifying the entire core - providing a quicker feedback cycle during development. Use the following command to run them:

python -m unittest

However, despite the existence of the unit tests, formally verifying the core after a change is completed is still strongly recommended.

Formal verification

Icicle supports the RISC-V Formal Interface (RVFI), allowing it to be formally verified with riscv-formal.

Clone the riscv-formal repository:

git clone https://github.com/SymbioticEDA/riscv-formal.git

Clone Icicle in the cores subdirectory:

cd riscv-formal/cores && git clone https://github.com/grahamedgecombe/icicle.git

Run the following commands to verify the processor core:

cd icicle
../../checks/genchecks.py
make -C checks -j $(nproc)
sby complete.sby
./equiv.sh

Size and performance

FPGA family Logic cells Frequency
iCE40 HX ~1,000 ~75 MHz
iCE40 UP ~1,000 ~30 MHz
ECP5 8_5G ~900 ~140 MHz

The numbers in the table above refer to the processor core in its default configuration only. The rest of the system-on-chip is not included.

License

This project is available under the terms of the ISC license, which is similar to the 2-clause BSD license. See the LICENSE file for the copyright information and licensing terms.

More Repositories

1

nginx-ct

Certificate Transparency module for nginx.
C
174
star
2

ct-submit

A program for submitting X.509 certificate chains to Certificate Transparency log servers.
Go
75
star
3

lightstone

An open-source implementation of the Minecraft server software.
Java
73
star
4

arc

A toy x86-64 kernel.
C
52
star
5

tiny-basic-compiler

A simple Tiny BASIC compiler which targets x86-64 Linux machines.
Java
49
star
6

pgzstd

Postgres module for Zstandard compression/decompression with preset dictionary support
C
37
star
7

jterminal

JTerminal is a (roughly) VT100-compatible terminal emulator for Swing-based Java applications.
Java
34
star
8

netty-sni-example

An example of how to use server-side SNI in Netty with Java 8.
Java
20
star
9

android-ssl

Android SSL certificate validation vulnerability detection tools.
Java
19
star
10

minecraft-installer

A Debian package which installs the Minecraft client and server.
Groff
18
star
11

lancat

Zero-configuration LAN file transfer.
Ruby
14
star
12

apiviz

A fork of APIviz with out of the box support for classes compiled with Java 8.
Java
10
star
13

picosoc-uip

uIP 0.9 PicoSoC/PicoRV32 port
C
8
star
14

ssh-ldap-publickey

A program for looking up SSH public keys with LDAP.
C
7
star
15

pgflate

PostgreSQL module for raw DEFLATE compression/decompression with preset dictionary support
C
7
star
16

db

A thin layer on top of the JDBC API that takes care of awkward boilerplate code.
Java
7
star
17

advent-2021

Advent of Code 2021 solutions
Kotlin
6
star
18

lasertag

An electronic laser tag system based on AVR microcontrollers.
C
5
star
19

ignition

Static pages for Rails 4.
Ruby
5
star
20

opencraft

A mirror of the OpenCraft repository, which was originally hosted as a Subversion repository on SourceForge.
Java
4
star
21

advent-2020

Advent of Code 2020 solutions
Kotlin
2
star
22

tnef-filter

Automatically convert TNEF (winmail.dat) attachments into MIME format
Perl
2
star
23

pdf-decrypt-filter

Automatically decrypt PDF attachments in emails
Perl
2
star
24

puppet-git-catalog

Submodule-aware Git-managed static Puppet catalogs
C
2
star
25

advent-2023

Advent of Code 2023 solutions
Kotlin
1
star
26

pragpub-mailer

Email PragPub automatically to a Kindle.
Shell
1
star