A
alb
Hi Rick,
On 03/10/2013 05:24, rickman wrote:
[]
That's the reason why the order of procedures matter. I let the higher
FSM (the one that supposedly 'controls' everything) be the last to start
and then respectively the second in rank and so on...
They *are* registered. What I meant is that if you write this:
<code>
a := a + 1;
</code>
then 'a' is used before it is assigned, leading to a register. This is
what happens in my fsm procedure, whether the procedure has a single
case-switch which rolls over the state value, using it before assigning it.
[]
I don't get this. My state variable at each state depends on several
conditions, some of them been states of another FSM (like you would have
with a counter), where is the problem?
See the following snippet of code:
<code>
-------------------------------------------------------------------------------
procedure writ_read (
state_v : inout state_t;
mstate_v : in mstate_t;
nstate_v : in nstate_t) is
begin
case state_v is
when IDLE =>
if mstate_v = START_READ or nstate_v = START_READ then
state_v := READ_BGN;
elsif mstate_v = START_WRITE or nstate_v = START_WRITE then
state_v := WRITE_BGN;
end if;
when READ_BGN =>
state_v := READ_END; -- this is one clock cycle
nRD_v := not nRD_v;
when READ_END =>
state_v := IDLE;
nRD_v := not nRD_v;
DATA_v := DATA;
when WRITE_BGN =>
state_v := WRITE_END; -- this is one clock cycle
nWR_v := not nWR_v;
when WRITE_END =>
state_v := DONE;
nWR_v := not nWR_v;
when DONE =>
state_v := IDLE;
DATA_v := (others => 'Z'); -- release the bus
when others => null;
end case;
end procedure writ_read;
</code>
the 'awareness' you refer to is in the IDLE state case, where the 'if'
branch reacts on the others' state variables... Being the author of this
code I certainly cannot see the 'complication' that lies behind it, but
please advise on how to write it *more* clear than this [1].
[]
'this' or 'that' clock cycle does not really matter to me, latency apart
I get the same throughput.
On 03/10/2013 05:24, rickman wrote:
[]
That *is* the problem. The second procedure sees the next state rather
than the current state.
That's the reason why the order of procedures matter. I let the higher
FSM (the one that supposedly 'controls' everything) be the last to start
and then respectively the second in rank and so on...
I thought they were all registers? If not, they aren't state variables.
They *are* registered. What I meant is that if you write this:
<code>
a := a + 1;
</code>
then 'a' is used before it is assigned, leading to a register. This is
what happens in my fsm procedure, whether the procedure has a single
case-switch which rolls over the state value, using it before assigning it.
[]
And therein lies the problem. When using a single variable like this,
if some state variable have been updated but not others, the FSM gets
very complex.
I don't get this. My state variable at each state depends on several
conditions, some of them been states of another FSM (like you would have
with a counter), where is the problem?
The isolated procedures for updating each state variable
in your FSM have to be aware of one another and the order in which they
are invoked. This greatly complicates the code and understanding of it.
I would find that to be impossibly difficult to use. I don't consider
this to be useful decomposition.
See the following snippet of code:
<code>
-------------------------------------------------------------------------------
procedure writ_read (
state_v : inout state_t;
mstate_v : in mstate_t;
nstate_v : in nstate_t) is
begin
case state_v is
when IDLE =>
if mstate_v = START_READ or nstate_v = START_READ then
state_v := READ_BGN;
elsif mstate_v = START_WRITE or nstate_v = START_WRITE then
state_v := WRITE_BGN;
end if;
when READ_BGN =>
state_v := READ_END; -- this is one clock cycle
nRD_v := not nRD_v;
when READ_END =>
state_v := IDLE;
nRD_v := not nRD_v;
DATA_v := DATA;
when WRITE_BGN =>
state_v := WRITE_END; -- this is one clock cycle
nWR_v := not nWR_v;
when WRITE_END =>
state_v := DONE;
nWR_v := not nWR_v;
when DONE =>
state_v := IDLE;
DATA_v := (others => 'Z'); -- release the bus
when others => null;
end case;
end procedure writ_read;
</code>
the 'awareness' you refer to is in the IDLE state case, where the 'if'
branch reacts on the others' state variables... Being the author of this
code I certainly cannot see the 'complication' that lies behind it, but
please advise on how to write it *more* clear than this [1].
[]
Yes, Mealy and Moore are not often used in a strict sense, but the point
is access to the *next* value of the state rather than the current
value. This lets you get registered outputs out on *this* clock edge
rather than having them wait a clock cycle.
'this' or 'that' clock cycle does not really matter to me, latency apart
I get the same throughput.