Skip to main content

Embedded RISC-V implementation written in Amaranth

Project description

Sentinel Logo. A lighthouse is shining its light on a PCB and computer
  chip. The silicon die of the computer chip is visible. The text "Sentinel"
  in a black and gray gradient stretches in parallel with the lighthouse's beam.
  The text covers the base of the lighthouse and is below the chip.

Logo by Tokino Kei.

Documentation Status main next

sentinel

Sentinel is a small RISC-V CPU (RV32I_Zicsr) written in Amaranth. It implements the Machine Mode privileged spec, and is designed to fit into ~1000 4-input LUTs or less on an FPGA. It is a good candidate for control tasks where a programmable state machine or custom size-tailored core would otherwise be used.

Unlike most RISC-V implementations, Sentinel is microcoded, not pipelined. Instructions require multiple clock cycles to execute. Sentinel is therefore not necessarily a good fit for applications where high throughput/ IPC is required. Short version: minimum of 4 CPI for basic arithmetic, maximum of 69 for a 31-bit shift (yes, shift instructions need work).

Sentinel has been tested against RISC-V Formal and the RISCOF frameworks, and passes both. Once I have added a few extra tests, the core can be considered correct with respect to the RISC-V Formal model. The core is also probably correct with respect to the SAIL golden model.

Why The Name sentinel?

I've like the way the word "sentinel" sounds ever since I first learned of the word, either from the title of a book on NJ lighthouses, or on an enemy from an old Sega Genesis RPG. The term has always stuck with me since then, albeit in a much more positive light than "the soldier golems of the forces of Darkness" :). Since "sentinel" means "one who stands watch", I think it's an apt name for a CPU intended to watch over the rest of your silicon, but otherwise stay out of the way. Also, since lighthouses are indeed "Sentinels Of The Shore", I wanted to shoehorn a lighthouse into the logo :).

Quick Quick Start

Verilog Programmers

If you're primarily a Verilog/VHDL programmer, each Sentinel release includes ready-to-use, standalone Verilog as an asset. If you wish to use Verilog generated from an arbitrary commit without getting involved with the source, see Pre-Generated Verilog section of the Quick Start docs.

Amaranth Programmers

For Amaranth programmers wishing to use Sentinel without playing with the source, you can install sentinel-cpu using pip or pdm. When a PyPI package is available, you will probably want one of the following:

  • pip install sentinel-cpu
  • pdm add sentinel-cpu

However, since there's no PyPI package right now, I recommend substituting the sentinel-cpu Name-Based Lookup with the git+https://codeberg.org/cr1901/sentinel@main URL-based lookup. See the As A Dependency section of the Installation docs for other useful command-lines.

Source Code Demos

For those who want to play with the source, the absolute fastest way to get started is to check out the source code, install pdm, use pdm to create a virtual environment with appropriate tools, and generate an .env.toolchain file that pdm uses to set some environment variables for Amaranth:

pipx install pdm
git clone https://codeberg.org/cr1901/sentinel.git
cd sentinel
pdm venv create -n quick-quickstart
pdm install --venv quick-quickstart -G examples -G yowasp
pdm run use-yowasp

Use pip or pipx to install pdm depending on your Python install's recommendation.

Then, to generate Verilog core with a Wishbone Classic bus, and clk, rst, and irq input pins, run:

pdm run --venv quick-quickstart gen

To create a demo bitstream that counts primes and sets LEDs accordingly (for the iCE40-HX8K Breakout Board), run:

pdm run --venv quick-quickstart demo -i csr -p ice40_hx8k_b_evn

The output will be available in build/ at the source code root.

If you have Rust installed with the riscv32i-unknown-none-elf target, you can create a Rule 110 demo that prints neat patterns to the serial port:

pdm run --venv quick-quickstart demo-rust -i csr -p ice40_hx8k_b_evn

The output will be available in build-rust/ at the source code root.

Run pdm run --venv quick-quickstart gen -h and pdm run --venv quick-quickstart demo -h for help, and experiment!

When you're done, unset the environment variables and optionally destroy the virtual environment, as we will not be using it again:

pdm run use-local
pdm venv remove quick-quickstart

Note that extra dependencies are required for development. See the next section.

Quick Doc Links

  • To get started with an environment suitable for development, consult the Installation doc page.
  • For information on the source code development environment, click here.
  • For other use cases, consult the Quick Start page. Note that they are a little less quick than the Quick Quick Start :).
  • Sentinel has multiple test suites. External submodules have their own README.mds for context and quick instructions. The Testing page and subpages give further instructions and information.
  • The Public API has its own page.
  • A copy of the below block diagram, detailed instruction cycle counts, and implemented CSRs are also on the Internals page.
  • Microcode information has its own page.

Block Diagram

Simplified block diagram of Sentinel. Black arrows are physical connections. Blue arrows represent microcode ROM outputs to Sentinel components, including feedback into the microcode ROM as inputs. Purple arrows represent microcode ROM inputs from the other components.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sentinel_cpu-0.1.0b2.tar.gz (5.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sentinel_cpu-0.1.0b2-py3-none-any.whl (72.3 kB view details)

Uploaded Python 3

File details

Details for the file sentinel_cpu-0.1.0b2.tar.gz.

File metadata

  • Download URL: sentinel_cpu-0.1.0b2.tar.gz
  • Upload date:
  • Size: 5.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.8 CPython/3.14.4 Linux/6.12.85+deb13-amd64

File hashes

Hashes for sentinel_cpu-0.1.0b2.tar.gz
Algorithm Hash digest
SHA256 121166bce4cea4061d29e92b6e20d1ff2dfe65f8a1ee8f4c237ddc8b08dcbb8a
MD5 3ebd02673029adc24c2446fbe838ff41
BLAKE2b-256 c185d92994aee9da992c1636d9fbc6b5c47805b48d0b4b7e8d4e29a97d70ceca

See more details on using hashes here.

File details

Details for the file sentinel_cpu-0.1.0b2-py3-none-any.whl.

File metadata

  • Download URL: sentinel_cpu-0.1.0b2-py3-none-any.whl
  • Upload date:
  • Size: 72.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.8 CPython/3.14.4 Linux/6.12.85+deb13-amd64

File hashes

Hashes for sentinel_cpu-0.1.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 c861fdd63e4379d3c4422fe699926a347487ece82b65f1fc7798854f5997a345
MD5 f240584c5bcbe760a6446e270ce50dc1
BLAKE2b-256 bb822b5956fc940e361408d98f94f7a80933ee0ee3131e9d695ae31927a9803f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page