Problem with substractor using 74ls283

Thread Starter

dyn_o

Joined May 29, 2017
35
Hy,

I want to perform addition and substraction on 2 bits with one 74ls283. No problem for addition but when I want to subtract (when I put the M variable on HI), LED3 lights. I don't know why.

Subtractor.jpg
74ls283.jpg
 

WBahn

Joined Mar 31, 2012
30,088
Your schematic doesn't match your logic diagram.

What are the upper two bits of the input to the '283 equal to when M=1? Do both diagrams agree on this?

You also shouldn't leave logic inputs floating. That is a VERY bad practice that will bite you sooner rather than later.
 

Thread Starter

dyn_o

Joined May 29, 2017
35
Your schematic doesn't match your logic diagram
The logic diagram is for the addition and substraction of 2 numbers of 4 bits, yes my schematic is for 2 numbers of 2 bits, but I think it is the same reasoning for 2, 4 or n full adders. Or do you mean something else ?

What are the upper two bits of the input to the '283 equal to when M=1? Do both diagrams agree on this?
Sorry I don't understand your question (maybe because french is my mother tonge...). The upper two bits of the '283 are A3 and A4 but since I only need to calculate on 2 bits and not 4 I don't need them. And ok for the floating input, I corrected it.
 

WBahn

Joined Mar 31, 2012
30,088
Look at your logic diagram. If it is in subtraction mode (M = 1), and you want to subtract B=0000 from A=0000, what are the inputs to the four full adders?

Now look as your circuit diagram. If you want to subtract B=00 from A=00, what are the inputs to the four full adders?
 

Thread Starter

dyn_o

Joined May 29, 2017
35
Look at your logic diagram. If it is in subtraction mode (M = 1), and you want to subtract B=0000 from A=0000, what are the inputs to the four full adders?

Now look as your circuit diagram. If you want to subtract B=00 from A=00, what are the inputs to the four full adders?
I just saw that the last logic gate is a XNOR and not a XOR so yes my schematic does not match the logic diagram.

Following the logic diagram on 4 bits I get A = 0000 and B = 0111 so A - B = 0000 - 0111
Following my circuit I get A = 00 and B = 11 so A - B = 00 - 11.

I changed the last logic gate for a XNOR but it still doesn't work. On the internet I see lot's of diagram with 4 XOR and no XNOR.. Grr and don't know wich is the good one.
 

WBahn

Joined Mar 31, 2012
30,088
Do you understand why the XOR gates are there and, mathematically, how the M signal being fed into them as well as the carry in of the lsb turn addition into subtraction?

As to whether the last logic gate should be an XOR or an XNOR, consider the case where you just want to add 0 + 0. What SHOULD the result be? What WILL the result be with that XNOR gate there?
 

Thread Starter

dyn_o

Joined May 29, 2017
35
Do you understand why the XOR gates are there and, mathematically, how the M signal being fed into them as well as the carry in of the lsb turn addition into subtraction?

As to whether the last logic gate should be an XOR or an XNOR, consider the case where you just want to add 0 + 0. What SHOULD the result be? What WILL the result be with that XNOR gate there?
I get it. The M input in the first XOR is used to 1'complement the input B. 1'complement is used to represent a negative number. 1'complement inverse the bit so if B = 3 = 0011 we got -3 = 1'complement of B = 1100. So the first XOR take B = 0 and make it 1 and take B = 1 and make it 0.
But if we want to make for example 3 - 1 with 1'complement we will not get the right result : 0011 + 1100 (1'complement of 1) = 0001 , so we need 1 to make 2 (3-1 = 2). Adding 1 after having 1'complemented is making the 2'complement. It is why we us the variable M = 1 as Cin for the second XOR inside the full adder, to make the 2'complement.

And now I understang why you said that my schematic doesn't match the logic diagram. Because the '783 use 4 full adders and I only 2'complemented the 2 first full adder! I did it for the 2 others and it works now. Here is my circuit.

And thanks a lot!

783.jpg
 
Top