Skip to content

Commit

Permalink
Merge branch 'master' into lekcyjna/extend-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
lekcyjna123 authored Dec 3, 2023
2 parents a2c5ee6 + ee90977 commit 7cda7e4
Show file tree
Hide file tree
Showing 24 changed files with 721 additions and 41 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Synthesis benchmarks
runs-on: ubuntu-latest
timeout-minutes: 40
container: ghcr.io/kuznia-rdzeni/amaranth-synth:ecp5-3.11
container: ghcr.io/kuznia-rdzeni/amaranth-synth:ecp5-2023.11.19_v
steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
build-perf-benchmarks:
name: Build performance benchmarks
runs-on: ubuntu-latest
container: ghcr.io/kuznia-rdzeni/riscv-toolchain:2023.10.08_v
container: ghcr.io/kuznia-rdzeni/riscv-toolchain:2023.11.19_v
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -83,7 +83,7 @@ jobs:
name: Run performance benchmarks
runs-on: ubuntu-latest
timeout-minutes: 60
container: ghcr.io/kuznia-rdzeni/verilator:v5.008-3.11
container: ghcr.io/kuznia-rdzeni/verilator:v5.008-2023.11.19_v
needs: build-perf-benchmarks
steps:
- name: Checkout
Expand Down
140 changes: 130 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,130 @@ on:
workflow_dispatch:

jobs:
build-core:
name: Synthesize full core
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Coreblocks dependencies
run: |
python3 -m venv venv
. venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements-dev.txt
- name: Generate Verilog
run: |
. venv/bin/activate
PYTHONHASHSEED=0 ./scripts/gen_verilog.py --verbose --config full
- uses: actions/upload-artifact@v3
with:
name: "verilog-full-core"
path: core.v


build-riscof-tests:
name: Build regression tests (riscv-arch-test)
runs-on: ubuntu-latest
container: ghcr.io/kuznia-rdzeni/riscv-toolchain:2023.11.19_v
timeout-minutes: 10
env:
PYENV_ROOT: "/root/.pyenv"
LC_ALL: "C.UTF8"
LANG: "C.UTF8"
defaults:
run:
working-directory: test/external/riscof/
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup PATH
run: echo "/.pyenv/bin" >> $GITHUB_PATH

- name: Setup pyenv python
run: |
eval "$(pyenv init --path)"
pyenv global 3.6.15
. /venv3.6/bin/activate
- name: Setup arch test suite
run: |
. /venv3.6/bin/activate
riscof --verbose info arch-test --clone
riscof testlist --config=config.ini --suite=riscv-arch-test/riscv-test-suite/ --env=riscv-arch-test/riscv-test-suite/env
- name: Build and run tests on reference and generate Makefiles
run: |
. /venv3.6/bin/activate
riscof run --config=config.ini --suite=riscv-arch-test/riscv-test-suite/ --env=riscv-arch-test/riscv-test-suite/env
- name: Build tests for Coreblocks
run: |
MAKEFILE_PATH=riscof_work/Makefile.build-DUT-coreblocks ../../../ci/riscof_run_makefile.sh
- uses: actions/upload-artifact@v3
with:
name: "riscof-tests"
path: |
test/external/riscof/riscv-arch-test/**/*.elf
test/external/riscof/riscof_work/**/*.signature
test/external/riscof/**/*Makefile*
run-riscof-tests:
name: Run regression tests (riscv-arch-test)
runs-on: ubuntu-latest
container: ghcr.io/kuznia-rdzeni/verilator:v5.008-2023.11.19_v
needs: [ build-riscof-tests, build-core ]
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Coreblocks dependencies
run: |
python3 -m venv venv
. venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements-dev.txt
- uses: actions/download-artifact@v3
with:
name: "verilog-full-core"
path: .

- uses: actions/download-artifact@v3
with:
name: "riscof-tests"
path: test/external/riscof/

- name: Run tests on Coreblocks
run: |
. venv/bin/activate
MAKEFILE_PATH=test/external/riscof/riscof_work/Makefile.run-DUT-coreblocks NPROC=1 ./ci/riscof_run_makefile.sh
- name: Compare signatures (test results)
run: MAKEFILE_PATH=test/external/riscof/riscof_work/Makefile.run-DUT-coreblocks ./ci/riscof_compare.sh


build-regression-tests:
name: Build regression tests
name: Build regression tests (riscv-tests)
runs-on: ubuntu-latest
container: ghcr.io/kuznia-rdzeni/riscv-toolchain:2023.10.08_v
container: ghcr.io/kuznia-rdzeni/riscv-toolchain:2023.11.19_v
outputs:
cache_hit: ${{ steps.cache-regression.outputs.cache-hit }}
steps:
Expand All @@ -31,7 +151,7 @@ jobs:
cache-name: cache-regression-tests
with:
path: test/external/riscv-tests/test-*

