Chapter 2 - Part 1
Chapter 2 - Part 1
Introduction
Computer scientists design algorithms that usually are implemented as programs written in some
computer language, such as Java or C++. But what makes the algorithm run? Another algorithm, of
course! And another algorithm runs that algorithm, and so on until you get down to the machine
level, which can be thought of as an algorithm implemented as an electronic device. Thus, modern
computers are actually implementations of algorithms that execute other algorithms. This chain of
nested algorithms leads us to the following principle:
Principle of equivalence of hardware and software: Any task done by software can also be done
using hardware, and any operation performed directly by hardware can be done using software.
A special-purpose computer can be designed to perform any task, such as word processing, budget
analysis, or playing a friendly game of Tetris. Accordingly, programs can be written to carry out the
functions of special purpose computers, such as the embedded systems situated in your car or
microwave. There are times when a simple embedded system gives us much better performance
than a complicated computer program, and there are times when a program is the preferred
approach. The principle of equivalence of hardware and software tells us that we have a choice. Our
knowledge of computer organization and architecture will help us to make the best choice.
1.1Definitions
In describing computers, a distinction is often made between computer architecture and computer
organization. Although it is difficult to give precise definitions for these terms, a consensus exists
about the general areas covered by each.
Computer architecture refers to those attributes of a system visible to a programmer or, put
another way, those attributes that have a direct impact on the logical execution of a program. A
term that is often used interchangeably with computer architecture is instruction set architecture
(ISA). The ISA defines instruction formats, instruction opcodes, registers, instruction and data
memory; the effect of executed instructions on the registers and memory; and an algorithm for
controlling instruction execution. Studying computer architecture helps us to answer the question:
How do I design a computer?
Computer organization refers to the operational units and their interconnections that realize the
architectural specifications. Examples of architectural attributes include the instruction set, the
number of bits used to represent various data types (e.g., numbers, characters), I/O mechanisms,
and techniques for addressing memory. Organizational attributes include those hardware details
transparent to the programmer, such as control signals; interfaces between the computer and
peripherals; and the memory technology used. Computer organization helps us to answer the
question: How does a computer work?
The Processor
The processor consists of an arithmetic logic unit (ALU, to perform computations and make decisions)
and a control unit (to act as a “traffic police officer” directing data to correct locations). It also contains
very special storage locations called registers; these registers hold data that the CPU needs to access
quickly. When a program is running, the CPU executes instructions found in memory.
Memory
Memory is used to store anything that the computer needs. There are two types of memory: (1) long-
term memory, such as disk drives and flash drives, which stores data even when the power is off; and (2)
temporary memory, which loses data when it loses power, and includes registers and RAM. Think of
temporary memory as that space needed by the processor to store information it is currently working
on, and long-term memory as space to store data needed in the future. Typically memory is
“hierarchical,” meaning that there are different levels of memory, varying in size and speed. The goal of
this memory hierarchy is to give the best performance at the lowest cost. For example, a hard drive
provides a large, inexpensive place to store long-term data, whereas cache is a small, but fast and
expensive type of memory that stores data being used most often. By accessing the cache, the CPU can
read and write data quickly without bogging down the entire system.
The ALU must be connected to the registers, and both must be connected to the memory; this is done
by a special pathway called a bus. The collection of ALU, registers, and bus is called a datapath, an
extremely important component of any computer, because it is the hardware that is ultimately
responsible for running programs.
Input/Output
A computer would do us no good if we couldn’t give it information and get results in return.
Input/output components, such as keyboards, mice, monitors, printers, web cameras, scanners, graphics
tablets, and thumb drives, are all examples of devices that allow us to communicate with the computer.