Skip to content

Commit ffa48cc

Browse files
committed
Merge branch 'tc-l2' into dev
2 parents 337e9d5 + e800faf commit ffa48cc

22 files changed

+539
-576
lines changed

README.md

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<p align="center">
22
<img width="200px" src="./.images/tree_core_logo.svg" align="center" alt="Tree Core CPU" />
3-
<h1 align="center">Tree Core CPU</h1>
4-
<p align="center">A RISC-V soft core processor written from scratch.</p>
3+
<h1 align="center">TreeCore CPU</h1>
4+
<p align="center">A series of RISC-V soft core processor written from scratch</p>
55
</p>
66
<p align="center">
77
<a href="./LICENSE">
@@ -18,27 +18,47 @@
1818
<a href="./README_zh-CN.md">简体中文</a>
1919
</p>
2020

21-
## Preface
21+
## Overview
22+
the TreeCore L2 is the
2223

23-
I heard the word RISC-V for the first time in the second semester of my junior year (that is, the summer of 2016), my roommate happened to participate in the pilot class of "Computer Architecture" organized by the college, and **their task was to design a simple soft-core CPU based on the RISC-V instruction set**. At that time, I only knew that it was an open source RISC instruction set launched by the University of Berkeley, I felt that it was similar to the MIPS instruction set used in our ordinary classes, so I didn't take it too seriously. But what is unexpected is that after just a few years of development, the RISC-V instruction set has been supported by many Internet and semiconductor giants around the world, and more and more research institutions and start-ups begin to design their own proprietary processors based on it. I think the current RISC-V is just like the early Linux kernel, although the function and performance are still very limited, with the power of open source collaboration, **I believe RISC-V will one day usher in a revolution that can change the old pattern in some areas**. Therefore, in order not to be abandoned by the coming new era, as an amateur hardware enthusiast, I think it is necessary for me to learn the RISC-V instruction set, maybe I will have the opportunity to contribute to the design and R & D of domestic independent controllable processor in the future!
24+
## Feature
25+
* 64-bit five-stage pipeline RISC-V ISA CPU core.
26+
* support RISC-V integer(I) instruction set.
27+
* supports machine mode privilege levels.
28+
* supports AXI4 inst and mem acess.
29+
* can boot rt-thread.
2430

25-
The ancients once said: **it’s always shallow on paper, and you must do it yourself**, since you decide to learn RISC-V, you must practice it to understand it. For this kind of project at the bottom of computer architecture, there is no better way than to realize it from scratch. So with this idea, I started to collect information on the Internet, and the results were disappointing. Although there are many foreign open source projects related to RISC-V, many of them are implemented using Chisel, a high-level hardware construction language. The learning threshold is very high. In addition, in order to pursue the overall performance, some CPU system architectures are designed to be very complex (such as using five-level or more pipelines, multi-core processing, out-of-order execution, etc), it is very difficult for beginners to get started. So after careful consideration, I decided to write an open source processor project from scratch, which has a **simple system architecture, clear code and excellent package**, I hope it can be like Arduino, which stands out from many microcontrollers, so that more hardware enthusiasts can quickly start to experience, and develop many interesting applications based on it. In the future, under the mutual promotion of the software and hardware ecological environment, maybe more people will like CPU development and be willing to spend time on it. If I can really do this, I will be satisfied.
2631

27-
## Overview
32+
## Datapath Diagram
33+
34+
### Memory Map
35+
36+
| Range | Description |
37+
| ------------------------- | --------------------------------------------------- |
38+
| 0x0000_0000 - 0x0000_ffff | 64KB TCM Memory |
39+
| 0x0000_2000 | Boot address (configurable, see RISCV_BOOT_ADDRESS) |
40+
| 0x8000_0000 - 0xffff_ffff | Peripheral address space (from AXI4-L port) |
41+
42+
#### Configuration
2843

2944
## Usage
3045

