Peripherals and Interfaces-01
Peripherals and Interfaces-01
and
Interfacing
Recommended Texts
• Dr. M. Rafiquzzaman, “Microprocessors and Microcomputer-
based System Design”
• Douglas V. Hall, “Microprocessors and Interfacing –
Programming and Hardware”
• N. Mathivanan, “Microprocessors, PC Hardware and
Interfacing”
• Jyoti Snehi, “Computer Peripherals and Interfacing”
2/26/2023 2
Peripherals
2/26/2023 3
Interfaces
• What is an interface?
– The interface is the combination of hardware and
software needed to link the CPU to the
peripherals and to enable them to communicate
with the CPU despite all their differing
characteristics.
• The hardware is the bit you connect the cable into e.g.
USB.
• Buffering;
• Voltage conversion;
2/26/2023 6
Interfaces
• Buffering:
– This is an area of RAM within the interface which
stores the data while in transit between the
processor and the peripheral.
Interface 0 0
1 1
0 1 0 1 0 1 0 0
0 0
1 1
0 1 1 0 0 1 1
Interfaces
• ADC and DAC
– A computer is connected to a peripheral by
an interface. This interface has to be able
to change the digital signals from the
computer to an analogue signal that the
other device can understand. This is done
by a DAC – Digital to Analogue Converter.
• Voltage Conversion
– Peripherals send data using a different voltage
from that used by the processor and its
associated components on the motherboard of
the computer.
Bluetooth
– Bluetooth can make short-range links between personal
devices, such as mobile phones and headsets, palmtops
(PDA) and laptop (notebook) computers.
WiFi
– WiFi stands for the Wireless Fidelity Alliance.
2/26/2023 39
Mainframe
• The largest and most powerful computer
• They are designed to work at very high speed
• Large data words, typically 64 bits or greater
• They have massive amount of memory
• Used in military defense control, business data
processing, computer graphic display.
• Example: IBM 4381
2/26/2023 40
Super Computer
• The fastest and more powerful mainframes
are called Super Computer
• Example: Cray Y-MP/ 832
• Used by largest firms, government agencies
and universities
2/26/2023 41
Mini Computer
• Scaled-down versions of mainframe Computer
• Runs slowly, works with smaller data word
• Does not have as much memory as mainframe
• Used in scientific research and industrial
control
2/26/2023 42
Micro Computer
• Small computer
• CPU is usually a single microprocessor
• Example: Desktop, Laptop, Palmtop
2/26/2023 43
Intel Core i7 Intel 8086
2/26/2023 44
Microprocessor Data Type
• Bit
• Byte
• Word
• Unsigned and Signed Binary Integers
• BCD (Binary Coded Decimal) Numbers
• ASCII
• Floating Point Numbers
2/26/2023 45
Microprocessor data type
• Bit:
– smallest unit of information
– It represents either 1 or 0
• Byte:
– 8 bits of data
• Word:
– Data that is handled by a microprocessor at a time
– Ex: 8 bit, 16 bit, 32 bit word
2/26/2023 46
Unsigned and Signed Binary Integers
2/26/2023 47
Unsigned And Signed Binary Integers
• An unsigned binary integer has no arithmetic sign
• Example of unsigned integer is memory address
• Unsigned uses the leading bit as a part of the value,
while the signed version uses the left-most-bit to
identify if the number is positive or negative.
• Signed integer is represented in true form for a
positive number and in two’s complement form for a
negative number
2/26/2023 48
Representation of Unsigned Binary Numbers
Example-2: Find range of 5 bit unsigned binary numbers. Also, find minimum
and maximum value in this range.
Solution: Since, range of unsigned binary number is from 0 to (2n-1).
Therefore, range of 5 bit unsigned binary number is from 0 to (25-1) which is
equal from minimum value 0 (i.e., 00000) to maximum value 31 (i.e., 11111).
2/26/2023 49
Representation of Signed Binary Numbers
(a) Sign-Magnitude form:
The range of Sign-Magnitude form is from -(2(n-1)-1) to (2(n-1)-1).
For example, range of 6 bit Sign-Magnitude form binary number is from -(25-1) to (25-
1) which is equal from minimum value -31 (i.e., 1 11111) to maximum value +31 (i.e., 0
11111). And zero (0) has two representation, -0 (i.e., 1 00000) and +0 (i.e., 0 00000).
(b) 1’s complement form:
The range of 1’s complement form is from -(2(n-1)-1) to (2(n-1)-1) .
For example, range of 6 bit 1’s complement form binary number is from -(25-1) to (25-
1) which is equal from minimum value -31 (i.e., 1 00000) to maximum value +31 (i.e., 0
11111). And zero (0) has two representation, -0 (i.e., 1 11111) and +0 (i.e., 0 00000).
(c) 2’s complement form:
The range of 2’s complement form is from -(2(n-1)) to (2(n-1)-1).
For example, range of 6 bit 2’s complement form binary number is from (25) to (25-1)
which is equal from minimum value -32 (i.e., 1 00000) to maximum value +31 (i.e., 0
11111). And zero (0) has one representation, +0 (i.e., 0 00000).
2/26/2023 50
Unsigned And Signed Binary Integers
• The range of unsigned
binary number is from 0 to
(2n-1).
• For 8-bit number system
– Unsigned: It consists of only
non-negative values i.e 0 to
255.
– Signed: It consist of both
negative and positive values
but in different formats like
• 0 to +127
• -1 to -128
2/26/2023 51
Unsigned And Signed Binary Integers
2/26/2023 52
BCD (Binary Coded Decimal) Numbers
• Each decimal digit is represented by four bit
binary number
• Microprocessor stores BCD numbers in two
forms, packed and unpacked
• The unpacked BCD number represents each
BCD digit as a byte
• The packed BCD number represents two BCD
digits in a byte
2/26/2023 53
ASCII
• Each character is represented by an integer.
• This code represents alphanumeric in a
microprocessor’s memory
• It also represents special symbols
2/26/2023 54
Floating-Point Number
• Floating point numbers contains three
components – sign, exponent and mantissa
• For the decimal value -2.5x10^-2, sign is
negative, exponent is -2 and mantissa is 2.5
• A binary floating point number is represented
as a normalized binary fraction raised to a
power of 2
2/26/2023 55
Floating-Point Number
• The Conversion Procedure:
– Convert the absolute value of the number to binary, perhaps with a fractional
part after the binary point. This can be done by converting the integral and
fractional parts separately.
– Append × 2^0 to the end of the binary number (which does not change its
value).
– Normalize the number. Move the binary point so that it is one bit from the
left. Adjust the exponent of two so that the value does not change.
– Place the mantissa into the mantissa field of the number. Omit the leading
one, and fill with zeros on the right.
– Add the bias to the exponent of two, and place it in the exponent field. The
bias is 2^(k−1) − 1, where k is the number of bits in the exponent field. For the
eight-bit format, k = 3, so the bias is 2^(3−1) − 1 = 3. For IEEE 32-bit, k = 8, so
the bias is 2^(8−1) − 1 = 127.
– Set the sign bit, 1 for negative, 0 for positive, according to the sign of the
original number.
2/26/2023 56
Using The Conversion Procedure
•Convert 2.625 to our 8-bit floating point format.
1.The integral part is easy, 210 = 102. For the fractional part:
The result is .
0 100 0101
Represented as hex, that is 4516.
Try Yourself: Convert -4.75 to our 8-bit floating point format.
2/26/2023 57
Using The Conversion Procedure
• Convert -4.75 to our 8-bit floating point
format.
– The integral part is 410 = 1002. The fractional:
2/26/2023 58
Using The Conversion Procedure
2/26/2023 59
Using The Conversion Procedure
2/26/2023 60
Using The Conversion Procedure(IEEE 32 bit)
2/26/2023 61
Using The Conversion Procedure(IEEE 32 bit)
2/26/2023 62
Using The Conversion Procedure(IEEE 64 bit)
2/26/2023 63
Overview of Microcomputer Structure
and Operation
Data Bus
Input
Device
I/O Memory
CPU ROM RAM
Ports
Output
device
Address Bus
2/26/2023 64
Major Parts:
• CPU
• Memory
• Input / Output circuitry
• Buses:
– Address bus
– Data bus
– Control bus
2/26/2023 65
Memory:
• It stores the binary codes for the
sequences of instructions
• It stores binary coded data
• Example: ROM, RAM, magnetic /
optical disks
2/26/2023 66
Input / Output:
• They are used to take in data from outside
world or send data to the outside world
• I/O devices are connected with
microprocessor through I/O ports
• Example: Keyboards, video display terminals,
printers, modems
2/26/2023 67
Central Processing Unit:
2/26/2023 68
Registers
(a) General Purpose Registers –
The 8085 has six general-purpose registers to store 8-bit data; these are identified as-
B, C, D, E, H, and L. These can be combined as register pairs – BC, DE, and HL, to
perform some 16-bit operation. These registers are used to store or copy temporary
data, by using instructions, during the execution of the program.
Accumulator: The accumulator is an 8-bit register (can store 8-bit data) that is the part
of the arithmetic and logical unit (ALU). After performing arithmetical or logical
operations, the result is stored in accumulator. Accumulator is also defined as register
A.
Flag registers: Sign Flag, Zero Flag, Parity Flag, Carry Flag, Overflow Flag
2/26/2023 73
Address Bus:
• It consists of 16, 20, 24, 32 or 36 parallel
unidirectional signal lines
• On these lines the CPU sends out the
address of the memory location or I/O port
that is to be written to or read from
• The number of locations that the CPU can
address is determined by the number of
address lines
2/26/2023 74
Data Bus:
• Data bus consists of 8, 16, 32 parallel
bidirectional signal lines
• Many devices in the system will have
their output connected to data bus, but
only one device at a time will have its
output enabled
2/26/2023 75
Control Bus:
• The control bus consists of 4 to 10 parallel
signal lines
• The CPU sends out signals on the control bus
to enable the outputs of addressed memory
devices or port devices
• Example of control signals: Memory read,
Memory write
2/26/2023 76
1 0
0 1
1 1
1
0
0
0
1
CPU 1
0
0
1
1
“Processing”
“Input”
10 1 1 0 0 0 1
1 1 0 0 1 1 1 0
“Output”
A
0
1
1
1
0
0
2/26/2023 1 77
1
Memory System
• Whether simple or complex, every
microprocessor-based system has a memory
system.
• Two main types of memory: read-only
memory (ROM) and random access memory
(RAM).
2/26/2023 78
Memory Pin Connections
• Pin connections common to all memory
devices are the
– address inputs,
– data outputs or input/outputs,
– some type of selection input, and
– at least one control input used to select a read or
write operation.
2/26/2023 79
Memory Pin Connections
2/26/2023 80
Address Connections
• Address inputs that select a memory location
within the memory device. Address inputs are
almost always labeled from A0, the least
significant address input, to An
2/26/2023 81
Data Connections
• The data connections are the points at which
data are entered for storage or extracted for
reading.
• A 16K x 1 is a memory device containing 16K
1-bit memory locations.
• 64K x 4 memory device is listed as a 256K
device.
2/26/2023 82
Selection Connections
• Each memory device has an input, sometimes
more than one, that selects or enables the
memory device.
• This kind of input is most often called a chip
select (CS), chip enable (CE), or simply select
(S) input.
2/26/2023 83
Control Connections
• The control input most often found on a ROM
is the output enable (OE) or gate (G)
connection, which allows data to flow out of
the output data pins of the ROM. If OE and
the selection input are both active, then the
output is enabled; if OE is inactive, the output
is disabled at its high-impedance state.
2/26/2023 84
Control Connections
• A RAM memory device has either one or two control
inputs.
• If there is one control input, it is often called R/W. This
pin selects a read operation or a write operation only if
the device is selected by the selection input (CS).
• If the RAM has two control inputs, they are usually
labeled WE (or W) and OE (or G). Here, WE (write
enable) must be active to perform a memory write
operation, and OE must be active to perform a memory
read operation. When these two controls (WE) and OE)
are present, they must never both be active at the
same time.
2/26/2023 85
ADDRESS DECODING
• In order to attach a memory device to the
microprocessor, it is necessary to decode the
address from the microprocessor to make the
memory function at a unique section or
partition of the memory map
• Without an address decoder, only one
memory device can be connected to a
microprocessor, which would make it virtually
useless.
2/26/2023 86
Main Memory Array Design
• Memory Array Design means: Interconnecting several memory
chips.
• A 16 bit microprocessor can address directly a maximum of 216 =
65,536 or 64K bytes of memory locations.
• M /IO › LOW : if the microprocessor executes an I/O instruction
• M /IO › HIGH: if the microprocessor executes a memory instruction.
2/26/2023 87
Main Memory Array Design
Chip
Select
Control
Input
2/26/2023 88
Main Memory Array Design
• To connect a microprocessor to ROM/RAM
chips, three address-decoding techniques are
commonly used:
• Linear decoding
• Full/Partial decoding
• Memory decoding using PALs
Typical ROM chip
2/26/2023 90
2/26/2023 91
Main Memory Array Design
• Linear decoding Advantage
does not require decoding hardware.
• Linear decoding Disadvantage
1. Bus Conflict: two or more of lines A10-A13are low at the same time, more
than one SRAM chip are selected.
Solution: software must be written such that it never reads into or writes
from any address in which more than one of bits A10-A13are low.
2. Memory Foldback : Wastes a large amount of address space. For
example, whenever the address value is B800 or 3800, SRAM chip I is
selected.
Solution: use full decoded memory addressing.
2/26/2023 92
Main Memory Array Design
• If only a portion of the addressable space is going to
be implemented there are two basic address
decoding strategies
– Full address decoding
• All the address lines are used to specify a memory location
• Each physical memory location is identified by a unique address
– Partial address decoding
• Since not all the address space is implemented, only a subset of the address lines
are needed to point to the physical memory locations
• Each physical memory location is identified by several possible addresses (using all
combinations of the address lines that were not used)
2/26/2023 93
Decoder
• Decoder is a combinational circuit that has ‘n’
input lines and maximum of 2n output lines.
One of these outputs will be active High based
on the combination of inputs present, when
the decoder is enabled. That means decoder
detects a particular code. The outputs of the
decoder are nothing but the min terms of ‘n’
input variables lines, when it is enabled.
2/26/2023 94
Decoder
• 2 to 4 Decoder
• Let 2 to 4 Decoder has two inputs A1 & A0 and four outputs Y3, Y2, Y1 & Y0.
• One of these four outputs will be “1”, for each combination of inputs,
when Enable, E is “1”.
2/26/2023 95
Decoder
2/26/2023 96
Main Memory Array Design
• Partial address decoding
• Let’s assume a microprocessor with 10 address lines (1KB memory)
– However, this time we wish to implement only 512 bytes of memory
– We still must use 128-byte memory chips
– Physical memory must be placed on the upper half of the memory map
• SOLUTION
2/26/2023 97
Main Memory Array Design
• Full address decoding
• Let’s assume the same microprocessor with 10 address lines (1KB
memory)
– However, this time we wish to implement only 512 bytes of memory
– We still must use 128-byte memory chips
– Physical memory must be placed on the upper half of the memory map
• SOLUTION
2/26/2023 98
Main Memory Array Design
• Full Decoding.
• Using 3x8 decoder
output selects one of
the four IK SRAM
chips, depending on
the values of A12, A11,
and A10
• Decoder output
enabled only when
E3 = E2 = 0 and E1 = 1
2/26/2023 99
2/26/2023 100
Main Memory Array Design
• Programmable Logic Devices (PLDs) are the integrated circuits.
They contain an array of AND gates & another array of OR
gates. There are three kinds of PLDs based on the type of
arrays, which has programmable feature.
– Programmable Read Only Memory
– Programmable Array Logic
– Programmable Logic Array
• The process of entering the information into these devices is
known as programming. Basically, users can program these
devices or ICs electrically in order to implement the Boolean
functions based on the requirement. Here, the term
programming refers to hardware programming but not
software programming.
2/26/2023 101
Main Memory Array Design
• Programmable Read Only Memory (PROM)
– Read Only Memory (ROM) is a memory device, which stores the binary information
permanently. That means, we can’t change that stored information by any means later. If
the ROM has programmable feature, then it is called as Programmable ROM (PROM).
The user has the flexibility to program the binary information electrically once by using
PROM programmer.
– PROM is a programmable logic device that has fixed AND array & Programmable OR
array. The block diagram of PROM is shown in the following figure.
2/26/2023 102
Main Memory Array Design
• Here, the inputs of AND gates are not of programmable type. So, we have to
generate 2n product terms by using 2n AND gates having n inputs each. We can
implement these product terms by using nx2n decoder. So, this decoder generates
‘n’ min terms.
• Here, the inputs of OR gates are programmable. That means, we can program any
number of required product terms, since all the outputs of AND gates are applied
as inputs to each OR gate. Therefore, the outputs of PROM will be in the form of
sum of min terms.
• Example
• Let us implement the following Boolean functions using PROM.
2/26/2023 103
Main Memory Array Design
• The given two functions are in sum of min terms form and each function is
having three variables X, Y & Z. So, we require a 3 to 8 decoder and two
programmable OR gates for producing these two functions. The
corresponding PROM is shown in the following figure.
• Here, 3 to 8 decoder generates eight min terms. The two programmable OR gates
have the access of all these min terms. But, only the required min terms are
programmed in order to produce the respective Boolean functions by each OR
gate. The symbol ‘X’ is used for programmable connections.
2/26/2023 104
Main Memory Array Design
• Programmable Array Logic (PAL)
– PAL is a programmable logic device that has Programmable AND array
& fixed OR array. The advantage of PAL is that we can generate only
the required product terms of Boolean function instead of generating
all the min terms by using programmable AND gates. The block
diagram of PAL is shown in the following figure.
2/26/2023 105
Main Memory Array Design
• Here, the inputs of AND gates are programmable. That means each AND gate has
both normal and complemented inputs of variables. So, based on the
requirement, we can program any of those inputs. So, we can generate only the
required product terms by using these AND gates.
• Here, the inputs of OR gates are not of programmable type. So, the number of
inputs to each OR gate will be of fixed type. Hence, apply those required product
terms to each OR gate as inputs. Therefore, the outputs of PAL will be in the form
of sum of products form.
• Example
• Let us implement the following Boolean functions using PAL.
2/26/2023 106
Main Memory Array Design
• The given two functions are in sum of products form. There are two
product terms present in each Boolean function. So, we require four
programmable AND gates & two fixed OR gates for producing those two
functions. The corresponding PAL is shown in the following figure.
• The programmable AND gates have the access of both normal and complemented inputs of variables. In
the above figure, the inputs X, X′X′, Y, Y′Y′, Z & Z′Z′, are available at the inputs of each AND gate. So,
program only the required literals in order to generate one product term by each AND gate. The symbol ‘X’
is used for programmable connections.
• Here, the inputs of OR gates are of fixed type. So, the necessary product terms are connected to inputs of
each OR gate. So that the OR gates produce the respective Boolean functions. The symbol ‘.’ is used for
fixed connections.
2/26/2023 107
Main Memory Array Design
• Programmable Logic Array (PLA)
– PLA is a programmable logic device that has both Programmable AND array &
Programmable OR array. Hence, it is the most flexible PLD. The block diagram
of PLA is shown in the following figure.
– Here, the inputs of AND gates are programmable. That means each AND gate
has both normal and complemented inputs of variables. So, based on the
requirement, we can program any of those inputs. So, we can generate only
the required product terms by using these AND gates.
– Here, the inputs of OR gates are also programmable. So, we can program any
number of required product terms, since all the outputs of AND gates are
applied as inputs to each OR gate. Therefore, the outputs of PAL will be in the
form of sum of products form.
– Example
– Let us implement the following Boolean functions using PLA.
2/26/2023 108
Main Memory Array Design
• The given two functions are in sum of products form. The number of product
terms present in the given Boolean functions A & B are two and three respectively.
One product term, Z′XZ′X is common in each function.
• So, we require four programmable AND gates & two programmable OR gates for
producing those two functions. The corresponding PLA is shown in the following
figure.
• The programmable AND gates have the access of both normal and complemented
inputs of variables. In the above figure, the inputs X, X′X′, Y, Y′Y′, Z & Z′Z′, are
available at the inputs of each AND gate. So, program only the required literals in
order to generate one product term by each AND gate.
• All these product terms are available at the inputs of each programmable OR gate.
But, only program the required product terms in order to produce the respective
Boolean functions by each OR gate. The symbol ‘X’ is used for programmable
connections.
2/26/2023 109
Combinational PLDs
2/26/2023 110
PAL
• PAL chips are usually identified by a two-digit number
followed by a letter and then a digit.
– Two-digit number specifies the number of input lines
– Last digit defines the number of output lines
– The fixed number of AND gates are connected to either an OR or a
NOR gate
– Letter H indicates that the output gates are OR gates
– Letter L indicates that the output gates are NOR gates
• Example: 10H8, 10L8
2/26/2023 111
Example: 01
• A processor having 16 bits address line and it
is byte addressable. Interface 4096x8 RAM
with the processor.
1. What is the memory capacity of the processor?
2. How many addresses are required for a RAM?/
3. How many RAM chips are required?
4. What will be the size of address decoder?
2/26/2023 112
Example: 02
• Interface two chips of 4k RAM and 1 chip of 2k
ROM. Starting address of RAM is 8000H.
2/26/2023 113
Memory Management Concepts
• Access to a hard disk is Slow.
• Solution: use a large and fast locally accessed semiconductor
memory SRAM.
• Unfortunately, the storage cost per bit for this solution is very
high.
• A combination of both off-board disk (secondary memory) and
on-board semiconductor main memory must be designed into a
system.
2/26/2023 114
Memory Management Concepts
Memory Management Unit (MMU):
A device, located between the microprocessor and memory
• The address used by a programmer will be called a logical address/
Virtual address
• An address in main memory is called a physical address
Control accesses, perform address mappings, and act as an interface
between the logical (programmer’s memory) and physical memory
2/26/2023 115
Memory Management Concepts
2/26/2023 117
Memory Management Concepts
MMU address translation: Memory is usually divided
into small manageable units:
• Page
• Segment.
• Combined Paging-Segmentation
• Paging divides the memory into equal sized pages
• Segmentation divides the memory into variable-
sized segments.
• It is relatively easier to implement the address translation table if the
logical and main memory spaces are divided into pages.
2/26/2023 118
Memory Management Concepts
The Paging method
• The virtual memory system is managed by both hardware and
software.
The hardware included in MMU handles address translation
The memory management software in operating system performs
functions such as
removal of the desired page from main memory to accommodate a new page
Transferring a new page from secondary to main memory at the right instant of time
Placing the page at the right location in memory
If the main memory is full during transfer from secondary to main
memory, it is necessary to remove a page from main memory to
accommodate the new page. Two methods:
FIFO
LRU
2/26/2023 119
Memory Management Concepts
2/26/2023 120
The Paging method
2/26/2023 121
Memory Management Concepts
The Segmentation method
• An MMU utilizes the Segment Selector to obtain a
descriptor from a table in memory containing several
descriptors.
Global Descriptor Table (GDT): Contains
1. The physical base address for a segment,
2. The segment’s privilege level,
3. Some control bits. Logical address
• Each program has: Selector Offset
Segment Descriptor +
GDTR/LDTR
Linear address
2/26/2023 122
(contains base address of
Each segment descriptor indexes into the program's
local descriptor table (LDT). Each table entry is mapped
to a linear address:
2/26/2023 123
Memory Management Concepts
The Segmentation method
1. When the MMU obtains a logical address from
the microprocessor
2. MMU determines whether the segment is
already in physical memory.
3. If it is, the MMU adds an offset component to
the segment base component of the address
obtained from the segment descriptor table to
provide the physical address.
4. MMU then generates the physical address on
the address bus for selecting the memory.
2/26/2023 124
Memory Management Concepts
The paged-segmentation method
• Each segment contains a number of pages.
• The logical address is divided into three
components: segment, page, and word.
• A page component of n bits can provide up to
2n pages.
• A segment can be assigned with one or more
pages up to maximum of 2n pages; therefore, a
segment size depends on the number of pages
assigned to it.
2/26/2023 125
Memory Management Concepts
• The Virtual memory: A technique that uses main
memory as a “cache” for secondary storage.
• virtual address: An address generated by a user program
is virtual address
• The key idea behind the virtual memory is to allow a user
program to address more locations than those available
in a physical memory.
• Two major motivations for virtual memory:
• to allow efficient and safe sharing of memory among multiple
programs
• to remove the programming burdens of a small, limited amount of
main memory.
• CPU and OS translate virtual addresses to physical
addresses
2/26/2023 126
Mapping Pages to Storage
2/26/2023 127
Paging with virtual addressing
Programs share main memory, each program gets a private virtual address space
holding its frequently used code and data and this is protected from other
programs.
2/26/2023 128