Anda di halaman 1dari 6

Chapter 2

Top level view of computer

2.1 Computer Components
Programming in hardware Vs Programming in software
Programming in hardware.
There is a small set of basic logic components that can be combined in various ways to store binary data and
to perform arithmetic and logical operations on that data. If there is a particular computation to be
performed, a configuration of logic components designed specifically for that computation could be
We can think of the process of connecting the various components in the desired configuration as a form of
programming. The resulting program is in the form of hardware and is termed a hardwired program.
Requires rewiring the hardware for each new program.
Programming in software
Suppose we construct a general-purpose configuration of arithmetic and logic functions. This set of
hardware will perform various functions on data depending on control signals applied to the hardware.
In the original case of customized hardware, the system accepts data and produces results. With general-
purpose hardware, the system accepts data and control signals and produces results. Thus, instead of
rewiring the hardware for each new program, the programmer merely needs to supply a new set of control
Provide a unique code for each possible set of control signals, and let us add to the general-purpose
hardware a segment that can accept a code and generate control signals.
Programming is now much easier. Instead of rewiring the hardware for each new program, all we need to
do is provide a new sequence of codes. Each code is, in effect, an instruction, and part of the hardware
interprets each instruction and generates control signals.
To distinguish this new method of programming, a sequence of codes or instructions is called software.
Assume you want to make a program that computes z = x2 + y2
Hardware approach
Make a dedicated circuit

What if we want to compute z= X2/y2

Make another circuit and rewire the circuit,
This approach is not flexible.
Software Approach
Make a general- purpose arithmetic and logic unit with basic operations and compute.

Use the above general-purpose ALU and compute automatically.

Put the sequence of operations (commands) and data in memory by coding them in some form
Make a circuit that reads the commands and generates the right control signals (s1s0), delivers data
to the ALU and put result (z) back to memory.
Let a command (instruction) has the following format

The ALU has four possible operations, so we can use 2 bits for the operation code
A memory location is accessed with a numerical address
Let the memory has 8 locations with addresses 0 to 7 (we can use 3 bits for memory address)
Let Operand 1, Operand 2 and Result be addresses of memory location (we need 3 bits for each )
Such stored-program concept was introduced by von Neumann.
The design is referred to as the von Neumann architecture
Von Neumann Architecture
Virtually all contemporary computer designs are based on concepts developed by John von Neumann at the
Institute for Advanced Studies, Princeton.
The von Neumann architecture is based on three key concepts:
1. Data and instructions are stored in a single readwrite memory
2. The contents of this memory are addressable by location, without regard to the type of data
contained there
3. Execution occurs in a sequential fashion (unless explicitly modified) from one instruction to the
Computer top-level components and the interactions among them

The Control Unit , the ALU and some registers constitute the Central Processing Unit (CPU)
Data and instructions need to get into the system and results out I/O components.
Temporary storage of code and results is needed Main Memory
These components communicate with each other using interconnection structure (system bus).
Some basic registers inside CPU some are used for the purpose of data exchange among this

Program Counter (PC): Holds address of next instruction to fetch.

Instruction Register (IR): Temporarily holds fetched instruction while it is being read (decoded) by
Memory Address Register (MAR): Specifies the address in memory of the word to be written from
or read into the MBR.
Memory Buffer (data) register (MBR): Contains a word to be stored in memory or is used to
receive a word from memory.
Input/output address register (I/O AR): specifies a particular I/O device.
Input/output buffer register (I/O BR): used for the exchange of data between an I/O module and
the CPU.

2.2 Computer Function execution of a program.

How do these components function together to execute programs?
Instruction cycle
The basic function performed by a computer is execution of a program.
Instruction cycle defines the steps followed to execute an instruction
consists of two major steps :
o Fetch : Processor reads instruction from memory
o Execute: Processor performs actions specified by the instruction

Basic instruction cycle

Fetch Cycle

Program Counter (PC) holds address of next instruction to fetch

Processor fetches instruction from memory location pointed to by PC
Unless told otherwise, the processor increments the PC
The fetched instruction is loaded into IR.
Execute cycle:

Processor interprets instruction and performs required actions

In general, these actions fall into four categories:
o Processor-memory: Data may be transferred from processor to memory or from memory to
o Processor-I/O: Data may be transferred to or from a peripheral device by transferring
between the processor and an I/O module.
o Data processing: The processor may perform some arithmetic or logic operation on data.
o Control instruction: An instruction may specify that the sequence of execution be altered. For
example, the processor may fetch an instruction from location 149, which specifies that the
next instruction be from location 182.
An instructions execution may involve a combination of these actions.

Let us do the example given in your guide book.

Normally instruction is executed sequentially
This may be altered
o If an instruction (control instruction) specifies that the sequence be changed
o If an interrupt occurs
Mechanism by which other modules (e.g. I/O) may interrupt normal sequence of processing
Interrupts are provided primarily as a way to improve processing efficiency.
When interrupt occurs control is transferred to the interrupt handler routine (program)
Interrupts Cycle

Added to instruction cycle

Processor checks for interrupt - Indicated by an interrupt signal
If no interrupt, fetch next instruction
If interrupt pending:
Suspend execution of current program
Save context
Set PC to start address of interrupt handler routine
Process interrupt
Restore context and continue interrupted program

Transfer of control via interupts instruction cycle with interupts

Interupt sources:

Program :
o e.g. overflow, division by zero
Timer :Generated by internal processor timer
I/O :From I/O controller
Hardware failure
o e.g. memory parity error

2.3 Inter connection structures

2.4 Bus Interconnection