How Do You Design a Moore State Machine for Two's Complement Operations?

In summary, the task is to develop a synchronous sequential machine that takes in binary data and produces the negative of the input number by performing a two's complement operation. The circuit should have two inputs, DATA and SYNC, with SYNC equal to 1 for only one positive-edge clock pulse. The Moore machine for this task has three states, each with a different output and transition rule. The state transition table for this machine uses D flip-flops.
  • #1
electroguy02
5
0

Homework Statement



Can someone check my work?

[...] Receiving DATA in binary. The string length of each word is unknown. You are told that each word, demarcated by SYNC signals, is a two's complement number.

Your task is to develop a synchronous sequential machine which examines the received data as input and produces as output the negative of the input number by performing the two's complement operation on the incoming data. Your circuit should have two inputs: DATA and SYNC.


Homework Equations



If the DATA string 10011100011010 is given (where the first digit is the first input), along with the SYNC string 10000010000000, the output should be 11100000010101.

The LSB is the DATA bit that shows up when SYNC = 1.

Short-cut rule for performing a two's complement operation on a string of data:

"Starting with the LSB and moving toward the MSB, transcribe all zeros until you reach the first '1', transcribe that '1' then complement every bit after (more significant than) that."

The Attempt at a Solution



I have already made a working Mealy machine with this functional specification. I'm just having trouble on the Moore machine. SYNC is equal to 1 for only one positive-edge clock pulse.

For the Moore machine, there are three states:

[State 00]: Only zeros are received when SYNC = 1. Output is 0.
[State 01]: First one received when SYNC = 1. Also, zeros after first one is received (and SYNC = 0). Output is 1.
[State 10]: 1 received after first one is received. Output is 0.

I'm trying to use D flip-flops for this, so I made the following state transition table:

Inputs Present State Next State Output D flip-flops
SYNC DATA | A B | A+ B+ | z | D_A D_B
0 0 0 0 0 0 0 0 0
0 0 0 1 0 1 1 0 1
0 0 1 0 0 1 0 0 1
0 0 1 1 X X 0 1 1
0 1 0 0 0 1 0 0 1
0 1 0 1 1 0 1 1 0
0 1 1 0 1 0 0 1 0
0 1 1 1 X X 0 1 1
1 0 0 0 0 0 0 0 0
1 0 0 1 0 0 1 0 0
1 0 1 0 0 0 0 0 0
1 0 1 1 X X 0 1 1
1 1 0 0 0 1 0 0 1
1 1 0 1 0 1 1 0 1
1 1 1 0 0 1 0 0 1
1 1 1 1 X X 0 1 1

