When being in a state "a1" how can I show that the next arrows will have a precedence over each other, without having an overhead of extra states?
Full example:
- We are at
a1
state and signalsx && y
are asserted: we go to state b1 - If that condition is not asserted but
x && z
is asserted then we go to state b2 - If the above conditions are not asserted but
x
is asserted then we go to state b3
Visual concept:
In the above "FSM" we can't see that x && y
is checked before the other two.
Code snippet:
always_comb begin
case (states)
a1: begin
if (x && y)
next_state = b1;
else if (x && z)
next_state = b2;
else if (x)
next_state = b3;
else
next_state = a1;
end
endcase
end
Ideally, you'd need to cover all the possible combinations of input events in each state to get a proper DFA (deterministic FSM).
However, you can get away by fully specifying the triggers in terms of input signals, and let your HDL default to "no transition". In that case:
a1
tob1
may be triggered byx && y && !z
a1
tob2
may be triggered byx && !y && z
a1
tob3
may be triggered byx && !y && !z
(with
!
denoting logical 'not').With an alphabet of 3 symbols (your three input signals), you get 2^3 = 8 possible combinations in every state. Ask yourself: in your current design, what happens if all of
x
,y
andz
get asserted ? You need to be specific about that.EDIT
Let me be more specific.
Let's consider
A
,B
,C
, ...H
as events, each representing one possible combination of input signals, such as:Then try to express your transitions in terms of
A
,B
,C
, ...H
. If you can, the resulting FSM is suitable to your task. If you can't, you should probably rethink your logic.