This topic is useful for KTU Regulation 2019 1. EET206 Digital Electronics ( ELECTRICAL AND ELECTRONICS ENGINEERING) 2. CST203 Logic System Design ( COMPUTER SCIENCE ENGINEERING) 3. ECT203 Logic Circuit Design (ELECTRONICS AND COMMUNICATION ENGINEERING) 4. EBT205 Logic Circuit and Design (BIOMEDICAL ENGINEERING) 5. ITT203 Logic System Design (INFORMATION TECHNOLOGY) 6. ECT203 Logic Circuit Design (APPLIED ELECTRONICS ENGINEERING) KTU Regulation 2015 1. EE204 Digital Electronics and Logic Design (ELECTRICAL AND ELECTRONICS ENGINEERING) 2. CS203 Switching Theory and Logic Design (COMPUTER SCIENCE ENGINEERING) 3. EC207 Logic Circuit Design (ELECTRONICS AND COMMUNICATION ENGINEERING) 4. EC207 Logic Circuit Design (APPLIED ELECTRONICS ENGINEERING AND INSTRUMENTATION) 5. IC207 Design of Logic Circuit (BIOMEDICAL ENGINEERING) FOR FULL CLASSES : https://youtube.com/playlist?list=PL2UV2EJdMQmgLuA8dwLY7-4DsbNQTsUOg #digitalelectronics#ktu#eee#electrical#cse FOR FULL CLASSES : https://youtube.com/playlist?list=PL2UV2EJdMQmgLuA8dwLY7-4DsbNQTsUOg #digitalelectronics#ktu#eee#electrical
hello students
today we are going to discuss about
digital electronics
in module 1
arithmetic operation with signed numbers
i.e. 2's complement arithmetic
1's complement arithmetic
we are going to discuss about
those things in this session
now let's go to the topic
first we are going to see
2's complement arithmetic
ok
2's complement form of
representing signed numbers
we use in microprocessors
2's complement system
is used to represent
negative numbers
negative numbers using
modulus arithmetic
i.e. a 4 bit binary
when we add
another 4 bit
the result is
written in 4 bit terms
in case of
a carry
from 4th bit to
5th bit
it will overflow
using modulus arithmetic
we are representing
negative numbers in 2's complement
here we have 4 cases
when addition occurs
we are looking at addition
here we have 4 cases
first case is
case 1
both numbers are positive
both
numbers are
positive
in 2's complement arithmetic
first addition operation
there are 4 possible cases
first case is
both numbers are positive
let's see an example
we have studied
1 plus 1 is
0 with a carry
1 plus 0 is
1
1 plus 0 is
0
1 plus 1 is
0 with a carry
over 1
1 plus 0 is
1
1 plus 0 is 1
0 plus 1 is 1
0 plus 0 is 0
the answer is
0 1 1 1
0 0 1 0
here carry is coming
last case
to go to the next bit
carry has not come
sum is positive
this is
true binary form
let's see the next case
case 2
positive number with
greater magnitude than
negative number
Here we have two cases, i.e. I have to add 32 plus or minus 15
Here the magnitude of positive number is greater than the magnitude of negative number
32 is represented in terms of binary
1, 2, 4, 8, 16, 32, 64
Here the magnitude of 32 is greater than the magnitude of negative number
We know the binary of 15
How do we represent the binary of 15?
We have represented 64 in terms of 8 bit
Similarly, we can represent 15 in 8 bit
15 is 1, 1, 1, 1 with 8, 4, 2, 1
Then we have given 4 zeros to write in terms of 8 bit
Now we have to convert 15 to minus 15
What do we have to do to convert 15 to minus 15?
We have to take 1's complement
0 becomes 1, 0 becomes 1
We have to replace 4 zeros with 1
We have to replace 4 ones with zeros
Then we have to find 2's complement
How do we get minus 15?
First write 15 in binary form
Then take 1's complement
Then take 2's complement
Then we will get minus 15 in terms
0 plus 1 is 1
Again 0, 0, 0, 1, 1, 1, 1
Minus 15 is 1, 1, 1, 1, 0, 0, 0, 1
That is what I am replacing here
If b is a minus in a plus b
We can write a plus minus b as a plus b
We can assign values accordingly
Here I have written a in terms of a plus minus b
Now see what is 0 plus 1?
0 plus 0 is 0
0 plus 1 is 1
1 plus 1 is 0 with a carry over 1
When we add 1 and 0, it becomes 1
When we add 1 and 1, it becomes 0 with a carry over 1
1 plus 0 is 1
1 plus 1 is 0 with a carry over 1
What is 1?
It comes as a carry
So, in our final case, what should we do for final carry bit?
If a carry bit comes like this, we should neglect it.
This is the case 2.
So, if a final carry bit comes like this, we should neglect it.
And what is sum?
Sum is positive, right?
Therefore, it is true binary.
Now, look at this.
32 plus minus 15.
Normally, when we do 32 minus 15, what do we get?
This is 2.
From 12 to 5, we get 7.
Plus 17 is what we get.
So, let us see if this value we got is 17.
This is 1.
Now, look at this position.
This is 16.
Then, 16 plus 1.
We know 17 here.
What is the answer we got?
It is correct, right?
Our sum is also positive.
Therefore, we can say that it is a true binary form.
Now, let us see what case 3 is.
What is the third case?
Negative number with magnitude greater than positive number.
Consider an example.
16 plus minus 20.
Look here.
Which magnitude is greater than 20?
Look here.
Negative number with magnitude greater than positive number.
16 and 20.
Minus 20 magnitude is greater than positive number.
Let us see how to solve this case.
16 plus 16 terms.
There is a change.
Write the binary form of 16.
8, 4, 2, 1, 16.
0, 0, 0, 1.
0, 0, 0, 0.
I have written in terms of 8 bits.
Next is minus 20.
We have to find 2's complement to write minus 20.
Let us do the binary form of 20.
How to write the binary form of 20?
16 and 4 are 20.
The representation of 16 bits is 0, 0, 0, 1.
Next is 0, 1, 0, 0.
Now, it is 20.
1, 2, 4, 8, 16.
16 and 4 are 20.
Now, look at the 1's complement.
1, 1, 1, 0, 1, 0, 1, 1, plus 1.
We get it in terms of minus 16.
What is 1 plus 1?
0 with a carry 1.
1 plus 1 is 0 with a carry 1.
0 plus 1 is 1.
1 is 0, 1, 1, 1.
We get it in terms of minus 16.
1, 1, 1, 0, 1, 1, 0, 0.
Now, I am placing it here.
0, 0, 1, 1, 0, 1, 1, 1.
Now, let us do the addition.
When we do 16 plus minus 20, we get minus 4.
Let us see.
What is 0 plus 0?
0.
Again, 0 plus 0 is 0.
0 plus 1 is 1.
1 plus 0 is 1.
0 plus 1 is 1.
Here we have the negative sum.
Look here.
MSB.
MSB is this.
What is MSB?
MSB1 is the sum.
It is negative.
Ok?
So, which term is this?
This is a representation of minus 4.
We get it.
To find out if the value we get is correct, we just need to get one more truth complement.
0 0 0 0 0 1 1
add 1 to it
1 1 0 with the carry over 1
1 1 0 with the carry 1
1 0 0 0 0 0
now see
1 2 4
right? this is in plus 4 terms
this 16 plus minus 20
is minus 4
this is the two's complement representation
given here
to know if the value is correct
we will take one more two's complement
in terms of plus 4
this is case 3
a negative number with magnitude is more
compared to that of a positive number
is the case
sum is negative
so it is a two's complement
therefore
4 is in
two's complement
4
ok
now let us see case 4
what is case 4?
both numbers are
negative
ok
the first number I am taking here is minus 3
and the next number I am taking is
minus 6
we are going to do a binary addition with 3 terms
so let us write the binary representation of 3
in terms of 8 bits
0 0 0 0
then 0 0 1 1
ok
let us take the one's complement
when we take the one's complement, zeros are replaced by 1
1 1 1 1
1 1 0 0
now let us take the two's complement
what do we get when we add?
when we take the two's complement, we get minus 3 terms
0 plus 1 1
then 0 1 1
1 1 1 1
so we get minus 3 terms
1 1 1 1
1 1 0 1
1 1 1 1
1 1 0 1
the second one is minus 6
so first we take the binary of 6 in terms of 8 bits
0 0 0 0
then
0 1 1 0
6 is
0 1 1 0
1 1 1 1
1 0 0 1
plus 1
so we get minus 6 terms
what is 1 plus 1?
0 plus 1 1
0 1
remaining 1
in terms of minus 6, what do we get?
1 1 1 1
1 0 1 0
1 1 1 1
1 0 1 0
1 plus 0
0 plus 1
1 plus 0
0 with a carry 1
we learn this in addition
1 with a carry 1
again
1 plus 1
1 with a carry 1
1 plus 1
1 with a carry 1
what is 1?
it is a carry
so let us ignore it
MSB is the most significant bit. MSB1 means negative number.
The answer we got is in terms of negative 9.
Let us cross check the answer given in case 3.
Let us cross check the answer given in case 4.
Let us cross check the answer given in case 5.
Let us cross check the answer given in case 6.
Let us cross check the answer given in case 7.
Let us cross check the answer given in case 8.
Let us cross check the answer given in case 9.
Let us cross check the answer given in case 10.
Let us cross check the answer given in case 11.
Let us cross check the answer given in case 12.
Let us cross check the answer given in case 13.
Let us cross check the answer given in case 14.
Let us cross check the answer given in case 15.
Let us cross check the answer given in case 16.
Let us cross check the answer given in case 17.
Let us cross check the answer given in case 18.
Let us cross check the answer given in case 19.
Let us cross check the answer given in case 20.
Let us cross check the answer given in case 21.
Let us cross check the answer given in case 22.
Let us cross check the answer given in case 23.
Let us cross check the answer given in case 24.
Let us cross check the answer given in case 25.
Let us cross check the answer given in case 26.
Let us cross check the answer given in case 27.
Let us cross check the answer given in case 28.
Let us cross check the answer given in case 29.
Let us cross check the answer given in case 30.
Let us cross check the answer given in case 31.
Let us cross check the answer given in case 32.
Let us cross check the answer given in case 33.
Let us cross check the answer given in case 34.
Let us cross check the answer given in case 35.
Let us cross check the answer given in case 36.
Let us cross check the answer given in case 37.
Let us cross check the answer given in case 38.
Let us cross check the answer given in case 39.
Let us cross check the answer given in case 40.
Let us cross check the answer given in case 41.
Let us cross check the answer given in case 42.
Let us cross check the answer given in case 43.
Let us cross check the answer given in case 44.
Let us cross check the answer given in case 45.
Let us cross check the answer given in case 46.
Let us cross check the answer given in case 47.
Let us cross check the answer given in case 48.
Let us cross check the answer given in case 49.
Let us cross check the answer given in case 50.
Let us cross check the answer given in case 51.
Let us cross check the answer given in case 52.
Let us cross check the answer given in case 53.
Let us cross check the answer given in case 54.
Let us cross check the answer given in case 55.
Let us cross check the answer given in case 56.
Let us cross check the answer given in case 57.
Let us cross check the answer given in case 58.
Let us cross check the answer given in case 59.
Let us cross check the answer given in case 60.
Let us cross check the answer given in case 61.
Let us cross check the answer given in case 62.
Let us cross check the answer given in case 63.
Let us cross check the answer given in case 64.
Let us cross check the answer given in case 65.