Support dynamic behaviour in pipelines
I want to support more dynamic behaviour in pipelines, and a key feature here is enable signals for pipeline stages.
You specify an enable signal as reg[cond]; which will make all registers of that stage reg(clk) x = if cond {x_next} else {x} instead of just `reg(clk) x = x_next;
The syntax is subject to change, [] was chosen because it doesn't collide with () for normal registers, but I think () is better.
In practice, the actual condition for enabling a stage is more complex than cond.
reg; // s1
reg[cond]; // s2
reg; // s3
Since s1 won't be able to propagate its result to 's2 if s2 retains its result, s1 inherits the cond from s2
Additionally, s3 will now have some cycles of duplicated values. I think the best option here would be to add a valid flag to everything downstream of a potentially disabled stage. This valid flag should probably also be made explicit by requiring Option<T> for pipelines which return values from conditioned stages. This requires some more poking around however. In addition, we probably also need to force handling of set in this case, but that requires even more thought.
I think we also need a stage.valid or something, to be able to reason about values not being valid downstream, and a stage.ready to reason about upstream values being held this cycle.
Current status
I'm making this draft early to allow you to review in smaller chunks. This particular first version only adds frontend support, it has no effect on codegen.
There are now 3 commits: frontend support, smol refactoring and codegen for enable signals. Valid signals remain to be gened
Author checklist
-
New Diagnostics have at least one snapshot test that triggers it -
Added a line to CHANGELOG.md, if relevant