State machine transition on internal signals -- is it legal?

D

Divyang M

Hi,

I am coding a state machine and have the transition from one state to
the next (or back to the same state) conditional on an internal signal.
The internal signal is essentially a counter. Is this OK to do and is
it synthesizable? Any forseen problems with it?

Here is a snippet of the state machine (one process type).
process(clk, rst) -- sensitivity list
"newline" is an INPUT port
"mydelay", "vert", and "horiz" are SIGNALs

when WAIT_16 =>
if newline = '1' then
mydelay <= mydelay + 1;
end if;

if mydelay < 16 then
next_state <= WAIT_16;
else
next_state <= DO_PROCESSING;
end if;

when DO_PROCESSING =>
if horiz < 640 then
horiz <= horiz + 1;
next_state <= DO_PROCESSING;
else
next_state <= WAIT_FOR_NEWLINE;
end if;

when WAIT_FOR_NEWLINE =>
if newline = '1' then
if vert < 240 then
vert <= vert + 1;
else
vert <= 0;
end if;
horiz <= 0;
next_state <= DO_PROCESSING;
else
next_state <= WAIT_FOR_NEWLINE;
end if;

end case;

Thanks,
Divyang M
 
J

Jerzy Gbur

Divyang said:
Hi,

I am coding a state machine and have the transition from one state to
the next (or back to the same state) conditional on an internal signal.
The internal signal is essentially a counter. Is this OK to do and is
it synthesizable? Any forseen problems with it?

Here is a snippet of the state machine (one process type).
process(clk, rst) -- sensitivity list
"newline" is an INPUT port
"mydelay", "vert", and "horiz" are SIGNALs

when WAIT_16 =>
if newline = '1' then
mydelay <= mydelay + 1;
end if;

if mydelay < 16 then
next_state <= WAIT_16;
else
next_state <= DO_PROCESSING;
end if;

when DO_PROCESSING =>
if horiz < 640 then
horiz <= horiz + 1;
next_state <= DO_PROCESSING;
else
next_state <= WAIT_FOR_NEWLINE;
end if;

when WAIT_FOR_NEWLINE =>
if newline = '1' then
if vert < 240 then
vert <= vert + 1;
else
vert <= 0;
end if;
horiz <= 0;
next_state <= DO_PROCESSING;
else
next_state <= WAIT_FOR_NEWLINE;
end if;

end case;

On the first glance it should work.

regards

Jerzy Gbur
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top