21.4 C
London
Wednesday, October 16, 2024

David Johnson-Davies Builds a Lisp Compiler for the RP2350’s RISC-V Cores — in Lisp, Naturally



Lisp fan David Johnson-Davies is placing his favourite language on the Raspberry Pi Pico 2 improvement board, however in an uncommon method — by writing a Lisp compiler for the RP2350’s RISC-V cores… in his microcontroller-centric uLisp language.

“This can be a easy experimental Lisp compiler, written in uLisp, that may compile a Lisp operate into RISC-V machine code,” Johnson-Davies explains of his creation. You may run the compiler on the RISC-V core of a Raspberry Pi Pico 2 (or one other RP2350-based board). The compiler program is written within the subset of Frequent Lisp supported by uLisp, and can run on the RISC-V core of a RP2350-based board; I used a Raspberry Pi Pico 2.”

uLisp, or microLisp, is, because the title suggests, a variant of Lisp for microcontrollers. Initially styled LISP, and named for an abbreviation of “checklist processor,” Lisp was created by John McCarthy, Steve Russell, Timothy P. Hart, and Mike Levin within the Sixties as a language for mathematical notation influenced by lambda calculus. uLisp takes this and makes it appropriate for microcontroller use, in a lot the identical method the MicroPython does for Python.

Johnson-Davies’ newest mission builds on his earlier work to construct a Lisp compiler in uLisp focusing on Arm structure cores, as discovered on the unique Raspberry Pi Pico and its RP2040 microcontroller. This time, it targets the newer RP2350 on the Raspberry Pi Pico 2 — ignoring the chip’s two Arm cores for the 2 Hazard3 RISC-V cores as a substitute.

“To run the compiler you merely name compile on a Lisp operate,” Johnson-Davies explains. “The operate might be compiled right into a machine code operate, changing the unique Lisp code, in order that calling [the function name] will now execute the RISC-V machine-code model.”

The straightforward cause for doing so, except for “as a result of you possibly can”: efficiency. In comparison with interpreted Lisp, the compiled features run orders of magnitude quicker: a least-prime factorization operate takes 5.4s as interpreted Lisp, and simply 19ms compiled; a Takeuchi operate benchmark completes in 4.1s interpreted and simply 16ms compiled; and a recursive implementation of the Fibonacci collection takes a whopping 50.5s interpreted and simply 80ms as soon as compiled.

The mission is documented in full on the uLisp web site.

Latest news
Related news

LEAVE A REPLY

Please enter your comment!
Please enter your name here