1 |
2 |
alfik |
### aoR3000
|
2 |
|
|
|
3 |
|
|
The aoR3000 is a MIPS R3000A compatible core capable of booting the Linux kernel version 3.16 in about 3 seconds and with a rating of 48.74 BogoMIPS. It features a compatible MMU, but no FPU.
|
4 |
|
|
|
5 |
|
|
### Current status
|
6 |
|
|
- 11 August 2014 - initial version 1.0.
|
7 |
|
|
|
8 |
|
|
### Features
|
9 |
|
|
|
10 |
|
|
The aoR3000 soft processor core has the following features:
|
11 |
|
|
- 5 stage pipeline (single-issue, in-order, forwarding, hazard detection);
|
12 |
|
|
- implements all MIPS I instructions (this includes the privileged coprocessor 0 instructions);
|
13 |
|
|
- the MMU in coprocessor 0 is compatible with the R3000A but has more micro-TLB entries: 64 TLB entries, 8 micro-TLB entries for data, 4 micro-TLB entries for instructions;
|
14 |
|
|
- 2 kB instruction cache (direct map);
|
15 |
|
|
- 2 kB data cache (direct map);
|
16 |
|
|
- all exceptions are implemented (bus error exceptions are not issued, exceptions in branch delays are supported);
|
17 |
|
|
- the core has one combined instruction/data Altera Avalon MM master interface (with burst and pipelined instruction reads, pipelined data reads);
|
18 |
|
|
- multiplication implemented in hardware using vendor-independent modules (Altera Quartus II infers embedded multipliers);
|
19 |
|
|
- division implemented in hardware using long division (33 clock cycles required);
|
20 |
|
|
- the core uses 7700 LE and runs at 50 MHz on a Altera Cyclone IV EP4CE115F29C7;
|
21 |
|
|
- the core is modeled in a vendor-independent subset of Verilog consistent with the requirements of Verilator (fully synchronous design, no vendor specific module instances);
|
22 |
|
|
- a Verilator generated executable C++ model is available;
|
23 |
|
|
- the core was tested and compared with the vmips software R3000 emulator;
|
24 |
|
|
- the core is chosen to be little-endian and can not be changed by software;
|
25 |
|
|
|
26 |
|
|
### Resource usage
|
27 |
|
|
The following table shows the result of synthesis using a balanced area/speed optimization:
|
28 |
|
|
|
29 |
|
|
+---------------------------------------------------------------------------------+
|
30 |
|
|
; Flow Summary ;
|
31 |
|
|
+------------------------------------+--------------------------------------------+
|
32 |
|
|
; Flow Status ; Successful - Mon Aug 11 21:46:48 2014 ;
|
33 |
|
|
; Quartus II 64-Bit Version ; 14.0.0 Build 200 06/17/2014 SJ Web Edition ;
|
34 |
|
|
; Revision Name ; aoR3000 ;
|
35 |
|
|
; Top-level Entity Name ; aoR3000 ;
|
36 |
|
|
; Family ; Cyclone IV E ;
|
37 |
|
|
; Device ; EP4CE115F29C7 ;
|
38 |
|
|
; Timing Models ; Final ;
|
39 |
|
|
; Total logic elements ; 7,660 / 114,480 ( 7 % ) ;
|
40 |
|
|
; Total combinational functions ; 7,174 / 114,480 ( 6 % ) ;
|
41 |
|
|
; Dedicated logic registers ; 2,633 / 114,480 ( 2 % ) ;
|
42 |
|
|
; Total registers ; 2633 ;
|
43 |
|
|
; Total pins ; 115 / 529 ( 22 % ) ;
|
44 |
|
|
; Total virtual pins ; 0 ;
|
45 |
|
|
; Total memory bits ; 61,616 / 3,981,312 ( 2 % ) ;
|
46 |
|
|
; Embedded Multiplier 9-bit elements ; 8 / 532 ( 2 % ) ;
|
47 |
|
|
; Total PLLs ; 0 / 4 ( 0 % ) ;
|
48 |
|
|
+------------------------------------+--------------------------------------------+
|
49 |
|
|
|
50 |
|
|
+-------------------------------------------------+
|
51 |
|
|
; Slow 1200mV 85C Model Fmax Summary ;
|
52 |
|
|
+-----------+-----------------+------------+------+
|
53 |
|
|
; Fmax ; Restricted Fmax ; Clock Name ; Note ;
|
54 |
|
|
+-----------+-----------------+------------+------+
|
55 |
|
|
; 52.58 MHz ; 52.58 MHz ; clk ; ;
|
56 |
|
|
+-----------+-----------------+------------+------+
|
57 |
|
|
|
58 |
|
|
### Implemented instructions
|
59 |
|
|
|
60 |
|
|
All the MIPS I instructions are implemented:
|
61 |
|
|
- ADD, ADDI, ADDIU, ADDU, AND, ANDI, NOR, OR, ORI, SLL, SLLV, SLT, SLTI, SLTIU, SLTU, SRA, SRAV, SRL, SRLV, SUB, SUBU, XOR, XORI, LUI;
|
62 |
|
|
- DIV, DIVU, MULT, MULTU, MTHI, MTLO, MFHI, MFLO;
|
63 |
|
|
- BREAK, SYSCALL;
|
64 |
|
|
- CFCz, CTCz, LWCz, SWCz;
|
65 |
|
|
- MFCz, MTCz;
|
66 |
|
|
- COPz, RFE, TLBP, TLBR, TLBWI, TLBWR;
|
67 |
|
|
- BEQ, BGEZ, BGEZAL, BGTZ, BLEZ, BLTZ, BLTZAL, BNE, J, JAL, JALR, JR;
|
68 |
|
|
- LB, LBU, LH, LHU, LW, LWL, LWR, SB, SH, SW, SWL, SWR;
|
69 |
|
|
|
70 |
|
|
### Running the tests
|
71 |
|
|
The aoR3000 core can be converted by Verilator to a C++ executable model. This executable model was compared with the vmips software R3000 emulator (http://vmips.sourceforge.net/) in simulation.
|
72 |
|
|
All instructions were simulated with random register and memory contents. After every instruction the register contents are compared.
|
73 |
|
|
|
74 |
|
|
To run the test the following steps have to be taken:
|
75 |
|
|
- compile the vmips emulator in sim/vmips/ by 'make tester';
|
76 |
|
|
- compile the Verilator aoR3000 model in sim/aoR3000/ by 'make tester';
|
77 |
|
|
- choose the test to be run in sim/tester/main_tester.cpp by setting the pointer 'tst_t *tst_current =';
|
78 |
|
|
- compile the tester in sim/tester/ by 'make tester';
|
79 |
|
|
- run the tester in sim/tester/ by './main_tester';
|
80 |
|
|
|
81 |
|
|
### GNU toolchain
|
82 |
|
|
To run programs on the aoR3000 a standard GNU toolchain in required. I used the following options during compilation of the toolchain:
|
83 |
|
|
- for GNU binutils: './../binutils-2.24.51/configure --prefix= --target=mipsel-unknown-linux-gnu';
|
84 |
|
|
- for GCC: './../gcc-4.9.1/configure --prefix= --target=mipsel-unknown-linux-gnu --enable-languages=c --disable-threads --disable-shared --disable-libssp --disable-libquadmath --disable-libgomp --disable-libatomic';
|
85 |
|
|
|
86 |
|
|
The target 'mipsel-unknown-elf' can also be used, but more changes are required to the Linux kernel in that case.
|
87 |
|
|
|
88 |
|
|
### Building a minimal Linux kernel
|
89 |
|
|
In the directory linux/ there is a minimal set of files required to add the aoR3000 SoC platform to the kernel sources version 3.16. To compile the kernel with these changes just copy/overwrite the files in
|
90 |
|
|
a Linux source tree. After that 'make ARCH=mips CROSS_COMPILE=mipsel-unknown-linux-gnu- vmlinux.bin' to build the kernel.
|
91 |
|
|
|
92 |
|
|
### Booting the Linux kernel in simulation on a Verilator executable model of the aoR3000
|
93 |
|
|
The booting of the Linux kernel is performed in a similar method like the tests described above. The Verilator executable model of the aoR3000 is run together with the vmips R3000 software simulator to verify
|
94 |
|
|
the correctness of the aoR3000. Every write to memory is checked to confirm that both of the models write the same data at the same time and in the same order.
|
95 |
|
|
|
96 |
|
|
To boot the Linux kernel in simulation the following steps have to be taken:
|
97 |
|
|
- compile the vmips emulator in sim/vmips/ by 'make linux';
|
98 |
|
|
- compile the Verilator aoR3000 model in sim/aoR3000/ by 'make linux';
|
99 |
|
|
- compile the tester in sim/tester/ by 'make linux';
|
100 |
|
|
- compile the Linux kernel to get the 'vmlinux.bin' file in the arch/mips/boot/ directory;
|
101 |
|
|
- run the tester in sim/tester/ by './main_linux ';
|
102 |
|
|
|
103 |
|
|
The booting of the Linux kernel takes about 12 minutes on a modern PC (more than 46 milion instructions have to be executed/simulated).
|
104 |
|
|
|
105 |
|
|
The tester simulates the following hardware devices:
|
106 |
|
|
- an eary Linux console that outputs the data written to that console to the file 'tester/early_console.txt';
|
107 |
|
|
- a simple hardware time interrupt device that signals IRQ 0 every 10 miliseconds;
|
108 |
|
|
- an Altera JTAG UART connected to a pseudo terminal (Unix PTY). The terminal name is printed just after executing the tester (for example: 'slave pty: /dev/pts/9');
|
109 |
|
|
|
110 |
|
|
To connect to this terminal one can use the following command: 'picocom --nolock /dev/pts/9'. Data can be read and written to this terminal.
|
111 |
|
|
|
112 |
|
|
### Booting the Linux kernel on a FPGA with a synthesized aoR3000
|
113 |
|
|
Together with the aoR3000 core there is also a example SoC in the syn/soc/ directory. It consists of:
|
114 |
|
|
- the aoR3000 core;
|
115 |
|
|
- an Altera JTAG UART;
|
116 |
|
|
- an Altera SDRAM controller;
|
117 |
|
|
- a simple time interrupt device;
|
118 |
|
|
- onchip memory for the boot code of the aoR3000;
|
119 |
3 |
alfik |
- an Altera JTAG to Avalon Master Bridge to upload the Linux kernel;
|
120 |
2 |
alfik |
|
121 |
|
|
The SoC is designed for the Terasic DE2-115 board.
|
122 |
|
|
|
123 |
|
|
To compile the SoC the following steps have to be taken:
|
124 |
|
|
- open the Altera Quartus II project in syn/soc/;
|
125 |
|
|
- open the Qsys tool and generate the HDL;
|
126 |
|
|
- compile the project;
|
127 |
|
|
- program the FPGA with the compiled project;
|
128 |
|
|
- in the Altera Nios2 Command Shell enter the directory arch/mips/boot/ of the Linux kernel and run 'system-console -cli';
|
129 |
|
|
- load the Linux kernel binary using the system-console by entering the following TCL commands at the system-console prompt:
|
130 |
|
|
|
131 |
|
|
---
|
132 |
|
|
set srv [claim_service "master" [lindex [get_service_paths "master"] 0] ""];
|
133 |
|
|
master_write_from_file $srv vmlinux.bin 0;
|
134 |
|
|
close_service master $srv;
|
135 |
|
|
---
|
136 |
|
|
|
137 |
|
|
- open the nios2-terminal in a Altera Nios2 Command Shell;
|
138 |
|
|
- verify that the following text is displayed in the terminal: 'Press any key to boot kernel...';
|
139 |
|
|
- press any key to boot the kernel;
|
140 |
|
|
|
141 |
|
|
The kernel is booted with the following output displayed on the nios2-terminal:
|
142 |
|
|
|
143 |
|
|
---
|
144 |
|
|
Press any key to boot kernel...
|
145 |
|
|
Booting kernel...
|
146 |
|
|
console [ttyJ0] enabled
|
147 |
|
|
bootconsole [early0] disabled
|
148 |
|
|
Freeing unused kernel memory: 176K (80204000 - 80230000)
|
149 |
|
|
#
|
150 |
|
|
---
|
151 |
|
|
|
152 |
|
|
A shell is run as init in the early root-fs. The early root-fs is the compiled klibc project.
|
153 |
|
|
|
154 |
|
|
After running the command dmesg the following output is displayed:
|
155 |
|
|
|
156 |
|
|
---
|
157 |
|
|
Linux version 3.16.0 (alek@duke) (gcc version 4.9.1 (GCC) ) #4 Mon Aug 11 23:49:07 CEST 2014
|
158 |
|
|
bootconsole [early0] enabled
|
159 |
|
|
CPU0 revision is: 00000230 (R3000A)
|
160 |
|
|
Determined physical RAM map:
|
161 |
|
|
memory: 08000000 @ 00000000 (usable)
|
162 |
|
|
Initrd not found or empty - disabling initrd
|
163 |
|
|
Zone ranges:
|
164 |
|
|
Normal [mem 0x00000000-0x07ffffff]
|
165 |
|
|
Movable zone start for each node
|
166 |
|
|
Early memory node ranges
|
167 |
|
|
node 0: [mem 0x00000000-0x07ffffff]
|
168 |
|
|
On node 0 totalpages: 32768
|
169 |
|
|
free_area_init_node: node 0, pgdat 80203600, node_mem_map 81000000
|
170 |
|
|
Normal zone: 256 pages used for memmap
|
171 |
|
|
Normal zone: 0 pages reserved
|
172 |
|
|
Normal zone: 32768 pages, LIFO batch:7
|
173 |
|
|
Primary instruction cache 2kB, linesize 4 bytes.
|
174 |
|
|
Primary data cache 2kB, linesize 4 bytes.
|
175 |
|
|
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
|
176 |
|
|
pcpu-alloc: [0] 0
|
177 |
|
|
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
|
178 |
|
|
Kernel command line: console=ttyJ0,115200
|
179 |
|
|
PID hash table entries: 512 (order: -1, 2048 bytes)
|
180 |
|
|
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
|
181 |
|
|
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
|
182 |
|
|
Memory: 127492K/131072K available (1741K kernel code, 101K rwdata, 212K rodata, 176K init, 171K bss, 3580K reserved)
|
183 |
|
|
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
|
184 |
|
|
NR_IRQS:128
|
185 |
|
|
Console: colour dummy device 80x25
|
186 |
|
|
Calibrating delay loop... 48.74 BogoMIPS (lpj=243712)
|
187 |
|
|
pid_max: default: 32768 minimum: 301
|
188 |
|
|
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
|
189 |
|
|
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
|
190 |
|
|
futex hash table entries: 256 (order: -1, 3072 bytes)
|
191 |
|
|
io scheduler noop registered
|
192 |
|
|
io scheduler deadline registered
|
193 |
|
|
io scheduler cfq registered (default)
|
194 |
|
|
ttyJ0 at MMIO 0x1ffffff0 (irq = 3, base_baud = 0) is a Altera JTAG UART
|
195 |
|
|
console [ttyJ0] enabled
|
196 |
|
|
bootconsole [early0] disabled
|
197 |
|
|
Freeing unused kernel memory: 176K (80204000 - 80230000)
|
198 |
|
|
---
|
199 |
|
|
|
200 |
|
|
### License
|
201 |
|
|
Most of the files in this project are under the BSD license. All the Verilog code for the aoR3000 core is under the BSD license.
|
202 |
|
|
|
203 |
|
|
A few files are under the GPL license. These files are:
|
204 |
|
|
- all files in the sim/vmips/ directory;
|
205 |
|
|
- all files in the linux/ directory;
|
206 |
|
|
|
207 |
|
|
See the LICENSE file for details.
|