Higher-Order and Symbolic Computation

, Volume 25, Issue 2–4, pp 255–274 | Cite as

Types and associated type families for hardware simulation and synthesis

The internals and externals of Kansas Lava
  • Andy Gill
  • Tristan Bull
  • Andrew Farmer
  • Garrin Kimmell
  • Ed Komp


In this article we overview the design and implementation of the second generation of Kansas Lava. Driven by the needs and experiences of implementing telemetry decoders and other circuits, we have made a number of improvements to both the external API and the internal representations used. We have retained our dual shallow/deep representation of signals in general, but now have a number of externally visible abstractions for combinatorial and sequential circuits, and enabled signals. We introduce these abstractions, as well as our abstractions for reading and writing memory. Internally, we found the need to represent unknown values inside our circuits, so we made aggressive use of associated type families to lift our values to allow unknowns, in a principled and regular way. We discuss this design decision, how it unfortunately complicates the internals of Kansas Lava, and how we mitigate this complexity. Finally, when connecting Kansas Lava to the real world, the standardized idiom of using named input and output ports is provided by Kansas Lava using a new monad, called Fabric. We present the design of this Fabric monad, and illustrate its use in a small but complete example.


Domain specific languages Hardware Synthesis Types 



We would like to thank the TFP 2010 referees for their useful feedback, both on this article, and on the earlier TFP version of this article. We would also like to thank Neil Sculthorpe for his detailed comments.


  1. 1.
    Axelsson, E.: Functional programming enabling flexible hardware design at low levels of abstraction. Ph.D. thesis, Department of Computer Science and Engineering Chalmers University of Technology and University of Gothenburg (2008) Google Scholar
  2. 2.
    Axelsson, E., Claessen, K., Dévai, G., Horváth, Z., Keijzer, K., Lyckegård, B., Persson, A., Sheeran, M., Svenningsson, J., Vajdax, A.: Feldspar: a domain specific language for digital signal processing algorithms. In: MEMOCODE’10, pp. 169–178 (2010) Google Scholar
  3. 3.
    Bellows, P., Hutchings, B.: JHDL—an HDL for reconfigurable systems. In: Annual IEEE Symposium on Field-Programmable Custom Computing Machines (1998) Google Scholar
  4. 4.
    Berry, G.: The constructive semantics of pure Esterel (1999).
  5. 5.
    Bird, R.: Pearls of Functional Algorithm Design. Cambridge University Press, Cambridge (2010) zbMATHCrossRefGoogle Scholar
  6. 6.
    Bird, R., de Moor, O.: Algebra of Programming. International Series in Computing Science, vol. 100. Prentice Hall, New York (1997) zbMATHGoogle Scholar
  7. 7.
    Bjesse, P., Claessen, K., Sheeran, M., Singh, S.: Lava: hardware design in Haskell. In: Proceedings of the Third ACM SIGPLAN International Conference on Functional Programming, pp. 174–184 (1998) CrossRefGoogle Scholar
  8. 8.
    Chakravarty, M.M.T., Keller, G., Peyton Jones, S.: Associated type synonyms. In: Proceedings of the Tenth ACM SIGPLAN International Conference on Functional Programming, pp. 241–253. ACM, New York (2005) CrossRefGoogle Scholar
  9. 9.
    Claessen, K.: Embedded languages for describing and verifying hardware. Ph.D. thesis, Dept. of Computer Science and Engineering, Chalmers University of Technology (2001) Google Scholar
  10. 10.
    Claessen, K., Sands, D.: Observable sharing for functional circuit description. In: Proc. of Asian Computer Science Conference (ASIAN). Lecture Notes in Computer Science. Springer, Berlin (1999) Google Scholar
  11. 11.
    Elliott, C., Finne, S., de Moor, O.: Compiling embedded languages. J. Funct. Program. 13(2), 9–27 (2003) zbMATHGoogle Scholar
  12. 12.
    Erkök, L.: Value recursion in monadic computations. Ph.D. thesis, OGI School of Science and Engineering, OHSU, Portland, Oregon (2002) Google Scholar
  13. 13.
    Erkök, L., Launchbury, J.: A recursive do for Haskell. In: Haskell Workshop’02, Pittsburgh, Pennsylvania, USA, pp. 29–37. ACM, New York (2002) CrossRefGoogle Scholar
  14. 14.
    Gill, A.: Type-safe observable sharing in Haskell. In: Proceedings of the Second ACM SIGPLAN Haskell Symposium, Haskell ’09, pp. 117–128. ACM, New York (2009) CrossRefGoogle Scholar
  15. 15.
    Gill, A.: Declarative FPGA circuit synthesis using Kansas Lava. In: The International Conference on Engineering of Reconfigurable Systems and Algorithms (2011) Google Scholar
  16. 16.
    Gill, A., Farmer, A.: Deriving an efficient FPGA implementation of a low density parity check forward error corrector. In: Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming, ICFP ’11, pp. 209–220. ACM, New York (2011) CrossRefGoogle Scholar
  17. 17.
    Gill, A., Neuenschwander, B.: Handshaking in Kansas Lava using patch logic. In: Practical Aspects of Declarative Languages. LNCS, vol. 7149. Springer, Berlin (2012) CrossRefGoogle Scholar
  18. 18.
    Gill, A., Bull, T., Kimmell, G., Perrins, E., Komp, E., Werling, B.: Introducing Kansas Lava. In: Proceedings of the Symposium on Implementation and Application of Functional Languages. LNCS, vol. 6041. Springer, Berlin (2009) Google Scholar
  19. 19.
    Gill, A., Bull, T., Farmer, A., Kimmell, G., Komp, E.: Types and type families for hardware simulation and synthesis: the internals and externals of Kansas Lava. In: Proceedings of Trends in Functional Programming. LNCS, vol. 6546. Springer, Berlin (2010) Google Scholar
  20. 20.
    Gill, A., Bull, T., DePardo, D., Farmer, A., Komp, E., Perrins, E.: Using functional programming to generate an LDPC forward error corrector. In: Proceedings of the IEEE 19th Annual International Symposium on Field-Programmable Custom Computing Machines, FCCM ’11, pp. 133–140. IEEE Comput. Soc., Los Alamitos (2011) CrossRefGoogle Scholar
  21. 21.
    Hutton, G.: The Ruby Interpreter. Research Report 72, Chalmers University of Technology (1993) Google Scholar
  22. 22.
    IEEE Std 1164-1993, IEEE Standard Multivalue Logic System for VHDL Model Interoperability (Std_logic_1164) (1993). doi: 10.1109/IEEESTD.1993.115571
  23. 23.
    Jantsch, A., Sander, I.: Models of computation and languages for embedded system design. IEE Proc., Comput. Digit. Tech. 152(2), 114–129 (2005). Special issue on Embedded Microelectronic Systems CrossRefGoogle Scholar
  24. 24.
    Jones, G., Sheeran, M.: Circuit design in ruby. In: Staunstrup, J. (ed.) Formal Methods for VLSI Design, pp. 13–70. Elsevier, Amsterdam (1990) Google Scholar
  25. 25.
    Leijen, D., Meijer, E.: Domain specific embedded compilers. In: 2nd USENIX Conference on Domain Specific Languages (DSL’99), Austin, Texas, pp. 109–122 (1999) Google Scholar
  26. 26.
    McBride, C., Patterson, R.: Applicative programing with effects. J. Funct. Program. 18(1), 1–13 (2008) CrossRefGoogle Scholar
  27. 27.
    Moon, T.K.: Error Correction Coding: Mathematical Methods and Algorithms. Wiley-Interscience, Hoboken (2005) zbMATHCrossRefGoogle Scholar
  28. 28.
    Naylor, M., Runciman, C.: The reduceron: widening the von Neumann bottleneck for graph reduction using an FPGA. In: Chitil, O., Horváth, Z., Zsók, V. (eds.) Implementation and Application of Functional Languages. Lecture Notes in Computer Science, vol. 5083, pp. 129–146. Springer, Berlin (2008) CrossRefGoogle Scholar
  29. 29.
    O’Donnell, J.: Generating netlists from executable circuit specifications in a pure functional language. In: Functional Programming, Glasgow, 1992. Workshops in Computing, pp. 178–194. Springer, Berlin (1992) Google Scholar
  30. 30.
    O’Donnell, J.: From transistors to computer architecture: teaching functional circuit specification in hydra. In: Hartel, P., Plasmeijer, R. (eds.) Functional Programming Languages in Education. Lecture Notes in Computer Science, vol. 1022, pp. 195–214. Springer, Berlin (1995) CrossRefGoogle Scholar
  31. 31.
    O’Donnell, J.T.: Hardware description with recursion equations. In: Proceedings of the IFIP 8th International Symposium on Computer Hardware Description Languages and Their Applications, pp. 363–382 (1987) Google Scholar
  32. 32.
    O’Donnell, J.T.: Embedding a hardware description language in template Haskell. In: Domain-Specific Program Generation. Lecture Notes in Computer Science, vol. 3016, pp. 143–164. Springer, Berlin (2004) CrossRefGoogle Scholar
  33. 33.
    O’Donnell, J.T.: Overview of Hydra: a concurrent language for synchronous digital circuit design. Information 9(2), 249–264 (2006) Google Scholar
  34. 34.
    Peyton Jones, S. (ed.): Haskell 98 Language and Libraries—The Revised Report. Cambridge University Press, Cambridge (2003) zbMATHGoogle Scholar
  35. 35.
    Sander, I.: System modeling and design refinement in ForSyDe. Ph.D. thesis, Royal Institute of Technology, Stockholm, Sweden (2003) Google Scholar
  36. 36.
    Sheeran, M.: muFP, a language for VLSI design. In: LFP ’84: Proceedings of the 1984 ACM Symposium on LISP and Functional Programming, pp. 104–112. ACM, New York (1984) CrossRefGoogle Scholar
  37. 37.
    Singh, S.: Designing reconfigurable systems in Lava. In: International Conference on VLSI Design, p. 299 (2004) CrossRefGoogle Scholar

Copyright information

© Springer Science+Business Media New York 2013

Authors and Affiliations

  • Andy Gill
    • 1
  • Tristan Bull
    • 1
  • Andrew Farmer
    • 1
  • Garrin Kimmell
    • 1
  • Ed Komp
    • 1
  1. 1.The University of KansasLawrenceUSA

Personalised recommendations