INTRODUCTORY CONCEPTS
The foundation of digital computer was laid upon the invention of some computing
machines by an eccentric British mathematician Charles Babbage (1791-1871).
Born December 26, 1791 in Teignmouth, Devonshire UK, Died 1871,
London; Known to some as the "Father of Computing" for his contributions to
the basic design of the computer through his Analytical machine. His previous
Difference Engine was a special purpose device intended for the production of
tables.
His first computing machine is called the difference engine.
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
The first functional digital computer was invented at Harvard University in 1944.
However, it was not an electronic computer, but an electromechanical computer.
ENIAC computer, the first large-scale general-purpose electronic computer. Built at
the University of Pennsylvania's Moore School of Electrical Engineering, ENIAC is
an acronym for "Electronic Numerical Integrator and Computer," but its birth lay
in World War II as a classified military project known only as Project PX. The
ENIAC is important historically, because it laid the foundations for the modern
electronic computing industry. More than any other machine, the ENIAC
demonstrated that high-speed digital computing was possible using the then-available
vacuum tube technology.
The ENIAC machine occupied a room thirty by fifty feet. The controls
are at the left, and a small part of the output device is seen at the right. The two
men in uniform were being trained to maintain the machine after it was turned
over to the Ordnance Department (which sponsored the development of the
ENIAC). The two women were assistants on the staff of the Moore School who
helped program the ENIAC.
The term digital is derived from the way computers
perform operations, by counting digits.
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
CONTROL
UNIT
PROCESSOR
or
ARITHMETIC
UNIT
STORAGE
or
MEMORY UNIT
INPUT
DEVICE
OUTPUT
DEVICE
Block Diagram of a Digital Computer
OLD SCHOOL OF THINKING
NEW SCHOOL OF THINKING
Digital electronics finds its use in:
Television
Communication systems
Radar
Navigation and Guidance System
Military Systems
Medical Instrumentation
Industrial Process Control
Consumer Electronics
Digital electronics are confined
only for the applications of digital
computers.
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
DIGITAL AND ANALOG QUANTITIES
Analog Quantity
One having continuous values.
Digital Quantity
One having a discrete set of values.
Analog Signal
Sampled & Quantized Signal
Digital Electronics includes circuits and system in which there are
only two possible states.
Advantages of Digital Electronics over Analog Electronics
Digital data can be processed and transmitted more efficiently and
reliably than analog data.
Digital data has a great advantage when storage is necessary.
Noise does not affect digital data nearly as much as it does analog data.
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
SWITCHING THEORY
Concerned with design concepts used for digital electronics.
Also known as logic design, digital logic, switching circuits,
digital systems.
DIGITAL SYSTEM
Receives,
stores,
manipulates
and
communicates information in discrete form.
Is any system intended for the transmission or
processing of information in which information is represented by physical
quantities (signals) that are so constrained as to take on only discrete values.
BINARY SYSTEM
Is the number system with only two distinct discrete values, 0 and 1 called bits. The
term bits is a contraction of the words binary digit.
In digital circuits, two different voltage levels are used to represent the two bits.
POSITIVE LOGIC : A 1 is represented by a higher
voltage, which will be referred to
as a HIGH and a 0 will be
referred to as a LOW.
HIGH = 1
LOW = 0
NEGATIVE LOGIC: A 1 is represented by a higher
voltage, which will be referred to
as a LOW and a 0 will be
referred to as a HIGH.
HIGH = 0
LOW = 1
BINARY CODES
Combination of binary digits (bits) used to represent numbers, letters, symbols,
instructions, and anything else required in a given application.
000101011101010101010000011110101010111100001010101000001110101001010101101
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
LOGIC LEVELS
The voltages used to represent a 1 or a 0 are called logic leves.
Ideally, one voltage level represents a HIGH and another voltage represents a LOW.
In a practical digital circuit, however, a HIGH can be any voltage between a specified
minimum value and specified maximum value. Likewise, a LOW can be any voltage
between a specified minimum and a specified maximum. There can be no overlap
between the accepted HIGH levels and accepted LOW levels.
For example, for TTL (transistor-transistor logic), the HIGH values may range from 2
V to 5 V and the LOW values may range from 0 to 0.8 V.
VH(max)
HIGH
(binary 1)
VH(min)
Unacceptable
VL(max)
LOW
(binary 0)
VL(min)
Characteristics of Digital Systems
Manipulation of discrete elements of information
Availability of low -cost integrated circuit devices
High speed
Ease in calibration and testing.
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
NUMBER SYSTEMS
Base/Radix
Number System
2
3
4
5
6
7
8
9
10
11
12
16
20
60
Binary or Dyadic
Ternary
Quaternary
Quintary
Senary
Septenary
Octal or Octenary
Nonary
Decimal or Decadic or Denary
Undenary
Duodecimal or Duodenary
Hexadecimal or Hexadecadic
Vigesimal or Vicenary
Sexagesimal
Generalizations:
The number of symbols is equivalent to the decimal value of the radix.
The last symbol is always equivalent to the decimal value of the radix minus 1.
In counting, the count after the last digit is always 10. The weight of 10 is equivalent
to the decimal value of the radix.
NUMBER REPRESENTATIONS
Given a number, (N.F) r, this can be represented in two forms.
N whole part/integer part
F fractional part
. radix point
r radix
A. POLYNOMIAL REPRESENTATION
The weight is explicit.
(N.F)r = a n r n + a n 1r n 1 + L + a 2 r 2 + a1r1 + a0 r 0 + a1r 1 + a 2 r 2 + L + a f r f
B. JUXTAPOSITIONAL REPRESENTATION
The weight is implicit to the position of the digit.
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
NUMBER BASE CONVERSIONS
1. Base r to Base 10
(N.F )r (N.F )10
RULE: Write (N.F)r in polynomial form and evaluate in decimal.
Exercises:
(1010.011) 2
(630.4)8
(B65F.8) 16
2. Base 10 to Base r
(N.F )10 (N.F)r
a) Repeated Division/Multiplication Method
The conversion from decimal to any number system is more convenient if the
number is separated into an integer part and a fraction part.
FOR THE INTEGER PART
FOR THE FRACTION PART
START
START
Divide by r
Multiply by r
Record quotient (Q)
and remainder (R)
Record product (P)
and fraction (F)
Q=0
F=0
Collect Rs into desired base
r number with 1st R as LSB
Collect Ps into desired base
r number with 1st P as MSB
END
END
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
b) Positional Method / Sum-o f-Weights Method
(207)10 (11001111)2
(38) 10 (1102)3
3. Binary, Octal, Hexadecimal
a) Binary to Octal group the bits in 3s with weights 4-2-1.
(101 110 010)2 (562)8
(001 001 101)2 (115)8
b) Binary to Hexadecimal group the bits in 4s with weights 8-4-2-1.
(1010 0000)2 (A0) 16
(0011 0111 1100) 2 (37C)16
c) Octal to Binary each octal digit consists of 3 bits.
(143)8 (001 100 011)2
(546)8 (101 100 110)2
d) Hexadecimal to Binary each hexadigit consists of 4 bits.
(FA0C)16 (1111 1010 0000 1100) 2
(87) 16 (1000 0111)2
e) Octal to Hexadecimal and vice-versa use binary as intermediate number
system.
(574)8 (101 111 100)2 = (0001 0111 1100) 2 (17C)16
(D2E)16 (1101 0010 1110)16 = (110 100 101 110)2 (6456) 8
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
BASIC ARITHMETIC OPERATIONS
RULE: Add/Subtract/Multip ly/Divide numbers of the same base only!!!
(1011 . 01)2
(0110 .10 )2
(1011 .11)2
( 101 .11)2
(127 .2 )8
(110 .5 )8
(127 .2 )8
(767 .7 )8
(AB.C)H
( 11 .2 )H
(AB.C)H
(FE.D)H
(78. 2)8
(12 .3)8
(1011 .11)2
(1010 .10 )2
(1000 . 01)2
( 111 .11)2
(72.1)8
(51.1)8
(125. 3)8
( 77.4 )8
(AB.C)H
( 19 .8)H
(F 9.8 )H
(AB.C)H
(101 .1)2
(11)2
(77. 1)8
(12 )8
(11)2 (10101)2
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
COMPLEMENTS OF NUMBERS
The 1s complement and the 2s complement of a binary number are important
because they permit the representation of negative numbers. The method of 2s complement
arithmetic is commonly used in computers to handle negative numbers.
A. Diminished Radix Complement [(r-1)s complement]
(N )r 1,c = r n r m N
(147)9,c =
(0.53)9,c =
(147.53)9,c =
(1010) 1,c =
Alternative Solution: for binary numbers: invert all bits;
for other systems: subtract all digits from (r-1)
B. Radix Complement [rs complement]
(N )r , c
= rn N
[N 0]
(147)10,c =
(0.53)10,c =
(147.53)10,c =
(453)8,c =
(1010) 2,c =
Alternative Solution: for binary numbers: start at the right with the LSB,
write the bits as they are up to and including the
first 1 and then, invert the remaining bits;
for all systems: subtract the LSB from r and subtract
all other digits from (r-1)1
Still another solution: for all systems: take the rs complement and add 1.
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
SUBTRACTION USING COMPLEMENTS
A. Subtraction using rs complement:
Steps:
1.) Make the number of digits of M and S equal.
2.) Take the rs complement of S, then add it to M.
3.) If there is an end carry, the sum is the difference,
D, of M and S, else, take the rs complement of the
sum and prefix a negative sign.
B. Subtraction using (r-1)s complement
Steps:
1.) Make the number of digits of M and N equal.
2.) Take the (r-1)s complement of S, then add it to M.
3.) If there is an end carry, the sum plus the carry is the
difference, D, of M and S, else, take the (r-1)s
complement of the sum and prefix a negative sign.
M
M
-- S
S
D
D
EXERCISES:
Solve using rs complement:
47 10
34 10
1310
47 10
34 10
47 10
1310
30 8
30
+ 8
118
17 8
34 10
118
11
+ 8
30 8
17 8
Solve using (r-1)s complement:
4710
47
+ 10
3410
1310
30 8
118
17 8
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
30 8
3410
34
+ 10
4710
1310
118
30 8
17 8
118
SIGNED BINARY NUMBERS
Digital systems, such as computer, must be able to handle
both positive and negative numbers. A signed binary number
consists of both sign and magnitude information. The sign
indicates whether a number is positive or negative and the
magnitude is the value of the number.
There are three ways in which signed integer (whole) numbers can be represented in
binary form:
1.) Sign-Magnitude
2.) 1s complement
3.) 2s complement
For non-integer and very large or small numbers, they can be represented/expressed in
floating-point format.
The Sign Bit
The left-most bit in a signed binary number is the sign bit, which tells whether the
number is positive or negative.
A 0 is for positive, and a 1 is for negative.
1.) Sign Magnitude System
The left-most bit is the sign bit and the remaining bits are the magnitude bits. The
magnitude bits are in true (uncomplemented) binary for both positive and negative numbers.
To illustrate, consider the decimal number +25. If it is to be expressed as an 8-bit
signed binary number using the sign-magnitude system as
00011001
Sign Bit
Magnitude bits
The decimal number 25 is expressed as
10011001
Sign Bit
Magnitude bits
In sign-magnitude system, a negative number has the same
magnitude bits as the corresponding positive number but the sign bit is a 1
rather than a zero.
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
2.) 1s Complement System
Positive numbers in the 1s complement system are represented the same way as the
positive sign-magnitude numbers. Negative numbers, however, are the 1s complement of the
corresponding positive numbers.
For example, using eight bits, the decimal number 25 is expressed as the 1s
complement of +25 (00011001) as
11100110
In the 1s complement system, a negative number is the 1s
complement of the corresponding positive number.
3.) 2s Complement System
Positive number in the 2s complement system are represented the same way as in the
sign-magnitude and the 1s complement systems. Negative numbers are the 2s complements
of the corresponding positive numbers.
Again, using eight bits, lets take decimal number 25 and express it as the 2s
complement of +25 (00011001) as
11100111
In the 2s complement system, a negative number is the 2s
complement of the corresponding positive number.
Exercises:
Express the decimal number 39 as an 8-bit number in signmagnitude, 1s complement, and 2s complement systems.
Do the same for +19 and 19.
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
COMPUTER NOTE:
Computers use the 2s complement for negative integer numbers
in all arithmetic operations. The reason is that subtraction of a number is
the same as adding the 2s complement of the number. Computers form the
2s complement by inverting the bits and adding 1 using special instructions.
The Decimal Value of Signed Numbers
SIGN-MAGNITUDE
Decimal values of positive and negative numbers in the sign-magnitude system are
determined by summing the weights in all the magnitude bit positions where there are
1s and ignoring those positions where there are zeros.
The sign is determined by examination of the sign bit.
Example:
Determine the decimal value of this signed binary number expressed in sign-magnitude:
10010101.
1S COMPLEMENT
Decimal values of positive numbers in the 1s complement system are determined by
summing the weights in all bit positions where there are 1s and ignoring those
positions where there are zeros.
Decimal values of negative numbers are determined by assigning a negative value to
the weight of the sign bit, summing all the weights where there are 1s (including the
sign bit) and adding 1 to the result.
Example:
Determine the decimal values of the signed binary numbers expressed in 1s complement:
(a) 00010111
(b) 11101000
2S COMPLEMENT
Decimal values of positive and negative numbers in the 2s complement systems are
determined by summing the weights in all bit positions where there are 1s (including
the sign bit) and ignoring those positions where there are zeros.
The weight of the sign bit in a negative number is given a negative value.
Example:
Determine the decimal values of the signed binary numbers expressed in 2s complement:
(a) 01010110
(b) 10101010
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
Range of Signed Integer Numbers
The formula for finding the number of different combinations of n bits is
Total Combinations = 2
For 2s complement signed numbers, the range of values for n-bit numbers is
n-1
-(2 ) to +(2
n-1
-1)
where in each case there is one sign bit and n-1 magnitude bits.
FLOATING-POINT NUMBERS
This type of representation is based on scientific
notation. It is capable of representing very large and
very small numbers without an increase in the number
of bits. Floating point numbers are used to represent
very large integer (whole) numbers and numbers with
both integer and fractional parts.
A floating point number (also known as a real number) consists of two parts plus a
sign: MANTISSA - part of a floating-point number that represents the magnitude of the
number; EXPONENT - part of a floating-point number that represents the number of
places that the decimal point (or binary point) is to be moved.
To illustrate, consider the decimal integer number: 241,506,800.
The mantissa is:
The exponent is:
.2415068
9
When the integer is expressed as a floating-point number, it is normalized by moving
the decimal point to the left of all the digits so that the mantissa is a fractional number and the
exponent is the power of ten.
The floating-point number of the example is
9
0.2415068 x 10
Binary Floating-Point Numbers
Format is defined by ANSI/IEEE Standard 754-1985
Has three forms:
a) Single -precision (32 bits)
b) Double -precision (64 bits)
c) Extended-precision (80 bits)
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
ARITHMETIC OPERATIONS WITH SIGNED BINARY
NUMBERS
Because the 2s complement system for representing signed numbers is the most
widely used in computers and microprocessor-based systems, 2s complement arithmetic will
be used in this discussion.
ADDITION
Conditions when adding two numbers:
Case I: Both numbers positive.
Case II: Positive number with magnitude larger than negative number.
Case III: Negative number with magnitude larger than positive number.
Case IV: Both numbers negative.
Case I: Both numbers positive.
+
00000111
00000100
00001011
4
11
The sum is positive and is therefore in true (uncomplemented) binary.
Case II: Positive number with magnitude larger than negative number.
+
00001111
11111010
1 00001001
15
6
9
The final carry bit is discarded. The sum is positive and therefore in true
(uncomplemented) binary.
Case III: Negative number with magnitude larger than positive number.
+
00010000
11101000
11111000
16
24
8
The sum is negative and therefore in 2s complement form.
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
Case IV: Both numbers negative.
+
1
11111011
11110111
11110010
9
14
The final carry bit is discarded. The sum is negative and therefore in 2s
complement form.
ADD THE TWO NUMBERS AND DISCARD ANY FINAL CARRY BIT.
OVERFLOW CONDITION
When two numbers are added and the number of bits required to
represent the sum exceeds the number of bits in the two numbers, an
OVERFLOW results as indicated by an incorrect sign bit. An overflow
can occur only when both numbers are positive or both numbers are
negative.
Example : Perform (+125) + (+58) in binary.
SUBTRACTION
Subtraction is a special case of addition. Basically, the subtraction operation changes
the sign of the subtrahend and adds it to the minuend. The result is called the difference.
Perform the following subtractions of the signed numbers:
(a)
(b)
(c)
(d)
00001000
00001100
11100111
10001000
00000011
11110111
00010011
11100010
TO SUBTRACT TWO SIGNED NUMBERS, TAKE THE 2S COMPLEMENT
OF THE SUBTRAHEND AND ADD. DISCARD ANY FINAL CARRY BIT.
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
BINARY CODES
Recall:
CODE a group of symbols
Binary Conversion
&
Binary Coding
the result is in binary/bits
binary
conversion
binary
coding
...010100101010101
111001110001010...
binary number
binary code
Binary Conversion:
The bits obtained are binary digits and they form a binary number.
Binary Coding
Bits obtained are arranged according to the rules of the code used. The output is a
binary code.
BINARY CODING SCHEMES:
1. Straight Binary Coding
2. BCD or Binary Coded Decimal
a) Weighted BCD
b) Unweighted BCD
3. Other Digital Codes
a) Gray Code
b) Error Detection Code
c) Alphanumeric Codes
c.1) ASCII
c.2) EBCDIC
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
1. Straight Binary Coding
The code is obtained using binary conversion.
To determine the number of bits to be used, let
N number of data/things/information to be represented
B number of bits needed to represent N data/things/information uniquely
2 N
B
To determine the number of bits needed,
log 10 N
= log 2 N
log 10 2
Example:
There are eight different colors, represent each color with a unique binary code.
There are 5 different signs, represent each sign with a unique binary code.
2. BINARY CODED DECIMAL or BCD
It is a binary code for decimal digits. It means that each decimal digit, 0 through 9, is
represented by a binary code of four bits and at least 6 unassigned code words.
a) WEIGHTED BINARY CODED DECIMAL
WEIGHTED BINARY CODED DECIMAL
8421
DECIMAL
DIGIT
4
0
0
0
0
1
1
1
2
0
0
1
1
0
0
1
84-2-1
0
1
2
3
4
5
6
8
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
7
8
9
0 1 1 1
1 0 0 0
1 0 0 1
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
8
0
0
0
0
0
1
1
4
0
1
1
1
1
0
0
7421
4
0
0
0
0
1
1
1
2
0
0
1
1
0
0
1
5421
-2
0
1
1
0
0
1
1
-1
0
1
0
1
0
1
0
7
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
1 0 0
1 0 0
1 1 1
1
0
1
1 0 0 0
1 0 0 1
1 0 1 0
5
0
0
0
0
0
0
0
4
0
0
0
0
1
1
1
2
0
0
1
1
0
0
1
2421
1
0
1
0
1
0
1
0
0 1 1 1
1 0 1 1
1 1 0 0
2
0
0
0
0
0
1
1
4
0
0
0
0
1
0
1
2
0
0
1
1
0
1
0
BIQUINARY
1
0
1
0
1
0
1
0
1 1 0 1
1 1 1 0
1 1 1 1
5
0
0
0
0
0
1
1
0
1
1
1
1
1
0
0
4
0
0
0
0
1
0
0
3
0
0
0
1
0
0
0
2
0
0
1
0
0
0
0
1
0
1
0
0
0
0
1
0
1
0
0
0
0
1
0
1 0 0 0 1 0 0
1 0 0 1 0 0 0
1 0 1 0 0 0 0
b) UNWEIGHTED BINARY CODED DECIMAL
EXCESS 3 (XS3)
It is obtained by adding 3 (0011 in binary) to the 8421 code.
It is self complementary using the 9s complement.
DECIMAL
DIGIT
0
1
2
3
4
5
6
7
8
9
XS3
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
3. Other Digital Codes
a) Gray Code
It is also known as the reflected and unit distance code.
It is also an unweighted and not an arithmetic code.
It exhibits only a single bit change from one code to the next.
DECIMAL
DIGIT
0
1
2
3
4
5
6
7
GRAY
CODE
000
001
011
010
110
111
101
100
Binary to Gray Code Conversion
1) Place a leading zero before the MSB.
2) Compare the adjacent bit starting from the le ading zero.
3) If the two compared bits are the same 0, if not 1
Gray Code to Binary Conversion
1) Drop the MSB.
2) Compare this to the next adjacent bit.
3) If the compared bits are the same 0, if not 1
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com
b) Parity Generation for Error Detection
Systems use a parity bit as a means for bit error detection. Any group of bits
contains either an even or an odd number of 1s. A parity bit is attached to a group of
bits to make the total number of 1s in a group always even or always odd.
ODD PARITY number of 1s is odd
EVEN PARITY number of 1s is even
EVEN PARITY
P
0
1
1
0
1
0
0
1
1
0
BCD
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
ODD PARITY
P
1
0
0
1
0
1
1
0
0
1
BCD
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
The parity bit can be attached to the code at either the
beginning or the end, depending on the system design. Notice that the
total number of 1s, including the parity bit, is always even for even
parity and always for odd parity.
c) Alphanumeric Codes
In the strictest sense, alphanumeric codes are codes that represent numbers and
alphabetic characters (letters). Most such codes, however, also represent other
characters such as symbols and various instruction necessary for conveying
information.
c.1) ASCII American Standard Code for Information Interchange
It is a universally accepted alphanumeric code used in most computers and
other electronic equipment.
ASCII has 128 characters and symbols represented by a 7-bit binary code.
Actually, ASCII can be considered an 8-bit code with the MSB always zero.
The first thirty-two are nongraphic commands that are never printed or
displayed and used only for control purposes.
c.2) EBCDIC Extended Binary Coded Decimal Interchange Code
Proposed by IBM
Composed of 8 bits but only half of the 256 combinations are actually used.
SWIDLEC Lecture Notes
Edzel R. Lapira
zell@mozcom.com