I designed a 4-bit adder/subtractor circuit in Quartus Prime Lite. I am struggling with getting the correct output on the waveform. It is supposed to take the unsigned decimal numbers and add or subtract them according to the control input M. When M=0 it is addition & when M=1 it is subtraction. I have changed the inputs A & B to unsigned decimals and entered the numbers provided to add or subtract. Any help to allow me to get the correct output would be greatly appreciated. I have included my circuit, waveform and the correct waveform I am trying to achieve.
\$\begingroup\$
\$\endgroup\$
2
-
\$\begingroup\$ The first waveform is your one, right? I think there's something weird going on with the carry between bits 1 and 2, or maybe all the carries. Is the FullAdder a circuit that you made yourself or is it a circuit you got from somewhere / a built-in one? \$\endgroup\$– user20574Commented May 23, 2023 at 22:35
-
1\$\begingroup\$ for example you are getting 11+5=14, that's 1011+0101=1110. digit 0 is correct but it looks like something went wrong with the carry to digit 1. The rest of the number was calculated without that carry happening. If you made the FullAdder, consider testing the FullAdder because I don't think it's working right. \$\endgroup\$– user20574Commented May 23, 2023 at 22:40
Add a comment
|
1 Answer
\$\begingroup\$
\$\endgroup\$
1
The sense of the carry out is inverted for subtraction: COUT=1 means that the result of a subtraction is correct. Note that all of the cases you simulated yielded a correct result for subtraction...try swapping the operands and see what happens.
-
\$\begingroup\$ Are you referring to the third image? I do see that COUT=1 when subtracting. However, in my waveform (the second image), not all of them are HIGH. Also, the subtraction yields only 2 correct outputs for S. I tried swapping the values for A&B and still got an incorrect output for S. \$\endgroup\$ Commented Feb 12, 2019 at 3:13