• Stars
    star
    984
  • Rank 46,528 (Top 1.0 %)
  • Language Verilog
  • License
    BSD 3-Clause "New...
  • Created about 10 years ago
  • Updated about 3 years ago

Reviews

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

Repository Details

RISC-V CPU Core (RV32IM)

RISC-V Core

Github: http://github.com/ultraembedded/riscv

A 32-bit RISC-V core written in Verilog and an instruction set simulator supporting RV32IM.
This core has been tested against a co-simulation model and exercised on FPGA.

For a higher performance dual issue CPU with branch prediction, see my latest RISC-V core here; http://github.com/ultraembedded/biriscv

Overview

Features

  • 32-bit RISC-V ISA CPU core.
  • Support RISC-V integer (I), multiplication and division (M), and CSR instructions (Z) extensions (RV32IMZicsr).
  • Supports user, supervisor and machine mode privilege levels.
  • Basic MMU support - capable of booting Linux with atomics (RV-A) SW emulation.
  • Implements base ISA spec v2.1 and privileged ISA spec v1.11.
  • Verified using Google's RISCV-DV random instruction sequences using cosimulation against C++ ISA model.
  • Support for instruction / data cache, AXI bus interfaces or tightly coupled memories.
  • Configurable number of pipeline stages and result forwarding options.
  • Synthesizable Verilog 2001, Verilator and FPGA friendly.
  • Coremark: 2.94 CoreMark/MHz
  • Dhrystone: 1.25 DMIPS/MHz ('legal compile options' / 337 instructions per iteration)
  • Want higher performance (4.1CM/MHz / 1.9DMIPS/MHz) - see my improved core.

Configuration

Param Name Valid Range Description
SUPPORT_SUPER 1/0 Enable supervisor / user privilege levels.
SUPPORT_MMU 1/0 Enable basic memory management unit.
SUPPORT_MULDIV 1/0 Enable HW multiply / divide (RV-M).
SUPPORT_LOAD_BYPASS 1/0 Support load result bypass paths.
SUPPORT_MUL_BYPASS 1/0 Support multiply result bypass paths.
SUPPORT_REGFILE_XILINX 1/0 Support Xilinx optimised register file.
EXTRA_DECODE_STAGE 1/0 Extra decode pipe stage for improved timing.
MEM_CACHE_ADDR_MIN 32'h0 - 32'hffffffff Lowest cacheable memory address.
MEM_CACHE_ADDR_MAX 32'h0 - 32'hffffffff Highest cacheable memory address.

Directories

Name Contents
core/riscv RISC-V pipelined RV32IM CPU core (Verilog)
isa_sim Instruction set simulator (C)
top_tcm_axi/src_v Example instance with 64KB DP-RAM & AXI Interfaces
top_tcm_axi/tb System-C testbench for the core
top_cache_axi/src_v Example instance with instruction and data caches.
top_cache_axi/tb System-C testbench for the core

Example Core Instance (with TCM memory)

The top (top_tcm_axi/src_v/riscv_tcm_top.v) contains;

  • Instances one of the above cores, adding RAM and standard bus interfaces.
  • 64KB dual ported RAM for (I/D code and data).
  • AXI4 slave port for loading the RAM, DMA access, etc (including support for burst access).
  • AXI4-Lite master port for CPU access to peripherals.
  • Separate reset for CPU core to dual ported RAM / AXI interface (to allow program code to be loaded prior to CPU reset de-assertion).

Memory Map

Range Description
0x0000_0000 - 0x0000_ffff 64KB TCM Memory
0x0000_2000 Boot address (configurable, see RISCV_BOOT_ADDRESS)
0x8000_0000 - 0xffff_ffff Peripheral address space (from AXI4-L port)

Interfaces

Name Description
clk_i Clock input
rst_i Async reset, active-high. Reset memory / AXI interface.
rst_cpu_i Async reset, active-high. Reset CPU core (excluding AXI / memory).
axi_t_* AXI4 slave interface for access to 64KB TCM memory.
axi_i_* AXI4-Lite master interface for CPU access to peripherals.
intr_i Active high interrupt input (for connection external int controller).

Testbench

A basic System-C / Verilator based testbench for the core is provided.

Dependencies;

  • gcc
  • make
  • libelf
  • System-C (specify path using SYSTEMC_HOME)
  • Verilator (specify path using VERILATOR_SRC)

To build the testbench;

cd top_tcm_axi/tb
make

To run the provided test executable;

cd top_tcm_axi/tb
make run

Example Core Instance (with caches)

The top (top_cache_axi/src_v/riscv_top.v) contains;

  • Instances one of the above cores, adding RAM and standard bus interfaces.
  • 16KB 2-way set associative instruction cache
  • 16KB 2-way set associative data cache with write-back and allocate on write.
  • 2 x AXI4 master port for CPU access to instruction / data / peripherals.

Interfaces

Name Description
clk_i Clock input
rst_i Async reset, active-high. Reset memory / AXI interface.
axi_i_* AXI4 master interface for CPU access to instruction memory.
axi_d_* AXI4 master interface for CPU access to data / peripheral memories.
intr_i Active high interrupt input (for connection external int controller).
reset_vector_i Boot vector.

Execution Example

