Skip to main content
Log in

Abstract

This paper aims to exploit the massive parallelism of Field-Programmable Gate Arrays (FPGAs) by programming them in OCaml, a multiparadigm and statically typed language. It first presents O2B, an implementation of the OCaml virtual machine using a softcore processor to run the entire OCaml language on an FPGA. It then introduces Macle, a language to express, in ML-style, hardware-accelerated user-defined functions, implemented as gates and registers on the same FPGA. Macle allows to implement pure computations and compose them in parallel. It also supports processing of dynamic data structures such as arrays, matrices and trees allocated by the OCaml runtime in the memory of the softcore processor. Macle functions can then be called, as hardware accelerators, by OCaml programs executed by O2B. This combination of Macle and OCaml codes in a single source program enables to easily prototype FPGA applications mixing numeric and symbolic computations.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Institutional subscriptions

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10
Fig. 11
Fig. 12
Fig. 13
Fig. 14
Fig. 15
Fig. 16

Notes

  1. https://github.com/janestreet/hardcaml.

  2. A softcore processor is a processor implemented in the reconfigurable part of an FPGA.

  3. Such as AMD Vivado HLS and Intel OpenCL SDK.

  4. https://github.com/jserot/O2B.

  5. https://github.com/lsylvestre/macle.

  6. This process is general and can be adapted to target other FPGA families.

  7. Avalon bus for Intel platforms.

  8. The FPGA board is connected to a host PC via an UART connection for printing and debugging.

  9. Each call of these functions is specialized and inlined at compile time.

