Skip to content

Explicitly define the one-hot cases for csrng_reg_top and entropy_src_reg_top #131

Explicitly define the one-hot cases for csrng_reg_top and entropy_src_reg_top

Explicitly define the one-hot cases for csrng_reg_top and entropy_src_reg_top #131

# docs: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: Interactive debugging
on:
push:
branches: ["main", "dev-goog", "dev-msft", "dev-public"]
pull_request:
workflow_dispatch:
jobs:
build_verilator:
name:
runs-on: ubuntu-22.04
env:
CARGO_INCREMENTAL: 0
SCCACHE_VERSION: 0.3.3
# TODO: To update to 5.006, clean up lint errors
VERILATOR_VERSION: v5.012
SCCACHE_GHA_CACHE_TO: sccache-verilator-10000
SCCACHE_GHA_CACHE_FROM: sccache-verilator-
# Change this to a new random value if you suspect the cache is corrupted
SCCACHE_C_CUSTOM_CACHE_BUSTER: f3e6951f0c1d
steps:
- name: Restore sccache binary
uses: actions/cache/restore@v3
id: sccache_bin_restore
with:
path: ~/.cargo/bin/sccache
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Install sccache
if: steps.sccache_bin_restore.outputs.cache-hit != 'true'
run: |
cargo install sccache --version ${SCCACHE_VERSION} --no-default-features --features=gha
- name: Save sccache binary
uses: actions/cache/save@v3
if: steps.sccache_bin_restore.outputs.cache-hit != 'true'
with:
path: ~/.cargo/bin/sccache
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Configure sccache
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Restore verilator dir
uses: actions/cache/restore@v3
id: verilator_restore
with:
path: /opt/verilator
key: verilator-${{ env.VERILATOR_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Install verilator
if: steps.verilator_restore.outputs.cache-hit != 'true'
run: |
sudo apt-get install flex bison libfl2 libfl-dev help2man
cd /tmp/
git clone -b "${VERILATOR_VERSION}" https://github.com/verilator/verilator
cd verilator
autoconf
./configure --prefix=/opt/verilator CC="sccache gcc" CXX="sccache g++"
make -j6
sudo make install
- name: Save verilator dir
uses: actions/cache/save@v3
if: steps.verilator_restore.outputs.cache-hit != 'true'
with:
path: /opt/verilator
key: verilator-${{ env.VERILATOR_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Pack Verilator
run: |
cd /opt && tar -czvf verilator.tar.gz verilator/
- name: Store Verilator binaries
uses: actions/upload-artifact@v3
with:
name: verilator
path: /opt/*.tar.gz
retention-days: 1
build_openocd:
name:
runs-on: ubuntu-22.04
env:
CARGO_INCREMENTAL: 0
SCCACHE_VERSION: 0.3.3
# A custom fork is needed to allow bypassing core examination and accessing
# peripherals regardless of core state.
OPENOCD_REPO: https://github.com/antmicro/openocd
OPENOCD_VERSION: riscv-nohalt
SCCACHE_GHA_CACHE_TO: sccache-openocd-10000
SCCACHE_GHA_CACHE_FROM: sccache-openocd-
# Change this to a new random value if you suspect the cache is corrupted
SCCACHE_C_CUSTOM_CACHE_BUSTER: f3e6951f0c1e
steps:
- name: Restore sccache binary
uses: actions/cache/restore@v3
id: sccache_bin_restore
with:
path: ~/.cargo/bin/sccache
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Install sccache
if: steps.sccache_bin_restore.outputs.cache-hit != 'true'
run: |
cargo install sccache --version ${SCCACHE_VERSION} --no-default-features --features=gha
- name: Save sccache binary
uses: actions/cache/save@v3
if: steps.sccache_bin_restore.outputs.cache-hit != 'true'
with:
path: ~/.cargo/bin/sccache
key: sccache-bin-${{ env.SCCACHE_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Configure sccache
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Restore OpenOCD dir
uses: actions/cache/restore@v3
id: openocd_restore
with:
path: /opt/openocd
key: openocd-${{ env.OPENOCD_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Install OpenOCD
if: steps.openocd_restore.outputs.cache-hit != 'true'
run: |
sudo apt-get install make libtool pkg-config autoconf automake texinfo
cd /tmp/
git clone -b "${OPENOCD_VERSION}" https://github.com/antmicro/openocd
cd openocd
./bootstrap
./configure --prefix=/opt/openocd --enable-remote-bitbang \
CC="sccache gcc" CXX="sccache g++" \
CFLAGS="-Wno-error=misleading-indentation -Wno-error=stringop-overflow"
make -j6
sudo make install
- name: Save OpenOCD dir
uses: actions/cache/save@v3
if: steps.openocd_restore.outputs.cache-hit != 'true'
with:
path: /opt/openocd
key: openocd-${{ env.OPENOCD_VERSION }}-${{ env.SCCACHE_C_CUSTOM_CACHE_BUSTER }}
- name: Pack OpenOCD
run: |
cd /opt && tar -czvf openocd.tar.gz openocd/
- name: Store OpenOCD binaries
uses: actions/upload-artifact@v3
with:
name: openocd
path: /opt/*.tar.gz
retention-days: 1
gdb_tests:
name: Run GDB debugging tests
runs-on: ubuntu-22.04
needs: [build_verilator, build_openocd]
env:
CARGO_INCREMENTAL: 0
PKG_CONFIG_PATH: /opt/verilator/share/pkgconfig
DEBIAN_FRONTEND: "noninteractive"
steps:
- name: Install Risc V Toolchain
run: |
# Building from source takes around 6.65 GB of disk and download size
wget -O toolchain.tar.gz https://github.com/stnolting/riscv-gcc-prebuilt/releases/download/rv64imc-3.0.0/riscv64-unknown-elf.gcc-12.1.0.tar.gz
mkdir /opt/riscv
tar -xzf toolchain.tar.gz -C /opt/riscv/
- name: Install dependencies
run: |
# For some reason GDB requires libpython3.8.so
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt update -qy && sudo apt install -qy --no-install-recommends \
libpython3.8
- name: Download Verilator binaries
uses: actions/download-artifact@v3
with:
name: verilator
path: /opt
- name: Download OpenOCD binaries
uses: actions/download-artifact@v3
with:
name: openocd
path: /opt
- name: Unpack binaries
run: |
pushd /opt
tar -zxvf verilator.tar.gz
tar -zxvf openocd.tar.gz
popd
- name: Setup path
run: |
echo /opt/riscv/bin:/opt/verilator/bin:/opt/openocd/bin >> $GITHUB_PATH
- name: Clone repository
uses: actions/checkout@v3
with:
submodules: 'true'
- name: Build Verilated simulation
run: |
export CALIPTRA_ROOT=$(pwd)
mkdir run
make -C run -f ${CALIPTRA_ROOT}/tools/scripts/Makefile verilator-build TESTNAME=infinite_loop DEBUG_UNLOCKED=1 \
OBJCACHE="" CC=gcc CXX=g++ LINK=g++
make -C run -f ${CALIPTRA_ROOT}/tools/scripts/Makefile program.hex TESTNAME=infinite_loop
- name: Test core register access
run: |
export CALIPTRA_ROOT=$(pwd)
cd run
${CALIPTRA_ROOT}/.github/scripts/gdb_test.sh \
/bin/bash -c 'cd ${CALIPTRA_ROOT}/src/integration/test_suites/infinite_loop && ./dump_and_compare.sh'
- name: Test memory access
run: |
export CALIPTRA_ROOT=$(pwd)
cd run
${CALIPTRA_ROOT}/.github/scripts/gdb_test.sh \
/bin/bash -c 'cd ${CALIPTRA_ROOT}/src/integration/test_suites/infinite_loop && ./mem_access.sh'
- name: Test peripheral access
run: |
export CALIPTRA_ROOT=$(pwd)
cd run
${CALIPTRA_ROOT}/.github/scripts/gdb_test.sh \
/bin/bash -c 'cd ${CALIPTRA_ROOT}/src/integration/test_suites/infinite_loop && ./peripheral_access.sh'
openocd_tests:
name: Run OpenOCD debugging tests
runs-on: ubuntu-22.04
needs: [build_verilator, build_openocd]
env:
CARGO_INCREMENTAL: 0
PKG_CONFIG_PATH: /opt/verilator/share/pkgconfig
DEBIAN_FRONTEND: "noninteractive"
steps:
- name: Install Risc V Toolchain
run: |
# Building from source takes around 6.65 GB of disk and download size
wget -O toolchain.tar.gz https://github.com/stnolting/riscv-gcc-prebuilt/releases/download/rv64imc-3.0.0/riscv64-unknown-elf.gcc-12.1.0.tar.gz
mkdir /opt/riscv
tar -xzf toolchain.tar.gz -C /opt/riscv/
- name: Download Verilator binaries
uses: actions/download-artifact@v3
with:
name: verilator
path: /opt
- name: Download OpenOCD binaries
uses: actions/download-artifact@v3
with:
name: openocd
path: /opt
- name: Unpack binaries
run: |
pushd /opt
tar -zxvf verilator.tar.gz
tar -zxvf openocd.tar.gz
popd
- name: Setup path
run: |
echo /opt/riscv/bin:/opt/verilator/bin:/opt/openocd/bin >> $GITHUB_PATH
- name: Clone repository
uses: actions/checkout@v3
with:
submodules: 'true'
- name: Build Verilated simulation
run: |
export CALIPTRA_ROOT=$(pwd)
mkdir run
make -C run -f ${CALIPTRA_ROOT}/tools/scripts/Makefile verilator-build TESTNAME=infinite_loop DEBUG_UNLOCKED=1 FORCE_CPU_RESET=1 \
OBJCACHE="" CC=gcc CXX=g++ LINK=g++
make -C run -f ${CALIPTRA_ROOT}/tools/scripts/Makefile program.hex TESTNAME=infinite_loop
- name: Test peripheral access with core in reset
run: |
export CALIPTRA_ROOT=$(pwd)
cd run
${CALIPTRA_ROOT}/.github/scripts/openocd_test.sh \
-f board/caliptra-verilator-rst.cfg \
-f ${CALIPTRA_ROOT}/src/integration/test_suites/infinite_loop/peripheral_access.tcl