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)
79 `(("readline" ,readline)))
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)
113 ("ghostscript" ,ghostscript))) ; ps2pdf
114 (home-page "http://iverilog.icarus.com/")
115 (synopsis "FPGA Verilog simulation and synthesis tool")
116 (description "Icarus Verilog is a Verilog simulation and synthesis tool.
117 It operates as a compiler, compiling source code written in Verilog
118 (IEEE-1364) into some target format.
119 For batch simulation, the compiler can generate an intermediate form
121 This intermediate form is executed by @command{vvp}.
122 For synthesis, the compiler generates netlists in the desired format.")
123 ;; GPL2 only because of:
124 ;; - ./driver/iverilog.man.in
125 ;; - ./iverilog-vpi.man.in
126 ;; - ./tgt-fpga/iverilog-fpga.man
127 ;; - ./vvp/vvp.man.in
128 ;; Otherwise would be GPL2+.
129 ;; You have to accept both GPL2 and LGPL2.1+.
130 (license (list license:gpl2 license:lgpl2.1+))))
139 (url "https://github.com/cliffordwolf/yosys")
140 (commit (string-append "yosys-" version))
141 (recursive? #t))) ; for the ‘iverilog’ submodule
144 "0lb9r055h8y1vj2z8gm4ip0v06j5mk7f9zx9gi67kkqb7g4rhjli"))
145 (file-name (git-file-name name version))
146 (modules '((guix build utils)))
149 (substitute* "Makefile"
150 (("ABCREV = .*") "ABCREV = default\n"))
152 (build-system gnu-build-system)
154 `(#:test-target "test"
155 #:make-flags (list "CC=gcc"
157 (string-append "PREFIX=" %output))
159 (modify-phases %standard-phases
160 (add-before 'configure 'fix-paths
162 (substitute* "./passes/cmds/show.cc"
163 (("exec xdot") (string-append "exec " (which "xdot")))
164 (("dot -") (string-append (which "dot") " -"))
165 (("fuser") (which "fuser")))
168 (lambda* (#:key inputs (make-flags '()) #:allow-other-keys)
169 (apply invoke "make" "config-gcc" make-flags)))
170 (add-after 'configure 'prepare-abc
171 (lambda* (#:key inputs #:allow-other-keys)
172 (let* ((sourceabc (assoc-ref inputs "abc"))
173 (sourcebin (string-append sourceabc "/bin"))
174 (source (string-append sourcebin "/abc")))
176 (call-with-output-file "abc/Makefile"
178 (format port ".PHONY: all\nall:\n\tcp -f abc abc-default\n")))
179 (copy-file source "abc/abc")
180 (invoke "chmod" "+w" "abc/abc"))))
181 (add-before 'check 'fix-iverilog-references
182 (lambda* (#:key inputs native-inputs #:allow-other-keys)
183 (let* ((xinputs (or native-inputs inputs))
184 (xdirname (assoc-ref xinputs "iverilog"))
185 (iverilog (string-append xdirname "/bin/iverilog")))
186 (substitute* '("./manual/CHAPTER_StateOfTheArt/synth.sh"
187 "./manual/CHAPTER_StateOfTheArt/validate_tb.sh"
188 "./techlibs/ice40/tests/test_bram.sh"
189 "./techlibs/ice40/tests/test_ffs.sh"
190 "./techlibs/xilinx/tests/bram1.sh"
191 "./techlibs/xilinx/tests/bram2.sh"
192 "./tests/bram/run-single.sh"
193 "./tests/realmath/run-test.sh"
194 "./tests/simple/run-test.sh"
195 "./tests/techmap/mem_simple_4x1_runtest.sh"
196 "./tests/tools/autotest.sh"
197 "./tests/vloghtb/common.sh")
198 (("if ! which iverilog") "if ! true")
199 (("iverilog ") (string-append iverilog " "))
200 (("iverilog_bin=\".*\"") (string-append "iverilog_bin=\""
204 `(("pkg-config" ,pkg-config)
208 ("gawk" , gawk) ; for the tests and "make" progress pretty-printing
209 ("tcl" ,tcl) ; tclsh for the tests
210 ("iverilog" ,iverilog))) ; for the tests
213 ("readline" ,readline)
215 ("graphviz" ,graphviz)
220 `(("z3" ,z3))) ; should be in path for yosys-smtbmc
221 (home-page "http://www.clifford.at/yosys/")
222 (synopsis "FPGA Verilog RTL synthesizer")
223 (description "Yosys synthesizes Verilog-2005.")
224 (license license:isc)))
226 (define-public icestorm
227 (let ((commit "0ec00d892a91cc68e45479b46161f649caea2933")
231 (version (git-version "0.0" revision commit))
235 (url "https://github.com/cliffordwolf/icestorm")
237 (file-name (git-file-name name version))
240 "1qlh99fafb7xga702k64fmc9m700nsddrfgcq4x8qn8fplsb64f1"))))
241 (build-system gnu-build-system)
243 `(#:tests? #f ; no unit tests that don't need an FPGA exist.
244 #:make-flags (list "CC=gcc" "CXX=g++"
245 (string-append "PREFIX=" (assoc-ref %outputs "out")))
247 (modify-phases %standard-phases
248 (add-after 'unpack 'remove-usr-local
250 (substitute* "iceprog/Makefile"
251 (("-I/usr/local/include") "")
252 (("-L/usr/local/lib") ""))
254 (add-after 'remove-usr-local 'fix-usr-local
255 (lambda* (#:key outputs #:allow-other-keys)
256 (substitute* "icebox/icebox_vlog.py"
257 (("/usr/local/share") (string-append (assoc-ref outputs "out") "/share")))
259 (delete 'configure))))
261 `(("libftdi" ,libftdi)))
263 `(("python-3" ,python)
264 ("pkg-config" ,pkg-config)))
265 (home-page "http://www.clifford.at/icestorm/")
266 (synopsis "Project IceStorm - Lattice iCE40 FPGAs bitstream tools")
267 (description "Project IceStorm - Lattice iCE40 FPGAs Bitstream Tools.
268 Includes the actual FTDI connector.")
269 (license license:isc))))
271 (define-public nextpnr-ice40
272 (let [(commit "fbe486df459909065d6852a7495a212dfd2accef")
275 (name "nextpnr-ice40")
276 (version (git-version "0.0.0" revision commit))
281 (url "git://github.com/YosysHQ/nextpnr")
283 (file-name (git-file-name name version))
286 "1fmxsywgs45g88ra7ips5s2niiiwrkyxdcy742ws18dfk2y4vi9c"))))
290 ("icestorm" ,icestorm)
294 (build-system cmake-build-system)
296 `(#:configure-flags `("-DARCH=ice40"
297 ,(string-append "-DICEBOX_ROOT="
298 (assoc-ref %build-inputs "icestorm")
301 (synopsis "Place-and-Route tool for FPGAs")
302 (description "Nextpnr aims to be a vendor neutral, timing driven,
303 FOSS FPGA place and route tool.")
304 (home-page "https://github.com/YosysHQ/nextpnr")
305 (license license:expat))))
307 (define-public arachne-pnr
308 (let ((commit "840bdfdeb38809f9f6af4d89dd7b22959b176fdd")
312 (version (string-append "0.0-" revision "-" (string-take commit 9)))
316 (url "https://github.com/YosysHQ/arachne-pnr")
318 (file-name (git-file-name name version))
321 "1dqvjvgvsridybishv4pnigw9gypxh7r7nrqp9z9qq92v7c5rxzl"))))
322 (build-system gnu-build-system)
324 `(#:test-target "test"
326 (list (string-append "DESTDIR=" (assoc-ref %outputs "out"))
327 (string-append "ICEBOX=" (string-append
328 (assoc-ref %build-inputs "icestorm")
330 #:phases (modify-phases %standard-phases
332 (lambda* (#:key outputs inputs #:allow-other-keys)
333 (substitute* '("./tests/fsm/generate.py"
334 "./tests/combinatorial/generate.py")
335 (("#!/usr/bin/python") "#!/usr/bin/python2"))
338 `(("icestorm" ,icestorm)))
340 `(("git" ,git) ; for determining its own version string
341 ("yosys" ,yosys) ; for tests
342 ("perl" ,perl) ; for shasum
343 ("python-2" ,python-2))) ; for tests
344 (home-page "https://github.com/YosysHQ/arachne-pnr")
345 (synopsis "Place-and-Route tool for FPGAs")
346 (description "Arachne-PNR is a Place-and-Route Tool For FPGAs.")
347 (license license:gpl2))))
349 (define-public gtkwave
356 (uri (list (string-append "mirror://sourceforge/gtkwave/"
357 "gtkwave-" version "/"
358 "gtkwave-" version ".tar.gz")
359 (string-append "http://gtkwave.sourceforge.net/"
360 "gtkwave-" version ".tar.gz")))
362 (base32 "0fzbap72zm4ka6n85j0873fpaarrx199ay0kjw1avrs20hs4gr7c"))))
363 (build-system gnu-build-system)
366 ("pkg-config" ,pkg-config)))
373 (list (string-append "--with-tcl="
374 (assoc-ref %build-inputs "tcl")
376 (string-append "--with-tk="
377 (assoc-ref %build-inputs "tk")
380 (synopsis "Waveform viewer for FPGA simulator trace files")
381 (description "This package is a waveform viewer for FPGA
382 simulator trace files (@dfn{FST}).")
383 (home-page "http://gtkwave.sourceforge.net/")
384 ;; Exception against free government use in tcl_np.c and tcl_np.h.
385 (license (list license:gpl2+ license:expat license:tcl/tk))))
387 (define-public python-migen
389 (name "python-migen")
393 ;; Tests fail in the PyPI tarball due to missing files.
396 (url "https://github.com/m-labs/migen")
398 (file-name (git-file-name name version))
400 (base32 "1kq11if64zj84gv4w1q7l16fp17xjxl2wv5hc9dibr1z3m1gy67l"))))
401 (build-system python-build-system)
403 `(("python-colorama" ,python-colorama)))
404 (home-page "https://m-labs.hk/gateware/migen/")
405 (synopsis "Python toolbox for building complex digital hardware")
407 "Migen FHDL is a Python library that replaces the event-driven
408 paradigm of Verilog and VHDL with the notions of combinatorial and
409 synchronous statements, has arithmetic rules that make integers always
410 behave like mathematical integers, and allows the design's logic to be
411 constructed by a Python program.")
412 (license license:bsd-2)))
414 (define-public python-myhdl
416 (name "python-myhdl")
421 (uri (pypi-uri "myhdl" version))
424 "04fi59cyn5dsci0ai7djg74ybkqfcjzhj1jfmac2xanbcrw9j3yk"))))
425 (build-system python-build-system)
426 (home-page "http://www.myhdl.org/")
427 (synopsis "Python as a Hardware Description Language")
428 (description "This package provides a library to turn Python into
429 a hardware description and verification language. ")
430 (license license:lgpl2.1+)))
439 (url "https://github.com/nickg/nvc.git")
440 (commit (string-append "r" version))))
441 (file-name (string-append name "-" version "-checkout"))
444 "0dd1xany6qhh2qsfw8ba0ky7y86h19yr4hlk0r5i2bvwsg4355v9"))))
445 (build-system gnu-build-system)
447 `(#:parallel-build? #f ; https://github.com/nickg/nvc/issues/409
451 (modify-phases %standard-phases
452 (add-after 'unpack 'clean-up
454 (delete-file "autogen.sh")
457 `(("automake" ,automake)
458 ("autoconf" ,autoconf)
460 ("gettext" ,gnu-gettext)
462 ("pkg-config" ,pkg-config)
464 ("check" ,check))) ; for the tests
467 (synopsis "VHDL compiler and simulator")
468 (description "This package provides a VHDL compiler and simulator.")
469 (home-page "https://github.com/nickg/nvc")
470 (license license:gpl3+)))
472 (define-public systemc
480 "https://accellera.org/images/downloads/standards/"
481 "systemc/systemc-" version ".tar.gz"))
483 (base32 "0gvv3xmhiwx1izmzy06yslzqzh6ygrgmw53xqfmyvbz5a6ivk0ap"))))
484 (native-inputs `(("perl" ,perl)))
485 (build-system gnu-build-system)
486 (arguments '(#:configure-flags '("--enable-debug")))
487 (home-page "https://accellera.org/community/systemc")
488 (synopsis "Library for event-driven simulation")
490 "SystemC is a C++ library for modeling concurrent systems, and the
491 reference implementation of IEEE 1666-2011. It provides a notion of timing as
492 well as an event-driven simulations environment. Due to its concurrent and
493 sequential nature, SystemC allows the description and integration of complex
494 hardware and software components. To some extent, SystemC can be seen as
495 a Hardware Description Language. However, unlike VHDL or Verilog, SystemC
496 provides sophisticated mechanisms that offer high abstraction levels on
497 components interfaces. This, in turn, facilitates the integration of systems
498 using different abstraction levels.")
499 ;; homepages.cae.wisc.edu/~ece734/SystemC/Esperan_SystemC_tutorial.pdf
500 (license license:asl2.0)))
502 (define-public verilator
510 (url "https://github.com/verilator/verilator")
511 (commit (string-append "v" version))))
512 (file-name (git-file-name name version))
514 (base32 "1lm2nyn7wzxj5y0ffwazhb4ygnmqf4d61sl937vmnmrpvdihsrrq"))))
516 `(("autoconf" ,autoconf)
517 ("automake" ,automake)
520 ("gettext" ,gettext-minimal)
524 ("systemc" ,systemc)))
525 (build-system gnu-build-system)
528 (list (string-append "LDFLAGS=-L"
529 (assoc-ref %build-inputs "systemc")
532 (list (string-append "LDFLAGS=-L"
533 (assoc-ref %build-inputs "systemc")
536 (modify-phases %standard-phases
538 (lambda _ (invoke "autoconf"))))
539 #:test-target "test"))
540 ;; #error "Something failed during ./configure as config_build.h is incomplete.
541 ;; Perhaps you used autoreconf, don't." -- so we won't. ^^
542 (home-page "https://www.veripool.org/projects/verilator/")
543 (synopsis "Fast Verilog/SystemVerilog simulator")
545 "Verilator is invoked with parameters similar to GCC or Synopsys’s VCS.
546 It ``Verilates'' the specified Verilog or SystemVerilog code by reading it,
547 performing lint checks, and optionally inserting assertion checks and
548 coverage-analysis points. It outputs single- or multi-threaded @file{.cpp}
549 and @file{.h} files, the ``Verilated'' code.
551 The user writes a little C++/SystemC wrapper file, which instantiates the
552 Verilated model of the user’s top level module. These C++/SystemC files are
553 then compiled by a C++ compiler (GCC/Clang/etc.). The resulting executable
554 performs the design simulation. Verilator also supports linking its generated
555 libraries, optionally encrypted, into other simulators.")
556 (license license:lgpl3)))