I did Karnaugh maps for the D_A, D_B, and z, and this is what I got (S=SYNC, D=DATA. S' means NOT SYNC):

D_A: AB+S'DB+S'DA
D_B: SD'+D'B+D'A+AB+S'DA'B'
z : A'B

I'm pretty sure of the Next State and z columns of my table; I've checked it against my teacher's answer. But somehow, the equations aren't working for me. Can you please check my work? Thanks in advance.
 
Last edited:
Physics news on Phys.org
  • #2
electroguy02 said:

Homework Statement



Can someone check my work?

[...] Receiving DATA in binary. The string length of each word is unknown. You are told that each word, demarcated by SYNC signals, is a two's complement number.

Your task is to develop a synchronous sequential machine which examines the received data as input and produces as output the negative of the input number by performing the two's complement operation on the incoming data. Your circuit should have two inputs: DATA and SYNC.


Homework Equations



If the DATA string 10011100011010 is given (where the first digit is the first input), along with the SYNC string 10000010000000, the output should be 11100000010101.

The LSB is the DATA bit that shows up when SYNC = 1.

Short-cut rule for performing a two's complement operation on a string of data:

"Starting with the LSB and moving toward the MSB, transcribe all zeros until you reach the first '1', transcribe that '1' then complement every bit after (more significant than) that."

The Attempt at a Solution



I have already made a working Mealy machine with this functional specification. I'm just having trouble on the Moore machine. SYNC is equal to 1 for only one positive-edge clock pulse.

For the Moore machine, there are three states:

[State 00]: Only zeros are received when SYNC = 1. Output is 0.
[State 01]: First one received when SYNC = 1. Also, zeros after first one is received (and SYNC = 0). Output is 1.
[State 10]: 1 received after first one is received. Output is 0.

I'm trying to use D flip-flops for this, so I made the following state transition table:

Inputs Present State Next State Output D flip-flops
SYNC DATA | A B | A+ B+ | z | D_A D_B
0 0 0 0 0 0 0 0 0
0 0 0 1 0 1 1 0 1
0 0 1 0 0 1 0 0 1
0 0 1 1 X X 0 1 1
0 1 0 0 0 1 0 0 1
0 1 0 1 1 0 1 1 0
0 1 1 0 1 0 0 1 0
0 1 1 1 X X 0 1 1
1 0 0 0 0 0 0 0 0
1 0 0 1 0 0 1 0 0
1 0 1 0 0 0 0 0 0
1 0 1 1 X X 0 1 1
1 1 0 0 0 1 0 0 1
1 1 0 1 0 1 1 0 1
1 1 1 0 0 1 0 0 1
1 1 1 1 X X 0 1 1

I did Karnaugh maps for the D_A, D_B, and z, and this is what I got (S=SYNC, D=DATA. S' means NOT SYNC):

D_A: AB+S'DB+S'DA
D_B: SD'+D'B+D'A+AB+S'DA'B'
z : A'B

I'm pretty sure of the Next State and z columns of my table; I've checked it against my teacher's answer. But somehow, the equations aren't working for me. Can you please check my work? Thanks in advance.

Well, a few thoughts (I didn't go through your tables in detail yet).

1) You should always have a binary number of states in your state machine. Unused states can just flow back to the reset/initial state, but you definitely need to not have any illegal or dangling states. That's not good design practice. So if you think you can do the state machine control circuit with 3 states, add in the 4th state, and have it always flow back to your idle or starting state.

2) I'm a bit confused by the example string given, and where you say "The LSB is the DATA bit that shows up when SYNC = 1." If I space out the example strings to make them more readable, then it looks like this:

Code:
1 001110 0011010 Input Data
1 000001 0000000 SYNC
1 110000 0010101 Output Data

Which looks like there is an initial 1-bit word, then a 6-bit word, and then an unterminated word of undefined length which is not getting inverted bit-by-bit, which the 2's compliment should require. Sorry if I'm completely off base here.

3) To do the 2's complement, you will invert each bit of the word, until the last bit is recognzed, where you do the inversion, but add back in a 1. That addition can force carrys to propagate up the bits of the word until a 0 is encountered. So it seems like you would need to store the output data string until you get the SYNC, then do the addition and any carrys, and then shift out that output string. Is there some way to do this with only 1 bit of memory? It seems like in addition to the state machine FFs, you need to know the max word length and add that many FFs in for temporary memory storage...?
 
  • #3




It looks like you have put a lot of thought and effort into your Moore state machine design. Your state transition table and Karnaugh maps seem to be correct, but it is always a good idea to double check with your teacher or a peer to make sure there are no errors. Additionally, it may be helpful to simulate your design to see if it produces the desired output for different input patterns. This can help identify any potential errors in your equations or implementation. Overall, it seems like you have a solid understanding of Moore state machines and their application in this problem. Keep up the good work!
 

FAQ: How Do You Design a Moore State Machine for Two's Complement Operations?

What is a Moore State Machine?

A Moore State Machine is a type of finite state machine that consists of a set of input symbols, output symbols, and a set of states. It is used to model sequential logic circuits and is designed to perform a specific task or function based on the current state and input.

How does a Moore State Machine work?

A Moore State Machine works by transitioning between different states based on the current state and input symbols. Each state has a specific output associated with it, and the output is determined only by the current state. This means that the output is independent of the input symbols and is only affected by the current state.

What are the advantages of using a Moore State Machine?

One advantage of using a Moore State Machine is that it is easy to design and implement, making it a popular choice for modeling sequential circuits. Additionally, since the output is only dependent on the current state, it can be easily tested and verified, making it a reliable choice for complex systems.

How is a Moore State Machine different from a Mealy State Machine?

The main difference between a Moore State Machine and a Mealy State Machine is that in a Mealy State Machine, the output is also dependent on the input symbols in addition to the current state. This means that the output can change more frequently in a Mealy State Machine, while in a Moore State Machine, the output remains constant until a state transition occurs.

What are some common applications of Moore State Machines?

Moore State Machines are commonly used in digital systems such as microcontrollers, CPUs, and other electronic devices to control and sequence operations. They can also be used in sequential logic circuits for tasks such as data processing, control systems, and communication protocols.

Similar threads

Replies
4
Views
2K
Replies
31
Views
3K
Replies
6
Views
2K
Replies
10
Views
2K
Replies
1
Views
1K
Replies
23
Views
7K
Back
Top