suggestion on data stuctures to use

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2005
Posts: 25
Reputation: arikeri is an unknown quantity at this point 
Solved Threads: 0
arikeri arikeri is offline Offline
Light Poster

suggestion on data stuctures to use

 
0
  #1
Mar 8th, 2005
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 :-)
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 25
Reputation: arikeri is an unknown quantity at this point 
Solved Threads: 0
arikeri arikeri is offline Offline
Light Poster

Re: suggestion on data stuctures to use

 
0
  #2
Mar 8th, 2005
Hope This is Clear enough to those who know what sequential state machines are.
I can elaborate more if u can really help me

:-)
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,771
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 743
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: suggestion on data stuctures to use

 
0
  #3
Mar 8th, 2005
>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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 25
Reputation: arikeri is an unknown quantity at this point 
Solved Threads: 0
arikeri arikeri is offline Offline
Light Poster

Re: suggestion on data stuctures to use

 
0
  #4
Mar 8th, 2005
Originally Posted by Narue
>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
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,398
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 245
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: suggestion on data stuctures to use

 
0
  #5
Mar 9th, 2005
Originally Posted by arikeri
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
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC