-
Notifications
You must be signed in to change notification settings - Fork 0
192 lines (188 loc) · 7.58 KB
/
Copy pathself-hosted-difftest.yml
File metadata and controls
192 lines (188 loc) · 7.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: Self-hosted Difftest
on:
push:
branches:
- master
- feat-*
- fix-*
- perf-*
workflow_dispatch:
jobs:
setup-toolchains:
name: Setup toolchains
runs-on: self-hosted
steps:
- name: Remove toolchains stub
run: |
rm -rf ./toolchains
- name: Restore toolchains cache
uses: woshiluo/local-cache@v3
id: cache-toolchains-restore
with:
path: toolchains
base: /var/cache/github_runners/local-cache
key: ${{ runner.os }}-toolchains
- name: Setup directory structure
if: steps.cache-toolchains-restore.outputs.cache-hit != 'true'
run: |
mkdir -p toolchains
chgrp github_runners toolchains
chmod g+s toolchains
cd toolchains
mkdir -p nemu picolibc newlib
- name: Download and setup GCC toolchain
if: steps.cache-toolchains-restore.outputs.cache-hit != 'true'
run: |
cd toolchains
wget https://gitee.com/loongson-edu/la32r-toolchains/releases/download/v0.0.3/loongson-gnu-toolchain-8.3-x86_64-loongarch32r-linux-gnusf-v2.0.tar.xz
tar -xf loongson-gnu-toolchain-8.3-x86_64-loongarch32r-linux-gnusf-v2.0.tar.xz
chmod -R +x loongson-gnu-toolchain-8.3-x86_64-loongarch32r-linux-gnusf-v2.0/bin/
rm loongson-gnu-toolchain-8.3-x86_64-loongarch32r-linux-gnusf-v2.0.tar.xz
- name: Download NEMU
if: steps.cache-toolchains-restore.outputs.cache-hit != 'true'
run: |
cd toolchains/nemu
wget https://gitee.com/wwt_panache/la32r-nemu/releases/download/v1.0.5-x86/la32r-nemu-interpreter-so
chmod +x la32r-nemu-interpreter-so
- name: Download and setup picolibc
if: steps.cache-toolchains-restore.outputs.cache-hit != 'true'
run: |
cd toolchains
wget https://gitee.com/ffshff/la32r-picolibc/releases/download/V1.0/picolibc.tar.gz
tar -xzf picolibc.tar.gz -C picolibc
rm picolibc.tar.gz
- name: Download and setup newlib
if: steps.cache-toolchains-restore.outputs.cache-hit != 'true'
run: |
cd toolchains
wget https://gitee.com/ffshff/newlib-la32r/releases/download/V1.0/newlib.tar.gz
tar -xzf newlib.tar.gz -C newlib
rm newlib.tar.gz
- name: Download and setup QEMU
if: steps.cache-toolchains-restore.outputs.cache-hit != 'true'
run: |
cd toolchains
wget https://gitee.com/loongson-edu/la32r-QEMU/releases/download/v0.0.2/la32r-QEMU-x86_64-ubuntu-22.04.tar
tar -xf la32r-QEMU-x86_64-ubuntu-22.04.tar
chmod -R +x la32r-QEMU-x86_64-ubuntu-22.04/
rm la32r-QEMU-x86_64-ubuntu-22.04.tar
generate-verilog:
runs-on: self-hosted
if: ${{ !(contains(github.event.head_commit.message, format('X-Actions-Control{0} no-verilog', ':')) || contains(github.event.head_commit.message, format('X-Actions-Control{0}no-verilog', ':'))) }}
strategy:
fail-fast: false
matrix:
build-mode: [full]
name: 'Generate Verilog: ${{ matrix.build-mode }}'
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
- name: Verify dependencies installation
run: |
firtool --version
which espresso
- name: Clobber Chisel
if: ${{ contains(github.event.head_commit.message, format('X-Actions-Control{0} clobber-chisel', ':')) || contains(github.event.head_commit.message, format('X-Actions-Control{0}clobber-chisel', ':')) }}
run: |
cd dependencies/chisel
./mill clean
- name: Setup Chisel
run: |
cd dependencies/chisel
./mill unipublish.publishLocal
- name: Patch CoreTop config
run: |
export UNTITL3D_BUILD_MODE=${{ matrix.build-mode }}
export UNTITL3D_BUILD_PATCH_CORETOP_CONFIG=config/CoreTop.json
./scripts/switch_build_mode.sh
export UNTITL3D_SYNTHESIS=off
export UNTITL3D_SYNTHESIS_PATCH_CORETOP_CONFIG=./config/CoreTop.json
./scripts/switch_synthesis.sh
sed -i -E 's/"tlbEntryNum":[[:space:]]*[[:digit:]]+/"tlbEntryNum": 32/gI' ./config/CoreTop.json
sed -i -E 's/"tlbEntries":[[:space:]]*[[:digit:]]+/"tlbEntries": 32/gI' ./config/CoreTop.json
- name: Clean previous runs
run: |
./mill clean
make clean
make clean DESIGN=backend
- name: Generate RTL
run: |
make -j verilog
- name: Upload built RTL
uses: actions/upload-artifact@v4
with:
name: verilog-output-${{ matrix.build-mode }}
path: ./IP/myCPU/rtl/CoreTop
retention-days: 2
difftest:
runs-on: self-hosted
needs: [setup-toolchains, generate-verilog]
if: ${{ contains(github.event.head_commit.message, format('X-Actions-Control{0} difftest', ':')) || contains(github.event.head_commit.message, format('X-Actions-Control{0}difftest', ':')) }}
strategy:
fail-fast: false
matrix:
build-mode: [full]
test-name: [func/func_lab19, my_coremark, fireye/my_A0]
name: 'Difftest ${{ matrix.test-name }}: ${{ matrix.build-mode }}'
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.GH_TOKEN }}
- name: Remove toolchains stub
run: |
rm -rf ./toolchains
- name: Restore toolchains cache
uses: woshiluo/local-cache@v3
with:
base: /var/cache/github_runners/local-cache
path: toolchains
key: ${{ runner.os }}-toolchains
- name: Fetch built RTL
uses: actions/download-artifact@v4
with:
name: verilog-output-${{ matrix.build-mode }}
path: ./IP/myCPU/rtl/CoreTop
- name: Setup environment variables
run: |
echo "CHIPLAB_HOME=$(pwd)" >> $GITHUB_ENV
- name: Setup PATH
run: |
echo "${CHIPLAB_HOME}/toolchains/loongson-gnu-toolchain-8.3-x86_64-loongarch32r-linux-gnusf-v2.0/bin/" >> $GITHUB_PATH
echo "${CHIPLAB_HOME}/toolchains/la32r-QEMU-x86_64-ubuntu-22.04/" >> $GITHUB_PATH
- name: Build DPI library
run: |
CC=clang CXX=clang++ make -j dpi-lib DESIGN=backend
- name: Build test and driver
run: |
cd ./sims/verilator/run_prog
./configure.sh --run ${{ matrix.test-name }} --output-pc-info
# https://unix.stackexchange.com/questions/14270/get-exit-status-of-process-thats-piped-to-another
set -o pipefail
CC=clang CXX=clang++ make -j 2> >(tee build_stderr_output.log >&2) | tee build_stdout_output.log
- name: Test
run: |
cd ./sims/verilator/run_prog
make run TIME_LIMIT=10000000 1> run_output.log 2> sim.md
- name: Tail report
if: ${{ success() || failure() }}
run: |
tail -n 128 ./sims/verilator/run_prog/run_output.log
- name: Generate report name
id: generate-report-name
if: ${{ failure() }}
run: |
echo "report_name=$(echo 'difftest-report-${{ matrix.test-name }}-${{ matrix.build-mode }}' | sed 's/\//-/g')" | tee $GITHUB_OUTPUT
- name: Upload report
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: ${{ steps.generate-report-name.outputs.report_name }}
path: |
./sims/verilator/run_prog/sim.md
./sims/verilator/run_prog/*_output.log
./sims/verilator/run_prog/log/
retention-days: 1