dan-fritchman / Hdl21

Hardware Description Library
BSD 3-Clause "New" or "Revised" License
69 stars 16 forks source link

It's probably time for immutable hierarchy walking, compiling, elaboration, etc. #209

Open dan-fritchman opened 1 year ago

dan-fritchman commented 1 year ago

Hdl21 has many things that walk a hierarchical HDL-data-model tree, checking or manipulating each node along the way.
Notable examples include:

The way the "mutable" versions have always worked is by modifying their input modules inline. This has always helped streamline their implementations, largely because... we don't have to track what's in the old, input objects vs the new, compiled ones. They're the same things.

It's pretty much always been a concern that this would become a pain. Now it has. Particularly since:

Most prior applications of Hdl21 had essentially just done (1), (2), end program, run a separate Python program/ process. That still works just fine.

We added band-aids to help aid the (1-4) loop, notably including "public" access to the GeneratorCache, and a capacity to reset it. That also can work. It's just very hard to communicate (and in fact, to remember) when one needs to do it. And in some cases it doesn't have any effect. Particularly when the programs take references to the result modules, instead of re-calling the generator functions.

Ideas:

Questions: