03_Rocket Computer System
03_Rocket Computer System
4
1. Introduction (2/4) Chipyard
Chipyard library
• Github: https://github.com/ucb-bar/chipyard
• Document: https://chipyard.readthedocs.io/en/stable/
You can see that there are many
processors ready for use.
We will use the Rocket core in here.
5
1. Introduction (3/4) Arty-A7 FPGA
Arty-A7 FPGA
• Link: https://digilent.com/reference/programmable-logic/arty-a7/start
6
1. Introduction (4/4) FPGA-shells
FPGA-shells library
• Github: https://github.com/sifive/fpga-shells
7
1. Introduction
Outline
2. System architecture
3. Git clone and prepare
4. Make the system
5. Program Arty-A7
6. Using IntelliJ IDEA-IC
7. Modifying system by Scala config
8. Practice: system modification 8
2. System architecture (1/9) Processor
In this course, we will working with an example of Rocket computer system at here:
• Github: https://github.com/uec-hanken/RISCVConsole
Coreplex
RISC-V 32/64
IMAFDC
9
2. System architecture (2/9) Memory
SDRAM DDR3
Controller Controller
For DE2 For ArtyA7
10
2. System architecture (3/9) UART
UART Controller
- TX and RX channels
- 8-entry FIFO with interrupts
11
2. System architecture (4/9) SD-card
SPI Controller
- To communicate with SD cards
- Read the partition and execute
12
2. System architecture (5/9) GPIO
GPIO Controller
- Input and Output registers
- Masked interrupts supported
13
2. System architecture (6/9) Interrupt
Interrupt Controllers
- Platform Interrupts (External)
- Core Local Interrupts (Time & Software)
14
2. System architecture (7/9) SPI
15
2. System architecture (8/9) Boot ROM
ROM
- Contains the SD load boot
- Always fixed
16
2. System architecture (9/9) Debug module
Debug
- JTAG-capable debug module
- Interrupts processor and debug
17
1. Introduction
Outline
2. System architecture
3. Git clone and prepare
4. Make the system
5. Program Arty-A7
6. Using IntelliJ IDEA-IC
7. Modifying system by Scala config
8. Practice: system modification 18
3. Git clone and prepare (1/4) $ git clone and folder structure
To clone the project: $ git clone https://github.com/uec-hanken/RISCVConsole.git
$ cd RISCVConsole/
$ ./update.sh
chipyard library:
provides processors
Scala sources fpga-shells library:
provides FPGA IPs
$ vi hardware/fpga-shells/xilinx/arty_a7_100/tcl/board.tcl
(type i to write and esc to release) (type :wq to save and exit)
20
3. Git clone and prepare (3/4) Prepare for Arty-A7-35T
$ vi hardware/fpga-
shells/src/main/scala/ip/xilinx/arty100tmig/arty100tmig.scala
(type i to write and esc to release) (type :wq to save and exit)
21
3. Git clone and prepare (4/4) Prepare Arty-A7 license
Arty-A7 license is free. You can download and install the Arty-A7 license to Vivado.
Download the link from the Digilent website.
Guide to install the license:
https://digilent.com/reference/programmable-logic/guides/installing-vivado-and-vitis
22
1. Introduction
Outline
2. System architecture
3. Git clone and prepare
4. Make the system
5. Program Arty-A7
6. Using IntelliJ IDEA-IC
7. Modifying system by Scala config
8. Practice: system modification 23
4. Make the system (1/9) Makefile in fpga folder
Makefile SBT (.scala) FIRRTL (.fir) FPGA (.v) FPGA (.bit)
At RISCVConsole/fpga/ArtyA7100T/Makefile:
At RISCVConsole/variables.mk:
24
4. Make the system (2/9) Equivalent in Scala config
Makefile SBT (.scala) FIRRTL (.fir) FPGA (.v) FPGA (.bit)
At RISCVConsole/hardware/riscvconsole/src/ At RISCVConsole/fpga/
ArtyA7100T/Makefile:
main/scala/riscvconsole/RVCConfig.scala:
At RISCVConsole/variables.mk:
25
4. Make the system (3/9) Scala structure
Makefile SBT (.scala) FIRRTL (.fir) FPGA (.v) FPGA (.bit)
26
4. Make the system (4/9) $ make default
Makefile SBT (.scala) FIRRTL (.fir) FPGA (.v) FPGA (.bit)
Now, to make the system, from the RISCVConsole, go to the Arty build folder:
$ cd fpga/ArtyA7100T/
27
4. Make the system (5/9) $ make default
Makefile SBT (.scala) FIRRTL (.fir) FPGA (.v) FPGA (.bit)
After $ make default, the
generated-src folder is created:
Inside the generated-src folder, there are many files:
Verilog files, FIRRTL files, temporary Java files, boot ROM files, device tree, etc.
Some
important files
28
4. Make the system (6/9) Verilog files
Makefile SBT (.scala) FIRRTL (.fir) FPGA (.v) FPGA (.bit)
Top file:
riscvconsole.fpga.ArtyA7
Top.ArtyA7Config.top.v
29
4. Make the system (7/9) Verilog files
Makefile SBT (.scala) FIRRTL (.fir) FPGA (.v) FPGA (.bit)
Boot ROM file:
riscvconsole.fpga.ArtyA7Top.
ArtyA7Config.rom.v Other Verilog files:
• EICG_wrapper.v
• plusarg_reader.v
30
4. Make the system (8/9) Device tree file
Makefile SBT (.scala) FIRRTL (.fir) FPGA (.v) FPGA (.bit)
31
4. Make the system (9/9) $ make bit
Makefile SBT (.scala) FIRRTL (.fir) FPGA (.v) FPGA (.bit)
After $ make bit, you can find the .bit file for programming the FPGA in:
generated-src/riscvconsole.fpga.ArtyA7Top.ArtyA7Config/obj/
34
5. Program Arty-A7 (2/10) Prepare SD-card
Some commands to use while in the gptfdisk tool:
$ p : print partitions information
$ d : delete partition
$ n : create new partition
$ w : write partition
$ q : exit gptfdisk
35
5. Program Arty-A7 (3/10) Prepare SD-card
Example commands:
$ sudo ./gdisk /dev/sdb
$ d
$ n
$ (Enter)
$ +1024
$ 5202
$ p
$ w
$ y
36
5. Program Arty-A7 (4/10) Prepare software
Now, prepare the after-boot software:
From your RISCVConsole folder:
$ cd RISCVConsole/
Go to:
$ cd software/RISCVConsoleCode/
Remember to have the RISC-V toolchain available in the PATH:
$ export PATH=/opt/riscv/bin/:$PATH
Finally, compile the software:
$ make bin
After $ make bin, the compiled software are under the build folder:
37
5. Program Arty-A7 (5/10) Prepare software
Now, to write the compiled software to the SD card:
From your RISCVConsole/software/RISCVConsoleCode folder:
$ sudo dd if=./build/out.bin of=/dev/sd?1 conv=fsync bs=4096
Again, the ? points to the SD card.
For example: $ sudo dd if=./build/out.bin of=/dev/sdb1 conv=fsync bs=4096
After $ sudo dd :
38
5. Program Arty-A7 (6/10) Program the Arty-A7
To program the board, open Vivado: Open hardware manager:
39
5. Program Arty-A7 (7/10) Program the Arty-A7
Open target → Auto connect :
40
5. Program Arty-A7 (8/10) Program the Arty-A7
Right-click on the xc7a100t (1) → Program device…
41
5. Program Arty-A7 (9/10) Program the Arty-A7
Browse to the ArtyA7Top.bit under
RISCVConsole/fpga/ArtyA7100T/generated-
src/riscvconsole.fpga.ArtyA7Top.ArtyA7Config/obj folder
43
1. Introduction
Outline
2. System architecture
3. Git clone and prepare
4. Make the system
5. Program Arty-A7
6. Using IntelliJ IDEA-IC
7. Modifying system by Scala config
8. Practice: system modification 44
6. Using IntelliJ IDEA-IC (1/3) Download and install
To write/modify Scala sources efficiently,
we need an IDE (Integrated Development Environment) tool.
• SBT is the compiler for Scala • IntelliJ IDEA-IC is the GUI for SBT
→ IntelliJ IDEA-IC for Scala is like Visual Studio for C++
When it
finishes.
47
1. Introduction
Outline
2. System architecture
3. Git clone and prepare
4. Make the system
5. Program Arty-A7
6. Using IntelliJ IDEA-IC
7. Modifying system by Scala config
8. Practice: system modification 48
7. Modifying system by Scala config (1/10) Peripheral
At RISCVConsole/hardware/riscvconsole/src/
main/scala/riscvconsole/RVCConfig.scala:
50
7. Modifying system by Scala config (3/10) Processor
At RISCVConsole/hardware/riscvconsole/src/
main/scala/riscvconsole/RVCConfig.scala:
WithNMedCores(1) ++
● Supports VM
● Suitable for Linux booting
51
7. Modifying system by Scala config (4/10) Processor
At RISCVConsole/hardware/riscvconsole/src/
main/scala/riscvconsole/RVCConfig.scala:
56
7. Modifying system by Scala config (9/10) L1 caches
To reduce the L1 caches, for example, from the Configs.scala file:
57
7. Modifying system by Scala config (10/10) L1 caches
The result after that:
58
1. Introduction
Outline
2. System architecture
3. Git clone and prepare
4. Make the system
5. Program Arty-A7
6. Using IntelliJ IDEA-IC
7. Modifying system by Scala config
8. Practice: system modification 59
8. Practice: system modification (1/1)
Exercise 1:
Try these combinations ($ make default → $ make bit) and report the resources in
Arty-A7:
• RV32IMAC small single-core Rocket
• RV64GC small single-core Rocket
• RV32IMAC medium single-core Rocket
• RV64GC medium single-core Rocket
• RV32IMAC small single-core Rocket with reduced caches ($I=1KB, $D=1KB)
• RV64GC medium single-core Rocket with increased caches ($I=64KB, $D=64KB)
Exercise 2:
Try multiple configurations to see if the Arty-A7 can support dual-core Rocket.
And check on both 35T and 100T versions of the Arty-A7. So the questions are:
1. Which configuration will use the most of the Arty-A7-35T?
2. Which configuration will use the most of the Arty-A7-100T?
60
THANK YOU
2022/11
61