phanrahan/magma

What is the recommendation for FSMs in magma?

Closed this issue · 2 comments

What is the recommended way for coding FSMs in magma?

  • m.when and m.elsewhen conditional statements
  • m.coroutine / m.sequential2

The when and elsewhen constructs seem familiar from a verilog perspective albeit more analogous to if and else if instead of the commonly used case statement. On the other hand, with coroutines it seems refactoring large hierarchical FSMs with branches and loops would be easier, and the code more readable, using the yield and yield from construct.

  • And is there support for case statements similar to switch, is in Chisel or an equivalent like Python's match, case?

I would use m.when for now.

We are planning to add m.coroutine style constructs using an m.when style syntax, but that feature is still planned and not ready. We are working on a sum type feature tracked by this PR: #1150 this introduces a match/case style syntax, which we then plan to add the coroutine style syntax on top of.

That sounds great. Thanks, @leonardt!