Sponsored Content
Top Forums Programming Bitwise operation for state machine Post 302880875 by Don Cragun on Tuesday 24th of December 2013 06:33:20 AM
Old 12-24-2013
Quote:
Originally Posted by anand.shah
Dear Don Cragun,
Thank you very much for your reply.
I am using C macro to accomplish this. I can not pass states to remove from
Code:
state

as I am not aware of previous state. What I want is their should always have no more than one of the three low order bits set.
Example :- If I am in
Code:
state1

currently then my state variable would be
Code:
 xxxx x001

. Now If I want to set state to
Code:
state3

then my state variable should become
Code:
 xxxx x100.

Thank you.
This makes no sense. If your program isn't aware of your current state (previous state when you want to change to a new set of states), then setting the new state is just a statement like:
Code:
state = state1;
    or
state = state3 | state4 | state7;

If you can't restrain yourself from writing code like:
Code:
state = state1 | state2;

and you aren't going to set up a function to perform verification of state changes, I have no idea what you are trying to do. And, doing this, there are never any unknown (or unchanged states); you replace (rather than update) states every time to assign a new value to state. So you won't have xxxx x100, you'll have 0000 0001, 0100 1100, or (the undesired) 0000 0011, respectively, for the three samples above; but never any xs.

I must be missing something in your description of what you're trying to do.
 

2 More Discussions You Might Find Interesting

1. AIX

Open firmware state to running state

Hi Admins, I am having a whole system lpar in open firmware state on HMC. How can I bring it to running state ? Let me know. Thanks. (2 Replies)
Discussion started by: snchaudhari2
2 Replies

2. Shell Programming and Scripting

Vim function to generate RTL Code(finite state machine) in verilog

Hi I wanted to call the AutoFsm function (given below) in vim to generate a code something like: **********verilog code to generate ************* always @(posedge clk or negedge rst_n) begin if(!rst_n) begin state_r <= #1 next_stateascii_r; ... (0 Replies)
Discussion started by: dll_fpga
0 Replies
All times are GMT -4. The time now is 02:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy