[ back to toc ]


Date: 2002/01/26 13:45

my name is *NAME-DELETED*.i'm not sure how to do this problem.the problem is
that,given the current state of the system and the input, i need to find
the next state.
for eg. if i have a system which has a 3 bit state i.e. ranging from 000
to 111 and an input
either 1 or 0.how do i find the next state??.the next state is computed by
using the following mechanism eg. current state= 001 and input =1 then the
next state would be 100(put the input in front of the state and count 3
bits from the front,discarding the last bit. in this case when we put
input in front of the current state it wud become 1001 and discarding the
1 at the end will give the next state as 100)
similarly a couple more eg.s
current state 100 input =1 the next state wud become 110
current state 110 input =0 the next state wud become 011

i need to write a function for this purpose. i was planning of using
if(inp == 0) then for(current state,current state<max,current state++)
but i don't know how to do that with the digital number.can you please
tell me how to write a function performing this program. i would really
appreciate if i could get the code.

waiting for your reply
If you store the actual state in a variable of the type int then and the
input comes as argument and the next state is the output then the
following code can work:

static int state=0;
int function(int input){
state >>= 1;
state += input <<2;
return state;


[ back to toc ]