From 1a6f8b5714c3bfa63f2b751700a4400b2e8d1115 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Fri, 28 Nov 2025 14:13:38 -0800 Subject: [PATCH 1/9] add WIP grant proposal: Libre-Chip's CPU with a Programmable Decoder to Run Multiple ISAs at Full Speed --- src/grants/cpu_with_programmable_decoder.md | 68 +++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/grants/cpu_with_programmable_decoder.md diff --git a/src/grants/cpu_with_programmable_decoder.md b/src/grants/cpu_with_programmable_decoder.md new file mode 100644 index 0000000..040a25f --- /dev/null +++ b/src/grants/cpu_with_programmable_decoder.md @@ -0,0 +1,68 @@ +# NLNet Grant Proposal -- Libre-Chip's CPU with a Programmable Decoder to Run Multiple ISAs at Full Speed + +Project Name: Libre-Chip's CPU with a Programmable Decoder to Run Multiple ISAs at Full Speed + +Website/Wiki: + +# Abstract + +Modern computers are built on several different mutually-incompatible popular ISAs such as x86_64, PowerISA, AArch64, and RISC-V. Many of the most popular ISAs have no high-speed libre/open-source implementations, which makes them much harder to trust since you can't inspect their source-code to look for bugs or secret backdoors. Additionally, there are basically no existing modern CPUs which can run more than one of those ISAs without requiring software emulation, which is slow and can often be buggy. + +To solve those issues, we are building a libre-licensed CPU with speculative out-of-order superscalar execution that will support a programmable decoder (loosely inspired by FPGAs) followed by a µOp cache so the CPU can be programmed to decode and run just about any ISA you like at full speed, by handling the most common instructions entirely in hardware, with software fallback for decoding some of the less common instructions which can still easily be executed in hardware (storing the decoded instructions in the µOp cache), and full software emulation for the remaining instructions. + +We are planning on building a custom compiler so the user can select an ISA and that compiler can compile the source code of QEMU to automatically generate the required bitstream for the FPGA, as well as generating the software required for decoding and/or emulating the remaining parts of the chosen ISA. + +Our CPU is a continuation of the CPU from , which we will also be extending to support more features such as memory paging, floating-point instructions, and better compatibility with the PowerISA specification. + +## Relevant Previous Involvement + +* Jacob Lifshay -- Currently working on . Worked on designing PowerISA CPUs with Libre-SOC for 5yr, built a simple OoO Superscalar CPU simulator , built a RV32I CPU with VGA output in a few weeks that runs a 2.5D maze game . Also is the main author of the [Fayalite](https://git.libre-chip.org/libre-chip/fayalite) HDL library. Has some experience writing compilers, e.g. Fayalite's simulator is implemented as a simple compiler to an internal p-code, also wrote a compiler from a language based on QuickBASIC to x86 (it successfully compiled a program he also wrote that animates a 3D diagram of a molecule), also wrote a JavaScript interpreter that properly handles running generators and is a compiler to internal p-code and has some optimization passes for specialization based on deduced types. Has experience writing and using LLVM IR, as well as being a contributor to LLVM and Rust. + +* Cesar Strauss - Currently working on . Contributed to the Libre-SOC project, mostly on digital +design and formal verification. Presented the talk "An introduction to +Formal Verification of Digital Circuits" on FOSDEM 2024 +(). + +* TODO: does Tobias Platen want to participate? + +# Requested support + +Requested Amount €100000 + +## Cost Explanation + +Libre-Chip is currently funded by NLnet for , which we expect to be mostly completed by the time we can start working on this grant. + +We are requesting more than €50000 based on Jacob Lifshay having previously completed a grant as part of Libre-SoC. If that is not sufficient, we can adjust our budget down by removing some tasks, and possibly by not implementing as much of the custom compiler, leaving some of it as future work. + +All of the cost is for labor. + +We're aiming for a rate of $69305.60/yr per person which is rate used in our grant application for + +Estimated Budget: + +* € 40000 Adding missing features to our CPU, such as memory paging, floating-point instructions, a better cache hierarchy, and better compatibility with the PowerISA specification. +* € 20000 Add the programmable decoder and µOp cache to our CPU design. +* € 20000 Build a compiler that can extract the decoder portion of QEMU using pattern matching and some symbolic execution of LLVM IR, converting to a HDL IR more suitable for hardware. +* € 15000 Write code to convert the HDL IR to a bitstream we can program into the decoder. +* € 10000 Get the fallback emulator to work, as well as misc. other parts of the compiler needed to make the whole system work together. + +## Compare with existing/historical efforts + +The [Transmeta Crusoe](https://en.wikipedia.org/wiki/Transmeta_Crusoe) is somewhat similar in that it implemented x86 by translating to an internal VLIW instruction set by using software JIT compilation, however our grant proposal differs in that we have hardware to handle the most common instructions instead of relying on software for everything, also we aim for compatibility with much more than just x86, unlike the Transmeta Crusoe. + +## Technical challenges we expect to solve during the project + +We expect to solve 3 technical challenges: + +* To design and write a working programmable decoder and µOp cache such that our CPU can run arbitrary ISAs. For now we're planning on it being able to support older x86_64 (where the patents have expired), PowerISA, and RISC-V, though we don't necessarily expect to have complete support for all of those within the scope of this grant. +* To build a custom compiler that can successfully extract a decoder for the most common instructions of the user's selected ISA, as well as generate a bitstream to program our decoder. +* To continue work on getting our CPU to be more complete and able to run more complex software. + +A WIP high-level design of our CPU: + +## Ecosystem + +We are likely to work with QEMU upstream, as well as LLVM and Clang. We are already working with the FIRRTL specification GitHub repo to resolve problems we encounter, as well as with LLVM Circt, and with the Rust Language. + +This project benefits Europeans (as well as everyone else) by providing a libre/open-source CPU with good performance that supports many of the most-popular ISAs all on the same CPU. From ea3967903428a0feddbfe696f80747feede6b29a Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Fri, 28 Nov 2025 14:47:26 -0800 Subject: [PATCH 2/9] update wording --- src/grants/cpu_with_programmable_decoder.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grants/cpu_with_programmable_decoder.md b/src/grants/cpu_with_programmable_decoder.md index 040a25f..868bd1b 100644 --- a/src/grants/cpu_with_programmable_decoder.md +++ b/src/grants/cpu_with_programmable_decoder.md @@ -8,7 +8,7 @@ Website/Wiki: Modern computers are built on several different mutually-incompatible popular ISAs such as x86_64, PowerISA, AArch64, and RISC-V. Many of the most popular ISAs have no high-speed libre/open-source implementations, which makes them much harder to trust since you can't inspect their source-code to look for bugs or secret backdoors. Additionally, there are basically no existing modern CPUs which can run more than one of those ISAs without requiring software emulation, which is slow and can often be buggy. -To solve those issues, we are building a libre-licensed CPU with speculative out-of-order superscalar execution that will support a programmable decoder (loosely inspired by FPGAs) followed by a µOp cache so the CPU can be programmed to decode and run just about any ISA you like at full speed, by handling the most common instructions entirely in hardware, with software fallback for decoding some of the less common instructions which can still easily be executed in hardware (storing the decoded instructions in the µOp cache), and full software emulation for the remaining instructions. +To solve those issues, we are building a libre-licensed CPU with speculative out-of-order superscalar execution that will support a programmable decoder (loosely inspired by FPGAs) followed by a µOp cache so the CPU can be programmed to decode and run at full speed just about any ISA you select, by handling the most common instructions entirely in hardware, with software fallback for decoding some of the less common instructions which can still easily be executed in hardware (storing the decoded instructions in the µOp cache), and full software emulation for the remaining instructions. Additionally you can easily switch between selected ISAs by reprogramming the decoder, allowing you to e.g. run an x86_64 program alongside a RISC-V program in the same OS and quickly context-switch between them. We are planning on building a custom compiler so the user can select an ISA and that compiler can compile the source code of QEMU to automatically generate the required bitstream for the FPGA, as well as generating the software required for decoding and/or emulating the remaining parts of the chosen ISA. From 7331330d68f0619151d550d0d255aa24da224943 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Fri, 28 Nov 2025 15:02:14 -0800 Subject: [PATCH 3/9] more wording adjustments --- src/grants/cpu_with_programmable_decoder.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/grants/cpu_with_programmable_decoder.md b/src/grants/cpu_with_programmable_decoder.md index 868bd1b..4c0a339 100644 --- a/src/grants/cpu_with_programmable_decoder.md +++ b/src/grants/cpu_with_programmable_decoder.md @@ -33,9 +33,7 @@ Requested Amount €100000 Libre-Chip is currently funded by NLnet for , which we expect to be mostly completed by the time we can start working on this grant. -We are requesting more than €50000 based on Jacob Lifshay having previously completed a grant as part of Libre-SoC. If that is not sufficient, we can adjust our budget down by removing some tasks, and possibly by not implementing as much of the custom compiler, leaving some of it as future work. - -All of the cost is for labor. +We are requesting more than €50000 based on Jacob Lifshay having previously completed a grant as part of Libre-SoC. If that is not allowed, we can adjust our budget down by removing some tasks, and possibly by not implementing as much of the custom compiler, leaving some of it as future work. We're aiming for a rate of $69305.60/yr per person which is rate used in our grant application for From 0b279f1f0fc627946895ee84d45a477080296228 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Fri, 28 Nov 2025 15:03:20 -0800 Subject: [PATCH 4/9] wording --- src/grants/cpu_with_programmable_decoder.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grants/cpu_with_programmable_decoder.md b/src/grants/cpu_with_programmable_decoder.md index 4c0a339..32e1add 100644 --- a/src/grants/cpu_with_programmable_decoder.md +++ b/src/grants/cpu_with_programmable_decoder.md @@ -35,7 +35,7 @@ Libre-Chip is currently funded by NLnet for +We're aiming for a FTE rate of $69305.60/yr per person which is rate used in our grant application for Estimated Budget: From 29cc01dfddf2cb4a905590d25f5a901cfb18763c Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Fri, 28 Nov 2025 15:06:58 -0800 Subject: [PATCH 5/9] add programmable decoder grant to summary.md --- src/SUMMARY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 60b3b40..311ac28 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -3,6 +3,7 @@ * [Register Renaming](first_arch/register_renaming.md) * [Grants](grants/index.md) * [First NLNet Grant Proposal -- 2024-12-324](grants/nlnet-first.md) + * [NLNet Grant Proposal: Programmable Decoder](grants/cpu_with_programmable_decoder.md) * [Conduct](Conduct.md) * [License](LICENSE.md) * [GPL 3.0](gpl-3.0.md) From 259afa1fa9a74a0465e4b89ef791ce3291aef30f Mon Sep 17 00:00:00 2001 From: Tobias Alexandra Platen Date: Sun, 30 Nov 2025 11:24:17 +0100 Subject: [PATCH 6/9] add my paragraph --- src/grants/cpu_with_programmable_decoder.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/grants/cpu_with_programmable_decoder.md b/src/grants/cpu_with_programmable_decoder.md index 32e1add..5051abf 100644 --- a/src/grants/cpu_with_programmable_decoder.md +++ b/src/grants/cpu_with_programmable_decoder.md @@ -23,7 +23,10 @@ design and formal verification. Presented the talk "An introduction to Formal Verification of Digital Circuits" on FOSDEM 2024 (). -* TODO: does Tobias Platen want to participate? +* Tobias Platen - Currently working on . Contributed to the Libre-SOC project, mostly on +ECP5 FPGA prototypes and DDR SDRAM memory interfaces. Presented the talk "Using the ECP5 +for Libre-SOC prototyping" on FOSDEM 2024 (). + # Requested support From 2f742e7606a4f5fdfdd86aea20d6f9ebd81656af Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Sun, 30 Nov 2025 02:47:02 -0800 Subject: [PATCH 7/9] clean up whitespace --- src/grants/cpu_with_programmable_decoder.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/grants/cpu_with_programmable_decoder.md b/src/grants/cpu_with_programmable_decoder.md index 5051abf..7d4bf22 100644 --- a/src/grants/cpu_with_programmable_decoder.md +++ b/src/grants/cpu_with_programmable_decoder.md @@ -23,11 +23,10 @@ design and formal verification. Presented the talk "An introduction to Formal Verification of Digital Circuits" on FOSDEM 2024 (). -* Tobias Platen - Currently working on . Contributed to the Libre-SOC project, mostly on -ECP5 FPGA prototypes and DDR SDRAM memory interfaces. Presented the talk "Using the ECP5 +* Tobias Platen - Currently working on . Contributed to the Libre-SOC project, mostly on +ECP5 FPGA prototypes and DDR SDRAM memory interfaces. Presented the talk "Using the ECP5 for Libre-SOC prototyping" on FOSDEM 2024 (). - # Requested support Requested Amount €100000 From 8bf2a914fa26e749744375fb1db3e51734a74561 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Sun, 30 Nov 2025 11:52:22 -0800 Subject: [PATCH 8/9] apply wording change suggested by cesar in https://git.libre-chip.org/libre-chip/website/pulls/1#issuecomment-380 --- src/grants/cpu_with_programmable_decoder.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grants/cpu_with_programmable_decoder.md b/src/grants/cpu_with_programmable_decoder.md index 7d4bf22..28ffddc 100644 --- a/src/grants/cpu_with_programmable_decoder.md +++ b/src/grants/cpu_with_programmable_decoder.md @@ -45,7 +45,7 @@ Estimated Budget: * € 20000 Add the programmable decoder and µOp cache to our CPU design. * € 20000 Build a compiler that can extract the decoder portion of QEMU using pattern matching and some symbolic execution of LLVM IR, converting to a HDL IR more suitable for hardware. * € 15000 Write code to convert the HDL IR to a bitstream we can program into the decoder. -* € 10000 Get the fallback emulator to work, as well as misc. other parts of the compiler needed to make the whole system work together. +* € 10000 Get the fallback software decoder and the software instruction emulator to work, as well as misc. other parts of the compiler needed to make the whole system work together. ## Compare with existing/historical efforts From df1721f487e0f8cd6b37e1eb9cc08898e80d0beb Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Sun, 30 Nov 2025 11:58:03 -0800 Subject: [PATCH 9/9] adjust requested amount to actually be the sum of the tasks' amounts --- src/grants/cpu_with_programmable_decoder.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grants/cpu_with_programmable_decoder.md b/src/grants/cpu_with_programmable_decoder.md index 28ffddc..e9dbe86 100644 --- a/src/grants/cpu_with_programmable_decoder.md +++ b/src/grants/cpu_with_programmable_decoder.md @@ -29,7 +29,7 @@ for Libre-SOC prototyping" on FOSDEM 2024 (