key: ${{ env.cache-name }}-${{ runner.os }}-${{ hashFiles(
'**/test/external/riscv-tests/environment/**',
'**/test/external/riscv-tests/Makefile',
Expand All @@ -51,11 +171,11 @@ jobs:
path: test/external/riscv-tests

run-regression-tests:
name: Run regression tests
name: Run regression tests (riscv-tests)
runs-on: ubuntu-latest
timeout-minutes: 10
container: ghcr.io/kuznia-rdzeni/verilator:v5.008-3.11
needs: build-regression-tests
container: ghcr.io/kuznia-rdzeni/verilator:v5.008-2023.11.19_v
needs: [ build-regression-tests, build-core ]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -74,10 +194,10 @@ jobs:
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements-dev.txt
- name: Generate Verilog
run: |
. venv/bin/activate
PYTHONHASHSEED=0 ./scripts/gen_verilog.py --verbose --config full
- uses: actions/download-artifact@v3
with:
name: "verilog-full-core"
path: .

- uses: actions/cache@v3
env:
Expand Down
53 changes: 53 additions & 0 deletions ci/riscof_compare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/sh

if [ -z "$MAKEFILE_PATH" ]; then
echo "Makefile path not specifed. Exiting... "
exit 1
fi

[ ! -z "$DIFF_QUIET" ] && [ "$DIFF_QUIET" -eq 1 ] && diff_add_args="-q"

RED="\033[1;31m"
GREEN="\033[1;32m"
RED_BG="\033[0;41m"
GREEN_BG="\033[0;42m"
NO_COLOR="\033[0m"

signature_files="$(cat $MAKEFILE_PATH | sed -n 's/^.*-o=\(.*\.signature\).*$/\1/p')"

REFERENCE_DIR_SUFF="/../ref/Reference-Spike.signature"

echo "> Veryfing signatures"
target_cnt=0
fail_cnt=0

for sig in $signature_files
do
ref="$(dirname "$sig")$REFERENCE_DIR_SUFF"
echo ">> Comparing $sig (TARGET$target_cnt) to $ref"

diff -b --strip-trailing-cr $diff_add_args "$sig" "$ref"
res=$?

[ -f "$ref" ] || echo -e "${RED}!${NO_COLOR} Reference signature file not found!"
[ -f "$sig" ] || echo -e "${RED}!${NO_COLOR} Coreblocks signature file not found! Check signature run logs"
[ -s "$sig" ] || echo -e "${RED}!${NO_COLOR} Coreblock signature file is empty! Check signature run logs"

if [ $res = 0 ]
then
echo -e "${GREEN}[PASS] Signature verification passed (TARGET$target_cnt)${NO_COLOR}"
else
echo -e "${RED}[FAIL] Signature verification failed (TARGET$target_cnt)${NO_COLOR}"
fail_cnt=$(( $fail_cnt+1 ))
fi

target_cnt=$(( $target_cnt+1 ))
done

rc=1
[ $fail_cnt -eq 0 ] && rc=0

bg=${GREEN_BG}
[ $rc = 1 ] && bg=$RED_BG
echo -e "${bg}>>> Compared $target_cnt signatures, FAILED=$fail_cnt, PASSED=$(($target_cnt-$fail_cnt))${NO_COLOR}"
exit $rc
22 changes: 22 additions & 0 deletions ci/riscof_run_makefile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

if [ -z "$MAKEFILE_PATH" ]; then
echo "Makefile path not specifed. Exiting... "
exit 1
fi

[ -z "$NPROC" ] && NPROC=$(nproc)

target_cnt=$(cat $MAKEFILE_PATH | grep TARGET | tail -n 1 | tr -d -c 0-9)

echo "> Running for $target_cnt Makefile targets"

targets=""

for i in $(seq 0 $target_cnt)
do
targets="$targets TARGET$i"
done

echo "Starting for targets: $targets"
make -f $MAKEFILE_PATH -i -j $NPROC $targets
2 changes: 1 addition & 1 deletion docker/AmaranthSynthECP5.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ubuntu:23.04
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends \
python3.11 python3-pip git yosys lsb-release \
python3.11 python3-pip python3.11-venv git yosys lsb-release \
build-essential cmake python3-dev libboost-all-dev libeigen3-dev && \
rm -rf /var/lib/apt/lists/*

Expand Down
4 changes: 2 additions & 2 deletions docker/Verilator.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ FROM ubuntu:23.04
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends \
python3.11 libpython3.11 python3-pip git lsb-release \
python3.11 libpython3.11 python3-pip python3.11-venv git lsb-release \
perl perl-doc help2man make autoconf g++ flex bison ccache numactl \
libgoogle-perftools-dev libfl-dev zlib1g-dev && \
rm -rf /var/lib/apt/lists/*

RUN git clone --recursive \
RUN git clone --recursive --shallow-since=2023.03.01 \
https://github.com/verilator/verilator.git \
verilator && \
cd verilator && \
Expand Down
32 changes: 28 additions & 4 deletions docker/riscv-toolchain.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,39 @@ FROM ubuntu:23.04
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends \
autoconf automake autotools-dev curl python3 bc lsb-release \
autoconf automake autotools-dev curl python3.11 python3.11-venv python3-pip bc lsb-release \
libmpc-dev libmpfr-dev libgmp-dev gawk build-essential \
bison flex texinfo gperf libtool patchutils zlib1g-dev \
libexpat-dev ninja-build git ca-certificates python-is-python3 && \
bison flex texinfo gperf libtool patchutils zlib1g-dev device-tree-compiler \
libexpat-dev ninja-build git ca-certificates python-is-python3 \
libssl-dev libbz2-dev libreadline-dev libsqlite3-dev libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev && \
rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/riscv/riscv-gnu-toolchain && \
RUN git clone --shallow-since=2023.05.01 https://github.com/riscv/riscv-gnu-toolchain && \
cd riscv-gnu-toolchain && \
git checkout 2023.05.14 && \
./configure --with-multilib-generator="rv32i-ilp32--a*zifence*zicsr;rv32im-ilp32--a*zifence*zicsr;rv32ic-ilp32--a*zifence*zicsr;rv32imc-ilp32--a*zifence*zicsr;rv32imfc-ilp32f--a*zifence;rv32i_zmmul-ilp32--a*zifence*zicsr;rv32ic_zmmul-ilp32--a*zifence*zicsr" && \
make -j$(nproc) && \
cd / && rm -rf riscv-gnu-toolchain

RUN git clone --shallow-since=2023.10.01 https://github.com/riscv-software-src/riscv-isa-sim.git spike && \
cd spike && \
git checkout eeef09ebb894c3bb7e42b7b47aae98792b8eef79 && \
mkdir build/ install/ && \
cd build/ && \
../configure --prefix=/spike/install/ && \
make -j$(nproc) && \
make install && \
cd .. && \
rm -rf build/

RUN git clone --depth=1 https://github.com/pyenv/pyenv.git .pyenv && \
export PATH=/.pyenv/bin:$PATH && \
export PYENV_ROOT=/root/.pyenv && \
eval "$(pyenv init --path)" && \
pyenv install 3.6.15 && \
pyenv global 3.6.15 && \
python -m venv venv3.6 && \
. venv3.6/bin/activate && \
python -m pip install --upgrade pip && \
python -m pip install riscof && \
pyenv global system
2 changes: 1 addition & 1 deletion scripts/run_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def run_with_cocotb(test_name: str, traces: bool, output: str) -> bool:
arglist = [
"make",
"-C",
parent + "/" if parent else "" + "test/regression/cocotb",
(parent + "/" if parent else "") + "test/regression/cocotb",
"-f",
"signature.Makefile",
"--no-print-directory",
Expand Down
11 changes: 11 additions & 0 deletions test/asm/link.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
OUTPUT_ARCH( "riscv" )

start = 0;

SECTIONS
{
.text : { *(.text) }
. = 0x100000000; /* start from 2**32 - trick to emulate Harvard architecture (.bss addresses will start from 0) */
.bss : { *(.bss) }
_end = .;
}
19 changes: 19 additions & 0 deletions test/external/riscof/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[RISCOF]
ReferencePlugin=spike_simple
ReferencePluginPath=./spike_simple
DUTPlugin=coreblocks
DUTPluginPath=./coreblocks

[coreblocks]
pluginpath=./coreblocks
PATH=../../../../
ispec=./coreblocks/coreblocks_isa.yaml
pspec=./coreblocks/coreblocks_platform.yaml
target_run=0

[spike_simple]
pluginpath=./spike_simple
PATH=/spike/install/bin/
ispec=./spike_simple/spike_simple_isa.yaml
pspec=./spike_simple/spike_simple_platform.yaml
compare_run=0
7 changes: 7 additions & 0 deletions test/external/riscof/coreblocks/coreblocks_isa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
hart_ids: [0]
hart0:
ISA: RV32I
physical_addr_sz: 32

User_Spec_Version: '2.3'
supported_xlen: [32]
4 changes: 4 additions & 0 deletions test/external/riscof/coreblocks/coreblocks_platform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
reset:
label: reset_vector
nmi:
label: nmi_vector
Loading

0 comments on commit 7cda7e4

Please sign in to comment.