Open thajohns opened 2 months ago
On further testing, the issue also happens with registers.
Hi,
Yes right.
Currently, the parrent statemachine first do childStateMachines.foreach(_.build())
and then build itself.
Instead what should maybe be done, is to stage the child state machine build into multiple sub step called at different stages of the parrent FSM.
If an FSM drives a combinational signal from the
whenIsActive
block of one of its states, and then transitions to a nested FSM state whose entry state has anonEntry
block which also drives the combinational signal, then the outer FSM's statement always wins even if it appears earlier in the file.For example:
In the above FSM, we expect to see
io.a
andio.b
act the same way, since the second driver onio.b
(the only one whichio.a
does not have) is redundant. However,io.b
never goes high, butio.a
does.The generated Verilog also demonstrates the issue. The (correct) block produced for
io.a
is:whereas the (incorrect) block for
io.b
is:In the latter, the branch for the
idle
state comes after the branch for theonEntry
state (theif
above), which if I understand Verilog's semantics correctly means that it wins.