gnu: Add systemc.
[jackhill/guix/guix.git] / gnu / packages / fpga.scm
CommitLineData
adba5f08
DM
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016 Danny Milosavljevic <dannym@scratchpost.org>
d109b1e8 3;;; Copyright © 2016, 2017 Theodoros Foradis <theodoros@foradis.org>
91d2e6f9 4;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <me@tobias.gr>
c2cf286c 5;;; Copyright © 2019 Amin Bandali <bandali@gnu.org>
44a4810a 6;;; Copyright © 2020 Vinicius Monego <monego@posteo.net>
adba5f08
DM
7;;;
8;;; This file is part of GNU Guix.
9;;;
10;;; GNU Guix is free software; you can redistribute it and/or modify it
11;;; under the terms of the GNU General Public License as published by
12;;; the Free Software Foundation; either version 3 of the License, or (at
13;;; your option) any later version.
14;;;
15;;; GNU Guix is distributed in the hope that it will be useful, but
16;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;;; GNU General Public License for more details.
19;;;
20;;; You should have received a copy of the GNU General Public License
21;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23(define-module (gnu packages fpga)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system cmake)
2b5eaf0e 30 #:use-module (guix build-system python)
adba5f08 31 #:use-module (gnu packages)
492826ec
DM
32 #:use-module (gnu packages autotools)
33 #:use-module (gnu packages base)
148585c2 34 #:use-module (gnu packages compression)
adba5f08
DM
35 #:use-module (gnu packages pkg-config)
36 #:use-module (gnu packages tcl)
37 #:use-module (gnu packages readline)
38 #:use-module (gnu packages python)
44a4810a 39 #:use-module (gnu packages python-xyz)
adba5f08 40 #:use-module (gnu packages bison)
492826ec 41 #:use-module (gnu packages check)
adba5f08 42 #:use-module (gnu packages flex)
492826ec 43 #:use-module (gnu packages gettext)
adc2f048 44 #:use-module (gnu packages gtk)
f90f6b68 45 #:use-module (gnu packages graphviz)
adba5f08 46 #:use-module (gnu packages libffi)
f90f6b68 47 #:use-module (gnu packages linux)
492826ec 48 #:use-module (gnu packages llvm)
85cdab64 49 #:use-module (gnu packages maths)
adba5f08
DM
50 #:use-module (gnu packages perl)
51 #:use-module (gnu packages ghostscript)
adc2f048 52 #:use-module (gnu packages gperf)
adba5f08
DM
53 #:use-module (gnu packages gawk)
54 #:use-module (gnu packages version-control)
363989e6 55 #:use-module (gnu packages qt)
56 #:use-module (gnu packages boost)
57 #:use-module (gnu packages algebra)
adba5f08
DM
58 #:use-module (gnu packages libftdi))
59
60(define-public abc
61 (let ((commit "5ae4b975c49c")
62 (revision "1"))
63 (package
64 (name "abc")
ec299312 65 (version (git-version "0.0" revision commit))
adba5f08
DM
66 (source (origin
67 (method url-fetch)
68 (uri
69 (string-append "https://bitbucket.org/alanmi/abc/get/" commit ".zip"))
70 (file-name (string-append name "-" version "-checkout.zip"))
71 (sha256
ec299312
JK
72 (base32
73 "1syygi1x40rdryih3galr4q8yg1w5bvdzl75hd27v1xq0l5bz3d0"))))
adba5f08
DM
74 (build-system gnu-build-system)
75 (native-inputs
76 `(("unzip" ,unzip)))
77 (inputs
78 `(("readline" ,readline)))
79 (arguments
80 `(#:tests? #f ; no check target
81 #:phases
82 (modify-phases %standard-phases
83 (delete 'configure)
84 (replace 'install
85 (lambda* (#:key outputs #:allow-other-keys)
86 (let* ((out (assoc-ref outputs "out"))
87 (out-bin (string-append out "/bin")))
88 (install-file "abc" out-bin)))))))
3bc9f9e7 89 (home-page "https://people.eecs.berkeley.edu/~alanmi/abc/")
adba5f08
DM
90 (synopsis "Sequential logic synthesis and formal verification")
91 (description "ABC is a program for sequential logic synthesis and
92formal verification.")
93 (license
94 (license:non-copyleft "https://fedoraproject.org/wiki/Licensing:MIT#Modern_Variants")))))
44721336
DM
95
96(define-public iverilog
97 (package
98 (name "iverilog")
f27cb0f1 99 (version "10.3")
44721336
DM
100 (source (origin
101 (method url-fetch)
102 (uri
103 (string-append "ftp://ftp.icarus.com/pub/eda/verilog/v10/"
104 "verilog-" version ".tar.gz"))
105 (sha256
f27cb0f1
TGR
106 (base32
107 "1vv88ckvfwq7mrysyjnilsrcrzm9d173kp9w5ivwh6rdw7klbgc6"))))
44721336
DM
108 (build-system gnu-build-system)
109 (native-inputs
110 `(("flex" ,flex)
111 ("bison" ,bison)
f27cb0f1 112 ("ghostscript" ,ghostscript))) ; ps2pdf
44721336
DM
113 (home-page "http://iverilog.icarus.com/")
114 (synopsis "FPGA Verilog simulation and synthesis tool")
115 (description "Icarus Verilog is a Verilog simulation and synthesis tool.
116It operates as a compiler, compiling source code written in Verilog
117(IEEE-1364) into some target format.
118For batch simulation, the compiler can generate an intermediate form
119called vvp assembly.
77659ff3 120This intermediate form is executed by @command{vvp}.
44721336
DM
121For synthesis, the compiler generates netlists in the desired format.")
122 ;; GPL2 only because of:
123 ;; - ./driver/iverilog.man.in
124 ;; - ./iverilog-vpi.man.in
125 ;; - ./tgt-fpga/iverilog-fpga.man
126 ;; - ./vvp/vvp.man.in
127 ;; Otherwise would be GPL2+.
128 ;; You have to accept both GPL2 and LGPL2.1+.
129 (license (list license:gpl2 license:lgpl2.1+))))
92fc940f
DM
130
131(define-public yosys
132 (package
133 (name "yosys")
922c8486 134 (version "0.9")
92fc940f 135 (source (origin
21fc352b
TGR
136 (method git-fetch)
137 (uri (git-reference
b0e7b699 138 (url "https://github.com/cliffordwolf/yosys")
21fc352b
TGR
139 (commit (string-append "yosys-" version))
140 (recursive? #t))) ; for the ‘iverilog’ submodule
92fc940f
DM
141 (sha256
142 (base32
922c8486 143 "0lb9r055h8y1vj2z8gm4ip0v06j5mk7f9zx9gi67kkqb7g4rhjli"))
21fc352b 144 (file-name (git-file-name name version))
92fc940f
DM
145 (modules '((guix build utils)))
146 (snippet
6cbee49d
MW
147 '(begin
148 (substitute* "Makefile"
149 (("ABCREV = .*") "ABCREV = default\n"))
150 #t))))
92fc940f
DM
151 (build-system gnu-build-system)
152 (arguments
153 `(#:test-target "test"
154 #:make-flags (list "CC=gcc"
155 "CXX=g++"
156 (string-append "PREFIX=" %output))
157 #:phases
158 (modify-phases %standard-phases
f90f6b68
TF
159 (add-before 'configure 'fix-paths
160 (lambda _
161 (substitute* "./passes/cmds/show.cc"
162 (("exec xdot") (string-append "exec " (which "xdot")))
163 (("dot -") (string-append (which "dot") " -"))
164 (("fuser") (which "fuser")))
165 #t))
92fc940f
DM
166 (replace 'configure
167 (lambda* (#:key inputs (make-flags '()) #:allow-other-keys)
99f6ef9a 168 (apply invoke "make" "config-gcc" make-flags)))
92fc940f
DM
169 (add-after 'configure 'prepare-abc
170 (lambda* (#:key inputs #:allow-other-keys)
171 (let* ((sourceabc (assoc-ref inputs "abc"))
172 (sourcebin (string-append sourceabc "/bin"))
173 (source (string-append sourcebin "/abc")))
174 (mkdir-p "abc")
175 (call-with-output-file "abc/Makefile"
176 (lambda (port)
177 (format port ".PHONY: all\nall:\n\tcp -f abc abc-default\n")))
178 (copy-file source "abc/abc")
99f6ef9a 179 (invoke "chmod" "+w" "abc/abc"))))
92fc940f
DM
180 (add-before 'check 'fix-iverilog-references
181 (lambda* (#:key inputs native-inputs #:allow-other-keys)
182 (let* ((xinputs (or native-inputs inputs))
183 (xdirname (assoc-ref xinputs "iverilog"))
184 (iverilog (string-append xdirname "/bin/iverilog")))
185 (substitute* '("./manual/CHAPTER_StateOfTheArt/synth.sh"
186 "./manual/CHAPTER_StateOfTheArt/validate_tb.sh"
187 "./techlibs/ice40/tests/test_bram.sh"
188 "./techlibs/ice40/tests/test_ffs.sh"
189 "./techlibs/xilinx/tests/bram1.sh"
190 "./techlibs/xilinx/tests/bram2.sh"
191 "./tests/bram/run-single.sh"
192 "./tests/realmath/run-test.sh"
193 "./tests/simple/run-test.sh"
194 "./tests/techmap/mem_simple_4x1_runtest.sh"
195 "./tests/tools/autotest.sh"
196 "./tests/vloghtb/common.sh")
197 (("if ! which iverilog") "if ! true")
198 (("iverilog ") (string-append iverilog " "))
199 (("iverilog_bin=\".*\"") (string-append "iverilog_bin=\""
200 iverilog "\"")))
201 #t))))))
92fc940f
DM
202 (native-inputs
203 `(("pkg-config" ,pkg-config)
204 ("python" ,python)
205 ("bison" ,bison)
206 ("flex" ,flex)
207 ("gawk" , gawk) ; for the tests and "make" progress pretty-printing
208 ("tcl" ,tcl) ; tclsh for the tests
209 ("iverilog" ,iverilog))) ; for the tests
210 (inputs
211 `(("tcl" ,tcl)
212 ("readline" ,readline)
213 ("libffi" ,libffi)
f90f6b68
TF
214 ("graphviz" ,graphviz)
215 ("psmisc" ,psmisc)
216 ("xdot" ,xdot)
92fc940f 217 ("abc" ,abc)))
85cdab64
TF
218 (propagated-inputs
219 `(("z3" ,z3))) ; should be in path for yosys-smtbmc
92fc940f
DM
220 (home-page "http://www.clifford.at/yosys/")
221 (synopsis "FPGA Verilog RTL synthesizer")
222 (description "Yosys synthesizes Verilog-2005.")
223 (license license:isc)))
36aa11c7
DM
224
225(define-public icestorm
179be4bb 226 (let ((commit "0ec00d892a91cc68e45479b46161f649caea2933")
227 (revision "3"))
36aa11c7
DM
228 (package
229 (name "icestorm")
ec299312 230 (version (git-version "0.0" revision commit))
36aa11c7
DM
231 (source (origin
232 (method git-fetch)
233 (uri (git-reference
b0e7b699 234 (url "https://github.com/cliffordwolf/icestorm")
36aa11c7 235 (commit commit)))
ec299312 236 (file-name (git-file-name name version))
36aa11c7
DM
237 (sha256
238 (base32
179be4bb 239 "1qlh99fafb7xga702k64fmc9m700nsddrfgcq4x8qn8fplsb64f1"))))
36aa11c7
DM
240 (build-system gnu-build-system)
241 (arguments
242 `(#:tests? #f ; no unit tests that don't need an FPGA exist.
243 #:make-flags (list "CC=gcc" "CXX=g++"
244 (string-append "PREFIX=" (assoc-ref %outputs "out")))
245 #:phases
246 (modify-phases %standard-phases
247 (add-after 'unpack 'remove-usr-local
248 (lambda _
249 (substitute* "iceprog/Makefile"
250 (("-I/usr/local/include") "")
251 (("-L/usr/local/lib") ""))
252 #t))
b500dc2e
TF
253 (add-after 'remove-usr-local 'fix-usr-local
254 (lambda* (#:key outputs #:allow-other-keys)
255 (substitute* "icebox/icebox_vlog.py"
256 (("/usr/local/share") (string-append (assoc-ref outputs "out") "/share")))
257 #t))
36aa11c7
DM
258 (delete 'configure))))
259 (inputs
260 `(("libftdi" ,libftdi)))
261 (native-inputs
262 `(("python-3" ,python)
263 ("pkg-config" ,pkg-config)))
264 (home-page "http://www.clifford.at/icestorm/")
265 (synopsis "Project IceStorm - Lattice iCE40 FPGAs bitstream tools")
266 (description "Project IceStorm - Lattice iCE40 FPGAs Bitstream Tools.
267Includes the actual FTDI connector.")
268 (license license:isc))))
bca3797b 269
363989e6 270(define-public nextpnr-ice40
09d18c67
MFG
271 (let [(commit "fbe486df459909065d6852a7495a212dfd2accef")
272 (revision "1")]
29bf0aa3
EF
273 (package
274 (name "nextpnr-ice40")
275 (version (git-version "0.0.0" revision commit))
276 (source
277 (origin
278 (method git-fetch)
279 (uri (git-reference
280 (url "git://github.com/YosysHQ/nextpnr")
281 (commit commit)))
282 (file-name (git-file-name name version))
283 (sha256
284 (base32
09d18c67 285 "1fmxsywgs45g88ra7ips5s2niiiwrkyxdcy742ws18dfk2y4vi9c"))))
29bf0aa3 286 (inputs
7dffabf8 287 `(("boost" ,boost)
29bf0aa3 288 ("eigen" ,eigen)
7dffabf8 289 ("icestorm" ,icestorm)
29bf0aa3 290 ("python" ,python)
7dffabf8
EF
291 ("qtbase" ,qtbase)
292 ("yosys" ,yosys)))
29bf0aa3
EF
293 (build-system cmake-build-system)
294 (arguments
295 `(#:configure-flags `("-DARCH=ice40"
296 ,(string-append "-DICEBOX_ROOT="
297 (assoc-ref %build-inputs "icestorm")
298 "/share/icebox"))
299 #:tests? #f))
300 (synopsis "Place-and-Route tool for FPGAs")
301 (description "Nextpnr aims to be a vendor neutral, timing driven,
a4649802 302FOSS FPGA place and route tool.")
29bf0aa3
EF
303 (home-page "https://github.com/YosysHQ/nextpnr")
304 (license license:expat))))
363989e6 305
bca3797b 306(define-public arachne-pnr
e82baf69
AB
307 (let ((commit "840bdfdeb38809f9f6af4d89dd7b22959b176fdd")
308 (revision "2"))
bca3797b
DM
309 (package
310 (name "arachne-pnr")
311 (version (string-append "0.0-" revision "-" (string-take commit 9)))
312 (source (origin
313 (method git-fetch)
314 (uri (git-reference
b0e7b699 315 (url "https://github.com/YosysHQ/arachne-pnr")
bca3797b 316 (commit commit)))
ec299312 317 (file-name (git-file-name name version))
bca3797b
DM
318 (sha256
319 (base32
e82baf69 320 "1dqvjvgvsridybishv4pnigw9gypxh7r7nrqp9z9qq92v7c5rxzl"))))
bca3797b
DM
321 (build-system gnu-build-system)
322 (arguments
323 `(#:test-target "test"
eccd3f6d
DM
324 #:make-flags
325 (list (string-append "DESTDIR=" (assoc-ref %outputs "out"))
326 (string-append "ICEBOX=" (string-append
327 (assoc-ref %build-inputs "icestorm")
328 "/share/icebox")))
bca3797b
DM
329 #:phases (modify-phases %standard-phases
330 (replace 'configure
331 (lambda* (#:key outputs inputs #:allow-other-keys)
bca3797b
DM
332 (substitute* '("./tests/fsm/generate.py"
333 "./tests/combinatorial/generate.py")
334 (("#!/usr/bin/python") "#!/usr/bin/python2"))
335 #t)))))
336 (inputs
337 `(("icestorm" ,icestorm)))
338 (native-inputs
339 `(("git" ,git) ; for determining its own version string
340 ("yosys" ,yosys) ; for tests
341 ("perl" ,perl) ; for shasum
342 ("python-2" ,python-2))) ; for tests
e82baf69 343 (home-page "https://github.com/YosysHQ/arachne-pnr")
bca3797b
DM
344 (synopsis "Place-and-Route tool for FPGAs")
345 (description "Arachne-PNR is a Place-and-Route Tool For FPGAs.")
346 (license license:gpl2))))
adc2f048
DM
347
348(define-public gtkwave
349 (package
350 (name "gtkwave")
91d2e6f9 351 (version "3.3.108")
82f81ffa
TGR
352 (source
353 (origin
354 (method url-fetch)
355 (uri (list (string-append "mirror://sourceforge/gtkwave/"
356 "gtkwave-" version "/"
357 "gtkwave-" version ".tar.gz")
358 (string-append "http://gtkwave.sourceforge.net/"
359 "gtkwave-" version ".tar.gz")))
360 (sha256
91d2e6f9 361 (base32 "0fzbap72zm4ka6n85j0873fpaarrx199ay0kjw1avrs20hs4gr7c"))))
adc2f048
DM
362 (build-system gnu-build-system)
363 (native-inputs
364 `(("gperf" ,gperf)
365 ("pkg-config" ,pkg-config)))
366 (inputs
367 `(("tcl" ,tcl)
368 ("tk" ,tk)
369 ("gtk+-2" ,gtk+-2)))
370 (arguments
371 `(#:configure-flags
372 (list (string-append "--with-tcl="
373 (assoc-ref %build-inputs "tcl")
374 "/lib")
375 (string-append "--with-tk="
376 (assoc-ref %build-inputs "tk")
377 "/lib"))))
378
379 (synopsis "Waveform viewer for FPGA simulator trace files")
380 (description "This package is a waveform viewer for FPGA
1e6191bb 381simulator trace files (@dfn{FST}).")
adc2f048 382 (home-page "http://gtkwave.sourceforge.net/")
1e6191bb 383 ;; Exception against free government use in tcl_np.c and tcl_np.h.
adc2f048 384 (license (list license:gpl2+ license:expat license:tcl/tk))))
2b5eaf0e 385
44a4810a
VM
386(define-public python-migen
387 (package
388 (name "python-migen")
389 (version "0.9.2")
390 (source
391 (origin
392 ;; Tests fail in the PyPI tarball due to missing files.
393 (method git-fetch)
394 (uri (git-reference
395 (url "https://github.com/m-labs/migen")
396 (commit version)))
397 (file-name (git-file-name name version))
398 (sha256
399 (base32 "1kq11if64zj84gv4w1q7l16fp17xjxl2wv5hc9dibr1z3m1gy67l"))))
400 (build-system python-build-system)
401 (propagated-inputs
402 `(("python-colorama" ,python-colorama)))
403 (home-page "https://m-labs.hk/gateware/migen/")
404 (synopsis "Python toolbox for building complex digital hardware")
405 (description
406 "Migen FHDL is a Python library that replaces the event-driven
407paradigm of Verilog and VHDL with the notions of combinatorial and
408synchronous statements, has arithmetic rules that make integers always
409behave like mathematical integers, and allows the design's logic to be
410constructed by a Python program.")
411 (license license:bsd-2)))
412
2b5eaf0e
DM
413(define-public python-myhdl
414 (package
415 (name "python-myhdl")
416 (version "0.11")
417 (source
418 (origin
419 (method url-fetch)
420 (uri (pypi-uri "myhdl" version))
421 (sha256
422 (base32
423 "04fi59cyn5dsci0ai7djg74ybkqfcjzhj1jfmac2xanbcrw9j3yk"))))
424 (build-system python-build-system)
425 (home-page "http://www.myhdl.org/")
426 (synopsis "Python as a Hardware Description Language")
427 (description "This package provides a library to turn Python into
428a hardware description and verification language. ")
429 (license license:lgpl2.1+)))
492826ec
DM
430
431(define-public nvc
432 (package
433 (name "nvc")
434 (version "1.5.0")
435 (source (origin
436 (method git-fetch)
437 (uri (git-reference
438 (url "https://github.com/nickg/nvc.git")
439 (commit (string-append "r" version))))
440 (file-name (string-append name "-" version "-checkout"))
441 (sha256
442 (base32
443 "0dd1xany6qhh2qsfw8ba0ky7y86h19yr4hlk0r5i2bvwsg4355v9"))))
444 (build-system gnu-build-system)
445 (arguments
446 `(#:parallel-build? #f ; https://github.com/nickg/nvc/issues/409
447 #:configure-flags
448 '("--enable-vhpi")
449 #:phases
450 (modify-phases %standard-phases
451 (add-after 'unpack 'clean-up
452 (lambda _
453 (delete-file "autogen.sh")
454 #t)))))
455 (native-inputs
456 `(("automake" ,automake)
457 ("autoconf" ,autoconf)
458 ("flex" ,flex)
459 ("gettext" ,gnu-gettext)
460 ("libtool" ,libtool)
461 ("pkg-config" ,pkg-config)
462 ("which" ,which)
463 ("check" ,check))) ; for the tests
464 (inputs
465 `(("llvm" ,llvm-9)))
466 (synopsis "VHDL compiler and simulator")
467 (description "This package provides a VHDL compiler and simulator.")
468 (home-page "https://github.com/nickg/nvc")
469 (license license:gpl3+)))
fc4834f8
AM
470
471(define-public systemc
472 (package
473 (name "systemc")
474 (version "2.3.3")
475 (source
476 (origin
477 (method url-fetch)
478 (uri (string-append
479 "https://accellera.org/images/downloads/standards/"
480 "systemc/systemc-" version ".tar.gz"))
481 (sha256
482 (base32 "0gvv3xmhiwx1izmzy06yslzqzh6ygrgmw53xqfmyvbz5a6ivk0ap"))))
483 (native-inputs `(("perl" ,perl)))
484 (build-system gnu-build-system)
485 (arguments '(#:configure-flags '("--enable-debug")))
486 (home-page "https://accellera.org/community/systemc")
487 (synopsis "Library for event-driven simulation")
488 (description
489 "SystemC is a C++ library for modeling concurrent systems, and the
490reference implementation of IEEE 1666-2011. It provides a notion of timing as
491well as an event-driven simulations environment. Due to its concurrent and
492sequential nature, SystemC allows the description and integration of complex
493hardware and software components. To some extent, SystemC can be seen as
494a Hardware Description Language. However, unlike VHDL or Verilog, SystemC
495provides sophisticated mechanisms that offer high abstraction levels on
496components interfaces. This, in turn, facilitates the integration of systems
497using different abstraction levels.")
498 ;; homepages.cae.wisc.edu/~ece734/SystemC/Esperan_SystemC_tutorial.pdf
499 (license license:asl2.0)))