Abstract
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.



Similar content being viewed by others
References
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)
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)
Bellows, P., Hutchings, B.: JHDL—an HDL for reconfigurable systems. In: Annual IEEE Symposium on Field-Programmable Custom Computing Machines (1998)
Berry, G.: The constructive semantics of pure Esterel (1999). http://www-sop.inria.fr/esterel.org/files/
Bird, R.: Pearls of Functional Algorithm Design. Cambridge University Press, Cambridge (2010)
Bird, R., de Moor, O.: Algebra of Programming. International Series in Computing Science, vol. 100. Prentice Hall, New York (1997)
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)
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)
Claessen, K.: Embedded languages for describing and verifying hardware. Ph.D. thesis, Dept. of Computer Science and Engineering, Chalmers University of Technology (2001)
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)
Elliott, C., Finne, S., de Moor, O.: Compiling embedded languages. J. Funct. Program. 13(2), 9–27 (2003)
Erkök, L.: Value recursion in monadic computations. Ph.D. thesis, OGI School of Science and Engineering, OHSU, Portland, Oregon (2002)
Erkök, L., Launchbury, J.: A recursive do for Haskell. In: Haskell Workshop’02, Pittsburgh, Pennsylvania, USA, pp. 29–37. ACM, New York (2002)
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)
Gill, A.: Declarative FPGA circuit synthesis using Kansas Lava. In: The International Conference on Engineering of Reconfigurable Systems and Algorithms (2011)
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)
Gill, A., Neuenschwander, B.: Handshaking in Kansas Lava using patch logic. In: Practical Aspects of Declarative Languages. LNCS, vol. 7149. Springer, Berlin (2012)
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)
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)
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)
Hutton, G.: The Ruby Interpreter. Research Report 72, Chalmers University of Technology (1993)
IEEE Std 1164-1993, IEEE Standard Multivalue Logic System for VHDL Model Interoperability (Std_logic_1164) (1993). doi:10.1109/IEEESTD.1993.115571
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
Jones, G., Sheeran, M.: Circuit design in ruby. In: Staunstrup, J. (ed.) Formal Methods for VLSI Design, pp. 13–70. Elsevier, Amsterdam (1990)
Leijen, D., Meijer, E.: Domain specific embedded compilers. In: 2nd USENIX Conference on Domain Specific Languages (DSL’99), Austin, Texas, pp. 109–122 (1999)
McBride, C., Patterson, R.: Applicative programing with effects. J. Funct. Program. 18(1), 1–13 (2008)
Moon, T.K.: Error Correction Coding: Mathematical Methods and Algorithms. Wiley-Interscience, Hoboken (2005)
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)
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)
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)
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)
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)
O’Donnell, J.T.: Overview of Hydra: a concurrent language for synchronous digital circuit design. Information 9(2), 249–264 (2006)
Peyton Jones, S. (ed.): Haskell 98 Language and Libraries—The Revised Report. Cambridge University Press, Cambridge (2003)
Sander, I.: System modeling and design refinement in ForSyDe. Ph.D. thesis, Royal Institute of Technology, Stockholm, Sweden (2003)
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)
Singh, S.: Designing reconfigurable systems in Lava. In: International Conference on VLSI Design, p. 299 (2004)
Acknowledgements
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.
Author information
Authors and Affiliations
Corresponding author
Appendices
Appendix A: VHDL generated for interactive nand gate circuit

Appendix B: Spartan3E starter board simulator running nand gate circuit

Rights and permissions
About this article
Cite this article
Gill, A., Bull, T., Farmer, A. et al. Types and associated type families for hardware simulation and synthesis. Higher-Order Symb Comput 25, 255–274 (2012). https://doi.org/10.1007/s10990-013-9098-7
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10990-013-9098-7