31-
### Enviroment setup(ubuntu 20.04 LTS)
32-
- 1. install verilator and mill
33-
- 2. install dep lib:
34-
- 1. sudo apt-get install g++-riscv64-linux-gnu binutils-riscv64-linux-gnu
35-
- 3. ./setup -a
36-
- 4. change the sim memory from 8G to 256MB. need to enter 'make menuconfig' and modify [Memory - Configuration]->[Memory size] to '0x10000000' manually
37-
- 5. cd in root rtl dir
38-
- 1. make nemuBuild
39-
- 2. make diffBuild
40-
- 3. make difftestBuild
41-
- 4. make demoTest
46+
### Getting Started
47+
#### Enviroment setup(ubuntu 20.04 LTS)
48+
install verilator, mill and dep lib:
49+
```bash
50+
$ sudo apt-get install g++-riscv64-linux-gnu binutils-riscv64-linux-gnu
51+
$ ./setup.sh -a
52+
```
53+
54+
change the sim memory from 8G to 256MB. need to enter 'make menuconfig' and modify [Memory - Configuration]->[Memory size] to '0x10000000' manually.
55+
cd in root rtl dir
56+
```bash
57+
$ make nemuBuild
58+
$ make diffBuild
59+
$ make difftestBuild
60+
$ make demoTest
61+
```
4262

4363
### Software test
4464

@@ -54,9 +74,16 @@ The ancients once said: **it’s always shallow on paper, and you must do it you
5474

5575
## Summary
5676

77+
## Documention
78+
5779
## Plan
5880

5981
## Update
6082

61-
## Copyright
83+
## License
84+
85+
## Story
6286

87+
I heard the word RISC-V for the first time in the second semester of my junior year (that is, the summer of 2016), my roommate happened to participate in the pilot class of "Computer Architecture" organized by the college, and **their task was to design a simple soft-core CPU based on the RISC-V instruction set**. At that time, I only knew that it was an open source RISC instruction set launched by the University of Berkeley, I felt that it was similar to the MIPS instruction set used in our ordinary classes, so I didn't take it too seriously. But what is unexpected is that after just a few years of development, the RISC-V instruction set has been supported by many Internet and semiconductor giants around the world, and more and more research institutions and start-ups begin to design their own proprietary processors based on it. I think the current RISC-V is just like the early Linux kernel, although the function and performance are still very limited, with the power of open source collaboration, **I believe RISC-V will one day usher in a revolution that can change the old pattern in some areas**. Therefore, in order not to be abandoned by the coming new era, as an amateur hardware enthusiast, I think it is necessary for me to learn the RISC-V instruction set, maybe I will have the opportunity to contribute to the design and R & D of domestic independent controllable processor in the future!
88+
89+
The ancients once said: **it’s always shallow on paper, and you must do it yourself**, since you decide to learn RISC-V, you must practice it to understand it. For this kind of project at the bottom of computer architecture, there is no better way than to realize it from scratch. So with this idea, I started to collect information on the Internet, and the results were disappointing. Although there are many foreign open source projects related to RISC-V, many of them are implemented using Chisel, a high-level hardware construction language. The learning threshold is very high. In addition, in order to pursue the overall performance, some CPU system architectures are designed to be very complex (such as using five-level or more pipelines, multi-core processing, out-of-order execution, etc), it is very difficult for beginners to get started. So after careful consideration, I decided to write an open source processor project from scratch, which has a **simple system architecture, clear code and excellent package**, I hope it can be like Arduino, which stands out from many microcontrollers, so that more hardware enthusiasts can quickly start to experience, and develop many interesting applications based on it. In the future, under the mutual promotion of the software and hardware ecological environment, maybe more people will like CPU development and be willing to spend time on it. If I can really do this, I will be satisfied.

rtl/.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version = 2.6.4
22

3-
maxColumn = 135
3+
maxColumn = 300
44
align = most
55
continuationIndent.defnSite = 2
66
assumeStandardLibraryStripMargin = true

rtl/Makefile

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,6 @@ endef
4343
millTest:
4444
mill -i __.test
4545

