Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump clash-vexriscv to latest version #498

Merged
merged 5 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions bittide/src/Bittide/ProcessingElement.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Clash.Prelude

import Protocols
import Protocols.Wishbone
import VexRiscv (Input(..), Output(..), vexRiscv)
import VexRiscv (CpuIn(..), CpuOut(..), JtagIn(..), vexRiscv)

import Bittide.DoubleBufferedRam
import Bittide.Extra.Maybe
Expand Down Expand Up @@ -91,9 +91,10 @@ rvCircuit tInterrupt sInterrupt eInterrupt = Circuit go
go ((),(iBusIn, dBusIn)) = ((),(iBusOut, dBusOut))
where
tupToCoreIn (timerInterrupt, softwareInterrupt, externalInterrupt, iBusWbS2M, dBusWbS2M) =
Input {..}
CpuIn {..}
rvIn = tupToCoreIn <$> bundle (tInterrupt, sInterrupt, eInterrupt, iBusIn, dBusIn)
rvOut = vexRiscv rvIn
jtagIn = pure (JtagIn 0 0 0)
(rvOut, _jtagOut) = vexRiscv hasClock hasReset rvIn jtagIn

-- The VexRiscv instruction- and data-busses assume a conceptual [Bytes 4] memory
-- while our storages work like [Bytes 1]. This is also why the address width of
Expand Down
82 changes: 82 additions & 0 deletions clash-vexriscv/.github/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# syntax=docker/dockerfile:1.2

# SPDX-FileCopyrightText: 2024 Google LLC

# SPDX-License-Identifier: CC0-1.0

ARG UBUNTU_VERSION
FROM ubuntu:$UBUNTU_VERSION AS builder

LABEL vendor="QBayLogic B.V." maintainer="[email protected]"
ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 LC_ALL=C.UTF-8 PREFIX=/opt

ARG DEPS_COMMON="build-essential ca-certificates curl git locales ca-certificates"

RUN apt-get update \
&& apt-get install -y --no-install-recommends $DEPS_COMMON \
&& locale-gen en_US.UTF-8 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

FROM builder AS build-openocd-vexriscv

ARG DEPS_OPENOCD_VEXRISCV="autoconf automake libtool pkg-config libusb-1.0-0-dev libftdi-dev libhidapi-dev libusb-dev libyaml-dev"

RUN apt-get update \
&& apt-get install -y --no-install-recommends $DEPS_OPENOCD_VEXRISCV \
&& git clone --recursive https://github.com/SpinalHDL/openocd_riscv.git \
&& cd openocd_riscv \
&& ./bootstrap \
&& ./configure --enable-ftdi --enable-dummy --prefix=/opt \
&& make -j$(nproc) \
&& make install

FROM builder AS build-verilator

ARG DEPS_VERILATOR="perl python3 make autoconf g++ flex bison ccache libgoogle-perftools-dev numactl perl-doc libfl2 libfl-dev zlib1g zlib1g-dev help2man"
RUN apt-get update \
&& apt-get install -y --no-install-recommends $DEPS_VERILATOR

ARG verilator_version="v5.020"
RUN git clone https://github.com/verilator/verilator verilator \
&& cd verilator \
&& git checkout $verilator_version \
&& autoconf \
&& ./configure --prefix $PREFIX \
&& make PREFIX=$PREFIX -j$(nproc) \
&& make PREFIX=$PREFIX install \
&& cd ../.. \
&& rm -Rf verilator

FROM builder AS build-ghc

ARG ghcup_version="0.1.22.0"

# Must be explicitly set
ARG ghc_version
ARG cabal_version

RUN curl "https://downloads.haskell.org/~ghcup/$ghcup_version/x86_64-linux-ghcup-$ghcup_version" --output /usr/bin/ghcup \
&& chmod +x /usr/bin/ghcup \
&& ghcup install ghc $ghc_version --set \
&& ghcup install cabal $cabal_version --set

FROM builder AS run

LABEL vendor="QBayLogic B.V." maintainer="[email protected]"
ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 LC_ALL=C.UTF-8 PATH="$PATH:/opt/bin:/root/.ghcup/bin"

ARG DEPS_RUNTIME="gnupg pkg-config openjdk-8-jdk gdb-multiarch picocom libtinfo5 libtinfo-dev build-essential curl libc6-dev libgmp10-dev python3 ccache libftdi1 libhidapi-hidraw0 libusb-1.0-0 libyaml-0-2"
RUN apt-get update \
&& apt-get install -y --no-install-recommends $DEPS_RUNTIME \
&& echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | tee /etc/apt/sources.list.d/sbt.list \
&& echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | tee /etc/apt/sources.list.d/sbt_old.list \
&& curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key add \
&& apt-get update \
&& apt-get install -y --no-install-recommends sbt \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build-verilator /opt /opt
COPY --from=build-openocd-vexriscv /opt /opt
COPY --from=build-ghc /root/.ghcup /root/.ghcup
48 changes: 48 additions & 0 deletions clash-vexriscv/.github/docker/build-and-publish-docker-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2024 Google LLC

# SPDX-License-Identifier: CC0-1.0
set -xeo pipefail

REPO="ghcr.io/clash-lang"
NAME="clash-vexriscv-ci"
DIR=$(dirname "$0")
now=$(date +%Y%m%d)

