summary refs log tree commit diff
diff options
context:
space:
mode:
authorOllieB <oliverbunting@gmail.com>2022-01-07 14:10:18 +0000
committerOllieB <oliverbunting@gmail.com>2022-01-08 14:48:28 +0000
commit12cc34ce2dd2f8d5973b91ca0c6c16d98f335fd6 (patch)
treefd2a6135356226f2b1e519f7bec258d320975eeb
parent204096332d6d21439ee835ce82fe814bdb7022ce (diff)
downloadnixpkgs-12cc34ce2dd2f8d5973b91ca0c6c16d98f335fd6.tar
nixpkgs-12cc34ce2dd2f8d5973b91ca0c6c16d98f335fd6.tar.gz
nixpkgs-12cc34ce2dd2f8d5973b91ca0c6c16d98f335fd6.tar.bz2
nixpkgs-12cc34ce2dd2f8d5973b91ca0c6c16d98f335fd6.tar.lz
nixpkgs-12cc34ce2dd2f8d5973b91ca0c6c16d98f335fd6.tar.xz
nixpkgs-12cc34ce2dd2f8d5973b91ca0c6c16d98f335fd6.tar.zst
nixpkgs-12cc34ce2dd2f8d5973b91ca0c6c16d98f335fd6.zip
yosys: Add yosys-symbiflow-plugins
-rw-r--r--maintainers/maintainer-list.nix6
-rw-r--r--pkgs/development/compilers/yosys/default.nix44
-rw-r--r--pkgs/development/compilers/yosys/plugins/bluespec.nix1
-rw-r--r--pkgs/development/compilers/yosys/plugins/ghdl.nix1
-rw-r--r--pkgs/development/compilers/yosys/plugins/symbiflow-pmgen.patch15
-rw-r--r--pkgs/development/compilers/yosys/plugins/symbiflow.nix106
-rw-r--r--pkgs/top-level/all-packages.nix1
7 files changed, 173 insertions, 1 deletions
diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix
index 48d8973e922..98242574fa7 100644
--- a/maintainers/maintainer-list.nix
+++ b/maintainers/maintainer-list.nix
@@ -8874,6 +8874,12 @@
     githubId = 72201;
     name = "Ole Jørgen Brønner";
   };
+  ollieB = {
+    email = "1237862+oliverbunting@users.noreply.github.com";
+    github = "oliverbunting";
+    githubId = 1237862;
+    name = "Ollie Bunting";
+  };
   olynch = {
     email = "owen@olynch.me";
     github = "olynch";
diff --git a/pkgs/development/compilers/yosys/default.nix b/pkgs/development/compilers/yosys/default.nix
index 8f7de873626..30b9b839398 100644
--- a/pkgs/development/compilers/yosys/default.nix
+++ b/pkgs/development/compilers/yosys/default.nix
@@ -6,13 +6,19 @@
 , fetchFromGitHub
 , flex
 , libffi
+, makeWrapper
 , pkg-config
 , protobuf
 , python3
 , readline
+, symlinkJoin
 , tcl
 , verilog
 , zlib
+, yosys
+, yosys-bluespec
+, yosys-ghdl
+, yosys-symbiflow
 }:
 
 # NOTE: as of late 2020, yosys has switched to an automation robot that
@@ -32,7 +38,39 @@
 # yosys version number helps users report better bugs upstream, and is
 # ultimately less confusing than using dates.
 
