diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e3aea75..c343fc9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,21 +1,21 @@ -// For format details, see https://aka.ms/devcontainer.json. { - "name": "labs344", - "context": "..", - "dockerFile": "../containers/labs344/Dockerfile", - "customizations": { - "vscode": { - "settings": {}, - "extensions": [] - } - }, - "initializeCommand": "xhost +local:", + "name": "Labs344", + "image": "ghcr.io/bouncmpe/labs344:latest-devel", "containerEnv": { - "DISPLAY": "${localEnv:DISPLAY}" + "DISPLAY": "${localEnv:DISPLAY}", + "XAUTHORITY": "/tmp/.Xauthority" }, "runArgs": [ - "--env=DISPLAY", - "--mount=type=bind,source=/tmp/.X11-unix,target=/tmp/.X11-unix,consistency=cached" + // "--device=/dev/dri", // Enable GPU acceleration + "--network=host", + "--security-opt=label:type:container_runtime_t" ], - "remoteUser": "bouncmpe" + "mounts": [ + "source=${localEnv:XAUTHORITY},target=/tmp/.Xauthority,type=bind,consistency=cached" + ], + "customizations": { + "vscode": { + "extensions": [] + } + } } diff --git a/.github/workflows/buildah-build-tools.yml b/.github/workflows/buildah-build-tools.yml deleted file mode 100644 index 67a8a68..0000000 --- a/.github/workflows/buildah-build-tools.yml +++ /dev/null @@ -1,138 +0,0 @@ -name: Container Build (Tools) -on: - workflow_dispatch: - inputs: - publish: - description: "Publish to the registry" - required: true - default: true - type: boolean - -env: - REGISTRY: ghcr.io/bouncmpe - IMAGE_NAME: labs344 - LABS344_VERSION: latest - CONTAINERS_ROOT: /home/runner/.local/share/containers - TMPDIR: /home/runner/.local/share/containers/tmp - -permissions: - contents: read - packages: write - -jobs: - buildah-build: - strategy: - fail-fast: false - matrix: - os: [ubuntu-24.04, ubuntu-24.04-arm] - runs-on: ${{ matrix.os }} - concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }} - cancel-in-progress: true - - steps: - - name: Install container tools - run: sudo apt-get install podman buildah jq - - - name: Maximize build space - uses: easimon/maximize-build-space@v10 - with: - root-reserve-mb: 2048 # Reserve disk space for repository - remove-dotnet: "true" - remove-android: "true" - remove-haskell: "true" - remove-codeql: "true" - remove-docker-images: "true" - build-mount-path: ${{ env.CONTAINERS_ROOT }} # The remaining space only for container build - - - run: mkdir -p $TMPDIR - - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Prepare environment variables - run: | - echo "HOSTARCH=$(podman info --format='{{.Host.Arch}}')" >> $GITHUB_ENV - echo "PLATFORM=$(podman info --format='{{.Version.OsArch}}' | sed 's/\//-/g')" >> $GITHUB_ENV - echo "LABS344_VERSION=$(date +'%Y%m%d')" >> $GITHUB_ENV - - - name: Log in to the GitHub Container registry - uses: redhat-actions/podman-login@v1 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build tools container image - id: build-tools - uses: redhat-actions/buildah-build@v2 - with: - image: ${{ env.IMAGE_NAME }} - tags: | - ${{ env.LABS344_VERSION }}-tools - ${{ env.LABS344_VERSION }}-tools-${{ env.HOSTARCH }} - layers: true - oci: true - build-args: | - LABS344_VERSION=${{ env.LABS344_VERSION }} - extra-args: | - --target labs344-tools - containerfiles: | - containers/labs344/Dockerfile - context: containers - - - name: Push to GitHub Container Repository - if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && github.event.inputs.publish - id: push-tools-ghcr - uses: redhat-actions/push-to-registry@v2 - with: - registry: ${{ env.REGISTRY }} - image: ${{ steps.build-tools.outputs.image }} - tags: ${{ env.LABS344_VERSION }}-tools-${{ env.HOSTARCH }} - digestfile: ${{ runner.temp }}/digest-labs344-tools-${{ env.LABS344_VERSION }}-${{ env.PLATFORM }} - - - name: Upload digests - if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && github.event.inputs.publish - uses: actions/upload-artifact@v4 - with: - name: digest-bouncmpe-${{ env.LABS344_VERSION }}-${{ env.PLATFORM }} - path: ${{ runner.temp }}/digest-* - if-no-files-found: error - retention-days: 1 - compression-level: 0 # no compression - - buildah-merge: - name: Merge container images - runs-on: ubuntu-24.04 - needs: buildah-build - if: always() && github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && github.event.inputs.publish - steps: - - name: Download digests - uses: actions/download-artifact@v4 - with: - path: ${{ runner.temp }}/digests - pattern: digest-* - merge-multiple: true - - - name: Prepare environment variables - run: | - echo "LABS344_VERSION=$(date +'%Y%m%d')" >> $GITHUB_ENV - - - name: Log in to the GitHub Container registry - uses: redhat-actions/podman-login@v1 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Create and push manifest list for labs344-tools - run: | - MANIFEST=labs344-tools - FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - buildah manifest create $MANIFEST - for digest in ${{ runner.temp }}/digests/digest-labs344-tools-*; do - echo "Adding $(cat $digest)" - buildah manifest add $MANIFEST $FULL_IMAGE_NAME@$(cat $digest) - done - buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:${{ env.LABS344_VERSION }}-tools - buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:latest-tools diff --git a/.github/workflows/buildah-build-toolchain.yml b/.github/workflows/container-release.yml similarity index 59% rename from .github/workflows/buildah-build-toolchain.yml rename to .github/workflows/container-release.yml index f2acd07..f204d7f 100644 --- a/.github/workflows/buildah-build-toolchain.yml +++ b/.github/workflows/container-release.yml @@ -1,17 +1,24 @@ -name: Container Build (Toolchain) +name: Container Release on: + push: + paths: + - containers/labs344/** + - .github/workflows/container-release.yml # Self-trigger workflow_dispatch: inputs: publish: - description: "Publish to the registry" - required: true - default: true + description: "Publish to the container registry" + required: false + default: false type: boolean env: - REGISTRY: ghcr.io/bouncmpe + REGISTRY: ghcr.io/${{ github.repository_owner }} IMAGE_NAME: labs344 - LABS344_VERSION: latest + HOSTARCH: amd64 + PLATFORM: linux-amd64 + CONTAINER_VERSION: latest + CONTAINER_LATEST_VERSION: latest CONTAINERS_ROOT: /home/runner/.local/share/containers TMPDIR: /home/runner/.local/share/containers/tmp @@ -21,6 +28,7 @@ permissions: jobs: buildah-build: + name: Build container images strategy: fail-fast: false matrix: @@ -29,7 +37,7 @@ jobs: concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }} cancel-in-progress: true - + steps: - name: Install container tools run: sudo apt-get install podman buildah jq @@ -44,17 +52,17 @@ jobs: remove-codeql: "true" remove-docker-images: "true" build-mount-path: ${{ env.CONTAINERS_ROOT }} # The remaining space only for container build - + - run: mkdir -p $TMPDIR - - name: Checkout repository - uses: actions/checkout@v4 - - name: Prepare environment variables run: | echo "HOSTARCH=$(podman info --format='{{.Host.Arch}}')" >> $GITHUB_ENV echo "PLATFORM=$(podman info --format='{{.Version.OsArch}}' | sed 's/\//-/g')" >> $GITHUB_ENV - echo "LABS344_VERSION=$(date +'%Y%m%d')" >> $GITHUB_ENV + echo "CONTAINER_VERSION=$(date +'%Y%m%d')" >> $GITHUB_ENV + + - name: Checkout repository + uses: actions/checkout@v4 - name: Log in to the GitHub Container registry uses: redhat-actions/podman-login@v1 @@ -63,39 +71,38 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build toolchain container image - id: build-toolchain + - name: Build runtime container image + id: build-runtime uses: redhat-actions/buildah-build@v2 with: - image: ${{ env.IMAGE_NAME }} - tags: | - ${{ env.LABS344_VERSION }}-toolchain - ${{ env.LABS344_VERSION }}-toolchain-${{ env.HOSTARCH }} + context: . + image: labs344 + tags: ${{ env.CONTAINER_VERSION }}-runtime ${{ env.CONTAINER_VERSION }}-runtime-${{ env.HOSTARCH }} layers: true oci: true build-args: | - LABS344_VERSION=${{ env.LABS344_VERSION }} + CONTAINER_VERSION=${{ env.CONTAINER_VERSION }} + CONTAINER_IMAGE_REGISTRY_REMOTE=${{ env.REGISTRY }} extra-args: | - --target labs344-toolchain + --target labs344-runtime containerfiles: | - containers/labs344/Dockerfile - context: containers + ./containers/labs344/Dockerfile - name: Push to GitHub Container Repository - if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && github.event.inputs.publish - id: push-toolchain-ghcr + if: github.event_name == 'workflow_dispatch' && github.event.inputs.publish + id: push-runtime-ghcr uses: redhat-actions/push-to-registry@v2 with: registry: ${{ env.REGISTRY }} - image: ${{ steps.build-toolchain.outputs.image }} - tags: ${{ env.LABS344_VERSION }}-toolchain-${{ env.HOSTARCH }} - digestfile: ${{ runner.temp }}/digest-labs344-toolchain-${{ env.LABS344_VERSION }}-${{ env.PLATFORM }} + image: ${{ steps.build-runtime.outputs.image }} + tags: ${{ env.CONTAINER_VERSION }}-runtime-${{ env.HOSTARCH }} + digestfile: ${{ runner.temp }}/digest-labs344-runtime-${{ env.CONTAINER_VERSION }}-${{ env.PLATFORM }} - name: Upload digests - if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && github.event.inputs.publish + if: github.event_name == 'workflow_dispatch' && github.event.inputs.publish uses: actions/upload-artifact@v4 with: - name: digest-bouncmpe-${{ env.LABS344_VERSION }}-${{ env.PLATFORM }} + name: digest-labs344-${{ env.CONTAINER_VERSION }}-${{ env.PLATFORM }} path: ${{ runner.temp }}/digest-* if-no-files-found: error retention-days: 1 @@ -105,7 +112,7 @@ jobs: name: Merge container images runs-on: ubuntu-24.04 needs: buildah-build - if: always() && github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && github.event.inputs.publish + if: always() && github.event_name == 'workflow_dispatch' && github.event.inputs.publish steps: - name: Download digests uses: actions/download-artifact@v4 @@ -114,10 +121,6 @@ jobs: pattern: digest-* merge-multiple: true - - name: Prepare environment variables - run: | - echo "LABS344_VERSION=$(date +'%Y%m%d')" >> $GITHUB_ENV - - name: Log in to the GitHub Container registry uses: redhat-actions/podman-login@v1 with: @@ -125,14 +128,24 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Create and push manifest list for labs344-toolchain + - name: Prepare environment variables + run: | + if [ "${{ env.CONTAINER_VERSION }}" == "latest" ]; then + echo "CONTAINER_VERSION=$(date +'%Y%m%d')" >> $GITHUB_ENV + fi + echo "CONTAINER_LATEST_VERSION=$(date +'%Y%m%d')" >> $GITHUB_ENV + + - name: Create and push manifest list for labs344-runtime run: | - MANIFEST=labs344-toolchain + MANIFEST=labs344-runtime FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} buildah manifest create $MANIFEST - for digest in ${{ runner.temp }}/digests/digest-labs344-toolchain-*; do + for digest in ${{ runner.temp }}/digests/digest-labs344-runtime-*; do echo "Adding $(cat $digest)" buildah manifest add $MANIFEST $FULL_IMAGE_NAME@$(cat $digest) done - buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:${{ env.LABS344_VERSION }}-toolchain - buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:latest-toolchain + buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:${{ env.CONTAINER_VERSION }}-runtime + if [ "${{ env.CONTAINER_VERSION }}" == "${{ env.CONTAINER_LATEST_VERSION }}" ]; then + buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:latest + buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:latest-runtime + fi diff --git a/.gitignore b/.gitignore index 29ade40..4689fba 100644 --- a/.gitignore +++ b/.gitignore @@ -3,16 +3,15 @@ # Ignore the following files *.vcd -*.log -*.hex -*.dis -*.tbl -*.map -snapshots -veer* -verilator* -*.elf -*.exe -obj* -*.o -*.sym +*.log +*.hex +*.dis +*.objdump +*.tbl +*.map +snapshots +*.elf +*.exe +obj* +*.o +*.sym diff --git a/Makefile b/Makefile index 114b95b..71f4860 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,28 @@ -CONTEXT ?= . - -all: build - -toolchain: - podman build \ - -f containers/labs344/Dockerfile \ - --tag bouncmpe/labs344:latest-toolchain \ - --target labs344-toolchain - ${CONTEXT} - -builder: - podman build \ - -f containers/labs344/Dockerfile \ - --tag bouncmpe/labs344:latest-builder \ - --target labs344-builder - ${CONTEXT} - -labs344: - podman build \ - -f containers/labs344/Dockerfile \ - --tag bouncmpe/labs344:latest \ - --target labs344 - ${CONTEXT} - -run: - docker run --rm -it bouncmpe/labs344:latest - -.PHONY: all builder labs344 run \ No newline at end of file +.PHONY: all clean run + +TOOLCHAIN_PREFIX := riscv64-unknown-elf +CC := $(TOOLCHAIN_PREFIX)-gcc + +SRC_DIR := examples/fibonacci +TARGET_DIR := target + +SRC := $(wildcard $(SRC_DIR)/*.s $(SRC_DIR)/*.c) +TARGET_NAME := main + +RV_ARCH := rv64gc +LD_FLAGS := +C_FLAGS := -Wall -Wextra -std=c11 -pedantic -O2 -ffreestanding -nostdlib \ + -mcmodel=medany -march=$(RV_ARCH) + + +all: $(TARGET_DIR)/$(TARGET_NAME) + +$(TARGET_DIR)/$(TARGET_NAME): $(SRC) + mkdir -p $(TARGET_DIR) + $(CC) $(C_FLAGS) $(LD_FLAGS) -o $@ $^ + +clean: + rm -rf $(TARGET_DIR) + +run: all + spike $(TARGET_DIR)/$(TARGET_NAME) diff --git a/containers/Makefile b/containers/Makefile new file mode 100644 index 0000000..a720623 --- /dev/null +++ b/containers/Makefile @@ -0,0 +1,26 @@ +LABS344_CONTAINER_BASE_IMAGE ?= docker.io/almalinux/9-base:9.6 +LABS344_CONTAINER_IMAGE_REGISTRY ?= localhost +LABS344_CONTAINER_IMAGE_REGISTRY_REMOTE ?= ghcr.io/bouncmpe +LABS344_CONTAINER_IMAGE_NAME ?= labs344 +LABS344_CONTAINER_TARGET_VERSION ?= latest +LABS344_CONTAINER_CURRENT_VERSION ?= $(shell date +'%Y%m%d') + +LABS344_CONTAINER_BUILD_CONTEXT ?= . + +info: + @echo "Container version: ${LABS344_CONTAINER_TARGET_VERSION}" + @echo "Container current version: ${LABS344_CONTAINER_CURRENT_VERSION}" + +devel: + buildah build \ + -f labs344/Dockerfile \ + --build-arg LABS344_CONTAINER_BASE_IMAGE=${LABS344_CONTAINER_BASE_IMAGE} \ + --build-arg LABS344_CONTAINER_VERSION=${LABS344_CONTAINER_CURRENT_VERSION} \ + --format oci \ + --layers=true \ + --target labs344-devel \ + --tag ${LABS344_CONTAINER_IMAGE_REGISTRY}/${LABS344_CONTAINER_IMAGE_NAME}:${LABS344_CONTAINER_TARGET_VERSION}-devel \ + --tag ${LABS344_CONTAINER_IMAGE_REGISTRY}/${LABS344_CONTAINER_IMAGE_NAME}:${LABS344_CONTAINER_CURRENT_VERSION}-devel \ + --tag ${LABS344_CONTAINER_IMAGE_REGISTRY_REMOTE}/${LABS344_CONTAINER_IMAGE_NAME}:${LABS344_CONTAINER_TARGET_VERSION}-devel \ + --tag ${LABS344_CONTAINER_IMAGE_REGISTRY_REMOTE}/${LABS344_CONTAINER_IMAGE_NAME}:${LABS344_CONTAINER_CURRENT_VERSION}-devel \ + ${LABS344_CONTAINER_BUILD_CONTEXT} diff --git a/containers/labs344/Dockerfile b/containers/labs344/Dockerfile index cf31479..766ab56 100644 --- a/containers/labs344/Dockerfile +++ b/containers/labs344/Dockerfile @@ -1,195 +1,176 @@ -ARG LABS344_VERSION=latest -ARG LABS344_DEBIAN_VERSION=12 -ARG LABS344_IMAGE_REGISTRY=localhost -ARG LABS344_IMAGE_REGISTRY_REMOTE=${LABS344_IMAGE_REGISTRY} -ARG LABS344_IMAGE_NAME=labs344 -ARG LABS344_IMAGE_NAME_FULL=${LABS344_IMAGE_REGISTRY}/${LABS344_IMAGE_NAME} -ARG LABS344_IMAGE_VERSION=${LABS344_VERSION} -ARG LABS344_BUILDER_IMAGE=${LABS344_IMAGE_NAME_FULL}:${LABS344_IMAGE_VERSION}-builder -ARG LABS344_TOOLCHAIN_IMAGE=${LABS344_IMAGE_NAME_FULL}:${LABS344_IMAGE_VERSION}-toolchain -ARG LABS344_TOOLS_IMAGE=${LABS344_IMAGE_NAME_FULL}:${LABS344_IMAGE_VERSION}-tools - -ARG LABS344_RISCV_GNU_TOOLCHAIN_VERSION=23863c2ca74e6c050f0c97e7af61f5f1776aadd1 - -FROM docker.io/library/debian:${LABS344_DEBIAN_VERSION} AS labs344-toolchain +ARG LABS344_CONTAINER_VERSION=latest +ARG LABS344_CONTAINER_BASE_IMAGE=docker.io/almalinux/10-base:10 + +ARG LABS344_CONTAINER_BUILDER_IMAGE=labs344-builder +ARG LABS344_CONTAINER_DEVEL_IMAGE=labs344-devel + +ARG RISCV_GNU_TOOLCHAIN_VERSION=23863c2ca74e6c050f0c97e7af61f5f1776aadd1 +ARG RISCV_INSTALL_PREFIX=/opt/riscv + +ARG WALLY_VERSION=407c74799bce0968b21551eba72864c2c6ead987 +ARG ELF2HEX_VERSION=f28a3103c06131ed3895052b1341daf4ca0b1c9c +ARG SPIKE_VERSION=4c870d063dbbaeb4dc7007fe5c2a1bf8b00a767e +ARG VERILATOR_VERSION=v5.036 + +FROM ${LABS344_CONTAINER_BASE_IMAGE} as labs344-base +ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT + +RUN dnf install -y dnf-plugins-core && \ + dnf config-manager --set-enabled crb && \ + dnf install -y epel-release && \ + dnf clean all + +RUN dnf install -y \ + dtc \ + mold \ + perl \ + && \ + dnf clean all + +FROM labs344-base as labs344-toolchain ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=${TARGETPLATFORM}/var/cache/apt \ - export DEBIAN_FRONTEND=noninteractive && \ - apt-get update -qq && \ - apt-get install -qy --no-install-recommends \ +ARG RISCV_GNU_TOOLCHAIN_VERSION +ENV RISCV_GNU_TOOLCHAIN_VERSION=${RISCV_GNU_TOOLCHAIN_VERSION} + +ARG RISCV_INSTALL_PREFIX +ENV RISCV_INSTALL_PREFIX=${RISCV_INSTALL_PREFIX} +ENV PATH="${RISCV_INSTALL_PREFIX}/bin:${PATH}" + +RUN dnf install -y \ + git \ autoconf \ automake \ - autotools-dev \ - curl \ python3 \ - python3-pip \ - python3-tomli \ - libmpc-dev \ - libmpfr-dev \ - libgmp-dev \ - gawk \ - build-essential \ + libmpc-devel \ + mpfr-devel \ + gmp-devel \ + gawk \ bison \ flex \ texinfo \ - gperf \ - libtool \ + diffutils \ patchutils \ - bc \ - zlib1g-dev \ - libexpat-dev \ - ninja-build \ - git \ + gcc \ + gcc-c++ \ cmake \ - libglib2.0-dev \ - libslirp-dev \ - && \ - apt-get autoremove -y && rm -rf /var/lib/apt/lists/* - -ARG LABS344_RISCV_GNU_TOOLCHAIN_VERSION -ENV LABS344_RISCV_GNU_TOOLCHAIN_VERSION=${LABS344_RISCV_GNU_TOOLCHAIN_VERSION} -ENV LABS344_RISCV_DIR=/opt/riscv -ENV PATH=${LABS344_RISCV_DIR}/riscv-gnu-toolchain/bin:$PATH - -RUN git clone https://github.com/riscv/riscv-gnu-toolchain /tmp/riscv-gnu-toolchain && \ + ninja-build \ + ccache \ + zlib-devel \ + expat-devel \ + libslirp-devel \ + && dnf clean all + +RUN git clone https://github.com/riscv/riscv-gnu-toolchain.git \ + --no-checkout \ + /tmp/riscv-gnu-toolchain \ + &&\ cd /tmp/riscv-gnu-toolchain && \ - ./configure --prefix=${LABS344_RISCV_DIR} --enable-multilib --with-multilib-generator="rv32e-ilp32e--;rv32i-ilp32--;rv32im-ilp32--;rv32iac-ilp32--;rv32imac-ilp32--;rv32imafc-ilp32f--;rv32imafdc-ilp32d--;rv64i-lp64--;rv64ic-lp64--;rv64iac-lp64--;rv64imac-lp64--;rv64imafdc-lp64d--;rv64im-lp64--;" && \ - make -j$(nproc) && \ - make install && \ + git checkout ${RISCV_GNU_TOOLCHAIN_VERSION} && \ + export CFLAGS='-g0 -DNDEBUG' && \ + export CPPFLAGS='-g0 -DNDEBUG' && \ + ./configure \ + --prefix="${RISCV_INSTALL_PREFIX}" \ + --with-multilib-generator="\ + rv32e-ilp32e--; \ + rv32i-ilp32--; \ + rv32im-ilp32--; \ + rv32iac-ilp32--; \ + rv32imac-ilp32--; \ + rv32imafc-ilp32f--; \ + rv32imafdc-ilp32d--; \ + rv64i-lp64--; \ + rv64ic-lp64--; \ + rv64iac-lp64--; \ + rv64imac-lp64--; \ + rv64imafdc-lp64d--; \ + rv64im-lp64--; \ + "\ + && \ + make -j"$(nproc)" && \ rm -rf /tmp/riscv-gnu-toolchain -FROM ${LABS344_TOOLCHAIN_IMAGE} AS labs344-tools -ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT - -RUN git clone https://github.com/sifive/elf2hex.git /tmp/elf2hex && \ +RUN git clone https://github.com/sifive/elf2hex.git \ + --no-checkout \ + /tmp/elf2hex \ + &&\ cd /tmp/elf2hex && \ - autoreconf -i && \ - ./configure --target=riscv64-unknown-elf --prefix=${LABS344_RISCV_DIR} && \ - make -j$(nproc) && \ + git checkout ${ELF2HEX_VERSION} && \ + export CFLAGS='-g0 -DNDEBUG' && \ + export CPPFLAGS='-g0 -DNDEBUG' && \ + ./configure --prefix="/usr/local" && \ + make -j"$(nproc)" && \ make install && \ rm -rf /tmp/elf2hex -RUN git clone https://github.com/riscv-software-src/riscv-isa-sim /tmp/riscv-isa-sim && \ - mkdir -p /tmp/riscv-isa-sim/build && \ - cd /tmp/riscv-isa-sim/build && \ - ../configure --prefix=${LABS344_RISCV_DIR} && \ - make -j$(nproc) && \ +RUN git clone https://github.com/riscv-software-src/riscv-isa-sim \ + --no-checkout \ + /tmp/riscv-isa-sim \ + &&\ + cd /tmp/riscv-isa-sim && \ + git checkout ${RISCV_ISA_SIM_VERSION} && \ + export CFLAGS='-g0 -DNDEBUG' && \ + export CPPFLAGS='-g0 -DNDEBUG' && \ + ./configure --prefix="/usr/local" && \ + make -j"$(nproc)" && \ make install && \ - && rm -rf /tmp/riscv-isa-sim - -FROM docker.io/library/debian:${LABS344_DEBIAN_VERSION} AS labs344 + rm -rf /tmp/riscv-isa-sim + +RUN git clone https://github.com/verilator/verilator \ + --no-checkout \ + /tmp/verilator \ + &&\ + cd /tmp/verilator && \ + git checkout ${VERILATOR_VERSION} && \ + cmake -S . -B build -G Ninja \ + -DCMAKE_INSTALL_PREFIX=/usr/local \ + -DCMAKE_BUILD_TYPE=Release \ + && \ + cmake --build build -j"$(nproc)" && \ + cmake --install build && \ + rm -rf /tmp/verilator + +FROM labs344-base as labs344-runtime ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT -COPY --from=labs344-tools /opt/riscv /opt/riscv - -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=${TARGETPLATFORM}/var/cache/apt \ - apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get install -qqy --no-install-recommends \ - curl \ - wget \ - git \ - gnupg2 \ - ca-certificates \ - build-essential \ - make \ - cmake \ - ninja-build \ - python3-minimal \ - python3-pip \ - && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* - -FROM ${LABS344_BUILDER_IMAGE} AS labs344-devel -ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT +ARG RISCV_INSTALL_PREFIX +ENV RISCV_INSTALL_PREFIX=${RISCV_INSTALL_PREFIX} -RUN git clone https://github.com/openhwgroup/cvw && \ - cd cvw && \ - git checkout main && \ - git submodule update --init --recursive && \ - export WALLY=$(pwd) && \ - export RISCV=/opt/riscv && \ - export PYTHON_VERSION=python3.11 && \ - bash -c ". $WALLY/bin/wally-environment-check.sh" && \ - bash -c ". $WALLY/bin/wally-package-install.sh" && \ - bash -c ". $WALLY/bin/installation/python-setup.sh" && \ - bash -c ". $WALLY/bin/installation/activate-tools.sh" && \ - # bash -c ". $WALLY/bin/installation/riscv-gnu-toolchain-install.sh" && \ - bash -c ". $WALLY/bin/installation/elf2hex-install.sh" && \ - bash -c ". $WALLY/bin/installation/qemu-install.sh" && \ - bash -c ". $WALLY/bin/installation/spike-install.sh" && \ - # bash -c ". $WALLY/bin/installation/sail-install.sh" && \ - bash -c ". $WALLY/bin/installation/verilator-install.sh" && \ - cd .. && rm -rf cvw - - -# FROM docker.io/verilator/verilator:v5.028 AS labs344 -# ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT - -# # hadolint ignore=DL3008 -# RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=${TARGETPLATFORM}/var/cache/apt \ -# export DEBIAN_FRONTEND=noninteractive && \ -# apt-get update -qq && \ -# apt-get install -qqy --no-install-recommends \ -# sudo \ -# git \ -# wget \ -# gnupg2 \ -# ca-certificates \ -# openssh-client \ -# && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* - -# # hadolint ignore=DL3008 -# RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=${TARGETPLATFORM}/var/cache/apt \ -# export DEBIAN_FRONTEND=noninteractive && \ -# apt-get update -qq && \ -# apt-get install -qqy --no-install-recommends \ -# gcc-riscv64-unknown-elf \ -# binutils-riscv64-unknown-elf \ -# && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* - -# COPY --from=whisper-builder /opt/VeeR-ISS/whisper /usr/local/bin/whisper - -# # hadolint ignore=DL3008 -# RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=${TARGETPLATFORM}/var/cache/apt \ -# export DEBIAN_FRONTEND=noninteractive && \ -# apt-get update -qq && \ -# apt-get install -qqy --no-install-recommends \ -# make \ -# ninja-build \ -# libjson-perl \ -# libbit-vector-perl \ -# python3-minimal \ -# python3-pip \ -# && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* - -# RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=${TARGETPLATFORM}/var/cache/apt \ -# export DEBIAN_FRONTEND=noninteractive && \ -# apt-get update -qq && \ -# apt-get install -qqy --no-install-recommends \ -# gtkwave \ -# dbus-x11 \ -# libgtk-3-0 \ -# pop-gtk-theme \ -# && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* - -# RUN groupadd bouncmpe -g 1000 && \ -# useradd -ms /bin/bash bouncmpe -g bouncmpe -u 1000 && \ -# printf "bouncmpe ALL= NOPASSWD: ALL\\n" >> /etc/sudoers - -# ENV LC_ALL=C.UTF-8 -# ENV LANG=C.UTF-8 -# ENV LANGUAGE=C.UTF-8 -# ENV GTK_THEME=Pop - -# USER bouncmpe -# WORKDIR /home/bouncmpe - -# # hadolint ignore=DL3013 -# RUN python3 -m pip install --no-cache-dir --user meson numpy pandas matplotlib - -# RUN git clone --depth=1 --recurse-submodules --shallow-submodules \ -# https://github.com/chipsalliance/Cores-VeeR-EL2.git /home/bouncmpe/cores/VeerEL2 &&\ -# git clone --depth=1 --recurse-submodules --shallow-submodules \ -# https://github.com/chipsalliance/Cores-VeeR-EH1.git /home/bouncmpe/cores/VeerEH1 - -# ENTRYPOINT ["/bin/bash"] +ARG WALLY_VERSION +ENV WALLY_VERSION=${WALLY_VERSION} + +COPY --from=labs344-toolchain ${RISCV_INSTALL_PREFIX} ${RISCV_INSTALL_PREFIX} +COPY --from=labs344-toolchain /usr/local /usr/local + +ENV WALLY_SOURCE_DIR=/opt/openhwgroup/cvw + +ENV LABS344_HOME=/root +ENV LABS344_SOURCE_DIR=/workspaces/labs344 +ENV LABS344_PYTHON_VENV_DIR=${LABS344_HOME}/.venv/labs344 +ENV LABS344_PYTHON_EXECUTABLE=${LABS344_PYTHON_VENV_DIR}/bin/python + +# Aliases used in Wally scripts +ENV RISCV=${RISCV_INSTALL_PREFIX} +ENV WALLY=${WALLY_SOURCE_DIR} + +RUN dnf install -y \ + git \ + wget \ + vim \ + emacs \ + nano \ + gtkwave \ + && \ + dnf clean all + +RUN git clone https://github.com/openhwgroup/cvw.git \ + --no-checkout \ + ${WALLY_SOURCE_DIR} \ + &&\ + cd ${WALLY_SOURCE_DIR} && \ + git fetch --depth 1 origin ${WALLY_VERSION} && \ + git checkout FETCH_HEAD && \ + git submodule update --init --recursive + +ENV PATH="${RISCV_INSTALL_PREFIX}/bin:${PATH}" +ENV NO_AT_BRIDGE=1 diff --git a/cores/VeerEH1/Makefile b/cores/VeerEH1/Makefile deleted file mode 100644 index cf218a5..0000000 --- a/cores/VeerEH1/Makefile +++ /dev/null @@ -1,123 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Copyright 2020 Western Digital Corporation or its affiliates. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -RV_ROOT = /home/bouncmpe/cores/VeerEH1 -CONF_PARAMS = -set iccm_enable -TEST_CFLAGS = -g -O3 -funroll-all-loops -ABI = -mabi=ilp32 -march=rv32im - -# Allow snapshot override -target = default -snapshot = $(target) - -# Allow tool override -VEER_CONFIG = ${RV_ROOT}/configs/veer.config -IRUN = xrun -VCS = vcs -VERILATOR = verilator -VLOG = qverilog -RIVIERA = riviera -GCC_PREFIX = riscv64-unknown-elf -BUILD_DIR = snapshots/${snapshot} -TBDIR = ${RV_ROOT}/testbench - -# Define default test name -TEST = hello_world - -# Define default test directory -TEST_DIR = /workspaces/labs344/programs -HEX_DIR = $(TBDIR)/hex -ifneq (,$(wildcard $(TBDIR)/tests/$(TEST))) - TEST_DIR = $(TBDIR)/tests/$(TEST) -endif - -# provide specific link file -ifeq (,$(wildcard $(TEST_DIR)/$(TEST).ld)) - LINK = $(TBDIR)/link.ld -else - LINK = $(TEST_DIR)/$(TEST).ld -endif - -OFILES = $(TEST).o - --include $(TEST_DIR)/$(TEST).mki - -VPATH = $(TEST_DIR) $(BUILD_DIR) $(TBDIR) -TBFILES = $(TBDIR)/tb_top.sv $(TBDIR)/ahb_sif.sv - -defines = $(BUILD_DIR)/common_defines.vh ${RV_ROOT}/design/include/veer_types.sv -includes = -I${RV_ROOT}/design/include -I${RV_ROOT}/design/lib -I${BUILD_DIR} - -# Verilator supports only C++14 and newer -CFLAGS += -std=c++17 - -# Optimization for better performance; alternative is nothing for -# slower runtime (faster compiles) -O2 for faster runtime (slower -# compiles), or -O for balance. -VERILATOR_MAKE_FLAGS = OPT_FAST="-O3" - -# Targets -all: clean verilator - -clean: - rm -rf *.log *.s *.hex *.dis *.tbl irun* vcs* simv* *.map snapshots veer* \ - verilator* *.elf obj* *.o ucli.key vc_hdrs.h csrc *.csv \ - work dataset.asdb library.cfg - -# If define files do not exist, then run veer.config. -${BUILD_DIR}/defines.h : - BUILD_PATH=${BUILD_DIR} ${VEER_CONFIG} -target=$(target) $(CONF_PARAMS) - -##################### Verilog Builds ##################################### - -verilator-build: ${TBFILES} ${BUILD_DIR}/defines.h test_tb_top.cpp - echo '`undef ASSERT_ON' >> ${BUILD_DIR}/common_defines.vh - RV_ROOT=${RV_ROOT} $(VERILATOR) --cc -CFLAGS ${CFLAGS} $(defines) $(includes) \ - -Wno-UNOPTFLAT \ - -I${RV_ROOT}/testbench \ - -f ${RV_ROOT}/testbench/flist \ - ${TBFILES} \ - --top-module tb_top -exe test_tb_top.cpp \ - --autoflush --timing --trace --timescale 1ns/100ps - cp ${RV_ROOT}/testbench/test_tb_top.cpp obj_dir - $(MAKE) -j -C obj_dir/ -f Vtb_top.mk $(VERILATOR_MAKE_FLAGS) - touch verilator-build - -##################### Simulation Runs ##################################### - -verilator: program.hex verilator-build - timeout 1s "./obj_dir/Vtb_top" - -##################### Test Build ##################################### - -program.hex: $(OFILES) $(LINK) - @echo Building $(TEST) - $(GCC_PREFIX)-gcc $(ABI) -Wl,-Map=$(TEST).map -T$(LINK) -o $(TEST).elf -nostdlib $(OFILES) $(TEST_LIBS) - $(GCC_PREFIX)-objcopy -O verilog $(TEST).elf program.hex - $(GCC_PREFIX)-objdump -S $(TEST).elf > $(TEST).dis - @echo Completed building $(TEST) - -%.o : %.s ${BUILD_DIR}/defines.h - $(GCC_PREFIX)-cpp -I${BUILD_DIR} $< > $*.cpp.s - $(GCC_PREFIX)-as $(ABI) $*.cpp.s -o $@ - - -%.o : %.c ${BUILD_DIR}/defines.h - $(GCC_PREFIX)-gcc -I${BUILD_DIR} ${TEST_CFLAGS} ${ABI} -nostdlib -c $< -o $@ - -view: - gtkwave sim.vcd -T default_wave.tcl - -.PHONY: clean verilator view \ No newline at end of file diff --git a/cores/VeerEL2/Makefile b/cores/VeerEL2/Makefile deleted file mode 100755 index eb4de0f..0000000 --- a/cores/VeerEL2/Makefile +++ /dev/null @@ -1,149 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# Copyright 2020 Western Digital Corporation or its affiliates. -# Copyright 2024 Antmicro -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -RV_ROOT = /home/bouncmpe/cores/VeerEL2 -TEST_CFLAGS = -g -gdwarf -O3 -funroll-all-loops -ABI = -mabi=ilp32 -LD_ABI = $(ABI) -march=rv32im - -# Allow snapshot override -target = default -snapshot = $(target) - -# Allow tool override -VEER_CONFIG = ${RV_ROOT}/configs/veer.config -VERILATOR = verilator -GCC_PREFIX = riscv64-unknown-elf -BUILD_DIR = snapshots/${snapshot} -TBDIR = ${RV_ROOT}/testbench - -# Override march depending on used GCC version -ifneq ($(shell which $(GCC_PREFIX)-gcc 2> /dev/null),) - GCCVERSIONGT11 := $(shell expr `$(GCC_PREFIX)-gcc -dumpversion | cut -f1 -d.` \>= 11) - ifeq "$(GCCVERSIONGT11)" "1" - CC_ABI = $(ABI) -march=rv32imc_zicsr_zifencei_zba_zbb_zbc_zbs; - else - CC_ABI = $(ABI) -march=rv32im - endif -endif - -VERILATOR_SKIP_WARNINGS = -Wno-IMPLICITSTATIC -Wno-TIMESCALEMOD -Wno-ASCRANGE \ - -Wno-CASEINCOMPLETE -Wno-INITIALDLY -Wno-WIDTH -Wno-UNOPTFLAT - -# Define test name -TEST = hello_world -TEST_DIR = /workspaces/labs344/programs -HEX_DIR = ${TBDIR}/hex -OFILES = $(TEST).o - -ifdef assert - ASSERT_DEFINES = +define+RV_ASSERT_ON -endif - -# provide specific link file -ifeq (,$(wildcard $(TEST_DIR)/$(TEST).ld)) - LINK = $(BUILD_DIR)/link.ld -else - LINK = $(TEST_DIR)/$(TEST).ld -endif - -VPATH = $(TEST_DIR) $(BUILD_DIR) $(TBDIR) - --include $(TEST_DIR)/$(TEST).mki - -# Testbench DPI sources -TB_DPI_SRCS = jtagdpi/jtagdpi.c \ - tcp_server/tcp_server.c - -TB_DPI_INCS := $(addprefix -I$(TBDIR)/,$(dir $(TB_DPI_SRCS))) -# Add testbench include paths -CFLAGS += $(TB_DPI_INCS) - -TB_DPI_SRCS := $(addprefix $(TBDIR)/,$(TB_DPI_SRCS)) - -# Testbench sources -TB_VERILATOR_SRCS = $(TBDIR)/test_tb_top.cpp $(TB_DPI_SRCS) - -TBFILES = $(TBDIR)/tb_top_pkg.sv \ - $(TBDIR)/tb_top.sv \ - $(TBDIR)/ahb_sif.sv \ - $(TBDIR)/jtagdpi/jtagdpi.sv \ - $(TBDIR)/ahb_lite_2to1_mux.sv - -defines = $(BUILD_DIR)/common_defines.vh -defines += ${RV_ROOT}/design/include/el2_def.sv -defines += $(BUILD_DIR)/el2_pdef.vh -includes = -I${BUILD_DIR} -I$(TBDIR)/axi4_mux - -# Verilator supports only C++14 and newer -CFLAGS += -std=c++17 - -# Optimization for better performance; alternative is nothing for -# slower runtime (faster compiles) -O2 for faster runtime (slower -# compiles), or -O for balance. -VERILATOR_MAKE_FLAGS = OPT_FAST="-O3" - -# Targets -all: clean verilator - -clean: - rm -rf *.log *.s *.hex *.dis *.tbl irun* vcs* simv* *.map snapshots veer* \ - verilator* *.elf obj* *.o *.sym ucli.key vc_hdrs.h csrc *.csv work \ - dataset.asdb library.cfg vsimsa.cfg riviera-build wave.asdb - -############ Model Builds ############################### - -# If define files do not exist, then run veer.config. -${BUILD_DIR}/defines.h: - BUILD_PATH=${BUILD_DIR} ${RV_ROOT}/configs/veer.config -target=$(target) $(CONF_PARAMS) - -verilator-build: ${TBFILES} ${BUILD_DIR}/defines.h $(TB_VERILATOR_SRCS) - RV_ROOT=${RV_ROOT} $(VERILATOR) --cc -CFLAGS "${CFLAGS}" $(defines) \ - $(includes) -I${RV_ROOT}/testbench -f ${RV_ROOT}/testbench/flist \ - $(VERILATOR_SKIP_WARNINGS) ${TBFILES} --top-module tb_top \ - -exe $(TB_VERILATOR_SRCS) --autoflush --timing --trace --timescale 1ns/100ps - cp ${RV_ROOT}/testbench/test_tb_top.cpp obj_dir/ - $(MAKE) -e -C obj_dir/ -f Vtb_top.mk $(VERILATOR_MAKE_FLAGS) - touch verilator-build - -############ TEST Simulation ############################### - -verilator: program.hex verilator-build - timeout 1s "./obj_dir/Vtb_top" - -############ TEST build ############################### - -program.hex: $(OFILES) ${BUILD_DIR}/defines.h - @echo Building $(TEST) - $(GCC_PREFIX)-gcc $(LD_ABI) --verbose -Wl,-Map=$(TEST).map -T$(LINK) $(TEST_LIBS) -nostdlib $(OFILES) -o $(TEST).elf - $(GCC_PREFIX)-objcopy -O verilog $(TEST).elf program.hex - $(GCC_PREFIX)-objdump -S $(TEST).elf > $(TEST).dis - $(GCC_PREFIX)-nm -B -n $(TEST).elf > $(TEST).sym - @echo Completed building $(TEST) - -%.o : %.s ${BUILD_DIR}/defines.h - $(GCC_PREFIX)-cpp -I${BUILD_DIR} $< > $*.cpp.s - $(GCC_PREFIX)-as ${CC_ABI} $*.cpp.s -o $@ - -%.o : %.c ${BUILD_DIR}/defines.h - $(GCC_PREFIX)-gcc ${includes} ${TEST_CFLAGS} -DCOMPILER_FLAGS="\"${TEST_CFLAGS}\"" ${CC_ABI} -c $< -o $@ - -view: - gtkwave sim.vcd -T default_wave.tcl - -.PHONY: clean verilator view - diff --git a/cores/VeerEL2/default_wave.tcl b/cores/VeerEL2/default_wave.tcl deleted file mode 100644 index 29023f2..0000000 --- a/cores/VeerEL2/default_wave.tcl +++ /dev/null @@ -1,18 +0,0 @@ -gtkwave::setZoomFactor -12 -gtkwave::setWindowStartTime 0 - -gtkwave::addSignalsFromList core_clk - -gtkwave::addSignalsFromList tb_top.rvtop_wrapper.rvtop.veer.ifu.ifc_fetch_addr_f -gtkwave::addSignalsFromList tb_top.rvtop_wrapper.rvtop.veer.ifu.ifu_fetch_data_f -gtkwave::addSignalsFromList tb_top.rvtop_wrapper.rvtop.veer.dec.dec_i0_instr_d -gtkwave::addSignalsFromList tb_top.rvtop_wrapper.rvtop.veer.dec.decode.i0_inst_x -gtkwave::addSignalsFromList tb_top.rvtop_wrapper.rvtop.veer.dec.decode.i0_inst_r - -# gtkwave::addSignalsFromList tb_top.rvtop_wrapper.rvtop.veer.exu.i_alu.pc_in; # PC input to ALU -# gtkwave::addSignalsFromList tb_top.rvtop_wrapper.rvtop.veer.exu.i_alu.a_in; # First input to ALU -# gtkwave::addSignalsFromList tb_top.rvtop_wrapper.rvtop.veer.exu.i_alu.b_in; # Second input to ALU -# gtkwave::addSignalsFromList tb_top.rvtop_wrapper.rvtop.veer.exu.i_alu.result; # ALU result - -# gtkwave::addSignalsFromList tb_top.rvtop_wrapper.rvtop.veer.exu.exu_flush_final -# gtkwave::addSignalsFromList tb_top.rvtop_wrapper.rvtop.veer.exu.exu_flush_path_final diff --git a/programs/addmul.s b/programs/addmul.s deleted file mode 100644 index a181302..0000000 --- a/programs/addmul.s +++ /dev/null @@ -1,41 +0,0 @@ -#include "defines.h" - -.globl _start -_start: - -# Enable Caches in MRAC -li x1, 0x5f555555 -csrw 0x7c0, x1 - -# Disable Pipeling -# Setting the first bit of the 0x7F9 register to 1 disables the pipeline -# https://github.com/chipsalliance/Cores-VeeR-EL2/blob/main/docs/source/core-control.md -# li t2, 0x001 -# csrrs t1, 0x7F9, t2 - -# Disable Advanced Branch Predictor -# Setting the third bit of the 0x7F9 register to 1 disables the branch predictor -# https://github.com/chipsalliance/Cores-VeeR-EL2/blob/main/docs/source/core-control.md -# li t2, 0x008 -# csrrs t1, 0x7F9, t2 - -li x28, 0x1 -li x29, 0x2 -li x30, 0x4 -li x31, 0x1 - -REPEAT: - nop; - nop; - mul x28, x29, x29 - add x30, x30, x31 - nop; - nop; - nop; - nop; - add x29, x29, 1 - nop; - nop; - nop; - nop; - beq zero, zero, REPEAT # Repeat the loop diff --git a/programs/arithmetic.s b/programs/arithmetic.s deleted file mode 100644 index 936b147..0000000 --- a/programs/arithmetic.s +++ /dev/null @@ -1,23 +0,0 @@ -#include "defines.h" - -.global _start -_start: - -// Clear minstret (Instruction Retired Register) -csrw minstret, zero -csrw minstreth, zero - -// Enable Caches in MRAC -li x1, 0x5f555555 -csrw 0x7c0, x1 - -# Register t3 is also called register 28 (x28) -li t3, 0x0 # t3 = 0 - -REPEAT: - addi t3, t3, 6 # t3 = t3 + 6 - addi t3, t3, -1 # t3 = t3 - 1 - andi t3, t3, 3 # t3 = t3 AND 3 - beq zero, zero, REPEAT # Repeat the loop - -.end \ No newline at end of file