Skip to content

Instantly share code, notes, and snippets.

@ceres-c
Created March 16, 2024 01:09
Show Gist options
  • Save ceres-c/7b58ae9d59ae1f5188ea73313aeb9cad to your computer and use it in GitHub Desktop.
Save ceres-c/7b58ae9d59ae1f5188ea73313aeb9cad to your computer and use it in GitHub Desktop.
Build environment for osresearch/spispy

As mentioned in osresearch/spispy#25, building spispy is not as trivial as one might expect.

It took me the good part of a day to find the right package version alchemy to succesfully build the project, so I decided to create a dockerfile to reproduce the result

NOTE: Expect a fairly long build, as nextpnr is compiled on a single core: I had bad luck with multicore builds hanging forever

from ubuntu:22.04
ADD yosys.patch /root/yosys.patch
ADD prjtrellis.patch /root/prjtrellis.patch
ADD nextpnr.patch /root/nextpnr.patch
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt upgrade -y && apt install -y build-essential=12.9ubuntu3 \
cmake=3.22.1-1ubuntu1.22.04.2 clang=1:14.0-55~exp2 bison=2:3.8.2+dfsg-1build1 \
flex=2.6.4-8build2 libreadline-dev=8.1.2-1 gawk=1:5.1.0-1build3 \
tcl-dev=8.6.11+1build2 libffi-dev=3.4.2-4 git=1:2.34.1-1ubuntu1 \
graphviz=2.42.2-6 xdot=1.2-2 pkg-config=0.29.2-1ubuntu3 \
python3-minimal=3.10.6-1~22.04 libpython3-stdlib=3.10.6-1~22.04 \
python3-lib2to3=3.10.8-1~22.04 python3-distutils python3=3.10.6-1~22.04 \
libboost-all-dev=1.74.0.3ubuntu7 libboost-python-dev=1.74.0.3ubuntu7 \
qtbase5-dev=5.15.3+dfsg-2ubuntu0.2 qtdeclarative5-dev=5.15.3+dfsg-1 libeigen3-dev=3.4.0-2ubuntu2
RUN git clone https://github.com/YosysHQ/yosys.git && \
cd yosys && git checkout 70d0f38 && \
git apply /root/yosys.patch && \
make config-clang && \
make -j$(nproc) && \
make install
RUN git clone --recursive https://github.com/SymbiFlow/prjtrellis && \
cd prjtrellis && \
git checkout 3311e6d && \
(cd database/ && git checkout master) && \
git apply /root/prjtrellis.patch && \
cd libtrellis && \
cmake -DCMAKE_INSTALL_PREFIX=/usr . && \
make -j$(nproc) && \
make install
RUN git clone https://github.com/YosysHQ/nextpnr.git && \
cd nextpnr && \
git checkout 19cb4ca && \
git checkout bac8335 -- ecp5/constids.inc && \
git apply /root/nextpnr.patch && \
cmake -DARCH=ecp5 -DTRELLIS_ROOT=/usr/share/trellis/ -DBUILD_PYTHON=OFF -DBUILD_GUI=OFF . && \
make && \
make install
RUN git clone https://github.com/osresearch/spispy.git && \
cd spispy/verilog && \
PRJTRELLIS=/prjtrellis/libtrellis/ make
diff --git a/ecp5/trellis_import.py b/ecp5/trellis_import.py
index 610bd331..08287b73 100755
--- a/ecp5/trellis_import.py
+++ b/ecp5/trellis_import.py
@@ -186,6 +186,8 @@ def process_timing_data():
max_delay = min(entry["rising"][2], entry["falling"][2])
delays.append((constids[from_pin], constids[to_pin], min_delay, max_delay))
elif entry["type"] == "SetupHold":
+ if type(entry["pin"]) is list:
+ continue
pin = constids[entry["pin"]]
clock = constids[entry["clock"][1]]
min_setup = entry["setup"][0]
diff --git a/database b/database
index d0b219a..4dda149 160000
--- a/database
+++ b/database
@@ -1 +1 @@
-Subproject commit d0b219af41ae3da6150645fbc5cc5613b530603f
+Subproject commit 4dda149b9e4f1753ebc8b011ece2fe794be1281a
diff --git a/libtrellis/CMakeLists.txt b/libtrellis/CMakeLists.txt
index dc49445..89e2151 100644
--- a/libtrellis/CMakeLists.txt
+++ b/libtrellis/CMakeLists.txt
@@ -1,6 +1,10 @@
cmake_minimum_required(VERSION 3.5)
project(libtrellis)
+if(POLICY CMP0148)
+ cmake_policy(SET CMP0148 OLD)
+endif()
+
option(BUILD_PYTHON "Build Python Integration" ON)
option(BUILD_SHARED "Build shared Trellis library" ON)
option(STATIC_BUILD "Create static build of Trellis tools" OFF)
diff --git a/libtrellis/src/CRAM.cpp b/libtrellis/src/CRAM.cpp
index 42c63fe..852ad53 100644
--- a/libtrellis/src/CRAM.cpp
+++ b/libtrellis/src/CRAM.cpp
@@ -1,5 +1,6 @@
#include "CRAM.hpp"
#include <cassert>
+#include <stdexcept>
namespace Trellis {
char &CRAMView::bit(int frame, int bit) const {
diff --git a/kernel/rtlil.h b/kernel/rtlil.h
index db5c33c73..9cc998883 100644
--- a/kernel/rtlil.h
+++ b/kernel/rtlil.h
@@ -18,6 +18,7 @@
*/
#include "kernel/yosys.h"
+#include <limits>
#ifndef RTLIL_H
#define RTLIL_H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment