You are on page 1of 49

DIGITAL ELECTRONICS-

DIGITAL SYSTEMS
• Digital means electronic technology that generates, stores, and
processes data in terms of two states: positive and non-positive.
Positive is expressed or represented by the number 1 and non-
positive by the number 0.
• A „digital system‟ is a data technology that uses discrete
(discontinuous) values represented by high and low states known as
bits.
BINARY
• Binary describes a numbering scheme in which there are only two
possible values for each digit: 0 and 1.
• The term also refers to any digital encoding/decoding system in which
there are exactly two possible states.
• In digital data memory, storage, processing, and communications, the
0 and 1 values are sometimes called "low" and "high," respectively.
BINARY NUMBER/BINARY NUMBER
SYSTEM

NUMBER SYSTEMS
• Decimal, (base 10)
• Decimal has ten values 0 − 9. If larger values than 9 are needed, extra
columns are added to the left.
• Each column value is ten times the value of the column to its right. For
example the decimal value twelve is written 12 (1 ten + 2 ones).
• Binary, (base 2)
• Binary has only two values 0 − 1. If larger values than 1 are needed, extra
columns are added to the left.
• Each column value is now twice the value of the column to its right.
• For example the decimal value three is written 11 in binary (1 two + 1 one).
NUMBER SYSTEM
• Octal, (base 8)
• Octal has eight values 0 − 7. If larger values than 7 are needed, extra columns
are added to the left.
• Each column value is now 8 times the value of the column to its right. For
example the decimal value eleven is written 13 in octal (1 eight + 3 ones).
• Hexadecimal, (base 16)
• Hexadecimal has sixteen values 0 − 15, but to keep all these values in a single
column, the 16 values (0 to 15) are written as 0 to F, using the letters A to F to
represent numbers 10 to 15, so avoiding the use of a second column.
• Again, if higher values than 15 (F in hexadecimal) are needed, extra columns
to the left are used. Each column value is sixteen times that of the column to
its right.
• For example the decimal value 20 is written 14 in hexadecimal (1 sixteen + 4
ones).
Hexadecimal Number System
• Base 16
• Sixteen Digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
• Example: EF5616
• Positional Number System
• 16 n1 16 4163162161160

0000 0 0100 4 1000 8 1100 C


0001 1 0101 5 1001 9 1101 D
0010 2 0110 6 1010 A 1110 E
0011 3 0111 7 1011 B 1111 F
5
SYSTEM RANDIX
The base of a system, more properly called
the RADIX, is the number of different values
that can be expressed using a single digit.
Therefore the decimal system has a radix of
10, the octal system has a radix of 8,
hexadecimal is radix 16, and binary radix
2.

Notice that
because the hexadecimal system must express
16 values using only one column, it uses the
letters A B C D E & F to represent the numbers
10 to 15.
NUMBER SYSTEM
• The reason for these differences is because each system has a
different base, and the column values in each system increase by
multiples of the base number as columns are added to the left.

A decimal number such as 456.210 can be considered as the sum of the values of
its individual digits, where each digit has a value dependent on its position
within the number (the value of the
column):
NUMBER SYSTEM
CONVERSION SYSTEM
• OTHER SYSTEMS TO DECIMAL:
DECIMAL TO OTHER RANDIX
CONVERSION

CONVERSION OF DECIMAL NUMBERS


Binary Arithmetic: Binary Addition

•Single Bit Addition Table


0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10 Note “carry”

15
Hex Addition
• 4-bit Addition
4 + 4 = 8
4 + 8 = C
8 + 7 = F
F + E = 1D Note “carry”

