Skip to content

Commit 3531713

Browse files
committed
Merge branch 'dev' into main
2 parents 6f479af + 9ed6060 commit 3531713

File tree

9 files changed

+422
-64
lines changed

9 files changed

+422
-64
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ dramsim3.txt
1414
dramsim3epoch.json
1515
*.vcd
1616
*.wave
17+
.mypy_cache
18+
.pytest_cache
19+
dependency
1720
__pycache__

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,18 @@ Now, the develop schedule is recorded by the **Tencent Document**. You can click
7777
#### Enviroment setup(ubuntu 20.04 LTS)
7878
install verilator, mill and dep lib:
7979
```bash
80-
sudo apt-get install g++-riscv64-linux-gnu binutils-riscv64-linux-gnu
81-
./setup.sh -a
80+
make install
81+
make setup
8282
```
83-
8483
change the sim memory from 8G to 256MB. need to enter 'make menuconfig' and modify [Memory - Configuration]->[Memory size] to '0x10000000' manually.
8584
cd in root rtl dir
8685
```bash
8786
make nemuBuild
88-
make diffBuild
89-
make difftestBuild
90-
make demoTest
87+
make dramsim3Build
88+
make simpleTestBuild
89+
make riscvTestBuild
90+
make cpuTestBuild
91+
make amTestBuild
9192
```
9293

9394
### Software test

rtl/Makefile

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
SHELL=/bin/bash
22

33
# be carefully, this path will be used in clean(rm -rf)!!!
4-
ROOT_PATH := $(shell pwd)/tc_l2
5-
BUILD_DIR := ${ROOT_PATH}/build
6-
MILL_OUT_DIR := ${ROOT_PATH}/../out
4+
# need to set the $(CHIP_TARGET) with tc_lx(2, 3, 4...)
5+
CHIP_TARGET := tc_l2
6+
ROOT_PATH := $(shell pwd)/dependency
7+
SOURCE_PATH := $(ROOT_PATH)/../$(CHIP_TARGET)
8+
BUILD_DIR := $(SOURCE_PATH)/build
9+
MILL_OUT_DIR := $(ROOT_PATH)/../out
710

811
AM_FOLDER_PATH := $(ROOT_PATH)/am
912
AM_KERNEL_PATH := $(AM_FOLDER_PATH)/am-kernels
@@ -22,7 +25,7 @@ DRAMSIM3_HOME := $(ROOT_PATH)/DRAMsim3
2225
YSYXSOC_HOME := $(ROOT_PATH)/ysyxSoC/ysyx
2326

2427
###### soc var ######
25-
SOC_CSRC_HOME += $(ROOT_PATH)/src/main/csrc
28+
SOC_CSRC_HOME += $(SOURCE_PATH)/src/main/csrc
2629
SOC_CSRC_LIB_HOME += $(ROOT_PATH)/ysyxSoC/ysyx/peripheral/spiFlash
2730
SOC_CXXFILES += $(shell find $(SOC_CSRC_HOME) -name "*.cpp")
2831
SOC_CXXFILES += $(shell find $(SOC_CSRC_LIB_HOME) -name "*.cpp")
@@ -76,16 +79,23 @@ define getRecursiveTestRes
7679
fi
7780
endef
7881

82+
###### dev env target ######
83+
install:
84+
./scripts/install.sh -g -c
85+
86+
setup:
87+
./scripts/setup.sh -a
88+
7989
###### chisel target ######
8090
millTest:
8191
mill -i __.test
8292

8393
chiselBuild:
8494
mkdir -p $(BUILD_DIR)
85-
mill -i tc_l2.runMain top.TopMain -td $(BUILD_DIR)
95+
mill -i $(CHIP_TARGET).runMain top.TopMain -td $(BUILD_DIR)
8696

8797
chiselHelp:
88-
mill -i tc_l2.runMain top.TopMain --help
98+
mill -i $(CHIP_TARGET).runMain top.TopMain --help
8999

90100
millCompile:
91101
mill -i __.compile
@@ -117,13 +127,13 @@ difftestBuild:
117127
@sed -i 's/io_memAXI_0_\([a-z]*\)_bits_data,/io_memAXI_0_\1_bits_data[3:0],/g' $(BUILD_DIR)/SimTop.v
118128
@sed -i 's/io_memAXI_0_w_bits_data =/io_memAXI_0_w_bits_data[0] =/g' $(BUILD_DIR)/SimTop.v
119129
@sed -i 's/ io_memAXI_0_r_bits_data;/ io_memAXI_0_r_bits_data[0];/g' $(BUILD_DIR)/SimTop.v
120-
$(MAKE) -C $(DIFFTEST_HOME) WITH_DRAMSIM3=1 EMU_TRACE=1
130+
$(MAKE) -C $(DIFFTEST_HOME) WITH_DRAMSIM3=1 EMU_TRACE=1 DESIGN_DIR=$(SOURCE_PATH)
121131

