Skip to content

Commit bc18469

Browse files
committed
Merge branch 'tc-l2' into dev
2 parents ffa48cc + 7e9590b commit bc18469

20 files changed

+304
-368
lines changed

README.md

Lines changed: 19 additions & 9 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" />
33
<h1 align="center">TreeCore CPU</h1>
4-
<p align="center">A series of RISC-V soft core processor written from scratch</p>
4+
<p align="center">A series of RISCV soft core processor written from scratch</p>
55
</p>
66
<p align="center">
77
<a href="./LICENSE">
@@ -19,25 +19,34 @@
1919
</p>
2020

2121
## Overview
22-
the TreeCore L2 is the
22+
the TreeCore L2 is the riscv64 software core developed under the [Open Source Chip Project by University (OSCPU)](https://github.com/OSCPU). OSCPU was initiated by ICTCAS(**_Institute of computing Technology, Chinese Academy of Sciences_**), which aims to make students use all open-source toolchain to design, develop open-source chips by themselves. It also can be called "One Life, One Chip" project in Chinese which has achieved two season. Now Season 3 is in progress in 2021.
2323

2424
## Feature
25-
* 64-bit five-stage pipeline RISC-V ISA CPU core.
26-
* support RISC-V integer(I) instruction set.
25+
* 64-bits single-issue, five-stage pipeline RISCV ISA CPU core.
26+
* support RISCV integer(I) instruction set.
2727
* supports machine mode privilege levels.
2828
* supports AXI4 inst and mem acess.
2929
* can boot rt-thread.
30+
* develop under all open-source toolchain.
3031

32+
## Develop Schedule
33+
Now, the develop schedule is recorded by the **Tencent Document**. You can click this link [schedule table](https://docs.qq.com/sheet/DY3lORW5Pa3pLRFpT?newPad=1&newPadType=clone&tab=BB08J2) to view it.
3134

3235
## Datapath Diagram
3336

3437
### Memory Map
3538

3639
| Range | Description |
3740
| ------------------------- | --------------------------------------------------- |
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+
| 0x0000_0000 - 0x01ff_ffff | reserve |
42+
| 0x0200_0000 - 0x0200_ffff | clint |
43+
| 0x0201_0000 - 0x0fff_ffff | reserve |
44+
| 0x1000_0000 - 0x1000_0fff | uart16550 |
45+
| 0x1000_1000 - 0x1000_1fff | spi controller |
46+
| 0x1000_2000 - 0x2fff_ffff | reserve |
47+
| 0x3000_0000 - 0x3fff_ffff | spi flash xip mode |
48+
| 0x4000_0000 - 0x7fff_ffff | chiplink |
49+
| 0x8000_0000 - 0x8xxx_xxxx | mem |
4150

4251
#### Configuration
4352

@@ -83,7 +92,8 @@ $ make demoTest
8392
## License
8493

8594
## Story
95+
I heard the word **_RISCV_** first time in the second semester of my junior year(that is, the summer of 2016). My roommate participated 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 RISCV 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, so I didn't take it too seriously. But what is unexpected is that after just a few period of development, the RISCV has been supported by many Internet and semiconductor giants around the world, and more and more research institutions, start-ups begin to design their own proprietary processors based on it. Although now the performance and application of RISCV are still limited, **I believe RISCV will usher in a revolution that can change the old pattern in someday**.
8696

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!
97+
The ancients once said: **it’s always shallow on paper, and you must do it yourself**. For the learn of the computer architecture, there is no better way to realize it from scratch. So I started to collect materials from the Internet, and I found the learning threshold and cost is very high. In addition, in order to pursue the performance, some open-source CPU cores are very complex(such as using mulit-pipelines, multi-core processing, out-of-order execution technology, etc), it is very difficult for beginners to get started. So I decided to design a series of open source processors from scratch, which has **simple, understandable architecture, high-quality code with step-to-step tutorial**.
8898

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.
99+
I hope it can become a ABC project like Arduino and make more processor enthusiasts or computer related specialized students enter into the computer architecture field. In the future, under the mutual promotion of the software and hardware ecosystem, I believe more people will like CPU development and be willing to spend time on it.

rtl/tc_l2/src/main/scala/axi4/AXI4Bridge.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ class AXI4Bridge() extends Module with AXI4Config with InstConfig {
302302
// h: 0001
303303
// w: 0011
304304
// d: 0111
305-
protected val instAddrOpA = WireDefault(UInt(4.W), Cat(0.U, io.inst.addr(ALIGNED_WIDTH-1, 0)))
305+
protected val instAddrOpA = WireDefault(UInt(4.W), Cat(0.U, io.inst.addr(ALIGNED_WIDTH - 1, 0)))
306306
protected val instAddrOpB = WireDefault(
307307
UInt(4.W),
308308
(Fill(4, instSizeByte) & "b0000".U(4.W))
@@ -359,7 +359,7 @@ class AXI4Bridge() extends Module with AXI4Config with InstConfig {
359359
protected val memSizeWord = WireDefault(io.mem.size === AXI4Bridge.SIZE_W)
360360
protected val memSizeDouble = WireDefault(io.mem.size === AXI4Bridge.SIZE_D)
361361

362-
protected val memAddrOpA = WireDefault(UInt(4.W), Cat(0.U, io.mem.addr(ALIGNED_WIDTH-1, 0)))
362+
protected val memAddrOpA = WireDefault(UInt(4.W), Cat(0.U, io.mem.addr(ALIGNED_WIDTH - 1, 0)))
363363
protected val memAddrOpB = WireDefault(
364364
UInt(4.W),
365365
(Fill(4, memSizeByte) & "b0000".U(4.W))
@@ -399,8 +399,8 @@ class AXI4Bridge() extends Module with AXI4Config with InstConfig {
399399
| ((Fill(8, memSizeDouble) & "b1111_1111".U(8.W)))
400400
)
401401

402-
protected val memStrbLow = WireDefault(UInt((AxiDataWidth/8).W), memStrb << io.mem.addr(ALIGNED_WIDTH-1, 0))
403-
protected val memStrbHig = WireDefault(UInt((AxiDataWidth/8).W), memStrb >> ((AxiDataWidth/8).U - io.mem.addr(ALIGNED_WIDTH-1, 0)))
402+
protected val memStrbLow = WireDefault(UInt((AxiDataWidth / 8).W), memStrb << io.mem.addr(ALIGNED_WIDTH - 1, 0))
403+
protected val memStrbHig = WireDefault(UInt((AxiDataWidth / 8).W), memStrb >> ((AxiDataWidth / 8).U - io.mem.addr(ALIGNED_WIDTH - 1, 0)))
404404

405405
protected val memAxiUser = Fill(AxiUserLen, "b0".U(1.W))
406406
protected val memReady = RegInit(false.B)

rtl/tc_l2/src/main/scala/core/CSRReg.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import treecorel2.common.ConstVal._
88
class CSRReg() extends Module with InstConfig {
99
val io = IO(new Bundle {
1010
// from id
11+
val inst: INSTIO = new INSTIO
1112
val rdAddrIn: UInt = Input(UInt(CSRAddrLen.W))
1213
val instOperTypeIn: UInt = Input(UInt(InstOperTypeLen.W))
13-
val inst: INSTIO = new INSTIO
14+
1415
// from ex's out
1516
val wtEnaIn: Bool = Input(Bool())
1617
val wtDataIn: UInt = Input(UInt(BusWidth.W))

0 commit comments

Comments
 (0)