diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..bcbc499f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,123 @@ +# Copyright 2020 ETH Zurich and University of Bologna. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +# Run functional regression checks +name: ci +on: [push, pull_request] +jobs: + + ######## + # Docs # + ######## + + # docs: + # name: Build documentation + # runs-on: ubuntu-22.04 + # container: + # image: ghcr.io/pulp-platform/snitch_cluster + # steps: + # - uses: actions/checkout@v2 + # - name: Build docs + # run: mkdocs build + + ###################################### + # Simulate SW on Occamy w/ Verilator # + ###################################### + + sw-occamy-vlt: + name: Simulate SW on Occamy w/ Verilator + runs-on: ubuntu-22.04 + container: + image: ghcr.io/pulp-platform/snitch_cluster + steps: + - uses: actions/checkout@v2 + with: + submodules: 'recursive' + # - name: Build MUSL dependency + # run: | + # cd sw/deps + # mkdir install + # cd musl + # CC=$LLVM_BINROOT/clang ./configure --disable-shared \ + # --prefix=../install/ --enable-wrapper=all \ + # CFLAGS="-mcpu=snitch -menable-experimental-extensions" + # make -j4 + # make install + # cd ../../../ + - name: Build Software + run: | + make -C target/sim sw + - name: Build Hardware + run: | + make -C target/sim bin/occamy.vlt + # - name: Run Unit Tests + # working-directory: target/sim + # run: |- + # ./sw/tests/run.py sw/tests/passing-apps.list --simulator verilator \ + # 2>&1 | tee tests.log + # - name: Run Test Applications + # working-directory: target/sim + # env: + # SNITCH_LOG: info + # run: |- + # ./sw/apps/run.py sw/apps/passing-apps.list --simulator verilator \ + # 2>&1 | tee apps.log + # - name: Check Unit Tests + # working-directory: target/sim + # run: |- + # grep -zoP 'All tests passed' tests.log + # - name: Check Test Applications + # working-directory: target/sim + # run: |- + # grep -zoP 'All tests passed' apps.log + + ############################################ + # Build SW on Snitch Cluster w/ Banshee # + ############################################ + + # sw-snitch-cluster-banshee: + # name: Simulate SW on Snitch Cluster w/ Banshee + # runs-on: ubuntu-22.04 + # container: + # image: ghcr.io/pulp-platform/snitch_cluster + # steps: + # - uses: actions/checkout@v2 + # with: + # submodules: 'recursive' + # - name: Build MUSL dependency + # run: | + # cd sw/deps + # mkdir install + # cd musl + # CC=$LLVM_BINROOT/clang ./configure --disable-shared \ + # --prefix=../install/ --enable-wrapper=all \ + # CFLAGS="-mcpu=snitch -menable-experimental-extensions" + # make -j4 + # make install + # cd ../../../ + # - name: Build Software + # run: | + # make -C target/snitch_cluster SELECT_RUNTIME=banshee sw + # - name: Run Unit Tests + # working-directory: target/snitch_cluster + # env: + # SNITCH_LOG: info + # run: |- + # ./sw/tests/run.py sw/tests/banshee-apps.list --simulator banshee \ + # 2>&1 | tee tests.log + # - name: Run Test Applications + # working-directory: target/snitch_cluster + # env: + # SNITCH_LOG: info + # run: |- + # ./sw/apps/run.py sw/apps/passing-apps.list --simulator banshee \ + # 2>&1 | tee apps.log + # - name: Check Unit Tests + # working-directory: target/snitch_cluster + # run: |- + # grep -zoP 'All tests passed' tests.log + # - name: Check Test Applications + # working-directory: target/snitch_cluster + # run: |- + # grep -zoP 'All tests passed' apps.log diff --git a/.github/workflows/gitlab-ci.yaml b/.github/workflows/gitlab-ci.yaml new file mode 100644 index 00000000..c2a2649c --- /dev/null +++ b/.github/workflows/gitlab-ci.yaml @@ -0,0 +1,27 @@ +# Copyright 2023 ETH Zurich and University of Bologna. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +# Some CI tests run on our GitLab servers due to licenses and tools +name: gitlab-ci +on: [push, pull_request, workflow_dispatch] +jobs: + gitlab-ci: + name: Internal Gitlab CI + runs-on: ubuntu-22.04 + steps: + - name: Check Gitlab CI + uses: pulp-platform/pulp-actions/gitlab-ci@v2.1.0 + # Skip on forks or pull requests from forks due to missing secrets. + if: + # yamllint disable rule:line-length + github.repository == 'pulp-platform/occamy' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) + # yamllint enable rule:line-length + with: + domain: iis-git.ee.ethz.ch + repo: github-mirror/occamy + token: ${{ secrets.GITLAB_TOKEN }} + poll-period: 20 + poll-count: 1000 + retry-count: 100 + retry-period: 50 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..1be006a2 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,116 @@ +# Copyright 2023 ETH Zurich and University of Bologna. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +# Run all lint checks +name: lint +on: [push, pull_request] + +jobs: + + ################ + # Verible Lint # + ################ + verible-lint: + name: Lint Verilog sources + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: chipsalliance/verible-linter-action@main + with: + paths: | + ./hw + github_token: ${{ secrets.GITHUB_TOKEN }} + fail_on_error: true + reviewdog_reporter: github-check + extra_args: "--waiver_files util/lint/waiver.verible" + verible_version: "v0.0-3318-g8d254167" + + ##################### + # Vendor Up-to-Date # + ##################### + bender-vendor-up-to-date: + name: Check bender vendor up-to-date + runs-on: ubuntu-latest + steps: + - name: Check bender vendor up-to-date + uses: pulp-platform/pulp-actions/bender-vendor-up-to-date@v2.1.0 + + ################# + # Check License # + ################# + license-lint: + name: Check License headers + runs-on: ubuntu-latest + steps: + - name: Check License + uses: pulp-platform/pulp-actions/lint-license@v2.1.0 + with: + patches: 0001-Allow-hash-comments-in-assembly.patch + # We cover ETH Zurich and lowRISC licenses and Apache 2.0 + # (mostly for SW) and Solderpad for the hardware. + # yamllint disable rule:line-length + license: | + Copyright (\d{4}(-\d{4})?\s)?(ETH Zurich and University of Bologna|lowRISC contributors). + (Solderpad Hardware License, Version 0.51|Licensed under the Apache License, Version 2.0), see LICENSE for details. + SPDX-License-Identifier: (SHL-0.51|Apache-2.0) + # yamllint enable rule:line-length + match_regex: true + exclude_paths: | + sw/snRuntime/src/omp/interface.h + + ################## + # Lint YML Files # + ################## + yaml-lint: + name: Lint YAML Sources + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: yaml-lint + uses: ibiqlik/action-yamllint@v3 + with: + config_file: util/lint/.yamllint.yml + + ######################## + # Check Python Sources # + ######################## + python-lint: + runs-on: ubuntu-latest + name: Lint Python Sources + steps: + - name: Check out source repository + uses: actions/checkout@v3 + - name: Set up Python environment + uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: flake8 Lint + uses: py-actions/flake8@v2 + with: + max-line-length: "100" + + ###################### + # Clang-Format Check # + ###################### + # Check C/C++ files for correct formatting. + clangfmt: + name: Lint C/C++ Sources + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: DoozyX/clang-format-lint-action@v0.16.2 + with: + clangFormatVersion: 10 + + ###################### + # Lint Editor Config # + ###################### + # Detect trailing whitespaces, missing new lines and wrong file encodings. + editorconfig-lint: + name: Lint Editorconfig + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: editorconfig-checker/action-editorconfig-checker@main + - run: editorconfig-checker diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..ff5e5e08 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,237 @@ +# Copyright 2022 ETH Zurich and University of Bologna. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +variables: + GIT_STRATEGY: clone + GIT_SUBMODULE_STRATEGY: recursive + PYTHON: /usr/local/anaconda3-2022.05/bin/python3 + BENDER: bender-0.27.1 + CC: gcc-9.2.0 + CXX: g++-9.2.0 + VCS: vcs-2020.12 + VERILATOR: verilator-4.110 + QUESTA: questa-2022.3 + LLVM_BINROOT: /usr/pack/riscv-1.0-kgf/pulp-llvm-0.12.0/bin + CLANG: /usr/pack/riscv-1.0-kgf/pulp-llvm-0.12.0/bin/clang + CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: /usr/pack/gcc-9.2.0-af/linux-x64/bin/gcc + LLVM_SYS_120_PREFIX: /usr/pack/llvm-12.0.1-af + SNITCH_LOG: info + CMAKE: cmake-3.18.1 + VIVADO: vitis-2020.2 vivado + VERIBLE_FMT: $CI_PROJECT_DIR/.local/bin/verible-verilog-format + CVA6_SDK: /usr/scratch2/dolent1/gitlabci/tmp/cva6-sdk + RISCV: ${CVA6_SDK}/install + UBOOT_SPL_BIN: ${CVA6_SDK}/u-boot/spl/u-boot-spl.bin + UBOOT_ITB: ${CVA6_SDK}/u-boot/u-boot.itb + LINUX_UIMAGE: ${CVA6_SDK}/uImage + RISCV_LLVM: /usr/pack/riscv-1.0-kgf/pulp-llvm-0.12.0/bin/ + PATH: $RISCV_LLVM:$CI_PROJECT_DIR/.local/bin:${RISCV}/bin:/home/gitlabci/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/condor/bin:/usr/sepp/bin + +before_script: + # yamllint disable rule:line-length + - > + if ! $CI_PROJECT_DIR/.gitlab-ci.d/memora_retry.sh get python; then + $CI_PROJECT_DIR/.gitlab-ci.d/build-python.sh $CI_PROJECT_DIR + $CI_PROJECT_DIR/.gitlab-ci.d/memora_retry.sh insert python + fi + - ${PYTHON} -m venv .venv + - source .venv/bin/activate + - pip install -r python-requirements.txt + - | + cd $CI_PROJECT_DIR && mkdir -p .local/bin && cd .local/bin + curl --proto '=https' --tlsv1.2 \ + https://pulp-platform.github.io/bender/init -sSf | sh -s -- 0.23.2 + ${BENDER} --version + - | + cd $CI_PROJECT_DIR && mkdir -p .local + curl -L https://github.com/chipsalliance/verible/releases/download/v0.0-3222-gb19cdf44/verible-v0.0-3222-gb19cdf44-CentOS-7.9.2009-Core-x86_64.tar.gz | tar xz -C .local --strip-components=1 + ${VERIBLE_FMT} --version + # yamllint enable rule:line-length +stages: + - build-sw + - snitch-cluster-tests + - verify-snitch-ips + - linux_prepare + - build_fpga + - linux_boot + +# CVA6 SDK +get_toolchain: + stage: linux_prepare + script: + - | + if [[ ! -d ${CVA6_SDK} ]]; then + git clone git@github.com:openhwgroup/cva6-sdk.git $CVA6_SDK + cd $CVA6_SDK && git checkout occamy + git submodule update --init --recursive + fi + - | + if [[ ! -f ${RISCV}/bin/riscv64-unknown-linux-gnu-gcc ]]; then + cd $CVA6_SDK && make all + fi + timeout: 2h 00m +get_linux: + stage: linux_prepare + script: + - | + if [[ ! -f ${UBOOT_ITB} ]]; then + cd $CVA6_SDK && make u-boot/u-boot.itb + fi + - | + if [[ ! -f ${LINUX_UIMAGE} ]]; then + ln -s /home/cykoenig/bin/ld $CI_PROJECT_DIR/.local/bin/ld && hash -r + cd $CVA6_SDK && make uImage LD_LIBRARY_PATH=/home/cykoenig/lib64 + fi + needs: [get_toolchain] + timeout: 2h 00m + +# Packages and elaborates the vivado IPs where occamy is part of. This ensures +# that the occamy xilinx IP can be elaborated +occamy_vivado_ip: + stage: build_fpga + script: + # Make Occamy system smaller to fit on FPGA + - ./.gitlab-ci.d/occamy_cfg_fpga.sh + - make -C hw/system/occamy update-source + # Package IPs and run test elaboration + - make -C hw/system/occamy/fpga/vivado_ips occamy_xilinx EXT_JTAG=0 DEBUG=0 + artifacts: + expire_in: 4 days + paths: + - hw/system/occamy/src + - hw/system/occamy/test + - sw/snRuntime/include/occamy_base_addr.h + +# The occamy on vcu128 design +occamy_vcu128: + stage: build_fpga + rules: + - if: $CI_PIPELINE_SOURCE == "web" + - if: $CI_PIPELINE_SOURCE != "web" + when: manual + changes: + - .gitlab-ci.d/occamy_cfg_fpga.sh + - hw/ip/**/* + - hw/vendor/**/* + - hw/system/occamy/**/* + - util/occamygen.py + - util/clustergen/**/* + - util/solder/**/* + - util/Makefrag + - util/reggen + - util/regtool.py + timeout: 11h 00m + script: + # yamllint disable rule:line-length + - | + if ! $CI_PROJECT_DIR/.gitlab-ci.d/memora_retry.sh --ignore-uncommitted-changes lookup occamy_vcu128; then + make -C hw/system/occamy/fpga occamy_vcu128 EXT_JTAG=0 DEBUG=0 + mkdir -p /usr/scratch2/dolent1/gitlabci/buildcache/snitch/snitch-incremental/ + $CI_PROJECT_DIR/.gitlab-ci.d/memora_retry.sh --ignore-uncommitted-changes insert occamy_vcu128 + fi + # yamllint enable rule:line-length + artifacts: + expire_in: 4 days + paths: [hw/system/occamy/fpga, hw/system/occamy/src] + needs: [get_toolchain, get_linux, occamy_vivado_ip] + +# Boot Linux on the VCU128 FPGA and check for prompt (disabled for now) +occamy_vcu128_fpga: + stage: linux_boot + when: manual + only: + changes: + - .gitlab-ci.d/occamy_cfg_fpga.sh + - .gitlab-ci.d/occamy_fpga_nightly.sh + # Only run if changes were made to anything related to Occamy + - hw/ip/**/* + - hw/vendor/**/* + - hw/system/occamy/**/* + script: + # We need the bitstream, bootrom (tracked in the repo) and linux binaries + - $CI_PROJECT_DIR/.gitlab-ci.d/memora_retry.sh \ + --ignore-uncommitted-changes get occamy_vcu128 + # Todo get linux distrib from hero and flash it + - .gitlab-ci.d/occamy_fpga_nightly.sh + artifacts: + expire_in: 4 days + paths: [console.log] + needs: [occamy_vcu128] + +######################### +# Build Occamy Software # +######################### + +occamy-single-cluster-sw: + # needs: [occamy-sw-musl] + script: + - cd target/snitch_cluster + - make CFG_OVERRIDE=cfg/single-cluster.hjson rtl + - make DEBUG=ON sw + artifacts: + paths: + - target/sim/sw/**/build/*.elf + expire_in: 1 day + +##################################### +# Test Snitch Cluster on IIS system # +##################################### +# Verilator +snitch-cluster-vlt: + # needs: [occamy-single-cluster-sw] + # yamllint disable rule:line-length + script: + - cd target/sim + - $VERILATOR make bin/occamy.vlt + # - $VERILATOR ./sw/tests/run.py sw/tests/passing-apps.list --simulator verilator 2>&1 | tee tests.log + # - $VERILATOR ./sw/apps/run.py sw/apps/passing-apps.list --simulator verilator 2>&1 | tee apps.log + # - grep -zoP 'All tests passed' tests.log + # - grep -zoP 'All tests passed' apps.log + # # yamllint enable rule:line-length + # artifacts: + # when: on_failure + # paths: + # - target/sim/tests.log + # - target/sim/apps.log + # expire_in: 1 day + +# VCS +snitch-cluster-vcs: + # needs: [occamy-single-cluster-sw] + # yamllint disable rule:line-length + script: + - cd target/sim + - make CFG_OVERRIDE=cfg/single-cluster.hjson rtl + - $VCS make bin/occamy.vcs + # - $VCS ./sw/tests/run.py sw/tests/passing-apps.list --simulator vcs 2>&1 | tee tests.log + # - $VCS ./sw/apps/run.py sw/apps/passing-apps.list --simulator vcs 2>&1 | tee apps.log + # - grep -zoP 'All tests passed' tests.log + # - grep -zoP 'All tests passed' apps.log + # # yamllint enable rule:line-length + # artifacts: + # when: on_failure + # paths: + # - target/sim/tests.log + # - target/sim/apps.log + # expire_in: 1 day + +# Questa +snitch-cluster-vsim: + # needs: [occamy-single-cluster-sw] + # yamllint disable rule:line-length + script: + - cd target/sim + - make CFG_OVERRIDE=cfg/single-cluster.hjson rtl + - $QUESTA make bin/occamy.vsim + # - $QUESTA ./sw/tests/run.py sw/tests/passing-apps.list --simulator vsim 2>&1 | tee tests.log + # - $QUESTA ./sw/apps/run.py sw/apps/passing-apps.list --simulator vsim 2>&1 | tee apps.log + # - grep -zoP 'All tests passed' tests.log + # - grep -zoP 'All tests passed' apps.log + # # yamllint enable rule:line-length + # artifacts: + # when: on_failure + # paths: + # - target/sim/tests.log + # - target/sim/apps.log + # expire_in: 1 day