122132
changeTargetToSimTop:
123-
@sed -i 's/SoCEna\([ ]*\)=\([ ]*\)true/SoCEna\1=\2false/g' $(ROOT_PATH)/src/main/scala/common/InstConfig.scala
133+
@sed -i 's/SoCEna\([ ]*\)=\([ ]*\)true/SoCEna\1=\2false/g' $(SOURCE_PATH)/src/main/scala/common/InstConfig.scala
124134

125135
changeTargetToSoCTop:
126-
@sed -i 's/SoCEna\([ ]*\)=\([ ]*\)false/SoCEna\1=\2true/g' $(ROOT_PATH)/src/main/scala/common/InstConfig.scala
136+
@sed -i 's/SoCEna\([ ]*\)=\([ ]*\)false/SoCEna\1=\2true/g' $(SOURCE_PATH)/src/main/scala/common/InstConfig.scala
127137

128138
simBuild: changeTargetToSimTop chiselBuild difftestBuild
129139

@@ -286,7 +296,8 @@ cleanDepRepo:
286296
cleanAll: cleanBuild cleanMillOut cleanDepRepo
287297

288298

289-
.PHONY: millTest chiselBuild chiselHelp millCompile millBsp format checkformat \
299+
.PHONY: install, setup,
300+
millTest chiselBuild chiselHelp millCompile millBsp format checkformat \
290301
nemuBuild dramsim3Build difftestBuild changeTargetToSimTop changeTargetToSoCTop simBuild \
291302
simpleTestBuild riscvTestBuild cpuTestBuild amTestBuild coremarkTestBuild \
292303
dhrystoneTestBuild microbenchTestBuild fecmuxTestBuild demoTest \

