calyxir / calyx

Intermediate Language (IL) for Hardware Accelerator Generators
https://calyxir.org
MIT License
450 stars 44 forks source link

eDSL: new example, new docs #2002

Closed anshumanmohan closed 1 week ago

anshumanmohan commented 1 month ago

This PR closes #1908.

There are two old pages of documentation:

  1. Emitting Calyx from Python, which walks through builder_example.py and also discusses a tiny made-up code snippet to show parallelism in the control section.
  2. Builder Library Reference, which presents a multi-component design as an example and then covers a number of topics.

Let us say that the things that these two pages cover are our "syllabus", and we won't drop anything from the syllabus without talking about it. As I mentioned above, neither of these pages discusses static stuff or the new higher-level constructors, so that stuff goes into the syllabus too.

This PR overhauls builder_example.py, such that the documentation of the builder library can mostly "just" be a discussion of the example program, and such that that discussion covers the syllabus.

I want to teach people using a runnable example because many of the builder's features (especially the "modern" higher-level constructors) can only be understood via code generation: a single line of Python generates quite a few lines of Calyx in different parts of the Calyx program. This is why just showing snippets of Python/Calyx is ineffective.

I want the example program to show most features, but I don't want to overwhelm the user with too much info at once. To this end, I'm going to split the builder example into a number of components. A component will have a small number of self-contained lessons.

There is also a simple "hello world" example that just introduces an adder component. This is documented separately and line-by-line. For the walkthrough proper, I still go in program order but I only stop to explain new concepts.

Here's the syllabus: