Thread: Designing State Machine

  1. #1
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572

    Designing State Machine

    hey guys for the semester project in my computer architecture and logic design course I have to design a processor. I've done quite a bit allready but am stuck at this part: designing a tate machine.

    The requirements for the state machine are:
    Code:
    Build a state machine that produces three signals REG, ALU, MEM corresponding to states within the state machine. 
    
    input: W and clk
    output: REG, ALU, MEM signals
    state table
    	W	next state
    REG	1	REG
    REG	0	ALU
    ALU	1	ALU
    ALU	0	MEM
    MEM	1	MEM
    MEM	0	REG
    basically, am I supposed to have the next state equal to some binarry number. For example REG = 001, ALU = 010...and so on. Or am I totally off track.

    Any suggestions?

    BTW: the register, alu, and memory are allready designed.

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  2. #2
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    you might have more luck getting help for this at megatokyo.com or the OS dev forum on FD
    PHP and XML
    Let's talk about SAX

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    One way is to have a state transition table (fancy name for an array) which contains every input state and the corresponding output state

    Code:
    int state;  // the current state
    
    int state_table[NUM_STATES][NUM_W] = {
        // data
    };
    Then it's simply
    Code:
    newstate = state_table[state][w];
    state = newstate;
    return newstate;
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572
    Thanks salem I'll try that.

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. State machine
    By sergio in forum General Discussions
    Replies: 3
    Last Post: 07-03-2009, 09:03 AM
  2. state machine using function pointers
    By meena_selvam in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 02:09 PM
  3. Finite State Machine
    By ArlexBee-871RBO in forum C++ Programming
    Replies: 8
    Last Post: 07-14-2008, 11:59 AM
  4. NAQ: Everything you never wanted to know about CPP
    By evildave in forum C Programming
    Replies: 21
    Last Post: 12-12-2005, 10:56 AM
  5. Finite State Machine Project Help
    By ryanbradley in forum C++ Programming
    Replies: 4
    Last Post: 03-06-2004, 10:23 AM