1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Danny Milosavljevic <dannym@scratchpost.org>
3 ;;; Copyright © 2016, 2017 Theodoros Foradis <theodoros@foradis.org>
4 ;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2019 Amin Bandali <bandali@gnu.org>
6 ;;; Copyright © 2020 Vinicius Monego <monego@posteo.net>
7 ;;; Copyright © 2021 Andrew Miloradovsky <andrew@interpretmath.pw>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu packages fpga)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix git-download)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix build-system cmake)
31 #:use-module (guix build-system python)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages autotools)
34 #:use-module (gnu packages base)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages pkg-config)
37 #:use-module (gnu packages tcl)
38 #:use-module (gnu packages readline)
39 #:use-module (gnu packages python)
40 #:use-module (gnu packages python-xyz)
41 #:use-module (gnu packages bison)
42 #:use-module (gnu packages check)
43 #:use-module (gnu packages flex)
44 #:use-module (gnu packages gettext)
45 #:use-module (gnu packages gtk)
46 #:use-module (gnu packages graphviz)
47 #:use-module (gnu packages libffi)
48 #:use-module (gnu packages linux)
49 #:use-module (gnu packages llvm)
50 #:use-module (gnu packages maths)
51 #:use-module (gnu packages perl)
52 #:use-module (gnu packages ghostscript)
53 #:use-module (gnu packages gperf)
54 #:use-module (gnu packages gawk)
55 #:use-module (gnu packages version-control)
56 #:use-module (gnu packages qt)
57 #:use-module (gnu packages boost)
58 #:use-module (gnu packages algebra)
59 #:use-module (gnu packages libftdi))
62 (let ((commit "5ae4b975c49c")
66 (version (git-version "0.0" revision commit))
70 (string-append "https://bitbucket.org/alanmi/abc/get/" commit ".zip"))
71 (file-name (string-append name "-" version "-checkout.zip"))
74 "1syygi1x40rdryih3galr4q8yg1w5bvdzl75hd27v1xq0l5bz3d0"))))
75 (build-system gnu-build-system)
81 `(#:tests? #f ; no check target
83 (modify-phases %standard-phases
86 (lambda* (#:key outputs #:allow-other-keys)
87 (let* ((out (assoc-ref outputs "out"))
88 (out-bin (string-append out "/bin")))
89 (install-file "abc" out-bin)))))))
90 (home-page "https://people.eecs.berkeley.edu/~alanmi/abc/")
91 (synopsis "Sequential logic synthesis and formal verification")
92 (description "ABC is a program for sequential logic synthesis and
93 formal verification.")
95 (license:non-copyleft "https://fedoraproject.org/wiki/Licensing:MIT#Modern_Variants")))))
97 (define-public iverilog
104 (string-append "ftp://ftp.icarus.com/pub/eda/verilog/v10/"
105 "verilog-" version ".tar.gz"))
108 "1vv88ckvfwq7mrysyjnilsrcrzm9d173kp9w5ivwh6rdw7klbgc6"))))
109 (build-system gnu-build-system)
111 (list flex bison ghostscript)) ; ps2pdf
112 (home-page "http://iverilog.icarus.com/")
113 (synopsis "FPGA Verilog simulation and synthesis tool")
114 (description "Icarus Verilog is a Verilog simulation and synthesis tool.
115 It operates as a compiler, compiling source code written in Verilog
116 (IEEE-1364) into some target format.
117 For batch simulation, the compiler can generate an intermediate form
119 This intermediate form is executed by @command{vvp}.
120 For synthesis, the compiler generates netlists in the desired format.")
121 ;; GPL2 only because of:
122 ;; - ./driver/iverilog.man.in
123 ;; - ./iverilog-vpi.man.in
124 ;; - ./tgt-fpga/iverilog-fpga.man
125 ;; - ./vvp/vvp.man.in
126 ;; Otherwise would be GPL2+.
127 ;; You have to accept both GPL2 and LGPL2.1+.
128 (license (list license:gpl2 license:lgpl2.1+))))
137 (url "https://github.com/cliffordwolf/yosys")
138 (commit (string-append "yosys-" version))
139 (recursive? #t))) ; for the ‘iverilog’ submodule
142 "0lb9r055h8y1vj2z8gm4ip0v06j5mk7f9zx9gi67kkqb7g4rhjli"))
143 (file-name (git-file-name name version))
144 (modules '((guix build utils)))
147 (substitute* "Makefile"
148 (("ABCREV = .*") "ABCREV = default\n"))
150 (build-system gnu-build-system)
152 `(#:test-target "test"
153 #:make-flags (list "CC=gcc"
155 (string-append "PREFIX=" %output))
157 (modify-phases %standard-phases
158 (add-before 'configure 'fix-paths
160 (substitute* "./passes/cmds/show.cc"
161 (("exec xdot") (string-append "exec " (which "xdot")))
162 (("dot -") (string-append (which "dot") " -"))
163 (("fuser") (which "fuser")))
166 (lambda* (#:key inputs (make-flags '()) #:allow-other-keys)
167 (apply invoke "make" "config-gcc" make-flags)))
168 (add-after 'configure 'prepare-abc
169 (lambda* (#:key inputs #:allow-other-keys)
170 (let* ((sourceabc (assoc-ref inputs "abc"))
171 (sourcebin (string-append sourceabc "/bin"))
172 (source (string-append sourcebin "/abc")))
174 (call-with-output-file "abc/Makefile"
176 (format port ".PHONY: all\nall:\n\tcp -f abc abc-default\n")))
177 (copy-file source "abc/abc")
178 (invoke "chmod" "+w" "abc/abc"))))
179 (add-before 'check 'fix-iverilog-references
180 (lambda* (#:key inputs native-inputs #:allow-other-keys)
181 (let* ((xinputs (or native-inputs inputs))
182 (xdirname (assoc-ref xinputs "iverilog"))
183 (iverilog (string-append xdirname "/bin/iverilog")))
184 (substitute* '("./manual/CHAPTER_StateOfTheArt/synth.sh"
185 "./manual/CHAPTER_StateOfTheArt/validate_tb.sh"
186 "./techlibs/ice40/tests/test_bram.sh"
187 "./techlibs/ice40/tests/test_ffs.sh"
188 "./techlibs/xilinx/tests/bram1.sh"
189 "./techlibs/xilinx/tests/bram2.sh"
190 "./tests/bram/run-single.sh"
191 "./tests/realmath/run-test.sh"
192 "./tests/simple/run-test.sh"
193 "./tests/techmap/mem_simple_4x1_runtest.sh"
194 "./tests/tools/autotest.sh"
195 "./tests/vloghtb/common.sh")
196 (("if ! which iverilog") "if ! true")
197 (("iverilog ") (string-append iverilog " "))
198 (("iverilog_bin=\".*\"") (string-append "iverilog_bin=\""
206 gawk ; for the tests and "make" progress pretty-printing
207 tcl ; tclsh for the tests
208 iverilog)) ; for the tests
218 (list z3)) ; should be in path for yosys-smtbmc
219 (home-page "http://www.clifford.at/yosys/")
220 (synopsis "FPGA Verilog RTL synthesizer")
221 (description "Yosys synthesizes Verilog-2005.")
222 (license license:isc)))
224 (define-public icestorm
225 (let ((commit "0ec00d892a91cc68e45479b46161f649caea2933")
229 (version (git-version "0.0" revision commit))
233 (url "https://github.com/cliffordwolf/icestorm")
235 (file-name (git-file-name name version))
238 "1qlh99fafb7xga702k64fmc9m700nsddrfgcq4x8qn8fplsb64f1"))))
239 (build-system gnu-build-system)
241 `(#:tests? #f ; no unit tests that don't need an FPGA exist.
242 #:make-flags (list "CC=gcc" "CXX=g++"
243 (string-append "PREFIX=" (assoc-ref %outputs "out")))
245 (modify-phases %standard-phases
246 (add-after 'unpack 'remove-usr-local
248 (substitute* "iceprog/Makefile"
249 (("-I/usr/local/include") "")
250 (("-L/usr/local/lib") ""))
252 (add-after 'remove-usr-local 'fix-usr-local
253 (lambda* (#:key outputs #:allow-other-keys)
254 (substitute* "icebox/icebox_vlog.py"
255 (("/usr/local/share") (string-append (assoc-ref outputs "out") "/share")))
257 (delete 'configure))))
261 `(("python-3" ,python)
262 ("pkg-config" ,pkg-config)))
263 (home-page "http://www.clifford.at/icestorm/")
264 (synopsis "Project IceStorm - Lattice iCE40 FPGAs bitstream tools")
265 (description "Project IceStorm - Lattice iCE40 FPGAs Bitstream Tools.
266 Includes the actual FTDI connector.")
267 (license license:isc))))
269 (define-public nextpnr-ice40
270 (let [(commit "fbe486df459909065d6852a7495a212dfd2accef")
273 (name "nextpnr-ice40")
274 (version (git-version "0.0.0" revision commit))
279 (url "git://github.com/YosysHQ/nextpnr")
281 (file-name (git-file-name name version))
284 "1fmxsywgs45g88ra7ips5s2niiiwrkyxdcy742ws18dfk2y4vi9c"))))
292 (build-system cmake-build-system)
294 `(#:configure-flags `("-DARCH=ice40"
295 ,(string-append "-DICEBOX_ROOT="
296 (assoc-ref %build-inputs "icestorm")
299 (synopsis "Place-and-Route tool for FPGAs")
300 (description "Nextpnr aims to be a vendor neutral, timing driven,
301 FOSS FPGA place and route tool.")
302 (home-page "https://github.com/YosysHQ/nextpnr")
303 (license license:expat))))
305 (define-public arachne-pnr
306 (let ((commit "840bdfdeb38809f9f6af4d89dd7b22959b176fdd")
310 (version (string-append "0.0-" revision "-" (string-take commit 9)))
314 (url "https://github.com/YosysHQ/arachne-pnr")
316 (file-name (git-file-name name version))
319 "1dqvjvgvsridybishv4pnigw9gypxh7r7nrqp9z9qq92v7c5rxzl"))))
320 (build-system gnu-build-system)
322 `(#:test-target "test"
324 (list (string-append "DESTDIR=" (assoc-ref %outputs "out"))
325 (string-append "ICEBOX=" (string-append
326 (assoc-ref %build-inputs "icestorm")
328 #:phases (modify-phases %standard-phases
330 (lambda* (#:key outputs inputs #:allow-other-keys)
331 (substitute* '("./tests/fsm/generate.py"
332 "./tests/combinatorial/generate.py")
333 (("#!/usr/bin/python") "#!/usr/bin/python2"))
338 `(("git" ,git) ; for determining its own version string
339 ("yosys" ,yosys) ; for tests
340 ("perl" ,perl) ; for shasum
341 ("python-2" ,python-2))) ; for tests
342 (home-page "https://github.com/YosysHQ/arachne-pnr")
343 (synopsis "Place-and-Route tool for FPGAs")
344 (description "Arachne-PNR is a Place-and-Route Tool For FPGAs.")
345 (license license:gpl2))))
347 (define-public gtkwave
354 (uri (list (string-append "mirror://sourceforge/gtkwave/"
355 "gtkwave-" version "/"
356 "gtkwave-" version ".tar.gz")
357 (string-append "http://gtkwave.sourceforge.net/"
358 "gtkwave-" version ".tar.gz")))
360 (base32 "15n2gv2hd7h23cci95ij7yr71fkxppb209sfdsmmngh3fik09rpn"))))
361 (build-system gnu-build-system)
363 (list gperf pkg-config))
370 (list (string-append "--with-tcl="
371 (assoc-ref %build-inputs "tcl")
373 (string-append "--with-tk="
374 (assoc-ref %build-inputs "tk")
377 (synopsis "Waveform viewer for FPGA simulator trace files")
378 (description "This package is a waveform viewer for FPGA
379 simulator trace files (@dfn{FST}).")
380 (home-page "http://gtkwave.sourceforge.net/")
381 ;; Exception against free government use in tcl_np.c and tcl_np.h.
382 (license (list license:gpl2+ license:expat license:tcl/tk))))
384 (define-public python-migen
386 (name "python-migen")
390 ;; Tests fail in the PyPI tarball due to missing files.
393 (url "https://github.com/m-labs/migen")
395 (file-name (git-file-name name version))
397 (base32 "1kq11if64zj84gv4w1q7l16fp17xjxl2wv5hc9dibr1z3m1gy67l"))))
398 (build-system python-build-system)
400 (list python-colorama))
401 (home-page "https://m-labs.hk/gateware/migen/")
402 (synopsis "Python toolbox for building complex digital hardware")
404 "Migen FHDL is a Python library that replaces the event-driven
405 paradigm of Verilog and VHDL with the notions of combinatorial and
406 synchronous statements, has arithmetic rules that make integers always
407 behave like mathematical integers, and allows the design's logic to be
408 constructed by a Python program.")
409 (license license:bsd-2)))
411 (define-public python-myhdl
413 (name "python-myhdl")
418 (uri (pypi-uri "myhdl" version))
421 "04fi59cyn5dsci0ai7djg74ybkqfcjzhj1jfmac2xanbcrw9j3yk"))))
422 (build-system python-build-system)
423 (home-page "http://www.myhdl.org/")
424 (synopsis "Python as a Hardware Description Language")
425 (description "This package provides a library to turn Python into
426 a hardware description and verification language. ")
427 (license license:lgpl2.1+)))
436 (url "https://github.com/nickg/nvc.git")
437 (commit (string-append "r" version))))
438 (file-name (string-append name "-" version "-checkout"))
441 "1gjpwblp8isplyad3b6fl7cb5qv1rn3lf9qgf4l139y97cp2mm4s"))))
442 (build-system gnu-build-system)
447 (modify-phases %standard-phases
448 (add-after 'unpack 'clean-up
450 (delete-file "autogen.sh"))))))
459 check)) ; for the tests
462 (synopsis "VHDL compiler and simulator")
463 (description "This package provides a VHDL compiler and simulator.")
464 (home-page "https://github.com/nickg/nvc")
465 (license license:gpl3+)))
467 (define-public systemc
475 "https://accellera.org/images/downloads/standards/"
476 "systemc/systemc-" version ".tar.gz"))
478 (base32 "0gvv3xmhiwx1izmzy06yslzqzh6ygrgmw53xqfmyvbz5a6ivk0ap"))))
479 (native-inputs (list perl))
480 (build-system gnu-build-system)
481 (arguments '(#:configure-flags '("--enable-debug")))
482 (home-page "https://accellera.org/community/systemc")
483 (synopsis "Library for event-driven simulation")
485 "SystemC is a C++ library for modeling concurrent systems, and the
486 reference implementation of IEEE 1666-2011. It provides a notion of timing as
487 well as an event-driven simulations environment. Due to its concurrent and
488 sequential nature, SystemC allows the description and integration of complex
489 hardware and software components. To some extent, SystemC can be seen as
490 a Hardware Description Language. However, unlike VHDL or Verilog, SystemC
491 provides sophisticated mechanisms that offer high abstraction levels on
492 components interfaces. This, in turn, facilitates the integration of systems
493 using different abstraction levels.")
494 ;; homepages.cae.wisc.edu/~ece734/SystemC/Esperan_SystemC_tutorial.pdf
495 (license license:asl2.0)))
497 (define-public verilator
505 (url "https://github.com/verilator/verilator")
506 (commit (string-append "v" version))))
507 (file-name (git-file-name name version))
509 (base32 "0cji5c8870h895l2vxnz8g6z7msv23dzbjaf98va7kva0qlfy2fz"))))
511 `(("autoconf" ,autoconf)
512 ("automake" ,automake)
515 ("gettext" ,gettext-minimal)
519 (build-system gnu-build-system)
522 (list (string-append "LDFLAGS=-L"
523 (assoc-ref %build-inputs "systemc")
526 (list (string-append "LDFLAGS=-L"
527 (assoc-ref %build-inputs "systemc")
530 (modify-phases %standard-phases
532 (lambda _ (invoke "autoconf"))))
533 #:test-target "test"))
534 ;; #error "Something failed during ./configure as config_build.h is incomplete.
535 ;; Perhaps you used autoreconf, don't." -- so we won't. ^^
536 (home-page "https://www.veripool.org/projects/verilator/")
537 (synopsis "Fast Verilog/SystemVerilog simulator")
539 "Verilator is invoked with parameters similar to GCC or Synopsys’s VCS.
540 It ``Verilates'' the specified Verilog or SystemVerilog code by reading it,
541 performing lint checks, and optionally inserting assertion checks and
542 coverage-analysis points. It outputs single- or multi-threaded @file{.cpp}
543 and @file{.h} files, the ``Verilated'' code.
545 The user writes a little C++/SystemC wrapper file, which instantiates the
546 Verilated model of the user’s top level module. These C++/SystemC files are
547 then compiled by a C++ compiler (GCC/Clang/etc.). The resulting executable
548 performs the design simulation. Verilator also supports linking its generated
549 libraries, optionally encrypted, into other simulators.")
550 (license license:lgpl3)))