| 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 <mab@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 libftdi)) |
| 48 | |
| 49 | (define-public abc |
| 50 | (let ((commit "5ae4b975c49c") |
| 51 | (revision "1")) |
| 52 | (package |
| 53 | (name "abc") |
| 54 | (version (git-version "0.0" revision commit)) |
| 55 | (source (origin |
| 56 | (method url-fetch) |
| 57 | (uri |
| 58 | (string-append "https://bitbucket.org/alanmi/abc/get/" commit ".zip")) |
| 59 | (file-name (string-append name "-" version "-checkout.zip")) |
| 60 | (sha256 |
| 61 | (base32 |
| 62 | "1syygi1x40rdryih3galr4q8yg1w5bvdzl75hd27v1xq0l5bz3d0")))) |
| 63 | (build-system gnu-build-system) |
| 64 | (native-inputs |
| 65 | `(("unzip" ,unzip))) |
| 66 | (inputs |
| 67 | `(("readline" ,readline))) |
| 68 | (arguments |
| 69 | `(#:tests? #f ; no check target |
| 70 | #:phases |
| 71 | (modify-phases %standard-phases |
| 72 | (delete 'configure) |
| 73 | (replace 'install |
| 74 | (lambda* (#:key outputs #:allow-other-keys) |
| 75 | (let* ((out (assoc-ref outputs "out")) |
| 76 | (out-bin (string-append out "/bin"))) |
| 77 | (install-file "abc" out-bin))))))) |
| 78 | (home-page "https://people.eecs.berkeley.edu/~alanmi/abc/") |
| 79 | (synopsis "Sequential logic synthesis and formal verification") |
| 80 | (description "ABC is a program for sequential logic synthesis and |
| 81 | formal verification.") |
| 82 | (license |
| 83 | (license:non-copyleft "https://fedoraproject.org/wiki/Licensing:MIT#Modern_Variants"))))) |
| 84 | |
| 85 | (define-public iverilog |
| 86 | (package |
| 87 | (name "iverilog") |
| 88 | (version "10.3") |
| 89 | (source (origin |
| 90 | (method url-fetch) |
| 91 | (uri |
| 92 | (string-append "ftp://ftp.icarus.com/pub/eda/verilog/v10/" |
| 93 | "verilog-" version ".tar.gz")) |
| 94 | (sha256 |
| 95 | (base32 |
| 96 | "1vv88ckvfwq7mrysyjnilsrcrzm9d173kp9w5ivwh6rdw7klbgc6")))) |
| 97 | (build-system gnu-build-system) |
| 98 | (native-inputs |
| 99 | `(("flex" ,flex) |
| 100 | ("bison" ,bison) |
| 101 | ("ghostscript" ,ghostscript))) ; ps2pdf |
| 102 | (home-page "http://iverilog.icarus.com/") |
| 103 | (synopsis "FPGA Verilog simulation and synthesis tool") |
| 104 | (description "Icarus Verilog is a Verilog simulation and synthesis tool. |
| 105 | It operates as a compiler, compiling source code written in Verilog |
| 106 | (IEEE-1364) into some target format. |
| 107 | For batch simulation, the compiler can generate an intermediate form |
| 108 | called vvp assembly. |
| 109 | This intermediate form is executed by @command{vvp}. |
| 110 | For synthesis, the compiler generates netlists in the desired format.") |
| 111 | ;; GPL2 only because of: |
| 112 | ;; - ./driver/iverilog.man.in |
| 113 | ;; - ./iverilog-vpi.man.in |
| 114 | ;; - ./tgt-fpga/iverilog-fpga.man |
| 115 | ;; - ./vvp/vvp.man.in |
| 116 | ;; Otherwise would be GPL2+. |
| 117 | ;; You have to accept both GPL2 and LGPL2.1+. |
| 118 | (license (list license:gpl2 license:lgpl2.1+)))) |
| 119 | |
| 120 | (define-public yosys |
| 121 | (package |
| 122 | (name "yosys") |
| 123 | (version "0.9") |
| 124 | (source (origin |
| 125 | (method git-fetch) |
| 126 | (uri (git-reference |
| 127 | (url "https://github.com/cliffordwolf/yosys.git") |
| 128 | (commit (string-append "yosys-" version)) |
| 129 | (recursive? #t))) ; for the ‘iverilog’ submodule |
| 130 | (sha256 |
| 131 | (base32 |
| 132 | "0lb9r055h8y1vj2z8gm4ip0v06j5mk7f9zx9gi67kkqb7g4rhjli")) |
| 133 | (file-name (git-file-name name version)) |
| 134 | (modules '((guix build utils))) |
| 135 | (snippet |
| 136 | '(begin |
| 137 | (substitute* "Makefile" |
| 138 | (("ABCREV = .*") "ABCREV = default\n")) |
| 139 | #t)))) |
| 140 | (build-system gnu-build-system) |
| 141 | (arguments |
| 142 | `(#:test-target "test" |
| 143 | #:make-flags (list "CC=gcc" |
| 144 | "CXX=g++" |
| 145 | (string-append "PREFIX=" %output)) |
| 146 | #:phases |
| 147 | (modify-phases %standard-phases |
| 148 | (add-before 'configure 'fix-paths |
| 149 | (lambda _ |
| 150 | (substitute* "./passes/cmds/show.cc" |
| 151 | (("exec xdot") (string-append "exec " (which "xdot"))) |
| 152 | (("dot -") (string-append (which "dot") " -")) |
| 153 | (("fuser") (which "fuser"))) |
| 154 | #t)) |
| 155 | (replace 'configure |
| 156 | (lambda* (#:key inputs (make-flags '()) #:allow-other-keys) |
| 157 | (apply invoke "make" "config-gcc" make-flags))) |
| 158 | (add-after 'configure 'prepare-abc |
| 159 | (lambda* (#:key inputs #:allow-other-keys) |
| 160 | (let* ((sourceabc (assoc-ref inputs "abc")) |
| 161 | (sourcebin (string-append sourceabc "/bin")) |
| 162 | (source (string-append sourcebin "/abc"))) |
| 163 | (mkdir-p "abc") |
| 164 | (call-with-output-file "abc/Makefile" |
| 165 | (lambda (port) |
| 166 | (format port ".PHONY: all\nall:\n\tcp -f abc abc-default\n"))) |
| 167 | (copy-file source "abc/abc") |
| 168 | (invoke "chmod" "+w" "abc/abc")))) |
| 169 | (add-before 'check 'fix-iverilog-references |
| 170 | (lambda* (#:key inputs native-inputs #:allow-other-keys) |
| 171 | (let* ((xinputs (or native-inputs inputs)) |
| 172 | (xdirname (assoc-ref xinputs "iverilog")) |
| 173 | (iverilog (string-append xdirname "/bin/iverilog"))) |
| 174 | (substitute* '("./manual/CHAPTER_StateOfTheArt/synth.sh" |
| 175 | "./manual/CHAPTER_StateOfTheArt/validate_tb.sh" |
| 176 | "./techlibs/ice40/tests/test_bram.sh" |
| 177 | "./techlibs/ice40/tests/test_ffs.sh" |
| 178 | "./techlibs/xilinx/tests/bram1.sh" |
| 179 | "./techlibs/xilinx/tests/bram2.sh" |
| 180 | "./tests/bram/run-single.sh" |
| 181 | "./tests/realmath/run-test.sh" |
| 182 | "./tests/simple/run-test.sh" |
| 183 | "./tests/techmap/mem_simple_4x1_runtest.sh" |
| 184 | "./tests/tools/autotest.sh" |
| 185 | "./tests/vloghtb/common.sh") |
| 186 | (("if ! which iverilog") "if ! true") |
| 187 | (("iverilog ") (string-append iverilog " ")) |
| 188 | (("iverilog_bin=\".*\"") (string-append "iverilog_bin=\"" |
| 189 | iverilog "\""))) |
| 190 | #t)))))) |
| 191 | (native-inputs |
| 192 | `(("pkg-config" ,pkg-config) |
| 193 | ("python" ,python) |
| 194 | ("bison" ,bison) |
| 195 | ("flex" ,flex) |
| 196 | ("gawk" , gawk) ; for the tests and "make" progress pretty-printing |
| 197 | ("tcl" ,tcl) ; tclsh for the tests |
| 198 | ("iverilog" ,iverilog))) ; for the tests |
| 199 | (inputs |
| 200 | `(("tcl" ,tcl) |
| 201 | ("readline" ,readline) |
| 202 | ("libffi" ,libffi) |
| 203 | ("graphviz" ,graphviz) |
| 204 | ("psmisc" ,psmisc) |
| 205 | ("xdot" ,xdot) |
| 206 | ("abc" ,abc))) |
| 207 | (propagated-inputs |
| 208 | `(("z3" ,z3))) ; should be in path for yosys-smtbmc |
| 209 | (home-page "http://www.clifford.at/yosys/") |
| 210 | (synopsis "FPGA Verilog RTL synthesizer") |
| 211 | (description "Yosys synthesizes Verilog-2005.") |
| 212 | (license license:isc))) |
| 213 | |
| 214 | (define-public icestorm |
| 215 | (let ((commit "0ec00d892a91cc68e45479b46161f649caea2933") |
| 216 | (revision "3")) |
| 217 | (package |
| 218 | (name "icestorm") |
| 219 | (version (git-version "0.0" revision commit)) |
| 220 | (source (origin |
| 221 | (method git-fetch) |
| 222 | (uri (git-reference |
| 223 | (url "https://github.com/cliffordwolf/icestorm.git") |
| 224 | (commit commit))) |
| 225 | (file-name (git-file-name name version)) |
| 226 | (sha256 |
| 227 | (base32 |
| 228 | "1qlh99fafb7xga702k64fmc9m700nsddrfgcq4x8qn8fplsb64f1")))) |
| 229 | (build-system gnu-build-system) |
| 230 | (arguments |
| 231 | `(#:tests? #f ; no unit tests that don't need an FPGA exist. |
| 232 | #:make-flags (list "CC=gcc" "CXX=g++" |
| 233 | (string-append "PREFIX=" (assoc-ref %outputs "out"))) |
| 234 | #:phases |
| 235 | (modify-phases %standard-phases |
| 236 | (add-after 'unpack 'remove-usr-local |
| 237 | (lambda _ |
| 238 | (substitute* "iceprog/Makefile" |
| 239 | (("-I/usr/local/include") "") |
| 240 | (("-L/usr/local/lib") "")) |
| 241 | #t)) |
| 242 | (add-after 'remove-usr-local 'fix-usr-local |
| 243 | (lambda* (#:key outputs #:allow-other-keys) |
| 244 | (substitute* "icebox/icebox_vlog.py" |
| 245 | (("/usr/local/share") (string-append (assoc-ref outputs "out") "/share"))) |
| 246 | #t)) |
| 247 | (delete 'configure)))) |
| 248 | (inputs |
| 249 | `(("libftdi" ,libftdi))) |
| 250 | (native-inputs |
| 251 | `(("python-3" ,python) |
| 252 | ("pkg-config" ,pkg-config))) |
| 253 | (home-page "http://www.clifford.at/icestorm/") |
| 254 | (synopsis "Project IceStorm - Lattice iCE40 FPGAs bitstream tools") |
| 255 | (description "Project IceStorm - Lattice iCE40 FPGAs Bitstream Tools. |
| 256 | Includes the actual FTDI connector.") |
| 257 | (license license:isc)))) |
| 258 | |
| 259 | (define-public arachne-pnr |
| 260 | (let ((commit "840bdfdeb38809f9f6af4d89dd7b22959b176fdd") |
| 261 | (revision "2")) |
| 262 | (package |
| 263 | (name "arachne-pnr") |
| 264 | (version (string-append "0.0-" revision "-" (string-take commit 9))) |
| 265 | (source (origin |
| 266 | (method git-fetch) |
| 267 | (uri (git-reference |
| 268 | (url "https://github.com/YosysHQ/arachne-pnr.git") |
| 269 | (commit commit))) |
| 270 | (file-name (git-file-name name version)) |
| 271 | (sha256 |
| 272 | (base32 |
| 273 | "1dqvjvgvsridybishv4pnigw9gypxh7r7nrqp9z9qq92v7c5rxzl")))) |
| 274 | (build-system gnu-build-system) |
| 275 | (arguments |
| 276 | `(#:test-target "test" |
| 277 | #:make-flags |
| 278 | (list (string-append "DESTDIR=" (assoc-ref %outputs "out")) |
| 279 | (string-append "ICEBOX=" (string-append |
| 280 | (assoc-ref %build-inputs "icestorm") |
| 281 | "/share/icebox"))) |
| 282 | #:phases (modify-phases %standard-phases |
| 283 | (replace 'configure |
| 284 | (lambda* (#:key outputs inputs #:allow-other-keys) |
| 285 | (substitute* '("./tests/fsm/generate.py" |
| 286 | "./tests/combinatorial/generate.py") |
| 287 | (("#!/usr/bin/python") "#!/usr/bin/python2")) |
| 288 | #t))))) |
| 289 | (inputs |
| 290 | `(("icestorm" ,icestorm))) |
| 291 | (native-inputs |
| 292 | `(("git" ,git) ; for determining its own version string |
| 293 | ("yosys" ,yosys) ; for tests |
| 294 | ("perl" ,perl) ; for shasum |
| 295 | ("python-2" ,python-2))) ; for tests |
| 296 | (home-page "https://github.com/YosysHQ/arachne-pnr") |
| 297 | (synopsis "Place-and-Route tool for FPGAs") |
| 298 | (description "Arachne-PNR is a Place-and-Route Tool For FPGAs.") |
| 299 | (license license:gpl2)))) |
| 300 | |
| 301 | (define-public gtkwave |
| 302 | (package |
| 303 | (name "gtkwave") |
| 304 | (version "3.3.103") |
| 305 | (source |
| 306 | (origin |
| 307 | (method url-fetch) |
| 308 | (uri (list (string-append "mirror://sourceforge/gtkwave/" |
| 309 | "gtkwave-" version "/" |
| 310 | "gtkwave-" version ".tar.gz") |
| 311 | (string-append "http://gtkwave.sourceforge.net/" |
| 312 | "gtkwave-" version ".tar.gz"))) |
| 313 | (sha256 |
| 314 | (base32 "1xzaxqbabj4sb4n10yki5acglx3736pwl3kwlq4k7i96rzvsn9f3")))) |
| 315 | (build-system gnu-build-system) |
| 316 | (native-inputs |
| 317 | `(("gperf" ,gperf) |
| 318 | ("pkg-config" ,pkg-config))) |
| 319 | (inputs |
| 320 | `(("tcl" ,tcl) |
| 321 | ("tk" ,tk) |
| 322 | ("gtk+-2" ,gtk+-2))) |
| 323 | (arguments |
| 324 | `(#:configure-flags |
| 325 | (list (string-append "--with-tcl=" |
| 326 | (assoc-ref %build-inputs "tcl") |
| 327 | "/lib") |
| 328 | (string-append "--with-tk=" |
| 329 | (assoc-ref %build-inputs "tk") |
| 330 | "/lib")))) |
| 331 | |
| 332 | (synopsis "Waveform viewer for FPGA simulator trace files") |
| 333 | (description "This package is a waveform viewer for FPGA |
| 334 | simulator trace files (@dfn{FST}).") |
| 335 | (home-page "http://gtkwave.sourceforge.net/") |
| 336 | ;; Exception against free government use in tcl_np.c and tcl_np.h. |
| 337 | (license (list license:gpl2+ license:expat license:tcl/tk)))) |