16
Hex Digit Addition Table
+ 0 1 2 3 4 5 6 7 8 9 A B C D E F
0 0 1 2 3 4 5 6 7 8 9 A B C D E F
1 1 2 3 4 5 6 7 8 9 A B C D E F 10
2 2 3 4 5 6 7 8 9 A B C D E F 10 11
3 3 4 5 6 7 8 9 A B C D E F 10 11 12
4 4 5 6 7 8 9 A B C D E F 10 11 12 13
5 5 6 7 8 9 A B C D E F 10 11 12 13 14
6 6 7 8 9 A B C D E F 10 11 12 13 14 15
7 7 8 9 A B C D E F 10 11 12 13 14 15 16
8 8 9 A B C D E F 10 11 12 13 14 15 16 17
9 9 A B C D E F 10 11 12 13 14 15 16 17 18
A A B C D E F 10 11 12 13 14 15 16 17 18 19
B B C D E F 10 11 12 13 14 15 16 17 18 19 1A
C C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B
D D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C
E E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D
F F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E

17
BINARY ARITHMETIC
Binary Subtraction
The rules for subtraction of binary numbers are again similar to
decimal. When a large digit is to be subtracted from a smaller one, a
‘borrow’ is taken from the next column to the left.
In decimal subtractions the digit ‘borrowed in’ is worth ten, but in
binary subtractions the ‘borrowed in’ digit must be worth 2 10 or binary
102.
SIGNED BINARY NUMBERS
• There are a number of ways in which binary numbers can represent
both positive and negative values, 8 bit systems all use one bit of the
byte to represent either + or − and the remaining 7 bits to give the
value.
• One of the simplest of these systems is SIGNED BINARY, also often
called 'Sign and Magnitude', which exists in several similar versions,
but is commonly an 8 bit system that uses the most significant bit
(msb) to indicate a positive or a negative value.
• By convention, a 0 in this position indicates that the number given by
the remaining 7 bits is positive, and a most significant bit of 1
indicates that the number is negative.
• For example:
• +4510 in signed binary is (0)01011012
• -4510 in signed binary is (1)01011012
• Notice that in the signed binary representation of positive numbers
between +010 and +12710, all the positive values are just the same as in
pure binary.
• However the pure binary values equivalents of +12810 to +25510 are now
considered to represent negative values −0 to −127.
• This also means that 010 can be represented by 000000002 (which is also 0
in pure binary and in decimal) and by 100000002 (which is equivalent to
128 in pure binary and in decimal).
Signed Binary Arithmetic
• Because the signed binary system now contains both positive and
negative values, calculation performed with signed binary arithmetic
should be more flexible.
• Subtraction now becomes possible without the problems of borrow
and payback described in Number Systems

Adding Positive &


Adding Positive
Negative
Numbers in Signed Binary
Numbers in Signed
Binary
Ones and Twos Complement
• Whilst signed binary does solve the problem of REPRESENTING
positive and negative numbers in binary, and to some extent carrying
out binary arithmetic, there are better sign and magnitude systems
for performing binary arithmetic.
• These systems are the ONES COMPLEMENT and TWOS
COMPLEMENT systems,
1’s Complements
• 1’s complement (or Ones’ Complement)
• To calculate the 1’s complement of a binary number just “flip” each bit of the
original binary number.
• E.g. 0  1 , 1  0
• 01010100100  10101011011

25
Ones Complement
• The complement (or opposite) of +5 is −5. When representing positive and negative
numbers in 8-bit ones complement binary form, the positive numbers are the same as
in signed binary notation .
• The numbers 0 to +127 are represented as 000000002 to 011111112.
• However, the complement of these numbers, that is their negative counterparts from
−128 to −1, are represented by ‘complementing’ each 1 bit of the positive binary
number to 0 and each 0 to 1.
• For example:
+510 is 000001012 and That the most significant bit (msb) in the negative number –510 is
−510 is 111110102 1, just as in signed binary. The remaining 7 bits of the negative
number however are not the same as in signed binary
notation.
They are just the complement of the
remaining 7 bits, and these give the value or magnitude
of the number.
• The problem with signed binary arithmetic was that it gave the wrong
answer when adding positive and negative numbers.
• Does ones complement notation give better results with negative
numbers than signed binary?
Adding Two Negative
Numbers in Ones
Complement

The result of adding −4 to +6, using


