OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [README.md] - Blame information for rev 58

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 50 zero_gravi
[![NEORV32](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/figures/neorv32_logo_dark.png)](https://github.com/stnolting/neorv32)
2 2 zero_gravi
 
3 37 zero_gravi
# The NEORV32 RISC-V Processor
4
 
5 43 zero_gravi
[![Processor Check](https://github.com/stnolting/neorv32/workflows/Processor%20Check/badge.svg)](https://github.com/stnolting/neorv32/actions?query=workflow%3A%22Processor+Check%22)
6 52 zero_gravi
[![riscv-arch-test](https://github.com/stnolting/neorv32/actions/workflows/riscv-arch-test.yml/badge.svg)](https://github.com/stnolting/neorv32/actions/workflows/riscv-arch-test.yml)
7 2 zero_gravi
[![license](https://img.shields.io/github/license/stnolting/neorv32)](https://github.com/stnolting/neorv32/blob/master/LICENSE)
8
[![release](https://img.shields.io/github/v/release/stnolting/neorv32)](https://github.com/stnolting/neorv32/releases)
9 57 zero_gravi
[![datasheet](https://img.shields.io/badge/data%20sheet-NEORV32.pdf-ffbd00)](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf)
10 2 zero_gravi
 
11 32 zero_gravi
* [Overview](#Overview)
12 47 zero_gravi
* [Status](#Status)
13 2 zero_gravi
* [Features](#Features)
14
* [FPGA Implementation Results](#FPGA-Implementation-Results)
15
* [Performance](#Performance)
16 30 zero_gravi
* [Top Entities](#Top-Entities)
17 2 zero_gravi
* [**Getting Started**](#Getting-Started)
18 40 zero_gravi
* [Contribute/Feedback/Questions](#ContributeFeedbackQuestions)
19 2 zero_gravi
* [Legal](#Legal)
20
 
21
 
22
 
23 32 zero_gravi
## Overview
24 2 zero_gravi
 
25 54 zero_gravi
![neorv32 Overview](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/figures/neorv32_processor.png)
26
 
27 23 zero_gravi
The NEORV32 Processor is a customizable microcontroller-like system on chip (SoC) that is based
28 56 zero_gravi
on the RISC-V NEORV32 CPU. The processor is intended as auxiliary processor in larger SoC
29 55 zero_gravi
designs or as *ready-to-go* stand-alone custom microcontroller.
30 2 zero_gravi
 
31 51 zero_gravi
:books: For detailed information take a look at the [NEORV32 data sheet (pdf)](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf).
32 57 zero_gravi
The `asciidoc` sources can be found in [`docs/src_adoc`](https://github.com/stnolting/neorv32/blob/master/docs/src_adoc). The latest automatic build
33
can be downloaded as artifacts from the [_Build Data Sheet_ GitHub workflow](https://github.com/stnolting/neorv32/actions/workflows/build_datasheet.yml).
34 51 zero_gravi
The doxygen-based documentation of the *software framework* is available online at [GitHub-pages](https://stnolting.github.io/neorv32/files.html).
35 45 zero_gravi
 
36 51 zero_gravi
:label: The project’s change log is available as [CHANGELOG.md](https://github.com/stnolting/neorv32/blob/master/CHANGELOG.md) in the root directory of this repository.
37
To see the changes between *stable* releases visit the project's [release page](https://github.com/stnolting/neorv32/releases).
38 11 zero_gravi
 
39 56 zero_gravi
:rocket: The [`boards`](https://github.com/stnolting/neorv32/tree/master/boards) folder provides exemplary setups targeting various FPGA boards to get you started.
40
 
41 52 zero_gravi
:spiral_notepad: Check out the [project boards](https://github.com/stnolting/neorv32/projects) for a list of current **ideas**,
42
**TODOs**, features being **planned** and **work-in-progress**.
43 40 zero_gravi
 
44 51 zero_gravi
:bulb: Feel free to open a [new issue](https://github.com/stnolting/neorv32/issues) or start a [new discussion](https://github.com/stnolting/neorv32/discussions)
45
if you have questions, comments, ideas or bug-fixes. Check out how to [contribute](#ContributeFeedbackQuestions).
46 47 zero_gravi
 
47 51 zero_gravi
 
48 32 zero_gravi
### Key Features
49 2 zero_gravi
 
50 52 zero_gravi
* RISC-V 32-bit `rv32` [**NEORV32 CPU**](#NEORV32-CPU-Features), compatible to
51 51 zero_gravi
  * subset of the *Unprivileged ISA Specification* [(Version 2.2)](https://github.com/stnolting/neorv32/blob/master/docs/riscv-spec.pdf)
52
  * subset of the *Privileged Architecture Specification* [(Version 1.12-draft)](https://github.com/stnolting/neorv32/blob/master/docs/riscv-privileged.pdf)
53 52 zero_gravi
  * the [official RISC-V architecture tests](#Status) (*passing*)
54
* Configurable RISC-V-compatible CPU extensions
55 51 zero_gravi
  * [`A`](#A---Atomic-memory-access-extension) - atomic memory access instructions (optional)
56 52 zero_gravi
  * [`B`](#B---Bit-manipulation-instructions-extension) - Bit manipulation instructions (optional) :construction:
57 51 zero_gravi
  * [`C`](#C---Compressed-instructions-extension) - compressed instructions (16-bit) (optional)
58
  * [`E`](#E---Embedded-CPU-version-extension) - embedded CPU (reduced register file size) (optional)
59
  * [`I`](#I---Base-integer-instruction-set) - base integer instruction set (always enabled)
60
  * [`M`](#M---Integer-multiplication-and-division-hardware-extension) - integer multiplication and division hardware (optional)
61
  * [`U`](#U---Privileged-architecture---User-mode-extension) - less-privileged *user mode* (optional)
62
  * [`X`](#X---NEORV32-specific-CPU-extensions) - NEORV32-specific extensions (always enabled)
63 55 zero_gravi
  * [`Zfinx`](#Zfinx---Single-precision-floating-point-extension) - Single-precision floating-point extensions (optional)
64 51 zero_gravi
  * [`Zicsr`](#Zicsr---Privileged-architecture---CSR-access-extension) - control and status register access instructions (+ exception/irq system) (optional)
65 56 zero_gravi
  * [`Zifencei`](#Zifencei---Instruction-stream-synchronization-extension) - instruction stream synchronization (optional)
66 51 zero_gravi
  * [`PMP`](#PMP---Privileged-architecture---Physical-memory-protection) - physical memory protection (optional)
67
  * [`HPM`](#HPM---Privileged-architecture---Hardware-performance-monitors) - hardware performance monitors (optional)
68 39 zero_gravi
* Full-scale RISC-V microcontroller system / **SoC** [**NEORV32 Processor**](#NEORV32-Processor-Features) with optional submodules
69 41 zero_gravi
  * optional embedded memories (instructions/data/bootloader, RAM/ROM) and caches
70 52 zero_gravi
  * timers (watch dog, RISC-V-compatible machine timer)
71 50 zero_gravi
  * serial interfaces (SPI, TWI, UARTs)
72 47 zero_gravi
  * general purpose IO and PWM channels
73 37 zero_gravi
  * external bus interface (Wishbone / [AXI4](#AXI4-Connectivity))
74 53 zero_gravi
  * dedicated NeoPixel(TM) LED interface
75 48 zero_gravi
  * subsystem for custom co-processors
76 37 zero_gravi
  * [more ...](#NEORV32-Processor-Features)
77 36 zero_gravi
* Software framework
78 37 zero_gravi
  * core libraries for high-level usage of the provided functions and peripherals
79
  * application compilation based on [GNU makefiles](https://github.com/stnolting/neorv32/blob/master/sw/example/blink_led/makefile)
80 46 zero_gravi
  * GCC-based toolchain ([pre-compiled toolchains available](https://github.com/stnolting/riscv-gcc-prebuilt))
81 45 zero_gravi
  * bootloader with UART interface console
82 36 zero_gravi
  * runtime environment
83
  * several example programs
84 55 zero_gravi
  * [doxygen-based](https://github.com/stnolting/neorv32/blob/master/docs/Doxyfile) software documentation: available on [GitHub pages](https://stnolting.github.io/neorv32/files.html)
85 36 zero_gravi
  * [FreeRTOS port](https://github.com/stnolting/neorv32/blob/master/sw/example/demo_freeRTOS) available
86 34 zero_gravi
* [**Full-blown data sheet**](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf) (pdf)
87 32 zero_gravi
* Completely described in behavioral, platform-independent VHDL - no primitives, macros, etc.
88
* Fully synchronous design, no latches, no gated clocks
89
* Small hardware footprint and high operating frequency
90 15 zero_gravi
 
91 22 zero_gravi
 
92 2 zero_gravi
### Design Principles
93
 
94 39 zero_gravi
 * From zero to *hello_world*: Completely open source and documented.
95 2 zero_gravi
 * Plain VHDL without technology-specific parts like attributes, macros or primitives.
96
 * Easy to use – working out of the box.
97
 * Clean synchronous design, no wacky combinatorial interfaces.
98 51 zero_gravi
 * Be as small as possible – but with a reasonable size-performance trade-off.
99 40 zero_gravi
 * Be as RISC-V-compliant as possible.
100 51 zero_gravi
 * The processor has to fit in a Lattice iCE40 UltraPlus 5k low-power FPGA running at 22+ MHz.
101 2 zero_gravi
 
102
 
103 36 zero_gravi
### Status
104 3 zero_gravi
 
105 57 zero_gravi
The processor is [synthesizable](#FPGA-Implementation-Results) (tested on *real hardware* using Intel Quartus Prime, Xilinx Vivado and Lattice Radiant) and can successfully execute
106
all the [provided example programs](https://github.com/stnolting/neorv32/tree/master/sw/example) including the [CoreMark benchmark](#CoreMark-Benchmark) and the custom
107
NEORV32 processor check ([`sw/example/cpu_test`](https://github.com/stnolting/neorv32/tree/master/sw/example/cpu_test), see the status report in the according
108
[GitHub workflow](https://github.com/stnolting/neorv32/actions/workflows/processor-check.yml)).
109 2 zero_gravi
 
110 52 zero_gravi
**RISC-V Architecture Tests**: The processor passes the official `rv32_m/C`, `rv32_m/I`, `rv32_m/M`, `rv32_m/privilege` and `rv32_m/Zifencei`
111
[riscv-arch-test](https://github.com/riscv/riscv-arch-test) tests. More information regarding the NEORV32 port of the riscv-arch-test test framework can be found in
112
[`riscv-arch-test/README.md`](https://github.com/stnolting/neorv32/blob/master/riscv-arch-test/README.md).
113 2 zero_gravi
 
114 43 zero_gravi
| Project component | CI status |
115
|:----------------- |:----------|
116 58 zero_gravi
| [NEORV32 processor](https://github.com/stnolting/neorv32)                                                  | [![Processor Check](https://github.com/stnolting/neorv32/workflows/Processor%20Check/badge.svg)](https://github.com/stnolting/neorv32/actions?query=workflow%3A%22Processor+Check%22) |
117
| [SW Framework Documentation (online at GH-pages)](https://stnolting.github.io/neorv32/files.html)          | [![Doc@GitHub-pages](https://github.com/stnolting/neorv32/workflows/Deploy%20SW%20Framework%20Documentation%20to%20GitHub-Pages/badge.svg)](https://stnolting.github.io/neorv32/files.html) |
118
| Build data sheet from [`asciidoc` sources](https://github.com/stnolting/neorv32/blob/master/docs/src_adoc) | [![Build Data Sheet](https://github.com/stnolting/neorv32/actions/workflows/build_datasheet.yml/badge.svg)](https://github.com/stnolting/neorv32/actions/workflows/build_datasheet.yml) |
119
| [Pre-built toolchains](https://github.com/stnolting/riscv-gcc-prebuilt)                                    | [![Test Toolchains](https://github.com/stnolting/riscv-gcc-prebuilt/workflows/Test%20Toolchains/badge.svg)](https://github.com/stnolting/riscv-gcc-prebuilt/actions?query=workflow%3A%22Test+Toolchains%22) |
120
| [RISC-V architecture test](https://github.com/stnolting/neorv32/blob/master/riscv-arch-test/README.md)     | [![riscv-arch-test](https://github.com/stnolting/neorv32/actions/workflows/riscv-arch-test.yml/badge.svg)](https://github.com/stnolting/neorv32/actions/workflows/riscv-arch-test.yml) |
121 6 zero_gravi
 
122
 
123 2 zero_gravi
## Features
124
 
125 34 zero_gravi
The full-blown data sheet of the NEORV32 Processor and CPU is available as pdf file:
126 40 zero_gravi
[:page_facing_up: NEORV32 data sheet](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf).
127 31 zero_gravi
 
128 44 zero_gravi
 
129 36 zero_gravi
### NEORV32 Processor Features
130 2 zero_gravi
 
131 23 zero_gravi
The NEORV32 Processor provides a full-scale microcontroller-like SoC based on the NEORV32 CPU. The setup
132 37 zero_gravi
is highly customizable via the processor's top generics and already provides the following *optional* modules:
133 2 zero_gravi
 
134 41 zero_gravi
* processor-internal data and instruction memories (**DMEM** / **IMEM**) & cache (**iCACHE**)
135
* bootloader (**BOOTLDROM**) with UART console and automatic application boot from SPI flash option
136 52 zero_gravi
* machine system timer (**MTIME**), RISC-V-compatible
137 37 zero_gravi
* watchdog timer (**WDT**)
138 51 zero_gravi
* two independent universal asynchronous receivers and transmitters (**UART0** & **UART1**) with optional hardware flow control (RTS/CTS)
139 37 zero_gravi
* 8/16/24/32-bit serial peripheral interface controller (**SPI**) with 8 dedicated chip select lines
140
* two wire serial interface controller (**TWI**), with optional clock-stretching, compatible to the I²C standard
141
* general purpose parallel IO port (**GPIO**), 32xOut & 32xIn, with pin-change interrupt
142 52 zero_gravi
* 32-bit external bus interface, Wishbone b4 compatible (**WISHBONE**)
143 37 zero_gravi
* wrapper for **AXI4-Lite Master Interface** (see [AXI Connectivity](#AXI4-Connectivity))
144
* PWM controller with 4 channels and 8-bit duty cycle resolution (**PWM**)
145 47 zero_gravi
* ring-oscillator-based true random number generator (**TRNG**)
146
* custom functions subsystem (**CFS**) for tightly-coupled custom co-processor extensions
147 49 zero_gravi
* numerically-controlled oscillator (**NCO**) with three independent channels
148 52 zero_gravi
* smart LED interface (**NEOLED**) - WS2812 / NeoPixel(c) compatible
149 51 zero_gravi
* system configuration information memory to check hardware configuration by software (**SYSINFO**)
150 23 zero_gravi
 
151 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
152 44 zero_gravi
 
153 56 zero_gravi
 
154 36 zero_gravi
### NEORV32 CPU Features
155 2 zero_gravi
 
156 52 zero_gravi
The NEORV32 CPU implements the
157 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
158 40 zero_gravi
[RISC-V privileged architecture specifications (1.12-draft)](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/riscv-spec.pdf)
159 52 zero_gravi
- tested via the [official riscv-arch-test Test Framework](https://github.com/riscv/riscv-arch-test)
160
(see [`riscv-arch-test/README`](https://github.com/stnolting/neorv32/blob/master/riscv-arch-test/README.md)).
161 2 zero_gravi
 
162 11 zero_gravi
More information regarding the CPU including a detailed list of the instruction set and the available CSRs can be found in
163 40 zero_gravi
the [:page_facing_up: NEORV32 data sheet](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf).
164 11 zero_gravi
 
165
 
166 47 zero_gravi
#### General Features
167
 
168 26 zero_gravi
  * Modified Harvard architecture (separate CPU interfaces for data and instructions; NEORV32 processor: Single processor-internal bus via I/D mux)
169 12 zero_gravi
  * Two stages in-order pipeline (FETCH, EXECUTE); each stage uses a multi-cycle processing scheme
170 15 zero_gravi
  * No hardware support of unaligned accesses - they will trigger an exception
171 40 zero_gravi
  * BIG-ENDIAN byte-order, processor's external memory interface allows endianness configuration to connect to system with different endianness
172 23 zero_gravi
  * All reserved or unimplemented instructions will raise an illegal instruction exception
173 15 zero_gravi
  * Privilege levels: `machine` mode, `user` mode (if enabled via `U` extension)
174 33 zero_gravi
  * Official [RISC-V open-source architecture ID](https://github.com/riscv/riscv-isa-manual/blob/master/marchid.md)
175 11 zero_gravi
 
176 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
177 11 zero_gravi
 
178 56 zero_gravi
 
179 51 zero_gravi
#### `A` - Atomic memory access extension
180 2 zero_gravi
 
181 47 zero_gravi
  * Supported instructions: `LR.W` (load-reservate) `SC.W` (store-conditional)
182
 
183 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
184 47 zero_gravi
 
185 56 zero_gravi
 
186 51 zero_gravi
#### `B` - Bit manipulation instructions extension
187 47 zero_gravi
 
188 53 zero_gravi
  * :construction: **work-in-progress** :construction:
189
  * :warning: this extension has not been officially ratified yet!
190
  * :books: more information can be found here: [RISC-V `B` spec.](https://github.com/riscv/riscv-bitmanip)
191 47 zero_gravi
  * Compatible to [v0.94-draft](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/bitmanip-draft.pdf) of the bit manipulation spec
192 55 zero_gravi
  * Software support via intrinsic library (see [`sw/example/bit_manipulation`](https://github.com/stnolting/neorv32/tree/master/sw/example/bit_manipulation))
193 52 zero_gravi
  * `Zbb` base instruction set: `CLZ` `CTZ` `CPOP` `SEXT.B` `SEXT.H` `MIN[U]` `MAX[U]` `ANDN` `ORN` `XNOR` `ROL` `ROR[I]` `zext`(*pseudo-instruction* for `PACK rd, rs, zero`) `rev8`(*pseudo-instruction* for `GREVI rd, rs, -8`) `orc.b`(*pseudo-instruction* for `GORCI rd, rs, 7`)
194
  * `Zbs` single-bit instructions: `SBSET[I]` `SBCLR[I]` `SBINV[I]` `SBEXT[I]`
195 53 zero_gravi
  * `Zba` shifted-add instructions: `SH1ADD` `SH2ADD` `SH3ADD`
196 47 zero_gravi
 
197 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
198 47 zero_gravi
 
199 56 zero_gravi
 
200 51 zero_gravi
#### `C` - Compressed instructions extension
201 47 zero_gravi
 
202 51 zero_gravi
  * ALU instructions: `C.ADDI4SPN` `C.ADD[I]` `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`
203 7 zero_gravi
  * Jump and branch instructions: `C.J` `C.JAL` `C.JR` `C.JALR` `C.BEQZ` `C.BNEZ`
204 2 zero_gravi
  * Memory instructions: `C.LW` `C.SW` `C.LWSP` `C.SWSP`
205 52 zero_gravi
  * System instructions: `C.EBREAK` (requires `Zicsr` extension)
206 40 zero_gravi
  * Pseudo-instructions are not listed
207 2 zero_gravi
 
208 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
209
 
210
 
211 51 zero_gravi
#### `E` - Embedded CPU version extension
212 47 zero_gravi
 
213 52 zero_gravi
  * Reduced register file (only the 16 lowest registers are implemented)
214 2 zero_gravi
 
215 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
216 47 zero_gravi
 
217 56 zero_gravi
 
218 51 zero_gravi
#### `I` - Base integer instruction set
219 47 zero_gravi
 
220 51 zero_gravi
  * ALU instructions: `LUI` `AUIPC` `ADD[I]` `SLT[I][U]` `XOR[I]` `OR[I]` `AND[I]` `SLL[I]` `SRL[I]` `SRA[I]` `SUB`
221 47 zero_gravi
  * Jump and branch instructions: `JAL` `JALR` `BEQ` `BNE` `BLT` `BGE` `BLTU` `BGEU`
222
  * Memory instructions: `LB` `LH` `LW` `LBU` `LHU` `SB` `SH` `SW`
223
  * System instructions: `ECALL` `EBREAK` `FENCE`
224
  * Pseudo-instructions are not listed
225
 
226 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
227 47 zero_gravi
 
228 56 zero_gravi
 
229 51 zero_gravi
#### `M` - Integer multiplication and division hardware extension
230 47 zero_gravi
 
231 2 zero_gravi
  * Multiplication instructions: `MUL` `MULH` `MULHSU` `MULHU`
232
  * Division instructions: `DIV` `DIVU` `REM` `REMU`
233 19 zero_gravi
  * By default, the multiplier and divider cores use an iterative bit-serial processing scheme
234
  * Multiplications can be mapped to DSPs via the `FAST_MUL_EN` generic to increase performance
235 2 zero_gravi
 
236 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
237 39 zero_gravi
 
238 56 zero_gravi
 
239 51 zero_gravi
#### `U` - Privileged architecture - User mode extension
240 44 zero_gravi
 
241 47 zero_gravi
  * Requires `Zicsr` extension
242
  * Privilege levels: `M` (machine mode) + less-privileged `U` (user mode)
243
 
244 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
245 47 zero_gravi
 
246 56 zero_gravi
 
247 51 zero_gravi
#### `X` - NEORV32-specific CPU extensions
248 47 zero_gravi
 
249
* The NEORV32-specific extensions are always enabled and are indicated via the `X` bit set in the `misa` CSR.
250 48 zero_gravi
* 16 *fast interrupt* request channels with according control/status bits in `mie` and `mip` and custom exception codes in `mcause`
251 47 zero_gravi
* `mzext` CSR to check for implemented `Z*` CPU extensions (like `Zifencei`)
252
* All undefined/umimplemented/malformed/illegal instructions do raise an illegal instruction exception
253
 
254 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
255 47 zero_gravi
 
256 56 zero_gravi
 
257 55 zero_gravi
#### `Zfinx` - Single-precision floating-point extension
258 53 zero_gravi
 
259
  * :warning: this extension has not been officially ratified yet!
260
  * :books: more information can be found here: [RISC-V `Zfinx` spec.](https://github.com/riscv/riscv-zfinx)
261 55 zero_gravi
  * Software support via intrinsic library (see [`sw/example/floating_point_test`](https://github.com/stnolting/neorv32/tree/master/sw/example/floating_point_test))
262
  * Fused multiply-add instructions (`F[N]MADD.S` & `F[N)MSUB.S`) are **not** supported!
263
  * Computational instructions: `FADD.S` `FSUB.S` `FMUL.S` `FSGNJ[N/X].S` `FCLASS.S` ~~`FDIV.S`~~ ~~`FSQRT.S`~~
264
  * Comparison instructions: `FMIN.S` `FMAX.S` `FEQ.S` `FLT.S` `FLE.S`
265
  * Conversion instructions: `FCVT.W.S` `FCVT.WU.S` `FCVT.S.W` `FCVT.S.WU`
266
  * Additional CSRs: `fcsr` `frm` `fflags`
267 56 zero_gravi
 
268
[[back to top](#The-NEORV32-RISC-V-Processor)]
269 55 zero_gravi
 
270 53 zero_gravi
 
271 51 zero_gravi
#### `Zicsr` - Privileged architecture - CSR access extension
272 47 zero_gravi
 
273 2 zero_gravi
  * Privilege levels: `M-mode` (Machine mode)
274 51 zero_gravi
  * CSR access instructions: `CSRRW[I]` `CSRRS[I]` `CSRRC[I]`
275 8 zero_gravi
  * System instructions: `MRET` `WFI`
276 40 zero_gravi
  * Pseudo-instructions are not listed
277 42 zero_gravi
  * Counter CSRs: `[m]cycle[h]` `[m]instret[m]` `time[h]` `[m]hpmcounter*[h]`(3..31, configurable) `mcounteren` `mcountinhibit` `mhpmevent*`(3..31, configurable)
278
  * Machine CSRs: `mstatus[h]` `misa`(read-only!) `mie` `mtvec` `mscratch` `mepc` `mcause` `mtval` `mip` `mvendorid` [`marchid`](https://github.com/riscv/riscv-isa-manual/blob/master/marchid.md) `mimpid` `mhartid` `mzext`(custom)
279 52 zero_gravi
  * Supported (sync.) exceptions (implementing the RISC-V specs):
280 2 zero_gravi
    * Misaligned instruction address
281 51 zero_gravi
    * Instruction access fault (via timeout/error after unacknowledged bus access)
282 2 zero_gravi
    * Illegal instruction
283 4 zero_gravi
    * Breakpoint (via `ebreak` instruction)
284 2 zero_gravi
    * Load address misaligned
285 51 zero_gravi
    * Load access fault (via timeout/error after unacknowledged bus access)
286 4 zero_gravi
    * Store address misaligned
287 38 zero_gravi
    * Store access fault (via unacknowledged bus access after timeout)
288 40 zero_gravi
    * Environment call from U-mode (via `ecall` instruction in user mode)
289
    * Environment call from M-mode (via `ecall` instruction in machine mode)
290 55 zero_gravi
  * Supported interrupts:
291 58 zero_gravi
    * RISC-V non-maskable interrupt `nmi` (via external signal)
292 55 zero_gravi
    * RISC-V machine timer interrupt `mti` (via processor-internal MTIME unit *or* external signal)
293
    * RISC-V machine software interrupt `msi` (via external signal)
294
    * RISC-V machine external interrupt `mei` (via external signal)
295
    * 16 fast interrupt requests, 6+1 available for custom usage
296 2 zero_gravi
 
297 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
298 15 zero_gravi
 
299 47 zero_gravi
 
300 56 zero_gravi
#### `Zifencei` - Instruction stream synchronization extension
301
 
302 41 zero_gravi
  * System instructions: `FENCE.I` (among others, used to clear and reload instruction cache)
303 8 zero_gravi
 
304 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
305 47 zero_gravi
 
306 56 zero_gravi
 
307 51 zero_gravi
#### `PMP` - Privileged architecture - Physical memory protection
308 47 zero_gravi
 
309
  * Requires `Zicsr` extension
310 44 zero_gravi
  * Configurable number of regions (0..63)
311 42 zero_gravi
  * Additional machine CSRs: `pmpcfg*`(0..15) `pmpaddr*`(0..63)
312 2 zero_gravi
 
313 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
314 47 zero_gravi
 
315 56 zero_gravi
 
316 51 zero_gravi
#### `HPM` - Privileged architecture - Hardware performance monitors
317 47 zero_gravi
 
318
  * Requires `Zicsr` extension
319 44 zero_gravi
  * Configurable number of counters (0..29)
320
  * Additional machine CSRs: `mhpmevent*`(3..31) `[m]hpmcounter*[h]`(3..31)
321 15 zero_gravi
 
322 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
323 23 zero_gravi
 
324 56 zero_gravi
 
325 52 zero_gravi
### :warning: Non-RISC-V-Compatible Issues and Limitations
326 44 zero_gravi
 
327 40 zero_gravi
* CPU and Processor are BIG-ENDIAN, but this should be no problem as the external memory bus interface provides big- and little-endian configurations
328 30 zero_gravi
* `misa` CSR is read-only - no dynamic enabling/disabling of synthesized CPU extensions during runtime; for compatibility: write accesses (in m-mode) are ignored and do not cause an exception
329 58 zero_gravi
* `mip` CSR is read-only - pending IRQs can be cleared using `mie`
330 42 zero_gravi
* The physical memory protection (**PMP**) only supports `NAPOT` mode yet and a minimal granularity of 8 bytes
331 56 zero_gravi
* The `A` extension only implements `lr.w` and `sc.w` instructions yet. However, these instructions are sufficient to emulate all remaining AMO operations
332 23 zero_gravi
 
333 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
334 23 zero_gravi
 
335
 
336 56 zero_gravi
 
337 2 zero_gravi
## FPGA Implementation Results
338
 
339 23 zero_gravi
### NEORV32 CPU
340
 
341
This chapter shows exemplary implementation results of the NEORV32 CPU for an **Intel Cyclone IV EP4CE22F17C6N FPGA** on
342 37 zero_gravi
a DE0-nano board. The design was synthesized using **Intel Quartus Prime Lite 20.1** ("balanced implementation"). The timing
343 4 zero_gravi
information is derived from the Timing Analyzer / Slow 1200mV 0C Model. If not otherwise specified, the default configuration
344 42 zero_gravi
of the CPU's generics is assumed (e.g. no physical memory protection, no hardware performance monitors).
345 49 zero_gravi
No constraints were used at all.
346 2 zero_gravi
 
347 55 zero_gravi
Results generated for hardware version [`1.5.3.2`](https://github.com/stnolting/neorv32/blob/master/CHANGELOG.md).
348 2 zero_gravi
 
349 55 zero_gravi
| CPU Configuration                                 | LEs  | FFs  | Memory bits | DSPs (9-bit) | f_max   |
350
|:--------------------------------------------------|:----:|:----:|:-----------:|:------------:|:-------:|
351
| `rv32i`                                           |  980 |  409 |        1024 |            0 | 123 MHz |
352
| `rv32i`    + `Zicsr`                              | 1835 |  856 |        1024 |            0 | 124 MHz |
353
| `rv32im`   + `Zicsr`                              | 2443 | 1134 |        1024 |            0 | 124 MHz |
354
| `rv32imc`  + `Zicsr`                              | 2669 | 1149 |        1024 |            0 | 125 MHz |
355
| `rv32imac` + `Zicsr`                              | 2685 | 1156 |        1024 |            0 | 124 MHz |
356
| `rv32imac` + `Zicsr` + `u`                        | 2698 | 1162 |        1024 |            0 | 124 MHz |
357
| `rv32imac` + `Zicsr` + `u` + `Zifencei`           | 2715 | 1162 |        1024 |            0 | 122 MHz |
358 56 zero_gravi
| `rv32imac` + `Zicsr` + `u` + `Zifencei` + `Zfinx` | 4004 | 1812 |        1024 |            7 | 121 MHz |
359 2 zero_gravi
 
360 49 zero_gravi
Setups with enabled "embedded CPU extension" `E` show the same LUT and FF utilization and identical f_max as the according `I` configuration.
361 55 zero_gravi
However, the size of the register file is cut in half.
362 2 zero_gravi
 
363 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
364 39 zero_gravi
 
365 56 zero_gravi
 
366 23 zero_gravi
### NEORV32 Processor-Internal Peripherals and Memories
367
 
368 58 zero_gravi
Results generated for hardware version [`1.5.4.9`](https://github.com/stnolting/neorv32/blob/master/CHANGELOG.md)
369
(mandatory core modules in **bold**).
370 11 zero_gravi
 
371 58 zero_gravi
| Module        | Description                                         | LEs | FFs | Memory bits | DSPs (9-bit) |
372
|:--------------|:----------------------------------------------------|----:|----:|------------:|-------------:|
373
| Boot ROM      | Bootloader ROM (4kB)                                |   3 |   1 |       32768 |    0         |
374
| **BUSKEEPER** | Processor-internal bus monitor                      |  11 |   6 |           0 |    0         |
375
| **BUSSWITCH** | Bus mux for CPU instr. and data interface           |  49 |   8 |           0 |    0         |
376
| CFS           | Custom functions subsystem                          |   - |   - |           - |    -         |
377
| DMEM          | Processor-internal data memory (8kB)                |  18 |   2 |       65536 |    0         |
378
| GPIO          | General purpose input/output ports                  |  67 |  65 |           0 |    0         |
379
| iCACHE        | Instruction cache (1x4 blocks, 256 bytes per block) | 220 | 154 |        8192 |    0         |
380
| IMEM          | Processor-internal instruction memory (16kB)        |   6 |   2 |      131072 |    0         |
381
| MTIME         | Machine system timer                                | 289 | 200 |           0 |    0         |
382
| NCO           | Numerically-controlled oscillator                   | 254 | 226 |           0 |    0         |
383
| NEOLED        | Smart LED Interface (NeoPixel/WS28128) [4xFIFO]     | 347 | 309 |           0 |    0         |
384
| PWM           | Pulse_width modulation controller                   |  71 |  69 |           0 |    0         |
385
| SPI           | Serial peripheral interface                         | 138 | 124 |           0 |    0         |
386
| **SYSINFO**   | System configuration information memory             |  10 |  10 |           0 |    0         |
387
| TRNG          | True random number generator                        | 132 | 105 |           0 |    0         |
388
| TWI           | Two-wire interface                                  |  77 |  44 |           0 |    0         |
389
| UART0/1       | Universal asynchronous receiver/transmitter 0/1     | 176 | 132 |           0 |    0         |
390
| WDT           | Watchdog timer                                      |  60 |  45 |           0 |    0         |
391
| WISHBONE      | External memory interface                           | 129 | 104 |           0 |    0         |
392 2 zero_gravi
 
393 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
394 2 zero_gravi
 
395 56 zero_gravi
 
396 23 zero_gravi
### NEORV32 Processor - Exemplary FPGA Setups
397 6 zero_gravi
 
398 56 zero_gravi
:information_source: Check out the [`boards`](https://github.com/stnolting/neorv32/tree/master/boards) folder for exemplary setups targeting various FPGA boards.
399 6 zero_gravi
 
400 56 zero_gravi
The following tables show exemplary processor implementation results for different FPGA platforms. The processor setups use *the default peripheral configuration* (like no *CFS* and no *TRNG*),
401
no external memory interface and only internal instruction and data memories. IMEM uses 16kB and DMEM uses 8kB memory space.
402
 
403 40 zero_gravi
Results generated for hardware version [`1.4.9.0`](https://github.com/stnolting/neorv32/blob/master/CHANGELOG.md).
404 6 zero_gravi
 
405 55 zero_gravi
| Vendor  | FPGA                              | Board            | Toolchain                  | CPU Configuration                              | LUT / LE   | FF / REG   | DSP (9-bit) | Memory Bits  | BRAM / EBR | SPRAM    | Frequency     |
406
|:--------|:----------------------------------|:-----------------|:---------------------------|:-----------------------------------------------|:-----------|:-----------|:------------|:-------------|:-----------|:---------|--------------:|
407
| Intel   | Cyclone IV `EP4CE22F17C6N`        | Terasic DE0-Nano | Quartus Prime Lite 20.1    | `rv32imc` + `u` + `Zicsr` + `Zifencei`         | 3813 (17%) | 1904  (8%) | 0 (0%)      | 231424 (38%) |          - |        - |       119 MHz |
408
| Lattice | iCE40 UltraPlus `iCE40UP5K-SG48I` | Upduino v2.0     | Radiant 2.1 (Synplify Pro) | `rv32ic`  + `u` + `Zicsr` + `Zifencei`         | 4397 (83%) | 1679 (31%) | 0 (0%)      |            - |   12 (40%) | 4 (100%) | *c* 22.15 MHz |
409
| Xilinx  | Artix-7 `XC7A35TICSG324-1L`       | Arty A7-35T      | Vivado 2019.2              | `rv32imc` + `u` + `Zicsr` + `Zifencei` + `PMP` | 2465 (12%) | 1912  (5%) | 0 (0%)      |            - |    8 (16%) |        - |   *c* 100 MHz |
410 2 zero_gravi
 
411 23 zero_gravi
**_Notes_**
412 56 zero_gravi
* The "default" implementation strategy of the according toolchain is used.
413 20 zero_gravi
* The Lattice iCE40 UltraPlus setup uses the FPGA's SPRAM memory primitives for the internal IMEM and DMEM (each 64kb).
414 12 zero_gravi
* The clock frequencies marked with a "c" are constrained clocks. The remaining ones are _f_max_ results from the place and route timing reports.
415 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
416
bootloader to store and automatically boot an application program after reset (both tested successfully).
417 40 zero_gravi
* The setups with `PMP` implement 2 regions with a minimal granularity of 64kB.
418 42 zero_gravi
* No HPM counters are implemented.
419 2 zero_gravi
 
420 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
421 22 zero_gravi
 
422
 
423 56 zero_gravi
 
424 2 zero_gravi
## Performance
425
 
426
### CoreMark Benchmark
427
 
428
The [CoreMark CPU benchmark](https://www.eembc.org/coremark) was executed on the NEORV32 and is available in the
429
[sw/example/coremark](https://github.com/stnolting/neorv32/blob/master/sw/example/coremark) project folder. This benchmark
430
tests the capabilities of a CPU itself rather than the functions provided by the whole system / SoC.
431
 
432
~~~
433
**Configuration**
434 56 zero_gravi
Hardware:       32kB IMEM, 8kB DMEM, no caches, 100MHz clock
435 38 zero_gravi
CoreMark:       2000 iterations, MEM_METHOD is MEM_STACK
436
Compiler:       RISCV32-GCC 10.1.0 (rv32i toolchain)
437
Compiler flags: default, see makefile
438 56 zero_gravi
Optimization:   -O3
439 38 zero_gravi
Peripherals:    UART for printing the results
440 2 zero_gravi
~~~
441
 
442 42 zero_gravi
Results generated for hardware version [`1.4.9.8`](https://github.com/stnolting/neorv32/blob/master/CHANGELOG.md).
443
 
444 56 zero_gravi
| CPU (including `Zicsr` extension)           | Executable Size | Optimization | CoreMark Score | CoreMarks/MHz |
445 34 zero_gravi
|:--------------------------------------------|:---------------:|:------------:|:--------------:|:-------------:|
446 42 zero_gravi
| `rv32i`                                     |    28 756 bytes |        `-O3` |          36.36 |    **0.3636** |
447
| `rv32imc`                                   |    22 008 bytes |        `-O3` |          68.97 |    **0.6897** |
448
| `rv32imc` + `FAST_MUL_EN` + `FAST_SHIFT_EN` |    22 008 bytes |        `-O3` |          90.91 |    **0.9091** |
449 2 zero_gravi
 
450 34 zero_gravi
The `FAST_MUL_EN` configuration uses DSPs for the multiplier of the `M` extension (enabled via the `FAST_MUL_EN` generic). The `FAST_SHIFT_EN` configuration
451
uses a barrel shifter for CPU shift operations (enabled via the `FAST_SHIFT_EN` generic).
452 2 zero_gravi
 
453 31 zero_gravi
When the `C` extension is enabled, branches to an unaligned uncompressed instruction require additional instruction fetch cycles.
454 22 zero_gravi
 
455 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
456 34 zero_gravi
 
457 56 zero_gravi
 
458 2 zero_gravi
### Instruction Cycles
459
 
460 11 zero_gravi
The NEORV32 CPU is based on a two-stages pipelined architecutre. Each stage uses a multi-cycle processing scheme. Hence,
461 9 zero_gravi
each instruction requires several clock cycles to execute (2 cycles for ALU operations, ..., 40 cycles for divisions).
462
The average CPI (cycles per instruction) depends on the instruction mix of a specific applications and also on the available
463 42 zero_gravi
CPU extensions. *By default* the CPU-internal shifter (e.g. for the `SLL` instruction) as well as the multiplier and divider of the
464 2 zero_gravi
`M` extension use a bit-serial approach and require several cycles for completion.
465
 
466 6 zero_gravi
The following table shows the performance results for successfully running 2000 CoreMark
467 9 zero_gravi
iterations, which reflects a pretty good "real-life" work load. The average CPI is computed by
468 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)
469 19 zero_gravi
by the number of executed instructions (`instret[h]` CSRs). The executables were generated using optimization `-O3`.
470 2 zero_gravi
 
471 42 zero_gravi
Results generated for hardware version [`1.4.9.8`](https://github.com/stnolting/neorv32/blob/master/CHANGELOG.md).
472 2 zero_gravi
 
473 56 zero_gravi
| CPU  (including `Zicsr` extension)          | Required Clock Cycles | Executed Instructions | Average CPI |
474 34 zero_gravi
|:--------------------------------------------|----------------------:|----------------------:|:-----------:|
475 42 zero_gravi
| `rv32i`                                     |         5 595 750 503 |         1 466 028 607 |    **3.82** |
476
| `rv32imc`                                   |         2 981 786 734 |           611 814 918 |    **4.87** |
477
| `rv32imc` + `FAST_MUL_EN` + `FAST_SHIFT_EN` |         2 265 135 174 |           611 814 948 |    **3.70** |
478 2 zero_gravi
 
479 34 zero_gravi
The `FAST_MUL_EN` configuration uses DSPs for the multiplier of the `M` extension (enabled via the `FAST_MUL_EN` generic). The `FAST_SHIFT_EN` configuration
480
uses a barrel shifter for CPU shift operations (enabled via the `FAST_SHIFT_EN` generic).
481
 
482 36 zero_gravi
When the `C` extension is enabled branches to an unaligned uncompressed instruction require additional instruction fetch cycles.
483 12 zero_gravi
 
484 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
485 22 zero_gravi
 
486 31 zero_gravi
 
487 56 zero_gravi
 
488 14 zero_gravi
## Top Entities
489 2 zero_gravi
 
490 51 zero_gravi
The top entity of the **NEORV32 Processor** (SoC) is [`rtl/core/neorv32_top.vhd`](https://github.com/stnolting/neorv32/blob/master/rtl/core/neorv32_top.vhd),
491
which provides a Wishbone b4-compatoible bus interface.
492 2 zero_gravi
 
493 51 zero_gravi
:information_source: It is recommended to use the processor setup even if you want to **use the CPU in stand-alone mode**. Simply disable all the processor-internal
494
modules via the generics and you will get a "CPU wrapper" that already provides a minimal CPU environment and an external memory interface (like AXI4).
495
This setup also allows to further use the default bootloader and software framework. From this base you can start building your own processor system.
496 14 zero_gravi
 
497 36 zero_gravi
Use the top's generics to configure the system according to your needs. Each generic is initilized with the default configuration.
498 34 zero_gravi
Detailed information regarding the interface signals and configuration generics can be found in
499 40 zero_gravi
the [:page_facing_up: NEORV32 data sheet](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf) (pdf).
500 22 zero_gravi
 
501 51 zero_gravi
All signals of the top entity are of type *std_ulogic* or *std_ulogic_vector*, respectively
502
(except for the processor's TWI signals, which are of type *std_logic*). Leave all unused output ports unconnected and tie all unused
503
input ports to zero.
504 23 zero_gravi
 
505 51 zero_gravi
**Alternative top entities**, like the simplified ["hello world" test setup](#Create-a-new-Hardware-Project) or CPU/Processor
506 36 zero_gravi
wrappers with resolved port signal types (i.e. *std_logic*), can be found in [`rtl/top_templates`](https://github.com/stnolting/neorv32/blob/master/rtl/top_templates).
507
 
508 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
509 36 zero_gravi
 
510 56 zero_gravi
 
511 35 zero_gravi
### AXI4 Connectivity
512 22 zero_gravi
 
513 35 zero_gravi
Via the [`rtl/top_templates/neorv32_top_axi4lite.vhd`](https://github.com/stnolting/neorv32/blob/master/rtl/top_templates/neorv32_top_axi4lite.vhd)
514
wrapper the NEORV32 provides an **AXI4-Lite** compatible master interface. This wrapper instantiates the default
515
[NEORV32 processor top entitiy](https://github.com/stnolting/neorv32/blob/master/rtl/core/neorv32_top.vhd) and implements a Wishbone to AXI4-Lite bridge.
516 2 zero_gravi
 
517 35 zero_gravi
The AXI4-Lite interface has been tested using Xilinx Vivado 19.2 block designer:
518
 
519
![AXI-SoC](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/figures/neorv32_axi_soc.png)
520
 
521
The processor was packed as custom IP using `neorv32_top_axi4lite.vhd` as top entity. The AXI interface is automatically detected by the packager.
522
All remaining IO interfaces are available as custom signals. The configuration generics are available via the "customize IP" dialog.
523
In the figure above the resulting IP block is named "neorv32_top_axi4lite_v1_0".
524
*(Note: Use Syntheiss option "global" when generating the block design to maintain the internal TWI tri-state drivers.)*
525
 
526
The setup uses an AXI interconnect to attach two block RAMs to the processor. Since the processor in this example is configured *without* IMEM and DMEM,
527
the attached block RAMs are used for storing instructions and data: the first RAM is used as instruction memory
528
and is mapped to address `0x00000000 - 0x00003fff` (16kB), the second RAM is used as data memory and is mapped to address `0x80000000 - 0x80001fff` (8kB).
529
 
530 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
531 35 zero_gravi
 
532
 
533 56 zero_gravi
 
534 2 zero_gravi
## Getting Started
535
 
536
This overview is just a short excerpt from the *Let's Get It Started* section of the NEORV32 documentary:
537
 
538 40 zero_gravi
[:page_facing_up: NEORV32 data sheet](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf)
539 2 zero_gravi
 
540
 
541 57 zero_gravi
### 0. Build the Documentation
542
 
543
This step is optional since there are pre-built versions of the [processor data sheet](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf)
544
and the [software documentation](https://stnolting.github.io/neorv32/files.html). If you want to build the documentation by yourself:
545
 
546
**NEORV32 Data Sheet**
547
 
548
To build the data sheet open a console and navigate to the project's `docs` folder. Run `$ sh make_datasheet.sh` (make sure `asciidoctor-pdf` is installed).
549
This will take all the `asciidoc` sources from [`docs/src_adoc`](https://github.com/stnolting/neorv32/blob/master/docs/src_adoc) to generate `docs/NEORV32.pdf`.
550
 
551
**Software Framework Documentation**
552
 
553
Make sure `doxygen` is installed. Open a console and navigate to the project's `docs` folder and run `$ doxygen Doxyfile`. This will create (if not already there)
554
a new folder `docs/doxygen_build/html` where doxygen will generate the HTML-based documentation pages. Open `docs/doxygen_build/html/files.html` to get started.
555
 
556
 
557 51 zero_gravi
### 1. Get the Toolchain
558 2 zero_gravi
 
559 50 zero_gravi
At first you need a **RISC-V GCC toolchain**. You can either [download the sources](https://github.com/riscv/riscv-gnu-toolchain)
560 2 zero_gravi
and build the toolchain by yourself, or you can download a prebuilt one and install it.
561
 
562 23 zero_gravi
To build the toolchain by yourself, follow the official [build instructions](https://github.com/riscv/riscv-gnu-toolchain).
563 14 zero_gravi
Make sure to use the `ilp32` or `ilp32e` ABI.
564 2 zero_gravi
 
565 15 zero_gravi
**Alternatively**, you can download a prebuilt toolchain. I have uploaded the toolchains I am using to GitHub. These toolchains
566 40 zero_gravi
were compiled on a 64-bit x86 Ubuntu 20.04 LTS (Ubuntu on Windows, actually). Download the toolchain of choice:
567 46 zero_gravi
[:octocat: github.com/stnolting/riscv-gcc-prebuilt](https://github.com/stnolting/riscv-gcc-prebuilt)
568 2 zero_gravi
 
569 45 zero_gravi
You can also use the toolchains provided by [SiFive](https://github.com/sifive/freedom-tools/releases). These are 64-bit toolchains that can also emit 32-bit
570 50 zero_gravi
RISC-V code. They were compiled for more sophisticated machines (`rv32imac`) so make sure the according NEORV32 hardware extensions are enabled.
571 2 zero_gravi
 
572 45 zero_gravi
:warning: Keep in mind that – for instance – a `rv32imc` toolchain only provides library code compiled with compressed and
573
`mul`/`div` instructions! Hence, this code cannot be executed (without emulation) on an architecture without these extensions!
574
 
575 50 zero_gravi
To check everything works fine, make sure `GNU Make` and a native `GCC` compiler are installed.
576
Test the installation of the RISC-V toolchain by navigating to an [example program project](https://github.com/stnolting/neorv32/tree/master/sw/example) like
577
`sw/example/blink_led` and running:
578 45 zero_gravi
 
579 50 zero_gravi
    neorv32/sw/example/blink_led$ make check
580 2 zero_gravi
 
581 50 zero_gravi
 
582 51 zero_gravi
### 2. Download the NEORV32 Project
583 50 zero_gravi
 
584 23 zero_gravi
Get the sources of the NEORV32 Processor project. The simplest way is using `git clone` (suggested for easy project updates via `git pull`):
585 12 zero_gravi
 
586 2 zero_gravi
    $ git clone https://github.com/stnolting/neorv32.git
587
 
588 23 zero_gravi
Alternatively, you can either download a specific [release](https://github.com/stnolting/neorv32/releases) or get the most recent version
589
of this project as [`*.zip` file](https://github.com/stnolting/neorv32/archive/master.zip).
590 2 zero_gravi
 
591 22 zero_gravi
 
592 51 zero_gravi
### 3. Create a new FPGA Project
593 22 zero_gravi
 
594 56 zero_gravi
:information_source: If want to use a script-based exemplary project setup check out the [`boards`](https://github.com/stnolting/neorv32/tree/master/boards) folder,
595
which provides exemplary setups targeting various FPGA boards.
596
 
597 23 zero_gravi
Create a new project with your FPGA design tool of choice. Add all the `*.vhd` files from the [`rtl/core`](https://github.com/stnolting/neorv32/blob/master/rtl)
598
folder to this project. Make sure to add these files to a **new design library** called `neorv32`.
599
 
600 40 zero_gravi
You can either instantiate the [processor's top entity](https://github.com/stnolting/neorv32/blob/master/rtl/core/neorv32_top.vhd) or one of its
601 51 zero_gravi
[wrappers](https://github.com/stnolting/neorv32/blob/master/rtl/top_templates) in your own project. If you just want to try thing out,
602
you can use the simple [**test setup** (`rtl/top_templates/neorv32_test_setup.vhd`)](https://github.com/stnolting/neorv32/blob/master/rtl/top_templates/neorv32_test_setup.vhd) as top entity.
603 2 zero_gravi
 
604 40 zero_gravi
![neorv32 test setup](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/figures/neorv32_test_setup.png)
605
 
606
 
607 51 zero_gravi
This test setup instantiates the processor and implements most of the peripherals and some ISA extensions. Only the UART0 communications lines, clock, reset and some
608
GPIO output signals are propagated as actual top entity interface signals. Basically, it is a FPGA version of a "hello world" example:
609 23 zero_gravi
 
610 2 zero_gravi
```vhdl
611 9 zero_gravi
  entity neorv32_test_setup is
612
    port (
613
      -- Global control --
614 50 zero_gravi
      clk_i       : in  std_ulogic := '0'; -- global clock, rising edge
615
      rstn_i      : in  std_ulogic := '0'; -- global reset, low-active, async
616 9 zero_gravi
      -- GPIO --
617 50 zero_gravi
      gpio_o      : out std_ulogic_vector(7 downto 0); -- parallel output
618
      -- UART0 --
619 51 zero_gravi
      uart0_txd_o : out std_ulogic;       -- UART0 send data
620 50 zero_gravi
      uart0_rxd_i : in  std_ulogic := '0' -- UART0 receive data
621 9 zero_gravi
    );
622
  end neorv32_test_setup;
623 2 zero_gravi
```
624
 
625
 
626 50 zero_gravi
### 4. Compile an Example Program
627 2 zero_gravi
 
628 50 zero_gravi
The NEORV32 project includes several [example program project](https://github.com/stnolting/neorv32/tree/master/sw/example) from
629
which you can start your own application. There are example programs to check out the processor's peripheral like I2C or the true-random number generator.
630 55 zero_gravi
And of course there is also a port of [Conway's Game of Life](https://github.com/stnolting/neorv32/tree/master/sw/example/game_of_life) available.
631 2 zero_gravi
 
632 50 zero_gravi
Simply compile one of these projects using
633 2 zero_gravi
 
634 23 zero_gravi
    neorv32/sw/example/blink_led$ make clean_all exe
635 2 zero_gravi
 
636 50 zero_gravi
This will create a NEORV32 *executable* `neorv32_exe.bin` in the same folder, which you can upload via the bootloader.
637 23 zero_gravi
 
638
 
639 50 zero_gravi
### 5. Upload the Executable via the Bootloader
640 34 zero_gravi
 
641 50 zero_gravi
Connect your FPGA board via UART to your computer and open the according port to interface with the fancy NEORV32 bootloader. The bootloader
642 2 zero_gravi
uses the following default UART configuration:
643
 
644 32 zero_gravi
* 19200 Baud
645
* 8 data bits
646
* 1 stop bit
647
* No parity bits
648
* No transmission / flow control protocol (raw bytes only)
649
* Newline on `\r\n` (carriage return & newline) - also for sent data
650 2 zero_gravi
 
651 51 zero_gravi
Use the bootloader console to upload the `neorv32_exe.bin` executable gerated during application compiling and *run* your application.
652 2 zero_gravi
 
653 9 zero_gravi
```
654 43 zero_gravi
<< NEORV32 Bootloader >>
655
 
656 55 zero_gravi
BLDV: Mar 23 2021
657
HWV:  0x01050208
658
CLK:  0x05F5E100
659
USER: 0x10000DE0
660
MISA: 0x40901105
661
ZEXT: 0x00000023
662
PROC: 0x0EFF0037
663
IMEM: 0x00004000 bytes @ 0x00000000
664
DMEM: 0x00002000 bytes @ 0x80000000
665 43 zero_gravi
 
666
Autoboot in 8s. Press key to abort.
667
Aborted.
668
 
669
Available CMDs:
670
 h: Help
671
 r: Restart
672
 u: Upload
673
 s: Store to flash
674
 l: Load from flash
675
 e: Execute
676
CMD:> u
677
Awaiting neorv32_exe.bin... OK
678
CMD:> e
679
Booting...
680
 
681
Blinking LED demo program
682 9 zero_gravi
```
683 2 zero_gravi
 
684 40 zero_gravi
Going further: Take a look at the _Let's Get It Started!_ chapter of the [:page_facing_up: NEORV32 data sheet](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/NEORV32.pdf).
685 2 zero_gravi
 
686 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
687 2 zero_gravi
 
688
 
689 40 zero_gravi
## Contribute/Feedback/Questions
690 2 zero_gravi
 
691 51 zero_gravi
I'm always thankful for help! So if you have any questions, bug reports, ideas or if you want to give any kind of feedback, feel free
692
to [open a new issue](https://github.com/stnolting/neorv32/issues), start a new [discussion on GitHub](https://github.com/stnolting/neorv32/discussions)
693
or directly [drop me a line](mailto:stnolting@gmail.com).
694 2 zero_gravi
 
695 51 zero_gravi
Here is a simple guide line if you'd like to contribute to this repository:
696 22 zero_gravi
 
697 51 zero_gravi
0. :star: this repository :wink:
698 40 zero_gravi
1. Check out the project's [code of conduct](https://github.com/stnolting/neorv32/tree/master/CODE_OF_CONDUCT.md)
699
2. [Fork](https://github.com/stnolting/neorv32/fork) this repository and clone the fork
700
3. Create a feature branch in your fork: `git checkout -b awesome_new_feature_branch`
701
4. Create a new remote for the upstream repo: `git remote add upstream https://github.com/stnolting/neorv32`
702
5. Commit your modifications: `git commit -m "Awesome new feature!"`
703
6. Push to the branch: `git push origin awesome_new_feature_branch`
704
7. Create a new [pull request](https://github.com/stnolting/neorv32/pulls)
705 2 zero_gravi
 
706 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
707 40 zero_gravi
 
708 56 zero_gravi
 
709 11 zero_gravi
## Legal
710 2 zero_gravi
 
711 12 zero_gravi
This project is released under the BSD 3-Clause license. No copyright infringement intended.
712 11 zero_gravi
Other implied or used projects might have different licensing - see their documentation to get more information.
713
 
714 37 zero_gravi
#### Citing
715 11 zero_gravi
 
716 51 zero_gravi
If you are using the NEORV32 or parts of the project in some kind of publication, please cite it as follows:
717 2 zero_gravi
 
718 51 zero_gravi
> S. Nolting, "The NEORV32 RISC-V Processor", github.com/stnolting/neorv32
719 2 zero_gravi
 
720 9 zero_gravi
#### BSD 3-Clause License
721 2 zero_gravi
 
722 42 zero_gravi
Copyright (c) 2021, Stephan Nolting. All rights reserved.
723 2 zero_gravi
 
724
Redistribution and use in source and binary forms, with or without modification, are
725
permitted provided that the following conditions are met:
726
 
727
1. Redistributions of source code must retain the above copyright notice, this list of
728
conditions and the following disclaimer.
729
2. Redistributions in binary form must reproduce the above copyright notice, this list of
730
conditions and the following disclaimer in the documentation and/or other materials
731
provided with the distribution.
732
3. Neither the name of the copyright holder nor the names of its contributors may be used to
733
endorse or promote products derived from this software without specific prior written
734
permission.
735
 
736
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
737
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
738
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
739
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
740
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
741
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
742
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
743
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
744
OF THE POSSIBILITY OF SUCH DAMAGE.
745
 
746
 
747 9 zero_gravi
#### Limitation of Liability for External Links
748
 
749 36 zero_gravi
Our website contains links to the websites of third parties ("external links"). As the
750 9 zero_gravi
content of these websites is not under our control, we cannot assume any liability for
751
such external content. In all cases, the provider of information of the linked websites
752
is liable for the content and accuracy of the information provided. At the point in time
753
when the links were placed, no infringements of the law were recognisable to us. As soon
754
as an infringement of the law becomes known to us, we will immediately remove the
755
link in question.
756
 
757
 
758 11 zero_gravi
#### Proprietary  Notice
759 9 zero_gravi
 
760 2 zero_gravi
"Artix" and "Vivado" are trademarks of Xilinx Inc.
761
 
762 45 zero_gravi
"Cyclone" and "Quartus Prime Lite" are trademarks of Intel Corporation.
763 2 zero_gravi
 
764 35 zero_gravi
"iCE40", "UltraPlus" and "Radiant" are trademarks of Lattice Semiconductor Corporation.
765 11 zero_gravi
 
766 35 zero_gravi
"AXI", "AXI4" and "AXI4-Lite" are trademarks of Arm Holdings plc.
767 2 zero_gravi
 
768 52 zero_gravi
"NeoPixel" is a trademark of Adafruit Industries.
769 2 zero_gravi
 
770 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
771 2 zero_gravi
 
772 52 zero_gravi
 
773 56 zero_gravi
 
774 18 zero_gravi
## Acknowledgements
775 9 zero_gravi
 
776 18 zero_gravi
[![RISC-V](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/figures/riscv_logo.png)](https://riscv.org/)
777
 
778 23 zero_gravi
[RISC-V](https://riscv.org/) - Instruction Sets Want To Be Free!
779 11 zero_gravi
 
780 43 zero_gravi
Continous integration provided by [:octocat: GitHub Actions](https://github.com/features/actions) and powered by [GHDL](https://github.com/ghdl/ghdl).
781 2 zero_gravi
 
782
![Open Source Hardware Logo https://www.oshwa.org](https://raw.githubusercontent.com/stnolting/neorv32/master/docs/figures/oshw_logo.png)
783
 
784
This project is not affiliated with or endorsed by the Open Source Initiative (https://www.oshwa.org / https://opensource.org).
785
 
786 56 zero_gravi
[[back to top](#The-NEORV32-RISC-V-Processor)]
787
 
788 32 zero_gravi
--------
789 2 zero_gravi
 
790 36 zero_gravi
Made with :coffee: in Hannover, Germany :eu:

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.