Open
Description
Issue by whitequark
Saturday Sep 14, 2019 at 21:22 GMT
Originally opened as m-labs/nmigen#206
It looks like the existing FSM sub-language is not expressive enough (e.g. #195, #205). Right now it is implemented in a very minimal way: only the absolute necessary parts. Predictably, this does not cover some interesting cases.
- Apart from
act
, oMigen haddelayed_enter
. I've never seen it actually used (looks like it is only used inmisoc/cores/minicon
andmisoc/cores/lasmicon
) and the implementation seems very wasteful, as it expands the entire delay into FSM states, which has a serious potential to bloat the FSM state register and prevent further optimizations. - Apart from
ongoing
, oMigen hadbefore_entering
,before_leaving
,after_entering
andafter_leaving
. Theafter_*
methods worked fine, butbefore_*
were prone to combinatorial loops, and IMO are more of an attractive nuisance than a good way to structure your code. - Right now, nMigen requires that a state would be defined in exactly one
with m.State()
block. (@RobertBaruch hit this in I can has Cover? #195) This does not match oMigen, where any amount offsm.act
statements would work, and they would be appended in execution order. However, @emilazy correctly notes that this does not work the same way as switches (which are priority encoders, with earlier cases overriding later cases), and this could be confusing. - Right now,
m.next
can only be written, not accessed. (@RobertBaruch hit this in Adds Value.matches #205) This does match oMigen, but could be useful in some cases. @emilazy notes that having a write-only property is confusing, however, we don't currently have anything like first-class enumerated signals, so it's not clear whatm.next
would even return; certainly it could not be a string. - Right now,
m.next
can only switch the state of the innermost FSM, not any outer FSM. This is a serious ergonomics problem with complex FSMs because while there is a cumbersome workaround, there's really no good reason for this restriction--it was an oversight.