From 3b07143069252912de0f78c4711dcb246649888e Mon Sep 17 00:00:00 2001 From: "Rodrigo A. Melo" Date: Tue, 10 Dec 2024 21:13:50 -0300 Subject: [PATCH 1/6] Add simulation, including GHDL and iVerilog --- recipes/simulation | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 recipes/simulation diff --git a/recipes/simulation b/recipes/simulation new file mode 100644 index 0000000..b208fd0 --- /dev/null +++ b/recipes/simulation @@ -0,0 +1,50 @@ +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 \ + # iVerilog + autoconf \ + bison \ + flex \ + gperf \ + # Verilator + && 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 + +# +# Clean-up +# + +############################################################################### + +# FROM ubuntu:latest From e56cfbe90ec3dd7b652acabf4fdb9e7acd25d9e0 Mon Sep 17 00:00:00 2001 From: "Rodrigo A. Melo" Date: Tue, 10 Dec 2024 22:41:43 -0300 Subject: [PATCH 2/6] simulation: add verilator --- recipes/simulation | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/recipes/simulation b/recipes/simulation index b208fd0..feb2c4f 100644 --- a/recipes/simulation +++ b/recipes/simulation @@ -12,15 +12,23 @@ RUN apt-get update -qq \ build-essential \ ca-certificates \ git \ + python3 \ zlib1g-dev \ # GHDL gnat \ - # iVerilog + # iVerilog & Verilator autoconf \ bison \ flex \ gperf \ # Verilator + help2man \ + libfl2 \ + libfl-dev \ + zlib1g \ + ccache \ + mold \ + libgoogle-perftools-dev numactl \ && apt-get autoclean && apt-get clean && apt-get -y autoremove \ && rm -rf /var/lib/apt/lists/* @@ -41,6 +49,14 @@ 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 + # # Clean-up # From 410a72ff01972f27259794017966531ceb5e7652 Mon Sep 17 00:00:00 2001 From: "Rodrigo A. Melo" Date: Tue, 10 Dec 2024 22:42:00 -0300 Subject: [PATCH 3/6] Add tests for simulation --- tests/simulation.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/simulation.sh diff --git a/tests/simulation.sh b/tests/simulation.sh new file mode 100644 index 0000000..c8b78e4 --- /dev/null +++ b/tests/simulation.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +DOCKER="docker run --rm -v $HOME:$HOME -w $PWD --user $(id -u):$(id -g) ghcr.io/pyfpga/simulation" + +$DOCKER ghdl --version +$DOCKER iverilog -V | grep Icarus +$DOCKER verilator --version From 841b594feaef732b290b024a2984380c178a37c7 Mon Sep 17 00:00:00 2001 From: "Rodrigo A. Melo" Date: Tue, 7 Jan 2025 21:37:29 -0300 Subject: [PATCH 4/6] simulation: add cocotb --- recipes/simulation | 9 +++++++++ tests/simulation.sh | 1 + 2 files changed, 10 insertions(+) diff --git a/recipes/simulation b/recipes/simulation index feb2c4f..15378d1 100644 --- a/recipes/simulation +++ b/recipes/simulation @@ -28,6 +28,9 @@ RUN apt-get update -qq \ 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/* @@ -57,6 +60,12 @@ 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 # diff --git a/tests/simulation.sh b/tests/simulation.sh index c8b78e4..f99fe5c 100644 --- a/tests/simulation.sh +++ b/tests/simulation.sh @@ -7,3 +7,4 @@ DOCKER="docker run --rm -v $HOME:$HOME -w $PWD --user $(id -u):$(id -g) ghcr.io/ $DOCKER ghdl --version $DOCKER iverilog -V | grep Icarus $DOCKER verilator --version +$DOCKER cocotb-config --version From 11afa336bf88e253d822c09b26288c13f9ac3175 Mon Sep 17 00:00:00 2001 From: "Rodrigo A. Melo" Date: Wed, 8 Jan 2025 21:06:43 -0300 Subject: [PATCH 5/6] ci: add to deploy simulation --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3787933..bebc407 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,8 +12,9 @@ jobs: fail-fast: false matrix: name: - - synthesis - langutils + - synthesis + - simulation steps: - uses: actions/checkout@v2 - name: Login to GitHub Container Registry From 49409f3a26d8042180f78af76ddf1bd90665c21d Mon Sep 17 00:00:00 2001 From: "Rodrigo A. Melo" Date: Wed, 8 Jan 2025 21:07:08 -0300 Subject: [PATCH 6/6] Update README, add simulation Closes #7 --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 2b87413..501acaf 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,8 @@ * [ghdl-yosys-plugin](https://github.com/ghdl/ghdl-yosys-plugin) * [yosys-slang](https://github.com/povik/yosys-slang) * [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)