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