forked from lowRISC/ibex
-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
166 lines (151 loc) · 6.32 KB
/
azure-pipelines.yml
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
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Azure Pipelines CI build configuration
# Documentation at https://aka.ms/yaml
variables:
VERILATOR_VERSION: 4.028
VERILATOR_PATH: /opt/buildcache/verilator/$(VERILATOR_VERSION)
RISCV_TOOLCHAIN_TAR_VERSION: 20190807-1
RISCV_COMPLIANCE_GIT_VERSION: 844c6660ef3f0d9b96957991109dfd80cc4938e2
trigger:
batch: true
branches:
# Combine builds on master as long as another build is running
include:
- master
# Note: All tests run as part of one job to avoid copying intermediate build
# artifacts around (e.g. Verilator and toolchain builds). Once more builds/tests
# are added, we need to re-evaluate this decision to parallelize jobs and
# improve end-to-end CI times.
jobs:
- job: lint_dv
displayName: Run quality checks (Lint and DV)
pool:
vmImage: "ubuntu-16.04"
steps:
# Installing six is a workaround for pip dependency resolution: six is already
# installed as system package with a version below the required one.
# Explicitly installing six through pip gets us a supported version.
#
# Updating pip and setuptools is required to have these tools properly parse
# Python-version metadata, which some packages uses to specify that an older
# version of a package must be used for a certain Python version. If that
# information is not read, pip installs the latest version, which then fails
# to run.
- bash: |
sudo apt-get install -y \
python3 \
python3-pip \
python3-setuptools \
srecord \
zlib1g-dev \
git \
make \
autoconf \
g++ \
flex \
bison \
curl \
libelf-dev \
clang-format \
&& sudo pip3 install -U setuptools pip six \
&& sudo pip3 install -U fusesoc
displayName: Install dependencies
- bash: |
set -e
if [ ! -d $(VERILATOR_PATH) ]; then
echo "Building verilator (no cached build found)"
mkdir -p build/verilator
cd build/verilator
curl -Ls -o verilator.tgz https://www.veripool.org/ftp/verilator-$(VERILATOR_VERSION).tgz
tar -xf verilator.tgz
cd verilator-$(VERILATOR_VERSION)
./configure --prefix=$(VERILATOR_PATH)
make -j$(nproc)
mkdir -p $VERILATOR_PATH
make install
else
echo "Re-using cached verilator build"
fi
echo "##vso[task.setvariable variable=PATH]$VERILATOR_PATH/bin:$PATH"
displayName: Build and install Verilator
- bash: |
export TOOLCHAIN_URL=https://github.com/lowRISC/lowrisc-toolchains/releases/download/${RISCV_TOOLCHAIN_TAR_VERSION}/lowrisc-toolchain-gcc-rv32imc-${RISCV_TOOLCHAIN_TAR_VERSION}.tar.xz
mkdir -p build/toolchain
curl -Ls -o build/toolchain/rv32-toolchain.tar.xz $TOOLCHAIN_URL
sudo mkdir -p /tools/riscv && sudo chmod 777 /tools/riscv
tar -C /tools/riscv -xf build/toolchain/rv32-toolchain.tar.xz --strip-components=1
echo "##vso[task.setvariable variable=PATH]/tools/riscv/bin:$PATH"
displayName: Get precompiled RISC-V toolchain
- bash: |
echo $PATH
python3 --version
echo -n "fusesoc "
fusesoc --version
verilator --version
riscv32-unknown-elf-gcc --version
displayName: Display environment
- bash: |
fusesoc --cores-root . run --target=lint lowrisc:ibex:ibex_core_tracing
if [ $? != 0 ]; then
echo -n "##vso[task.logissue type=error]"
echo "Verilog lint failed. Run 'fusesoc --cores-root . run --target=lint lowrisc:ibex:ibex_core_tracing' to check and fix all errors."
exit 1
fi
displayName: Lint Verilog source files with Verilator
- bash: |
fork_origin=$(git merge-base --fork-point origin/master)
changed_files=$(git diff --name-only $fork_origin | grep -v /vendor/ | grep -E '\.(cpp|cc|c|h)$')
test -z "$changed_files" || git diff -U0 $fork_origin $changed_files | clang-format-diff -p1 | tee clang-format-output
if [ -s clang-format-output ]; then
echo -n "##vso[task.logissue type=error]"
echo "C/C++ lint failed. Use 'git clang-format' with appropriate options to reformat the changed code."
exit 1
fi
# This check is not idempotent, but checks changes to a base branch.
# Run it only on pull requests.
condition: eq(variables['Build.Reason'], 'PullRequest')
displayName: 'Use clang-format to check C/C++ coding style'
- bash: |
# Build and run CSR testbench
fusesoc --cores-root=. run --target=sim --tool=verilator lowrisc:ibex:tb_cs_registers
displayName: Build and run CSR testbench with Verilator
- bash: |
cd build
git clone https://github.com/riscv/riscv-compliance.git
cd riscv-compliance
git checkout "$(RISCV_COMPLIANCE_GIT_VERSION)"
displayName: Get RISC-V Compliance test suite
- bash: |
# Build simulation model of Ibex
fusesoc --cores-root=. run --target=sim --setup --build lowrisc:ibex:ibex_riscv_compliance --RV32M=1 --RV32E=0
if [ $? != 0 ]; then
echo -n "##vso[task.logissue type=error]"
echo "Unable to build Verilator model of Ibex for compliance testing."
exit 1
fi
# Run compliance test suite
export TARGET_SIM=$PWD/build/lowrisc_ibex_ibex_riscv_compliance_0.1/sim-verilator/Vibex_riscv_compliance
export RISCV_PREFIX=riscv32-unknown-elf-
export RISCV_TARGET=ibex
export RISCV_DEVICE=rv32imc
fail=0
for isa in rv32i rv32im rv32imc rv32Zicsr rv32Zifencei; do
make -C build/riscv-compliance RISCV_ISA=$isa 2>&1 | tee run.log
if [ ${PIPESTATUS[0]} != 0 ]; then
echo -n "##vso[task.logissue type=error]"
echo "The RISC-V compliance test suite failed for $isa"
# There's no easy way to get the test results in machine-readable
# form to properly exclude known-failing tests. Going with an
# approximate solution for now.
if [ $isa == rv32i ] && grep -q 'FAIL: 4/48' run.log; then
echo -n "##vso[task.logissue type=error]"
echo "Expected failure for rv32i, see lowrisc/ibex#100 more more information."
else
fail=1
fi
fi
done
exit $fail
displayName: "Run RISC-V Compliance test for Ibex RV32IMC"