1{
2 fetchFromGitHub,
3 gtest,
4 lib,
5 python3,
6 readline,
7 stdenv,
8 yosys,
9 zlib,
10 yosys-symbiflow,
11 pkg-config,
12}:
13let
14
15 version = "1.20230906";
16
17 src = fetchFromGitHub {
18 owner = "chipsalliance";
19 repo = "yosys-f4pga-plugins";
20 rev = "v${version}";
21 hash = "sha256-XIn5wFw8i2njDN0Arua5BdZ0u1q6a/aJAs48YICehsc=";
22 };
23
24 # Supported symbiflow plugins.
25 #
26 # The following are disabled:
27 #
28 # "ql-qlf" builds but fails to load the plugin, so is not currently supported.
29 plugins = [
30 "design_introspection"
31 "fasm"
32 "integrateinv"
33 "params"
34 "ql-iob"
35 # "ql-qlf"
36 "sdc"
37 "xdc"
38 ];
39
40 static_gtest = gtest.overrideAttrs (old: {
41 dontDisableStatic = true;
42 disableHardening = [ "pie" ];
43 cmakeFlags = old.cmakeFlags ++ [ "-DBUILD_SHARED_LIBS=OFF" ];
44 });
45
46in
47lib.genAttrs plugins (
48 plugin:
49 stdenv.mkDerivation (rec {
50 pname = "yosys-symbiflow-${plugin}-plugin";
51 inherit src version plugin;
52 enableParallelBuilding = true;
53
54 nativeBuildInputs = [
55 python3
56 pkg-config
57 ];
58 buildInputs = [
59 yosys
60 readline
61 zlib
62 ];
63
64 # xdc has an incorrect path to a test which has yet to be patched
65 doCheck = plugin != "xdc";
66 nativeCheckInputs = [ static_gtest ];
67
68 # A Makefile rule tries to wget-fetch a yosys script from github.
69 # Link the script from our yosys sources in preBuild instead, so that
70 # the Makefile rule is a no-op.
71 preBuild = ''
72 ln -s ${yosys.src}/passes/pmgen/pmgen.py pmgen.py
73 '';
74
75 # Providing a symlink avoids the need for patching the test makefile
76 postUnpack = ''
77 mkdir -p source/third_party/googletest/build/
78 ln -s ${static_gtest}/lib source/third_party/googletest/build/lib
79 '';
80
81 makeFlags = [
82 "PLUGIN_LIST=${plugin}"
83 ];
84
85 buildFlags = [
86 "YOSYS_PLUGINS_DIR=\${out}/share/yosys/plugins/"
87 "YOSYS_DATA_DIR=\${out}/share/yosys/"
88 ];
89
90 checkTarget = "test";
91 checkFlags = [
92 (
93 "NIX_YOSYS_PLUGIN_DIRS=\${NIX_BUILD_TOP}/source/${plugin}-plugin/build"
94 # sdc and xdc plugins use design introspection for their tests
95 + (lib.optionalString (
96 plugin == "sdc" || plugin == "xdc"
97 ) ":${yosys-symbiflow.design_introspection}/share/yosys/plugins/")
98 )
99 ];
100
101 installFlags = buildFlags;
102
103 meta = with lib; {
104 description = "Symbiflow ${plugin} plugin for Yosys";
105 license = licenses.isc;
106 platforms = platforms.all;
107 maintainers = with maintainers; [
108 ollieB
109 thoughtpolice
110 ];
111 };
112 })
113)