Chapter 1
Chapter 1
1
Course Objectives
• Main objectives of this course is to provide the
student with the fundamental knowledge about the
basic building logical blocks of digital computer
systems.
2
Course Logistics
• Prerequisite:
– Basic concept of Digital Logic
• Textbook:
– "Logic and Computer Design Fundamentals,"
2nd Edition, by M. Mano and C. Kime, Pearson Education Asia,ISBN # 81-7808-
334-5
Reference Books:
– Book by M.Morris Mano/PHI
– Book by Hamachar/Zakie/McGraw Hill
3
Syllabus
4
History of the transistor
• Around 1947, Bell Labs scientists discovered that
silicon was comprised two distinct regions differentiated
by the way in which they favored current flow.
5
Transistor
• Semiconductors: ability to
change from conductor to
insulator
• Can either allow current or
prohibit current to flow
• Useful as a switch, but also as an
amplifier
• Essential part of many
technological advances
6
The Transistor is Born
• Bell Labs (1947): Bardeen, Brattain, and
Shockley
• Originally made of germanium
• Current transistors made of doped silicon
7
How Transistors Work
• Doping: adding small amounts of other
elements to create additional protons or
electrons
• P-Type: dopants lack a fourth valence electron
(Boron, Aluminum)
• N-Type: dopants have an additional (5th)
valence electron (Phosphorus, Arsenic)
• Importance: Current only flows from P to N
8
Bipolar Junction Transistor (BJT)
• 3 adjacent regions of doped Si
(each connected to a lead):
– Base. (thin layer,less doped).
– Collector.
– Emitter.
• 2 types of BJT: npn bipolar junction transistor
– npn.
– pnp.
• Most common: npn (focus on
it).
Developed by
Shockley pnp bipolar junction transistor
(1947) 9
Digital Logic Circuit
10
Moore’s Law
11
Introduction to Digital Logic
Deals with building blocks of digital systems
? Transistor
(Intel)
12
Digital Model of a Transistor
• We make abstraction of the signals: 0 or 1
• As a result a transistors can be considered a switch (on or off; 1 or 0)
13
Overview: you will learn
• Digital Computer
• Information Representation
• Number Systems [binary, octal and
hexadecimal]
• Base Conversion
• Negative Number Representation
• Decimal Codes [BCD (binary coded
decimal)]
• Alphanumeric Codes
• Parity Bit
• Gray Codes, Excess-3 Codes
14
Digital Processing System
• Takes a set of discrete information inputs
and discrete internal information (system
state) and generates a set of discrete
information outputs.
15
Digital System Example:
A Digital Counter (e. g., odometer):
Count Up
Reset 0 0 1 3 5 64
16
A Generic Digital Computer
17
A Generic Digital Computer
• Data Path:
– Performs calculations and comparisons (data changed)[Data
Processing and arithmetic operation specified by the program]
• CU (control unit): performs fetch/execute cycle
– Functions:
• Moves data to and from CPU registers and other hardware
components (no change in data)
• Accesses program instructions and issues commands to the ALU
– Subparts:
• Memory management unit: supervises fetching instructions and data
• I/O Interface: sometimes combined with memory management unit
as Bus Interface Unit
• FPU: like CPU, except its data path and Control Unit are designed to perform
floating-point operations
• Cache: memory that allow the CPU and FPU to get at the data to be
processed much faster than RAM alone.
18
INFORMATION REPRESENTATION
• Information variables represented by physical
quantities.
• For digital systems, the variables take on
discrete values.
• Two levels or binary values are the most
prevalent values in digital systems.
• Binary values are represented abstractly by:
– digits 0 and 1
– words (symbols) False (F) and True (T)
– words (symbols) Low (L) and High (H)
– and words Off and On.
19
Signal Examples Over Time
Time
Continuous
Analog in value &
time
Digital Discrete in
value &
Asynchronous
continuous
in time
Synchronous Discrete in
with the clock value &
time20
Advantages of Digital System
Reproducibility ( Hi-Fi-> high fidelity)
Programmable (Storage)
21
Immunity to noise: Noise Margin
VOH
NMH
VIH
Forbidden
VIL
NML
VOL
Threshold
Region
NMH=VOH-VIH NML=VIL-VOL
We cannot violate the Noise Margins, otherwise our digital assumption
is not valid: thus Vo must be > VOH or < VOL.
22
Binary Values: Other Physical Quantities
• What are other physical quantities
represent 0 and 1?
– Logic Gates, CPU: Voltage
– CD Surface Pits/Light
– Dynamic RAM
Electrical Charge 23
Number Systems
• Positive radix, positional number systems
• Examples:
– Decimal (radix r =10)
Ex: 24.3 = 2x101 + 4x100+3x10-1
– Binary (radix r =2)
Ex: 1101.01 = ( . )10 Digits (0-9)
– Octal (radix r = )
Digits: 0,1,2,3,4,5,6,7
– Hexadecimal (r = )
Digits: 0,1,2,…9, A, B, C, D, E, F
24
Powers of 2: 2 n
n 2n n 2n
0 1
1 2 -1 0.5
2 4 -2 0.25
3 8 -3 0.125
4 16
5 32
6 64
7 128
8 256
9 512
10 1024
25
Special Powers of 2
210 (=1024) is Kilo, denoted "K"
• (146.A)16 = ( ? )10
• (247.4)8 = ( ? )10
27
Range of numbers
• Binary number: ex. a 3-bit number: n=3
– 000, 001 … ,111 or in decimal system: 0,
1…7
• Total of 8 numbers (=2 3) 2m-1/2m
• Range: from 0 to 7 (0 to 2 3-1)
Proof: A-12-1 + A-22-2
– In general a n-bit number represents:
• 2n different numbers
+ …. A-m2-m)
• Min: 0 = 2-m (A-12m-1 + A-22m-
• Max number: 2n-1 2
+… A-m20)
• For fractions: m bits after the radix = 2-m (2m -1)
point:
– Min: 0
– Max number: (2m -1)/2m
28
Number of Bits Required
Given M elements to be represented by a
binary code, the minimum number of bits,
n, needed, satisfies the following
relationships:
2n ³ M > 2(n – 1)
n = log2 M where x , called the ceiling
function, is the integer greater than or
equal to x.
Example: How many bits are required to
represent decimal digits with a binary
code?
29
Exercise
• 16 Gbyte (= 16 GB) of memory
– How many (address) bits are required to
address each byte?
30
Exercise
• Digital camera has 2048x2048 pixels, and
each pixel stores 8 bits of information:
31
Use of HEX system
• Short hand notation of large binary numbers:
– Each HEX digits can be represented by exactly 4 bits
(16=24)
– Thus (10011110.0101)2
9 E . 5
33
Conversion Between Bases
34
Conversion from Decimal to new Radix
• To Convert the Integral Part:
Repeatedly divide the number by the new radix and
save the remainders. The digits for the new radix
are the remainders in reverse order of their
computation.
• To Convert the Fractional Part:
Repeatedly multiply the fraction by the new radix
and save the integer digits that result. The digits
for the new radix are the integer digits in order of
their computation. If the new radix is > 10, then
convert all integers > 10 to digits A, B, …
35
Example: convert (325.65)10 to hex
• Integer part: 32510 = ( . )16
325/16 = 20 and rem = 5 Least significant digit
20/16 = 1 and rem = 4
1/16 = 0 and rem = 1
Most significant
• Convert 54 to Base 2
Octal: Hexadecimal
10001011 10001011
2 1 38 8 B16
38
Octal to Hexadecimal via Binary
Conversion from Octal to Hexadecimal and vice versa
2138
10001011
8 B16
39
Exercise: Octal Hexadecimal
• Exercise: Hexadecimal to Octal:
3A.5 16 = ( )8
40
Conversion - Summary
Divisions (or x) by 16
Ai.16i Hexadecimal
Decimal Di
vis
on
sb
S A
y2 Group in
.2 i bits of 4
Div
i
Binary
iso
ns
Octal Hex:
Group in
by
representation
Octal
41
Arithmetic Operations
Single Bit Binary Addition with Carry
Multiple Bit Binary Addition
Single Bit Binary Subtraction with Borrow
Multiple Bit Binary Subtraction
Multiplication
42
Single Bit Binary Addition with Carry
Given two binary digits (X,Y), a carry in (Z) we get the
following sum (S) and carry (C):
Carry in (Z) of 0: Z 0 0 0 0
X 0 0 1 1
+Y +0 +1 +0 +1
CS 00 01 01 10
Carry in (Z) of 1: Z 1 1 1 1
X 0 0 1 1
+Y +0 +1 +0 +1
CS 01 10 10 11
43
Multiple Bit Binary Addition
46
Binary Multiplication
The binary multiplication table is simple:
00=0 | 10=0 | 01=0 | 11=1
Extending multiplication to multiple digits:
Multiplicand 1011
Multiplier x 101
Partial Products 1011
0000 -
1011 - -
Product 110111
47
Negative Binary Number
• In decimal we are quite familiar with placing
a
“-” sign in front of a number to denote that it
is negative
• The same is true for binary numbers a
computer won’t understand that
• What happens in memory then?
48
Negative Binary Number
• There are several representations
- Signed magnitude
- One’s complement
- Two’s complement
• Two’s complement is the system used in
microprocessors
• Most significant bit becomes important
49 49
Sign Magnitude
• Represent the decimal number as binary
• Left bit (MSB) used as the sign bit
• Only have 7 bits to express the number
• 1210 = 00001100
• -1210 = 10001100
50 50
1’s Complement
• 1110 = 00001011
• -1110 = 11110100
51 51
2’s Complement
• Method: Take the one’s complement and add
1
• 1110 = 00001011
• -1110 = 11110100 one’s comp
• -1110 = 11110101 two’s comp
52 52
2’s Complement Subtraction
• Only need one type of hardware/process to add
both signed and unsigned numbers.
54 54
POS + NEG → POS Answer
Take the 2’s complement of the negative number and use
regular binary addition
55 55
POS + NEG → NEG Answer
Take the 2’s complement of the negative number and use
regular binary addition.
56 56
NEG + NEG → NEG Answer
Take the 2’s complement of both negative numbers and
use regular binary addition.
57 57
Binary Codes
• A n-bit binary code is a n-bit word
which can represent up to 2n different
elements.
• Example: 3-bit code can represent up
to 8 different elements”
58
Binary Codes
• Example: A
binary code Color Binary Number
Red 000
for the seven
Orange 001
colors of the Yellow 010
rainbow Green 011
Blue 101
Indigo 110
Violet 111
61
Exercise
Add 448BCD to 489BCD showing carries and digit
corrections.
62
ALPHANUMERIC CODES - ASCII Character Codes
• American Standard Code for Information
Interchange
• This code is a popular code used to
represent information sent as character-
based data. It uses 7-bits to represent:
– 94 Graphic printing characters.
– 34 Non-printing characters
• Some non-printing characters are used for
text format (e.g. BS = Backspace, CR =
carriage return)
63
ASCII Code: B7B6B5 B4B3B2B1
H=(1001000)
64
ASCII Properties
ASCII has some interesting properties:
Digits 0 to 9 span Hexadecimal values 3016 to 3916 .
Upper case A - Z span 4116 to 5A16 .
Lower case a - z span 6116 to 7A16 .
• Lower to upper case translation (and vice versa)
65
PARITY BIT Error-Detection Codes
• Redundancy (e.g. extra information), in the form of
extra bits, can be incorporated into binary code words
to detect and correct errors.
• A simple form of redundancy is parity, an extra bit
appended onto the code word in the most significant
position to make the number of 1’s odd or even. Parity
can detect all single-bit errors and some multiple-bit
errors.
A code word has even parity if the
number of 1’s in the code word is 7
even. TX RX
A code word has odd parity if the Parity bit
number of 1’s in the code word is
odd.
66
ASCII Parity Code Example
7
TX At the receiver side:
RX
Parity bit If an even parity is
detected, send an
Transmit Ha in ascii: ACK control =
1001000 1100001 00000110
Transmit with even parity: If error was detected
01001000 11100001 send negative
acknowledge NAK =
10010101
added parity bit
67
4-Bit Parity Codes
000 - 000
-
001 - 001
-
010 - 010
-
011 - 011
-
100 - 100
-
101 - 101
-
110 - 110
-
The codeword "1111" has even parity
111 - 111
- and the
codeword "1110" has odd parity. Both can be used
to represent 3-bit data.
68
GRAY CODE
Binary Gray
000 000
001 2 bit changes 001
010 011
011 2 bit changes 010 Only 1 bit changes
100 110
101 2 bit changes 111
110 101
111 100
69
Binary to Gray Code( Vice-Versa)
E.g. Conversion of Binary number 10110 to Gray
Code
1+0+1+1+0 Binary
1 1 1 0 1
Conversion of Gray Code 11101 to Binary Number
1 1 1 0 1
+ + + +
1 0 1 1 0
70
Excess 3 Code
Decimal Excess 3
0 0011
1 0100
2 0101
3 0110
4 0111
5 1000
6 1001
7 1010
8 1011
9 1100
72
Problem:
73