2023-10-19 13:55:26 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
2024-02-07 01:22:34 +00:00
|
|
|
, fetchpatch
|
2023-10-19 13:55:26 +00:00
|
|
|
, pkg-config
|
|
|
|
, antlr4
|
|
|
|
, capnproto
|
|
|
|
, readline
|
|
|
|
, surelog
|
|
|
|
, uhdm
|
|
|
|
, yosys
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
|
|
pname = "yosys-synlig";
|
|
|
|
plugin = "synlig";
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
# The module has automatic regular releases, with date + short git hash
|
2024-01-02 11:29:13 +00:00
|
|
|
GIT_VERSION = "2023-11-28-b8ed72d";
|
2023-11-16 04:20:00 +00:00
|
|
|
|
|
|
|
# Derive our package version from GIT_VERSION, remove hash, just keep date.
|
|
|
|
version = builtins.concatStringsSep "-" (
|
|
|
|
lib.take 3 (builtins.splitVersion finalAttrs.GIT_VERSION));
|
|
|
|
|
2023-10-19 13:55:26 +00:00
|
|
|
src = fetchFromGitHub {
|
2023-11-16 04:20:00 +00:00
|
|
|
owner = "chipsalliance";
|
|
|
|
repo = "synlig";
|
|
|
|
rev = "${finalAttrs.GIT_VERSION}";
|
2024-01-02 11:29:13 +00:00
|
|
|
hash = "sha256-jdA3PBodecqriGWU/BzWtQ5gyu62pZHv+1NvFrwsTTk=";
|
2023-10-19 13:55:26 +00:00
|
|
|
fetchSubmodules = false; # we use all dependencies from nix
|
|
|
|
};
|
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
# Fixes https://github.com/chipsalliance/synlig/issues/2299
|
|
|
|
name = "make-compile-for-yosys-0.37.patch";
|
|
|
|
url = "https://github.com/chipsalliance/synlig/commit/3dd46d4769c20b6dd1163310f8e56560b351a211.patch";
|
|
|
|
hash = "sha256-OP/2HA/Ukt6o5aKgoBk19P6T/33btU/x6VnoIVXct1g=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2023-10-19 13:55:26 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
antlr4.runtime.cpp
|
|
|
|
capnproto
|
|
|
|
readline
|
|
|
|
surelog
|
|
|
|
uhdm
|
|
|
|
yosys
|
|
|
|
];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2023-11-16 04:20:00 +00:00
|
|
|
|
|
|
|
# Remove assumptions that submodules are available.
|
|
|
|
rm -f third_party/Build.*.mk
|
|
|
|
|
|
|
|
# Create a stub makefile include that delegates the parameter-gathering
|
|
|
|
# to yosys-config
|
|
|
|
cat > third_party/Build.yosys.mk << "EOF"
|
|
|
|
t := yosys
|
|
|
|
ts := ''$(call GetTargetStructName,''${t})
|
|
|
|
|
|
|
|
''${ts}.src_dir := ''$(shell yosys-config --datdir/include)
|
|
|
|
''${ts}.mod_dir := ''${TOP_DIR}third_party/yosys_mod/
|
|
|
|
EOF
|
|
|
|
|
|
|
|
make -j $NIX_BUILD_CORES build@systemverilog-plugin \
|
|
|
|
LDFLAGS="''$(yosys-config --ldflags --ldlibs)"
|
2023-10-19 13:55:26 +00:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
# Check that the plugin can be loaded successfully and parse simple file.
|
2023-10-19 13:55:26 +00:00
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
2023-11-16 04:20:00 +00:00
|
|
|
echo "module litmustest(); endmodule;" > litmustest.sv
|
2023-10-19 13:55:26 +00:00
|
|
|
yosys -p "plugin -i build/release/systemverilog-plugin/systemverilog.so;\
|
2023-11-16 04:20:00 +00:00
|
|
|
read_systemverilog litmustest.sv"
|
2023-10-19 13:55:26 +00:00
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/share/yosys/plugins
|
|
|
|
cp ./build/release/systemverilog-plugin/systemverilog.so \
|
|
|
|
$out/share/yosys/plugins/systemverilog.so
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "SystemVerilog support plugin for Yosys";
|
|
|
|
homepage = "https://github.com/chipsalliance/synlig";
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = with maintainers; [ hzeller ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
})
|