2021-03-31 23:11:34 +02:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
2020-02-01 12:11:30 +01:00
|
|
|
, abc-verifier
|
2020-06-12 05:43:44 +02:00
|
|
|
, bash
|
2020-01-07 16:06:23 +01:00
|
|
|
, bison
|
|
|
|
, fetchFromGitHub
|
|
|
|
, flex
|
|
|
|
, libffi
|
2021-01-15 17:26:16 +01:00
|
|
|
, pkg-config
|
2020-01-07 16:06:23 +01:00
|
|
|
, 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-11-12 21:14:08 +01: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 12:11:30 +01:00
|
|
|
stdenv.mkDerivation rec {
|
2020-03-17 11:26:27 +01:00
|
|
|
pname = "yosys";
|
2021-08-19 10:17:43 +02:00
|
|
|
version = "0.9+4276";
|
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";
|
2021-08-19 10:17:43 +02:00
|
|
|
rev = "75a4cdfc8afc10fed80e43fb1ba31c7edaf6e361";
|
|
|
|
sha256 = "13xb7ny6i0kr6z6xkj9wmmcj551si7w05r3cghq8h8wkikyh6c8p";
|
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;
|
2021-01-15 23:07:53 +01:00
|
|
|
nativeBuildInputs = [ pkg-config bison flex ];
|
|
|
|
buildInputs = [ tcl readline libffi python3 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
|
|
|
|
2021-01-15 23:07:53 +01:00
|
|
|
patches = [
|
|
|
|
./plugin-search-dirs.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
2018-02-14 07:15:48 +01:00
|
|
|
substituteInPlace ./Makefile \
|
2020-02-01 12:11:30 +01:00
|
|
|
--replace 'echo UNKNOWN' 'echo ${builtins.substring 0 10 src.rev}'
|
2021-01-15 17:26:16 +01:00
|
|
|
|
|
|
|
chmod +x ./misc/yosys-config.in
|
|
|
|
patchShebangs tests ./misc/yosys-config.in
|
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-11-12 21:14:08 +01:00
|
|
|
echo "ERROR: yosys isn't compatible with the provided abc (${shortAbcRev}), failing."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-01-15 17:26:16 +01:00
|
|
|
if ! grep -q "YOSYS_VER := $version" Makefile; then
|
2021-01-15 17:13:27 +01:00
|
|
|
echo "ERROR: yosys version in Makefile isn't equivalent to version of the nix package (${version}), failing."
|
2020-02-01 12:34:30 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2015-12-29 17:31:18 +01:00
|
|
|
'';
|
|
|
|
|
2020-11-12 21:14:08 +01:00
|
|
|
checkTarget = "test";
|
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
|
|
|
|
#
|
2020-11-12 21:14:08 +01: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-15 17:13:27 +01:00
|
|
|
postInstall = "ln -sfv ${abc-verifier}/bin/abc $out/bin/yosys-abc";
|
2020-03-17 11:26:27 +01:00
|
|
|
|
yosys: enable loading "out of band" plugins
By default, when yosys looks for plugins with the `-m` flag or `plugin`
command, it always looks in `YOSYS_PREFIX/share/yosys/plugins` for a
`.so` file, and loads that.
By design, this is intended to be a single, global, mutable location
such as `/usr/share/yosys/...` on disk, and plugins are supposed to
install their `.so` files here after yosys is installed, and they all
coexist together. Obviously, this won't work for us, but users might
expect these plugins to still work. More importantly, they won't want to
add special cases to their build systems.
Instead, to allow Nix users to use yosys plugins with the same UX (e.g.
natively call `plugin bluespec` or `-m ghdl`), we add a patch to yosys
that allows it to search a new `NIX_YOSYS_PLUGIN_DIRS` search path
environment variable. In tandem, we add a setup hook that adds to this
search path if a package has a `$out/share/yosys/plugins` directory.
Thus, it's enough to just include `yosys`, and any package that has a
yosys plugin in `$out/share/yosys/plugins`, and you can load it with
`-m` or the `plugin` command.
We could use a style like the haskellPackages set, where the set of
packages are "encased" in a lambda, and we pass packages that are
compatible with that version of the compiler:
haskell.packages.ghc8102.ghcWithPackages (p: with p; [ ... ])
but, realistically, there will probably only ever be one version of
yosys and one set of compatible plugins, so this seems overdone.
Signed-off-by: Austin Seipp <aseipp@pobox.com>
2021-01-15 06:52:23 +01:00
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
2021-01-15 23:07:53 +01:00
|
|
|
meta = with lib; {
|
2020-03-17 11:26:27 +01: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 ];
|
2021-02-12 21:28:22 +01:00
|
|
|
#In file included from kernel/driver.cc:20:
|
|
|
|
#./kernel/yosys.h:42:10: fatal error: 'map' file not found
|
|
|
|
##include <map>
|
|
|
|
|
|
|
|
#https://github.com/YosysHQ/yosys/issues/681
|
|
|
|
#https://github.com/YosysHQ/yosys/issues/2011
|
|
|
|
broken = stdenv.isDarwin;
|
2015-12-29 17:31:18 +01:00
|
|
|
};
|
|
|
|
}
|