46-
diffPrvBuild:
47-
@cp $(ROOT_PATH)/src/main/scala/top/SimTop.scala $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
48-
@sed -i 's/class SimTop/class SoCTop/g' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
49-
@sed -i '/val logCtrl/d' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
50-
@sed -i '/val perfInfo/d' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
51-
@sed -i '/val uart/d' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
52-
@sed -i '/io.uart/d' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
53-
@sed -i 's/memAXI_0/master/g' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
54-
@sed -i 's/val master = new AXI4IO/val master = new AXI4IO/g' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
55-
@sed -i '/val master/i\ val interrupt = Input(Bool())' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
56-
@sed -i '/val master/a\ val slave = Flipped(new AXI4IO)' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
57-
@sed -i 's/axiBridge.io.inst <> treeCoreL2.io.inst/axiBridge.io.inst <> treeCoreL2.io.inst/g' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
58-
@sed -i 's/axiBridge.io.mem <> treeCoreL2.io.mem/axiBridge.io.mem <> treeCoreL2.io.mem/g' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
59-
@sed -i '/protected val treeCoreL2/a\ treeCoreL2.io.uart.in.ch := DontCare' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
60-
@sed -i '/axiBridge.io.mem/a\ io.slave.r.bits.user := 0.U' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
61-
@sed -i '/axiBridge.io.mem/a\ io.slave.r.bits.id := 0.U' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
62-
@sed -i '/axiBridge.io.mem/a\ io.slave.r.bits.last := false.B' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
63-
@sed -i '/axiBridge.io.mem/a\ io.slave.r.bits.data := 0.U' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
64-
@sed -i '/axiBridge.io.mem/a\ io.slave.r.bits.resp := 0.U' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
65-
@sed -i '/axiBridge.io.mem/a\ io.slave.r.valid := false.B' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
66-
@sed -i '/axiBridge.io.mem/a\ io.slave.ar.ready := false.B' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
67-
@sed -i '/axiBridge.io.mem/a\ io.slave.b.bits.user := 0.U' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
68-
@sed -i '/axiBridge.io.mem/a\ io.slave.b.bits.id := 0.U' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
69-
@sed -i '/axiBridge.io.mem/a\ io.slave.b.bits.resp := 0.U' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
70-
@sed -i '/axiBridge.io.mem/a\ io.slave.b.valid := false.B' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
71-
@sed -i '/axiBridge.io.mem/a\ io.slave.w.ready := false.B' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
72-
@sed -i '/axiBridge.io.mem/a\ io.slave.aw.ready := false.B' $(ROOT_PATH)/src/main/scala/top/SoCTop.scala
73-
7446
diffBuild:
7547
mkdir -p $(BUILD_DIR)
7648
mill -i tc_l2.runMain treecorel2.TopMain -td $(BUILD_DIR)
@@ -102,13 +74,15 @@ dramsim3Build:
10274

10375
###### difftest target ######
10476
# if want to use the RamHelper, need to remove the 'WITH_DRAMSIM3=1'
77+
# becuase the framework, now the 'memAXI_0_[r|w]_bits_data' need to be replaced
78+
# by 'memAXI_0_w_bits_data[3:0]' in Makefile
10579
difftestBuild:
10680
@sed -i 's/io_memAXI_0_\([a-z]*\)_bits_data,/io_memAXI_0_\1_bits_data[3:0],/g' $(BUILD_DIR)/SimTop.v
10781
@sed -i 's/io_memAXI_0_w_bits_data =/io_memAXI_0_w_bits_data[0] =/g' $(BUILD_DIR)/SimTop.v
10882
@sed -i 's/ io_memAXI_0_r_bits_data;/ io_memAXI_0_r_bits_data[0];/g' $(BUILD_DIR)/SimTop.v
10983
$(MAKE) -C $(DIFFTEST_HOME) WITH_DRAMSIM3=1
11084

111-
diffAllBuild: diffPrvBuild diffBuild difftestBuild
85+
diffAllBuild: diffBuild difftestBuild
11286

11387
simpleTestBuild:
11488
$(MAKE) -C $(SIMPLETEST_HOME) ARCH=riscv64-mycpu

0 commit comments

Comments
 (0)