Professional Documents
Culture Documents
1
1.1 ANALOG AND DIGITAL REPRESENTATION
❑ Analog system process information that varies continuously.
They process time varying signals that can take on any values across a continuous range.
Examples of analog quantities : time, pressure, sound.
2
…1.1 ANALOG AND DIGITAL REPRESENTATION
❑ Digital systems use digital circuits that can process digital signals which can
take either 0 or 1 for binary system.
A discrete set of values.
Varies in discrete (separate) steps.
3
…1.1 ANALOG AND DIGITAL REPRESENTATION
Analog Digital
❑ Use base 10 (decimal) ❑ Use base 2 (binary)
❑ Represented by 10 different level : ❑ Represented by 2 different level: 0 & 1 or
0,1,2,3,4,5,6,7,8,9 low & high.
❑ Analog system: A combination of devices that ❑ Digital system: A combination of devices that
manipulate values represented in analog form manipulate values represented in digital form.
4
5
Bit 1 : 2 to 5V(high)
Bit 0 : 0 to 0.8V(low)
There are no overlap b/n
Undefined :0.8 to 2V
the accepted range of
HIGH & LOW levels.
10
❑ Examples of digital
❑ waveforms :
11
❑ Period (T) is the time from the edge of one pulse to the corresponding edge
of the next pulse.
❖ Is measured in second 𝑇 = 1/𝑓 𝑠
❑ Example: clock frequency: 𝑓 = 100𝐻𝑧,
𝑠𝑜, 𝑇 = 1/100𝐻𝑧 = 0.01𝑠 = 10𝑚𝑠
❑ An important characteristics of a periodic wave form is its duty cycle,
❖ which is the ratio of the pulse width (tw) to the period.
𝐷𝑢𝑡𝑦 𝑐𝑦𝑐𝑙𝑒 = 𝑡𝑤/𝑇 ≤100%
12
❖ Logic gates themselves are simple electronic circuits comprising of diodes, transistors
and resistors.
❑ The digital integrated circuits are designed using bipolar devices or Metal
Oxide Semiconductor (MOS) or a combination of both.
❖ Logic families are mainly classified as Bipolar and Unipolar Logic Families.
14
Positional values
(weight)
103 102 101 100 10-1 10-2 10-3
2 7 4 5 . 2 1 4
❑ Example 2: Express decimal 376 and 2,593 as a sum of the values of each digit.
…1.4 DECIMAL NUMBER AND BINARY NUMBER
2. BINARY NUMBER
❑ The binary numbering system has 2 digits 0 and 1
❑ The binary numbering system has a base of 2 with each position weighted by
a factor of 2 4 3 2 1 0 -1 -2 -3 -4 -5
2 2 2 2 2 2 2 2 2 2
increase increase
16 + 4 + 2 + 1 = 2310
20
2 + 2 + 2 + 2 + 2 + 2 = 32 + 4 + 1 = 3710
5 4 3 2 1 0 0 0 0 0 0
0 0 0 1 1
0 0 1 0 2
0 0 1 1 3
0 1 0 0 4
0 1 0 1 5
0 1 1 0 6
Binary Count 0
1
1
0
1
0
1
0
7
1 0 0 1 9
1 0 1 0 10
1 0 1 1 11
1 1 0 0 12
1 1 0 1 13
1 1 1 0 14
1 1 1 1 15
21
❑ Step 4: Sum the result from step 3, and binary is now decimal.
Example 1. 100101
❑ Step 1: Binary number: 100101 ➔ n = 6
❑ Step 3: multiply
❑ Step 4: sum
22
◼ Determine the set of binary weights whose sum is equal to the decimal
number
23
= 28 + 26 + 25 + 22 + 20
Binary weights
1024 512 256 128 64 32 16 8 4 2 1
1937 = 1024 + 512 + 256 + 128 + 16 + 1 11110010001
Exercises: Decimal – to – Binary conversions
a. 39810 =????
b. 415310= ????
…1.5 B) DECIMAL-TO-BINARY CONVERSION
1) SUM-OF-WEIGHT METHOD
58 AND 125 CONVERT TO BINARY NUMBER
Nearest weight to 58 125
minus
58 64
minus
32 64 32 16 8 4 1
32 16 8 2 61 Apply a 1 to these
26 Apply a 1 to these
minus
weights and 0 to others
minus
weights and 0 to others
32
16
29
10 minus
minus 16
8
13
2 minus 26 25 24 23 22 21 20
minus
25 24 23 22 21 20 8
2 64 32 16 8 4 2 1
5
0 32 16 8 4 2 1 minus
4 1 1 1 1 1 0 1
1 1 1 0 1 0
1
minus 24
5810 = 1110102 1
0
25
0.625 x 2 = 1.25 1
.0 1 0 1
0.25 x 2 = 0.50 0
0.50 x 2 = 1.00 1
right/LSB
1011111.1011
30
❑ Repeated division by 2 yields the whole number while repeated
multiplication by 2 of the fraction yields the binary fraction.
1
❑ Base 16
16 possible symbols
0-9 and A-F
❑ Allows for convenient handling of long binary strings.
❑ Convert from hex to decimal by multiplying each hex digit by its positional
weight.
2
Decimal-to-Hex
4
❑ Convert from binary to hex by grouping bits in four starting with the LSB.
❑ Each group is then converted to the hex equivalent.
❑ Leading zeros can be added to the left of the MSB to fill out the last group.
❑ Example of binary to hex conversion.
❑ 11101001102 = 0011 1010 0110
= 3 A 6
= 3A616
uses base 8
includes only the digits 0 through 7
❑ The Octal system is based on the binary system with a 3-bit boundary
85 84 83 82 81 80
32768 4096 512 64 8 1
❑ Convert octal number to decimal number.
35
…1.6 HEXADECIMAL NUMBER AND OCTAL NUMBER
OCTAL NUMBER
Binary-to-Octal Conversion
001 010 111 110 110 010
(ex : 10101111101100102) 1 2 7 6 6 2
Octal-to-Binary Conversion
1 2 7 6 6 2
(ex : 1276628)
001 010 111 110 110 010
36
7
❑ There are three forms in which signed integer (whole) numbers can be
represented in binary:
❖ Sign-magnitude,
❖ 1's complement, and
❖ 2's complement.
Sign-Magnitude Form
❑ When a signed binary number is represented in sign-magnitude, the left-most bit is the
sign bit and the remaining bits are the magnitude bits.
❑ For example, the decimal number +25 is expressed as an 8-bit signed binary number using
the sign-magnitude form as
00011001 Sign bit Magnitude bits
❑ The decimal number −25 is expressed as 10011001
❑ Notice that the only difference between +25 and -25 is the sign bit because the magnitude
bits are in true binary for both positive and negative numbers
❑ In the sign-magnitude form, a negative number has the same magnitude bits as the
corresponding positive number but the sign bit is a 1 rather than a zero.
9
simply invert the given number and add 1 to the least significant bit (LSB) of given
result.
2’s Complement = 1’s Complement +1
0
❑ It is normally to represent the sign with a bit placed in the left most position
of the number.
❑ The convention is to make the sign bit 0 for positive & 1 for negative.
❑ Three different ways the signed binary numbers represented.
❖ Signed
Magnitude, 1’s Complement & 2’s Complement Form
❑ Example: The representation of + 34 and -34 in a 8-bit sign-magnitude
form.
3
❑ In
2’s complement, the representation of the positive number is same as 1’s
complement and sign-magnitude form.
4
❖ Starting at the LSB, copying down each bit up to and including the first 1 bit
encountered, and complementing the remaining bits.
…1.7 SIGNED NUMBERS
Example: Express -45 in 8-bit 2’s complement form. +45 in 8-bit form is 00101101.
❑ First method
❖ Obtain the 1’s complement of 00101101 and then add 1.
❖ Positive expression of the given number 00101101
❖ 1’s complement of it 11010010
❖ Add 1 +1
❖ Thus, the 2’s complement form of -45 is 11010011
❑ Second method
Subtract the given number N from 2n
2n = 100000000
Subtract 45 = − 00101101
Thus, the 2’s complement form of -45 is 11010011
❑ Thirdmethod
❑ Copy down the bits starting from LSB up to and including the first 1, and then
complement the remaining bits.
Original number 00101101
Copy up to first 1 bit 1
Complement the remaining bits 1101001
Thus, the 2’s complement form of -45 is 11010011
47
…1.7 SIGNED NUMBERS
Two's Complement Arithmetic
❑ The 2's complement system is used to represent negative numbers using modulus
arithmetic.
❑ The word length of a computer is fixed.
❑ That means if a 4-bit number is added to another 4-bit number, the result will be only of 4
bits. Carry, if any, from the fourth bit will overflow.
❑ This is called the modulus arithmetic. Example: 1100 + 1111 = 1011.
❑ In the 2's complement subtraction, add the 2's complement of the subtrahend to the
minuend.
❑ If there is a carry out, ignore it. Look at the sign bit, i.e. MSB of the sum term.
❑ If the MSB is a 0, the result is positive and it is true binary form.
❑ If the MSB is a 1 (whether there is a carry or no carry at all) the result is negative and is in
its 2's complement form.
❑ Take its 2's complement to find its magnitude in binary.
…1.7 SIGNED NUMBERS
Example: subtract 14 from 46 using the 8-bit 2’s complement arithmetic.
+14 = 00001110
−14 = 11110010 (in 2’s complement form)
+46 00101110
−14 +11110010 (2’s complement form of−14)
+32 100100000 (Ignore the carry)
❑ There is a carry, ignore it.
❑ The MSB is 0; so, the result is positive and is in normal binary form.
❑ Therefore, the result is +00100000=+32
…1.7 SIGNED NUMBERS
Example: add −75 to +26 using the 8-bit 2’s complement arithmetic
+75 = 01001011
−75 = 10110101 (in 2’s complement form)
+26 00011010
−75 +10110101 (2’s complement form of -75)
−49 11001111 (No carry)
❑ There is no carry, the MSB is a 1.
❑ There are four cases that must be considered when adding two numbers:
1. Both numbers positive
We will take one case at a time. Eight bits are used to represent each number
…1.7 SIGNED NUMBERS
1. Both numbers positive:
❖ In this case, both sign bits are zero and a 2's compliment is not required. To illustrate,
we will add +7 and +4: 7 00000111
+ 4 00000100
11 00001011
❑ The overflow condition can occur only when both numbers are positive or both
numbers are negative. An overflow result is indicated by an incorrect sign bit.
1.8 GRAY CODE
❑ The Gray code belongs to a class of codes called minimum change codes,
❖ Only one bit in the code group changes when going from one step to the next.
❑ The gray code is an unweighted code, meaning that the bit positions in the code
groups do not have any specific weight assigned to them.
❑ Because of this, the gray code is not suitable for arithmetic operations but finds
application in input/out put devices and some types of analog-to-digital
converters.
❑ Table below shows the gray code representation for the decimal number 0 through
15,together with straight binary code.
…1.8 GRAY CODE
❑ In Gray code only one bit of Gray code changes.
Decimal Binary Gray
❑ For example:
code code
Decimal Gray code
0 0000 0000
1 0001 0001 3 to 4 0010 to 0110
2 0010 0011
3 0011 0010
14 to 15 1001 to 1000
4 0100 0110
5 0101 0111
❑ Compare this with the binary code, where anywhere
6 0110 0101
7 0111 0100
from one to all of the bits changes in going from one
8 1000 1100
9 1001 1101
step to the next.
10 1010 1111 ❑ For example:
11 1011 1110
12 1100 1010 Decimal Binary code Gray code
13 1101 1011
14 1110 1001
7 to 8 0111 to 1000 0100 to 1100
57
15 1111 1000
…1.8 GRAY CODE
BINARY-TO-GRAY CODE CONVERSION
❑ The most significant bit (MSBt) in the Gray code is the same as the
corresponding MSB in the binary number.
❑ Going from left to right, add each adjacent pair of binary code bits to get the
next Gray code bit. Discard carries.
❑ For example, the conversion of the binary number 1110 to Gray code is as
follows:
1 + 1 + 1 + 0
1 0 0 1
+ + +
= 10112
1 0 1 1
❑ The binary combinations 1010 through 1111 are not used and have no
meaning in BCD. Ex : 3510 = 0011 0101
60
…1.9 BINARY CODED DECIMAL (BCD)
BCD CONVERSION AND ADDITION
❑ There are only 10 code groups in the BCD system
0 1 2 3 4 5 6 7 8 9
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
❑ Ex
❑ BCD Addition
62
63
❑ Example :
A = 10000012;
a = 11000012
ASCII TABLE Kos ASCII : 10000012
1000 BS CAN ( 8 H X h x
1001 HT EM ) 9 I Y i y
1010 LF SUB * : J Z j z
1011 VT ESC + ; K [ k {
1100 FF FS , < L \ l |
1101 CR GS - = M ] m } 64
1110 SO RS . > N ^ n ~
1111 SI US / ? O _ o DEL
65
Symbol Binary Hexadecimal
2 0110010 32
0 0110000 30
Space 0100000 20
P 1010000 50
R 1010010 52
I 1001001 49
Space 0100000 20
A 1000001 41
4 18 “ 0100010 22
X 1011000 3B
“ 0100010 22
; 0111011 3B