References

  1. Alur, R., Kannan, S., Yannakakis, M.: Communicating hierarchical state machines. In: International Colloquium on Automata, Languages, and Programming, pp. 169–178. Springer (1999). https://doi.org/10.1007/3-540-48523-6_14

  2. Auerbach, J., Bacon, D.F., Cheng, P., et al.: Lime: a Java-compatible and synthesizable language for heterogeneous architectures. In: ACM International Conference on Object Oriented Programming Systems Languages and Applications, pp. 89–108 (2010). https://doi.org/10.1145/1869459.1869469

  3. Baaij, C., Kooijman, M., Kuper, J., et al.: Clash: structural descriptions of synchronous hardware using Haskell. In: 2010 13th Euromicro Conference on Digital System Design: Architectures, Methods and Tools, pp. 714–721. IEEE (2010). https://doi.org/10.1109/DSD.2010.21

  4. Bachrach, J., Vo, H., Richards, B., et al.: Chisel: constructing hardware in a Scala embedded language. In: DAC Design Automation Conference, 2012, pp. 1212–1221. IEEE (2012). https://doi.org/10.1145/2228360.2228584

  5. Canis, A., Choi, J., Aldham, M., et al.: LegUp: high-level synthesis for FPGA-based processor/accelerator systems. In: Proceedings of the 19th ACM/SIGDA International Symposium on Field Programmable Gate Arrays (FPGA), pp. 33–36 (2011). https://doi.org/10.1145/1950413.1950423

  6. Cardoso, J.M., Diniz, P.C., Weinhardt, M.: Compiling for reconfigurable computing: a survey. ACM Comput. Surv. (CSUR) 42(4), 1–65 (2010). https://doi.org/10.1145/1749603.1749604

    Article  Google Scholar 

  7. Chi, Y., Guo, L., Lau, J., et al.: Extending high-level synthesis for task-parallel programs. In: 2021 IEEE 29th Annual International Symposium on Field-Programmable Custom Computing Machines (FCCM), pp. 204–213. IEEE (2021). https://doi.org/10.1145/3431920.3439470

  8. Colaço, J.-L., Hamon, G., Pouzet, M.: Mixing signals and modes in synchronous data-flow systems. In: Proceedings of the 6th ACM & IEEE International Conference on Embedded Software, pp. 73–82 (2006). https://doi.org/10.1145/1176887.1176899

  9. Danelutto, M., Mencagli, G., Torquati, M., et al.: Algorithmic skeletons and parallel design patterns in mainstream parallel programming. Int. J. Parallel Program. 49, 177–198 (2021). https://doi.org/10.1007/s10766-020-00684-w

    Article  Google Scholar 

  10. Decaluwe, J.: MyHDL: a Python-based hardware description language. Linux J. 2004, 84–87 (2004)

    Google Scholar 

  11. Drusinsky, D., Harel, D.: Using statecharts for hardware description and synthesis. IEEE Trans. Comput. Aided Des. Integr. Circuits Syst. 8(7), 798–807 (1989). https://doi.org/10.1109/43.31537

    Article  Google Scholar 

  12. Fumero, J., Stratikopoulos, A., Kotselidis, C.: Running parallel bytecode interpreters on heterogeneous hardware. In: 4th International Conference on Art, Science, and Engineering of Programming, pp. 31–35 (2020). https://doi.org/10.1145/3397537.3397563

  13. Gammie, P.: Synchronous digital circuits as functional programs. ACM Comput. Surv. (CSUR) 46(2), 1–27 (2013). https://doi.org/10.1145/2543581.2543588

    Article  Google Scholar 

  14. Ghica, D.R., Smith, A., Singh, S.: Geometry of synthesis IV: compiling affine recursion into static hardware. In: Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming, pp. 221–233 (2011). https://doi.org/10.1145/2034574.2034805

  15. Huang, S., Wu, K., Jeong, H., et al.: Pylog: an algorithm-centric python-based FPGA programming and synthesis flow. IEEE Trans. Comput. 70(12), 2015–2028 (2021). https://doi.org/10.1109/TC.2021.3123465

    Article  MATH  Google Scholar 

  16. Ito, Y., Nakano, K.: A hardware-software cooperative approach for the exhaustive verification of the Collatz conjecture. In: 2009 IEEE International Symposium on Parallel and Distributed Processing with Applications, pp. 63–70. IEEE (2009). https://doi.org/10.1109/ISPA.2009.35

  17. Kennedy, A.: Compiling with continuations, continued. In: 12th ACM SIGPLAN International Conference on Functional Programming, pp. 177–190 (2007). https://doi.org/10.1145/1291151.1291179

  18. Lai, Y.-H., Ustun, E., Xiang, S., et al.: Programming and synthesis for software-defined FPGA acceleration: status and future prospects. ACM Trans. Reconfig. Technol. Syst. (TRETS) 14(4), 1–39 (2021). https://doi.org/10.1145/3469660

    Article  Google Scholar 

  19. Maas, M., Asanović, K., Kubiatowicz, J.: A hardware accelerator for tracing garbage collection. In: 2018 ACM/IEEE 45th Annual International Symposium on Computer Architecture (ISCA), pp. 138–151. IEEE (2018). https://doi.org/10.1109/ISCA.2018.00022

  20. Mycroft, A., Sharp, R.: A statically allocated parallel functional language. In: International Colloquium on Automata, Languages, and Programming, pp. 37–48. Springer (2000). https://doi.org/10.1007/3-540-45022-X_5

  21. Nane, R., Sima, V.-M., Pilato, C., et al.: A survey and evaluation of fpga high-level synthesis tools. IEEE Trans. Comput. Aided Des. Integr. Circuits Syst. 35(10), 1591–1604 (2015). https://doi.org/10.1109/TCAD.2015.2513673

    Article  Google Scholar 

  22. Papadimitriou, M., Fumero, J., Stratikopoulos, A., et al.: Transparent compiler and runtime specializations for accelerating managed languages on FPGAs. Art Sci. Eng. Program. (2020). https://doi.org/10.22152/programming-journal.org/2021/5/8

    Article  Google Scholar 

  23. Saint-Mleux, X., Feeley, M., David, J.-P.: SHard: a Scheme to hardware compiler. In: Workshop on Scheme and Functional Programming (2006)

  24. Segal, O., Margala, M., Chalamalasetti, S.R., et al.: High level programming framework for FPGAs in the data center. In: 2014 24th International Conference on Field Programmable Logic and Applications (FPL), pp. 1–4. IEEE (2014). https://doi.org/10.1109/FPL.2014.6927442

  25. Singh, S., Greaves, D. J.: Kiwi: synthesis of fpga circuits from parallel programs. In: 16th International Symposium on Field-Programmable Custom Computing Machines, pp. 3–12. IEEE (2008). https://doi.org/10.1109/FCCM.2008.46

  26. Stewart, R., Duncan, K., Michaelson, G., et al.: RIPL: a parallel image processing language for FPGAs. ACM Trans. Reconfig. Technol. Syst. (TRETS) 11(1), 1–24 (2018). https://doi.org/10.1145/3180481

    Article  Google Scholar 

  27. Townsend, R., Kim, M.A., Edwards, S.A.: From functional programs to pipelined dataflow circuits. In: Proceedings of the 26th International Conference on Compiler Construction, pp. 76–86 (2017). https://doi.org/10.1145/3033019.3033027

  28. Tsai, C.-J., Kuo, H.-W., Lin, Z., et al.: A Java processor IP design for embedded SoC. ACM Trans. Embed. Comput. Syst. 14(2), 1–25 (2015). https://doi.org/10.1145/2629649

    Article  Google Scholar 

  29. Varoumas, S., Vaugon, B., Chailloux, E.: A generic virtual machine approach for programming microcontrollers: the OMicroB project. In: 9th European Congress on Embedded Real Time Software and Systems (ERTS 2018) (2018)

Download references

Acknowledgements

Work on O2B and Macle is partially supported by the Center for Research and Innovation on Free Software (IRILL).

Author information

Authors and Affiliations

Authors

Contributions

All authors have contributed equally to this work.

Corresponding author

Correspondence to Jocelyn Sérot.

Ethics declarations

Conflict of interest

The authors have no relevant financial or non-financial interests to disclose. No special funding was received for conducting this work. All of the material is owned by the authors and no permissions are required.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Sylvestre, L., Chailloux, E. & Sérot, J. Accelerating OCaml Programs on FPGA. Int J Parallel Prog 51, 186–207 (2023). https://doi.org/10.1007/s10766-022-00748-z

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10766-022-00748-z

Keywords

Navigation