2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, cmake
|
2021-10-17 09:34:42 +00:00
|
|
|
, boost, python3, eigen, python3Packages
|
2020-04-24 23:36:52 +00:00
|
|
|
, icestorm, trellis
|
|
|
|
, llvmPackages
|
|
|
|
|
2021-01-05 17:05:55 +00:00
|
|
|
, enableGui ? false
|
|
|
|
, wrapQtAppsHook ? null
|
|
|
|
, qtbase ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
, OpenGL ? null
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
boostPython = boost.override { python = python3; enablePython = true; };
|
2023-08-22 20:05:09 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "nextpnr";
|
2024-02-07 01:22:34 +00:00
|
|
|
version = "0.7";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
main_src = fetchFromGitHub {
|
|
|
|
owner = "YosysHQ";
|
|
|
|
repo = "nextpnr";
|
|
|
|
rev = "${pname}-${version}";
|
2024-02-07 01:22:34 +00:00
|
|
|
hash = "sha256-YIAQcCg9RjvCys1bQ3x+sTgTmnmEeXVbt9Lr6wtg1pA=";
|
2023-08-22 20:05:09 +00:00
|
|
|
name = "nextpnr";
|
|
|
|
};
|
|
|
|
|
|
|
|
test_src = fetchFromGitHub {
|
|
|
|
owner = "YosysHQ";
|
|
|
|
repo = "nextpnr-tests";
|
|
|
|
rev = "00c55a9eb9ea2e062b51fe0d64741412b185d95d";
|
|
|
|
sha256 = "sha256-83suMftMtnaRFq3T2/I7Uahb11WZlXhwYt6Q/rqi2Yo=";
|
|
|
|
name = "nextpnr-tests";
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
inherit pname version;
|
|
|
|
|
|
|
|
srcs = [ main_src test_src ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
sourceRoot = main_src.name;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
nativeBuildInputs
|
|
|
|
= [ cmake ]
|
|
|
|
++ (lib.optional enableGui wrapQtAppsHook);
|
|
|
|
buildInputs
|
2021-10-17 09:34:42 +00:00
|
|
|
= [ boostPython python3 eigen python3Packages.apycula ]
|
2020-04-24 23:36:52 +00:00
|
|
|
++ (lib.optional enableGui qtbase)
|
|
|
|
++ (lib.optional stdenv.cc.isClang llvmPackages.openmp);
|
|
|
|
|
|
|
|
cmakeFlags =
|
|
|
|
[ "-DCURRENT_GIT_VERSION=${lib.substring 0 7 (lib.elemAt srcs 0).rev}"
|
2021-10-17 09:34:42 +00:00
|
|
|
"-DARCH=generic;ice40;ecp5;gowin"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DBUILD_TESTS=ON"
|
2021-01-05 17:05:55 +00:00
|
|
|
"-DICESTORM_INSTALL_PREFIX=${icestorm}"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DTRELLIS_INSTALL_PREFIX=${trellis}"
|
2020-07-18 16:06:22 +00:00
|
|
|
"-DTRELLIS_LIBDIR=${trellis}/lib/trellis"
|
2021-10-17 09:34:42 +00:00
|
|
|
"-DGOWIN_BBA_EXECUTABLE=${python3Packages.apycula}/bin/gowin_bba"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DUSE_OPENMP=ON"
|
|
|
|
# warning: high RAM usage
|
2021-01-05 17:05:55 +00:00
|
|
|
"-DSERIALIZE_CHIPDBS=OFF"
|
2020-04-24 23:36:52 +00:00
|
|
|
]
|
2021-01-05 17:05:55 +00:00
|
|
|
++ (lib.optional enableGui "-DBUILD_GUI=ON")
|
2020-04-24 23:36:52 +00:00
|
|
|
++ (lib.optional (enableGui && stdenv.isDarwin)
|
|
|
|
"-DOPENGL_INCLUDE_DIR=${OpenGL}/Library/Frameworks");
|
|
|
|
|
|
|
|
patchPhase = with builtins; ''
|
|
|
|
# use PyPy for icestorm if enabled
|
2021-10-01 09:20:50 +00:00
|
|
|
substituteInPlace ./ice40/CMakeLists.txt \
|
2020-04-24 23:36:52 +00:00
|
|
|
--replace ''\'''${PYTHON_EXECUTABLE}' '${icestorm.pythonInterp}'
|
|
|
|
'';
|
|
|
|
|
|
|
|
preBuild = ''
|
2023-08-22 20:05:09 +00:00
|
|
|
ln -s ../${test_src.name} tests
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
postFixup = lib.optionalString enableGui ''
|
|
|
|
wrapQtApp $out/bin/nextpnr-generic
|
|
|
|
wrapQtApp $out/bin/nextpnr-ice40
|
|
|
|
wrapQtApp $out/bin/nextpnr-ecp5
|
2021-10-17 09:34:42 +00:00
|
|
|
wrapQtApp $out/bin/nextpnr-gowin
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
strictDeps = true;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Place and route tool for FPGAs";
|
|
|
|
homepage = "https://github.com/yosyshq/nextpnr";
|
|
|
|
license = licenses.isc;
|
|
|
|
platforms = platforms.all;
|
2024-06-20 14:57:18 +00:00
|
|
|
maintainers = with maintainers; [ thoughtpolice ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|