website/grants/cpu_with_programmable_decoder.html

285 lines
21 KiB
HTML

<!DOCTYPE HTML>
<html lang="en" class="light" dir="ltr">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>NLNet Grant Proposal: Programmable Decoder -- 2025-12-681</title>
<!-- Custom HTML head -->
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff">
<link rel="icon" href="../favicon.svg">
<link rel="shortcut icon" href="../favicon.png">
<link rel="stylesheet" href="../css/variables.css">
<link rel="stylesheet" href="../css/general.css">
<link rel="stylesheet" href="../css/chrome.css">
<!-- Fonts -->
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="../fonts/fonts.css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../highlight.css">
<link rel="stylesheet" href="../tomorrow-night.css">
<link rel="stylesheet" href="../ayu-highlight.css">
<!-- Custom theme stylesheets -->
<link rel="stylesheet" href="../src/custom.css">
<!-- MathJax -->
<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</head>
<body class="sidebar-visible no-js">
<div id="body-container">
<!-- Provide site root to javascript -->
<script>
var path_to_root = "../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script>
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script>
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('light')
html.classList.add(theme);
var body = document.querySelector('body');
body.classList.remove('no-js')
body.classList.add('js');
</script>
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
<!-- Hide / unhide sidebar before it is displayed -->
<script>
var body = document.querySelector('body');
var sidebar = null;
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
} else {
sidebar = 'hidden';
}
sidebar_toggle.checked = sidebar === 'visible';
body.classList.remove('sidebar-visible');
body.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded "><a href="../index.html">Libre-Chip</a><a class="toggle"><div></div></a></li><li><ol class="section"><li class="chapter-item "><a href="../first_arch/index.html">Proposal for Libre-Chip's First CPU Architecture</a><a class="toggle"><div></div></a></li><li><ol class="section"><li class="chapter-item "><a href="../first_arch/register_renaming.html">Register Renaming</a></li></ol></li><li class="chapter-item expanded "><a href="../grants/index.html">Grants</a><a class="toggle"><div></div></a></li><li><ol class="section"><li class="chapter-item "><a href="../grants/nlnet-first.html">First NLNet Grant Proposal -- 2024-12-324</a></li><li class="chapter-item expanded "><a href="../grants/cpu_with_programmable_decoder.html" class="active">NLNet Grant Proposal: Programmable Decoder -- 2025-12-681</a></li></ol></li></ol></li><li class="chapter-item expanded "><a href="../Conduct.html">Conduct</a></li><li class="chapter-item expanded "><a href="../LICENSE.html">License</a><a class="toggle"><div></div></a></li><li><ol class="section"><li class="chapter-item "><a href="../gpl-3.0.html">GPL 3.0</a></li><li class="chapter-item "><a href="../lgpl-3.0.html">LGPL 3.0</a></li><li class="chapter-item "><a href="../lgpl-2.1.html">LGPL 2.1</a></li></ol></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
<div class="sidebar-resize-indicator"></div>
</div>
</nav>
<!-- Track and set sidebar scroll position -->
<script>
var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
sidebarScrollbox.addEventListener('click', function(e) {
if (e.target.tagName === 'A') {
sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
}
}, { passive: true });
var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
sessionStorage.removeItem('sidebar-scroll');
if (sidebarScrollTop) {
// preserve sidebar scroll position when navigating via links within sidebar
sidebarScrollbox.scrollTop = sidebarScrollTop;
} else {
// scroll sidebar to current active section when navigating via "next/previous chapter" buttons
var activeSection = document.querySelector('#sidebar .active');
if (activeSection) {
activeSection.scrollIntoView({ block: 'center' });
}
}
</script>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky">
<div class="left-buttons">
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</label>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title"></h1>
<div class="right-buttons">
<a href="https://git.libre-chip.org/libre-chip/website" title="Git repository" aria-label="Git repository">
<i id="git-repository-button" class="fa fa-git"></i>
</a>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script>
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1 id="nlnet-grant-proposal----libre-chips-cpu-with-a-programmable-decoder-to-run-multiple-isas-at-full-speed----2025-12-681"><a class="header" href="#nlnet-grant-proposal----libre-chips-cpu-with-a-programmable-decoder-to-run-multiple-isas-at-full-speed----2025-12-681">NLNet Grant Proposal -- Libre-Chip's CPU with a Programmable Decoder to Run Multiple ISAs at Full Speed -- 2025-12-681</a></h1>
<p>Project Name: Libre-Chip's CPU with a Programmable Decoder to Run Multiple ISAs at Full Speed</p>
<p>Website/Wiki: <a href="https://libre-chip.org/">https://libre-chip.org/</a></p>
<h1 id="abstract"><a class="header" href="#abstract">Abstract</a></h1>
<p>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.</p>
<p>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.</p>
<h2 id="relevant-previous-involvement"><a class="header" href="#relevant-previous-involvement">Relevant Previous Involvement</a></h2>
<ul>
<li>
<p>Jacob Lifshay -- Currently working on <a href="https://nlnet.nl/project/Libre-Chip-proof/">https://nlnet.nl/project/Libre-Chip-proof/</a>. Worked on designing PowerISA CPUs with Libre-SOC for 5yr, built a simple OoO Superscalar CPU simulator <a href="https://salsa.debian.org/Kazan-team/power-cpu-sim">https://salsa.debian.org/Kazan-team/power-cpu-sim</a>, built a RV32I CPU with VGA output in a few weeks that runs a 2.5D maze game <a href="https://github.com/programmerjake/rv32">https://github.com/programmerjake/rv32</a>. Also is the main author of the <a href="https://git.libre-chip.org/libre-chip/fayalite">Fayalite</a> 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.</p>
</li>
<li>
<p>Cesar Strauss - Currently working on <a href="https://nlnet.nl/project/Libre-Chip-proof/">https://nlnet.nl/project/Libre-Chip-proof/</a>. 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
(<a href="https://archive.fosdem.org/2024/schedule/event/fosdem-2024-2215-an-introduction-to-formal-verification-of-digital-circuits/">https://archive.fosdem.org/2024/schedule/event/fosdem-2024-2215-an-introduction-to-formal-verification-of-digital-circuits/</a>).</p>
</li>
<li>
<p>Tobias Platen - Currently working on <a href="https://nlnet.nl/project/Libre-Chip-proof/">https://nlnet.nl/project/Libre-Chip-proof/</a>. 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 (<a href="https://archive.fosdem.org/2024/schedule/event/fosdem-2024-2060-using-the-ecp5-for-libre-soc-prototyping/">https://archive.fosdem.org/2024/schedule/event/fosdem-2024-2060-using-the-ecp5-for-libre-soc-prototyping/</a>).</p>
</li>
</ul>
<h1 id="requested-support"><a class="header" href="#requested-support">Requested support</a></h1>
<p>Requested Amount €105000</p>
<h2 id="cost-explanation"><a class="header" href="#cost-explanation">Cost Explanation</a></h2>
<p>Libre-Chip is currently funded by NLnet for <a href="https://nlnet.nl/project/Libre-Chip-proof/">https://nlnet.nl/project/Libre-Chip-proof/</a>, which we expect to be mostly completed by the time we can start working on this grant.</p>
<p>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.</p>
<p>We're aiming for a FTE rate of $69305.60/yr per person which is rate used in our grant application for <a href="https://nlnet.nl/project/Libre-Chip-proof/">https://nlnet.nl/project/Libre-Chip-proof/</a></p>
<p>Estimated Budget:</p>
<ul>
<li>€ 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.</li>
<li>€ 20000 Add the programmable decoder and µOp cache to our CPU design.</li>
<li>€ 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.</li>
<li>€ 15000 Write code to convert the HDL IR to a bitstream we can program into the decoder.</li>
<li>€ 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.</li>
</ul>
<h2 id="compare-with-existinghistorical-efforts"><a class="header" href="#compare-with-existinghistorical-efforts">Compare with existing/historical efforts</a></h2>
<p>The <a href="https://en.wikipedia.org/wiki/Transmeta_Crusoe">Transmeta Crusoe</a> 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.</p>
<h2 id="technical-challenges-we-expect-to-solve-during-the-project"><a class="header" href="#technical-challenges-we-expect-to-solve-during-the-project">Technical challenges we expect to solve during the project</a></h2>
<p>We expect to solve 3 technical challenges:</p>
<ul>
<li>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.</li>
<li>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.</li>
<li>To continue work on getting our CPU to be more complete and able to run more complex software.</li>
</ul>
<p>A WIP high-level design of our CPU: <a href="https://libre-chip.org/first_arch/index.html">https://libre-chip.org/first_arch/index.html</a></p>
<p>Text that was intended to be part of the Abstract, but didn't fit within the 1200 character length constraint:
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.</p>
<p>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.</p>
<p>Our CPU is a continuation of the CPU from <a href="https://nlnet.nl/project/Libre-Chip-proof/">https://nlnet.nl/project/Libre-Chip-proof/</a>, which we will also be extending to support more features such as memory paging, floating-point instructions, and better compatibility with the PowerISA specification.</p>
<h2 id="ecosystem"><a class="header" href="#ecosystem">Ecosystem</a></h2>
<p>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.</p>
<p>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.</p>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../grants/nlnet-first.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next prefetch" href="../Conduct.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="../grants/nlnet-first.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next prefetch" href="../Conduct.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script>
window.playground_copyable = true;
</script>
<script src="../elasticlunr.min.js"></script>
<script src="../mark.min.js"></script>
<script src="../searcher.js"></script>
<script src="../clipboard.min.js"></script>
<script src="../highlight.js"></script>
<script src="../book.js"></script>
<!-- Custom JS scripts -->
<script src="../mermaid.min.js"></script>
<script src="../mermaid-init.js"></script>
</div>
</body>
</html>