fpga.scm 13 KB

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