Skip to content

Commit 280b296

Browse files
committed
Merge branch 'tc-l3' into dev
2 parents b13b828 + 6919395 commit 280b296

File tree

5 files changed

+54
-28
lines changed

5 files changed

+54
-28
lines changed

.github/workflows/unit-test.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,10 @@ jobs:
1515
cd rtl
1616
chmod +x scripts/install.sh
1717
make install
18-
# chmod +x scripts/setup.sh
19-
# make setup
18+
chmod +x scripts/setup.sh
19+
make setup
20+
make nemuBuild
21+
make dramsim3Build
22+
make riscvTestBuild
23+
make cpuTestBuild
24+
make CHIP_TARGET=tc_l2 unit-test

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,14 @@ adsfadfasdfasf
9797
9898
First, you need to install verilator, mill and dependency libraries:
9999
```bash
100+
$ su -
100101
$ cd rtl
102+
$ chmod +x scripts/install.sh
101103
$ make install
102104
```
103105
Then, download and configuare all components from the github:
104106
```bash
107+
$ chmod +x scripts/setup.sh
105108
$ make setup
106109
```
107110
After that, you need to set the `NEMU_HOME` and `NOOP_HOME` environment variables:

rtl/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ demoTest:
184184
simpleTestbinFile = $(foreach dir, $(SIMPLETEST_HOME)/build, $(wildcard $(dir)/*.bin))
185185
simpleTestCaseName = $(foreach file, $(simpleTestbinFile), $(patsubst %-riscv64-mycpu, simpletest-%, $(basename $(notdir $(file)))))
186186
simpleTestLogFile = $(foreach file, $(simpleTestCaseName), $(patsubst %, %-log.txt, $(file)))
187-
$(shell mkdir -p $(SIMPLETEST_HOME)/build/log 1>/dev/null 2>&1)
187+
$(shell if [[ -d $(SIMPLETEST_HOME) ]]; then mkdir -p $(SIMPLETEST_HOME)/build/log 1>/dev/null 2>&1; fi)
188188

189189
simpleRecursiveTest: $(simpleTestLogFile) $(simpleTestCaseName)
190190
@printf "[\033[0;33m%s\033[0m]\n" all-done
@@ -202,11 +202,12 @@ $(simpleTestCaseName): simpletest-%: $(SIMPLETEST_HOME)/build/%-riscv64-mycpu.bi
202202

203203

204204
###### riscv test recursive test target ######
205+
riscvNum = 50
205206
riscvTestbinFile = $(foreach dir, $(RISCVTEST_HOME)/build, $(wildcard $(dir)/*.bin))
206207
riscvTestCaseName = $(foreach file, $(riscvTestbinFile), $(patsubst %-riscv64-mycpu, riscvtest-%, $(basename $(notdir $(file)))))
207208
riscvTestLogFile = $(foreach file, $(riscvTestCaseName), $(patsubst %, %-log.txt, $(file)))
208-
riscvNum = 50
209-
$(shell mkdir -p $(RISCVTEST_HOME)/build/log 1>/dev/null 2>&1)
209+
$(shell if [[ -d $(RISCVTEST_HOME) ]]; then mkdir -p $(RISCVTEST_HOME)/build/log 1>/dev/null 2>&1; fi)
210+
210211
riscvRecursiveTest: $(riscvTestLogFile) $(riscvTestCaseName)
211212
@printf "[\033[0;33mall-done\033[0m]\n"
212213
@echo -e "[\033[0;33mAll: $$(cat $(RISCVTEST_HOME)/build/log/allcasenum-log.txt) \033[0;32mPASS: $$(cat $(RISCVTEST_HOME)/build/log/passcasenum-log.txt) \033[0;31mFAIL: $$(echo $$(echo $$(cat $(RISCVTEST_HOME)/build/log/allcasenum-log.txt) - $$(cat $(RISCVTEST_HOME)/build/log/passcasenum-log.txt) | bc))\033[0m]";
@@ -226,7 +227,8 @@ $(riscvTestCaseName): riscvtest-%: $(RISCVTEST_HOME)/build/%-riscv64-mycpu.bin
226227
cpuTestbinFile = $(foreach dir, $(CPUTEST_HOME)/build, $(wildcard $(dir)/*.bin))
227228
cpuTestCaseName = $(foreach file, $(cpuTestbinFile), $(patsubst %-riscv64-mycpu, cputest-%, $(basename $(notdir $(file)))))
228229
cpuTestLogFile = $(foreach file, $(cpuTestCaseName), $(patsubst %, %-log.txt, $(file)))
229-
$(shell mkdir -p $(CPUTEST_HOME)/build/log 1>/dev/null 2>&1)
230+
$(shell if [[ -d $(CPUTEST_HOME) ]]; then mkdir -p $(CPUTEST_HOME)/build/log 1>/dev/null 2>&1; fi)
231+
230232
cpuRecursiveTest: $(cpuTestLogFile) $(cpuTestCaseName)
231233
@printf "[\033[0;33mall-done\033[0m]\n"
232234
@echo -e "[\033[0;33mAll: $$(cat $(CPUTEST_HOME)/build/log/allcasenum-log.txt) \033[0;32mPASS: $$(cat $(CPUTEST_HOME)/build/log/passcasenum-log.txt) \033[0;31mFAIL: $$(echo $$(echo $$(cat $(CPUTEST_HOME)/build/log/allcasenum-log.txt) - $$(cat $(CPUTEST_HOME)/build/log/passcasenum-log.txt) | bc))\033[0m]";

rtl/scripts/install.sh

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,26 @@ install_verilator() {
4646
install_package $package
4747
done
4848

49-
git clone https://github.com/verilator/verilator # Only first time
49+
which verilator >/dev/null 2>&1 && {
50+
echo "verilator has been installed."
51+
} || {
52+
git clone https://github.com/verilator/verilator /tmp/verilator # run first time
5053

51-
# Every time you need to build:
52-
# unsetenv VERILATOR_ROOT # For csh; ignore error if on bash
53-
unset VERILATOR_ROOT # For bash
54-
cd verilator
55-
git pull # Make sure git repository is up-to-date
56-
git tag # See what versions exist
57-
#git checkout master # Use development branch (e.g. recent bug fixes)
58-
#git checkout stable # Use most recent stable release
59-
git checkout v4.204 # Switch to specified release version
54+
# every time you need to build:
55+
# unsetenv VERILATOR_ROOT # For csh; ignore error if on bash
56+
unset VERILATOR_ROOT # for bash
57+
cd /tmp/verilator
58+
git pull # make sure git repository is up-to-date
59+
git tag # see what versions exist
60+
#git checkout master # use development branch (e.g. recent bug fixes)
61+
#git checkout stable # use most recent stable release
62+
git checkout v4.204 # switch to specified release version
6063

61-
autoconf # Create ./configure script
62-
./configure # Configure and create Makefile
63-
make -j `nproc` # Build Verilator itself (if error, try just 'make')
64-
sudo make install
64+
autoconf # create ./configure script
65+
./configure # configure and create Makefile
66+
make -j `nproc` # build Verilator itself (if error, try just 'make')
67+
sudo make install
68+
}
6569

6670
# dpkg -s verilator >/dev/null 2>&1 && {
6771
# echo "verilator has been installed."
@@ -95,8 +99,11 @@ install_package libsqlite3-dev
9599
install_package libreadline-dev libsdl2-dev bison
96100
# install cmake for DRAMsim3
97101
install_package cmake
102+
# isntall riscv toolchain
103+
install_package g++-riscv64-linux-gnu
104+
install_package binutils-riscv64-linux-gnu
98105

99106
[[ $GTKWAVE == "true" ]] && install_package gtkwave libcanberra-gtk-module
100107
[[ $CHISEL == "true" ]] && install_mill
101108

102-
echo "finish!"
109+
echo "############# verilator and mill install finish!!! #############"

rtl/scripts/setup.sh

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ configYsyxSoftwareFile() {
3434
# download the am repo from the github
3535
###### abstract-machine ######
3636
configAbstractMachine() {
37+
configYsyxSoftwareFile
38+
3739
mkdir -p ${AM_FOLDER_PATH}
3840
cd ${AM_FOLDER_PATH}
39-
4041
if [[ -d ${ABSTRACT_MACHINE_FOLDER_PATH} ]]; then
4142
echo -e "${RIGHT}abstract-machine exist!${END}"
4243
# if git fsck --full != 0; then
@@ -45,12 +46,14 @@ configAbstractMachine() {
4546
# git clone https://github.com/NJU-ProjectN/abstract-machine.git
4647
# fi
4748
else
48-
echo -e "${INFO}[no download]: git clone...${END}"
49-
git clone https://github.com/NJU-ProjectN/abstract-machine.git
49+
echo -e "${INFO}[no exist] copy...${END}"
50+
cp -rf ${YSYX_SOFTWARE_FILE_PATH}/abstract-machine ./
51+
# echo -e "${INFO}[no download]: git clone...${END}"
52+
# git clone https://github.com/NJU-ProjectN/abstract-machine.git
5053
fi
5154

5255
cd ${ABSTRACT_MACHINE_FOLDER_PATH}
53-
git checkout ysyx2021
56+
# git checkout ysyx2021
5457

5558
if [[ -z $AM_HOME ]]; then
5659
echo -e "${INFO}AM_HOME is empty, set AM_HOME...${END}"
@@ -72,12 +75,11 @@ configAbstractMachine() {
7275
configTestSuites() {
7376
mkdir -p ${AM_FOLDER_PATH}
7477
cd ${AM_FOLDER_PATH}
75-
7678
if [[ -d ${RISCV_TESTS_FOLDER_PATH} ]]; then
7779
echo -e "${RIGHT}riscv-tests exist!${END}"
7880
else
7981
echo -e "${INFO}[no download]: git clone...${END}"
80-
git clone https://github.com/NJU-ProjectN/riscv-tests.git
82+
git clone https://github.com/NJU-ProjectN/riscv-tests.git
8183
fi
8284

8385
cd ${ROOT_PATH}
@@ -137,6 +139,8 @@ configDiffTest() {
137139

138140
###### NEMU ######
139141
configNemu() {
142+
cd ${ROOT_PATH}
143+
140144
if [[ -d ${NEMU_FOLDER_PATH} ]]; then
141145
echo -e "${RIGHT}NEMU exist!${END}"
142146
else
@@ -167,7 +171,9 @@ configNemu() {
167171
# change the sim memory from 8G to 256MB
168172
# need to enter 'make menuconfig' and
169173
# modify [Memory Configuration]->[Memory size] to '0x10000000' manually
170-
# sed -i 's/^\(CONFIG_MSIZE=0x\)\(.*\)/\110000000/' .config
174+
sed -i 's/^\(CONFIG_MSIZE=0x\)\(.*\)/\110000000/' .config
175+
# NOTE: you need to set the 'NEMU_HOME' and 'NOOP_HOME' in sh config file!
176+
# because the compliation only reads sh env vars
171177

172178
cd ${ROOT_PATH}
173179
}
@@ -186,6 +192,7 @@ configDramSim3() {
186192

187193
cd ${DRAMSIM3_FOLDER_PATH}
188194
git checkout 5723f6b1cc157ac2d7b4154b50fd1799c9cf54aa
195+
189196
cd ${ROOT_PATH}
190197
}
191198

@@ -199,6 +206,8 @@ configYsyxSoC() {
199206
echo -e "${INFO}[no download]: git clone...${END}"
200207
git clone --depth 1 https://github.com/OSCPU/ysyxSoC.git
201208
fi
209+
210+
cd ${ROOT_PATH}
202211
}
203212

204213
helpInfo() {

0 commit comments

Comments
 (0)