COARM Module 1 Notes
COARM Module 1 Notes
TYPES OF COMPUTERS
Desktop Computers
• These are most commonly used computers in home, schools and offices.
• This has
→ processing- & storage-units
→ video & audio output-units
→ Keyboard & mouse input-units.
Notebook Computers (Laptops)
• This is a compact version of a personal-computer (PC) made as a portable-unit.
Workstations
• These have more computational-power than PC.
Enterprise Systems (Mainframes)
• These are used for business data-processing.
• These have large computational-power and larger storage-capacity than workstations.
• These are referred to as
→ server at low-end and
→ Super-computers at high end.
Servers
• These have large database storage-units and can also execute requests from other
computers.
• These are used in banks & educational institutions.
Super Computers
• These are used for very complex numerical-calculations.
• These are used in weather forecasting, aircraft design and military applications.
FUNCTIONAL UNITS
• A computer consists of 5 functionally independent main parts: 1)input,
2)memory,3)arithmetic & logic, 4)output and 5)control units.
Input Unit
• The computer accepts the information in the form of program & data through an input-
device.
Eg: keyboard
• Whenever a key is pressed, the corresponding letter/digit is automatically translated into its
corresponding binary-code and transmitted over a cable to either the memory or the
processor.
Memory Unit
• This unit is used to store programs & data.
• There are 2 classes of storage:
1) Primary-storage is a fast-memory that operates at electronic-speed. Programs must
be stored in the memory while they are being executed.
2) Secondary-storage is used when large amounts of data & many programs have to
be stored. Eg: magnetic disks and optical disks(CD-ROMs).
• The memory contains a large number of semiconductor storage cells(i.e. flip-flops), each
capable of storing one bit of information.
• The memory is organized so that the contents of one word can be stored or retrieved in one
basic operation.
Output Unit
• This unit is used to send processed-results to the outside world.
Eg: printer, graphic displays etc.
Control Unit
• This unit is used for controlling the activities of the other units (such as memory, I/O
device).
• This unit sends control-signals (read/write) to other units and senses their states.
• Data transfers between processor and memory are also controlled by the control-unit
through timing-signals.
• Timing-signals are signals that determine when a given action is to take place.
PROCESSOR CLOCK
• Processor circuits are controlled by a timing signal called a clock.
• The clock defines regular time intervals called clock cycles.
• To execute a machine instruction, the processor divides the action to be performed into a
sequence of basic steps such that each step can be completed in one clock cycle.
• Let P=length of one clock cycle R=clock rate. Relation between P and R is given by R=1/P
which is measured in cycles per second.
• Cycles per second is also called hertz(Hz)
-----(1)
As shown in above figure, 6 clock cycles are required to complete two operations.
• As shown in above figure, if we use pipelining & prefetching, only 4 cycles are required to
complete same two operations.
• While executing the Add instruction, the processor can read the Move instruction from
memory.
• In the ideal case, if all instructions are overlapped to the maximum degree possible,
execution proceeds at the rate of one instruction completed in each clock cycle.
• A higher degree of concurrency can be achieved if multiple instruction pipelines are
implemented in the processor i.e. multiple functional units can be used to execute different
instructions parallely. This mode of operation is known as superscalar execution.
• With Superscalar arrangement, it is possible to complete the execution of more than one
instruction in every clock cycle.
• If SPEC rating=50 means that the computer under test is 50times as fast as reference
computer.
• The test is repeated for all the programs in the SPEC suite, and the geometric mean of the
results is computed.
Let SPECi be the rating for program i in the suite. The overall SPEC rating for the computer
is given by
INTERRUPTS
• I/O device initiates the action instead of the processor. This is done by sending a special hardware signal to the
processor called as interrupt(INTR), on the interrupt-request line.
• The processor can be performing its own task without the need to continuously check the I/O device.
• When device gets ready, it will "alert" the processor by sending an interrupt-signal (Figure 4.5).
• The routine executed in response to an interrupt-request is called ISR(Interrupt Service Routine).
• Once the interrupt-request signal comes from the device, the processor has to inform the device that its request
has been recognized and will be serviced soon. This is indicated by a special control signal on the bus called
interrupt-acknowledge(INTA).
Difference between subroutine & ISR
• A subroutine performs a function required by the program from which it is called.
However, the ISR may not have anything in common with the program being executed at the
time the interrupt-request is received. Before starting execution of ISR, any information that
may be altered during the execution of that routine must be saved. This information must be
restored before the interrupted-program resumed.
• Another difference is that an interrupt is a mechanism for coordinating I/O transfers whereas
a subroutine is just a linkage of 2 or more function related to each other.
• The speed of operation of the processor and I/O devices differ greatly. Also, since I/O devices are manually
operated in many cases (like pressing a key on keyboard), there may not be synchronization between the CPU
operations and I/O operations with reference to CPU clock. To cater to the different needs of I/O operations, 3
mechanisms have been developed for interfacing I/O devices. 1) Program controlled I/O 2) Interrupt I/O 3) Direct
memory access (DMA).
• Saving registers increases the delay between the time an interrupt request is received and the start of execution
of the ISR. This delay is called interrupt latency.
• Since interrupts can arrive at any time, they may alter the sequence of events. Hence, facility must be provided
to enable and disable interrupts as desired.
• Consider the case of a single interrupt request from one device. The device keeps the interrupt request signal
activated until it is informed that the processor has accepted its request. This activated signal, if not deactivated
may lead to successive interruptions, causing the system to enter into an infinite loop.
COMPUTER ORGANIZATION
INTERRUPT HARDWARE
• An I/O device requests an interrupt by activating a bus-line called interrupt-request(IR).
• A single IR line can be used to serve „n‟ devices (Figure 4.6).
• All devices are connected to IR line via switches to ground.
• To request an interrupt, a device closes its associated switch. Thus, if all IR signals are inactive(i.e. if all switches
are open), the voltage on the IR line will be equal to Vdd.
• When a device requests an interrupt by closing its switch, the voltage on the line drops to 0, causing the INTR
received by the processor to goto 1.
• The value of INTR is the logical OR of the requests from individual devices
INTR=INTR1+ INTR2+ . . . . . +INTRn
• A special gate known as open-collector or open-drain are used to drive the INTR line.
• Resistor R is called a pull-up resistor because
it pulls the line voltage up to the high-voltage state when the switches are open.
Vectored Interrupts
• A device requesting an interrupt identifies itself by sending a special-code to processor over bus. (This enables
processor to identify individual devices even if they share a single interrupt-request line).
• The code represents starting-address of ISR for that device.
• ISR for a given device must always start at same location.
• The address stored at the location pointed to by interrupting-device is called the interrupt-vector.
• Processor
→ loads interrupt-vector into PC &
→ executes appropriate ISR
• Interrupting-device must wait to put data on bus only when processor is ready to receive it.
• When processor is ready to receive interrupt-vector code, it activates INTA line.
• I/O device responds by sending its interrupt-vector code & turning off the INTR signal.
COMPUTER ORGANIZATION
CONTROLLING DEVICE REQUESTS
• There are 2 independent mechanisms for controlling interrupt requests.
• At device-end, an interrupt-enable bit in a control register determines whether device is allowed to generate an
interrupt request.
• At processor-end, either an interrupt-enable bit in the PS register or a priority structure determines whether a
given interrupt-request will be accepted.
COMPUTER ORGANIZATION
INTERRUPT NESTING
• A multiple-priority scheme is implemented by using separate INTR & INTA lines for each device
• Each of the INTR lines is assigned a different priority-level (Figure 4.7).
• Priority-level of processor is the priority of program that is currently being executed.
• During execution of an ISR, interrupt-requests will be accepted from some devices but not from others
depending upon device’s priority.
• Processor accepts interrupts only from devices that have priority higher than its own.
• At the time of execution of an ISR for some device is started, priority of processor is raised to that of the device
• Processor's priority is encoded in a few bits of processor-status (PS) word. This can be changed by program
instructions that write into PS. These are called privileged instructions.
• Privileged-instructions can be executed only while processor is running in supervisor-mode.
• Processor is in supervisor-mode only when executing operating-system routines. (An attempt to execute a
privileged-instruction while in the user-mode leads to a special type of interrupt called a privileged exception).
SIMULTANEOUS REQUESTS
• INTR line is common to all devices (Figure 4.8).
• INTA line is connected in a daisy-chain fashion such that INTA signal propagates serially through devices.
• When several devices raise an interrupt-request and INTR line is activated, processor responds by setting INTA
line to 1. This signal is received by device 1.
• Device 1 passes signal on to device 2 only if it does not require any service.
• If device 1 has a pending-request for interrupt, it blocks INTA signal and proceeds to put its identifying code on
data lines.
• Device that is electrically closest to processor has highest priority.
• Main advantage: This allows the processor to accept interrupt-requests from some devices but not
from others depending upon their priorities.
COMPUTER ORGANIZATION
EXCEPTIONS
• An interrupt is an event that causes
→ execution of one program to be suspended &
→ execution of another program to begin.
• Exception refers to any event that causes an interruption.
I/O interrupts are one example of an exception.
Recovery from Errors
• Computers use a variety of techniques to ensure that all hardware-components are operating properly. For e.g.
many computers include an error-checking code in main-memory which allows detection of errors in stored-data.
• If an error occurs, control-hardware detects it & informs processor by raising an interrupt.
• When exception processing is initiated (as a result of errors), processor
→ suspends program being executed &
→ starts an ESR(Exception Service Routine). This routine takes appropriate action to recover from the
error to inform user about it.
Debugging
• Debugger
→ helps programmer find errors in a program and
→ uses exceptions to provide 2 important facilities: 1) Trace & 2) Breakpoints
• When a processor is operating in trace-mode, an exception occurs after execution of every instruction (using
debugging-program as ESR).
• Debugging-program enables user to examine contents of registers (AX, BX), memory-locations and so on.
• On return from debugging-program,
next instruction in program being debugged is executed,
then debugging-program is activated again.
• Breakpoints provide a similar facility except that program being debugged is interrupted only at specific points
selected by user. An instruction called Trap(or Software interrupt) is usually provided for this purpose.
Privilege Exception
• To protect OS of computer from being corrupted by user-programs, certain instructions can be executed only
while processor is in supervisor-mode. These are called privileged instructions.
• For e.g. when the processor is running in user-mode, it will not execute an instruction that changes priority-level
of processor.
• An attempt to execute such an instruction will produce a privilege-exception. As a result, processor switches to
supervisor-mode & begins to execute an appropriate routine in OS.
COMPUTER ORGANIZATION
DIRECT MEMORY ACCESS (DMA)
• The transfer of a block of data directly between an external device & main memory without continuous
involvement by processor is called as DMA.
• DMA transfers are performed by a control-circuit that is part of I/O device interface. This circuit is called as a
DMA controller (Figure 4.19).
• DMA controller performs the functions that would normally be carried out by processor
• In controller, 3 registers are accessed by processor to initiate transfer operations (Figure 4.18):
1) Two registers are used for storing starting-address & word-count
2) Third register contains status- & control-flags
• The R/W bit determines direction of transfer.
When R/W=1, controller performs a read operation(i.e. it transfers data from memory to I/O),
Otherwise it performs a write operation (i.e. it transfers data from I/O device to memory).
• When Done=1, controller
→ completes transferring a block of data &
→ is ready to receive another command.
• When IE=1, controller raises an interrupt after it has completed transferring a block of data (IE=Interrupt
Enable).
• Finally, when IRQ=1, controller requests an interrupt. (Requests by DMA devices for using the bus are always
given higher priority than processor requests).
• There are 2 ways in which the DMA operation can be carried out:
2) In one method, processor originates most memory-access cycles. DMA controller is said to "steal"
memory cycles from processor. Hence, this technique is usually called cycle stealing.
3) In second method, DMA controller is given exclusive access to main-memory to transfer a block of data
without any interruption. This is known as block mode (or burst mode).
COMPUTER ORGANIZATION
BUS ARBITRATION
• The device that is allowed to initiate data transfers on bus at any given time is called bus-master.
• There can be only one bus master at any given time.
• Bus arbitration is the process by which next device to become the bus-master is selected and bus-mastership is
transferred to it.
• There are 2 approaches to bus arbitration:
1) In centralized arbitration, a single bus-arbiter performs the required arbitration.
2) In distributed arbitration, all device participate in selection of next bus-master.
CENTRALIZED ARBITRATION
• A single bus-arbiter performs the required arbitration (Figure: 4.20 & 4.21).
• Normally, processor is the bus. master unless it grants bus mastership to one of the DMA controllers.
• A DMA controller indicates that it needs to become busmaster by activating Bus-Request line(BR).
• The signal on the BR line is the logical OR of bus-requests from all devices connected to it.
• When BR is activated, processor activates Bus-Grant signal(BG1) indicating to DMA controllers that they may
use bus when it becomes free. (This signal is connected to all DMA controllers using a daisy-chain arrangement).
• If DMA controller-1 is requesting the bus, it blocks propagation of grant-signal to other devices.
Otherwise, it passes the grant downstream by asserting BG2.
• Current bus-master indicates to all devices that it is using bus by activating Bus-Busy line (BBSY).
• Arbiter circuit ensures that only one request is granted at any given time according to a predefined priority
scheme
A conflict may arise if both the processor and a DMA controller try to use the bus at the same time to access the
main memory. To resolve these conflicts, a special circuit called the bus arbiter is provided to coordinate the
activities of all devices requesting memory transfers
COMPUTER ORGANIZATION
DISTRIBUTED ARBITRATION
• All device participate in the selection of next bus-master (Figure 4.22)
• Each device on bus is assigned a 4-bit identification number (ID).
• When 1 or more devices request bus, they
→ assert Start-Arbitration signal &
→ place their 4-bit ID numbers on four open-collector lines ARB 0 through ARB 3 .
• A winner is selected as a result of interaction among signals transmitted over these lines by all contenders.
• Net outcome is that the code on 4 lines represents request that has the highest ID number.
• Main advantage: This approach offers higher reliability since operation of bus is not dependent on any single
device.
COMPUTER ORGANIZATION
BUSES
• Bus
→ is used to inter-connect main-memory, processor & I/O devices
→ includes lines needed to support interrupts & arbitration
• Primary function: To provide a communication-path for transfer of data.
• Bus protocol is set of rules that govern the behaviour of various devices connected to the buses.
• Bus-protocol specifies parameters such as:
→ asserting control-signals
→ timing of placing information on bus
→ rate of data-transfer
• A typical bus consists of 3 sets of lines: 1) Address, 2) Data and 3) Control lines.
• Control-signals specify whether a read or a write operation is to be performed.
• R/W line specifies
→ read operation when R/W=1
→ write operation when R/W=0
• In data-transfer operation, one device plays the role of a bus-master which initiates data transfers by issuing
Read or Write commands on bus ( Hence it may be called an initiator).
• Device addressed by master is referred to as a slave (or target).
• Timing of data transfers over a bus is classified into 2 types:
1) Synchronous and 2) Asynchronous
SYNCHRONOUS BUS
• All devices derive timing-information from a common clock-line.
• Equally spaced pulses on this line define equal time intervals.
• Each of these intervals constitutes a bus-cycle during which one data transfer can take place.
A sequence of events during a read operation:
• At time t0, the master (processor)
→ places the device-address on address-lines &
→ Sends an appropriate command on control-lines (Figure 4.23).
• Information travels over bus at a speed determined by its physical & electrical characteristics.
• Clock pulse width (t1-t0) must be longer than the maximum propagation-delay between 2 devices connected to
bus.
• Information on bus is unreliable during the period t0 to t1 because signals are changing state.
• Slave places requested input-data on data-lines at time t1.
• At end of clock cycle(at time t2), master strobes(captures) data on data-lines into its input-buffer
• For data to be loaded correctly into any storage device (such as a register built with flip-flops), data must be
available at input of that device for a period greater than setup-time of device.
COMPUTER ORGANIZATION
ASYNCHRONOUS BUS
• This method uses handshake-signals between master and slave for coordinating data transfers.
• There are 2 control-lines:
1) Master-ready(MR) to indicate that master is ready for a transaction
2) Slave-ready(SR) to indicate that slave is ready to respond
The read operation proceeds as follows:
• At t0, master places address- & command-information on bus. All devices on bus begin to
decode this information.
• At t1, master sets MR-signal to 1 to inform all devices that the address- & command-information
is ready.
• At t2, selected slave performs required input-operation & sets SR signal to 1 (Figure 4.26).
• At t3, SR signal arrives at master indicating that the input-data are available on bus skew.
• At t4, master removes address- & command-information from bus.
• At t5, when the device-interface receives the 1-to-0 transition of MR signal, it removes data and
SR signal from the bus. This completes the input transfer
INTERFACE CIRCUITS
I/O interface consists of the circuitry required to connect an I/O device to a computer bus.
Side of the interface which connects to the computer has bus signals for:
Address,
Data
Control
Side of the interface which connects to the I/O device has:
Datapath and associated controls to transfer data between the interface and the
I/O device.
This side is called as a “port”.
Ports can be classified into two:
Parallel port,
Serial port.
Parallel port transfers data in the form of a number of bits, normally 8 or 16 to or from the
device.
Serial port transfers and receives data one bit at a time.
Processor communicates with the bus in the same way, whether it is a parallel port or a
serial port.
Conversion from the parallel to serial and vice versa takes place inside the
interface circuit.
Dat
a
Addres
DATAIN Dat
s
a Encoder
R /W an Keyboard
Processo SIN d
debouncing switche
r Master-ready circuit s
Valid
Input
Sl v e-ready
interface
a
Data
Processor
CPU R /W SOUT Printer
Valid
Master -ready
Output Idle
Sla ve-ready interface
• Data lines of the processor bus are connected to the DATAOUT register of the interface.
• The status flag SOUT is connected to the data line D1 using a three-state driver.
• The three-state driver is turned on, when the control Read-status line is 1.
• Address decoder selects the output interface using address lines A1 through A31.
• Address line A0 determines whether the data is to be loaded into the DATAOUT register or
status flag is to be read.
• If the Load-data line is 1, then the Valid line is set to 1.
• If the Idle line is 1, then the status flag SOUT is set to 1.
• Address bits A2 through A31, that is 30 bits are used to select the overall interface.
• Address bits A1 through A0, that is, 2 bits select one of the three registers, namely,
DATAIN, DATAOUT, and the status register.
• Status register contains the flags SIN and SOUT in bits 0 and 1.
• Data lines PA0 through PA7 connect the input device to the DATAIN register.
• DATAOUT register connects the data lines on the processor bus to lines PB0 through PB7
which connect to the output device.
• Separate input and output data lines for connection to an I/O device. Refer fig no. 4.33
SERIAL PORT
Serial port is used to connect the processor to I/O devices that require transmission of
data one bit at a time.
Serial port communicates in a bit-serial fashion on the device side and bit parallel fashion
on the bus side.
Transformation between the parallel and serial formats is achieved with shift
registers that have parallel access capability.
• Input shift register accepts input one bit at a time from the I/O device. Refer fig no.4.37
• Once all the 8 bits are received, the contents of the input shift register are loaded in
parallel into DATAIN register.
• Output data in the DATAOUT register are loaded into the output shift register.
• Bits are shifted out of the output shift register and sent out to the I/O device one bit at a
time.
• As soon as data from the input shift registers are loaded into DATAIN, it can start
accepting another 8 bits of data.
• Input shift register and DATAIN registers are both used at input so that the input shift
register can start receiving another set of 8 bits from the input device after loading the
contents to DATAIN, before the processor reads the contents of DATAIN. This is called as
double-buffering.
• Serial interfaces require fewer wires, and hence serial transmission is convenient for
connecting devices that are physically distant from the computer.
• Speed of transmission of the data over a serial interface is known as the “bit rate”.
• Bit rate depends on the nature of the devices connected.
• In order to accommodate devices with a range of speeds, a serial interface must be able to
use a range of clock speeds.
• Several standard serial interfaces have been developed:
• Universal Asynchronous Receiver Transmitter (UART) for low-speed serial devices.
• RS-232-C for connection to communication links.
PCI BUS
Peripheral Component Interconnect
Introduced in 1992
Low-cost bus
Processor independent
Plug-and-play capability
In today’s computers, most memory transfers involve a burst of data rather than just one
word. The PCI is designed primarily to support this mode of operation.
The bus supports three independent address spaces: memory, I/O, and configuration.
we assumed that the master maintains the address information on the bus until data
transfer is completed. But, the address is needed only long enough for the slave to be
selected. Thus, the address is needed on the bus for one clock cycle only, freeing the
address lines to be used for sending data in subsequent clock cycles. The result is a
significant cost reduction.
A master is called an initiator in PCI terminology. The addressed device that responds to
read and write commands is called a target.
Refer table 4.3 and 4.40 from text
Device configuration
When an I/O device is connected to a computer, several actions are needed to configure
both the device and the software that communicates with it.
PCI incorporates in each I/O device interface a small configuration ROM memory that
stores information about that device.
The configuration ROMs of all devices are accessible in the configuration address space.
The PCI initialization software reads these ROMs and determines whether the device is a
printer, a keyboard, an Ethernet interface, or a disk controller. It can further learn bout
various device options and characteristics.
Devices are assigned addresses during the initialization process.
This means that during the bus configuration operation, devices cannot be accessed based
on their address, as they have not yet been assigned one.
Hence, the configuration address space uses a different mechanism. Each device has an
input signal called Initialization Device Select, IDSEL#
Electrical characteristics:
PCI bus has been defined for operation with either a 5 or 3.3 V power supply
SCSI BUS
The acronym SCSI stands for Small Computer System Interface.
It refers to a standard bus defined by the American National Standards Institute (ANSI)
under the designation X3.131 .
In the original specifications of the standard, devices such as disks are connected to a
computer via a 50-wire cable, which can be up to 25 meters in length and can transfer
data at rates up to 5 megabytes/s.
The SCSI bus standard has undergone many revisions, and its data transfer capability has
increased very rapidly, almost doubling every two years.
SCSI-2 and SCSI-3 have been defined, and each has several options.
Because of various options SCSI connector may have 50, 68 or 80 pins.
Devices connected to the SCSI bus are not part of the address space of the processor
The SCSI bus is connected to the processor bus through a SCSI controller. This controller
uses DMA to transfer data packets from the main memory to the device, or vice versa.
A packet may contain a block of data, commands from the processor to the device, or
status information about the device.
A controller connected to a SCSI bus is one of two types – an initiator or a target.
An initiator has the ability to select a particular target and to send commands specifying
the operations to be performed. The disk controller operates as a target. It carries out the
commands it receives from the initiator.
The initiator establishes a logical connection with the intended target.
Once this connection has been established, it can be suspended and restored as needed to
transfer commands and bursts of data.
While a particular connection is suspended, other device can use the bus to transfer
information.
This ability to overlap data transfer requests is one of the key features of the SCSI bus
that leads to its high performance.
Data transfers on the SCSI bus are always controlled by the target controller.
To send a command to a target, an initiator requests control of the bus and, after winning
arbitration, selects the controller it wants to communicate with and hands control of the
bus over to it.
Then the controller starts a data transfer operation to receive a command from the
initiator.
Assume that processor needs to read block of data from a disk drive and that data are
stored in disk sectors that are not contiguous.
The processor sends a command to the SCSI controller, which causes the following
sequence of events to take place:
The SCSI controller, acting as an initiator, contends for control of the bus.
When the initiator wins the arbitration process, it selects the target controller and
hands over control of the bus to it.
The target starts an output operation (from initiator to target); in response to this,
the initiator sends a command specifying the required read operation.
The target, realizing that it first needs to perform a disk seek operation, sends a
message to the initiator indicating that it will temporarily suspend the connection
between them. Then it releases the bus.
The target controller sends a command to the disk drive to move the read head to
the first sector involved in the requested read operation. Then, it reads the data
stored in that sector and stores them in a data buffer. When it is ready to begin
transferring data to the initiator, the target requests control of the bus. After it
wins arbitration, it reselects the initiator controller, thus restoring the suspended
connection.
The target transfers the contents of the data buffer to the initiator and then
suspends the connection again
The target controller sends a command to the disk drive to perform another seek
operation. Then, it transfers the contents of the second disk sector to the initiator
as before. At the end of this transfers, the logical connection between the two
controllers is terminated.
As the initiator controller receives the data, it stores them into the main memory
using the DMA approach.
The SCSI controller sends as interrupt to the processor to inform it that the
requested operation has been completed