Cso U 4
Cso U 4
• The EX-OR gate provides 0 as output when the signs are identical. It is
1 when the signs are different.
• A + B is computed for the following and the sum is stored in EA:
1. When the signs are same and addition operation is required.
2. When the signs are different and subtract operation is required.
• The carry in E after addition indicates an overflow if it is 1 and it
is transferred to AVF, the add overflow flag
• A-B = A+ B’+1 computed for the following:
• 1. When the signs are different and addition operation is required.
• 2. When the signs are same and subtract operation is required. No
overflow can occur if the numbers are subtracted and hence AVF is
cleared to Zero.
• A 1 in E indicates that A ≥ B and the number in A is the correct result.
If this number in A is zero, the sign AS must be made positive to avoid a
negative zero.
• A 0 in E indicates that A< B. For this case it is necessary to take the
2’s complement of the value in A.
• In the algorithm shown in flow chart, it is assumed that A register
has circuits for micro operations complement and increment.
• Hence two complement of value in A is obtained in 2, micro operations..
• In other paths of the flow chart, the sign of the result is the same as the
sign of A, so no change in AS is required.
• However, when A < B, the sign of the result is the complement
of original sign of A.
• Hence the complement of AS stored in AS.
• Final Result: As and A
Multiplication Algorithms:
• Multiplication of two fixed-point binary numbers in signed-magnitude
representation is done with process of successive shift and adds
operations.
• This process is best illustrated with a numerical example as follows:
Division Algorithm:
• Division of two fixed-point binary numbers in signed magnitude
representation is performed with paper and pencil by a process of successive
compare, shift and subtract operations.
• Binary division is much simpler than decimal division because here the
quotient digits are either 0 or 1.
• The division process is described in Figure
Example of Division Operation:
Hardware Implementation
Division Operation using Pen and Paper:
• The divisor is compared with the five most significant bits of the dividend.
• Since the 5-bit number is smaller than B, we again repeat the same process.
• Now the 6-bit number is greater than B, so we place a 1 for the quotient bit
in the sixth position above the dividend.
• Now we shift the divisor once to the right and subtract it from the dividend.
• The difference is known as a partial remainder because the division could
have stopped here to obtain a quotient of 1 and a remainder equal to the
partial remainder.
Considerin Normal
g the sign Division
of the
Process
result and a
overflow
condition.
• Initially, the dividend is in A & Q and the divisor is in B.
• Sign of result is transferred into Q, to be the part of quotient. Then a
constant is set into the SC to specify the number of bits in the quotient.
• Since an operand must be saved with its sign, one bit of the word will be
inhabited by the sign, and the magnitude will be composed of n -1 bits.
• The condition of divide-overflow is checked by subtracting the divisor in
B from the half of bits of the dividend stored in A.
• If A ≥ B, DVF is set and the operation is terminated before time.
• If A < B, no overflow condition occurs and so the value of the dividend
is reinstated by adding B to A.
Output Devices
ASCII(American Standard Code for Information
Interchange)- Alphanumeric Characters:
• Input/output devices that communicate with people and the computer are
usually involved in the transfer of Alphanumeric Information to and from
the device and the computer.
• The standard binary code for the alphanumeric characters is ASCII
• It uses 7 bits to code 128 characters.
• ASCII code contains 94 characters that are printable and 34 characters that
are nonprinting characters used for various control functions.
• Among 94, 26 used for uppercase letters, 26 used for lowercase letters,10
are used for numerical and 32 are used for special characters.
• 34 control characters are used for routing and arranging the printed text in a
prescribed format
• 3 types of control characters:
1. Format Effectors (control the layout of printing includes BS-Back
space,HT-Horizontaltab,CR-Carriage Return)
2. Information Separators(used to separate data into paragraphs & pages
includes RS-record seperator and FS-file seperator)
3. Communication control characters (useful for transmission of text
between remote terminals includes STX-Start of text, ETX-End of text)
• The I/O Bus consists of data lines, address lines and control lines.
• The I/O bus from the processor is attached to all peripherals interface.
• To communicate with a particular device, the processor places a device
address on address lines.
• Each Interface decodes the address and control received from the I/O
bus, interprets them for peripherals and provides signals for the
peripheral controller.
• It is also synchronizes the data flow and supervises the transfer between
peripheral and processor.
• Each peripheral has its own controller. For example, the printer controller
controls the paper motion, the print timing
• The processor provides a function code in the control lines.
• The control lines are referred as I/O command.
• The commands are as following:
• Control command- A control command is issued to activate the peripheral
and to inform it what to do.
• Status command- A status command is used to test various status conditions
in the interface and the peripheral.
• Data Output command- A data output command causes the interface to
respond by transferring data from the bus into one of its registers.
• Data Input command- The data input command is the opposite of the data
output.
• In the block diagram fig. (a), the data bus carries the binary information
from source to destination unit.
• Typically, the bus has multiple lines to transfer an entire byte or word.
• The strobe is a single line that informs the destination unit when a valid data
word is available.
• The timing diagram fig. (b) the source unit first places the data on the data
bus.
• The information on the data bus and strobe signal remain in the active state
to allow the destination unit to receive the data.
Data Transfer Initiated by Destination Unit(Destinaation initiated strobe
signal for data transfer)
• In this method, the destination unit activates the strobe pulse, to informing
the source to provide the data.
• The source will respond by placing the requested binary information on the
data bus.
• The data must be valid and remain in the bus long enough for the
destination unit to accept it.
• When accepted the destination unit then disables the strobe and the source
unit removes the data from the bus
Disadvantage of Strobe Signal:
The disadvantage of the strobe method is that, the source unit initiates the transfer
has no way of knowing whether the destination unit has actually received the
data item that was places in the bus.
Similarly, a destination unit that initiates the transfer has no way of knowing
whether the source unit has actually placed the data on bus. The Handshaking
method solves this problem
Handshaking
• The handshaking method solves the problem of strobe method by
introducing a second control signal that provides a reply to the unit that
initiates the transfer.
Principle of Handshaking:
• The basic principle of the two-wire handshaking method of data transfer is
as follow:
• One control line is in the same direction as the data flows in the bus from
the source to destination.
• It is used by source unit to inform the destination unit whether there a valid
data in the bus.
• The other control line is in the other direction from the destination to the
source.
• It is used by the destination unit to inform the source whether it can accept
the data. The sequence of control during the transfer depends on the unit that
initiates the transfer.
Source Initiated Transfer using Handshaking:
• The sequence of events shows four possible states that the system can be at
any given time.
• The source unit initiates the transfer by placing the data on the bus and
enabling its data valid signal.
• The data accepted signal is activated by the destination unit after it accepts
the data from the bus.
• The source unit then disables its data accepted signal and the system goes
into its initial state .
Destination Initiated Transfer Using Handshaking:
• The name of the signal generated by the destination unit has been changed
to ready for data to reflects its new meaning.
• The source unit in this case does not place data on the bus until after it
receives the ready for data signal from the destination unit.
• From there on, the handshaking procedure follows the same pattern as in
the source initiated case.
• The only difference between the Source Initiated and the Destination
Initiated transfer is in their choice of Initial sate
• Advantage of the Handshaking method:
• The Handshaking scheme provides degree of flexibility and reliability
because the successful completion of data transfer relies on active
participation by both units.
• If any of one unit is faulty, the data transfer will not be completed. Such an
error can be detected by means of a Timeout mechanism which provides an
alarm if the data is not completed within time.
• The peripheral device transfers bytes of bytes of data one at a time when
they are available.
• When a byte of data is available, the device places it in the I/O bus and
enables data valid line.
• The interface accepts the data into its data register and enables data accepted
line.
• The interface sets a bit in the status register that is referred as Flag bit(F).
• A program is written for the computer too check for flag in status register to
determine if a byte has placed in the data register by the I/O device.
• This is done by reading the status register to a CPU register and checking
the value of flag bit.
• If F=1, CPU reads the data from data register.
• If F=0, CPU/interface disables the data accepted line.
• A flowchart of the program is written for CPU is shown below
• Here the device is sending a sequence of bytes that must be stored in
memory.
• The transfer of data requires three instructions:
Flowchart:
Drawback of the Programmed I/O :
• The main drawback of the Program Initiated I/O was that the CPU has to
monitor the units all the times when the program is executing.
• Thus the CPU stays in a program loop until the I/O unit indicates that it is
ready for data transfer.
• This is a time consuming process and the CPU time is wasted a lot in
keeping an eye to the executing of program.
• To remove this problem an Interrupt facility and special commands are used.
•
Interrupt-Initiated I/O :
• In this method an interrupt facility called an interrupt command is used to
inform the device about the start and end of transfer.
• In the meantime the CPU executes other program. When the interface
determines that the device is ready for data transfer it generates an Interrupt
Request and sends it to the computer.
• When the CPU receives such an signal, it temporarily stops the execution of
the program and branches to a service program to process the I/O transfer
and after completing it returns back to task, what it was originally
performing.
• In this type of IO, computer does not check the flag. It continue to perform
its task.
• Whenever any device wants the attention, it sends the interrupt signal
to the CPU.
• CPU then deviates from what it was doing, store the return address from
PC and branch to the address of the subroutine.
• There are two ways of choosing the branch address:
• Vectored Interrupt
• Non-vectored Interrupt
• In vectored interrupt the source that interrupts the CPU provides the
branch information. This information is called interrupt vectored.
• In non-vectored interrupt, the branch address is assigned to the fixed
address in the memory.
Priority Interrupt:
• There are number of IO devices attached to the computer.
• They are all capable of generating the interrupt.
• When the interrupt is generated from more than one device, priority
interrupt system is used to determine which device is to be serviced
first.
• Devices with high speed transfer are given higher priority and slow devices
are given lower priority.
• Establishing the priority can be done in two ways:
Using Software Using
Hardware
• A polling procedure is used to identify highest priority in software means.
• Polling Procedure :
• There is one common branch address for all interrupts.
• Branch address contain the code that polls the interrupt sources in sequence.
• The highest priority is tested first.
• The particular service routine of the highest priority device is served.
• The disadvantage is that time required to poll them can exceed the time to
serve them in large number of IO devices.
• Using Hardware:
• Hardware priority system function as an overall manager
• It accepts interrupt request and determine the priorities.
• To speed up the operation each interrupting devices has its own interrupt
vector.
• No polling is required, all decision are established by hardware
priority interrupt unit.
• It can be established by serial or parallel connection of interrupt lines.
SP SP - 1 Decrement stack
M[SP] PC
pointer Push PC into
INTACK 1
stack
PC VAD
Enable interrupt
IEN 0
acknowledge Transfer vector
Go To Fetch
address to PC Disable further
interrupts
to execute the first instruction
in the interrupt service
routine
Direct Memory Access (DMA):
• In the Direct Memory Access (DMA) the interface transfer the data into
and out of the memory unit through the memory bus.
• The transfer of data between a fast storage device such as magnetic disk and
memory is often limited by the speed of the CPU.
• Removing the CPU from the path and letting the peripheral device
manage the memory buses directly would improve the speed of transfer.
• This transfer technique is called Direct Memory Access (DMA).
• During the DMA transfer, the CPU is idle and has no control of the memory
buses.
• A DMA Controller takes over the buses to manage the transfer directly
between the I/O device and memory.
• The CPU may be placed in an idle state in a variety of ways. One common
method extensively used in microprocessor is to disable the buses through
special control signals such as:
Bus Request (BR)
Bus Grant (BG)
These two control signals in the CPU that facilitates the DMA transfer.
The Bus Request (BR) input is used by the DMA controller to request the
CPU.
When this input is active, the CPU terminates the execution of the current
instruction and places the address bus, data bus and read write lines into a
high Impedance state. High Impedance state means that the output is
disconnected.
CPU Bus signals for DMA Transfer:
• The CPU activates the Bus Grant (BG) output to inform the external DMA
that the Bus Request (BR) can now take control of the buses to conduct
memory transfer without processor.
• When the DMA terminates the transfer, it disables the Bus Request (BR) line.
• The CPU disables the Bus Grant (BG), takes control of the buses and return
to its normal operation.
• The transfer can be made in several ways that are:
i. DMA Burst
ii. Cycle Stealing
DMA Burst :-
In DMA Burst transfer, a block sequence consisting of a number of memory words
is transferred in continuous burst while the DMA controller is master of the
memory buses.
Cycle Stealing:
• Cycle stealing allows the DMA controller to transfer one data word at a
time, after which it must returns control of the buses to the CPU
DMA Controller:
• The DMA controller needs the usual circuits of an interface to communicate
with the CPU and I/O device. The DMA controller has three registers:
i. Address Register
ii. Word Count Register
iii. Control Register
i. Address Register :- Address Register contains an address to specify the
desired location in memory.
ii. Word Count Register :- WC holds the number of words to be
transferred and internally tested for zero.
iii. Control Register :-
Control Register specifies the mode of transfer
The unit communicates with the CPU via the data bus and control lines.
The registers in the DMA are selected by the CPU through the address bus by
enabling the DS (DMA select) and RS (Register select) inputs.
The RD (read) and WR (write) inputs are bidirectional.
When the BG (Bus Grant) input is 0, the CPU can communicate with the
DMA registers through the data bus to read from or write to the DMA
registers.
When BG =1, the DMA can communicate directly with the memory by
specifying an address in the address bus and activating the RD or WR
control.
Block Diagram of DMA Controller
DMA Transfer:
• The CPU communicates with the DMA through the address and data buses
as with any interface unit.
• The DMA has its own address, which activates the DS and RS lines.
• The CPU initializes the DMA through the data bus. Once the DMA receives
the start control command, it can transfer between the peripheral and the
memory.
• When BG = 0 the RD and WR are input lines allowing the CPU to
communicate with the internal DMA registers.
• When BG=1, the RD and WR are output lines from the DMA controller to
the random access memory to specify the read or write operation of data.
Input-Output Processor:
• It is a processor with direct memory access capability that
communicates with IO devices.
• IOP is similar to CPU except that it is designed to handle the details of IO
operation.
• Unlike DMA which is initialized by CPU, IOP can fetch and execute its
own instructions.
• IOP instruction are specially designed to handle IO operation.
Block Diagram of a computer with a I/O Processor:
• Memory occupies the central position and can communicate with each
processor by DMA.
• CPU is responsible for processing data.
• IOP provides the path for transfer of data between various peripheral
devices and memory.
• Data formats of peripherals differ from CPU and memory. IOP maintain
such problems.
• Data is transferred from IOP to memory by stealing one memory cycle.
• Instructions that are read from memory by IOP are called commands to
distinguish them from instructions that are read by the CPU.
CPU- IOP Communication: