at master 2.3 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchFromGitHub, 5 pkg-config, 6 antlr4, 7 capnproto, 8 readline, 9 surelog, 10 uhdm, 11 yosys, 12}: 13 14stdenv.mkDerivation (finalAttrs: { 15 pname = "yosys-synlig"; 16 plugin = "synlig"; 17 18 # The module has automatic regular releases, with date + short git hash 19 GIT_VERSION = "2024-12-10-2d838ed"; 20 21 # Derive our package version from GIT_VERSION, remove hash, just keep date. 22 version = builtins.concatStringsSep "-" (lib.take 3 (builtins.splitVersion finalAttrs.GIT_VERSION)); 23 24 src = fetchFromGitHub { 25 owner = "chipsalliance"; 26 repo = "synlig"; 27 rev = "${finalAttrs.GIT_VERSION}"; 28 hash = "sha256-MsnRraAqsIkJ2PjBfoSrvUX/RHtL+FV2+iB3i7galLI="; 29 fetchSubmodules = false; # we use all dependencies from nix 30 }; 31 32 nativeBuildInputs = [ 33 pkg-config 34 ]; 35 36 buildInputs = [ 37 antlr4.runtime.cpp 38 capnproto 39 readline 40 surelog 41 uhdm 42 yosys 43 ]; 44 45 buildPhase = '' 46 runHook preBuild 47 48 # Remove assumptions that submodules are available. 49 rm -f third_party/Build.*.mk 50 51 # Create a stub makefile include that delegates the parameter-gathering 52 # to yosys-config 53 cat > third_party/Build.yosys.mk << "EOF" 54 t := yosys 55 ts := ''$(call GetTargetStructName,''${t}) 56 57 ''${ts}.src_dir := ''$(shell yosys-config --datdir/include) 58 ''${ts}.mod_dir := ''${TOP_DIR}third_party/yosys_mod/ 59 EOF 60 61 make -j $NIX_BUILD_CORES build@systemverilog-plugin \ 62 LDFLAGS="''$(yosys-config --ldflags --ldlibs)" 63 runHook postBuild 64 ''; 65 66 # Check that the plugin can be loaded successfully and parse simple file. 67 doCheck = true; 68 checkPhase = '' 69 runHook preCheck 70 echo "module litmustest(); endmodule;" > litmustest.sv 71 yosys -p "plugin -i build/release/systemverilog-plugin/systemverilog.so;\ 72 read_systemverilog litmustest.sv" 73 runHook postCheck 74 ''; 75 76 installPhase = '' 77 runHook preInstall 78 mkdir -p $out/share/yosys/plugins 79 cp ./build/release/systemverilog-plugin/systemverilog.so \ 80 $out/share/yosys/plugins/systemverilog.so 81 runHook postInstall 82 ''; 83 84 meta = with lib; { 85 description = "SystemVerilog support plugin for Yosys"; 86 homepage = "https://github.com/chipsalliance/synlig"; 87 license = licenses.asl20; 88 maintainers = with maintainers; [ hzeller ]; 89 platforms = platforms.all; 90 }; 91})