amaranth
amaranth copied to clipboard
Add an `amaranth.hdl._ast.Choice` node, use it for `ArrayProxy`, `Part`, and `Mux`
We currently have a wart in the core part of the language, which is that an AST processor has to care about ArrayProxy (a weirdly shaped Migen-derived construct) and Part legalization. Pre-legalization ArrayProxy and Part are not something that can be handled by our IR or basically any RTL backend, so they are not wanted there; they are, at most, only wanted in the simulator AST compiler, and even that is unclear. In addition, there's no reasonable way to get something like an ArrayProxy but which is a mapping with enum keys, which is one of the oldest open design issues (#73).
We should add a Choice node which is essentially the same as Decision from #1074, but in the value language instead of statement language. ArrayProxy will lower to it when legal, Part will lower to it when legalized on LHS, and Mux will lower to it immediately (enabling it to be used on LHS).
See also #480. This improvement does not add any features to the surface language so it doesn't need an RFC. Choice is a far better primitive than Array to expose for Amaranth-based DSL authors so Choice is something we can eventually make public.