gnu: nextpnr-ice40: Re-indent.
[jackhill/guix/guix.git] / gnu / packages / fpga.scm
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, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2019 Amin Bandali <bandali@gnu.org>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages fpga)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (guix packages)
25 #:use-module (guix download)
26 #:use-module (guix git-download)
27 #:use-module (guix build-system gnu)
28 #:use-module (guix build-system cmake)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages compression)
31 #:use-module (gnu packages pkg-config)
32 #:use-module (gnu packages tcl)
33 #:use-module (gnu packages readline)
34 #:use-module (gnu packages python)
35 #:use-module (gnu packages bison)
36 #:use-module (gnu packages flex)
37 #:use-module (gnu packages gtk)
38 #:use-module (gnu packages graphviz)
39 #:use-module (gnu packages libffi)
40 #:use-module (gnu packages linux)
41 #:use-module (gnu packages maths)
42 #:use-module (gnu packages perl)
43 #:use-module (gnu packages ghostscript)
44 #:use-module (gnu packages gperf)
45 #:use-module (gnu packages gawk)
46 #:use-module (gnu packages version-control)
47 #:use-module (gnu packages qt)
48 #:use-module (gnu packages boost)
49 #:use-module (gnu packages algebra)
50 #:use-module (gnu packages libftdi))
51
52 (define-public abc
53 (let ((commit "5ae4b975c49c")
54 (revision "1"))
55 (package
56 (name "abc")
57 (version (git-version "0.0" revision commit))
58 (source (origin
59 (method url-fetch)
60 (uri
61 (string-append "https://bitbucket.org/alanmi/abc/get/" commit ".zip"))
62 (file-name (string-append name "-" version "-checkout.zip"))
63 (sha256
64 (base32
65 "1syygi1x40rdryih3galr4q8yg1w5bvdzl75hd27v1xq0l5bz3d0"))))
66 (build-system gnu-build-system)
67 (native-inputs
68 `(("unzip" ,unzip)))
69 (inputs
70 `(("readline" ,readline)))
71 (arguments
72 `(#:tests? #f ; no check target
73 #:phases
74 (modify-phases %standard-phases
75 (delete 'configure)
76 (replace 'install
77 (lambda* (#:key outputs #:allow-other-keys)
78 (let* ((out (assoc-ref outputs "out"))
79 (out-bin (string-append out "/bin")))
80 (install-file "abc" out-bin)))))))
81 (home-page "https://people.eecs.berkeley.edu/~alanmi/abc/")
82 (synopsis "Sequential logic synthesis and formal verification")
83 (description "ABC is a program for sequential logic synthesis and
84 formal verification.")
85 (license
86 (license:non-copyleft "https://fedoraproject.org/wiki/Licensing:MIT#Modern_Variants")))))
87
88 (define-public iverilog
89 (package
90 (name "iverilog")
91 (version "10.3")
92 (source (origin
93 (method url-fetch)
94 (uri
95 (string-append "ftp://ftp.icarus.com/pub/eda/verilog/v10/"
96 "verilog-" version ".tar.gz"))
97 (sha256
98 (base32
99 "1vv88ckvfwq7mrysyjnilsrcrzm9d173kp9w5ivwh6rdw7klbgc6"))))
100 (build-system gnu-build-system)
101 (native-inputs
102 `(("flex" ,flex)
103 ("bison" ,bison)
104 ("ghostscript" ,ghostscript))) ; ps2pdf
105 (home-page "http://iverilog.icarus.com/")
106 (synopsis "FPGA Verilog simulation and synthesis tool")
107 (description "Icarus Verilog is a Verilog simulation and synthesis tool.
108 It operates as a compiler, compiling source code written in Verilog
109 (IEEE-1364) into some target format.
110 For batch simulation, the compiler can generate an intermediate form
111 called vvp assembly.
112 This intermediate form is executed by @command{vvp}.
113 For synthesis, the compiler generates netlists in the desired format.")
114 ;; GPL2 only because of:
115 ;; - ./driver/iverilog.man.in
116 ;; - ./iverilog-vpi.man.in
117 ;; - ./tgt-fpga/iverilog-fpga.man
118 ;; - ./vvp/vvp.man.in
119 ;; Otherwise would be GPL2+.
120 ;; You have to accept both GPL2 and LGPL2.1+.
121 (license (list license:gpl2 license:lgpl2.1+))))
122
123 (define-public yosys
124 (package
125 (name "yosys")
126 (version "0.9")
127 (source (origin
128 (method git-fetch)
129 (uri (git-reference
130 (url "https://github.com/cliffordwolf/yosys")
131 (commit (string-append "yosys-" version))
132 (recursive? #t))) ; for the ‘iverilog’ submodule
133 (sha256
134 (base32
135 "0lb9r055h8y1vj2z8gm4ip0v06j5mk7f9zx9gi67kkqb7g4rhjli"))
136 (file-name (git-file-name name version))
137 (modules '((guix build utils)))
138 (snippet
139 '(begin
140 (substitute* "Makefile"
141 (("ABCREV = .*") "ABCREV = default\n"))
142 #t))))
143 (build-system gnu-build-system)
144 (arguments
145 `(#:test-target "test"
146 #:make-flags (list "CC=gcc"
147 "CXX=g++"
148 (string-append "PREFIX=" %output))
149 #:phases
150 (modify-phases %standard-phases
151 (add-before 'configure 'fix-paths
152 (lambda _
153 (substitute* "./passes/cmds/show.cc"
154 (("exec xdot") (string-append "exec " (which "xdot")))
155 (("dot -") (string-append (which "dot") " -"))
156 (("fuser") (which "fuser")))
157 #t))
158 (replace 'configure
159 (lambda* (#:key inputs (make-flags '()) #:allow-other-keys)
160 (apply invoke "make" "config-gcc" make-flags)))
161 (add-after 'configure 'prepare-abc
162 (lambda* (#:key inputs #:allow-other-keys)
163 (let* ((sourceabc (assoc-ref inputs "abc"))
164 (sourcebin (string-append sourceabc "/bin"))
165 (source (string-append sourcebin "/abc")))
166 (mkdir-p "abc")
167 (call-with-output-file "abc/Makefile"
168 (lambda (port)
169 (format port ".PHONY: all\nall:\n\tcp -f abc abc-default\n")))
170 (copy-file source "abc/abc")
171 (invoke "chmod" "+w" "abc/abc"))))
172 (add-before 'check 'fix-iverilog-references
173 (lambda* (#:key inputs native-inputs #:allow-other-keys)
174 (let* ((xinputs (or native-inputs inputs))
175 (xdirname (assoc-ref xinputs "iverilog"))
176 (iverilog (string-append xdirname "/bin/iverilog")))
177 (substitute* '("./manual/CHAPTER_StateOfTheArt/synth.sh"
178 "./manual/CHAPTER_StateOfTheArt/validate_tb.sh"
179 "./techlibs/ice40/tests/test_bram.sh"
180 "./techlibs/ice40/tests/test_ffs.sh"
181 "./techlibs/xilinx/tests/bram1.sh"
182 "./techlibs/xilinx/tests/bram2.sh"
183 "./tests/bram/run-single.sh"
184 "./tests/realmath/run-test.sh"
185 "./tests/simple/run-test.sh"
186 "./tests/techmap/mem_simple_4x1_runtest.sh"
187 "./tests/tools/autotest.sh"
188 "./tests/vloghtb/common.sh")
189 (("if ! which iverilog") "if ! true")
190 (("iverilog ") (string-append iverilog " "))
191 (("iverilog_bin=\".*\"") (string-append "iverilog_bin=\""
192 iverilog "\"")))
193 #t))))))
194 (native-inputs
195 `(("pkg-config" ,pkg-config)
196 ("python" ,python)
197 ("bison" ,bison)
198 ("flex" ,flex)
199 ("gawk" , gawk) ; for the tests and "make" progress pretty-printing
200 ("tcl" ,tcl) ; tclsh for the tests
201 ("iverilog" ,iverilog))) ; for the tests
202 (inputs
203 `(("tcl" ,tcl)
204 ("readline" ,readline)
205 ("libffi" ,libffi)
206 ("graphviz" ,graphviz)
207 ("psmisc" ,psmisc)
208 ("xdot" ,xdot)
209 ("abc" ,abc)))
210 (propagated-inputs
211 `(("z3" ,z3))) ; should be in path for yosys-smtbmc
212 (home-page "http://www.clifford.at/yosys/")
213 (synopsis "FPGA Verilog RTL synthesizer")
214 (description "Yosys synthesizes Verilog-2005.")
215 (license license:isc)))
216
217 (define-public icestorm
218 (let ((commit "0ec00d892a91cc68e45479b46161f649caea2933")
219 (revision "3"))
220 (package
221 (name "icestorm")
222 (version (git-version "0.0" revision commit))
223 (source (origin
224 (method git-fetch)
225 (uri (git-reference
226 (url "https://github.com/cliffordwolf/icestorm")
227 (commit commit)))
228 (file-name (git-file-name name version))
229 (sha256
230 (base32
231 "1qlh99fafb7xga702k64fmc9m700nsddrfgcq4x8qn8fplsb64f1"))))
232 (build-system gnu-build-system)
233 (arguments
234 `(#:tests? #f ; no unit tests that don't need an FPGA exist.
235 #:make-flags (list "CC=gcc" "CXX=g++"
236 (string-append "PREFIX=" (assoc-ref %outputs "out")))
237 #:phases
238 (modify-phases %standard-phases
239 (add-after 'unpack 'remove-usr-local
240 (lambda _
241 (substitute* "iceprog/Makefile"
242 (("-I/usr/local/include") "")
243 (("-L/usr/local/lib") ""))
244 #t))
245 (add-after 'remove-usr-local 'fix-usr-local
246 (lambda* (#:key outputs #:allow-other-keys)
247 (substitute* "icebox/icebox_vlog.py"
248 (("/usr/local/share") (string-append (assoc-ref outputs "out") "/share")))
249 #t))
250 (delete 'configure))))
251 (inputs
252 `(("libftdi" ,libftdi)))
253 (native-inputs
254 `(("python-3" ,python)
255 ("pkg-config" ,pkg-config)))
256 (home-page "http://www.clifford.at/icestorm/")
257 (synopsis "Project IceStorm - Lattice iCE40 FPGAs bitstream tools")
258 (description "Project IceStorm - Lattice iCE40 FPGAs Bitstream Tools.
259 Includes the actual FTDI connector.")
260 (license license:isc))))
261
262 (define-public nextpnr-ice40
263 (let [(commit "fbe486df459909065d6852a7495a212dfd2accef")
264 (revision "1")]
265 (package
266 (name "nextpnr-ice40")
267 (version (git-version "0.0.0" revision commit))
268 (source
269 (origin
270 (method git-fetch)
271 (uri (git-reference
272 (url "git://github.com/YosysHQ/nextpnr")
273 (commit commit)))
274 (file-name (git-file-name name version))
275 (sha256
276 (base32
277 "1fmxsywgs45g88ra7ips5s2niiiwrkyxdcy742ws18dfk2y4vi9c"))))
278 (inputs
279 `(("qtbase" ,qtbase)
280 ("boost" ,boost-with-python3)
281 ("yosys" ,yosys)
282 ("eigen" ,eigen)
283 ("python" ,python)
284 ("icestorm" ,icestorm)))
285 (build-system cmake-build-system)
286 (arguments
287 `(#:configure-flags `("-DARCH=ice40"
288 ,(string-append "-DICEBOX_ROOT="
289 (assoc-ref %build-inputs "icestorm")
290 "/share/icebox"))
291 #:tests? #f))
292 (synopsis "Place-and-Route tool for FPGAs")
293 (description "Nextpnr aims to be a vendor neutral, timing driven,
294 FOSS FPGA place and route tool.")
295 (home-page "https://github.com/YosysHQ/nextpnr")
296 (license license:expat))))
297
298 (define-public arachne-pnr
299 (let ((commit "840bdfdeb38809f9f6af4d89dd7b22959b176fdd")
300 (revision "2"))
301 (package
302 (name "arachne-pnr")
303 (version (string-append "0.0-" revision "-" (string-take commit 9)))
304 (source (origin
305 (method git-fetch)
306 (uri (git-reference
307 (url "https://github.com/YosysHQ/arachne-pnr")
308 (commit commit)))
309 (file-name (git-file-name name version))
310 (sha256
311 (base32
312 "1dqvjvgvsridybishv4pnigw9gypxh7r7nrqp9z9qq92v7c5rxzl"))))
313 (build-system gnu-build-system)
314 (arguments
315 `(#:test-target "test"
316 #:make-flags
317 (list (string-append "DESTDIR=" (assoc-ref %outputs "out"))
318 (string-append "ICEBOX=" (string-append
319 (assoc-ref %build-inputs "icestorm")
320 "/share/icebox")))
321 #:phases (modify-phases %standard-phases
322 (replace 'configure
323 (lambda* (#:key outputs inputs #:allow-other-keys)
324 (substitute* '("./tests/fsm/generate.py"
325 "./tests/combinatorial/generate.py")
326 (("#!/usr/bin/python") "#!/usr/bin/python2"))
327 #t)))))
328 (inputs
329 `(("icestorm" ,icestorm)))
330 (native-inputs
331 `(("git" ,git) ; for determining its own version string
332 ("yosys" ,yosys) ; for tests
333 ("perl" ,perl) ; for shasum
334 ("python-2" ,python-2))) ; for tests
335 (home-page "https://github.com/YosysHQ/arachne-pnr")
336 (synopsis "Place-and-Route tool for FPGAs")
337 (description "Arachne-PNR is a Place-and-Route Tool For FPGAs.")
338 (license license:gpl2))))
339
340 (define-public gtkwave
341 (package
342 (name "gtkwave")
343 (version "3.3.104")
344 (source
345 (origin
346 (method url-fetch)
347 (uri (list (string-append "mirror://sourceforge/gtkwave/"
348 "gtkwave-" version "/"
349 "gtkwave-" version ".tar.gz")
350 (string-append "http://gtkwave.sourceforge.net/"
351 "gtkwave-" version ".tar.gz")))
352 (sha256
353 (base32 "0kw9a33gx60kn069yhx5pyk39x1z3pwaj8l1qqwq943v62lx23fj"))))
354 (build-system gnu-build-system)
355 (native-inputs
356 `(("gperf" ,gperf)
357 ("pkg-config" ,pkg-config)))
358 (inputs
359 `(("tcl" ,tcl)
360 ("tk" ,tk)
361 ("gtk+-2" ,gtk+-2)))
362 (arguments
363 `(#:configure-flags
364 (list (string-append "--with-tcl="
365 (assoc-ref %build-inputs "tcl")
366 "/lib")
367 (string-append "--with-tk="
368 (assoc-ref %build-inputs "tk")
369 "/lib"))))
370
371 (synopsis "Waveform viewer for FPGA simulator trace files")
372 (description "This package is a waveform viewer for FPGA
373 simulator trace files (@dfn{FST}).")
374 (home-page "http://gtkwave.sourceforge.net/")
375 ;; Exception against free government use in tcl_np.c and tcl_np.h.
376 (license (list license:gpl2+ license:expat license:tcl/tk))))