More Repositories

1

biriscv

32-bit Superscalar RISC-V CPU
Verilog
701
star
2

cores

Various HDL (Verilog) IP Cores
Verilog
598
star
3

core_ddr3_controller

A DDR3 memory controller in Verilog for various FPGAs
Verilog
260
star
4

FPGAmp

720p FPGA Media Player (RISC-V + Motion JPEG + SD + HDMI on an Artix 7)
C
237
star
5

core_jpeg

High throughput JPEG decoder in Verilog for FPGA
Verilog
166
star
6

openlogicbit

Open-source Logic Analyzer gateware for various FPGA dev boards/replacement gateware for commercially available logic analyzers.
Verilog
87
star
7

core_usb_host

Basic USB 1.1 Host Controller for small FPGAs
C
77
star
8

riscv_soc

Basic RISC-V Test SoC
Verilog
76
star
9

exactstep

Instruction set simulator for RISC-V, MIPS and ARM-v6m
C++
74
star
10

core_ft60x_axi

FTDI FT600 SuperSpeed USB3.0 to AXI bus master
C++
73
star
11

libhelix-mp3

Fixed-point MP3 decoder (RISC-V port)
C
66
star
12

core_dvi_framebuffer

Minimal DVI / HDMI Framebuffer
Verilog
65
star
13

core_audio

Audio controller (I2S, SPDIF, DAC)
Verilog
64
star
14

core_usb_cdc

Basic USB-CDC device core (Verilog)
Verilog
61
star
15

core_sdram_axi4

SDRAM controller with AXI4 interface
C++
59
star
16

usb_sniffer

High Speed USB 2.0 capture device based on miniSpartan6+
C
56
star
17

core_soc

Basic Peripheral SoC (SPI, GPIO, Timer, UART)
Verilog
51
star
18

core_uriscv

Another tiny RISC-V implementation
Verilog
49
star
19

fat_io_lib

Small footprint, low dependency, C code implementation of a FAT16 & FAT32 driver.
C
48
star
20

usb2sniffer

USB2Sniffer: High Speed USB 2.0 capture (for LambdaConcept USB2Sniffer hardware)
Verilog
42
star
21

core_dbg_bridge

UART -> AXI Bridge
Verilog
41
star
22

riscv-linux-boot

Trivial RISC-V Linux binary bootloader
C
38
star
23

core_usb_fs_phy

USB Full Speed PHY
Verilog
35
star
24

core_spiflash

SPI-Flash XIP Interface (Verilog)
Verilog
33
star
25

core_usb_bridge

USB -> AXI Debug Bridge
Verilog
32
star
26

core_usb_uart

USB serial device (CDC-ACM)
Verilog
27
star
27

core_jpeg_decoder

HW JPEG decoder wrapper with AXI-4 DMA
Verilog
24
star
28

core_axi_cache

128KB AXI cache (32-bit in, 256-bit out)
Verilog
24
star
29

riscv_sbc

A RISC-V SBC based around the LambdaConcept USB2Sniffer FPGA board.
Verilog
24
star
30

fpga_test_soc

A small test SoC for various soft-CPUs (Cortex-M0, RISC-V)
C
22
star
31

core_enet

Ethernet MAC 10/100 Mbps
Verilog
21
star
32

core_mmc

MMC (and derivative standards) host controller
Verilog
21
star
33

minispartan6-audio

miniSpartan6+ (Spartan6) FPGA based MP3 Player
Verilog
21
star
34

core_ftdi_bridge

FTDI FT245 Style Synchronous/Asynchronous FIFO Bridge
Verilog
20
star
35

core_ulpi_wrapper

ULPI Link Wrapper (USB Phy Interface)
C++
19
star
36

core_usb_sniffer

USB capture IP
Verilog
18
star
37

riscv32_linux_from_scratch

RISC-V 32-bit Linux From Scratch
Makefile
18
star
38

librtos

Very basic real time operating system for embedded systems...
C
14
star
39

ecpix-5

Projects for the ECPiX-5 - a ECP5 FPGA board.
Verilog
12
star
40

minispartan6

Projects for the Scarab Minispartan6+ FPGA board
VHDL
12
star
41

core_ram_tester

AXI-4 RAM Tester Component
Verilog
11
star
42

altor32

AltOr32 - Alternative Lightweight OpenRisc CPU
Verilog
11
star
43

armv6m-sim

Simple instruction set simulator for ARMv6-M (Cortex M0)
C++
10
star
44

core_mpx

MPX is a open-source CPU which can execute code compiled for MIPS-I ISA
Verilog
9
star
45

xc6_bus_pirate

XC6 Bus Pirate (FPGA based multi-tool)
Verilog
7
star
46

orangecrab

Test projects for the OrangeCrab ECP5 FPGA board
Verilog
6
star
47

ecpix5-test

Test code / bitstreams for the LambdaConcept ECPIX-5 FPGA board
Verilog
6
star
48

riscv-sw-test

C++
5
star
49

riscv-linux-prebuilt

RISC-V Linux prebuilt images
5
star
50

embedded_httpd

Embedded HTTP Server
C
3
star
51

rp2040_blinky

Simple blinky example for the RP2040 that does not require cmake
C++
3
star