ones complement, this is the same as subtracting +4
from +6, so it is crucial to arithmetic.

The result, 000000012 is 110 instead of 210.


• +410 is 000001002 in pure 8 bit binary, so complementing gives 11111011.
This is −410 in ones complement notation.
• +310 is 00000011 in pure 8 bit binary, so complementing gives 11111100.
• This is −310 in ones complement notation.
• The result of 111101112 is in its complemented form so the 7 bits after
the sign bit (1110111), should be re-complemented and read as
0001000, which gives the value 810.
• As the most significant bit (msb) of the result is 1 the result must be
negative, which is correct, but the remaining seven bits give the value of
−8. This is still wrong by 1, it should be −7.
• There are still problems with both ones complement and signed binary
notation. The ones complement system still has two ways of writing 010
(000000002 = +0 and 111111112 = −0).
2’s Complements
• 2’s complement
• To calculate the 2’s complement just calculate the 1’s
complement, then add 1.
01010100100  10101011011 + 1=
10101011100
• Handy Trick: Leave all of the least significant 0’s and first 1
unchanged, and then “flip” the bits for all other digits.
• Eg: 01010100100 -> 10101011100

29
Complements
• Note the 2’s complement of the 2’s complement is just the original
number N
• EX: let N = 01010100100
• (2’s comp of N) = M = 10101011100
• (2’s comp of M) = 01010100100 = N

30
Signed Binary Numbers
• Two methods:
• First method: sign-magnitude
• Use one bit to represent the sign
• 0 = positive, 1 = negative
• Remaining bits are used to represent the magnitude
• Range - (2n-1 – 1) to 2n-1 - 1
where n=number of digits
• Example: Let n=4: Range is –7 to 7 or
• 1111 to 0111

31
Signed Binary Numbers
• Second method: Two’s-complement
• Use the 2’s complement of N to represent
-N
• Note: MSB is 0 if positive and 1 if negative
• Range - 2n-1 to 2n-1 -1
where n=number of digits

• Example: Let n=4: Range is –8 to 7


Or 1000 to 0111

32
Signed Numbers – 4-bit example
Decimal 2’s comp Sign-Mag
7 0111 0111
6 0110 0110
5 0101 0101
4 0100 0100
3 0011 0011
2 0010 0010
1 0001 0001 Pos 0
0 0000 0000
33
Signed Numbers-4 bit example
Decimal 2’s comp Sign-Mag
-8 1000 N/A
-7 1001 1111
-6 1010 1110
-5 1011 1101
-4 1100 1100
-3 1101 1011
-2 1110 1010
-1 1111 1001
-0 0000 (= +0) 1000
34
Twos Complement Notation
• Twos complement notation solves the problem of the relationship
between positive and negative numbers, and achieves accurate
results in subtractions.
• The twos complement system overcomes both of these problems by
simply adding one to the ones complement version of the number
before addition takes place.
Adding a Number to its
Twos Complement Produces
Zero
With numbers electronically stored in their twos
complement form, subtractions can be carried
out more easily (and faster) as the
microprocessor has simply to add two numbers
together using nearlythe same circuitry as is
used for addition.
6 − 2 = 4 is the same as (+6) + (−2) = 4

Adding Positive
Numbers
in Twos Complement

Subtracting a Positive
Number
Subtraction Producing
a Negative Result
Notes:
• “Humans” normally use sign-magnitude representation for signed
numbers
• Eg: Positive numbers: +N or N
• Negative numbers: -N
• Computers generally use two’s-complement representation for signed
numbers
• First bit still indicates positive or negative.
• If the number is negative, take 2’s complement to determine its magnitude
• Or, just add up the values of bits at their positions, remembering that the first bit is
implicitly negative.

38
Examples
• Let N=4: two’s-complement
• What is the decimal equivalent of
01012
Since MSB is 0, number is positive
01012 = 4+1 = +510

• What is the decimal equivalent of


11012 =
• Since MSB is one, number is negative
• Must calculate its 2’s complement
• 11012 = −(0010+1)= − 00112 or −310

