1 |
2 |
ultra_embe |
### uriscv - Another tiny RISC-V implementation
|
2 |
|
|
|
3 |
|
|
Github: [https://github.com/ultraembedded/core_uriscv](https://github.com/ultraembedded/core_uriscv)
|
4 |
|
|
|
5 |
|
|
Simple, small, multi-cycle 32-bit RISC-V CPU implementation.
|
6 |
|
|
Most instructions take 2 cycles, apart from load/stores which take 4+ cycles (depending on memory latency), and division which can take up-to 34 cycles.
|
7 |
|
|
|
8 |
|
|
## Features
|
9 |
|
|
* 32-bit RISC-V ISA CPU core.
|
10 |
|
|
* Support RISC-V’s integer (I), multiplication and division (M), and CSR instructions (Z) extensions (RV32IMZicsr).
|
11 |
|
|
* Implements base ISA spec v2.1 and parts of the privileged ISA spec v1.11.
|
12 |
|
|
* Supports machine mode privilege level only.
|
13 |
|
|
* Configurable support for exceptions, interrupts, timers, multiplication, division and error traps.
|
14 |
|
|
* Verified using random instruction sequences using cosimulation against [C++ ISA model](https://github.com/ultraembedded/exactstep).
|
15 |
|
|
* Synthesizable Verilog 2001, Verilator and FPGA friendly.
|
16 |
|
|
* Coremark: **1.48 CoreMark/MHz** (with HW mul/div)
|
17 |
|
|
* Dhrystone: **0.58 DMIPS/MHz** ('legal compile options' / 337 instructions per iteration / with HW mul/div)
|
18 |
|
|
|
19 |
|
|
**For my higher performance pipelined cores, see here:**
|
20 |
|
|
* Coremark: **2.94CM/MHZ** - [http://github.com/ultraembedded/riscv](http://github.com/ultraembedded/riscv)
|
21 |
|
|
* Coremark: **4.1CM/MHz** - [http://github.com/ultraembedded/biriscv](http://github.com/ultraembedded/biriscv)
|
22 |
|
|
|
23 |
|
|
## Getting Started
|
24 |
|
|
|
25 |
|
|
#### Cloning
|
26 |
|
|
|
27 |
|
|
To clone this project and its dependencies;
|
28 |
|
|
|
29 |
|
|
```
|
30 |
|
|
git clone https://github.com/ultraembedded/core_uriscv.git
|
31 |
|
|
|
32 |
|
|
```
|
33 |
|
|
|
34 |
|
|
#### Running Helloworld
|
35 |
|
|
|
36 |
|
|
To run a simple test image on the core RTL using Icarus Verilog;
|
37 |
|
|
|
38 |
|
|
```
|
39 |
|
|
# Install Icarus Verilog (Debian / Ubuntu / Linux Mint)
|
40 |
|
|
sudo apt-get install iverilog
|
41 |
|
|
|
42 |
|
|
# [or] Install Icarus Verilog (Redhat / Centos)
|
43 |
|
|
#sudo yum install iverilog
|
44 |
|
|
|
45 |
|
|
# Run a simple test image (test.elf)
|
46 |
|
|
cd tb/tb_core_icarus
|
47 |
|
|
make
|
48 |
|
|
```
|
49 |
|
|
|
50 |
|
|
The expected output is;
|
51 |
|
|
```
|
52 |
|
|
Starting bench
|
53 |
|
|
VCD info: dumpfile waveform.vcd opened for output.
|
54 |
|
|
|
55 |
|
|
Test:
|
56 |
|
|
1. Initialised data
|
57 |
|
|
2. Multiply
|
58 |
|
|
3. Divide
|
59 |
|
|
4. Shift left
|
60 |
|
|
5. Shift right
|
61 |
|
|
6. Shift right arithmetic
|
62 |
|
|
7. Signed comparision
|
63 |
|
|
8. Word access
|
64 |
|
|
9. Byte access
|
65 |
|
|
10. Comparision
|
66 |
|
|
```
|
67 |
|
|
#### Configuration
|
68 |
|
|
|
69 |
|
|
| Param Name | Valid Range | Description |
|
70 |
|
|
| ------------------------- |:------------:| ------------------------------------------------------------|
|
71 |
|
|
| SUPPORT_MUL | 1/0 | Enable multiplication instructions. |
|
72 |
|
|
| SUPPORT_DIV | 1/0 | Enable division instructions. |
|
73 |
|
|
| SUPPORT_CSR | 1/0 | Global enable for CSR/trap/interrupt handling. |
|
74 |
|
|
| SUPPORT_TRAP_LSU_ALIGN | 1/0 | Enable unaligned memory load / store exception. |
|
75 |
|
|
| SUPPORT_MTVEC | 1/0 | Configurable exception entry address. |
|
76 |
|
|
| SUPPORT_MTVAL | 1/0 | Support MTVAL CSR (holds bad addr / opcode). |
|
77 |
|
|
| SUPPORT_MIP_MIE | 1/0 | Support MIE and MIP CSR registers. |
|
78 |
|
|
| SUPPORT_MSCRATCH | 1/0 | Support MSCRATCH CSR registers (SW read/write). |
|
79 |
|
|
| SUPPORT_MCYCLE | 1/0 | Support cycle counter / rdtime. |
|
80 |
|
|
| SUPPORT_MTIMECMP | 1/0 | Non-std - support timer compare interrupt. |
|
81 |
|
|
| SUPPORT_TRAP_INVALID_OPC | 1/0 | Fault on invalid opcodes (enable SW emulation). |
|
82 |
|
|
| SUPPORT_BRAM_REGFILE | 1/0 | FPGA BlockRAM friendly reg file (inst take 1 cycle longer). |
|
83 |
|
|
| ISR_VECTOR | 'h0-FFFFFFFF | ISR addr = reset_vector + ISR_VECTOR (SUPPORT_MTVEC = 0). |
|
84 |
|
|
|