Mealy state machine

Discussion in 'Homework Help' started by omerysmi, Oct 4, 2015.

  1. omerysmi

    Thread Starter Member

    Oct 10, 2014
    44
    0
    Hi,
    I have an exercise which i need to detect a block of odd number of '0's, and then the output will be 1.
    for example if i get "10001" the output will be '1' after "000".
    X: 10001
    Y: 00010

    I need to implement it with mealy state machine (X is input, Y is output).
    This is what i did, Does it right?

    [​IMG]
     
    Last edited: Oct 4, 2015
  2. Papabravo

    Expert

    Feb 24, 2006
    10,140
    1,789
    Your specification is ambiguous and I think the diagram is wrong. In a string three zeros there are two subblocks with an even number of zeros. According to your specification the output should be high for two clock cycles and then go low. Is that the way you see it as well? How about arrowheads on the transition arcs to show the direction. How about showing the state transition table?
     
  3. omerysmi

    Thread Starter Member

    Oct 10, 2014
    44
    0
    Maybe this is right? because a single '0' is not considered as "block" no?


    [​IMG]
     
  4. JSCV

    New Member

    Oct 3, 2015
    13
    1
    As Papabravo mentioned you are not really clear in your specification.
    When should the output become '0' again ?
    What if there are more than 3 consequential '0' ?
    should the output only be '1' when the number of '0' is even (2,4,6,8).

    With the description you gave nobody is able to give you a correct answer.
     
  5. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,789
    This makes no sense. Why would the output be 1 after "000" when you are trying to detect blocks of even number of '0's?

    Neither of your diagrams indicate the start state -- that's a rather important piece of information.
     
  6. omerysmi

    Thread Starter Member

    Oct 10, 2014
    44
    0
    Sorry is my mistake it should detect odd number of zeros.
    Anyway, the problem is that i don't know if a single '0' considered as a "block of zeros".
     
  7. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,789
    Actually, I think it's my mistake and that I misread your original post.

    Given the example output, it would appear that it shouldn't consider a single 0 as a block.

    But should it give "false" indications for blocks greater than three? The example output goes HI as soon as the third 0 is seen, but what if it turns out that this is a block of four 0's. It can't tell the future, so it would appear that it must. For instance, if should probably get

    X = 10.00.00.00.01.00.01.0
    Y = 00.01.01.01.00.00.10.0

    I put in periods just to make it easier to match up the two strings.

    Does that agree with your understanding?
     
  8. omerysmi

    Thread Starter Member

    Oct 10, 2014
    44
    0
    I think it should be like your example, but i am not sure about a single zero..

    This is the diagram if so (single zero is not considered as a block of zeros)
    [​IMG]


    and this is the diagram if a single '0' is included:

    [​IMG]
     
  9. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,789
    SHOW THE DAMN START STATE!

    What is SO HARD about that? Don't make your reader (or the grader) GUESS! Engineering is NOT about guessing!
     
  10. omerysmi

    Thread Starter Member

    Oct 10, 2014
    44
    0
    I didn't understand you..
     
  11. Papabravo

    Expert

    Feb 24, 2006
    10,140
    1,789
    Your machine needs a state to start in. Such a state is often the one you go to in response to a RESET signal. If you don't have such a state the machine can come up in an arbitrary and possibly unrecoverable state. This is especially true in cases where the behavior depends on the history of states the machine has traversed.
     
  12. omerysmi

    Thread Starter Member

    Oct 10, 2014
    44
    0
    A is the start state
     
  13. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,789
    You generally indicate the start state with at least an arrow coming from nowhere and pointing at the start state. Frequently this is labeled with the name of the signal that will send it there from any other state (such as RESET). That's just a common convention to avoid cluttering the diagram. The strict way is to have a label coming from each state to the start state explicitly. This approach is particularly important when some states don't respond the same way to a reset signal. For your exercise, just showing an arrow pointing to the start state should suffice.
     
  14. omerysmi

    Thread Starter Member

    Oct 10, 2014
    44
    0
    Ok i understand you..in my diagram A is the start state

    Anyway the problem is that if for example i have an even number of zeros the output will be also '1' after the first '0'. like here:
    X: 1110011
    Y: 0001000

    You understand what i mean? there is no odd number of zeros and the output is also '1'.
     
    Last edited: Oct 5, 2015
  15. WBahn

    Moderator

    Mar 31, 2012
    17,743
    4,789
    This is going to be a problem as long as you are supposed to assert the output HI while one of the zeros in the sequence is present. The machine has no way to foresee the future and so it doesn't know if the next bit will be a zero or a one. So a HI can only be interpreted as meaning, "As of right now, the length of the present sequence of zeros is odd."
     
  16. omerysmi

    Thread Starter Member

    Oct 10, 2014
    44
    0
    If the machine wait until '1' appear after sequence of zeros it will solve the problem but if for example there is not '1' after zeros like here: "1001000" you understand?
     
Loading...