954,480 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

suggestion on data stuctures to use

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 :-)

arikeri
Light Poster
25 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

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

:-)

arikeri
Light Poster
25 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

>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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

>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)

arikeri
Light Poster
25 posts since Mar 2005
Reputation Points: 10
Solved Threads: 0
 
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

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You