if [[ "$1" == "-y" ]]; then
push=y
elif [[ "$1" != "" ]]; then
echo "Unrecognized argument: $1" >&2
exit 1
fi

UBUNTU_VERSION=jammy-20240125
GHC_VERSIONS=( "9.4.8" "9.2.8" "9.0.2")
CABAL_VERSIONS=("3.10.2.0" "3.10.2.0" "3.10.2.0")

for i in "${!GHC_VERSIONS[@]}"
do
GHC_VERSION="${GHC_VERSIONS[i]}"
CABAL_VERSION="${CABAL_VERSIONS[i]}"

docker buildx build \
--build-arg UBUNTU_VERSION=${UBUNTU_VERSION} \
--build-arg cabal_version=${CABAL_VERSION} \
--build-arg ghc_version=${GHC_VERSION} \
-t "${REPO}/${NAME}:${GHC_VERSION}-$now" \
"$DIR"
done

if [[ "${push}" == "" ]]; then
read -p "Push to GitHub? (y/N) " push
fi

if [[ $push =~ ^[Yy]$ ]]; then
for i in "${!GHC_VERSIONS[@]}"
do
GHC_VERSION="${GHC_VERSIONS[i]}"
docker push "${REPO}/${NAME}:${GHC_VERSION}-$now"
done
else
echo "Skipping push to container registry"
fi
42 changes: 18 additions & 24 deletions clash-vexriscv/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
run: |
apt-get update
apt-get install -y curl build-essential

- uses: actions-rs/toolchain@v1
with:
toolchain: 1.67 # See Note [Updating Rust versions]
Expand Down Expand Up @@ -69,7 +70,6 @@ jobs:
run: |
apt-get update
apt-get install -y curl build-essential

- uses: actions-rs/toolchain@v1
with:
toolchain: 1.67.1 # See Note [Updating Rust versions]
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
- "9.4.8"

container:
image: ghcr.io/clash-lang/clash-ci:${{ matrix.ghc }}-20240221
image: ghcr.io/clash-lang/clash-vexriscv-ci:${{ matrix.ghc }}-20240329

steps:
- name: Checkout
Expand All @@ -131,28 +131,10 @@ jobs:
uses: actions/cache@v3
with:
path: |
~/.cabal/store
key: packages-cachebust-2-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze', 'cabal.project') }}
restore-keys: packages-cachebust-2-${{ matrix.ghc }}
~/.local/state/cabal/store/
key: packages-cachebust-3-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze', 'cabal.project') }}
restore-keys: packages-cachebust-3-${{ matrix.ghc }}

- name: Install build deps
run: |
apt-get update
apt-get install gnupg pkg-config -y
- name: Install Java
run: |
# install Java 8
apt-get update
apt-get install openjdk-8-jdk -y
update-alternatives --config java
update-alternatives --config javac
- name: Install SBT
run: |
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | tee /etc/apt/sources.list.d/sbt_old.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key add
apt-get update
apt-get install sbt -y
- name: Stash existing VexRiscv.v
run: |
cp clash-vexriscv/example-cpu/VexRiscv.v clash-vexriscv/example-cpu/VexRiscv.v.comitted
Expand All @@ -172,14 +154,26 @@ jobs:
with:
name: vexriscv-test-binaries

- name: Work around dubious owner error
run: |
git config --global --add safe.directory "$(pwd)"

- name: Extract VexRiscv Integration Tests
run: |
tar -x -f vexriscv-test-binaries.tar

- name: OpenOCD bin symlink
run: |
ln -s /opt/bin/openocd /opt/bin/openocd-vexriscv

- name: Run `clash-vexriscv` unittests
run: |
cabal run clash-vexriscv:unittests

- name: Run `clash-vexriscv-sim` unittests
run: |
cabal run clash-vexriscv-sim:unittests
cabal run clash-vexriscv-sim:unittests -- -j2

- name: Run `clash-vexriscv-sim` HDL test
run: |
cabal run clash-vexriscv-sim:hdl-test
6 changes: 6 additions & 0 deletions clash-vexriscv/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ log
vivado_*
tight_setup_hold_pins.txt
.Xil

# Verilator debug output
simulation_dump.vcd

# Clash output
verilog
1 change: 0 additions & 1 deletion clash-vexriscv/cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ packages:
clash-vexriscv-sim/

write-ghc-environment-files: always

tests: True


Expand Down
10 changes: 0 additions & 10 deletions clash-vexriscv/clash-vexriscv-sim/app/Clash.hs

This file was deleted.

19 changes: 4 additions & 15 deletions clash-vexriscv/clash-vexriscv-sim/app/HdlTest.hs
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
-- SPDX-FileCopyrightText: 2023 Google LLC
-- SPDX-FileCopyrightText: 2023-2024 Google LLC
--
-- SPDX-License-Identifier: Apache-2.0

import Clash.Prelude
import Clash.Annotations.TH
import Prelude

import VexRiscv

circuit ::
"CLK" ::: Clock System ->
"RST" ::: Reset System ->
"INPUT" ::: Signal System Input ->
"OUTPUT" ::: Signal System Output
circuit clk rst input =
withClockResetEnable clk rst enableGen vexRiscv input

makeTopEntity 'circuit
import qualified Clash.Main as Clash

main :: IO ()
main = pure ()
main = Clash.defaultMain ["Utils.Instance", "-main-is", "circuit", "--verilog"]
Loading
Loading