2021-04-05 15:23:46 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
2020-04-24 23:36:52 +00:00
|
|
|
, abc-verifier
|
2020-06-18 07:06:33 +00:00
|
|
|
, bash
|
2020-04-24 23:36:52 +00:00
|
|
|
, bison
|
|
|
|
, fetchFromGitHub
|
|
|
|
, flex
|
|
|
|
, libffi
|
2021-01-15 22:18:51 +00:00
|
|
|
, pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
, protobuf
|
|
|
|
, python3
|
|
|
|
, readline
|
|
|
|
, tcl
|
|
|
|
, verilog
|
|
|
|
, zlib
|
|
|
|
}:
|
|
|
|
|
2020-11-12 23:50:31 +00:00
|
|
|
# NOTE: as of late 2020, yosys has switched to an automation robot that
|
|
|
|
# automatically tags their repository Makefile with a new build number every
|
|
|
|
# day when changes are committed. please MAKE SURE that the version number in
|
|
|
|
# the 'version' field exactly matches the YOSYS_VER field in the Yosys
|
|
|
|
# makefile!
|
|
|
|
#
|
|
|
|
# if a change in yosys isn't yet available under a build number like this (i.e.
|
|
|
|
# it was very recently merged, within an hour), wait a few hours for the
|
|
|
|
# automation robot to tag the new version, like so:
|
|
|
|
#
|
|
|
|
# https://github.com/YosysHQ/yosys/commit/71ca9a825309635511b64b3ec40e5e5e9b6ad49b
|
|
|
|
#
|
|
|
|
# note that while most nix packages for "unstable versions" use a date-based
|
|
|
|
# version scheme, synchronizing the nix package version here with the unstable
|
|
|
|
# yosys version number helps users report better bugs upstream, and is
|
|
|
|
# ultimately less confusing than using dates.
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "yosys";
|
2021-12-06 16:07:01 +00:00
|
|
|
version = "0.11+52";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2021-12-06 16:07:01 +00:00
|
|
|
owner = "YosysHQ";
|
|
|
|
repo = "yosys";
|
|
|
|
rev = "2be110cb0ba645f95f62ee01b6a6fa46a85d5b26";
|
|
|
|
hash = "sha256-A1QKu6SbtpJJPF8/LA5SMUP3/+n5giM6rOYdc6vkl90=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
2021-01-17 00:15:33 +00:00
|
|
|
nativeBuildInputs = [ pkg-config bison flex ];
|
2021-01-15 22:18:51 +00:00
|
|
|
buildInputs = [ tcl readline libffi python3 protobuf zlib ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
makeFlags = [ "ENABLE_PROTOBUF=1" "PREFIX=${placeholder "out"}"];
|
|
|
|
|
2021-01-17 00:15:33 +00:00
|
|
|
patches = [
|
|
|
|
./plugin-search-dirs.patch
|
2021-12-06 16:07:01 +00:00
|
|
|
./fix-clang-build.patch # see https://github.com/YosysHQ/yosys/issues/2011
|
2021-01-17 00:15:33 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace ./Makefile \
|
|
|
|
--replace 'echo UNKNOWN' 'echo ${builtins.substring 0 10 src.rev}'
|
2021-01-17 00:15:33 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
chmod +x ./misc/yosys-config.in
|
2021-01-17 00:15:33 +00:00
|
|
|
patchShebangs tests ./misc/yosys-config.in
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
preBuild = let
|
|
|
|
shortAbcRev = builtins.substring 0 7 abc-verifier.rev;
|
|
|
|
in ''
|
|
|
|
chmod -R u+w .
|
|
|
|
make config-${if stdenv.cc.isClang or false then "clang" else "gcc"}
|
|
|
|
echo 'ABCEXTERNAL = ${abc-verifier}/bin/abc' >> Makefile.conf
|
|
|
|
|
|
|
|
# we have to do this ourselves for some reason...
|
|
|
|
(cd misc && ${protobuf}/bin/protoc --cpp_out ../backends/protobuf/ ./yosys.proto)
|
|
|
|
|
|
|
|
if ! grep -q "ABCREV = ${shortAbcRev}" Makefile; then
|
2020-11-12 23:50:31 +00:00
|
|
|
echo "ERROR: yosys isn't compatible with the provided abc (${shortAbcRev}), failing."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
if ! grep -q "YOSYS_VER := $version" Makefile; then
|
2021-01-17 00:15:33 +00:00
|
|
|
echo "ERROR: yosys version in Makefile isn't equivalent to version of the nix package (${version}), failing."
|
2020-04-24 23:36:52 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2020-11-12 23:50:31 +00:00
|
|
|
checkTarget = "test";
|
2020-04-24 23:36:52 +00:00
|
|
|
doCheck = true;
|
|
|
|
checkInputs = [ verilog ];
|
|
|
|
|
|
|
|
# Internally, yosys knows to use the specified hardcoded ABCEXTERNAL binary.
|
|
|
|
# But other tools (like mcy or symbiyosys) can't know how yosys was built, so
|
|
|
|
# they just assume that 'yosys-abc' is available -- but it's not installed
|
|
|
|
# when using ABCEXTERNAL
|
|
|
|
#
|
2020-11-12 23:50:31 +00:00
|
|
|
# add a symlink to fake things so that both variants work the same way. this
|
|
|
|
# is also needed at build time for the test suite.
|
|
|
|
postBuild = "ln -sfv ${abc-verifier}/bin/abc ./yosys-abc";
|
2021-01-17 00:15:33 +00:00
|
|
|
postInstall = "ln -sfv ${abc-verifier}/bin/abc $out/bin/yosys-abc";
|
2021-01-15 22:18:51 +00:00
|
|
|
|
2021-01-17 00:15:33 +00:00
|
|
|
setupHook = ./setup-hook.sh;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-17 00:15:33 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Open RTL synthesis framework and tools";
|
|
|
|
homepage = "http://www.clifford.at/yosys/";
|
|
|
|
license = licenses.isc;
|
|
|
|
platforms = platforms.all;
|
|
|
|
maintainers = with maintainers; [ shell thoughtpolice emily ];
|
|
|
|
};
|
|
|
|
}
|