Skip to content

Commit c239a76

Browse files
authored
feat: Add Icarus Verilog (#27)
- Add the latest version of Icarus Verilog since the last tagged version is v12_0 from Dec 27, 2022. Signed-off-by: Leo Moser <[email protected]>
1 parent 956b41d commit c239a76

File tree

3 files changed

+135
-0
lines changed

3 files changed

+135
-0
lines changed

Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ We compile and cache the tools for the following platforms:
2525
* [GDSFactory](https://github.com/gdsfactory/gdsfactory)
2626
* (+ `klayout-gdsfactory` as a shorthand for an environment with both installed)
2727
* [Verilator](https://verilator.org)
28+
* [Icarus Verilog](https://github.com/steveicarus/iverilog)
2829
* [Xschem](https://xschem.sourceforge.io/stefan/index.html)
2930
* [Xyce](https://github.com/xyce/xyce)
3031
* Linux only.

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
klayout = callPackage ./nix/klayout.nix {};
105105
klayout-app = pkgs'.klayout; # alias, there's a python package called klayout (related) (thats also this)
106106
#
107+
iverilog = callPackage ./nix/iverilog.nix {};
107108
klayout-gdsfactory = callPackage ./nix/klayout-gdsfactory.nix {};
108109
tclFull = callPackage ./nix/tclFull.nix {};
109110
tk-x11 = callPackage ./nix/tk-x11.nix {};

nix/iverilog.nix

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Copyright 2025 Ciel Contributors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# Code adapated from nixpkgs, original license follows
15+
# ---
16+
# Copyright (c) 2003-2025 Eelco Dolstra and the Nixpkgs/NixOS contributors
17+
#
18+
# Permission is hereby granted, free of charge, to any person obtaining
19+
# a copy of this software and associated documentation files (the
20+
# "Software"), to deal in the Software without restriction, including
21+
# without limitation the rights to use, copy, modify, merge, publish,
22+
# distribute, sublicense, and/or sell copies of the Software, and to
23+
# permit persons to whom the Software is furnished to do so, subject to
24+
# the following conditions:
25+
#
26+
# The above copyright notice and this permission notice shall be
27+
# included in all copies or substantial portions of the Software.
28+
#
29+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
33+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
34+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
35+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36+
{
37+
lib,
38+
stdenv,
39+
fetchFromGitHub,
40+
fetchpatch,
41+
autoconf,
42+
bison,
43+
bzip2,
44+
flex,
45+
gperf,
46+
ncurses,
47+
perl,
48+
python3,
49+
readline,
50+
zlib,
51+
buildPackages,
52+
version ? "s20250103-60-gdb82380ce",
53+
rev ? "db82380cecf9943fcc397818e6899b7146442127",
54+
sha256 ? "sha256-0WA/SrHINtwv0UKX7Jjb8sjnXBfRIBoErK+MrdBwErg=",
55+
}:
56+
57+
stdenv.mkDerivation rec {
58+
pname = "iverilog";
59+
inherit version;
60+
61+
src = fetchFromGitHub {
62+
owner = "steveicarus";
63+
repo = "iverilog";
64+
rev =
65+
if rev == null
66+
then "v${lib.replaceStrings [ "." ] [ "_" ] version}"
67+
else rev;
68+
inherit sha256;
69+
};
70+
71+
nativeBuildInputs = [
72+
autoconf
73+
bison
74+
flex
75+
gperf
76+
];
77+
78+
CC_FOR_BUILD = "${buildPackages.stdenv.cc}/bin/cc";
79+
CXX_FOR_BUILD = "${buildPackages.stdenv.cc}/bin/c++";
80+
81+
patches = [
82+
];
83+
84+
buildInputs = [
85+
bzip2
86+
ncurses
87+
readline
88+
zlib
89+
];
90+
91+
preConfigure = "sh autoconf.sh";
92+
93+
enableParallelBuilding = true;
94+
95+
env = lib.optionalAttrs stdenv.hostPlatform.isDarwin {
96+
NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration";
97+
};
98+
99+
# NOTE(jleightcap): the `make check` target only runs a "Hello, World"-esque sanity check.
100+
# the tests in the doInstallCheck phase run a full regression test suite.
101+
# however, these tests currently fail upstream on aarch64
102+
# (see https://github.com/steveicarus/iverilog/issues/917)
103+
# so disable the full suite for now.
104+
doCheck = true;
105+
doInstallCheck = !stdenv.hostPlatform.isAarch64;
106+
107+
nativeInstallCheckInputs = [
108+
perl
109+
(python3.withPackages (
110+
pp: with pp; [
111+
docopt
112+
]
113+
))
114+
];
115+
116+
installCheckPhase = ''
117+
runHook preInstallCheck
118+
export PATH="$PATH:$out/bin"
119+
sh .github/test.sh
120+
runHook postInstallCheck
121+
'';
122+
123+
meta = with lib; {
124+
description = "Icarus Verilog compiler";
125+
homepage = "https://steveicarus.github.io/iverilog";
126+
license = with licenses; [
127+
gpl2Plus
128+
lgpl21Plus
129+
];
130+
maintainers = with maintainers; [ thoughtpolice ];
131+
platforms = platforms.all;
132+
};
133+
}

0 commit comments

Comments
 (0)