| 1 |
11 |
zero_gravi |
# [The NEORV32 Processor](https://github.com/stnolting/neorv32) (RISC-V-compliant)
|
| 2 |
2 |
zero_gravi |
|
| 3 |
|
|
[](https://travis-ci.com/stnolting/neorv32)
|
| 4 |
|
|
[](https://github.com/stnolting/neorv32/blob/master/LICENSE)
|
| 5 |
|
|
[](https://github.com/stnolting/neorv32/releases)
|
| 6 |
|
|
|
| 7 |
|
|
|
| 8 |
|
|
## Table of Content
|
| 9 |
|
|
|
| 10 |
|
|
* [Introduction](#Introduction)
|
| 11 |
|
|
* [Features](#Features)
|
| 12 |
|
|
* [FPGA Implementation Results](#FPGA-Implementation-Results)
|
| 13 |
|
|
* [Performance](#Performance)
|
| 14 |
|
|
* [Top Entity](#Top-Entity)
|
| 15 |
|
|
* [**Getting Started**](#Getting-Started)
|
| 16 |
9 |
zero_gravi |
* [Contribute](#Contribute)
|
| 17 |
2 |
zero_gravi |
* [Legal](#Legal)
|
| 18 |
|
|
|
| 19 |
|
|
|
| 20 |
|
|
|
| 21 |
|
|
## Introduction
|
| 22 |
|
|
|
| 23 |
14 |
zero_gravi |
The **NEORV32 processor** is a customizable full-scale mikrocontroller-like processor system based on the RISC-V-compliant
|
| 24 |
15 |
zero_gravi |
`rv32i` NEORV32 CPU with optional `M`, `E`, `C` and `U`, `Zicsr` and `Zifencei` extensions and optional physical memory protection (PMP).
|
| 25 |
|
|
The CPU was built from scratch and is compliant to the *Unprivileged ISA Specification Version 2.2* and a subset of the *Privileged Architecture
|
| 26 |
14 |
zero_gravi |
Specification Version 1.12-draft*.
|
| 27 |
2 |
zero_gravi |
|
| 28 |
14 |
zero_gravi |
The **processor** is intended as auxiliary processor within a larger SoC designs or as stand-alone
|
| 29 |
|
|
custom microcontroller. Its top entity can be directly synthesized for any FPGA without modifications and
|
| 30 |
|
|
provides a full-scale RISC-V based microcontroller with common peripherals like GPIO, serial interfaces for
|
| 31 |
|
|
UART, I²C and SPI, timers, external bus interface and embedded memories. All optional features beyond the
|
| 32 |
|
|
base CPU can be enabled and configured via VHDL generics.
|
| 33 |
11 |
zero_gravi |
|
| 34 |
14 |
zero_gravi |
Alternatively, you can use the **NEORV32 CPU** as stand-alone central processing unit and build your own microcontroller
|
| 35 |
|
|
or processor system around it.
|
| 36 |
2 |
zero_gravi |
|
| 37 |
14 |
zero_gravi |
This project comes with a complete software ecosystem that features core libraries for high-level
|
| 38 |
|
|
usage of the provided functions and peripherals, application makefiles, a runtime environment and
|
| 39 |
|
|
several example programs. All software source files provide a doxygen-based documentary.
|
| 40 |
2 |
zero_gravi |
|
| 41 |
14 |
zero_gravi |
The project is intended to work "out of the box". Just synthesize the test setup from this project,
|
| 42 |
|
|
upload it to your FPGA board of choice and start playing with the NEORV32. If you do not want to
|
| 43 |
|
|
[compile the GCC toolchains](https://github.com/riscv/riscv-gnu-toolchain) by yourself, you can also
|
| 44 |
|
|
download [pre-compiled toolchains](https://github.com/stnolting/riscv_gcc_prebuilt) for Linux.
|
| 45 |
2 |
zero_gravi |
|
| 46 |
|
|
For more information take a look a the [ NEORV32 datasheet](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf).
|
| 47 |
|
|
|
| 48 |
15 |
zero_gravi |
### Key Features
|
| 49 |
2 |
zero_gravi |
|
| 50 |
15 |
zero_gravi |
- RISC-V-compliant `rv32i` CPU with optional `C`, `E`, `M`, `U`, `Zicsr`, `rv32Zifencei` and PMP (physical memory protection) extensions
|
| 51 |
|
|
- GCC-based toolchain ([pre-compiled rv32i and rv32 etoolchains available](https://github.com/stnolting/riscv_gcc_prebuilt))
|
| 52 |
|
|
- Application compilation based on [GNU makefiles](https://github.com/stnolting/neorv32/blob/master/sw/example/blink_led/makefile)
|
| 53 |
|
|
- [Doxygen-based](https://github.com/stnolting/neorv32/blob/master/docs/doxygen_makefile_sw) documentation of the software framework: available on [GitHub pages](https://stnolting.github.io/neorv32/files.html)
|
| 54 |
|
|
- Detailed [datasheet](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf) (pdf)
|
| 55 |
|
|
- Completely described in behavioral, platform-independent VHDL – no primitives, macros, etc.
|
| 56 |
|
|
- Fully synchronous design, no latches, no gated clocks
|
| 57 |
|
|
- Small hardware footprint and high operating frequency
|
| 58 |
|
|
- Highly configurable CPU and processor setup
|
| 59 |
|
|
|
| 60 |
2 |
zero_gravi |
### Design Principles
|
| 61 |
|
|
|
| 62 |
|
|
* From zero to main(): Completely open source and documented.
|
| 63 |
|
|
* Plain VHDL without technology-specific parts like attributes, macros or primitives.
|
| 64 |
|
|
* Easy to use – working out of the box.
|
| 65 |
|
|
* Clean synchronous design, no wacky combinatorial interfaces.
|
| 66 |
18 |
zero_gravi |
* Be as small as possible – but with a reasonable size-speed tradeoff.
|
| 67 |
2 |
zero_gravi |
* The processor has to fit in a Lattice iCE40 UltraPlus 5k FPGA running at 20+ MHz.
|
| 68 |
|
|
|
| 69 |
|
|
|
| 70 |
|
|
### Status
|
| 71 |
3 |
zero_gravi |
|
| 72 |
6 |
zero_gravi |
The processor is synthesizable (tested with Intel Quartus Prime, Xilinx Vivado and Lattice Radiant/LSE) and can successfully execute
|
| 73 |
|
|
all the [provided example programs](https://github.com/stnolting/neorv32/tree/master/sw/example) including the CoreMark benchmark.
|
| 74 |
2 |
zero_gravi |
|
| 75 |
8 |
zero_gravi |
The processor passes the official `rv32i`, `rv32im`, `rv32imc`, `rv32Zicsr` and `rv32Zifencei` [RISC-V compliance tests](https://github.com/riscv/riscv-compliance).
|
| 76 |
2 |
zero_gravi |
|
| 77 |
11 |
zero_gravi |
| Project component | CI status | Note |
|
| 78 |
|
|
|:--------------------------------------------------------------------------------|:----------|:---------|
|
| 79 |
14 |
zero_gravi |
| [NEORV32 processor](https://github.com/stnolting/neorv32) | [](https://travis-ci.com/stnolting/neorv32) | [](https://stnolting.github.io/neorv32/files.html) |
|
| 80 |
|
|
| [Pre-built toolchain](https://github.com/stnolting/riscv_gcc_prebuilt) | [](https://travis-ci.com/stnolting/riscv_gcc_prebuilt) | |
|
| 81 |
|
|
| [RISC-V compliance test](https://github.com/stnolting/neorv32_riscv_compliance) | [](https://travis-ci.com/stnolting/neorv32_riscv_compliance) | |
|
| 82 |
6 |
zero_gravi |
|
| 83 |
|
|
|
| 84 |
12 |
zero_gravi |
### Non RISC-V-Compliant Issues
|
| 85 |
7 |
zero_gravi |
|
| 86 |
14 |
zero_gravi |
* No exception is triggered for the `E` CPU extension when using registers above `x15` (*needs fixing*)
|
| 87 |
12 |
zero_gravi |
* `misa` CSR is read-only - no dynamic enabling/disabling of implemented CPU extensions during runtime
|
| 88 |
14 |
zero_gravi |
* `mcause` CSR is read-only
|
| 89 |
12 |
zero_gravi |
* The `[m]cycleh` and `[m]instreth` CSR counters are only 20-bit wide (in contrast to original 32-bit)
|
| 90 |
18 |
zero_gravi |
* The physical memory protection (**PMP**) only supports `NAPOT` mode, a minimal granularity of 8 bytes and only up to 8 regions
|
| 91 |
7 |
zero_gravi |
|
| 92 |
|
|
|
| 93 |
14 |
zero_gravi |
### Custom CPU Extensions
|
| 94 |
|
|
|
| 95 |
15 |
zero_gravi |
The custom extensions are always enabled and are indicated via the `X` bit in the `misa` CSR.
|
| 96 |
|
|
|
| 97 |
14 |
zero_gravi |
* Four *fast interrupt* request channels with according control/status bits in `mie` and `mip` and custom exception codes in `mcause`
|
| 98 |
|
|
|
| 99 |
|
|
|
| 100 |
9 |
zero_gravi |
### To-Do / Wish List
|
| 101 |
7 |
zero_gravi |
|
| 102 |
16 |
zero_gravi |
- Add AXI(-Lite) bridges
|
| 103 |
13 |
zero_gravi |
- Option to use DSP-based multiplier in `M` extension (would be so much faster)
|
| 104 |
9 |
zero_gravi |
- Synthesis results for more platforms
|
| 105 |
7 |
zero_gravi |
- Port Dhrystone benchmark
|
| 106 |
13 |
zero_gravi |
- Implement atomic operations (`A` extension) and floating-point operations (`F` extension)
|
| 107 |
|
|
- Maybe port an RTOS (like [Zephyr](https://github.com/zephyrproject-rtos/zephyr), [freeRTOS](https://www.freertos.org) or [RIOT](https://www.riot-os.org))
|
| 108 |
|
|
- Make a 64-bit branch someday
|
| 109 |
7 |
zero_gravi |
|
| 110 |
|
|
|
| 111 |
|
|
|
| 112 |
2 |
zero_gravi |
## Features
|
| 113 |
|
|
|
| 114 |
|
|
### Processor Features
|
| 115 |
|
|
|
| 116 |
11 |
zero_gravi |

|
| 117 |
|
|
|
| 118 |
15 |
zero_gravi |
Highly customizable processor configuration:
|
| 119 |
|
|
- Optional processor-internal data and instruction memories (DMEM/IMEM)
|
| 120 |
|
|
- Optional internal bootloader with UART console and automatic SPI flash boot option
|
| 121 |
|
|
- Optional machine system timer (MTIME), RISC-V-compliant
|
| 122 |
|
|
- Optional universal asynchronous receiver and transmitter (UART)
|
| 123 |
|
|
- Optional 8/16/24/32-bit serial peripheral interface controller (SPI) with 8 dedicated chip select lines
|
| 124 |
|
|
- Optional two wire serial interface controller (TWI), compatible to the I²C standard
|
| 125 |
|
|
- Optional general purpose parallel IO port (GPIO), 16xOut & 16xIn, with pin-change interrupt
|
| 126 |
|
|
- Optional 32-bit external bus interface, Wishbone b4 compliant (WISHBONE)
|
| 127 |
|
|
- Optional watchdog timer (WDT)
|
| 128 |
|
|
- Optional PWM controller with 4 channels and 8-bit duty cycle resolution (PWM)
|
| 129 |
|
|
- Optional GARO-based true random number generator (TRNG)
|
| 130 |
|
|
- Optional dummy device (DEVNULL) (can be used for *fast* simulation console output)
|
| 131 |
|
|
- System configuration information memory to check hardware configuration by software (SYSINFO)
|
| 132 |
2 |
zero_gravi |
|
| 133 |
|
|
### CPU Features
|
| 134 |
|
|
|
| 135 |
11 |
zero_gravi |

|
| 136 |
|
|
|
| 137 |
|
|
The CPU is [compliant](https://github.com/stnolting/neorv32_riscv_compliance) to the
|
| 138 |
12 |
zero_gravi |
[official RISC-V specifications (2.2)](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/riscv-spec.pdf) including a subset of the
|
| 139 |
|
|
[RISC-V privileged architecture specifications (1.12-draft)](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/riscv-spec.pdf).
|
| 140 |
2 |
zero_gravi |
|
| 141 |
11 |
zero_gravi |
More information regarding the CPU including a detailed list of the instruction set and the available CSRs can be found in
|
| 142 |
|
|
the [ NEORV32 datasheet](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf).
|
| 143 |
|
|
|
| 144 |
|
|
|
| 145 |
|
|
**General**:
|
| 146 |
12 |
zero_gravi |
* Modified Harvard architecture (separate CPU interfaces for data and instructions; single processor-bus via bus switch)
|
| 147 |
|
|
* Two stages in-order pipeline (FETCH, EXECUTE); each stage uses a multi-cycle processing scheme
|
| 148 |
15 |
zero_gravi |
* No hardware support of unaligned accesses - they will trigger an exception
|
| 149 |
|
|
* Privilege levels: `machine` mode, `user` mode (if enabled via `U` extension)
|
| 150 |
11 |
zero_gravi |
|
| 151 |
|
|
|
| 152 |
3 |
zero_gravi |
**RV32I base instruction set** (`I` extension):
|
| 153 |
2 |
zero_gravi |
* ALU instructions: `LUI` `AUIPC` `ADDI` `SLTI` `SLTIU` `XORI` `ORI` `ANDI` `SLLI` `SRLI` `SRAI` `ADD` `SUB` `SLL` `SLT` `SLTU` `XOR` `SRL` `SRA` `OR` `AND`
|
| 154 |
7 |
zero_gravi |
* Jump and branch instructions: `JAL` `JALR` `BEQ` `BNE` `BLT` `BGE` `BLTU` `BGEU`
|
| 155 |
2 |
zero_gravi |
* Memory instructions: `LB` `LH` `LW` `LBU` `LHU` `SB` `SH` `SW`
|
| 156 |
8 |
zero_gravi |
* System instructions: `ECALL` `EBREAK` `FENCE`
|
| 157 |
2 |
zero_gravi |
|
| 158 |
3 |
zero_gravi |
**Compressed instructions** (`C` extension):
|
| 159 |
2 |
zero_gravi |
* ALU instructions: `C.ADDI4SPN` `C.ADDI` `C.ADD` `C.ADDI16SP` `C.LI` `C.LUI` `C.SLLI` `C.SRLI` `C.SRAI` `C.ANDI` `C.SUB` `C.XOR` `C.OR` `C.AND` `C.MV` `C.NOP`
|
| 160 |
7 |
zero_gravi |
* Jump and branch instructions: `C.J` `C.JAL` `C.JR` `C.JALR` `C.BEQZ` `C.BNEZ`
|
| 161 |
2 |
zero_gravi |
* Memory instructions: `C.LW` `C.SW` `C.LWSP` `C.SWSP`
|
| 162 |
|
|
* Misc instructions: `C.EBREAK` (only with `Zicsr` extension)
|
| 163 |
|
|
|
| 164 |
3 |
zero_gravi |
**Embedded CPU version** (`E` extension):
|
| 165 |
2 |
zero_gravi |
* Reduced register file (only the 16 lowest registers)
|
| 166 |
|
|
|
| 167 |
3 |
zero_gravi |
**Integer multiplication and division hardware** (`M` extension):
|
| 168 |
2 |
zero_gravi |
* Multiplication instructions: `MUL` `MULH` `MULHSU` `MULHU`
|
| 169 |
|
|
* Division instructions: `DIV` `DIVU` `REM` `REMU`
|
| 170 |
|
|
|
| 171 |
8 |
zero_gravi |
**Privileged architecture / CSR access** (`Zicsr` extension):
|
| 172 |
2 |
zero_gravi |
* Privilege levels: `M-mode` (Machine mode)
|
| 173 |
|
|
* CSR access instructions: `CSRRW` `CSRRS` `CSRRC` `CSRRWI` `CSRRSI` `CSRRCI`
|
| 174 |
8 |
zero_gravi |
* System instructions: `MRET` `WFI`
|
| 175 |
12 |
zero_gravi |
* Counter CSRs: `[m]cycle[h]` `[m]instret[h]` `time[h]`
|
| 176 |
14 |
zero_gravi |
* Machine CSRs: `mstatus` `misa`(read-only!) `mie` `mtvec` `mscratch` `mepc` `mcause`(read-only!) `mtval` `mip` `mvendorid` `marchid` `mimpid` `mhartid`
|
| 177 |
2 |
zero_gravi |
* Supported exceptions and interrupts:
|
| 178 |
|
|
* Misaligned instruction address
|
| 179 |
|
|
* Instruction access fault
|
| 180 |
|
|
* Illegal instruction
|
| 181 |
4 |
zero_gravi |
* Breakpoint (via `ebreak` instruction)
|
| 182 |
2 |
zero_gravi |
* Load address misaligned
|
| 183 |
|
|
* Load access fault
|
| 184 |
4 |
zero_gravi |
* Store address misaligned
|
| 185 |
2 |
zero_gravi |
* Store access fault
|
| 186 |
4 |
zero_gravi |
* Environment call from M-mode (via `ecall` instruction)
|
| 187 |
15 |
zero_gravi |
* Machine timer interrupt `mti` (via processor's MTIME unit)
|
| 188 |
|
|
* Machine software interrupt `msi` (via external signal)
|
| 189 |
|
|
* Machine external interrupt `mei` (via external signal)
|
| 190 |
|
|
* Four fast interrupt requests (custom extension)
|
| 191 |
2 |
zero_gravi |
|
| 192 |
15 |
zero_gravi |
**Privileged architecture / User mode** (`U` extension, requires `Zicsr` extension):
|
| 193 |
16 |
zero_gravi |
* Privilege levels: `M-mode` (Machine mode) + `U-mode` (User mode)
|
| 194 |
15 |
zero_gravi |
|
| 195 |
8 |
zero_gravi |
**Privileged architecture / FENCE.I** (`Zifencei` extension):
|
| 196 |
17 |
zero_gravi |
* System instructions: `FENCE.I`
|
| 197 |
8 |
zero_gravi |
|
| 198 |
18 |
zero_gravi |
**Privileged architecture / Physical memory protection** (`PMP`, requires `Zicsr` extension):
|
| 199 |
15 |
zero_gravi |
* Additional machine CSRs: `pmpcfgx` `pmpaddrx`
|
| 200 |
2 |
zero_gravi |
|
| 201 |
15 |
zero_gravi |
|
| 202 |
2 |
zero_gravi |
## FPGA Implementation Results
|
| 203 |
|
|
|
| 204 |
|
|
This chapter shows exemplary implementation results of the NEORV32 processor for an **Intel Cyclone IV EP4CE22F17C6N FPGA** on
|
| 205 |
|
|
a DE0-nano board. The design was synthesized using **Intel Quartus Prime Lite 19.1** ("balanced implementation"). The timing
|
| 206 |
4 |
zero_gravi |
information is derived from the Timing Analyzer / Slow 1200mV 0C Model. If not otherwise specified, the default configuration
|
| 207 |
15 |
zero_gravi |
of the CPU's generics is assumed (no PMP). No constraints were used at all.
|
| 208 |
2 |
zero_gravi |
|
| 209 |
11 |
zero_gravi |
### CPU
|
| 210 |
|
|
|
| 211 |
14 |
zero_gravi |
Results generated for hardware version: `1.3.0.0`
|
| 212 |
2 |
zero_gravi |
|
| 213 |
12 |
zero_gravi |
| CPU Configuration | LEs | FFs | Memory bits | DSPs | f_max |
|
| 214 |
|
|
|:---------------------------------|:----------:|:--------:|:-----------:|:----:|:-------:|
|
| 215 |
14 |
zero_gravi |
| `rv32i` | 1122 | 481 | 2048 | 0 | 110 MHz |
|
| 216 |
|
|
| `rv32i` + `Zicsr` + `Zifencei` | 1891 | 819 | 2048 | 0 | 100 MHz |
|
| 217 |
|
|
| `rv32im` + `Zicsr` + `Zifencei` | 2496 | 1067 | 2048 | 0 | 100 MHz |
|
| 218 |
|
|
| `rv32imc` + `Zicsr` + `Zifencei` | 2734 | 1066 | 2048 | 0 | 100 MHz |
|
| 219 |
|
|
| `rv32emc` + `Zicsr` + `Zifencei` | 2722 | 1066 | 1024 | 0 | 100 MHz |
|
| 220 |
2 |
zero_gravi |
|
| 221 |
6 |
zero_gravi |
### Processor-Internal Peripherals and Memories
|
| 222 |
2 |
zero_gravi |
|
| 223 |
14 |
zero_gravi |
Results generated for hardware version: `1.3.0.0`
|
| 224 |
11 |
zero_gravi |
|
| 225 |
14 |
zero_gravi |
| Module | Description | LEs | FFs | Memory bits | DSPs |
|
| 226 |
|
|
|:----------|:------------------------------------------------|:---:|:---:|:-----------:|:----:|
|
| 227 |
|
|
| BOOT ROM | Bootloader ROM (4kB) | 4 | 1 | 32 768 | 0 |
|
| 228 |
|
|
| BUSSWITCH | Mux for CPU I & D interfaces | 62 | 8 | 0 | 0 |
|
| 229 |
|
|
| DEVNULL | Dummy device | 3 | 1 | 0 | 0 |
|
| 230 |
|
|
| DMEM | Processor-internal data memory (8kB) | 12 | 2 | 65 536 | 0 |
|
| 231 |
|
|
| GPIO | General purpose input/output ports | 40 | 33 | 0 | 0 |
|
| 232 |
|
|
| IMEM | Processor-internal instruction memory (16kb) | 7 | 2 | 131 072 | 0 |
|
| 233 |
|
|
| MTIME | Machine system timer | 266 | 166 | 0 | 0 |
|
| 234 |
|
|
| PWM | Pulse-width modulation controller | 72 | 69 | 0 | 0 |
|
| 235 |
|
|
| SPI | Serial peripheral interface | 198 | 125 | 0 | 0 |
|
| 236 |
|
|
| SYSINFO | System configuration information memory | 10 | 9 | 0 | 0 |
|
| 237 |
|
|
| TRNG | True random number generator | 105 | 93 | 0 | 0 |
|
| 238 |
|
|
| TWI | Two-wire interface | 75 | 44 | 0 | 0 |
|
| 239 |
|
|
| UART | Universal asynchronous receiver/transmitter | 153 | 108 | 0 | 0 |
|
| 240 |
|
|
| WDT | Watchdog timer | 59 | 45 | 0 | 0 |
|
| 241 |
2 |
zero_gravi |
|
| 242 |
|
|
|
| 243 |
11 |
zero_gravi |
### Exemplary FPGA Setups
|
| 244 |
6 |
zero_gravi |
|
| 245 |
11 |
zero_gravi |
Exemplary implementation results for different FPGA platforms. The processor setup uses *all provided peripherals*,
|
| 246 |
15 |
zero_gravi |
no external memory interface, no PMP and only internal instruction and data memories. IMEM uses 16kB and DMEM uses 8kB memory space. The setup's top entity connects most of the
|
| 247 |
11 |
zero_gravi |
processor's [top entity](https://github.com/stnolting/neorv32/blob/master/rtl/core/neorv32_top.vhd) signals
|
| 248 |
12 |
zero_gravi |
to FPGA pins - except for the Wishbone bus and the interrupt signals.
|
| 249 |
6 |
zero_gravi |
|
| 250 |
14 |
zero_gravi |
Results generated for hardware version: `1.3.0.0`
|
| 251 |
6 |
zero_gravi |
|
| 252 |
14 |
zero_gravi |
| Vendor | FPGA | Board | Toolchain | Impl. strategy |CPU | LUT / LE | FF / REG | DSP | Memory Bits | BRAM / EBR | SPRAM | Frequency |
|
| 253 |
|
|
|:--------|:----------------------------------|:-----------------|:------------------------|:---------------|:---------------------------------|:-----------|:-----------|:-------|:-------------|:-----------|:---------|---------------:|
|
| 254 |
|
|
| Intel | Cyclone IV `EP4CE22F17C6N` | Terasic DE0-Nano | Quartus Prime Lite 19.1 | balanced | `rv32imc` + `Zicsr` + `Zifencei` | 3934 (18%) | 1799 (8%) | 0 (0%) | 231424 (38%) | - | - | 100 MHz |
|
| 255 |
|
|
| Lattice | iCE40 UltraPlus `iCE40UP5K-SG48I` | Upduino v2.0 | Radiant 2.1 (LSE) | timing | `rv32ic` + `Zicsr` + `Zifencei` | 4895 (92%) | 1636 (31%) | 0 (0%) | - | 12 (40%) | 4 (100%) | *c* 22.875 MHz |
|
| 256 |
|
|
| Xilinx | Artix-7 `XC7A35TICSG324-1L` | Arty A7-35T | Vivado 2019.2 | default | `rv32imc` + `Zicsr` + `Zifencei` | 2432 (12%) | 1852 (4%) | 0 (0%) | - | 8 (16%) | - | *c* 100 MHz |
|
| 257 |
2 |
zero_gravi |
|
| 258 |
11 |
zero_gravi |
**Notes**
|
| 259 |
|
|
* The Lattice iCE40 UltraPlus setup uses the FPGA's SPRAM memory primitives for the internal IMEM and DEMEM (each 64kb).
|
| 260 |
12 |
zero_gravi |
The FPGA-specific memory components can be found in [`rtl/fpga_specific`](https://github.com/stnolting/neorv32/blob/master/rtl/fpga_specific/lattice_ice40up).
|
| 261 |
|
|
* The clock frequencies marked with a "c" are constrained clocks. The remaining ones are _f_max_ results from the place and route timing reports.
|
| 262 |
11 |
zero_gravi |
* The Upduino and the Arty board have on-board SPI flash memories for storing the FPGA configuration. These device can also be used by the default NEORV32
|
| 263 |
|
|
bootloader to store and automatically boot an application program after reset (both tested successfully).
|
| 264 |
2 |
zero_gravi |
|
| 265 |
|
|
## Performance
|
| 266 |
|
|
|
| 267 |
|
|
### CoreMark Benchmark
|
| 268 |
|
|
|
| 269 |
|
|
The [CoreMark CPU benchmark](https://www.eembc.org/coremark) was executed on the NEORV32 and is available in the
|
| 270 |
|
|
[sw/example/coremark](https://github.com/stnolting/neorv32/blob/master/sw/example/coremark) project folder. This benchmark
|
| 271 |
|
|
tests the capabilities of a CPU itself rather than the functions provided by the whole system / SoC.
|
| 272 |
|
|
|
| 273 |
14 |
zero_gravi |
Results generated for hardware version: `1.3.0.0`
|
| 274 |
2 |
zero_gravi |
|
| 275 |
|
|
~~~
|
| 276 |
|
|
**Configuration**
|
| 277 |
12 |
zero_gravi |
Hardware: 32kB IMEM, 16kB DMEM, 100MHz clock
|
| 278 |
|
|
CoreMark: 2000 iterations, MEM_METHOD is MEM_STACK
|
| 279 |
14 |
zero_gravi |
Compiler: RISCV32-GCC 10.1.0
|
| 280 |
12 |
zero_gravi |
Peripherals: UART for printing the results
|
| 281 |
2 |
zero_gravi |
~~~
|
| 282 |
|
|
|
| 283 |
18 |
zero_gravi |
| CPU | Executable Size | Optimization | CoreMark Score | CoreMarks/MHz |
|
| 284 |
|
|
|:----------|:---------------:|:------------:|:--------------:|:-------------:|
|
| 285 |
|
|
| `rv32i` | 21 600 bytes | `-O2` | 27.02 | 0.2702 |
|
| 286 |
|
|
| `rv32im` | 20 976 bytes | `-O2` | 57.14 | 0.5714 |
|
| 287 |
|
|
| `rv32imc` | 16 348 bytes | `-O2` | 57.14 | 0.5714 |
|
| 288 |
2 |
zero_gravi |
|
| 289 |
|
|
|
| 290 |
|
|
### Instruction Cycles
|
| 291 |
|
|
|
| 292 |
11 |
zero_gravi |
The NEORV32 CPU is based on a two-stages pipelined architecutre. Each stage uses a multi-cycle processing scheme. Hence,
|
| 293 |
9 |
zero_gravi |
each instruction requires several clock cycles to execute (2 cycles for ALU operations, ..., 40 cycles for divisions).
|
| 294 |
|
|
The average CPI (cycles per instruction) depends on the instruction mix of a specific applications and also on the available
|
| 295 |
2 |
zero_gravi |
CPU extensions.
|
| 296 |
|
|
|
| 297 |
|
|
Please note that the CPU-internal shifter (e.g. for the `SLL` instruction) as well as the multiplier and divider of the
|
| 298 |
|
|
`M` extension use a bit-serial approach and require several cycles for completion.
|
| 299 |
|
|
|
| 300 |
6 |
zero_gravi |
The following table shows the performance results for successfully running 2000 CoreMark
|
| 301 |
9 |
zero_gravi |
iterations, which reflects a pretty good "real-life" work load. The average CPI is computed by
|
| 302 |
12 |
zero_gravi |
dividing the total number of required clock cycles (only the timed core to avoid distortion due to IO wait cycles; sampled via the `cycle[h]` CSRs)
|
| 303 |
|
|
by the number of executed instructions (`instret[h]` CSRs). The executables were generated using optimization `-O2`.
|
| 304 |
2 |
zero_gravi |
|
| 305 |
14 |
zero_gravi |
Results generated for hardware version: `1.3.0.0`
|
| 306 |
2 |
zero_gravi |
|
| 307 |
18 |
zero_gravi |
| CPU | Required Clock Cycles | Executed Instructions | Average CPI |
|
| 308 |
|
|
|:----------|----------------------:|----------------------:|:-----------:|
|
| 309 |
|
|
| `rv32i` | 7 433 933 906 | 1 494 298 800 | 4.97 |
|
| 310 |
|
|
| `rv32im` | 3 589 861 906 | 628 281 454 | 5.71 |
|
| 311 |
|
|
| `rv32imc` | 3 587 131 226 | 628 282 016 | 5.70 |
|
| 312 |
2 |
zero_gravi |
|
| 313 |
|
|
|
| 314 |
12 |
zero_gravi |
|
| 315 |
14 |
zero_gravi |
## Top Entities
|
| 316 |
2 |
zero_gravi |
|
| 317 |
14 |
zero_gravi |
The top entity of the **processor** is [**neorv32_top.vhd**](https://github.com/stnolting/neorv32/blob/master/rtl/core/neorv32_top.vhd) (from the `rtl/core` folder).
|
| 318 |
2 |
zero_gravi |
Just instantiate this file in your project and you are ready to go! All signals of this top entity are of type *std_ulogic* or *std_ulogic_vector*, respectively
|
| 319 |
|
|
(except for the TWI signals, which are of type *std_logic*).
|
| 320 |
|
|
|
| 321 |
14 |
zero_gravi |
The top entity of the **CPU** is [**neorv32_cpu.vhd**](https://github.com/stnolting/neorv32/blob/master/rtl/core/neorv32_cpu.vhd) (from the `rtl/core` folder).
|
| 322 |
16 |
zero_gravi |
All signals of this top entity are of type *std_ulogic* or *std_ulogic_vector*, respectively.
|
| 323 |
14 |
zero_gravi |
|
| 324 |
|
|
Use the generics to configure the processor/CPU according to your needs. Each generic is initilized with the default configuration.
|
| 325 |
2 |
zero_gravi |
Detailed information regarding the signals and configuration generics can be found in the [NEORV32 documentary](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf).
|
| 326 |
|
|
|
| 327 |
14 |
zero_gravi |
Alternative top entities can be found in [`rtl/top_templates`](https://github.com/stnolting/neorv32/blob/master/rtl/top_templates) folder.
|
| 328 |
|
|
|
| 329 |
|
|
### Processor
|
| 330 |
|
|
|
| 331 |
2 |
zero_gravi |
```vhdl
|
| 332 |
|
|
entity neorv32_top is
|
| 333 |
|
|
generic (
|
| 334 |
|
|
-- General --
|
| 335 |
12 |
zero_gravi |
CLOCK_FREQUENCY : natural := 0; -- clock frequency of clk_i in Hz
|
| 336 |
8 |
zero_gravi |
BOOTLOADER_USE : boolean := true; -- implement processor-internal bootloader?
|
| 337 |
|
|
CSR_COUNTERS_USE : boolean := true; -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
|
| 338 |
12 |
zero_gravi |
USER_CODE : std_ulogic_vector(31 downto 0) := x"00000000"; -- custom user code
|
| 339 |
2 |
zero_gravi |
-- RISC-V CPU Extensions --
|
| 340 |
14 |
zero_gravi |
CPU_EXTENSION_RISCV_C : boolean := false; -- implement compressed extension?
|
| 341 |
8 |
zero_gravi |
CPU_EXTENSION_RISCV_E : boolean := false; -- implement embedded RF extension?
|
| 342 |
14 |
zero_gravi |
CPU_EXTENSION_RISCV_M : boolean := false; -- implement muld/div extension?
|
| 343 |
15 |
zero_gravi |
CPU_EXTENSION_RISCV_U : boolean := false; -- implement user mode extension?
|
| 344 |
8 |
zero_gravi |
CPU_EXTENSION_RISCV_Zicsr : boolean := true; -- implement CSR system?
|
| 345 |
|
|
CPU_EXTENSION_RISCV_Zifencei : boolean := true; -- implement instruction stream sync.?
|
| 346 |
15 |
zero_gravi |
-- Physical Memory Protection (PMP) --
|
| 347 |
|
|
PMP_USE : boolean := false; -- implement PMP?
|
| 348 |
16 |
zero_gravi |
PMP_NUM_REGIONS : natural := 4; -- number of regions (max 8)
|
| 349 |
|
|
PMP_GRANULARITY : natural := 14; -- minimal region granularity (1=8B, 2=16B, 3=32B, ...) default is 64k
|
| 350 |
2 |
zero_gravi |
-- Memory configuration: Instruction memory --
|
| 351 |
8 |
zero_gravi |
MEM_ISPACE_BASE : std_ulogic_vector(31 downto 0) := x"00000000"; -- base address of instruction memory space
|
| 352 |
|
|
MEM_ISPACE_SIZE : natural := 16*1024; -- total size of instruction memory space in byte
|
| 353 |
14 |
zero_gravi |
MEM_INT_IMEM_USE : boolean := true; -- implement processor-internal instruction memory
|
| 354 |
8 |
zero_gravi |
MEM_INT_IMEM_SIZE : natural := 16*1024; -- size of processor-internal instruction memory in bytes
|
| 355 |
14 |
zero_gravi |
MEM_INT_IMEM_ROM : boolean := false; -- implement processor-internal instruction memory as ROM
|
| 356 |
2 |
zero_gravi |
-- Memory configuration: Data memory --
|
| 357 |
8 |
zero_gravi |
MEM_DSPACE_BASE : std_ulogic_vector(31 downto 0) := x"80000000"; -- base address of data memory space
|
| 358 |
|
|
MEM_DSPACE_SIZE : natural := 8*1024; -- total size of data memory space in byte
|
| 359 |
|
|
MEM_INT_DMEM_USE : boolean := true; -- implement processor-internal data memory
|
| 360 |
|
|
MEM_INT_DMEM_SIZE : natural := 8*1024; -- size of processor-internal data memory in bytes
|
| 361 |
2 |
zero_gravi |
-- Memory configuration: External memory interface --
|
| 362 |
8 |
zero_gravi |
MEM_EXT_USE : boolean := false; -- implement external memory bus interface?
|
| 363 |
|
|
MEM_EXT_REG_STAGES : natural := 2; -- number of interface register stages (0,1,2)
|
| 364 |
14 |
zero_gravi |
MEM_EXT_TIMEOUT : natural := 15; -- cycles after which a valid bus access will timeout
|
| 365 |
2 |
zero_gravi |
-- Processor peripherals --
|
| 366 |
8 |
zero_gravi |
IO_GPIO_USE : boolean := true; -- implement general purpose input/output port unit (GPIO)?
|
| 367 |
|
|
IO_MTIME_USE : boolean := true; -- implement machine system timer (MTIME)?
|
| 368 |
|
|
IO_UART_USE : boolean := true; -- implement universal asynchronous receiver/transmitter (UART)?
|
| 369 |
|
|
IO_SPI_USE : boolean := true; -- implement serial peripheral interface (SPI)?
|
| 370 |
|
|
IO_TWI_USE : boolean := true; -- implement two-wire interface (TWI)?
|
| 371 |
|
|
IO_PWM_USE : boolean := true; -- implement pulse-width modulation unit (PWM)?
|
| 372 |
|
|
IO_WDT_USE : boolean := true; -- implement watch dog timer (WDT)?
|
| 373 |
|
|
IO_TRNG_USE : boolean := false; -- implement true random number generator (TRNG)?
|
| 374 |
|
|
IO_DEVNULL_USE : boolean := true -- implement dummy device (DEVNULL)?
|
| 375 |
2 |
zero_gravi |
);
|
| 376 |
|
|
port (
|
| 377 |
|
|
-- Global control --
|
| 378 |
14 |
zero_gravi |
clk_i : in std_ulogic := '0'; -- global clock, rising edge
|
| 379 |
|
|
rstn_i : in std_ulogic := '0'; -- global reset, low-active, async
|
| 380 |
2 |
zero_gravi |
-- Wishbone bus interface (available if MEM_EXT_USE = true) --
|
| 381 |
14 |
zero_gravi |
wb_adr_o : out std_ulogic_vector(31 downto 0); -- address
|
| 382 |
|
|
wb_dat_i : in std_ulogic_vector(31 downto 0) := (others => '0'); -- read data
|
| 383 |
|
|
wb_dat_o : out std_ulogic_vector(31 downto 0); -- write data
|
| 384 |
|
|
wb_we_o : out std_ulogic; -- read/write
|
| 385 |
|
|
wb_sel_o : out std_ulogic_vector(03 downto 0); -- byte enable
|
| 386 |
|
|
wb_stb_o : out std_ulogic; -- strobe
|
| 387 |
|
|
wb_cyc_o : out std_ulogic; -- valid cycle
|
| 388 |
|
|
wb_ack_i : in std_ulogic := '0'; -- transfer acknowledge
|
| 389 |
|
|
wb_err_i : in std_ulogic := '0'; -- transfer error
|
| 390 |
12 |
zero_gravi |
-- Advanced memory control signals (available if MEM_EXT_USE = true) --
|
| 391 |
14 |
zero_gravi |
fence_o : out std_ulogic; -- indicates an executed FENCE operation
|
| 392 |
|
|
fencei_o : out std_ulogic; -- indicates an executed FENCEI operation
|
| 393 |
2 |
zero_gravi |
-- GPIO (available if IO_GPIO_USE = true) --
|
| 394 |
14 |
zero_gravi |
gpio_o : out std_ulogic_vector(15 downto 0); -- parallel output
|
| 395 |
|
|
gpio_i : in std_ulogic_vector(15 downto 0) := (others => '0'); -- parallel input
|
| 396 |
2 |
zero_gravi |
-- UART (available if IO_UART_USE = true) --
|
| 397 |
14 |
zero_gravi |
uart_txd_o : out std_ulogic; -- UART send data
|
| 398 |
|
|
uart_rxd_i : in std_ulogic := '0'; -- UART receive data
|
| 399 |
2 |
zero_gravi |
-- SPI (available if IO_SPI_USE = true) --
|
| 400 |
14 |
zero_gravi |
spi_sck_o : out std_ulogic; -- SPI serial clock
|
| 401 |
|
|
spi_sdo_o : out std_ulogic; -- controller data out, peripheral data in
|
| 402 |
|
|
spi_sdi_i : in std_ulogic := '0'; -- controller data in, peripheral data out
|
| 403 |
|
|
spi_csn_o : out std_ulogic_vector(07 downto 0); -- SPI CS
|
| 404 |
2 |
zero_gravi |
-- TWI (available if IO_TWI_USE = true) --
|
| 405 |
14 |
zero_gravi |
twi_sda_io : inout std_logic := 'H'; -- twi serial data line
|
| 406 |
|
|
twi_scl_io : inout std_logic := 'H'; -- twi serial clock line
|
| 407 |
2 |
zero_gravi |
-- PWM (available if IO_PWM_USE = true) --
|
| 408 |
14 |
zero_gravi |
pwm_o : out std_ulogic_vector(03 downto 0); -- pwm channels
|
| 409 |
|
|
-- Interrupts --
|
| 410 |
|
|
msw_irq_i : in std_ulogic := '0'; -- machine software interrupt
|
| 411 |
|
|
mext_irq_i : in std_ulogic := '0' -- machine external interrupt
|
| 412 |
2 |
zero_gravi |
);
|
| 413 |
|
|
end neorv32_top;
|
| 414 |
|
|
```
|
| 415 |
|
|
|
| 416 |
14 |
zero_gravi |
### CPU
|
| 417 |
2 |
zero_gravi |
|
| 418 |
14 |
zero_gravi |
```vhdl
|
| 419 |
|
|
entity neorv32_cpu is
|
| 420 |
|
|
generic (
|
| 421 |
|
|
-- General --
|
| 422 |
|
|
CSR_COUNTERS_USE : boolean := true; -- implement RISC-V perf. counters ([m]instret[h], [m]cycle[h], time[h])?
|
| 423 |
|
|
HW_THREAD_ID : std_ulogic_vector(31 downto 0):= (others => '0'); -- hardware thread id
|
| 424 |
|
|
CPU_BOOT_ADDR : std_ulogic_vector(31 downto 0):= (others => '0'); -- cpu boot address
|
| 425 |
|
|
-- RISC-V CPU Extensions --
|
| 426 |
|
|
CPU_EXTENSION_RISCV_C : boolean := false; -- implement compressed extension?
|
| 427 |
|
|
CPU_EXTENSION_RISCV_E : boolean := false; -- implement embedded RF extension?
|
| 428 |
|
|
CPU_EXTENSION_RISCV_M : boolean := false; -- implement muld/div extension?
|
| 429 |
15 |
zero_gravi |
CPU_EXTENSION_RISCV_U : boolean := false; -- implement user mode extension?
|
| 430 |
14 |
zero_gravi |
CPU_EXTENSION_RISCV_Zicsr : boolean := true; -- implement CSR system?
|
| 431 |
|
|
CPU_EXTENSION_RISCV_Zifencei : boolean := true; -- implement instruction stream sync.?
|
| 432 |
15 |
zero_gravi |
-- Physical Memory Protection (PMP) --
|
| 433 |
|
|
PMP_USE : boolean := false; -- implement PMP?
|
| 434 |
16 |
zero_gravi |
PMP_NUM_REGIONS : natural := 4; -- number of regions (max 8)
|
| 435 |
|
|
PMP_GRANULARITY : natural := 14; -- minimal region granularity (1=8B, 2=16B, 3=32B, ...) default is 64k
|
| 436 |
14 |
zero_gravi |
-- Bus Interface --
|
| 437 |
|
|
BUS_TIMEOUT : natural := 15 -- cycles after which a valid bus access will timeout
|
| 438 |
|
|
);
|
| 439 |
|
|
port (
|
| 440 |
|
|
-- global control --
|
| 441 |
|
|
clk_i : in std_ulogic := '0'; -- global clock, rising edge
|
| 442 |
|
|
rstn_i : in std_ulogic := '0'; -- global reset, low-active, async
|
| 443 |
|
|
-- instruction bus interface --
|
| 444 |
|
|
i_bus_addr_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus access address
|
| 445 |
|
|
i_bus_rdata_i : in std_ulogic_vector(data_width_c-1 downto 0) := (others => '0'); -- bus read data
|
| 446 |
|
|
i_bus_wdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus write data
|
| 447 |
|
|
i_bus_ben_o : out std_ulogic_vector(03 downto 0); -- byte enable
|
| 448 |
|
|
i_bus_we_o : out std_ulogic; -- write enable
|
| 449 |
|
|
i_bus_re_o : out std_ulogic; -- read enable
|
| 450 |
|
|
i_bus_cancel_o : out std_ulogic; -- cancel current bus transaction
|
| 451 |
|
|
i_bus_ack_i : in std_ulogic := '0'; -- bus transfer acknowledge
|
| 452 |
|
|
i_bus_err_i : in std_ulogic := '0'; -- bus transfer error
|
| 453 |
|
|
i_bus_fence_o : out std_ulogic; -- executed FENCEI operation
|
| 454 |
|
|
-- data bus interface --
|
| 455 |
|
|
d_bus_addr_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus access address
|
| 456 |
|
|
d_bus_rdata_i : in std_ulogic_vector(data_width_c-1 downto 0) := (others => '0'); -- bus read data
|
| 457 |
|
|
d_bus_wdata_o : out std_ulogic_vector(data_width_c-1 downto 0); -- bus write data
|
| 458 |
|
|
d_bus_ben_o : out std_ulogic_vector(03 downto 0); -- byte enable
|
| 459 |
|
|
d_bus_we_o : out std_ulogic; -- write enable
|
| 460 |
|
|
d_bus_re_o : out std_ulogic; -- read enable
|
| 461 |
|
|
d_bus_cancel_o : out std_ulogic; -- cancel current bus transaction
|
| 462 |
|
|
d_bus_ack_i : in std_ulogic := '0'; -- bus transfer acknowledge
|
| 463 |
|
|
d_bus_err_i : in std_ulogic := '0'; -- bus transfer error
|
| 464 |
|
|
d_bus_fence_o : out std_ulogic; -- executed FENCE operation
|
| 465 |
|
|
-- system time input from MTIME --
|
| 466 |
|
|
time_i : in std_ulogic_vector(63 downto 0) := (others => '0'); -- current system time
|
| 467 |
|
|
-- interrupts (risc-v compliant) --
|
| 468 |
|
|
msw_irq_i : in std_ulogic := '0'; -- machine software interrupt
|
| 469 |
|
|
mext_irq_i : in std_ulogic := '0'; -- machine external interrupt
|
| 470 |
|
|
mtime_irq_i : in std_ulogic := '0'; -- machine timer interrupt
|
| 471 |
|
|
-- fast interrupts (custom) --
|
| 472 |
|
|
firq_i : in std_ulogic_vector(3 downto 0) := (others => '0')
|
| 473 |
|
|
);
|
| 474 |
|
|
end neorv32_cpu;
|
| 475 |
|
|
```
|
| 476 |
2 |
zero_gravi |
|
| 477 |
14 |
zero_gravi |
|
| 478 |
|
|
|
| 479 |
2 |
zero_gravi |
## Getting Started
|
| 480 |
|
|
|
| 481 |
|
|
This overview is just a short excerpt from the *Let's Get It Started* section of the NEORV32 documentary:
|
| 482 |
|
|
|
| 483 |
|
|
[ NEORV32 datasheet](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf)
|
| 484 |
|
|
|
| 485 |
|
|
|
| 486 |
14 |
zero_gravi |
### Toolchain
|
| 487 |
2 |
zero_gravi |
|
| 488 |
|
|
At first you need the **RISC-V GCC toolchain**. You can either [download the sources](https://github.com/riscv/riscv-gnu-toolchain)
|
| 489 |
|
|
and build the toolchain by yourself, or you can download a prebuilt one and install it.
|
| 490 |
|
|
|
| 491 |
14 |
zero_gravi |
:warning: Keep in mind that – for instance – a `rv32imc` toolchain only provides library code compiled with compressed and
|
| 492 |
|
|
`mul`/`div` instructions! Hence, this code cannot be executed (without emulation) on an architecture without these extensions!
|
| 493 |
2 |
zero_gravi |
|
| 494 |
14 |
zero_gravi |
To build the toolchain by yourself, follow the official [build instructions](https://github.com/riscv/riscv-gnu-toolchain.
|
| 495 |
|
|
Make sure to use the `ilp32` or `ilp32e` ABI.
|
| 496 |
2 |
zero_gravi |
|
| 497 |
15 |
zero_gravi |
**Alternatively**, you can download a prebuilt toolchain. I have uploaded the toolchains I am using to GitHub. These toolchains
|
| 498 |
|
|
were compiled on a 64-bit x86 Ubuntu 20.04 LTS (Ubuntu on Windows, actually). Download the toolchain of choice:
|
| 499 |
2 |
zero_gravi |
|
| 500 |
|
|
[https://github.com/stnolting/riscv_gcc_prebuilt](https://github.com/stnolting/riscv_gcc_prebuilt)
|
| 501 |
|
|
|
| 502 |
|
|
|
| 503 |
11 |
zero_gravi |
### Dowload the NEORV32 and Create a Hardware Project
|
| 504 |
2 |
zero_gravi |
|
| 505 |
12 |
zero_gravi |
Get the sources of the NEORV32 Processor project. You can either download a [release](https://github.com/stnolting/neorv32/releases)
|
| 506 |
|
|
or get the most recent version of this project as [`*.zip` file](https://github.com/stnolting/neorv32/archive/master.zip) or using `git clone` (suggested for easy project updates via `git pull`):
|
| 507 |
|
|
|
| 508 |
2 |
zero_gravi |
$ git clone https://github.com/stnolting/neorv32.git
|
| 509 |
|
|
|
| 510 |
12 |
zero_gravi |
Create a new project with your FPGA design tool of choice and add all the `*.vhd` files from the [`rtl/core`](https://github.com/stnolting/neorv32/blob/master/rtl)
|
| 511 |
|
|
folder to this project. Make sure to add them to a **new library** called `neorv32`.
|
| 512 |
2 |
zero_gravi |
|
| 513 |
11 |
zero_gravi |
You can either instantiate the [processor's top entity](https://github.com/stnolting/neorv32#top-entity) in your own project or you
|
| 514 |
|
|
can use a simple [test setup](https://github.com/stnolting/neorv32/blob/master/rtl/top_templates/neorv32_test_setup.vhd) (from the project's
|
| 515 |
|
|
[`rtl/top_templates`](https://github.com/stnolting/neorv32/blob/master/rtl/top_templates) folder) as top entity.
|
| 516 |
12 |
zero_gravi |
This test setup instantiates the processor and implements most of the peripherals and some ISA extensions. Only the UART, clock, reset and some GPIO output sginals are
|
| 517 |
11 |
zero_gravi |
propagated (basically, its a FPGA "hello world" example):
|
| 518 |
2 |
zero_gravi |
|
| 519 |
|
|
```vhdl
|
| 520 |
9 |
zero_gravi |
entity neorv32_test_setup is
|
| 521 |
|
|
port (
|
| 522 |
|
|
-- Global control --
|
| 523 |
|
|
clk_i : in std_ulogic := '0'; -- global clock, rising edge
|
| 524 |
|
|
rstn_i : in std_ulogic := '0'; -- global reset, low-active, async
|
| 525 |
|
|
-- GPIO --
|
| 526 |
|
|
gpio_o : out std_ulogic_vector(7 downto 0); -- parallel output
|
| 527 |
|
|
-- UART --
|
| 528 |
|
|
uart_txd_o : out std_ulogic; -- UART send data
|
| 529 |
|
|
uart_rxd_i : in std_ulogic := '0' -- UART receive data
|
| 530 |
|
|
);
|
| 531 |
|
|
end neorv32_test_setup;
|
| 532 |
2 |
zero_gravi |
```
|
| 533 |
|
|
|
| 534 |
|
|
|
| 535 |
|
|
### Compiling and Uploading One of the Example Projects
|
| 536 |
|
|
|
| 537 |
11 |
zero_gravi |
Make sure `GNU Make` and a native `GCC` compiler are installed. To test the installation of the RISC-V toolchain navigate to an example project like
|
| 538 |
2 |
zero_gravi |
`sw/example/blink_led` and run:
|
| 539 |
|
|
|
| 540 |
|
|
neorv32/sw/example/blink_led$ make check
|
| 541 |
|
|
|
| 542 |
9 |
zero_gravi |
The NEORV32 project includes some [example programs](https://github.com/stnolting/neorv32/tree/master/sw/example) from
|
| 543 |
|
|
which you can start your own application. Simply compile one of these projects. This will create a NEORV32
|
| 544 |
|
|
executable `neorv32_exe.bin` in the same folder.
|
| 545 |
2 |
zero_gravi |
|
| 546 |
|
|
neorv32/sw/example/blink_led$ make clean_all compile
|
| 547 |
|
|
|
| 548 |
|
|
Connect your FPGA board via UART to you computer and open the according port to interface with the NEORV32 bootloader. The bootloader
|
| 549 |
|
|
uses the following default UART configuration:
|
| 550 |
|
|
|
| 551 |
|
|
- 19200 Baud
|
| 552 |
|
|
- 8 data bits
|
| 553 |
|
|
- 1 stop bit
|
| 554 |
|
|
- No parity bits
|
| 555 |
|
|
- No transmission / flow control protocol (raw bytes only)
|
| 556 |
|
|
- Newline on `\r\n` (carriage return & newline)
|
| 557 |
|
|
|
| 558 |
9 |
zero_gravi |
Use the bootloader console to upload the `neorv32_exe.bin` file and run your application image.
|
| 559 |
2 |
zero_gravi |
|
| 560 |
9 |
zero_gravi |
```
|
| 561 |
|
|
<< NEORV32 Bootloader >>
|
| 562 |
|
|
|
| 563 |
|
|
BLDV: Jul 6 2020
|
| 564 |
|
|
HWV: 1.0.1.0
|
| 565 |
|
|
CLK: 0x0134FD90 Hz
|
| 566 |
13 |
zero_gravi |
USER: 0x0001CE40
|
| 567 |
9 |
zero_gravi |
MISA: 0x42801104
|
| 568 |
|
|
CONF: 0x03FF0035
|
| 569 |
|
|
IMEM: 0x00010000 bytes @ 0x00000000
|
| 570 |
|
|
DMEM: 0x00010000 bytes @ 0x80000000
|
| 571 |
|
|
|
| 572 |
|
|
Autoboot in 8s. Press key to abort.
|
| 573 |
|
|
Aborted.
|
| 574 |
|
|
|
| 575 |
|
|
Available CMDs:
|
| 576 |
|
|
h: Help
|
| 577 |
|
|
r: Restart
|
| 578 |
|
|
u: Upload
|
| 579 |
|
|
s: Store to flash
|
| 580 |
|
|
l: Load from flash
|
| 581 |
|
|
e: Execute
|
| 582 |
|
|
CMD:> u
|
| 583 |
|
|
Awaiting neorv32_exe.bin... OK
|
| 584 |
|
|
CMD:> e
|
| 585 |
|
|
Booting...
|
| 586 |
|
|
|
| 587 |
|
|
Blinking LED demo program
|
| 588 |
|
|
```
|
| 589 |
2 |
zero_gravi |
|
| 590 |
9 |
zero_gravi |
Going further: Take a look at the _Let's Get It Started!_ chapter of the [ NEORV32 datasheet](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf).
|
| 591 |
2 |
zero_gravi |
|
| 592 |
|
|
|
| 593 |
|
|
|
| 594 |
9 |
zero_gravi |
## Contribute
|
| 595 |
2 |
zero_gravi |
|
| 596 |
9 |
zero_gravi |
I'm always thankful for help! So if you have any questions, bug reports, ideas or if you want to give some kind of feedback, feel free
|
| 597 |
|
|
to open a [new issue](https://github.com/stnolting/neorv32/issues).
|
| 598 |
2 |
zero_gravi |
|
| 599 |
9 |
zero_gravi |
If you want to get involved you can also directly drop me a line (mailto:stnolting@gmail.com).
|
| 600 |
|
|
Please also check out the project's [code of conduct](https://github.com/stnolting/neorv32/tree/master/CODE_OF_CONDUCT.md).
|
| 601 |
2 |
zero_gravi |
|
| 602 |
|
|
|
| 603 |
9 |
zero_gravi |
|
| 604 |
11 |
zero_gravi |
## Legal
|
| 605 |
2 |
zero_gravi |
|
| 606 |
12 |
zero_gravi |
This project is released under the BSD 3-Clause license. No copyright infringement intended.
|
| 607 |
11 |
zero_gravi |
Other implied or used projects might have different licensing - see their documentation to get more information.
|
| 608 |
|
|
|
| 609 |
|
|
#### Citation
|
| 610 |
|
|
|
| 611 |
2 |
zero_gravi |
If you are using the NEORV32 Processor in some kind of publication, please cite it as follows:
|
| 612 |
|
|
|
| 613 |
|
|
> S. Nolting, "The NEORV32 Processor", github.com/stnolting/neorv32
|
| 614 |
|
|
|
| 615 |
9 |
zero_gravi |
#### BSD 3-Clause License
|
| 616 |
2 |
zero_gravi |
|
| 617 |
|
|
Copyright (c) 2020, Stephan Nolting. All rights reserved.
|
| 618 |
|
|
|
| 619 |
|
|
Redistribution and use in source and binary forms, with or without modification, are
|
| 620 |
|
|
permitted provided that the following conditions are met:
|
| 621 |
|
|
|
| 622 |
|
|
1. Redistributions of source code must retain the above copyright notice, this list of
|
| 623 |
|
|
conditions and the following disclaimer.
|
| 624 |
|
|
2. Redistributions in binary form must reproduce the above copyright notice, this list of
|
| 625 |
|
|
conditions and the following disclaimer in the documentation and/or other materials
|
| 626 |
|
|
provided with the distribution.
|
| 627 |
|
|
3. Neither the name of the copyright holder nor the names of its contributors may be used to
|
| 628 |
|
|
endorse or promote products derived from this software without specific prior written
|
| 629 |
|
|
permission.
|
| 630 |
|
|
|
| 631 |
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
|
| 632 |
|
|
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
| 633 |
|
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
| 634 |
|
|
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
| 635 |
|
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
| 636 |
|
|
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
| 637 |
|
|
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
| 638 |
|
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
| 639 |
|
|
OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 640 |
|
|
|
| 641 |
|
|
|
| 642 |
9 |
zero_gravi |
#### Limitation of Liability for External Links
|
| 643 |
|
|
|
| 644 |
|
|
Our website contains links to the websites of third parties („external links“). As the
|
| 645 |
|
|
content of these websites is not under our control, we cannot assume any liability for
|
| 646 |
|
|
such external content. In all cases, the provider of information of the linked websites
|
| 647 |
|
|
is liable for the content and accuracy of the information provided. At the point in time
|
| 648 |
|
|
when the links were placed, no infringements of the law were recognisable to us. As soon
|
| 649 |
|
|
as an infringement of the law becomes known to us, we will immediately remove the
|
| 650 |
|
|
link in question.
|
| 651 |
|
|
|
| 652 |
|
|
|
| 653 |
11 |
zero_gravi |
#### Proprietary Notice
|
| 654 |
9 |
zero_gravi |
|
| 655 |
2 |
zero_gravi |
"Windows" is a trademark of Microsoft Corporation.
|
| 656 |
|
|
|
| 657 |
|
|
"Artix" and "Vivado" are trademarks of Xilinx Inc.
|
| 658 |
|
|
|
| 659 |
11 |
zero_gravi |
"Cyclone", "Quartus Prime", "Quartus Prime Lite" and "Avalon Bus" are trademarks of Intel Corporation.
|
| 660 |
2 |
zero_gravi |
|
| 661 |
11 |
zero_gravi |
"Artix" and "Vivado" are trademarks of Xilinx, Inc.
|
| 662 |
|
|
|
| 663 |
2 |
zero_gravi |
"iCE40", "UltraPlus" and "Lattice Radiant" are trademarks of Lattice Semiconductor Corporation.
|
| 664 |
|
|
|
| 665 |
13 |
zero_gravi |
"AXI" and "AXI-Lite" are trademarks of Arm Holdings plc.
|
| 666 |
2 |
zero_gravi |
|
| 667 |
|
|
|
| 668 |
18 |
zero_gravi |
## Acknowledgements
|
| 669 |
9 |
zero_gravi |
|
| 670 |
18 |
zero_gravi |
[](https://riscv.org/)
|
| 671 |
|
|
|
| 672 |
11 |
zero_gravi |
[RISC-V](https://riscv.org/) - Instruction Sets Want To Be Free :heart:
|
| 673 |
|
|
|
| 674 |
2 |
zero_gravi |
[](https://travis-ci.com/stnolting/neorv32)
|
| 675 |
|
|
|
| 676 |
|
|
Continous integration provided by [Travis CI](https://travis-ci.com/stnolting/neorv32) and powered by [GHDL](https://github.com/ghdl/ghdl).
|
| 677 |
|
|
|
| 678 |
|
|
|
| 679 |
|
|

|
| 680 |
|
|
|
| 681 |
|
|
This project is not affiliated with or endorsed by the Open Source Initiative (https://www.oshwa.org / https://opensource.org).
|
| 682 |
|
|
|
| 683 |
|
|
|
| 684 |
14 |
zero_gravi |
|
| 685 |
6 |
zero_gravi |
Made with :coffee: in Hannover, Germany.
|