39
BINARY CODES
• Advantages of Binary Code
• Binary codes are suitable for the computer applications.
• Binary codes are suitable for the digital communications.
• Binary codes make the analysis and designing of digital circuits if we use the
binary codes.
• Since only 0 & 1 are being used, implementation becomes easy.
BCD Codes
• BCD8421 code is so called because each of the four bits is given a
‘weighting’ according to its column value in the binary system.
The least significant bit (lsb) has the weight or
value 1, the next bit, going left, the value 2. The
next bit has the value 4, and the most significant
bit (msb) the value 8,
The 8421BCD code for the decimal number 610 is 01108421.
For numbers greater than 9 the system is extended by using a
second block of 4 bits to represent tens and a third block to
represent hundreds etc.
2410 in 8 bit binary would be 00011000 but in BCD8421 is 0010
0100.
99210 in 16 bit binary would be 00000011111000002 but in
BCD8421 is 1001 1001 0010.
ADVANTAGES AND DISADVANTAGES

• Advantages of BCD Codes


• It is very similar to decimal system.
• We need to remember binary equivalent of decimal numbers 0 to 9 only
• Disadvantages of BCD Codes
• The addition and subtraction of BCD have different rules.
• The BCD arithmetic is little more complicated.
• BCD needs more number of bits than binary to represent the decimal
number. So BCD is less efficient than binary
GRAY CODE
• REFLECTED BINARY CODE; MINIMU DISTANCE CODE/MINIU ERROR
CODE/ CYCLIC CODE/
• From: Frank Gray
• Unweighted code
• 2 successive values differ by 1 bit
• Binary numbers are converted to gray
code to reduce switching operation
• COMPARE 3;4 7,8 ONE VALUE
CHANGES FOR THE GRAY CODE:
• Application of Gray code
• Gray code is popularly used in the shaft position encoders.
• A shaft position encoder produces a code word which represents the angular
position of the shaft.
CONVERSION:
• STEP 1: RECORD THE MSB eg 1011 msb = 1
• STEP 2: ADD THE MSB TO THE NEXT BIT, RECORD THE SUM NEGLECT THE
CARRY A B X
• STEP 3: REPEAT THE PROCESS FOR OTHER BITS 0 0 0
• 1011 = 1110 0 1 1
• USE OF THE X-OR OPERATION 1 0 1
1 1 0
Gray Code
• Binary codes are not only used for data output. Another special binary
code that is extensively used for reading positional information on
mechanical devices such as rotating shafts is Gray Code.
• This is a 4 bit code that uses all 16 values, and as the values change
through 0-1510 the code’s binary values change only 1 bit at a time

It is the non-weighted code and it is not


arithmetic codes. That means there are no
specific weights assigned to the bit position. It
has a very special feature that, only one bit will
change each time the decimal number is
incremented
Excess-3 code
• The Excess-3 code is also called as XS-3 code. It is non-weighted code
used to express decimal numbers. The Excess-3 code words are
derived from the 8421 BCD code words adding (0011)2 or (3)10 to
each code word in 8421
CONVERSION BCD TO EXCESS 3
• Example − convert (1001)BCD to Excess-3.
• Step 1 − Convert to decimal
• (1001)BCD = 910
• Step 2 − Add 3 to decimal
• (9)10 + (3)10 = (12)10
• Step 3 − Convert to Excess-3
• (12)10 = (1100)2
• Result
• (1001)BCD = (1100)XS-3
Excess-3 to BCD Conversion

• Step 1 -- Subtract (0011)2 from each 4 bit of excess-3 digit to obtain the
corresponding BCD code.

• Example − convert (10011010)XS-3 to BCD.


• Given XS-3 number = 1 0 0 1 1 0 1 0
• Subtract (0011)2 = 0 0 1 1 0 0 1 1
• --------------------
• BCD = 0 1 1 0 0 1 1 1
• 10011010)XS-3 = (01100111)BCD

You might also like