2020-01-07 15:06:23 +00:00
|
|
|
{ stdenv
|
2020-02-01 11:11:30 +00:00
|
|
|
, abc-verifier
|
2020-06-12 03:43:44 +00:00
|
|
|
, bash
|
2020-01-07 15:06:23 +00:00
|
|
|
, bison
|
|
|
|
, fetchFromGitHub
|
|
|
|
, flex
|
|
|
|
, libffi
|
|
|
|
, pkgconfig
|
|
|
|
, protobuf
|
|
|
|
, python3
|
|
|
|
, readline
|
|
|
|
, tcl
|
2019-09-27 14:06:42 +00:00
|
|
|
, verilog
|
2020-01-07 15:06:23 +00:00
|
|
|
, zlib
|
2017-10-16 07:34:04 +00:00
|
|
|
}:
|
2015-12-29 16:31:18 +00:00
|
|
|
|
2020-11-12 20:14:08 +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-02-01 11:11:30 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2020-03-17 10:26:27 +00:00
|
|
|
pname = "yosys";
|
2020-11-12 20:14:08 +00:00
|
|
|
version = "0.9+3675";
|
2015-12-29 16:31:18 +00:00
|
|
|
|
2020-01-07 15:09:08 +00:00
|
|
|
src = fetchFromGitHub {
|
2020-02-08 15:29:50 +00:00
|
|
|
owner = "YosysHQ";
|
2020-01-07 15:09:08 +00:00
|
|
|
repo = "yosys";
|
2020-11-12 20:14:08 +00:00
|
|
|
rev = "71ca9a825309635511b64b3ec40e5e5e9b6ad49b";
|
|
|
|
sha256 = "03jlhfvm5rxx8yybf94nqd3ld2y6brp8r0k6gfi56chv3iqqavy3";
|
2020-01-07 15:09:08 +00:00
|
|
|
};
|
2015-12-29 16:31:18 +00:00
|
|
|
|
2017-10-16 07:34:04 +00:00
|
|
|
enableParallelBuilding = true;
|
2017-09-05 21:26:13 +00:00
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
2019-08-13 23:46:42 +00:00
|
|
|
buildInputs = [ tcl readline libffi python3 bison flex protobuf zlib ];
|
2018-08-09 00:28:18 +00:00
|
|
|
|
2020-01-07 15:06:23 +00:00
|
|
|
makeFlags = [ "ENABLE_PROTOBUF=1" "PREFIX=${placeholder "out"}"];
|
2018-02-14 06:15:48 +00:00
|
|
|
|
|
|
|
patchPhase = ''
|
|
|
|
substituteInPlace ./Makefile \
|
2018-04-11 20:08:51 +00:00
|
|
|
--replace 'CXX = clang' "" \
|
2019-08-20 09:43:58 +00:00
|
|
|
--replace 'LD = clang++' 'LD = $(CXX)' \
|
|
|
|
--replace 'CXX = gcc' "" \
|
|
|
|
--replace 'LD = gcc' 'LD = $(CXX)' \
|
|
|
|
--replace 'ABCMKARGS = CC="$(CXX)" CXX="$(CXX)"' 'ABCMKARGS =' \
|
2020-02-01 11:11:30 +00:00
|
|
|
--replace 'echo UNKNOWN' 'echo ${builtins.substring 0 10 src.rev}'
|
2020-06-12 03:43:44 +00:00
|
|
|
substituteInPlace ./misc/yosys-config.in \
|
|
|
|
--replace '/bin/bash' '${bash}/bin/bash'
|
2019-09-27 14:06:42 +00:00
|
|
|
patchShebangs tests
|
2018-02-14 06:15:48 +00:00
|
|
|
'';
|
|
|
|
|
2020-02-01 11:34:30 +00:00
|
|
|
preBuild = let
|
|
|
|
shortAbcRev = builtins.substring 0 7 abc-verifier.rev;
|
|
|
|
in ''
|
2020-01-07 15:09:08 +00:00
|
|
|
chmod -R u+w .
|
2018-04-11 20:08:51 +00:00
|
|
|
make config-${if stdenv.cc.isClang or false then "clang" else "gcc"}
|
2020-02-01 11:11:30 +00:00
|
|
|
echo 'ABCEXTERNAL = ${abc-verifier}/bin/abc' >> Makefile.conf
|
2018-08-09 00:28:18 +00:00
|
|
|
|
|
|
|
# we have to do this ourselves for some reason...
|
|
|
|
(cd misc && ${protobuf}/bin/protoc --cpp_out ../backends/protobuf/ ./yosys.proto)
|
2020-02-01 11:34:30 +00:00
|
|
|
|
2020-03-17 10:26:27 +00:00
|
|
|
if ! grep -q "ABCREV = ${shortAbcRev}" Makefile; then
|
2020-11-12 20:14:08 +00:00
|
|
|
echo "ERROR: yosys isn't compatible with the provided abc (${shortAbcRev}), failing."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep -q "YOSYS_VER := ${version}" Makefile; then
|
|
|
|
echo "ERROR: yosys version in Makefile isn't equivalent to version of the nix package (${version}), failing."
|
2020-02-01 11:34:30 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2015-12-29 16:31:18 +00:00
|
|
|
'';
|
|
|
|
|
2020-11-12 20:14:08 +00:00
|
|
|
checkTarget = "test";
|
2019-09-27 14:06:42 +00:00
|
|
|
doCheck = true;
|
|
|
|
checkInputs = [ verilog ];
|
|
|
|
|
2020-03-17 10:26:27 +00:00
|
|
|
# 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 20:14:08 +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";
|
|
|
|
postInstall = "ln -sfv ${abc-verifier}/bin/abc $out/bin/yosys-abc";
|
2020-03-17 10:26:27 +00:00
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
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 ];
|
2015-12-29 16:31:18 +00:00
|
|
|
};
|
|
|
|
}
|