This last section is about running Haskell programs on the SoCKit. The Haskell compiler, GHC, is also available for the ARM processor. However, the ARM processor on the SoCKit is not very efficient for compiling Haskell due to its rather small memory and low clock speed. For this reason a cross-compiler was investigated and built to compile programs on a more capable host computer. Building a cross-compiler3 [37] consist of the first two stages as shown in Table B.1. Stage 0 is the GHC compiler installed on the host computer itself, which is a version installed from the GHC download page. Then the libraries used for building the stage 1 are downloaded and built using the stage 0 compiler. Then the actual cross-compiler at stage 1 is built, which targets the ARM processor.
Stage 0 libs boot Stage 1 libs install Stage 2
Built on — host host host host
Runs on host host host target target
Targets host — target — target
Table B.1: Stages involved in the building process for a GHC compiler [37]. Host is the development PC and target is the ARM processor.
1
For this thesis a Kingston 32GB Micro SDHC Class 10 card was used.
2
An open source project that provides templates, tools and methods for creating a custom Linux-based system for embedded products.
3
B.3. HASKELL ON THE ARM APPENDIX B. SOCKIT DEVELOPMENT KIT
Cross-platform Haskell compiler building is still in a development phase and therefore some limitations and the occasional bugs are available. The most relevant restrictions are that in the stage 1 cross-compiler there can be no dynamic loading and no Template Haskell (TH) due to missing libraries, which are only available on the target platform [38]. Dynamic loading is required for CλaSH to work, due to for example a typechecker plugin that is used. TH is an extension on the GHC compiler, which is used to execute Haskell code at compile time. As we will show in a later chapter, the ability to run TH is paramount as it is used to automatically offload functions. There is at least one solution [39] to circumvent the TH problem by using an external process to run TH code, but this was deemed as too much work for this thesis project. So the only option is to have the GHC compiler on the ARM processor. This can be done by cross-compiling GHC itself to be a native GHC compiler on the ARM target processor, as can be seen in the last two columns of Table B.1. On some Linux distribution for the SoCKit platform, such as the upgraded Ubuntu image used in this implementation, there are package managers available which can install GHC (version 7.10.3) from the repository. This way, also any additional GHC packages can be installed, such as CλaSH. However, this process, and any future Haskell compilations, will take a considerable amount of time, due to the low performance of the ARM processor. A solution for this last mentioned problem would be to run the SoCKit image in a virtual machine on the host computer with the QEMU machine emulator. Mainly this allows for more memory than the standard 1GB on the SoCKit, but it also may provide a boost in processor clock frequency.
Bibliography
[1] J. Teich, ”Hardware/Software Codesign: The Past, the Present, and Predicting the Future”, Pro- ceedings of the IEEE, vol.100, Issue: Special Centennial Issue, pp. 1411-1430, May 13 2012 [2] A.A. Jerraya, W. Wolf, ”Hardware/Software Interface Codesign for Embedded Systems”, Computer,
vol.38, no. 2, pp. 63-69, February 2005, doi:10.1109/MC.2005.61
[3] Intel newsroom webpage detailing their view on FPGAs being a critical part of their growth strategy. Last seen 29-8-2016.https://newsroom.intel.com/editorials/intels-fpga-future- here-to-stay/
[4] J.G.J. Verheij, ”Co-simulation between CλaSH and traditional HDLs”, Master’s thesis, University of Twente, August 2016http://essay.utwente.nl/70777/
[5] W. Meeus, K. van Beeck, T. Goedem´e, J. Meel, D. Stroobandt, ”An overview of today’s high-level synthesis tools”, Design Automation for Embedded Systems, September 2012, Volume 16, Issue 3, pp. 31-51.
[6] The Haskell website. Last seen 28-4-2016.https://www.haskell.org/
[7] The Haskell 2010 Language Report. Last seen 28-4-2016. https://www.haskell.org/ onlinereport/haskell2010/
[8] G.J.M. Smit, J. Kuper, C.P.R. Baaij. A mathematical approach towards hardware design. University of Twente, Enschede, The Netherlands.
[9] The CλaSH website. Last seen 28-4-2016.www.clash-lang.org
[10] Baaij, C.P.R. (2015) Digital Circuits in CλaSH : Functional Specifications and Type-Directed Syn- thesis. PhD thesis, University of Twente, Enschede, The Netherlands, January 2015.
[11] Educational website with information on a practical example of the GFSK demodulator and FIR filter. Last seen 29-9-2016.http://wwwhome.ewi.utwente.nl/~gerezsh/vlsidsp/index.html [12] Haskell wiki page on annotations. Last seen 29-9-2016. https://ghc.haskell.org/trac/ghc/
wiki/Annotations
[13] M. Sheeran, muFP, a Language for VLSI Design. Proceedings of the ACM Symposium on LISP and Functional Programming, 1984.
[14] J. O’Donnell, Generating Netlists from Executable Circuit Specifications in a Pure Functional Language. In Functional Programming Glasgow, Springer-Verlag Workshops in Computing, pages 178-194, 1993.
[15] P. Bjesse , K. Claessen, M. Sheeran and S. Singh, Lava: Hardware Description in Haskell. Proceed- ings of the 3rd ACM SIGPLAN International Conference on Functional Programming, 1998. [16] A. Mycroft, R. Sharp, Hardware/Software Co-Design using Functional Languages.
BIBLIOGRAPHY BIBLIOGRAPHY [17] Getting Started with Hardware-Software Codesign Workflow for Altera SoC Platform. Last seen 29-8-2016. http://www.mathworks.com/examples/matlab-hdl-coder/mw/hdlcoder_product- hdlcoder_ip_core_tutorial_alterasoc-getting-started-with-hardware-software-
codesign-workflow-for-altera-soc-platform
[18] Hardware-Software Codesign Workflow Examples. Last seen on 29-8-2016. https: //www.mathworks.com/examples/matlab-hdl-coder/category/hardware-software-
codesign-workflow-examples
[19] FPGA coprocessing for C/C++ programmers. Tutorial written in 2013. Last seen 29-8-2016.http: //xillybus.com/tutorials/vivado-hls-c-fpga-howto-1
[20] J. Epstein, A. Black, and S.P. Jones, Haskell Symposium, Towards Haskell in the Cloud, Tokyo, Sept 2011.
[21] Cloud Haskell webpage on the Haskell wiki. Last seen 29-9-2016. https://wiki.haskell.org/ Cloud_Haskell
[22] J. Armstrong, R. Virding, C. Wikstr¨om, and M. Williams, Concurrent programming in Erlang, 1993.
[23] George H. Mealy. A Method to Synthesizing Sequential Circuits. Bell Systems Technical Journal, pages 1045-1079, 1955.
[24] https://hackage.haskell.org/package/clash-prelude-0.10.3/docs/CLaSH-Prelude.html [25] The official CλaSH tutorial page. Last seen 29-6-2016.https://hackage.haskell.org/package/
clash-prelude/docs/CLaSH-Tutorial.html
[26] Baaij, C.P.R. (2009) CλaSH : from Haskell to hardware. MSc thesis, University of Twente, Enschede, The Netherlands, December 2009.
[27] Document describing the Glasgow Haskell Compiler. Dated March 16, 2012. http://community. haskell.org/~simonmar/papers/aos.pdf
[28] Haskell wiki page on the Core Type. Last seen 29-9-2016.https://ghc.haskell.org/trac/ghc/ wiki/Commentary/Compiler/CoreSynType
[29] Haskell Core plugin user guide page. Last seen 29-9-2016.https://downloads.haskell.org/~ghc/ 7.10.3/docs/html/users_guide/compiler-plugins.html
[30] Arrow SoCKit development board website. Last seen on 29-8-16. https://www.arrow.com/en/ products/sockit/arrow-development-tools
[31] Terasic webpage for the SoCKit Development Board. Last seen on 29-8-16.http://www.terasic. com.tw/cgi-bin/page/archive.pl?Language=English&CategoryNo=167&No=816
[32] Cyclone V device specifications. Last seen on 29-8-16. https://cloud.altera.com/ds/part/ 5CSXFC6D6F31C8ES/
[33] Cyclone V Hard Processor System Technical Reference Manual. Last seen 28-4-2016. https: //www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/hb/cyclone- v/cv_5v4.pdf
[34] Website for the SoCKit Golden System Reference Design (GSRD) documentation and sources. Last seen 28-4-2016.https://rocketboards.org/foswiki/view/Documentation/GSRD
[35] Terasic webpage for the DE1-SoC Development Board. See CD zip for the default linux images and the standard HW/SW co-design demo application. Last seen on 29-8-16. http://www.terasic. com.tw/cgi-bin/page/archive.pl?Language=English&CategoryNo=167&No=836
BIBLIOGRAPHY BIBLIOGRAPHY [36] Github page on how to build a cross-compiler for a Raspberry Pi, which is quite similar to the SoCKit ARM processor. Last seen on 29-8-2016.https://github.com/ku-fpg/raspberry-pi/wiki/GHC- Cross-Compiler-for-Raspberry-Pi
[37] Haskell webpage on GHC for the ARM architecture. Last seen 29-8-2016.https://wiki.haskell. org/ARM
[38] Haskell webpage on why there can’t be Template Haskell in a cross-compiler. Last seen 29-8-2016. https://ghc.haskell.org/trac/ghc/wiki/TemplateHaskell/CrossCompilation
[39] Github project for running Template Haskell code on a external process. Last seen 29-8-2016. https://github.com/ghcjs/ghcjs/wiki/Porting-GHCJS-Template-Haskell-to-GHC
[40] Xillybus homepage. Last seen 29-9-2016.http://xillybus.com/
[41] Xillybus licensing formats webpage. Last seen 29-9-2016. http://xillybus.com/licensing [42] Haskell hackage page on Unsafe IO operations. Last seen 29-9-2016. https://hackage.haskell.
org/package/base-4.9.0.0/docs/System-IO-Unsafe.html
[43] Online Xillybus IP core factory. Last seen 29-9-2016.http://xillybus.com/custom-ip-factory [44] Error correction code in SoC FPGA-based memory systems. White paper. Last seen 29- 9-2016. https://www.altera.com/content/dam/altera-www/global/en_US/pdfs/literature/ wp/wp-01179-ecc-embedded.pdf
[45] Xillybus Linux host programming guide. Last seen 28-4-2016.http://xillybus.com/doc
[46] Bitpack package hackage page of the Clash compiler. Last seen 29-9-2016. https://hackage. haskell.org/package/clash-prelude-0.10.14/docs/CLaSH-Class-BitPack.html
[47] Altera Dual clock FIFO IP Cores User Guide. Last seen 29-9-2016.https://www.altera.com/en_ US/pdfs/literature/ug/ug_fifo.pdf
[48] Source documentation webpage for the dataflow module in CλaSH . Last seen 28- 4-2016. http://hackage.haskell.org/package/clash-prelude-0.10.7/docs/CLaSH-Prelude- DataFlow.html#t:DataFlow
[49] Dell webpage of the Inspiron 15 7559 laptop used in the testbenches. Last seen 29-9-2016. http: //www.dell.com/en-us/shop/productdetails/inspiron-15-7559-laptop
[50] Homepage of the Criterion Haskell benchmarking library. Last seen 29-9-2016. http://www. serpentine.com/criterion/
[51] Haskell wiki page for a basic approach on timing IO computations. Last seen 29-9-2016. https: //wiki.haskell.org/Timing_computations
[52] Guide to install Xillinux and use it with the demo FPGA bundle. Last seen 29-9-2016. http: //xillybus.com/xillinux
[53] The permanent GitHub repository with the code and in-depth standalone user manual of the proof of concept of this thesis.https://github.com/jjvanvossen/Haskell-FunctionOffloading