Hi,
I have an assignment which entails coding a sequential state machine form arbitrary charecteristic table of a flip-flop and the state specifications given.

.For example, if the user wants one input x and one output y, and the following excitatoin table for the state machine:
| x = 0 | x = 1
------+--------+--------
q_0 | q_0, 0 | q_3, 1
q_1 | q_0, 0 | q_2, 0
q_2 | q_1, 1 | q_3, 1
q_3 | q_0, 0 | q_2, 0
------+--------+--------
(Here, q_0 corresponds to A = 0 and B = 0, etc - assume that the Q outputs of the two flip flops required are called A and B, respectively)
(The second and third column in the table are in the form (next state, output). Suppose the user chooses to input a characteristic table, which is the characteristic table of a JK'-Flip Flop.
The program should have the following answer as output:
J_A = x
K_A' = x
J_B = x + A
K_B' = 0
y = xB' + AB'

Iam not able to decide what data structures to use to manupulate data.
Plz suggest which data stucures suit the problem the best so that I can start of coding ASAP.


Thanks in advance :-)

Recommended Answers

All 4 Replies

Hope This is Clear enough to those who know what sequential state machines are.
I can elaborate more if u can really help me

:-)

>Hope This is Clear enough
Not really. Explaining how you're going to do something is irrelevant if we don't know what it will be used for. Knowing the end result is a key element in determining how to approach a problem.

>Iam not able to decide what data structures to use to manupulate data.
Every state has an input and an output, so a simple data structure or no data structure will usually suffice. You'll find that most state machines are implemented as an array of function pointers that take the initial state as an argument and return the next state. Alternative designs use a table of IN/OUT states that do basically the same thing.

>Hope This is Clear enough
Not really.

>Iam not able to decide what data structures to use to manupulate data.
Every state has an input and an output, so a simple data structure or no data structure will usually suffice. You'll find that most state machines are implemented as an array of function pointers that take the initial state as an

what is an arrray of fuction pointers?? Plz explain.

argument and return the next state. Alternative designs use a table of IN/OUT states that do basically the same thing.

Hi, This is my problem:

Suppose The Sequentional State Machine has 'l' states and 2^(k-1)<l<2^K,
then I'll have to use 'k' flip-flops .
Further suppose that each (initial) state has 'n' inputs , 'm' outputs and an output state.
It's like having 'l' nodes , and each node has 2^n lines going out of .The nodes into which these lines go depends on the 'n' inputs.
Also, There is a particular output associated with each line

Now, This is the input to my coding assgignment. Iam not able to decide how to read this in.Plz help me till this point so that I can start of soon.

The entire assingnment if about getting a boolen expression for each of 'm' outputs and each of the 'l' states in terms of ths inputs and the present states.


Thanks ,
Bye,
Arjun

what is an arrray of fuction pointers?? Plz explain.

Not the easiest thing to explain, sometimes.

#include <stdio.h>

int foo(void) { return 1; }
int bar(void) { return 2; }
int baz(void) { return 3; }

int main()
{
   int (*afp[])(void) = { foo, bar, baz };
   int i;
   for (i = 0; i < sizeof afp / sizeof *afp; ++i )
   {
      printf("afp[%d]() = %d\n", i, afp[i]());
   }
    return 0;
}

/* my output
afp[0]() = 1
afp[1]() = 2
afp[2]() = 3
*/

More info: http://www.newty.de/fpt/index.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.