calyxir / calyx

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

eDSL: no `cells` list when defining new component #2038

Closed anshumanmohan closed 2 weeks ago

anshumanmohan commented 3 weeks ago

As #2034 shows, it is possible to create a free-floating list of cells prior to the creation of a component, and to then associate those cells with a component when creating the component.

This is a little dicey and inelegant. This PR removes that power. You must now create a component, and then construct and insert cells specifically into that component.

This change has no victims in the existing codebase, since NTT (the only user of this feature) has stopped using it as of #2034.

If someone really wanted to, say, insert some "basic" cells into a variety of components and then add more stuff per component, like so:

def manifest_basic_cells_in_a_vacuum() -> list[Cell]:
  // elided
comp1 = prog.component("comp1", cells=manifest_basic_cells_in_a_vacuum())
comp2 = prog.component("comp2", cells=manifest_basic_cells_in_a_vacuum())
// add more cells to comp1 and comp2 as needed

They can still do that:

def add_basic_cells_to_comp(comp) -> ():
  // elided
comp1 = prog.component("comp1")
add_basic_cells_to_comp(comp1)
comp2 = prog.component("comp2")
add_basic_cells_to_comp(comp2)
// add more cells to comp1 and comp2 as needed
rachitnigam commented 3 weeks ago

Awesome! This also brings it in line with the interface of the Rust-based builder which only allows construction of cells on a particular component.

anshumanmohan commented 3 weeks ago

Super. I'll just leave this PR open in case @sampsyo, @EclecticGriffin, or @calebmkim know of a good reason to keep this feature around!

EclecticGriffin commented 2 weeks ago

No objections here!