-stdenv.mkDerivation rec {
+let
+
+  # Provides a wrapper for creating a yosys with the specifed plugins preloaded
+  #
+  # Example:
+  #
+  #     my_yosys = yosys.withPlugins (with yosys.allPlugins; [
+  #        fasm
+  #        bluespec
+  #     ]);
+  withPlugins = plugins:
+    let
+      paths = lib.closePropagation plugins;
+      module_flags = with builtins; concatStringsSep " "
+        (map (n: "--add-flags -m --add-flags ${n.plugin}") plugins);
+    in lib.appendToName "with-plugins" ( symlinkJoin {
+      inherit (yosys) name;
+      paths = paths ++ [ yosys ] ;
+      buildInputs = [ makeWrapper ];
+      postBuild = ''
+        wrapProgram $out/bin/yosys \
+          --set NIX_YOSYS_PLUGIN_DIRS $out/share/yosys/plugins \
+          ${module_flags}
+      '';
+    });
+
+  allPlugins = {
+    bluespec = yosys-bluespec;
+    ghdl     = yosys-ghdl;
+  } // (yosys-symbiflow);
+
+
+in stdenv.mkDerivation rec {
   pname   = "yosys";
   version = "0.12+54";
 
@@ -99,6 +137,10 @@ stdenv.mkDerivation rec {
 
   setupHook = ./setup-hook.sh;
 
+  passthru = {
+    inherit withPlugins allPlugins;
+  };
+
   meta = with lib; {
     description = "Open RTL synthesis framework and tools";
     homepage    = "http://www.clifford.at/yosys/";
diff --git a/pkgs/development/compilers/yosys/plugins/bluespec.nix b/pkgs/development/compilers/yosys/plugins/bluespec.nix
index 519da019c25..77d4ad8cf9d 100644
--- a/pkgs/development/compilers/yosys/plugins/bluespec.nix
+++ b/pkgs/development/compilers/yosys/plugins/bluespec.nix
@@ -5,6 +5,7 @@
 stdenv.mkDerivation {
   pname = "yosys-bluespec";
   version = "2021.09.08";
+  plugin = "bluespec";
 
   src = fetchFromGitHub {
     owner  = "thoughtpolice";
diff --git a/pkgs/development/compilers/yosys/plugins/ghdl.nix b/pkgs/development/compilers/yosys/plugins/ghdl.nix
index 35f3ef2bcc8..0999f5ab34b 100644
--- a/pkgs/development/compilers/yosys/plugins/ghdl.nix
+++ b/pkgs/development/compilers/yosys/plugins/ghdl.nix
@@ -5,6 +5,7 @@
 stdenv.mkDerivation {
   pname = "yosys-ghdl";
   version = "2021.01.25";
+  plugin = "ghdl";
 
   src = fetchFromGitHub {
     owner  = "ghdl";
diff --git a/pkgs/development/compilers/yosys/plugins/symbiflow-pmgen.patch b/pkgs/development/compilers/yosys/plugins/symbiflow-pmgen.patch
new file mode 100644
index 00000000000..8af0f86a89b
--- /dev/null
+++ b/pkgs/development/compilers/yosys/plugins/symbiflow-pmgen.patch
@@ -0,0 +1,15 @@
+diff --git a/yql-qlf-plugin/Makefile b/ql-qlf-plugin/Makefile
+index 2819055c9fe..0e391581012 100644
+--- a/ql-qlf-plugin/Makefile
++++ b/ql-qlf-plugin/Makefile
+@@ -55,10 +55,6 @@ VERILOG_MODULES = $(COMMON)/cells_sim.v         \
+                   $(PP3_DIR)/mult_sim.v        \
+                   $(PP3_DIR)/qlal3_sim.v       \
+
+-retrieve-pmgen:=$(shell mkdir -p pmgen && wget -nc -O pmgen/pmgen.py https://raw.githubusercontent.com/SymbiFlow/yosys/master%2Bwip/passes/pmgen/pmgen.py)
+-
+-pre-build:=$(shell python3 pmgen/pmgen.py -o pmgen/ql-dsp-pm.h -p ql_dsp ql_dsp.pmg)
+-
+ install_modules: $(VERILOG_MODULES)
+ 	$(foreach f,$^,install -D $(f) $(DATA_DIR)/quicklogic/$(f);)
+
diff --git a/pkgs/development/compilers/yosys/plugins/symbiflow.nix b/pkgs/development/compilers/yosys/plugins/symbiflow.nix
new file mode 100644
index 00000000000..cecc1bee921
--- /dev/null
+++ b/pkgs/development/compilers/yosys/plugins/symbiflow.nix
@@ -0,0 +1,106 @@
+{ fetchFromGitHub
+, gtest
+, lib
+, python3
+, readline
+, stdenv
+, which
+, yosys
+, zlib
+, yosys-symbiflow
+}: let
+
+  src = fetchFromGitHub {
+    owner  = "SymbiFlow";
+    repo   = "yosys-symbiflow-plugins";
+    rev    = "35c6c33811a8de7c80dff6a7bcf7aa6ec9b21233";
+    hash   = "sha256-g5dX9+R+gWt8e7Bhbbg60O9qa+Vi6Ar0M1sHhYlAre8=";
+  };
+
+  version = "2022.01.06";
+
+  # Supported symbiflow plugins.
+  #
+  # The following are disabled:
+  #
+  # "ql-qlf" builds but fails to load the plugin, so is not currently supported.
+  #
+  # "UHDM" doesn't currently build, as the work to package UHDM and surelog has
+  # not (yet) been undertaken.
+  plugins = [
+    "design_introspection"
+    "fasm"
+    "integrateinv"
+    "params"
+    "ql-iob"
+    # "ql-qlf"
+    "sdc"
+    "xdc"
+    # "UHDM"
+  ];
+
+  static_gtest = gtest.dev.overrideAttrs (old: {
+    dontDisableStatic = true;
+    disableHardening = [ "pie" ];
+    cmakeFlags = old.cmakeFlags ++ ["-DBUILD_SHARED_LIBS=OFF"];
+  });
+
+in lib.genAttrs plugins (plugin: stdenv.mkDerivation (rec {
+  pname = "yosys-symbiflow-${plugin}-plugin";
+  inherit src version plugin;
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [ which python3 ];
+  buildInputs = [ yosys readline zlib ] ;
+
+  # xdc has an incorrect path to a test which has yet to be patched
+  doCheck = plugin != "xdc";
+  checkInputs = [ static_gtest ];
+
+  # ql-qlf tries to fetch a yosys script from github
+  # Run the script in preBuild instead.
+  patches = lib.optional ( plugin == "ql-qlf" ) ./symbiflow-pmgen.patch;
+
+  preBuild = ''
+    mkdir -p ql-qlf-plugin/pmgen
+  ''
+  + lib.optionalString ( plugin == "ql-qlf" ) ''
+    python3 ${yosys.src}/passes/pmgen/pmgen.py -o ql-qlf-plugin/pmgen/ql-dsp-pm.h -p ql_dsp ql-qlf-plugin/ql_dsp.pmg
+  '';
+
+  # Providing a symlink avoids the need for patching the test makefile
+  postUnpack = ''
+    mkdir -p source/third_party/googletest/googletest/build/
+    ln -s ${static_gtest}/lib source/third_party/googletest/googletest/build/lib
+  '';
+
+  makeFlags = [
+    "PLUGIN_LIST=${plugin}"
+  ];
+
+  buildFlags = [
+    "PLUGINS_DIR=\${out}/share/yosys/plugins/"
+    "DATA_DIR=\${out}/share/yosys/"
+  ];
+
+  checkFlags = [
+    "PLUGINS_DIR=\${NIX_BUILD_TOP}/source/${plugin}-plugin"
+    "DATA_DIR=\${NIX_BUILD_TOP}/source/${plugin}-plugin"
+    ( "NIX_YOSYS_PLUGIN_DIRS=\${NIX_BUILD_TOP}/source/${plugin}-plugin"
+      # sdc and xdc plugins use design introspection for their tests
+      + (lib.optionalString ( plugin == "sdc" || plugin == "xdc" )
+        ":${yosys-symbiflow.design_introspection}/share/yosys/plugins/")
+    )
+  ];
+
+  installFlags = buildFlags;
+
+  meta = with lib; {
+    description = "Symbiflow ${plugin} plugin for Yosys";
+    license     = licenses.isc;
+    platforms   = platforms.all;
+    maintainers = with maintainers; [ ollieB thoughtpolice ];
+  };
+}))
+
+
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index b04f94e9d66..45b329dad1f 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -13315,6 +13315,7 @@ with pkgs;
   yosys = callPackage ../development/compilers/yosys { };
   yosys-bluespec = callPackage ../development/compilers/yosys/plugins/bluespec.nix { };
   yosys-ghdl = callPackage ../development/compilers/yosys/plugins/ghdl.nix { };
+  yosys-symbiflow = callPackage ../development/compilers/yosys/plugins/symbiflow.nix { };
 
   z88dk = callPackage ../development/compilers/z88dk { };