rtl/scripts/install.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
3+
help() {
4+
echo "Usage:"
5+
echo "install.sh [-g] [-c]"
6+
echo "Description:"
7+
echo "-g: Install gtkwave."
8+
echo "-c: Install mill for Chisel env."
9+
exit 0
10+
}
11+
12+
while getopts 'hgc' OPT; do
13+
case $OPT in
14+
h) help;;
15+
g) GTKWAVE="true";;
16+
c) CHISEL="true";;
17+
?) help;;
18+
esac
19+
done
20+
21+
if !(cat /etc/*release | grep 'Ubuntu 20.04'); then
22+
echo "Your Linux branch does not meet the requirements, please use Ubuntu 20.04."
23+
exit 1
24+
fi
25+
26+
UPDATED="false"
27+
install_package() {
28+
for package in $*
29+
do
30+
dpkg -s "$package" >/dev/null 2>&1 && {
31+
echo "$package has been installed."
32+
} || {
33+
if [[ $UPDATED == "false" ]]; then
34+
UPDATED="true"
35+
sudo apt-get update
36+
fi
37+
sudo apt-get --yes install $package
38+
}
39+
done
40+
}
41+
42+
install_verilator() {
43+
ubt20_64_package_list=("git" "perl" "python3" "make" "g++" "libfl2" "libfl-dev" "zlibc" "zlib1g" "zlib1g-dev" "ccache" "libgoogle-perftools-dev" "numactl" "perl-doc")
44+
for package in ${ubt20_64_package_list[@]} ; do
45+
install_package $package
46+
done
47+
48+
dpkg -s verilator >/dev/null 2>&1 && {
49+
echo "verilator has been installed."
50+
} || {
51+
wget -O /tmp/verilator_4_204_amd64.deb https://gitee.com/oscpu/install/attach_files/817254/download/verilator_4_204_amd64.deb
52+
sudo dpkg -i /tmp/verilator_4_204_amd64.deb
53+
rm /tmp/verilator_4_204_amd64.deb
54+
}
55+
}
56+
57+
install_mill() {
58+
install_package curl
59+
install_package default-jre
60+
61+
which mill >/dev/null 2>&1 && {
62+
echo "mill has been installed."
63+
} || {
64+
sudo mkdir /usr/local/bin >/dev/null 2>&1
65+
wget -O /tmp/mill https://gitee.com/oscpu/install/raw/master/mill
66+
sudo chmod +x /tmp/mill
67+
sudo mv /tmp/mill /usr/local/bin/
68+
}
69+
}
70+
71+
install_verilator
72+
73+
# install libsqlite3-dev for difftest
74+
install_package libsqlite3-dev
75+
# install libreadline-dev libsdl2-dev bison for NEMU
76+
install_package libreadline-dev libsdl2-dev bison
77+
# install cmake for DRAMsim3
78+
install_package cmake
79+
80+
[[ $GTKWAVE == "true" ]] && install_package gtkwave libcanberra-gtk-module
81+
[[ $CHISEL == "true" ]] && install_mill
82+
83+
echo "finish!"

rtl/tc_l2/setup.sh renamed to rtl/scripts/setup.sh

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ RIGHT="\033[0;32m"
77
END="\033[0m"
88

99

10-
ROOT_PATH=$(dirname $(readlink -f "$0"))
10+
ROOT_PATH=$(dirname $(readlink -f "$0"))/../dependency
1111
AM_FOLDER_PATH=${ROOT_PATH}"/am"
1212
ABSTRACT_MACHINE_FOLDER_PATH=${AM_FOLDER_PATH}"/abstract-machine"
1313
RISCV_TESTS_FOLDER_PATH=${AM_FOLDER_PATH}"/riscv-tests"
@@ -18,6 +18,7 @@ NEMU_FOLDER_PATH=${ROOT_PATH}"/NEMU"
1818
DRAMSIM3_FOLDER_PATH=${ROOT_PATH}"/DRAMsim3"
1919
YSYXSOC_PATH=${ROOT_PATH}"/ysyxSoC"
2020

21+
#TODO: am-kernel, simple-test need to dowload from the 'ysyx_software_file' repo
2122
# download the am repo from the github
2223
###### abstract-machine ######
2324
configAbstractMachine() {
@@ -52,27 +53,34 @@ configAbstractMachine() {
5253
fi
5354
echo -e "${RIGHT}AM_HOME: $AM_HOME${END}"
5455

55-
cd ${ROOT_PATH} # am -> tc-l2
56+
cd ${ROOT_PATH}
5657
}
5758

5859
###### riscv-tests ######
59-
configRiscvTests() {
60+
configTestSuites() {
6061
mkdir -p ${AM_FOLDER_PATH}
6162
cd ${AM_FOLDER_PATH}
6263

6364
if [[ -d ${RISCV_TESTS_FOLDER_PATH} ]]; then
6465
echo -e "${RIGHT}riscv-tests exist!${END}"
65-
# if git fsck --full != 0; then
66-
# echo "[download error]: remove the dir and git clone"
67-
# rm -rf riscv-tests
68-
# git clone https://github.com/NJU-ProjectN/riscv-tests.git
69-
# fi
7066
else
7167
echo -e "${INFO}[no download]: git clone${END}"
7268
git clone https://github.com/NJU-ProjectN/riscv-tests.git
7369
fi
7470

75-
cd ${ROOT_PATH} # am -> tc-l2
71+
# cd ${ROOT_PATH}
72+
73+
# mkdir -p ${AM_FOLDER_PATH}
74+
# cd ${AM_FOLDER_PATH}
75+
76+
# if [[ -d ${CPU_TESTS_FOLDER_PATH} ]]; then
77+
# echo -e "${RIGHT}simple-tests exist!${END}"
78+
# else
79+
# echo -e "${INFO}[no download]: git clone${END}"
80+
# git clone https://github.com/NJU-ProjectN
81+
# fi
82+
83+
# cd ${ROOT_PATH}
7684
}
7785

7886
###### am-kernels ######
@@ -82,17 +90,12 @@ configAMKernels() {
8290

8391
if [[ -d ${AM_KERNELS_FOLDER_PATH} ]]; then
8492
echo -e "${RIGHT}am-kernels exist!${END}"
85-
# if git fsck --full != 0; then
86-
# echo "[download error]: remove the dir and git clone"
87-
# rm -rf am-kernels
88-
# git clone https://github.com/NJU-ProjectN/am-kernels.git
89-
# fi
9093
else
9194
echo -e "${INFO}[no download]: git clone${END}"
9295
git clone https://github.com/NJU-ProjectN/am-kernels.git
9396
fi
9497

95-
cd ${ROOT_PATH} # am -> tc-l2
98+
cd ${ROOT_PATH}
9699
}
97100

98101
# download the specific commit id difftest and NEMU
@@ -103,11 +106,6 @@ configDiffTest() {
103106

104107
if [[ -d ${DIFFTEST_FOLDER_PATH} ]]; then
105108
echo -e "${RIGHT}difftest exist!${END}"
106-
# if git fsck --full != 0; then
107-
# echo "[download error]: remove the dir and git clone"
108-
# rm -rf am-kernels
109-
# git clone https://github.com/NJU-ProjectN/am-kernels.git
110-
# fi
111109
else
112110
echo -e "${INFO}[no download]: git clone${END}"
113111
git clone https://gitee.com/oscpu/difftest.git
@@ -126,11 +124,6 @@ configDiffTest() {
126124
configNemu() {
127125
if [[ -d ${NEMU_FOLDER_PATH} ]]; then
128126
echo -e "${RIGHT}NEMU exist!${END}"
129-
# if git fsck --full != 0; then
130-
# echo "[download error]: remove the dir and git clone"
131-
# rm -rf am-kernels
132-
# git clone https://github.com/NJU-ProjectN/am-kernels.git
133-
# fi
134127
else
135128
echo -e "${INFO}[no download]: git clone${END}"
136129
git clone https://gitee.com/oscpu/NEMU.git
@@ -171,11 +164,6 @@ configDramSim3() {
171164

172165
if [[ -d ${DRAMSIM3_FOLDER_PATH} ]]; then
173166
echo -e "${RIGHT}dramsim3 exist!${END}"
174-
# if git fsck --full != 0; then
175-
# echo "[download error]: remove the dir and git clone"
176-
# rm -rf am-kernels
177-
# git clone https://github.com/NJU-ProjectN/am-kernels.git
178-
# fi
179167
else
180168
echo -e "${INFO}[no download]: git clone${END}"
181169
git clone https://github.com/OpenXiangShan/DRAMsim3.git
@@ -207,19 +195,19 @@ helpInfo() {
207195
echo -e "${RIGHT} -d: download and config difftest${END}"
208196
echo -e "${RIGHT} -i: download and config dramsim3${END}"
209197
echo -e "${RIGHT} -m: download and config abstract-machine${END}"
210-
echo -e "${RIGHT} -r: download and config riscv-tests${END}"
198+
echo -e "${RIGHT} -r: download and config simple-tests, riscv-tests${END}"
211199
echo -e "${RIGHT} -k: download and config am-kernels${END}"
212200
echo -e "${RIGHT} -y: download and config ysyx-soc${END}"
213201
echo -e "${RIGHT} -s: download and config specific repo${END}"
214-
echo -e "sample: ./setup.sh -s [repo](default: nemu) ${INFO}[repo]: [nemu, diffttest, dramsim3, am, riscv-tests, am-kernels, ysyx-soc]${END}"
202+
echo -e "sample: ./setup.sh -s [repo](default: nemu) ${INFO}[repo]: [nemu, diffttest, dramsim3, am, testsuites, am-kernels, ysyx-soc]${END}"
215203
echo -e "${RIGHT} -h: help information${END}"
216204

217205
}
218206

219207
configSpecRepo() {
220208
if [[ -n $1 && $1 == "all" ]]; then
221209
configAbstractMachine
222-
configRiscvTests
210+
configTestSuites
223211
configAMKernels
224212
configDiffTest
225213
configNemu
@@ -233,17 +221,18 @@ configSpecRepo() {
233221
configDramSim3
234222
elif [[ -n $1 && $1 == "am" ]]; then
235223
configAbstractMachine
236-
elif [[ -n $1 && $1 == "riscv-tests" ]]; then
237-
configRiscvTests
224+
elif [[ -n $1 && $1 == "testsuites" ]]; then
225+
configTestSuites
238226
elif [[ -n $1 && $1 == "am-kernels" ]]; then
239227
configAMKernels
240228
elif [[ -n $1 && $1 == "ysyx-soc" ]]; then
241229
configysyxSoC
242230
else
243-
echo -e "${ERROR}the params [$1] is not found.${END} opt value: [nemu, diffttest, dramsim3, am, riscv-tests, am-kernels, ysyx-soc]"
231+
echo -e "${ERROR}the params [$1] is not found.${END} opt value: [nemu, diffttest, dramsim3, am, testsuites, am-kernels, ysyx-soc]"
244232
fi
245233
}
246234

235+
mkdir -p ${ROOT_PATH}
247236
# Check parameters
248237
while getopts 'andimrkys:h' OPT; do
249238
case $OPT in
@@ -252,7 +241,7 @@ while getopts 'andimrkys:h' OPT; do
252241
d) configDiffTest;;
253242
i) configDramSim3;;
254243
m) configAbstractMachine;;
255-
r) configRiscvTests;;
244+
r) configTestSuites;;
256245
k) configAMKernels;;
257246
y) configysyxSoC;;
258247
s) configSpecRepo $OPTARG;;

rtl/tc_l2/src/main/scala/common/InstConfig.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,13 @@ import chisel3._
44
import chisel3.util._
55

66
trait InstConfig {
7-
val SoCEna = false
7+
val SoCEna = false
8+
val CacheEna = false
9+
val XLen = 64
10+
val NWay = 4
11+
val NBank = 4
12+
val NSet = 32
13+
val CacheLineSize = 64 * NBank
14+
val ICacheSize = NWay * NSet * CacheLineSize
15+
val DCacheSize = NWay * NSet * CacheLineSize
816
}

0 commit comments

Comments
 (0)