Skip to content

Commit a664b81

Browse files
committed
Update verilator to 5.038
Signed-off-by: Leo Moser <[email protected]>
1 parent c239a76 commit a664b81

File tree

1 file changed

+78
-18
lines changed

1 file changed

+78
-18
lines changed

nix/verilator.nix

Lines changed: 78 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023 Efabless Corporation
1+
# Copyright 2025 Ciel Contributors
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414
# Code adapated from nixpkgs, original license follows
1515
# ---
16-
# Copyright (c) 2003-2023 Eelco Dolstra and the Nixpkgs/NixOS contributors
16+
# Copyright (c) 2003-2025 Eelco Dolstra and the Nixpkgs/NixOS contributors
1717
#
1818
# Permission is hereby granted, free of charge, to any person obtaining
1919
# a copy of this software and associated documentation files (the
@@ -34,59 +34,119 @@
3434
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
3535
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3636
{
37-
clangStdenv,
37+
lib,
38+
stdenv,
3839
fetchFromGitHub,
3940
perl,
40-
makeWrapper,
4141
flex,
4242
bison,
4343
python3,
4444
autoconf,
45-
help2man,
4645
which,
46+
help2man,
47+
makeWrapper,
48+
systemc,
49+
git,
50+
numactl,
51+
coreutils,
52+
gdb,
4753
glibcLocales,
48-
lib,
49-
version ? "v5.018",
54+
version ? "5.038",
5055
rev ? null,
51-
sha256 ? "sha256-f06UzNw2MQ5me03EPrVFhkwxKum/GLDzQbDNTBsJMJs=",
56+
sha256 ? "sha256-uPGVE7y3zm+5ZydGjd1+/kIjW+a5u6d+YzjUSE4KnCY=",
5257
}:
53-
clangStdenv.mkDerivation {
58+
59+
stdenv.mkDerivation rec {
5460
pname = "verilator";
5561
inherit version;
5662

63+
# Verilator gets the version from this environment variable
64+
# if it can't do git describe while building.
65+
VERILATOR_SRC_VERSION = "v${version}";
66+
5767
src = fetchFromGitHub {
5868
owner = "verilator";
5969
repo = "verilator";
6070
rev =
6171
if rev == null
62-
then version
72+
then "v${version}"
6373
else rev;
6474
inherit sha256;
6575
};
6676

6777
enableParallelBuilding = true;
68-
buildInputs = [perl];
69-
nativeBuildInputs = [makeWrapper flex bison python3 autoconf help2man];
70-
nativeCheckInputs = [which];
78+
buildInputs = [
79+
perl
80+
systemc
81+
(python3.withPackages (
82+
pp: with pp; [
83+
distro
84+
]
85+
))
86+
# ccache
87+
];
88+
nativeBuildInputs = [
89+
makeWrapper
90+
flex
91+
bison
92+
autoconf
93+
help2man
94+
git
95+
]
96+
++ lib.optionals stdenv.hostPlatform.isLinux [
97+
gdb
98+
];
99+
100+
nativeCheckInputs = [
101+
which
102+
coreutils
103+
# cmake
104+
python3
105+
]
106+
++ lib.optionals stdenv.hostPlatform.isLinux [
107+
numactl
108+
];
109+
110+
doCheck = true;
111+
checkTarget = "test";
71112

72113
preConfigure = "autoconf";
73114

74115
postPatch = ''
75-
patchShebangs bin/* src/{flexfix,vlcovgen}
116+
patchShebangs bin/* src/* nodist/* docs/bin/* examples/xml_py/* \
117+
test_regress/{driver.py,t/*.{pl,pf}} \
118+
test_regress/t/t_a1_first_cc.py \
119+
test_regress/t/t_a2_first_sc.py \
120+
ci/* ci/docker/run/* ci/docker/run/hooks/* ci/docker/buildenv/build.sh
121+
# verilator --gdbbt uses /bin/echo to test if gdb works.
122+
substituteInPlace bin/verilator --replace-fail "/bin/echo" "${coreutils}/bin/echo"
123+
'';
124+
# grep '^#!/' -R . | grep -v /nix/store | less
125+
# (in nix-shell after patchPhase)
126+
127+
# This is needed to ensure that the check phase can find the verilator_bin_dbg.
128+
preCheck = ''
129+
export PATH=$PWD/bin:$PATH
76130
'';
77131

78-
postInstall = lib.optionalString clangStdenv.isLinux ''
132+
env = {
133+
SYSTEMC_INCLUDE = "${lib.getDev systemc}/include";
134+
SYSTEMC_LIBDIR = "${lib.getLib systemc}/lib";
135+
};
136+
137+
postInstall = lib.optionalString stdenv.isLinux ''
79138
for x in $(ls $out/bin/verilator*); do
80139
wrapProgram "$x" --set LOCALE_ARCHIVE "${glibcLocales}/lib/locale/locale-archive"
81140
done
82141
'';
83142

84-
doCheck = false;
85-
86143
meta = with lib; {
87144
description = "Fast and robust (System)Verilog simulator/compiler and linter";
88145
homepage = "https://www.veripool.org/verilator";
89-
license = with licenses; [lgpl3Only artistic2];
146+
license = with licenses; [
147+
lgpl3Only
148+
artistic2
149+
];
90150
platforms = platforms.unix;
91151
};
92152
}

0 commit comments

Comments
 (0)