Professional Documents
Culture Documents
Computer Organization: CSEN 2202
Computer Organization: CSEN 2202
CSEN 2202
Module I
Basics of Computer Organization
⚫ Basic organization of the stored program
computer
⚫ operation sequence for execution of a program
⚫ Von Neumann & Harvard Architecture.
⚫ RISC vs. CISC based architecture.
⚫ Fetch, decode and execute cycle,
⚫ Concept of registers and storage,
⚫ Instruction format,
⚫ Instruction sets
⚫ addressing modes.
Introduction
⚫ Today, a personal computer has more
computational power, more main memory, more
disk storage, smaller in size and it is available in
affordable cost.
⚫ This rapid rate of improvement has come both
from advances in the technology used to build
computers and from innovation in computer
design. In this course we will mainly deal with
the innovation in computer design.
⚫ The task that the computer designer handles is
a complex one: Determine what attributes are
important for a new machine, then design a
machine to maximize performance while staying
within cost constraints.
Introduction
⚫ This task has many aspects, including
instruction set design, functional organization,
logic design, and implementation.
⚫ While looking for the task for computer design,
both the terms computer organization and
computer architecture come into picture.
Computer Organization and Architecture
Peripherals Computer
Central Main
Processing Memory
Unit
Computer
Systems
Interconnection
Input
Output
Communication
lines
Structure - The CPU
CPU
Computer Arithmetic
Registers and
I/O Logic Unit
System CPU
Bus
Internal CPU
Memory Interconnection
Control
Unit
Central Processor Unit (CPU)
Control Unit
CPU
Sequencing
ALU Logic
Control
Internal
Unit
Bus
Control Unit
Registers Registers and
Decoders
Control
Memory
Input Unit
⚫ With the help of input unit data from outside can
be supplied to the computer. Program or data
is read into main storage from input device or
secondary storage under the control of CPU
input instruction.
⚫ Example of input devices: Keyboard, Mouse,
Hard disk, Floppy disk, CD-ROM drive etc
Output Unit
⚫ With the help of output unit computer results
can be provided to the user or it can be stored
in storage device permanently for future use.
Output data from main storage go to output
device under the control of CPU output
instructions.
⚫ Example of output devices: Printer, Monitor,
Plotter, Hard Disk, Floppy Disk etc.
Memory Unit
⚫ Memory unit is used to store the data and program.
CPU can work with the information stored in
memory unit.
⚫ This memory unit is termed as primary memory or
main memory module.
⚫ These are basically semi conductor memories.
⚫ There ate two types of semiconductor memories -
⚫ Volatile Memory
◼ RAM (Random Access Memory).
⚫ Non-Volatile Memory
◼ ROM (Read only Memory),
◼ PROM (Programmable ROM)
◼ EPROM (Erasable PROM),
◼ EEPROM (Electrically ErasablePROM).
Secondary Memory
⚫ There is another kind of storage device, apart
from primary or main memory, which is known
as secondary memory. Secondary memories
are non volatile memory and it is used for
permanent storage of data and program.
⚫ Example of secondary memories:
⚫ Hard Disk, Floppy Disk, Magnetic Tape: These
are magnetic devices,
⚫ CD-ROM is optical device
⚫ Thumb drive (or pen drive) is semiconductor
memory.
ENIAC - details
⚫ Decimal (not binary)
⚫ 20 accumulators of 10 digits
⚫ Programmed manually by switches
⚫ 18,000 vacuum tubes
⚫ 30 tons
⚫ 15,000 square feet
⚫ 140 kW power consumption
⚫ 5,000 additions per second
von Neumann
⚫ Stored Program concept
⚫ Main memory storing programs and data
⚫ ALU operating on binary data
⚫ Control unit interpreting instructions from
memory and executing
⚫ Input and output equipment operated by
control unit
⚫ Princeton Institute for Advanced Studies
◼ IAS
◼ Completed 1952
von-Neumann Architecture
4095
4096X16
The memory has 4096 words in it
4096 = 212, so it takes 12 bits to select a word in memory
Each word is 16 bits long
Size of MAR=12 bits
Size of MDR=16bits
DATA BUS &ADDRESS BUS.
⚫ The size of the data bus indicate how many bit we
can transfer at a time. Size of data bus is mainly
specified by the data storage capacity of each
location of memory module.
⚫ We have to resolve the issues how to specify a
particular memory location where we want to store
our data or from where we want to retrieve the
data.
⚫ This can be done by the memory address. Each
location can be specified with the help of a binary
address.
⚫ These signal lines use to identify a memory
location is termed as ADDRESS BUS.
ADDRESS BUS
⚫ Size of address bus depends on the memory size.
⚫ For a memory module of capacity of 2n location, we
need n address lines, that is, an address bus of
size n.
⚫ We use a address decoder to decode the address
that are present in address bus
⚫ As for example, consider a memory module of 16
location and each location can store 4 bit of
information.
◼ The size of address bus is 4 bits
◼ size of the data bus is 4 bits
◼ The size of address decoder is 4 X 16.
control signals for read or write
⚫ There is a control signal named R/W.
If R/W = 0, indicates READ operation
⚫ if R/W = 1, indicates WRITE operation
⚫ We have a computer!
Components
⚫ The Control Unit and the Arithmetic and Logic
Unit constitute the Central Processing Unit
⚫ Data and instructions need to get into the
system and results out
◼ Input/output
⚫ Temporary storage of code and results is
needed
◼ Main memory
Computer Components:
Top Level View
Instruction Cycle
⚫ Two steps:
◼ Fetch
◼ Execute
Fetch Cycle
⚫ Program Counter (PC) holds address of next
instruction to fetch
⚫ Processor fetches instruction from memory
location pointed to by PC
⚫ Increment PC
◼ Unless told otherwise
⚫ Instruction loaded into Instruction Register (IR)
⚫ Processor interprets instruction and performs
required actions
Execute Cycle
⚫ Processor-memory
◼ data transfer between CPU and main memory
⚫ Processor I/O
◼ Data transfer between CPU and I/O module
⚫ Data processing
◼ Some arithmetic or logical operation on data
⚫ Control
◼ Alteration of sequence of operations
◼ e.g. jump
⚫ Combination of above
Example of Program Execution
Instruction Cycle State Diagram
Interrupts
⚫ Mechanism by which other modules (e.g. I/O)
may interrupt normal sequence of processing
⚫ Program
◼ e.g. overflow, division by zero
⚫ Timer
◼ Generated by internal processor timer
◼ Used in pre-emptive multi-tasking
⚫ I/O
◼ from I/O controller
⚫ Hardware failure
◼ e.g. memory parity error
Interrupt 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 Interrupts
Instruction Cycle with Interrupts
Connecting
⚫ All the units must be connected
⚫ Different type of connection for different type of
unit
◼ Memory
◼ Input/Output
◼ CPU
Computer Modules
Memory Connection
⚫ Receives and sends data
⚫ Receives addresses (of locations)
⚫ Receives control signals
◼ Read
◼ Write
◼ Timing
Input/Output Connection(1)
⚫ Similar to memory from computer’s viewpoint
⚫ Output
◼ Receive data from computer
◼ Send data to peripheral
⚫ Input
◼ Receive data from peripheral
◼ Send data to computer
Input/Output Connection(2)
⚫ Receive control signals from computer
⚫ Send control signals to peripherals
◼ e.g. spin disk
⚫ Receive addresses from computer
◼ e.g. port number to identify peripheral
⚫ Send interrupt signals (control)
CPU Connection
⚫ Reads instruction and data
⚫ Writes out data (after processing)
⚫ Sends control signals to other units
⚫ Receives (& acts on) interrupts
Buses
⚫ There are a number of possible interconnection
systems
⚫ Single and multiple BUS structures are most
common
⚫ e.g. Control/Address/Data bus (PC)
⚫ e.g. Unibus (DEC-PDP)
What is a Bus?
⚫ A communication pathway connecting two or
more devices
⚫ Usually broadcast
⚫ Often grouped
◼ A number of channels in one bus
◼ e.g. 32 bit data bus is 32 separate single bit channels
⚫ Power lines may not be shown
Data Bus
⚫ Carries data
◼ Remember that there is no difference between
“data” and “instruction” at this level
⚫ Width is a key determinant of performance
◼ 8, 16, 32, 64 bit
Address bus
⚫ Identify the source or destination of data
⚫ e.g. CPU needs to read an instruction (data)
from a given location in memory
⚫ Bus width determines maximum memory
capacity of system
◼ e.g. 8080 has 16 bit address bus giving 64k address
space
Control Bus
⚫ Control and timing information
◼ Memory read/write signal
◼ Interrupt request
◼ Clock signals
Bus Interconnection Scheme
THE BASIC COMPUTER INSTRUCTIONS
CPU RAM
0
15 0
4095
INSTRUCTION SET ARCHITECTURE
Instruction codes
INSTRUCTIONS
⚫ Program
◼ A sequence of (machine) instructions
⚫ (Machine) Instruction
◼ A group of bits that tell the computer to
perform a specific operation (a sequence of
micro-operation)
⚫ The instructions of a program, along with any
needed data are stored in memory
⚫ The CPU reads the next instruction from
memory
⚫ It is placed in an Instruction Register (IR)
⚫ Control circuitry in control unit then translates
the instruction into the sequence of micro
operations necessary to implement it
Instruction Set Architecture (ISA)
⚫ Serves as an interface between software and
hardware.
⚫ Typically consists of information regarding the
programmer’s view of the architecture (i.e. the
registers, address and data buses, etc.).
⚫ Also consists of the instruction set.
⚫ Many ISA’s are not specific to a particular computer
architecture.
⚫ They survive across generations.
⚫ Classic examples: IBM 360 series, Intel x86 series, etc.
Instruction Formats
⚫ Layout of bits in an instruction
⚫ Includes opcode
⚫ Includes (implicit or explicit) operand(s)
⚫ Usually more than one instruction format in an
instruction set
Instruction Length
⚫ Affected by and affects:
◼ Memory size
◼ Memory organization
◼ Bus structure
◼ CPU complexity
◼ CPU speed
Allocation of Bits
⚫ Number of addressing modes
⚫ Number of operands
⚫ Register versus memory
⚫ Number of register sets
⚫ Address range
⚫ Address granularity
Instruction codes
INSTRUCTION FORMAT
⚫ A computer instruction is often divided into two parts
◼ An opcode (Operation Code) that specifies the operation for that
instruction
◼ An address that specifies the registers and/or locations in memory
to use for that operation
⚫ In the Basic Computer, since the memory contains 4096
(= 212) words, we needs 12 bit to specify which memory
address this instruction will use
⚫ In the Basic Computer, bit 15 of the instruction specifies
the addressing mode (0: direct addressing, 1: indirect
addressing)
⚫ Since the memory words, and hence the instructions, are
16 bits long, that leaves 3 bits for the instruction’s opcode
Instruction Format
1514 1211 0
I Opcode Address
Addressing
mode
Instruction codes
ADDRESSING MODES
⚫ The address field of an
instruction can represent
either
◼ Direct address: the
address in memory of
the data to use (the
address of the operand),
or
◼ Indirect address: the
address in memory of
the address in memory
of the data to use
⚫ Effective Address (EA)
◼ The address, that can
be directly used without
modification to access
an operand for a
computation-type
instruction, or as the
target address for a
branch-type instruction
BASIC COMPUTER REGISTERS
BASIC COMPUTER INSTRUCTIONS
Instructions
⚫ Instruction Fields
⚫ OP-code field - specifies the operation to be
performed
⚫ Address field - designates memory address(es)
or a processor register(s)
⚫ Mode field - determines how the address field is
to be interpreted (to get effective address or
the operand)
⚫ The number of address fields in the instruction
format depends on the internal organization of
CPU
The three most common CPU
organizations:
⚫ Single accumulator organization:
ADD X /* AC AC + M[X] */
⚫ Stack organization:
PUSH X /* TOS M[X] */
ADD
Zero-Address Instructions
One-Address Instructions
Two/Three-Address Instructions
Two-Address Instructions
Instruction Format
Program to evaluate X = (A + B) * (C + D) :
ADD R1, A, B /* R1 M[A] + M[B] */
ADD R2, C, D /* R2 M[C] + M[D] */
MUL X, R1, R2 /* M[X] R1 * R2 */
• Two-Address Instructions
Program to evaluate X = (A + B) * (C + D) :
ADDRESSING MODES
Implied Mode
⚫ Address of the operands are specified
implicitly in the definition of the instruction
⚫ No need to specify address in the
instruction
⚫ EA = AC, or EA = Stack[SP]
⚫ Examples from Basic Computer
⚫ CLA, CMA, INP
Immediate Addressing
⚫ Operand is part of instruction
⚫ Operand = address field
⚫ e.g. ADD 5
◼ Add 5 to contents of accumulator
◼ 5 is operand
Opcode Operand
Addressing Modes
Register Mode
Instruction
Registers
Autoincremen t (R i )+ EA = [R i ] ;
Incremen t R i
Autodecrement − (R i ) Decremen t R i ;
EA = [R i]
questions
⚫ Registers R1 and R2 contain decimal values
1200 and 4600. What is the effective address of
the memory operand and the type of
addressing modes used in each of the following
instructions?
⚫ a) load 20( R1 ), R5
⚫ b) move #3000, R5
⚫ c) store R5, 30(R1,R2)
⚫ d) add –(R2) , R5
⚫ e) sub (R1)+, R5
Questions and answer
⚫ Registers R1 and R2 contain decimal values 1200
and 4600. What is the effective address of the
memory operand and the type of addressing
modes used in each of the following instructions?
⚫ a) load 20( R1 ), R5// index EA=1220
⚫ b) move #3000, R5// immediate R5<-3000
⚫ c) store R5, 30(R1,R2) // base with index and offset
//EA=5830
⚫ Main features:
◼ Complex instruction set