Introduction to Computer Architecture
Introduction to Computer Architecture
for
Computer Science 1
(Computer Organization and Architecture)
Module 1
(Introduction to Computer Architecture)
Contents
i
Computer Science 1
CAP College
ii
INSTRUCTIONS TO THE STUDENT
iii
Module 1: Introduction to Computer Architecture
1
The 5 Component Model
A computer system can be divided into 5 components:
1. Hardware
2. Software
3. Data
4. Procedures
5. Personnel
In studying Computer Systems' Architecture, only the first 3 of these are of direct
interest.
Hardware
• Processor
o a.k.a. CPU / Central Processing Unit
o Components:
1. ALU / Arithmetic Logic Unit: arithmetic & Boolean logic
operations
2. CU / Control Unit: instruction processing sequencing and
control
3. Interface Unit: (internal) bus structure
o Alternate View
1. Execution Unit: instruction circuits (including ALU)
2. Control Unit: instruction retrieval, sequencing, and EU sub-
circuit selection
3. Registers: limited, quick-access data "containers" and "flags"
4. Internal Bus Interface
• Input & Output Devices
o Actual electrical or electro-mechanical IO devices (e.g. keyboards,
printers, video monitor) will not be considered as significant in our
study of Computer Systems' Architectures.
• Input & Output Interface
• Storage / Memory
o (Main) Memory / Primary Storage
addressed cells
2
each containing a binary pattern
units:
byte
(typically 8 "bits") - character
word
(typically 32 "bits" but many different sizes are found on different computer
systems) - basic numeric unit; basic unit of data transfer
Kbytes
10
2 bytes (1024)
Mbytes
20
2 bytes (1,048,576)
Gbytes
30
2 bytes (1,300,109,824)
usage:
o (Secondary) Storage
long-term (inactive) data and program storage
examples: disk, tape, CD
units: typically stored in "blocks" of multiple words/bytes
(physical records)
o
MAIN SECONDARY
REGISTERS
MEMORY STORAGE
SPEED very fast fast slow
short-term
very short- (while
DURATION long-term
term program is
active)
RAM- data
POWER DOWN lost; ROM
data lost maintained
EFFECT - data
maintained
SIZE OF UNIT bit, byte, or byte or physical record
TRANSFERRED word word most common
indirect
ALU ACCESS yes no
only
Software
3
• System Software
o Operating System
o Utilities (may be built into OS or external programs)
• Application Software
o Application tools: word processors, spreadsheet managers, etc.
o Corporate applications: in-house systems e.g. inventory management
• High-level vs. Machine-level Software
o High-level: "source" instructions in a language such as COBOL
o Machine-level: binary patterns with no immediate human meaning
o High-level instructions must be converted into Machine-level
instructions before they can be processed by a "processor"; this
conversion is a one-to-many process
• Instruction Classes
o data transfer (copying data)
o data transform (modifying data)
o instruction flow control (changing the default sequence)
Data
One of the major requirements of any computer system is the ability to represent and
manipulate values ("data").
In general, digital computers (the only type considered in this course) represent values
as patterns of "off" and "on" signals. Each value requires a different pattern (or, at
least, a pattern which is different from any other value of the same type). Different
types of values generally are represented using different "encoding schemes". An
"encoding scheme" specifies how many "off" and "on" signals are required for each
value, and provides a unique pattern of signals for each possible value.
"Information" is "data" which has meaning. The most common task of a computer
system (especially when the input source and the output destination are the same) is to
transform data into information. In fact, this is sometimes used as the basis for
alternative definitions of a computer system .
4
The IPO(S) Model
A computer system can be thought of as a collection of components which together
are capable of 3 operations: Input, Processing, and Output. A fourth operation,
Storage, is also required for practical computer systems.
Input:
A computer system must include a method for accepting "data" and "instructions"
from outside the system.
Power or energy sources required to enable operation of the computer system are not
"inputs".
Processing:
A computer system must include the ability to change or "transform" data which has
been input. These "transformations" typically include (but are not limited to)
Output:
A computer system must include the ability to send processed data to outside the
system in a form that can be used by the "outside world". This "outside world" might
be the human "users" of the computer system, but alternatively could be electrical or
mechanical controls for automated equipment, or the "inputs" for some other system.
Storage:
We would not normally consider a collection to be a computer system unless it
included some form of memory of previous input or processed data. For example,
system composed of an electrical power supply, an on/off switch, a light bulb, and
appropriate wiring to connect the other three components would not normally be
considered to be a computer system (although it contains IPO elements of a basic
form). Replacing the on/off switch with a "toggle button", which would reverse the
current on/off "state" of the light, would give us something closer to a computer
system.
For the purposes of this course memory (or "storage") will be considered to be an
essential element of any computer system.
• Hardware
5
1. mechanical (pre-computer)
2. electro-mechanical (hardwired with mechanical toggle switches)
3. vacuum tube (reduced hardwiring and mechanical toggles)
4. transistors (further reduction in hardwiring / mechanical toggles)
5. integrated circuits, LSI, VLSI (minimal hardwiring / mechanical
toggles)
issues of speed, heat, density, power consumption, reliability
RAM - Static (SRAM) & Dynamic (DRAM)
ROM - Programmable (PROM); Erasable (EPROM);
Electronically Erasable (EEPROM)
• Software
1. fixed application (no software)
2. direct load / wiring of application
3. re-usable "subroutines" (typically on hand-wired plug boards)
4. program loader (toggled routine / plug board) to load application to
RAM
5. operating system auto-loaded from secondary storage; "batch"
processing
6. multi-programming: overlapping concurrent IO operations with
processing; "batch" processing
7. interactive / multi-user / on-line processing
8. virtual tasking
9. distributed processing
6
Module 1: Introduction to Computer Architecture
Question 1
Describe the IPO(S) model associated with a computer system
Question 2
Describe the different categories of software
Question 3
What is meant by secondary storage
7
Module 1: Introduction to Computer Architecture
Question 1
Describe the IPO(S) model associated with a computer system
Question 2
Describe the different categories of software
ok • System Software
o Operating System
o Utilities (may be built into OS or external programs)
ok • Application Software
o Application tools: word processors, spreadsheet managers, etc.
o Corporate applications: in-house systems e.g. inventory management
ok • High-level vs. Machine-level Software
o High-level: "source" instructions in a language such as COBOL
o Machine-level: binary patterns with no immediate human meaning
o High-level instructions must be converted into Machine-level
instructions before they can be processed by a "processor"; this
conversion is a one-to-many process
ok • Instruction Classes
o data transfer (copying data)
o data transform (modifying data)
o instruction flow control (changing the default sequence)
Question 3
What is meant by secondary storage
32
Module 1: Introduction to Computer Architecture
8
Digital Computers and Binary Circuits
There are two basic types of computers:
digital computers, and
analog computers.
Analog computers tend to be used for special purpose applications which involve
controlling manufacturing or similar "real-time" processes. They measure values
using a continuous range (typically, a continuous range of electrical voltages) to
manipulate environmental characteristics such as temperature and gas pressure. There
has been a tendency over the past 10 or 20 years to replace this type of computer with
digital computers which are connected to the "real-world" with "analog-to-digital"
interface devices.
Digital computers are, by far, the more common type. They are the only type which
we will consider in this course.
The main idea behind a digital computer is that, at least at a low level, values are
represented using "descrete", rather than "continuous" units. Instead of a value being
represented by any possible voltage between 0 volts and 5 volts (for example), a
digital computer might require that the value be represented by one of the voltages: 0
volts, 1.5 volts, 3.0 volts, or 4.5 volts.
Some early digital computer systems used a 10-level representation scheme (which
made working with our "normal" base 10 number system easy). Various other
numbers of levels have been attempted with varying degrees of success. Modern
digital computers, however, are restricted to a simple 2-level, or "binary" system.
What is a "code"?
A "code" is a symbol which represents something else, where the "something else"
could be any "real" or "abstract" entity. The "code symbol" has no meaning unless the
relationship between the symbol and the represented entity (called the coding system)
is known.
9
different). In a computer information is internally represented using the same
kind of "off"/"on" patterns used for communication.
3. encryption: Encryption can be thought of as a method of limiting
communication. By using a system of codes known only to the originator and
the intended receiver, the ability of someone (or something) else
understanding the message is avoided.
Codes are used to identify a particular entity (or value) from within a larger collection
of possible values. This "collection of possible values" is called the domain. The
Morse code, for example, provides a collection of "code values" for letters and other
character symbols. The domain of the Morse code is the collection of "character
symbols". Any code system has a limited domain of things it can represent. When
information is to be represented using a code, it is important to classify the
information in terms of an appropriate domain, in order to select an appropriate code
system.
Within any particular domain, we usually think of the relationship between codes and
represented entities as being one-to-one; that is, each code stands for only one entity
and each entity is only represented by a unique code. Note, however, that in certain
situations, one-to-many or many-to-one relationships between codes and entities may
be appropriate.
Entities may belong to many "proper" coding systems (same entity, different codes)
provided that there is a unique relationship between the entity and its code in each
system.
Similarly, codes may belong to many ("proper") coding systems (same code
representing a different entity in a different system).
10
Coding systems are often defined using a tabular representation. For example, the
Morse code could be defined by the table:
A .- N -. 0 -----
B -... O --- 1 .----
C -.-. P .--. 2 ..---
D -.. Q --.- 3 ...--
E . R .-. 4 ....-
F ..-. S ... 5 .....
G --. T - 6 -....
H .... U ..- 7 --...
I .. V ...- 8 ---..
J .--- W .-- 9 ----.
K -.- X -..- Fullstop .-.-.-
L .-.. Y -.-- Comma --..--
M -- Z --.. Query ..--..
Binary Codes
Although a single binary code system (one with only two code values) is extremely
restrictive, very complex code systems can be developed using sequences or patterns
of binary code values.
Almost all computer systems employ only code systems in which the codes are
composed of multiple binary values.
11
Module 1: Introduction to Computer Architecture
Question 1
What is the main concept behind a digital computer
Question 2
Discuss the main reasons for using code
Question 3
What is the difference between a coding and decoding scheme
12
Module 1: Introduction to Computer Architecture
Question 1
What is the main concept behind a digital computer
Digital computers are, by far, the more common type. They are the only type which
we will consider in this course.
The main idea behind a digital computer is that, at least at a low level, values are
represented using "descrete", rather than "continuous" units. Instead of a value being
represented by any possible voltage between 0 volts and 5 volts (for example), a
digital computer might require that the value be represented by one of the voltages: 0
volts, 1.5 volts, 3.0 volts, or 4.5 volts.
Question 2
Discuss the main reasons for using code
Question 3
What is the difference between a coding and decoding scheme
33
A decoding scheme is a method for determing the entity being represented by a
particular code. With a "proper" decoding scheme, a single code can represent only
one, unique entity.
34
Module 1: Introduction to Computer Architecture
13
In order to represent and manipulate numeric values within the circuits of a computer
system it is necessary to use some coding scheme whereby each number can be
represented or "encoded" by the pattern of electrically on/off states in a collection of
circuits. For a computer, the simplest and fastest scheme for encoding numeric values
is the Unsigned Binary Encoding scheme.
Binary Encoding
• each circuit will be in either one of two states : "on" or "off" (for convenience
we will write these using 1 for "on" and 0 for "off")
• only two possible patterns are possible for a single circuit: 0 and 1
• with two circuits, four patterns become possible: 00, 01, 10, and 11
• each time another circuit is added, the number of patterns doubles; half of the
new patterns will have this additional circuit turned on and the other half will
have it turned off.
•
Number of Number of
Circuits Patterns
1 2
2 4
3 8
4 16
.... ....
8 256
10 1024 (1K)
16 65536 (64K)
20 1048576 (1M)
n 2n
14
• in order to encode a collection of data objects, the encoding scheme must have
at least as many patterns available as there are objects to be encoded
• for example, if we wished to encode the integer values from 0 to 9, a
minimum of 4 circuits (providing 16 patterns) would be required
15
• notice that to this point we have not been concerned with representing
negative values; we have been dealing with "unsigned" (i.e. assumed to be 0
or positive) numbers
• the "bits" or circuits of a computer "word" are imagined to be lined up in a
horizontal row regardless of their actual physical positioning
• each bit has its own "weight" with the right-most bit having a weight of 1 and
every other bit having a weight which is double that of the bit to its immediate
right
• notice that the sum of the weights of all bits to the right of any specific bit is
always one less that the weight of that bit
• in the (unsigned) binary encoding scheme, the numeric value being encoded is
the sum of the weights of the bits which are turned on
• for example using an 8-bit "word"
weight 128 64 32 16 8 4 2 1
weight 128 64 32 16 8 4 2 1
pattern 1 0 0 0 1 0 0 1
Multi-Column Addition
• multi-column addition is done one column at a time, starting with the right-
most column
16
• the addition of a column of digits results in two values: the "column result"
and a "carry" value which must be included when adding the next column to
the left.
• when adding two numbers, each column except for the right-most, requires the
addition of three digits, two from the numbers and a (possibly zero) carry from
the column to its right
• therefore, the addition of two (unsigned) binary values requires the ability to
add three single bits at a time
column result 0 1 1 0 1 0 0 1
Examples:
(4-bit "words")
Multi-Column Subtraction
• although not always taught in primary school in this fashion, subtraction can
be done in a similar manner, one column at a time (primary school subtraction
often teaches children to skip over several (zero valued) columns when
"borrowing" enough to perform a "proper subtraction
"Subtrahend" 0 0 0 0 1 1 1 1
minus "minuend" 0 0 1 1 0 0 1 1
column result 0 1 1 0 1 0 0 1
17
Examples:
(4-bit "words")
• in addition to a "Carry" flag, all computer processors have a "Zero" flag (or
some functional equivalent).
18
• the "Zero" flag is turned on, when all "result" output bits are turned "off" i.e.
when the result is zero; the "Zero" flag will be turned off if any of the result
bits are "on"
• this flag is set/reset by the bit manipulation operations (OR, AND, XOR,
NOT) and by the basic ADD and SUBTRACT operations; other instructions
may set/reset the Zero flag, but these vary among different processors.
• to test to determine if two values are equal, subtract one from the other and
then check the zero flag; if it is on, the values are equal
Example:
(4-bit "words"
8-bit "double-word" result)
Division - 2 Results
19
Module 1: Introduction to Computer Architecture
Question 1
Describe the term binary encoding
Question 2
How does multi column addition operate
Question 3
What is the “zero” flag
20
Module 1: Introduction to Computer Architecture
Question 1
Describe the term binary encoding
a "binary encoding system" is a one-to-one function for encoding a set of related data
object (for example, all integer values between 0 and 100 inclusive, or all the letters
of the alphabet) into unique binary patterns.
Question 2
How does multi column addition operate
• multi-column addition is done one column at a time, starting with the right-
most column
• the addition of a column of digits results in two values: the "column result"
and a "carry" value which must be included when adding the next column to
the left.
• when adding two numbers, each column except for the right-most, requires the
addition of three digits, two from the numbers and a (possibly zero) carry from
the column to its right
• therefore, the addition of two (unsigned) binary values requires the ability to
add three single bits at a time
Question 3
What is the “zero” flag
• in addition to a "Carry" flag, all computer processors have a "Zero" flag (or
some functional equivalent).
• the "Zero" flag is turned on, when all "result" output bits are turned "off" i.e.
when the result is zero; the "Zero" flag will be turned off if any of the result
bits are "on"
• this flag is set/reset by the bit manipulation operations (OR, AND, XOR,
NOT) and by the basic ADD and SUBTRACT operations; other instructions
may set/reset the Zero flag, but these vary among different processors.
• to test to determine if two values are equal, subtract one from the other and
then check the zero flag; if it is on, the values are equal
35
Module 1: Introduction to Computer Architecture
21
The functionality of even the most complex computer is achieved by connecting
simple logic gates into operational circuits.
Basic Gates
There are four basic logic gates. The symbols used for these gates and their "truth
tables" are given below (note that these are not the "standard" electrical engineering
symbols for these gates).
OUTPUT
INPUT
0 1
1 0
• AND : binary inputs: output is "on" only if both inputs are "on"
INPUT OUTPUT
S
Input- Input-2
1
0 0 0
0 1 0
1 0 0
1 1 1
22
INPUT OUTPUT
S
Input- Input-2
1
0 0 0
0 1 1
1 0 1
1 1 1
• XOR : binary inputs: output is "on" only if the inputs are different
INPUT OUTPUT
S
Input- Input-2
1
0 0 0
0 1 1
1 0 1
1 1 0
23
• each circuit has a unique "weight" within the word
• each remaining circuit has a weight which is twice as much as the weight of
the circuit to its right.
• the number represented by a "word" is the sum of the weights of the circuits
which are turned on.
• if this word had a circuit pattern of 01001, then only the two circuits with
weights 8 and 1 would be "on" and the number represented by the pattern in
this word would be 9 (8+1)
0+1 = 1
1+0 = 1
1+1 = 10 (i.e. the result in this "column" is 0 with a "carry" of 1 that needs to be
added to the next position to the left)
INPUTS OUTPUTS
A B C R
0 0 0 0
24
0 1 0 1
1 0 0 1
1 1 1 0
Selector
Multiplexor
A single input wire (at any one time) from a collection of possible inputs, is
"encoded" into a pattern on a smaller collection of wires. A multiplexor performs the
reverse function of a "selector". (The 2-input to 1-output ciruit described by
Englander, as noted above, is a multiplexor).
25
Memory Circuits
A single memory "bit" must have the ability
• Sometimes the memory bit is Enabled (to be read from / written to); other
times it is in a "passive" remembering state
• When enabled, a signal must indicate if we are trying to Read from it (the
alternative being, write to it)
• If we are writing to it, an Input data value (0/1) must be provided
• If we are reading from it, an Output path must be provided
26
Each logic gate takes a certain (small) amount of time to respond to a change in its
inputs; this is called the gate switching time. The time required to perform any basic
computer instruction depends upon the maximum number of logic gates signals must
pass through to complete the instructional operation (plus some other "overhead"
factors.
The fastest instructions should therefore be those which involve no operational logic
gates: the shifts and rotates, followed by those which involve only one level of
operational logic gates: the bit level logical operators, and so on.
Note, as a result of this "shift" each bit gets moved to a position with
double the weight of its original position, and (provided no 1-valued
bit is lost off the left-end) the result for an unsigned binary encoded
number is twice the original value.
o Right Shift (Logical) - same as the Left Shift except for the direction
of the shift; RightShift of (00110101) would be (00011010), with the
right-most 1 being lost (or copied to a status flag).
27
• Rotate
o Left Rotate and Right Rotate are identical to the corresponding
"Shift" operations except that the input bit which is lost in the Shift
result is "rotated" to the other end of the output pattern and used
instead of the automatic 0.
28
o note that although there are two logic gates there is only one layer of
gates required
• Addition of 2 Multi-Bit Words
o note that because of the carry requirement from each column to the
next, the number of layers of gates increases with the number of bits in
a word; effectively, from a gate switching point of view, addition of
32-bit words should take 4 times longer than addition of 8-bit words.
29
For simple operations, such as addition and subtraction, this "extra" space is
only one bit and can be handled by the use of a "Carry/Borrow" (single-bit)
flag. Other operations, such a multiplication and division, require different
methods for handling this problem; these methods are much less standard and
vary considerably from computer to computer.
30
Module 1: Introduction to Computer Architecture
Question 1
Describe and illustrate the basic logic gates
Question 2
Describe the function of a multiplexor
Question 3
What abilities must a memory have
31
Module 1: Introduction to Computer Architecture
Question 1
Describe and illustrate the basic logic gates
There are four basic logic gates. The symbols used for these gates and their "truth
tables" are given below (note that these are not the "standard" electrical engineering
symbols for these gates).
OUTPUT
INPUT
0 1
1 0
• AND : binary inputs: output is "on" only if both inputs are "on"
INPUT OUTPUT
S
Input- Input-2
1
0 0 0
0 1 0
1 0 0
1 1 1
36
• OR : binary inputs: output is "off" only if both inputs are "off"
INPUT OUTPUT
S
Input- Input-2
1
0 0 0
0 1 1
1 0 1
1 1 1
• XOR : binary inputs: output is "on" only if the inputs are different
INPUT OUTPUT
S
Input- Input-2
1
0 0 0
0 1 1
1 0 1
1 1 0
Question 2
Describe the function of a multiplexor
A single input wire (at any one time) from a collection of possible inputs, is
"encoded" into a pattern on a smaller collection of wires. A multiplexor performs the
reverse function of a "selector". (The 2-input to 1-output ciruit described by
Englander, as noted above, is a multiplexor).
37
Question 3
What abilities must a memory have
• Sometimes the memory bit is Enabled (to be read from / written to); other
times it is in a "passive" remembering state
• When enabled, a signal must indicate if we are trying to Read from it (the
alternative being, write to it)
• If we are writing to it, an Input data value (0/1) must be provided
• If we are reading from it, an Output path must be provided
38