| | |
suggestion on data stuctures to use
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2005
Posts: 25
Reputation:
Solved Threads: 0
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 :-)
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 :-)
>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.
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.
•
•
Join Date: Mar 2005
Posts: 25
Reputation:
Solved Threads: 0
•
•
•
•
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
•
•
•
•
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
•
•
•
•
Originally Posted by arikeri
what is an arrray of fuction pointers?? Plz explain.
#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
*/ "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
![]() |
Similar Threads
- change data value at front end (ASP.NET)
- Data Structures??? (C++)
- Discrete Math or Data structure (Computer Science)
Other Threads in the C Forum
- Previous Thread: Help!!!
- Next Thread: readin flip-flop charecteristic table
| Thread Tools | Search this Thread |
adobe ansi api array arrays bash binarysearch centimeter char convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic fflush file floatingpointvalidation fork frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o ide inches infiniteloop initialization interest kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql odf open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer pointers posix power probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling segmentationfault send shape single socketprograming socketprogramming stack standard strchr string strings structures suggestions systemcall test testautomation unix urboc user voidmain() wab win32api windows.h






