diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bebc407..ccfdb00 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,6 +2,10 @@ name: Deploy Docker Images on: push: + paths: + - 'recipes/Dockerfile.langutils' + - 'recipes/Dockerfile.synthesis' + - 'recipes/Dockerfile.simulation' schedule: - cron: '0 21 * * 5' @@ -24,6 +28,6 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build Docker image for ${{ matrix.name }} - run: docker build -f recipes/${{ matrix.name }} -t ghcr.io/pyfpga/${{ matrix.name }} . + run: docker build -f recipes/Dockerfile.${{ matrix.name }} -t ghcr.io/pyfpga/${{ matrix.name }} . - name: Push Docker image for ${{ matrix.name }} run: docker push ghcr.io/pyfpga/${{ matrix.name }} diff --git a/.gitignore b/.gitignore index 1a06816..09863dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ results +slpp_all diff --git a/README.md b/README.md index 501acaf..75b14d4 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,33 @@ # PyFPGA containers +A collection of Docker containers featuring a curated selection of Free/Libre and Open-Source Software (FLOSS) tools for FPGA development. +They streamline the setup process, ensuring consistency and easy access across diverse environments. +Below is a list of the available containers and their included tools. + * `langutils`: utilities for processing and analyzing HDL languages * [vhd2vl](https://github.com/ldoolitt/vhd2vl) * [Slang](https://github.com/MikePopoloski/slang) * [sv2v](https://github.com/zachjs/sv2v) + * [svlint](https://github.com/dalance/svlint) * [Verible](https://github.com/chipsalliance/verible) * [Surelog](https://github.com/chipsalliance/Surelog) * `synthesis`: tools for logic synthesis * [GHDL](https://github.com/ghdl/ghdl) * [Yosys](https://github.com/YosysHQ/yosys) * [ghdl-yosys-plugin](https://github.com/ghdl/ghdl-yosys-plugin) - * [yosys-slang](https://github.com/povik/yosys-slang) + * [sv-elab](https://github.com/povik/sv-elab) * [synlig](https://github.com/chipsalliance/synlig) * `simulation`: tools for simulation * [GHDL](https://github.com/ghdl/ghdl) * [iVerilog](https://github.com/steveicarus/iverilog) * [Verilator](https://github.com/verilator/verilator) * [cocotb](https://github.com/cocotb/cocotb) + +In the CI pipeline, the Dockerfile is used to build a Docker image, which is then pushed to the GitHub Container Registry. +From there, it can be pulled and run as a container whenever needed. + +```bash +docker run --user $(id -u):$(id -g) --rm -v $PWD:$PWD -w $PWD ghcr.io/pyfpga/ +``` + +Replace `` with the appropriate image name and `` with the command you want to execute inside the container. diff --git a/build.sh b/build.sh index 669fdb4..66bec49 100644 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ #!/bin/bash set -e IMAGE=$1 -docker build -f recipes/$IMAGE -t ghcr.io/pyfpga/$IMAGE . +docker build -f recipes/Dockerfile.$IMAGE --network=host -t ghcr.io/pyfpga/$IMAGE . diff --git a/purge.sh b/purge.sh new file mode 100644 index 0000000..a611ee1 --- /dev/null +++ b/purge.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e +docker rmi -f $(docker images -q) +docker system prune -a --volumes -f diff --git a/recipes/Dockerfile.ghdl b/recipes/Dockerfile.ghdl new file mode 100644 index 0000000..418f50e --- /dev/null +++ b/recipes/Dockerfile.ghdl @@ -0,0 +1,28 @@ +# https://github.com/ghdl/ghdl + +FROM ubuntu:latest AS builder + +WORKDIR /tmp + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + git +RUN apt-get install -y --no-install-recommends \ + build-essential \ + gnat \ + zlib1g-dev + +RUN git clone --depth 1 https://github.com/ghdl/ghdl +RUN mkdir ghdl/build && cd ghdl/build && ../configure --prefix=/usr/local \ + && make -j$(nproc) && make install + +#------------------------------------------------------------------------------ + +FROM ubuntu:latest AS runtime + +COPY --from=builder /usr/local /usr/local + +RUN ldconfig diff --git a/recipes/Dockerfile.iverilog b/recipes/Dockerfile.iverilog new file mode 100644 index 0000000..6cdcfdc --- /dev/null +++ b/recipes/Dockerfile.iverilog @@ -0,0 +1,30 @@ +# https://github.com/steveicarus/iverilog + +FROM ubuntu:latest AS builder + +WORKDIR /tmp + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + git +RUN apt-get install -y --no-install-recommends \ + autoconf \ + bison \ + build-essential \ + flex \ + gperf + +RUN git clone --depth 1 https://github.com/steveicarus/iverilog +RUN cd iverilog && autoconf && ./configure \ + && make -j$(nproc) && make install + +#------------------------------------------------------------------------------ + +FROM ubuntu:latest AS runtime + +COPY --from=builder /usr/local /usr/local + +RUN ldconfig diff --git a/recipes/Dockerfile.langutils b/recipes/Dockerfile.langutils new file mode 100644 index 0000000..a94bb41 --- /dev/null +++ b/recipes/Dockerfile.langutils @@ -0,0 +1,88 @@ +FROM ubuntu:latest AS builder + +WORKDIR /tmp + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + git +RUN apt-get install -y --no-install-recommends \ + bison \ + build-essential \ + cargo \ + cmake \ + curl \ + default-jre \ + flex \ + python3 \ + python3-orderedmultidict + +# +# vhd2vl +# + +RUN git clone --depth 1 https://github.com/ldoolitt/vhd2vl +RUN cd vhd2vl && make -j$(nproc) && make install + +# +# sv2v +# + +RUN curl -sSL https://get.haskellstack.org/ | sh + +RUN git clone --depth 1 https://github.com/zachjs/sv2v.git +RUN cd sv2v && make -j$(nproc) && cp bin/sv2v /usr/local/bin + +# +# Slang +# + +RUN git clone --depth 1 https://github.com/MikePopoloski/slang.git +RUN cd slang && cmake -B build && cmake --build build -j$(nproc) \ + && cmake --install build --strip + +# +# Surelog +# + +RUN git clone --depth 1 https://github.com/alainmarcel/Surelog.git +RUN cd Surelog && git submodule update --init --depth 1 --recursive \ + && cmake -B build \ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/usr/local \ + && cmake --build build -j$(nproc) \ + && cmake --install build --strip + +# +# Verible +# + +RUN curl -fsSL https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \ + -o /usr/local/bin/bazel && chmod +x /usr/local/bin/bazel + +RUN git clone --depth 1 https://github.com/chipsalliance/verible.git +RUN cd verible && bazel build -c opt :install-binaries \ + && .github/bin/simple-install.sh /usr/local/bin + +# +# svlint +# + +RUN cargo install --root /usr/local --git https://github.com/dalance/svlint.git svlint + +# +# clean-up +# + +RUN rm -f /usr/local/bin/stack /usr/local/bin/bazel + +#------------------------------------------------------------------------------ + +FROM ubuntu:latest AS runtime + +COPY --from=builder /usr/local /usr/local + +RUN ldconfig diff --git a/recipes/Dockerfile.simulation b/recipes/Dockerfile.simulation new file mode 100644 index 0000000..a85b8c6 --- /dev/null +++ b/recipes/Dockerfile.simulation @@ -0,0 +1,83 @@ +FROM ubuntu:latest AS builder + +WORKDIR /tmp + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + git +RUN apt-get install -y --no-install-recommends \ + autoconf \ + bison \ + build-essential \ + flex \ + gnat \ + gperf \ + help2man \ + libfl-dev \ + python3 \ + python3-dev \ + python3-pip \ + python3-venv \ + zlib1g-dev + +# +# ghdl +# + +RUN git clone --depth 1 https://github.com/ghdl/ghdl +RUN mkdir ghdl/build && cd ghdl/build && ../configure --prefix=/usr/local \ + && make -j$(nproc) && make install + +# +# iVerilog +# + +RUN git clone --depth 1 https://github.com/steveicarus/iverilog +RUN cd iverilog && autoconf && ./configure \ + && make -j$(nproc) && make install + +# +# Verilator +# + +RUN git clone --depth 1 https://github.com/verilator/verilator +RUN cd verilator && autoconf && ./configure \ + && make -j$(nproc) && make install + +# +# cocotb +# + +# RUN pip install cocotb --break-system-packages + +RUN python3 -m venv /opt/venv && /opt/venv/bin/pip install --no-cache-dir cocotb + +# +# Optimization +# + +RUN strip /usr/local/bin/* 2>/dev/null || true +RUN find /usr/local/lib -name "*.so*" -exec strip --strip-unneeded {} + 2>/dev/null || true + +#------------------------------------------------------------------------------ + +FROM ubuntu:latest AS runtime + +ENV PATH="/opt/venv/bin:$PATH" + +RUN apt-get update -qq && apt-get install -y --no-install-recommends \ + g++ \ + make \ + perl \ + python3 \ + libgnat-14 \ + zlib1g \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=builder /usr/local /usr/local +COPY --from=builder /opt/venv /opt/venv + +RUN ldconfig diff --git a/recipes/Dockerfile.slang b/recipes/Dockerfile.slang new file mode 100644 index 0000000..aa237e8 --- /dev/null +++ b/recipes/Dockerfile.slang @@ -0,0 +1,28 @@ +# https://github.com/MikePopoloski/slang + +FROM ubuntu:latest AS builder + +WORKDIR /tmp + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + git +RUN apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + python3 + +RUN git clone --depth 1 https://github.com/MikePopoloski/slang.git +RUN cd slang && cmake -B build && cmake --build build -j$(nproc) \ + && cmake --install build --strip + +#------------------------------------------------------------------------------ + +FROM ubuntu:latest AS runtime + +COPY --from=builder /usr/local /usr/local + +RUN ldconfig diff --git a/recipes/Dockerfile.surelog b/recipes/Dockerfile.surelog new file mode 100644 index 0000000..123bc71 --- /dev/null +++ b/recipes/Dockerfile.surelog @@ -0,0 +1,35 @@ +# https://github.com/chipsalliance/Surelog + +FROM ubuntu:latest AS builder + +WORKDIR /tmp + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + git +RUN apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + default-jre \ + python3 \ + python3-orderedmultidict + +RUN git clone --depth 1 https://github.com/alainmarcel/Surelog.git +RUN cd Surelog && git submodule update --init --depth 1 --recursive \ + && cmake -B build \ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/usr/local \ + && cmake --build build -j$(nproc) \ + && cmake --install build --strip + +#------------------------------------------------------------------------------ + +FROM ubuntu:latest AS runtime + +COPY --from=builder /usr/local /usr/local + +RUN ldconfig diff --git a/recipes/Dockerfile.sv2v b/recipes/Dockerfile.sv2v new file mode 100644 index 0000000..3525752 --- /dev/null +++ b/recipes/Dockerfile.sv2v @@ -0,0 +1,29 @@ +# https://github.com/zachjs/sv2v + +FROM ubuntu:latest AS builder + +WORKDIR /tmp + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + git +RUN apt-get install -y --no-install-recommends \ + curl + +RUN curl -sSL https://get.haskellstack.org/ | sh + +RUN git clone --depth 1 https://github.com/zachjs/sv2v.git +RUN cd sv2v && make -j$(nproc) && cp bin/sv2v /usr/local/bin + +RUN rm -f /usr/local/bin/stack + +#------------------------------------------------------------------------------ + +FROM ubuntu:latest AS runtime + +COPY --from=builder /usr/local /usr/local + +RUN ldconfig diff --git a/recipes/Dockerfile.svlint b/recipes/Dockerfile.svlint new file mode 100644 index 0000000..ce0a726 --- /dev/null +++ b/recipes/Dockerfile.svlint @@ -0,0 +1,24 @@ +# https://github.com/dalance/svlint + +FROM ubuntu:latest AS builder + +WORKDIR /tmp + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + git +RUN apt-get install -y --no-install-recommends \ + cargo + +RUN cargo install --root /usr/local --git https://github.com/dalance/svlint.git svlint + +#------------------------------------------------------------------------------ + +FROM ubuntu:latest AS runtime + +COPY --from=builder /usr/local /usr/local + +RUN ldconfig diff --git a/recipes/Dockerfile.synlig b/recipes/Dockerfile.synlig new file mode 100644 index 0000000..af58541 --- /dev/null +++ b/recipes/Dockerfile.synlig @@ -0,0 +1,38 @@ +# https://github.com/chipsalliance/synlig + +FROM ubuntu:latest AS builder + +WORKDIR /tmp + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + git +RUN apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + default-jre \ + libffi-dev \ + libreadline-dev \ + python3 \ + python3-orderedmultidict \ + tcl-dev +RUN apt-get install -y --no-install-recommends bison flex pkg-config + +RUN git clone --depth 1 https://github.com/chipsalliance/synlig +RUN cd synlig \ + && git submodule update --init --depth 1 --recursive third_party/surelog \ + && git submodule update --init --depth 1 --recursive third_party/yosys \ + && find third_party -name "CMakeLists.txt" -exec sed -i -E 's/cmake_minimum_required\s*\([^)]+\)/cmake_minimum_required(VERSION 3.5)/gI' {} + \ + && sed -i '1s/^/#include \n/' third_party/yosys/libs/json11/json11.cpp \ + && make install -j$(nproc) + +#------------------------------------------------------------------------------ + +FROM ubuntu:latest AS runtime + +COPY --from=builder /usr/local /usr/local + +RUN ldconfig diff --git a/recipes/Dockerfile.synthesis b/recipes/Dockerfile.synthesis new file mode 100644 index 0000000..97f3cfa --- /dev/null +++ b/recipes/Dockerfile.synthesis @@ -0,0 +1,76 @@ +FROM ubuntu:latest AS builder + +WORKDIR /tmp + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + git +RUN apt-get install -y --no-install-recommends \ + bison \ + build-essential \ + cmake \ + default-jre \ + flex \ + gnat \ + libffi-dev \ + libreadline-dev \ + pkg-config \ + python3-orderedmultidict \ + tcl-dev \ + zlib1g-dev + +# +# GHDL +# + +RUN git clone --depth 1 https://github.com/ghdl/ghdl +RUN mkdir ghdl/build && cd ghdl/build && ../configure --prefix=/usr/local \ + && make -j$(nproc) && make install + +# +# Yosys +# + +RUN git clone --depth 1 https://github.com/YosysHQ/yosys +RUN cd yosys && git submodule update --init --depth 1 \ + && cmake -B build . -DCMAKE_BUILD_TYPE=Release \ + && cmake --build build --config Release -j$(nproc) \ + && cmake --install build --strip + +# +# ghdl-yosys-plugin +# + +RUN git clone --depth 1 https://github.com/ghdl/ghdl-yosys-plugin +RUN cd ghdl-yosys-plugin && git submodule update --init --depth 1 \ + && make -j$(nproc) && make install + +# +# Synlig +# + +RUN git clone --depth 1 https://github.com/chipsalliance/synlig +RUN cd synlig \ + && git submodule update --init --depth 1 --recursive third_party/surelog \ + && git submodule update --init --depth 1 --recursive third_party/yosys \ + && find third_party -name "CMakeLists.txt" -exec sed -i -E 's/cmake_minimum_required\s*\([^)]+\)/cmake_minimum_required(VERSION 3.5)/gI' {} + \ + && sed -i '1s/^/#include \n/' third_party/yosys/libs/json11/json11.cpp \ + && make install -j$(nproc) + +#------------------------------------------------------------------------------ + +FROM ubuntu:latest AS runtime + +RUN apt-get update -qq && apt-get install -y --no-install-recommends \ + libffi-dev \ + tcl-dev \ + libgnat-14 \ + libreadline-dev \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=builder /usr/local /usr/local + +RUN ldconfig diff --git a/recipes/Dockerfile.verible b/recipes/Dockerfile.verible new file mode 100644 index 0000000..dcd5766 --- /dev/null +++ b/recipes/Dockerfile.verible @@ -0,0 +1,32 @@ +# https://github.com/chipsalliance/verible + +FROM ubuntu:latest AS builder + +WORKDIR /tmp + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + git +RUN apt-get install -y --no-install-recommends \ + build-essential \ + curl + +RUN curl -fsSL https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 \ + -o /usr/local/bin/bazel && chmod +x /usr/local/bin/bazel + +RUN git clone --depth 1 https://github.com/chipsalliance/verible.git +RUN cd verible && bazel build -c opt :install-binaries \ + && .github/bin/simple-install.sh /usr/local/bin + +RUN rm -f /usr/local/bin/bazel + +#------------------------------------------------------------------------------ + +FROM ubuntu:latest AS runtime + +COPY --from=builder /usr/local /usr/local + +RUN ldconfig diff --git a/recipes/Dockerfile.verilator b/recipes/Dockerfile.verilator new file mode 100644 index 0000000..a06f006 --- /dev/null +++ b/recipes/Dockerfile.verilator @@ -0,0 +1,32 @@ +# https://github.com/verilator/verilator + +FROM ubuntu:latest AS builder + +WORKDIR /tmp + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + git +RUN apt-get install -y --no-install-recommends \ + autoconf \ + bison \ + build-essential \ + flex \ + help2man \ + libfl-dev \ + python3 + +RUN git clone --depth 1 https://github.com/verilator/verilator +RUN cd verilator && autoconf && ./configure \ + && make -j$(nproc) && make install + +#------------------------------------------------------------------------------ + +FROM ubuntu:latest AS runtime + +COPY --from=builder /usr/local /usr/local + +RUN ldconfig diff --git a/recipes/Dockerfile.vhd2vl b/recipes/Dockerfile.vhd2vl new file mode 100644 index 0000000..f3a955b --- /dev/null +++ b/recipes/Dockerfile.vhd2vl @@ -0,0 +1,27 @@ +# https://github.com/ldoolitt/vhd2vl + +FROM ubuntu:latest AS builder + +WORKDIR /tmp + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + git +RUN apt-get install -y --no-install-recommends \ + bison \ + build-essential \ + flex + +RUN git clone --depth 1 https://github.com/ldoolitt/vhd2vl +RUN cd vhd2vl && make -j$(nproc) && make install + +#------------------------------------------------------------------------------ + +FROM ubuntu:latest AS runtime + +COPY --from=builder /usr/local /usr/local + +RUN ldconfig diff --git a/recipes/Dockerfile.yosys b/recipes/Dockerfile.yosys new file mode 100644 index 0000000..01eb070 --- /dev/null +++ b/recipes/Dockerfile.yosys @@ -0,0 +1,42 @@ +# https://github.com/yosyshq/yosys + +FROM ubuntu:latest AS builder + +WORKDIR /tmp + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -qq +RUN apt-get install -y --no-install-recommends \ + ca-certificates \ + git +RUN apt-get install -y --no-install-recommends \ + bison \ + build-essential \ + cmake \ + flex \ + gnat \ + python3 \ + zlib1g-dev + +RUN git clone --depth 1 https://github.com/ghdl/ghdl +RUN mkdir ghdl/build && cd ghdl/build && ../configure --prefix=/usr/local \ + && make -j$(nproc) && make install + +RUN git clone --depth 1 https://github.com/YosysHQ/yosys +RUN cd yosys && git submodule update --init --depth 1 \ + && cmake -B build . -DCMAKE_BUILD_TYPE=Release \ + && cmake --build build --config Release -j$(nproc) \ + && cmake --install build --strip + +RUN git clone --depth 1 https://github.com/ghdl/ghdl-yosys-plugin +RUN cd ghdl-yosys-plugin && git submodule update --init --depth 1 \ + && make -j$(nproc) && make install + +#------------------------------------------------------------------------------ + +FROM ubuntu:latest AS runtime + +COPY --from=builder /usr/local /usr/local/bin + +RUN ldconfig diff --git a/recipes/langutils b/recipes/langutils deleted file mode 100644 index 1e13c63..0000000 --- a/recipes/langutils +++ /dev/null @@ -1,84 +0,0 @@ -FROM ubuntu:latest AS build - -WORKDIR /root - -# -# Dependencies -# - -RUN apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - # Common - build-essential \ - ca-certificates \ - curl \ - git \ - python3 \ - zlib1g-dev \ - # vhd2vl - flex \ - bison \ - # Surelog - cmake \ - default-jre \ - python3-orderedmultidict \ - && curl -sSL https://get.haskellstack.org/ | sh \ - && curl -sSL https://github.com/bazelbuild/bazel/releases/download/6.5.0/bazel-6.5.0-linux-x86_64 \ - -o /usr/bin/bazel && chmod +x /usr/bin/bazel \ - && apt-get autoclean && apt-get clean && apt-get -y autoremove \ - && rm -rf /var/lib/apt/lists/* - -# -# vhd2vl -# - -RUN git clone --depth 1 https://github.com/ldoolitt/vhd2vl \ - && cd vhd2vl && make -j$(nproc) && make install - -# -# Slang -# - -RUN git clone --depth 1 https://github.com/MikePopoloski/slang.git \ - && cd slang && cmake -B build && cmake --build build -j8 \ - && cmake --install build --strip - -# -# Surelog -# - -RUN git clone --depth 1 https://github.com/alainmarcel/Surelog.git \ - && cd Surelog && git submodule update --init --recursive \ - && make -j$(nproc) && make install - -# -# sv2v -# - -RUN git clone --depth 1 https://github.com/zachjs/sv2v.git \ - && cd sv2v && make -j$(nproc) && cp bin/sv2v /usr/local/bin - -# -# Verible -# - -RUN git clone --depth 1 https://github.com/chipsalliance/verible.git \ - && cd verible && bazel build -c opt :install-binaries \ - && .github/bin/simple-install.sh /usr/local/bin - -# -# Clean-up -# - -RUN cd /usr/local/bin && rm stack - -############################################################################### - -FROM ubuntu:latest - -COPY --from=build /usr/local/bin /usr/local/bin -COPY --from=build /usr/local/lib /usr/local/lib -COPY --from=build /usr/local/include /usr/local/include -COPY --from=build /usr/local/share/pkgconfig /usr/local/share/pkgconfig -COPY --from=build /usr/local/share/surelog /usr/local/share/surelog -COPY --from=build /usr/local/share/uhdm /usr/local/share/uhdm diff --git a/recipes/simulation b/recipes/simulation deleted file mode 100644 index 15378d1..0000000 --- a/recipes/simulation +++ /dev/null @@ -1,75 +0,0 @@ -FROM ubuntu:latest AS build - -WORKDIR /root - -# -# Dependencies -# - -RUN apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - # Common - build-essential \ - ca-certificates \ - git \ - python3 \ - zlib1g-dev \ - # GHDL - gnat \ - # iVerilog & Verilator - autoconf \ - bison \ - flex \ - gperf \ - # Verilator - help2man \ - libfl2 \ - libfl-dev \ - zlib1g \ - ccache \ - mold \ - # cocotb - python3-pip \ - libpython3-dev \ - libgoogle-perftools-dev numactl \ - && apt-get autoclean && apt-get clean && apt-get -y autoremove \ - && rm -rf /var/lib/apt/lists/* - -# -# GHDL -# - -RUN git clone --depth 1 https://github.com/ghdl/ghdl \ - && mkdir ghdl/build && cd ghdl/build \ - && ../configure --prefix=/usr/local \ - && make -j$(nproc) && make install - -# -# iVerilog -# - -RUN git clone --depth 1 https://github.com/steveicarus/iverilog \ - && cd iverilog && autoconf && ./configure \ - && make -j$(nproc) && make install - -# -# Verilator -# - -RUN git clone --depth 1 https://github.com/verilator/verilator \ - && cd verilator && autoconf && ./configure \ - && make -j$(nproc) && make install - -# -# cocotb -# - -RUN pip install cocotb --break-system-packages - -# -# Clean-up -# - -############################################################################### - -# FROM ubuntu:latest diff --git a/recipes/synthesis b/recipes/synthesis deleted file mode 100644 index acae36a..0000000 --- a/recipes/synthesis +++ /dev/null @@ -1,98 +0,0 @@ -FROM ubuntu:latest AS build - -WORKDIR /root - -# -# Dependencies -# - -RUN apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - # Common - build-essential \ - ca-certificates \ - git \ - zlib1g-dev \ - # GHDL - gnat \ - # Yosys - clang \ - bison \ - flex \ - libreadline-dev \ - tcl-dev \ - libffi-dev \ - pkg-config \ - python3 \ - # Synlig - cmake \ - default-jre \ - python3-orderedmultidict \ - && apt-get autoclean && apt-get clean && apt-get -y autoremove \ - && rm -rf /var/lib/apt/lists/* - -# -# GHDL -# - -RUN git clone --depth 1 https://github.com/ghdl/ghdl \ - && mkdir ghdl/build && cd ghdl/build \ - && ../configure --prefix=/usr/local \ - && make -j$(nproc) && make install - -# -# Yosys -# - -RUN git clone --depth 1 https://github.com/YosysHQ/yosys \ - && cd yosys && git submodule update --init \ - && make -j$(nproc) && make install - -# -# ghdl-yosys-plugin -# - -RUN git clone --depth 1 https://github.com/ghdl/ghdl-yosys-plugin \ - && cd ghdl-yosys-plugin && git submodule update --init \ - && make -j$(nproc) && make install - -# -# yosys-slang -# - -RUN git clone --recursive https://github.com/povik/yosys-slang \ - && cd yosys-slang && make -j$(nproc) && make install - -# -# Synlig -# - -RUN git clone --depth 1 https://github.com/chipsalliance/synlig && cd synlig \ - && git submodule update --init --depth 1 --recursive third_party/surelog \ - && git submodule update --init --depth 1 --recursive third_party/yosys \ - && make install -j$(nproc) - -# -# Clean-up -# - -RUN cd /usr/local/lib && rm -fr libghdlvpi.so libghw.so python3.* \ - && cd /usr/local/bin && rm ghwdump yosys-filterlib yosys-smtbmc yosys-witness - -############################################################################### - -FROM ubuntu:latest - -RUN apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - gnat \ - libreadline-dev \ - tcl-dev \ - && apt-get autoclean && apt-get clean && apt-get -y autoremove \ - && rm -rf /var/lib/apt/lists/* - -COPY --from=build /usr/local/bin /usr/local/bin -COPY --from=build /usr/local/lib /usr/local/lib -COPY --from=build /usr/local/include/ghdl /usr/local/include/ghdl -COPY --from=build /usr/local/share/yosys /usr/local/share/yosys -COPY --from=build /usr/local/share/synlig /usr/local/share/synlig diff --git a/sanity.sh b/sanity.sh new file mode 100644 index 0000000..9dbdb17 --- /dev/null +++ b/sanity.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +for dockerfile in "recipes"/Dockerfile.*; do + name="${dockerfile##*Dockerfile.}" + echo "Processing target: ${name}" + bash build.sh "${name}" +done + +cd tests +bash langutils.sh +bash simulation.sh +bash synthesis.sh +bash checklibs.sh diff --git a/tests/.svlint.toml b/tests/.svlint.toml new file mode 100644 index 0000000..0430690 --- /dev/null +++ b/tests/.svlint.toml @@ -0,0 +1,244 @@ +[option] +exclude_paths = [] +textwidth = 80 +copyright_linenum = 1 +copyright_year = "1234" +copyright_holder = "HOLDER" +indent = 2 +prefix_inout = "b_" +prefix_input = "i_" +prefix_output = "o_" +prefix_label = "l_" +prefix_instance = "u_" +prefix_module = "mod_" +prefix_package = "pkg_" +prefix_interface = "ifc_" +re_required_assert = "^[a-z]+[a-z0-9_]*$" +re_required_assert_property = "^[a-z]+[a-z0-9_]*$" +re_required_checker = "^[a-z]+[a-z0-9_]*$" +re_required_class = "^[a-z]+[a-z0-9_]*$" +re_required_function = "^[a-z]+[a-z0-9_]*$" +re_required_generateblock = "^[a-z]+[a-z0-9_]*$" +re_required_genvar = "^[a-z]+[a-z0-9_]*$" +re_required_instance = "^[a-z]+[a-z0-9_]*$" +re_required_interface = "^[a-z]+[a-z0-9_]*$" +re_required_localparam = "^[A-Z]+[A-Z0-9_]*$" +re_required_modport = "^[a-z]+[a-z0-9_]*$" +re_required_module_ansi = "^[a-z]+[a-zA-Z0-9_]*$" +re_required_module_nonansi = "^[A-Z]+[A-Z0-9_]*$" +re_required_package = "^[a-z]+[a-z0-9_]*$" +re_required_parameter = "^[A-Z]+[A-Z0-9_]*$" +re_required_port_inout = "^[a-z]+[a-z0-9_]*$" +re_required_port_input = "^[a-z]+[a-z0-9_]*$" +re_required_port_output = "^[a-z]+[a-z0-9_]*$" +re_required_port_ref = "^[a-z]+[a-z0-9_]*$" +re_required_port_interface = "^[a-z]+[a-z0-9_]*$" +re_required_program = "^[a-z]+[a-z0-9_]*$" +re_required_property = "^[a-z]+[a-z0-9_]*$" +re_required_sequence = "^[a-z]+[a-z0-9_]*$" +re_required_task = "^[a-z]+[a-z0-9_]*$" +re_required_var_class = "^[a-z]+[a-z0-9_]*$" +re_required_var_classmethod = "^[a-z]+[a-z0-9_]*$" +re_forbidden_assert = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_assert_property = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_checker = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_class = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_function = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_generateblock = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_genvar = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_instance = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_interface = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_localparam = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_modport = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_module_ansi = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_module_nonansi = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_package = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_parameter = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_port_inout = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_port_input = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_port_output = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_port_ref = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_port_interface = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_program = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_property = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_sequence = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_task = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_var_class = "^[^X](UNCONFIGURED|.*)$" +re_forbidden_var_classmethod = "^[^X](UNCONFIGURED|.*)$" + +[option.unpacked_array] +localparam_declaration = false +param_declaration = false +specparam_declaration = false +inout_declaration = false +ansi_port_declaration = false +input_declaration = false +output_declaration = false +interface_port_declaration = false +ref_declaration = false +data_declaration = true +net_declaration = false + +[textrules] +header_copyright = false +style_directives = false +style_semicolon = false +style_textwidth = false + +[syntaxrules] +action_block_with_side_effect = false +blocking_assignment_in_always_at_edge = false +blocking_assignment_in_always_ff = false +blocking_assignment_in_always_latch = false +case_default = false +default_nettype_none = false +default_nettype_wire_at_end = false +enum_with_type = false +eventlist_comma_always_ff = false +eventlist_or = false +explicit_brackets_for_confusing_precedence = false +explicit_case_default = false +explicit_if_else = false +function_same_as_system_function = false +function_with_automatic = false +general_always_level_sensitive = false +general_always_no_edge = false +generate_case_with_label = false +generate_for_with_label = false +generate_if_with_label = false +genvar_declaration_in_loop = false +genvar_declaration_out_loop = false +implicit_case_default = false +inout_with_tri = false +input_with_var = false +interface_identifier_matches_filename = false +interface_port_with_modport = false +keyword_forbidden_always = false +keyword_forbidden_always_comb = false +keyword_forbidden_always_ff = false +keyword_forbidden_always_latch = false +keyword_forbidden_generate = false +keyword_forbidden_logic = false +keyword_forbidden_priority = false +keyword_forbidden_unique = false +keyword_forbidden_unique0 = false +keyword_forbidden_wire_reg = false +keyword_required_generate = false +localparam_explicit_type = false +localparam_type_twostate = false +loop_statement_in_always_comb = false +loop_statement_in_always_ff = false +loop_statement_in_always_latch = false +loop_variable_declaration = false +lowercamelcase_interface = false +lowercamelcase_module = false +lowercamelcase_package = false +module_ansi_forbidden = false +module_identifier_matches_filename = false +module_nonansi_forbidden = false +multiline_for_begin = false +multiline_if_begin = false +non_blocking_assignment_in_always_comb = false +non_blocking_assignment_in_always_no_edge = false +operator_case_equality = false +operator_incdec = false +operator_self_assignment = false +output_with_var = false +package_identifier_matches_filename = false +package_item_not_in_package = false +parameter_default_value = false +parameter_explicit_type = false +parameter_in_generate = false +parameter_in_package = false +parameter_type_twostate = false +prefix_inout = false +prefix_input = false +prefix_instance = false +prefix_interface = false +prefix_module = false +prefix_output = false +prefix_package = false +procedural_continuous_assignment = false +program_identifier_matches_filename = false +re_forbidden_assert = false +re_forbidden_assert_property = false +re_forbidden_checker = false +re_forbidden_class = false +re_forbidden_function = false +re_forbidden_generateblock = false +re_forbidden_genvar = false +re_forbidden_instance = false +re_forbidden_interface = false +re_forbidden_localparam = false +re_forbidden_modport = false +re_forbidden_module_ansi = false +re_forbidden_module_nonansi = false +re_forbidden_package = false +re_forbidden_parameter = false +re_forbidden_port_inout = false +re_forbidden_port_input = false +re_forbidden_port_interface = false +re_forbidden_port_output = false +re_forbidden_port_ref = false +re_forbidden_program = false +re_forbidden_property = false +re_forbidden_sequence = false +re_forbidden_task = false +re_forbidden_var_class = false +re_forbidden_var_classmethod = false +re_required_assert = false +re_required_assert_property = false +re_required_checker = false +re_required_class = false +re_required_function = false +re_required_generateblock = false +re_required_genvar = false +re_required_instance = false +re_required_interface = false +re_required_localparam = false +re_required_modport = false +re_required_module_ansi = false +re_required_module_nonansi = false +re_required_package = false +re_required_parameter = false +re_required_port_inout = false +re_required_port_input = false +re_required_port_interface = false +re_required_port_output = false +re_required_port_ref = false +re_required_program = false +re_required_property = false +re_required_sequence = false +re_required_task = false +re_required_var_class = false +re_required_var_classmethod = false +sequential_block_in_always_comb = false +sequential_block_in_always_ff = false +sequential_block_in_always_latch = false +style_commaleading = false +style_indent = false +style_keyword_0or1space = false +style_keyword_0space = false +style_keyword_1or2space = false +style_keyword_1space = false +style_keyword_1spaceornewline = false +style_keyword_construct = false +style_keyword_datatype = false +style_keyword_end = false +style_keyword_maybelabel = false +style_keyword_new = false +style_keyword_newline = false +style_operator_arithmetic = false +style_operator_arithmetic_leading_space = false +style_operator_boolean = false +style_operator_boolean_leading_space = false +style_operator_integer = false +style_operator_integer_leading_space = false +style_operator_unary = false +style_trailingwhitespace = false +tab_character = false +unpacked_array = false +uppercamelcase_interface = false +uppercamelcase_module = false +uppercamelcase_package = false + diff --git a/tests/checklibs.sh b/tests/checklibs.sh new file mode 100644 index 0000000..25a0275 --- /dev/null +++ b/tests/checklibs.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -e + +DOCKER="docker run --rm -v $HOME:$HOME -w $PWD --user $(id -u):$(id -g) ghcr.io/pyfpga/langutils" +echo "* vhd2vl" +$DOCKER ldd /usr/local/bin/vhd2vl +echo "* sv2v" +$DOCKER ldd /usr/local/bin/sv2v +echo "* slang" +$DOCKER ldd /usr/local/bin/slang +echo "* surelog" +$DOCKER ldd /usr/local/bin/surelog +echo "* verible" +$DOCKER ldd /usr/local/bin/verible-verilog-syntax +echo "* svlint" +$DOCKER ldd /usr/local/bin/svlint + +DOCKER="docker run --rm -v $HOME:$HOME -w $PWD --user $(id -u):$(id -g) ghcr.io/pyfpga/synthesis" +echo "* ghdl" +$DOCKER ldd /usr/local/bin/ghdl +echo "* yosys" +$DOCKER ldd /usr/local/bin/yosys +echo "* synlig" +$DOCKER ldd /usr/local/bin/synlig + +DOCKER="docker run --rm -v $HOME:$HOME -w $PWD --user $(id -u):$(id -g) ghcr.io/pyfpga/simulation" +echo "* ghdl" +$DOCKER ldd /usr/local/bin/ghdl +echo "* iverilog" +$DOCKER ldd /usr/local/bin/iverilog +echo "* verilator" +$DOCKER ldd /usr/local/bin/verilator_bin + +echo "Test passed" diff --git a/tests/langutils.sh b/tests/langutils.sh index 45da66a..5096769 100644 --- a/tests/langutils.sh +++ b/tests/langutils.sh @@ -2,20 +2,40 @@ set -e -DOCKER="docker run --rm -v $HOME:$HOME -w $PWD --user $(id -u):$(id -g) ghcr.io/pyfpga/langutils" +POC=$1 + +# [[ -z "$POC" ]] && echo "POC is unset" +# [[ -n "$POC" ]] && echo "POC is set" + +[[ -z "$POC" ]] && DOCKER="docker run --rm -v $HOME:$HOME -w $PWD --user $(id -u):$(id -g) ghcr.io/pyfpga/langutils" mkdir -p results +[[ -n "$POC" ]] && DOCKER="docker run --rm -v $HOME:$HOME -w $PWD --user $(id -u):$(id -g) ghcr.io/pyfpga/vhd2vl" $DOCKER vhd2vl --version -$DOCKER slang --version -$DOCKER surelog --version +$DOCKER vhd2vl --quiet hdl/counter.vhdl results/vhd2vl.v +test -f results/vhd2vl.v + +[[ -n "$POC" ]] && DOCKER="docker run --rm -v $HOME:$HOME -w $PWD --user $(id -u):$(id -g) ghcr.io/pyfpga/sv2v" $DOCKER sv2v --version -$DOCKER verible-verilog-syntax --version +$DOCKER sv2v hdl/counter.sv --write=results/sv2v.v +test -f results/sv2v.v -$DOCKER vhd2vl --quiet hdl/counter.vhdl results/vhd2vl.v +[[ -n "$POC" ]] && DOCKER="docker run --rm -v $HOME:$HOME -w $PWD --user $(id -u):$(id -g) ghcr.io/pyfpga/slang" +$DOCKER slang --version $DOCKER slang hdl/counter.sv --lint-only + +[[ -n "$POC" ]] && DOCKER="docker run --rm -v $HOME:$HOME -w $PWD --user $(id -u):$(id -g) ghcr.io/pyfpga/surelog" +$DOCKER surelog --version $DOCKER surelog -parse hdl/counter.sv -$DOCKER sv2v hdl/counter.sv --write=results/sv2v.v +rm -fr slpp_all + +[[ -n "$POC" ]] && DOCKER="docker run --rm -v $HOME:$HOME -w $PWD --user $(id -u):$(id -g) ghcr.io/pyfpga/verible" +$DOCKER verible-verilog-syntax --version $DOCKER verible-verilog-lint hdl/counter.sv -rm -fr slpp_all +[[ -n "$POC" ]] && DOCKER="docker run --rm -v $HOME:$HOME -w $PWD --user $(id -u):$(id -g) ghcr.io/pyfpga/svlint" +$DOCKER svlint --version +$DOCKER svlint hdl/counter.sv + +echo "Test passed" diff --git a/tests/synthesis.sh b/tests/synthesis.sh index e8e881c..3607345 100644 --- a/tests/synthesis.sh +++ b/tests/synthesis.sh @@ -8,7 +8,7 @@ mkdir -p results $DOCKER ghdl --version $DOCKER yosys -m ghdl -V -$DOCKER yosys -m slang -V +$DOCKER yosys -V $DOCKER synlig -V $DOCKER ghdl synth --workdir=results hdl/counter.vhdl -e counter > results/ghdl.vhdl @@ -27,7 +27,6 @@ write_verilog -noattr results/yosys.v ' $DOCKER yosys -Q -p ' -plugin -i slang read_slang hdl/counter.sv -top counter write_verilog -noattr results/yosys-slang.v '