From ec1830e696fce7a92e230ee28e6deb3c53bee1a1 Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Thu, 14 Jan 2021 23:52:24 -0600 Subject: [PATCH] init: experimental yosys-{bluespec, ghdl} plugins These plugins can be included in a closure, along with the `yosys` derivation, and they will be automatically picked up for use. For example, this allows you to include 'yosys-bluespec' in your `buildInputs`, and then immediately run: $ nix-shell -p yosys yosys-bluespec yosys-ghdl $ yosys -m bluespec -p 'help read_bluespec' $ yosys -m ghdl -p 'help ghdl' These two plugins are a bit experimental, admittedly, but they are good, clean examples of how to write and use the yosys plugin infrastructure, and make it easy to test updates, etc. Signed-off-by: Austin Seipp --- .../compilers/yosys/plugins/bluespec.nix | 32 +++++++++++++++++++ .../compilers/yosys/plugins/ghdl.nix | 31 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 3 files changed, 65 insertions(+) create mode 100644 pkgs/development/compilers/yosys/plugins/bluespec.nix create mode 100644 pkgs/development/compilers/yosys/plugins/ghdl.nix diff --git a/pkgs/development/compilers/yosys/plugins/bluespec.nix b/pkgs/development/compilers/yosys/plugins/bluespec.nix new file mode 100644 index 00000000000..ea67ffc661c --- /dev/null +++ b/pkgs/development/compilers/yosys/plugins/bluespec.nix @@ -0,0 +1,32 @@ +{ stdenv, lib, fetchFromGitHub, pkg-config +, yosys, readline, zlib, bluespec +}: + +stdenv.mkDerivation { + pname = "yosys-bluespec"; + version = "2021.01.14"; + + src = fetchFromGitHub { + owner = "thoughtpolice"; + repo = "yosys-bluespec"; + rev = "7a0c609e9b601560067c34b8ce41e89ea4a397d4"; + sha256 = "0xj9j5dwvq0dwqzfjd4ikmxkd28amj6d9m6ava7pwcrpjhyjnd0c"; + }; + + buildInputs = [ yosys readline zlib bluespec ]; + nativeBuildInputs = [ pkg-config ]; + + doCheck = true; + makeFlags = [ + "PREFIX=$(out)/share/yosys/plugins" + "STATIC_BSC_PATH=${bluespec}/bin/bsc" + "STATIC_BSC_LIBDIR=${bluespec}/lib" + ]; + + meta = with lib; { + description = "Bluespec plugin for Yosys"; + license = licenses.isc; + platforms = platforms.all; + maintainers = with maintainers; [ thoughtpolice ]; + }; +} diff --git a/pkgs/development/compilers/yosys/plugins/ghdl.nix b/pkgs/development/compilers/yosys/plugins/ghdl.nix new file mode 100644 index 00000000000..ccf8efc7c80 --- /dev/null +++ b/pkgs/development/compilers/yosys/plugins/ghdl.nix @@ -0,0 +1,31 @@ +{ stdenv, lib, fetchFromGitHub, pkg-config +, yosys, readline, zlib, ghdl +}: + +stdenv.mkDerivation { + pname = "yosys-ghdl"; + version = "2021.01.01"; + + src = fetchFromGitHub { + owner = "ghdl"; + repo = "ghdl-yosys-plugin"; + rev = "8b3e740fef9a653a20a838f1ade475960e1d379b"; + sha256 = "13kpcp37r11xgqd8aksddi40a5vpzqi7p8qgyjbs99lyscyli75x"; + }; + + buildInputs = [ yosys readline zlib ghdl ]; + nativeBuildInputs = [ pkg-config ]; + + doCheck = true; + installPhase = '' + mkdir -p $out/share/yosys/plugins + cp ghdl.so $out/share/yosys/plugins/ghdl.so + ''; + + meta = with lib; { + description = "GHDL plugin for Yosys"; + license = licenses.isc; + platforms = platforms.all; + maintainers = with maintainers; [ thoughtpolice ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index efac18edc02..300aa516668 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10832,6 +10832,8 @@ in yasm = callPackage ../development/compilers/yasm { }; yosys = callPackage ../development/compilers/yosys { }; + yosys-bluespec = callPackage ../development/compilers/yosys/plugins/bluespec.nix { }; + yosys-ghdl = callPackage ../development/compilers/yosys/plugins/ghdl.nix { }; z88dk = callPackage ../development/compilers/z88dk { };