FSM output functions in an array

P

psihodelia

Is it possible to have in a FSM one procedure-or-function for each
state? It should make the program code easy to read. It will be also
better to have an array of functions and call them according FSM state
number. Do you have any idea how to implement this approach in VHDL?

Here is a vivid wishful pseudo-Python example:


def read(args):
do smth.
def write(args):
do smth.
...
function = [1:read, 2:write, 3:sleep, 4:wake]
next_state = [1:3, 2:3, 3:3, 4:1]
def FSM_states_switch:
state = next_state[state]
def FSM_output_function:
function[state](args)
 
K

KJ

Is it possible to have in a FSM one procedure-or-function for each
state? Yes.

It should make the program code easy to read. It will be also
better to have an array of functions and call them according FSM state
number.

You can't have an array of functions in VHDL. You can have a function that
takes the current state as an argument (along with other inputs which are
usually necessary) and compute the next state but I don't think it will do
anything to make the code more readable since, although the code for the
state machine collapses right down to a simple function call, that code has
now moved verbatim over to some other function so the reader now is
redirected and you haven't really simplified or reduced the actual number of
lines of code. Just my 2 cents.
Do you have any idea how to implement this approach in VHDL?
Functions and procedures are useful to use in several places (including
FSMs) so you're general path of investigating how to use them is good. Mike
Tressler's web site has several good examples to peruse that may give you
some ideas to build upon

http://home.comcast.net/~mike_treseler/

KJ
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top