MP Print
MP Print
Sejal M Chopra
Program:
MOV AL, B4H; Control Word = 1011 0100 = B4H
OUT 86H, AL
Program:
MOV AL, B4H; Control Word = 1011 0100 = B4H
OUT 86H, AL
Q 3) Generate a square wave on a display device connected to PortC3 by BSR command. Assume
8255 is at 80H.
Solution:
Back: MOV AL, 06H
OUT 86H, AL // BSR Command (Send 0) = 0000 0110
CALL Delay
MOV AL, 07H
OUT 86H, AL // BSR Command (Send 1) = 0000 0111
CALL Delay
JMP Back
Q 4) WAP to generate “positive spikes” on a display device connected to PortC3 using BSR
command.
Solution:
Back: MOV AL, 06H
OUT 86H, AL // BSR Command (Send 0) = 0000 0110
CALL Delay
MOV AL, 07H
MICROPROCESSOR
Sejal M Chopra
Q 5) WAP to generate a rectangular wave with a 25% duty cycle on a display device connected to
PortC3 using BSR command.
Solution:
Back: MOV AL, 06H
OUT 86H, AL // BSR Command (Send 0) = 0000 0110
CALL Delay
CALL Delay
CALL Delay
MOV AL, 07H
OUT 86H, AL // BSR Command (Send 1) = 0000 0111
CALL Delay
JMP Back
Reason 1: Let us consider a keyboard interfaced serially to 8086 microprocessor as shown in Fig.
In the Fig, microprocessor receives ASCII code of a key serially, which is sent from keyboard after
the key hit. Here keyboard is mechanical device on which a user can type characters at rate up
to 130 words per minute and microprocessor is high speed semiconductor device, which accept
and process millions of words per second.There is no speed compatibility between these two
devices. To achieve the speed compatibility, place a semiconductor bidirectional buffer (called
as port in 8255 ) (synchronize the buffer and microprocessor) between microprocessor and
Keyboard.
MICROPROCESSOR
Sejal M Chopra
When key is hit, the ASCII code of the key transferred to buffer serially. If the buffer is full, then
it intimates the microprocessor through a separate signal (IBF) that it has received a key. Now
the microprocessor collects the entire 8-bit data by reading buffer. In this way, speed
compatibility is achieved. There are three programmable ports are available in 8255.
Reason 2: microcomputer is used for general purpose; so that many devices are interfaced to
microprocessor. For example, keyboard, mouse, printer, monitor, Hard drive, etc., To interface
all these devices to microprocessor require more buffers and I/O lines, which increases the
circuit complexity and space occupied. This can be solved by controlling fixed number of buffers
or PORTs programmatically. 8255 PPI has three bi-directional I/O PORTs (labeled A, B, C). These
ports are programmed as input/output using control word register and interface many devices
using time share basis using these fixed ports.
MICROPROCESSOR
Sejal M Chopra
2. Pin Diagram:
WRITE*: This control signal enables the write operation. When the signal goes low,
microprocessor writes data into a selected I/O Port or control register.
ADDRESS (A0, A1): These input signals, control the selection of one of the three ports
or the control word register. A0 and A1 are normally connected to the A1 and A2 bits of
the Address Bus of processor.
PA0 - PA7, PB0 - PB7, PC0 - PC7 : These signal lines are used as 8-bit I/O ports. They
can be connected to peripheral devices. The 8255 has three 8 bit I/O ports and each one
can be connected to the physical lines of an external device. These lines are labeled
PA0- PA7, PB0-PB7, and PC0-PC7. The groups of the signals are divided into three
different I/O ports labeled port A (PA), port B (PB), and port C (PC).
3. Architecture:
CS* A1 A0 SELECTION
0 0 0 PORT A
0 0 1 PORT B
0 1 0 PORT C
0 1 1 CONTROL REGISTER
1 X X 8255 IC NOT SELECTED
Group A and Group B Controls:
The functional configuration of each port is programmed by the systems software. In essence,
the CPU "outputs" a control word to the 8255. The control word contains information such as
"mode", "bit set", "bit reset", etc., that initializes the functional configuration of the 8255. Each
of the Control blocks (Group A and Group B) accepts "commands" from the Read/Write Control
logic, receives "control words" from the internal data bus and issues the proper commands to its
associated ports.
Ports A, B, and C:
The 8255 contains three 8-bit ports (A, B, and C). All can be configured to a wide variety of
functional characteristics by the system software but each has its own special features or
"personality" to further enhance the power and flexibility of the 8255.
Port A One 8-bit data output latch/buffer and one 8-bit data input latch. Both "pull-up" and
"pull-down" bus-hold devices are present on Port A.
Port B One 8-bit data input/output latch/buffer and one 8-bit data input buffer.
Port C One 8-bit data output latch/buffer and one 8-bit data input buffer (no latch for input).
This port can be divided into two 4-bit ports under the mode control. Each 4-bit port contains a
4-bit latch and it can be used for the control signal output and status signal inputs in conjunction
with ports A and B.
2. Operating Modes:
BSR mode is used only for port C wherein the individual bits can be set/reset .
It is used while interfacing devices like A to D converter or a seven segment display.
It will not affect the I/O operations of 8255.
MICROPROCESSOR
Lecturer: Sejal Chopra
Write a program assuming IC 8255 is working in BSR mode with port A address configured at 60H for
the following cases: a) To reset bit 6 of port C b) To set bit 4 of port C c) To glow LEDs connected on
PC3 and PC7
Write a program to blink an LED connected on port C bit 2 of IC 8255 (working in BSR mode) with port
A address configured at 61H.
MICROPROCESSOR
Lecturer: Sejal Chopra
Program:
LABEL: MOV AL, 05H
OUT 67H, AL
CALL DELAY
MOV AL, 04H
OUT 67H, AL
CALL DELAY
JMP LABEL
DELAY SUBROUTINE:
MOV CL, FFH
LABEL: DEC CL
JNZ LABEL
INTR is set by the condition: STB* == 1, IBF == 1 and INTE == 1. It is reset by the falling edge of
RD*.
Timing diagram:
Timing Diagram:
MICROPROCESSOR
Lecturer: Sejal M Chopra
Viva Question: In case of simultaneous occurrence of signals on the following pins which has
highest priority?
RESET (1)
HOLD (2)
NMI (3)
INTR (4)
MICROPROCESSOR
Lecturer: Sejal M Chopra
2. Features:
It is a device to transfer the data directly between IO device and memory without through the
CPU. So it performs a high-speed data transfer between memory and I/O device.
It has four channels which can be used over four I/O devices.
Each channel has 16-bit address and 14-bit counter, can transfer data up to 64KB, can be
programmed independently and can have either fixed or rotating priority mode.
Each channel can perform either of the three DMA operations: read transfer, write transfer and
verify transfer operations.
It generates MARK signal to the peripheral device that 128 bytes have been transferred.
Its frequency ranges from 250Hz to 3MHz.
It operates in either Master mode or Slave mode.
It has four data transfer modes: Single, Block, demand and cascade transfer modes
Viva Question: What is the difference between DMA read, DMA write and DMA verify
operations?
• DMA read: DMA reads from memory and writes into an I/O, active signal are MEMR* &
IOW*
• DMA write: DMA reads from an I/O and writes into memory, active signal are IOR* &
MEMW*
• DMA verify: no data transfer takes place, error detection and correction technique is
implemented wherein data transferred is verified.
Viva Question: What is the difference between fixed and rotating priority mode?
In the fixed priority, channel 0 has the highest priority and channel 3 has the lowest priority.
In rotating priority mode, the priority of the channels has a circular sequence. In this, channel
being serviced gets the lowest priority and the channel next to it gets the highest priority.
MICROPROCESSOR
Lecturer: Sejal M Chopra
3. Pin Diagram:
DRQ0−DRQ3 :
These are the four individual channel DMA request inputs, which are used by the peripheral devices
for using DMA services. When the fixed priority mode is selected, then DRQ 0 has the highest priority
and DRQ3 has the lowest priority among them.
DACKo* − DACK3*:
These are the active-low DMA acknowledge lines, which updates the requesting peripheral about the
status of their request by the CPU.
Do − D7:
These are bidirectional, data lines which are used to interface the system bus with the internal data
bus of DMA controller. In the Slave mode, it carries command words to 8257 and status word from
8257. In the master mode, these lines are used to send higher byte of the generated address to the
latch.
IOR*:
It is an active-low bidirectional input line, which is used by the CPU to read internal registers of 8257
in the Slave mode. In the master mode, it is used to read data from the peripheral devices during a
memory write cycle.
IOW*:
It is an active low bi-direction line, which is used to load the contents of the data bus to the 8-bit
mode register or upper/lower byte of a 16-bit DMA address register or terminal count register. In the
master mode, it is used to load the data to the peripheral devices during DMA memory read cycle.
CLK:
It is a clock frequency signal which is required for the internal operation of 8257.
RESET:
This signal is used to RESET the DMA controller by disabling all the DMA channels.
Ao - A3:
These are the four least significant address lines. In the slave mode, they act as an input, which
selects one of the registers to be read or written. In the master mode, they are the four least
significant memory address output lines generated by 8257.
CS*:
It is an active-low chip select line. In the Slave mode, it enables the read/write operations to/from
8257. In the master mode, it disables the read/write operations to/from 8257.
A4 - A7:
These are the higher nibble of the lower byte address generated by DMA in the master mode.
MICROPROCESSOR
Lecturer: Sejal M Chopra
READY:
It is an active-high asynchronous input signal, which makes DMA ready by inserting wait states.
HRQ:
This signal is used to receive the hold request signal from the output device. In the slave mode, it is
connected with a DRQ input line 8257. In Master mode, it is connected with HOLD input of the CPU.
HLDA:
It is the hold acknowledgement signal which indicates the DMA controller that the bus has been
granted to the requesting peripheral by the CPU when it is set to 1.
MEMR*:
It is the low memory read signal, which is used to read the data from the addressed memory
locations during DMA read cycles.
MEMW*:
It is the active-low three state signal which is used to write the data to the addressed memory
location during DMA write operation.
ADSTB:
This signal is used to convert the higher byte of the memory address generated by the DMA controller
into the latches.
AEN:
This signal is used to disable the address bus/data bus.
TC:
It stands for ‘Terminal Count’, which indicates the present DMA cycle to the present peripheral
devices.
MARK:
The mark will be activated after each 128 cycles or integral multiples of it from the beginning. It
indicates the current DMA cycle is the 128th cycle since the previous MARK output to the selected
peripheral device.
Vcc:
It is the power signal which is required for the operation of the circuit.
4. Block Diagram:
MICROPROCESSOR
Lecturer: Sejal M Chopra
When the CPU is programming or reading one of the internal registers of 8257 (i.e, when the
8257 is in the slave mode), the Read/Write logic accepts the I/O Read (IOR*) or I/O Write
(IOW) signal, decodes the least significant four address bits (A0 – A3) and either writes the
contents of the data bus into the addressed register (if IOW* is low) or places the contents of
the addressed register onto the data bus (if IOR*is low).
During DMA cycles (i.e. when the 8257 is in the master mode) the Read/Write logic generates
the I/O read and memory write (DMA write cycle) or I/O write and memory read (DMA read
cycle) signals which control the data transfer between peripheral and memory device.
Channels:
Provides four identical channels, labeled CH0 to CH3. Each channel has two sixteen bit registers:
DMA address register : It specifies the address of the first memory location to be accessed. It is
necessary to load valid memory address in the DMA address register before channel is enabled.
Control logic:
It controls the sequence of operations during all DMA cycles (DMA read, DMA write, DMA verify) by
generating the appropriate control signals and the 16-bit address that specifies the memory location
to be accessed. It consists of mode set register and status register. Mode set register is programmed
by the CPU to configure 8257 whereas the status register is read by CPU to check which channels
have reached a terminal count condition and status of update flag.
MICROPROCESSOR
Lecturer: Sejal M Chopra
Least significant four bits of mode set register, when set, enable each of the four DMA channels.
Most significant four bits allow four different options for the 8257 .It is normally programmed by the
CPU after initializing the DMA address registers and terminal count registers. It is cleared by the
RESET input, thus disabling all options, inhibiting all channels, and preventing bus conflicts on
power-up.
1. Enable/disable a channel.
2. Fixed/rotating priority
3. Stop DMA on terminal count.
4.Extended/normal write time.
5. Auto reloading of channel-2.
The bits B0, B1, B2, and B3 of mode set register are used to enable/disable channel -0, 1, 2 and 3
respectively. A one in these bit position will enable a particular channel and a zero will disable it.
If the bit B4 is set to one, then the channels will have rotating priority and if it zero then the
channels wilt have fixed priority.
If the bit B5 is set to one, then the timing of low write signals (MEMW and IOW) will be extended.
If the bit B6 is set to one then the DMA operation is stopped at the terminal count.
The bit B7 is used to select the auto load feature for DMA channel-2.
When bit B7 is set to one, then the content of channel-3 count and address registers are loaded in
channel-2 count and address registers respectively whenever the channel-2 reaches terminal count.
When this mode is activated the number of channels available for DMA reduces from four to three.
Status Register:
It indicates which channels have reached a terminal count condition and includes the update flag
described previously.
The bit B0, B1, B2, and B3 of status register indicates the terminal count status of channel-0, 1,2 and
3 respectively. A one in these bit positions indicates that the particular channel has reached terminal
count.
The bit B4 of status register is called update flag and a one in this bit position indicates that the
channel-2 register has been reloaded from channel-3 registers in the auto load mode of operation.
Priority Resolver:
It resolves the peripherals requests. It can be programmed to work in two modes, either in fixed
mode or rotating priority mode.
DMA address register, terminal count register, Mode Set Register and Status Register
MICROPROCESSOR
Lecturer: Sejal M Chopra
Once the DMAC becomes the bus master, it will transfer only ONE BYTE and return the bus
back to the microprocessor. As soon as the microprocessor performs one bus cycle, DMAC will
once again take the bus back from the microprocessor.
Both DMAC and microprocessor are constantly stealing bus cycles from each other. It is the
most popular method of DMA, because it keeps the microprocessor active in the background.
For further bytes to be transferred, the DREQ line must go active again, and then the entire
operation is repeated.
In this mode, the DMAC is programmed to transfer all the bytes in one complete DMA
operation.
The system bus is returned to the µP, only after all the bytes are transferred. i.e. TC is
reached or EOP signal is issued. It is the fastest form of DMA but keeps the microprocessor
inactive for a long time.
The DREQ signal needs to be active only in the beginning for requesting the DMA service
initially. Thereafter DREQ can become low during the transfer.
It is very similar to Block Transfer, except that the DREQ must active throughout the DMA
operation.
If during the operation DREQ goes low, the DMA operation is stopped and the busses are
returned to the µP.
In the meantime, the µP can continue with its own operations. Once DREQ goes high again,
the DMA operation continues from where it had stopped.
In this mode, more than one DMACs are cascaded together. It is used to increase the number
of devices interfaced to the µP. Here we have one Master DMAC, to which one or more Slave
DMACs are connected.
The Slave gives HRQ to the Master on the DREQ of the Master, and the Master gives HRQ to
the µP on the HOLD of the µP.
MICROPROCESSOR
Lecturer: Sejal M Chopra
Programming IC 8259
1. Initialization Sequence:
The 8259 accepts two types of command words generated by the CPU:
1. Initializat ion Command Words (ICWs): Before normal operation can begin, each 8259 in the
system must be brought to a starting point by a sequence of 2 to 4 bytes timed by WR* pulses.
2. Operation Command Words (OCWs): These are the command words which command the
8259 to operate in various interrupt modes. These modes are:
a. Fully nested mode
b. Rotating priority mode
c. Special mask mode
d. Polled mode
The OCWs can be written into the 8259 anytime after initializat ion.
f. If IC4 = 0, then all functions selected in ICW4 are set to zero. (Non-Buffered mode*, no
Auto-EOI).
Programming Exercise:
1. Write a program to initialize a single 8259 IC with the following specification:
• It should be edge triggered working in EOI mode as well as non -buffered mode.
• IR1 and IR5 should be masked.
• Vector no .of IR0 is 60 H.
• Assume that 8259 is at port address 80 H.
2. Write a program to initialize a cascaded 8259 IC ‘s with one master and two slaves on
IR1 and IR3 of master with the following specification:
• Master:Port address is 10 H.Vector no.of IR5 is 95 H.It is edge triggered ,AEOI
mode,special fully nested mode and scanner is connected to IR7.
• Slave1: Port address is 70 H.Vector no.of IR0 is 80 H.It is edge triggered ,normal EOI
mode,printer and keyboard is connected to IR3 and IR5.
• Slave2: Port address is 90 H.Vector no.of IR3 is 62 H.It is level triggered ,AEOI
mode,external interrupts on IR1,IR2,IR3 and IR7.
• For all the above 8259 IC’s mask the unwanted interrupts.
Solution:
1. Calculate the selection address as follows:
Selection A7 A6 A5 A4 A3 A2 A1(CONNECTED A0(USED
Address TO A0 OF FOR
Command 8259) BANKING)
words
ICW1 1 0 0 0 0 0 0 0
ICW2 1 0 0 0 0 0 1 0
ICW4 1 0 0 0 0 0 1 0
OCW1 1 0 0 0 0 0 1 0
Program:
M OV AL,17H
OUT 80H,AL
M OV AL,60H
OUT 82H,AL
MICROPROCESSOR
Lecturer: Sejal M Chopra
M OV AL,01H
OUT 82H,AL
M OV AL,22H
OUT 82H,AL
Program:
M OV AL,15H
OUT 10H,AL
M OV AL,90H
OUT 12H,AL
M OV AL,0AH
OUT 12H,AL
M OV AL,13H
OUT 12H,AL
M OV AL,75H
OUT 12H,AL
SLAVE1:
The selection address (I/O map) as follows:
Selection A7 A6 A5 A4 A3 A2 A1(CONNECTED A0(USED
Address TO A0 OF FOR
Command 8259) BANKING)
words
ICW1 0 1 1 1 0 0 0 0
ICW2 0 1 1 1 0 0 1 0
ICW3 0 1 1 1 0 0 1 0
ICW4 0 1 1 1 0 0 1 0
OCW1 0 1 1 1 0 0 1 0
Program:
M OV AL,15H
OUT 70H,AL
M OV AL,80H
OUT 72H,AL
M OV AL,01H
OUT 72H,AL
M OV AL,01H
OUT 72H,AL
M OV AL,D7H
OUT 72H,AL
SLAVE2:
The selection address (I/O map) as follows:
Selection A7 A6 A5 A4 A3 A2 A1(CONNECTED A0(USED
Address TO A0 OF FOR
Command 8259) BANKING)
words
ICW1 1 0 0 1 0 0 0 0
ICW2 1 0 0 1 0 0 1 0
MICROPROCESSOR
Lecturer: Sejal M Chopra
ICW3 1 0 0 1 0 0 1 0
ICW4 1 0 0 1 0 0 1 0
OCW1 1 0 0 1 0 0 1 0
Program:
M OV AL,1DH
OUT 90H,AL
M OV AL,5FH
OUT 92H,AL
M OV AL,03H
OUT 92H,AL
M OV AL,03H
OUT 92H,AL
M OV AL, 71H
OUT 92H,AL
TE
MICROPROCESSOR
1. Features:
The 8259 is a device specifically designed for using real time, interrupt driven
microcomputer systems.
The 8259 programmable interrupt controller (PIC) adds eight vectored priority encoded
interrupts to the microprocessor.
This controller can be expanded to accept up to 64 interrupt requests. This requires a
master 8259 and eight 8259 slaves.
Vector an Interrupt request anywhere in the memory map.
Resolve eight levels of interrupt priorities in a variety of modes, such as fully nested mode,
automatic rotation mode, and specific rotation mode. The priority modes can be changed or
reconfigured dynamically at any time during the main program.
Mask each of the interrupt request individually.
Read the status of the pending interrupts, in-service interrupts and masked interrupts.
It issues a single interrupt request to the CPU.
In response to the INTA/, it issues a unique type number (vector) for each interrupt request
input. In addition, type numbers are programmable.
This means that the complete interrupt structure can be defined as required, based on the
total system environment.
2. Block Diagram:
INT (Interrupt):
This output goes directly to the CPU interrupt input. The VOH level on this line is
designed to be fully compatible with the 8080A, 8085A and 8086 input levels.
INTA (Interrupt Acknowledg e)* :
INTA* pulses will cause the 8259 to release vectoring information onto the data bus.
The format of this data depends on the system mode of the 8259.
Data Bus Buffer:
This 3-state, bidirectional 8-bit buffer is used to interface the 8259 to the system
Data Bus. Control words and status information are transferred through the Data Bus Buffer.
Read/Write Control Logic:
The function of this block is to accept OUTput commands from the CPU. It contains
the Initialization Command Word (ICW) registers and Operation Command Word (OCW)
registers which store the various control formats for device operation. This function block
also allows the status of the 8259 to be transferred onto the Data Bus.
CS (Chip Select)*:A LOW on this input enables the 8259. No reading or writing of the chip
will occur unless the device is selected.
WR (Write)*:A LOW on this input enables the CPU to write control words (ICWs and OCWs)
to the 8259.
RD (READ)*: A LOW on this input enables the 8259 to send the status of the Interrupt
Request Register (IRR), In Service Register (ISR), the Interrupt Mask Register (IMR), or the
Interrupt level onto the Data Bus.
A0:This input signal is used in conjunction with WR* and RD* signals to write commands into
the various command registers, as well as reading the various status registers of the chip.
This line is tied directly to A1of address lines.
The Cascade Buffer/Comp arator:
This function block stores and compares the IDs of all 8259's used in the system. The
associated three I/O pins (CAS0-2) are outputs when the 8259 is used as a master and are
inputs when the 8259A is used as a slave. As a master, the 8259 sends the ID of the
interrupting slave device onto the CAS0±2 lines. The slave thus selected will send its
preprogrammed subroutine address onto the Data Bus during the next one or two
consecutive INTA* pulses.
SP*/EN*:If the IC works in buffered mode ,EN* works as an output line wherein the outputs
of the data bus buffer are allowed .In non-buffered mode ,it works as an input line to
distinguish between the master and slave PIC’s.If SP* (slave Program)is connected to gnd,it
is a slave IC and if it is connected to Vcc it is master IC.
Viva Question: Which one is preferred: Level triggering or edge triggering on IR0 –IR7
lines?
Because output can change in precise amount of time while dealing with edge triggered
lines.
3.8259-Interrupt sequence:
TE
MICROPROCESSOR
One or more of the INTERRUPT REQUEST lines (IR7-IR0) are raised high, setting the
corresponding IRR bit(s).
The 8259A evaluates these requests, and sends an INT to the CPU, if appropriate.
The CPU acknowledges the INT and responds with an INTA/ pulse.
Upon receiving an INTA/ from the CPU, the highest priority ISR bit is set, and the
corresponding IRR bit is reset. The 8259 does not drive the data bus this cycle.
The 8088/8086 will initiate a second INTA/ pulse. During this pulse, the 8259 releases an 8-
bit pointer onto the Data Bus where it is read by the CPU.
This completes the interrupt cycle. In the AEOI mode, the ISR bit is reset at the end of the
second INTA/ pulse. Otherwise, the ISR bit remains set until the appropriate EOI command is
issued at the end of the Interrupt Service Routine (ISR).
The IRR is a transparent latch. Bits of IRR are frozen by the FREEZE/ signal starting at the
beginning of first INTA/ pulse till the end of the second INTA/ pulse.
Whatever interrupt requests arrive at the IRR will be latched transparently.
If the interrupt request is not masked as per the Interrupt Mask Register (IMR), it will reach
to the Priority Resolver (PR).
IF new request’s priority is higher than the interrupt under service, INT signal is raised by the
PR to make a request to the CPU.
After some time, the CPU sends the first INTA/ pulse. Now the requests in IRR are frozen,
and the highest priority interrupt is identified by the PR. The corresponding bit in the ISR is
set, and the corresponding bit of IRR is cleared.
During the second INTA/ pulse, the vector type is sent out, and then the INT signal is
lowered.
The ISR records the requests currently being serviced.
It enables the 8259 to check whether any of the incoming new requests has higher priority
than the priority of the currently in-service requests. If so, the 8259 will again raise the INT
signal and wait for INTA/.
The ISR bit(s) get cleared.
At the end of the ISR, there should be an instruction to send End of Interrupt (EOI) command
to the 8259. Then the highest priority ISR bit gets reset.
Note: If End Of Interrupt (EOI) is not issued at the end of ISR, all interrupt requests of equal
or lower priority remain blocked until the ISR bit is cleared.
For nesting of interrupts, ISR bit is reset at the end of the second INTA/ pulse (It is a
programmable feature called Automatic End of Interrupt (AEOI)).
MICROPROCESSOR
Sejal M Chopra
Decoding Techniques
Address Decoding Techniques in 8086 Microprocessor:
Note: Used for interfacing RAM and ROM chips
1. Absolute Decoding :
In absolute decoding technique the memory chip is selected only for the specified logic level on
the address lines; no other logic levels can select the chip. Fig shows the memory interface with
absolute decoding. Two 8K EPROMs (2764) are used to provide even and odd memory banks. BHE*
and A0 are used to enable outputs of odd and even memory banks respectively. As each memory
chip has 8K memory locations, thirteen address lines are required to address each locations,
independently. All remaining address lines are used to generate an unique chip select signal.
This addressing technique is normally used in large, memory systems.
Block Decoding:
In a microcomputer system the memory array is often consists of several blocks of memory chips.
Each block of memory requires decoding circuit. To avoid separate decoding for each memory
block special decoder IC is used to generate chip select signal for each block. Fig. shows the
block Address Decoding Techniques in 8086 Microprocessor using 74138, 3:8 decoder.
MICROPROCESSOR
Sejal M Chopra
2.Linear Decoding :
In small systems, hardware for the decoding logic can be eliminated, by using only required
number of addressing lines (not all). Other lines are simply ignored. This technique is referred as
Linear Decoding or Partial Decoding. Fig. shows the addressing of 16K RAM (6264) with linear
decoding. BHE* and A0 are used to, enable odd and even memory banks, respectively. The
address line A19 is used to select the RAM chips. When A19 is low, chip is selected, otherwise it is
disabled. The status of A14 to A18 does not affect the chip selection logic. This gives you multiple
addresses (shadow addresses). This technique reduces the cost of Address Decoding Techniques
in 8086 Microprocessor circuit, but it has drawback of multiple addresses.
MICROPROCESSOR
Sejal M Chopra
Designing Examples
Design an 8086 based Maximum Mode system working at 6 MHz having the following:
32KB EPROM using 16KB chips,
128KB RAM using 32KB chips,
Note:
** Every designing problem has three components:
1) Mode of Operation of 8086 processor: Minimum mode or Maximum mode
2) Memory Interfacing: Using ROM and RAM chips (we will construct a Memory Map and
interfacing diagram)
3) I/O Interfacing: Using 8255 ICs (not in syllabus)
Solution:
1) Mode of Operation:
Show 8086 max. mode configuration with a crystal of 18 MHz.
2) Memory Calculations:
EPROM:
Required size = 32 KB, Available size = 16 KB
No. of chips required = Required size / Available size =2 chips.
No. of sets required= No. of chips required/ No. of banks= 2/2=1
Set size= Available Chip size x no .of banks= 16 x 2= 32 KB=32 x 1KB= 25 x 210 =215
A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 7 F F F
Ending Address=FFFFFH
Starting address of EPROM is calculated as:
=Ending Address – Set size
=F F F F F H- 7 F F F H=F8000H
MICROPROCESSOR
Sejal M Chopra
RAM:
Required size = 128 KB, Available size = 32 KB
No. of chips required = Required size / Available size = 4 chips.
No. of sets required= No. of chips required/ No. of banks= 4/2=2
Set size= Available Chip size x no .of banks= 32 x 2= 64 KB=64 x 1KB= 2 6 x 210 =216
A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 F F F F
No. of address lines required for interfacing is dependent on size of a single available RAM chip
= 32 KB
= 32 x 1 KB = 25 x 210
= 215
= 15 address lines
= (A15 … A1)…. note A0 is reserved for banking….IMPORTANT during interfacing
MICROPROCESSOR
Sejal M Chopra
MEMORY MAP
Memory Interfacing:
Step1: Interfacing RAM set1
MICROPROCESSOR
Sejal M Chopra
4) Depending on the address lines used, sometimes we need to use either 2:4 decoder(IC-
74139) or3:8 decoder(IC 74138) or 4:16 decoder(74154)
5) Specifications of these decoders are as follows:
2:4 decoder (IC-74139): It has 2 inputs and 4 active low outputs. It has one active low G pin.
3:8 decoder (IC 74138): It has 3 inputs and 8 active low outputs. It has one active high G 1 pin
and two active low G2A and G2B pin.
4:16 decoder (74154): It has 4 inputs and 16 active low outputs. It has two active low G 1 and
G2 pin.
Practise Question:
Design an 8086 based system working at 7 MHz having the following:
128KB EPROM using 32KB chips,
32KB RAM using 8KB chips,
Two 8-bit input and two 8-bit output ports all interrupt driven
Solution:
Memory Calculations:
EPROM:
Required size = 128 KB, Available size = 32 KB
No. of chips required = Required size / Available size =4 chips.
No. of sets required= No. of chips required/ No. of banks= 4/2=2
Set size= Available Chip size x no .of banks= 32 x 2= 64 KB=64 x 1KB= 2 6 x 210 =216
A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 F F F F
RAM:
Required size = 32 KB, Available size = 8 KB
No. of chips required = Required size / Available size = 4 chips.
No. of sets required= No. of chips required/ No. of banks= 4/2=2
Set size= Available Chip size x no .of banks= 8 x 2= 16 KB=16 x 1KB= 2 4 x 210 =214
A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 3 F F F
No. of address lines required for interfacing is dependent on size of a single available RAM chip
= 8 KB
= 8 x 1 KB = 23 x 210
= 213
= 13 address lines
= (A13 … A1)…. note A0 is reserved for banking….IMPORTANT during interfacing
Draw the memory map further for this question and also interfacing diagram.
Interfacing the 8259 in single and cascaded mode
Figure below shows that how an 8259 can be interfaced with the 8086 microprocessor
system in minimum mode. In case of 8088 microprocessor same interfacing diagram can be
used except M/I0 signal.
The A0 input of the 8259A is used to select one of the two internal addresses in the device.
Ao of the 8259A is connected to system line Al.
The data lines of an 8259 are connected to the lower half of the system data bus; because
the 8086 expects to receive interrupt types on these lower eight data lines.
RD and WR signals are connected to the system RD and WR lines.
The interrupt request signal INT from the 8259 is connected to the INTR input of the 8086
and INTA from the 8086 is connected to INTA on the 8259A. As we are using single 8259 in
the system SP/EN pin is tied high and CAS0-CAS2 lines are left open.
The eight IR inputs are available for interrupt signals.
Interfacing the 8259 in cascaded mode:
The 8259 can be easily interconnected to get multiple interrupts.
Fig below shows how 8259 can be connected in the cascade mode.
In cascade mode one 8259 is configured in Master mode and other should be configured in
the Slave mode. In this figure 8259 is in the master mode and others are in slave mode.
Each slave 8259 is identified by the number which is assigned as a part of its initialization.
Since the 8086 has only one INTR input, only one of the 8259 INT pins is connected to the
8086 INTR pin. The 8259 connected directly into the 8086 INTR pm is referred as the
master.
The INT pins from other 8259 are connected to the IR inputs of the master 8259. These
cascaded 8259s are referred as slave. The INTA signal is connected to both master and slave
8259.
The cascade pins CAS0 to CAS2 are connected from the master to the corresponding pins of
the slave. For the master these pins function as outputs, and for the slave these pins
function as inputs. The SP/EN signal is tied high for the master. However it is grounded for
the slave.
Each 8259A has its own addresses so that command words can be written to it and status
bytes read from it.
Master and slave operation:
When the slave receives an interrupt signal on one of its IR inputs, it checks mask condition and
priority of the interrupt request. If the interrupt is unmasked and its priority is higher than any
other interrupt level being serviced in the slave, then the slave will send an NT signal to the IR
input of a master. If that IR input of the master is unmasked and if that input is a higher priority
than any other IR inputs currently being serviced, then the master will send an INT signal to the
8086 INTR input. If the INTR interrupt is enabled, the 8086 will go through its INTR interrupt
procedure and sends out two INTA pulses to both the master and the slave. The slave ignores the
first interrupt acknowledge pulse but the master outputs a 3-bit slave identification number on the
CAS0-CAS2 lines. Sending the 3-bit ID number enables the slave. When the slave receives the
second INTA pulse from the 8086, the slave will send the desired type number to the 8086 on the
eight data lines. If an interrupt signal is applied directly to one of the IR inputs of the master, the
master will send the desired interrupt type to the 8086 when it receives the second INTA pulse from
the 8086.
MICROPROCESSOR
Sejal M Chopra
Pentium 4
There are four main sections: the in-order front end, the out-of-order execution engine, the integer and
floating-point execution units, and the memory subsystem.
In-Order Front End:
The in-order front end is the part of the machine that fetches the instructions to be executed next in the
program and prepares them to be used later in the machine pipeline.
Its job is to supply a high-bandwidth stream of decoded instructions to the out-of-order execution core,
which will do the actual completion of the instructions. The front end has highly accurate branch prediction
logic that uses the past history of program execution to speculate where the program is going to execute
next.
The predicted instruction address, from this front-end branch prediction logic, is used to fetch instruction
bytes from the Level 2 (L2) cache.
These IA-32 instruction bytes are then decoded into basic operations called uops (micro-operations) that
the execution core is able to execute.
The NetBurst microarchitecture has an advanced form of a Level 1 (L1) instruction cache called the
ExecutionTrace Cache.
Unlike conventional instruction caches, the Trace Cache sits between the instructions decode logic and
execution core as shown in Figure 1.
In this location the Trace Cache is able to store the already decoded IA-32 instructions or uops.
Storing already decoded instructions removes the IA-32 decoding from the main execution loop.
Typically the instructions are decoded once and placed in the Trace Cache and then used repeatedly from
there like a normal instruction cache on previous machines.
The IA-32 instruction decoder is only used when the machine misses the Trace Cache and needs to go to the
MICROPROCESSOR
Sejal M Chopra
Memory Subsystem:
Figure 1 also shows the memory subsystem. This includes the L2 cache and the system bus.
The L2 cache stores both instructions and data that cannot fit in the Execution Trace Cache and the L1
data cache.
The external system bus is connected to the backside of the second-level cache and is used to access main
memory when the L2 cache has a cache miss, and to access the system I/O resources.
MICROPROCESSOR
Sejal M Chopra
4. Hyper-Threading (HT)
Hyper-Threading (HT) concept was introduced by Intel on desktop CPUs with the Pentium 4 HT. Pentium 4
is a single CPU core and cannot perform multi-tasking and in order to address this situation, Hyper
threading allows the two logical CPU cores to share physical execution resources. HT enables multiple
threads which are sequences of instruction to be run by each core to make the CPU run more efficiently.
MICROPROCESSOR
Sejal M Chopra
Uses of Hyper-threading
When the hyper-threading is enabled, each logical core of processor can act independently and can be
interrupted, halted and operated separately from the other virtual processor sharing the same core. In this
process, when one logical core is idle, the second core can take over the resources of other logical core.
Hyper threading allows the processor to work on more instruction threads in a given time. Hyper threading is
a hardware-based virtualization at the processor hardware level. Applications that take benefit of hyper-
threading are heavy-duty audio/video transcoding apps and scientific applications built for maximum multi-
threaded performance. By using hyper-threading performance can be boost up to 30%.
HT Technology is applied where multiple tasks are scheduled so that there will be no idle time on your
processor. Video editing, 3D rendering are examples of hyper-threading. Hyper Threading does not increase
the cores of processors; it will only help to handle the task efficiently. Hyper Threading technology enables
each core to run two threads at same time parallelly.
Hyper-Threading Performance
Hyper Threading increases the performance of CPU cores by enabling hyper-threading feature. Multiple
threads are sequences of the instructions to be run by each core to make the CPU operate more efficiently.
CPU can execute more tasks in the same amount of time. Hyper threading only helps to handle the
instructions. With Hyper Threading, the OS will recognize each physical core as 2 virtual or logical cores.
Eventually, Hyper threading virtually doubles the number of cores that are on the CPU. Dual-core processors
acts like a virtual quad-core processor.
Hyper Threading Technology improves the utilization of CPU resources so that a second thread can be
processed in the same processor. Hyper Threading provides two logical processors in a single processor
package. Hyper Threading Technology offers:
HT is responsible for generating extra heat. Cores are made to perform additional calculations per cycle,
which results in more leakage, consequently more heat, which negatively impacts overclocking.
MICROPROCESSOR
Sejal M Chopra
Pentium Processor
1. Features of Pentium:
Introduced in 1993 with clock frequency ranging from 60 to 66 MHz
It has data bus of 64 bit and address bus of 32-bit
There are two separate 8kB caches – one for code and one for data.
The primary changes in Pentium Processor were:
Superscalar Architecture
Dynamic Branch Prediction
Pipelined Floating-Point Unit
Separate 8K Code and Data Caches
Writeback MESI Protocol in the Data Cache
64-Bit Data Bus
Bus Cycle Pipelining
2. Pentium Architecture:
University Question: Draw and explain Pentium Processor architecture. Highlight architectural features
There are two separate 8kB caches – one for code and one for data. Each cache has a separate
address translation TLB which translates linear addresses to physical.
Code Cache:
2 way set associative cache
256 lines b/w code cache and prefetch buffer, permitting prefetching of 32 bytes (256/8) of
instructions
Prefetch Buffers:
Four prefetch buffers within the processor works as two independent pairs.
▪ When instructions are prefetched from cache, they are placed into one set of prefetch buffers.
▪ The other set is used as when a branch operation is predicted.
Prefetch buffer sends a pair of instructions to instruction decoder
Instruction Decode Unit:
It occurs in two stages – Decode1 (D1) and Decode2(D2)
D1 checks whether instructions can be paired
D2 calculates the address of memory resident operands
Control Unit :
This unit interprets the instruction word and microcode entry point fed to it by Instruction
Decode Unit
It handles exceptions, breakpoints and interrupts.
It controls the integer pipelines and floating point sequences
Microcode ROM :
Stores microcode sequences
Arithmetic/Logic Units (ALUs) :
There are two parallel integer instruction pipelines: u-pipeline and v-pipeline
The u-pipeline has a barrel shifter
The two ALUs perform the arithmetic and logical operations specified by their instructions in their
respective pipeline
Address Generators :
Two address generators (one for each pipeline) form the address specified by the ins tructions in
their respective pipeline.
They are equivalent to segmentation unit.
Paging Unit :
If enabled, it translates linear address (from address generator) to physical address
It can handle two linear addresses at the same time to support both pipelines with one TLB per
cache
Floating Point Unit:
It can accept upto two floating point operations per clock when one of the instruction is an
exchange instruction
Three types of floating point operations can operate simultaneously within FPU: addition, divi sion
and multiplication.
Data Cache:
MICROPROCESSOR
Sejal M Chopra
It is an 8KB write-back , two way set associative cache with line size of 32 bytes
Bus Unit:
Address Drivers and Receivers:
Push address onto the processor’s local address bus (A31:A3 and BE7:BE0)
Data Bus Transceivers:
gate data into the processor ‘s local data bus
Bus Control Logic:
controls whether a standard or burst bus cycle is to be run
Branch Target Buffer: supplies jump target prefetch addresses to the code cache
3. Superscalar Operation:
UQ: Explain with block diagram how superscalar operation is carried out in Pentium Processor
• The prefetcher sends an address to code cache and if present, a line of 32 bytes is send to one of
the prefetch buffers
• The prefetch buffer transfers instructions to decode unit
• Initially it checks if the instructions can be paired.
• If paired, one goes to ‘u’ and other goes to ‘v’ pipeline as long as no dependencies exist between
them.
• Pair of instructions enter and exit each stage of pipeline in unison.
MICROPROCESSOR
Sejal M Chopra
4. Integer Pipeline:
UQ: Explain in brief integer instruction pipeline stages of Pentium
• The pipelines are called “u” and “v” pipes.
• The u-pipe can execute any instruction, while the v-pipe can execute “simple”
instructions as defined in the “Instruction Pairing Rules”.
• When instructions are paired, the instruction issued to the v -pipe is always the next sequential
instruction after the one issued to u-pipe.
The integer pipeline stages are as follows:
Prefetch (PF):
Instructions are prefetched from the on-chip instruction cache
Decode1 (D1):
Two parallel decoders attempt to decode and issue the next two sequential instructions
MICROPROCESSOR
Sejal M Chopra
Decode2 (D2):
Decodes the control word
Address of memory resident operands are calculated
Execute (EX):
The instruction is executed in ALU
Data cache is accessed at this stage
For both ALU and data cache access requires more than one clock.
Writeback(WB):
The CPU stores the result and updates the flags
MICROPROCESSOR
Sejal M Chopra
Prefetch(PF) :
Instructions are prefetched from the on-chip instruction cache
Instruction Decode(D1):
Two parallel decoders attempt to decode and issue the next two sequential instructions
It decodes the instruction to generate a control word
A single control word causes direct execution of an instruction
Complex instructions require microcoded control sequencing
Address Generate (D2):
Decodes the control word
Address of memory resident operands are calculated
Memory and Register Read (Execution Stage) (EX):
Register read, memory read or memory write performed as required by the instruction to access
an operand.
Floating Point Execution Stage 1(X1):
Information from register or memory is written into FP register.
Data is converted to floating point format before being loaded into the floating point unit
Floating Point Execution Stage 2(X2):
Floating point operation performed within floating point unit.
Write FP Result (WF):
Floating point results are rounded and the result is written to the target floating point register.
Error Reporting(ER)
If an error is detected, an error reporting stage is entered where the error is reported and
FPU status word is updated.
If taken, the next instruction to be executed should be the one fetched from branch target
address.
If not taken, the next instruction is the next sequential memory address.
When the branch is taken for the first time, the execution unit provides feedback to the branch
prediction logic.
The branch target address is sent back and recorded in BTB.
A directory entry is made containing the source memory address and history bits set as
strongly taken
The caches have been designed for maximum flexibility and performance. The data cache is
configurable as writeback or writethrough on a line-by-line basis.
Memory areas can be defined as non-cacheable by software and external hardware. Cache
writeback and invalidations can be initiated by hardware or software.
On the Pentium processor, each of the caches are 8 Kbytes in size and each is organized as a 2-
way set associative cache. There are 128 sets in each cache, each set containing 2 lines (each line has its
own tag address). Each cache line is 32 bytes wide.
In the Pentium processor, replacement in both the data and instruction caches is handled by the
LRU mechanism which requires one bit per set in each of the caches.
The instruction and data caches can be accessed simultaneously. The instruction cache can
provide up to 32 bytes of raw opcodes and the data cache can provide data for two data references all in
the same clock.
This capability is implemented partially through the tag structure. The tags in the data cache are
triple ported. One of the ports is dedicated to snooping while the other two are used to lookup two
independent addresses corresponding to data references from each of the pipelines.
The instruction cache tags of the Pentium processor are also triple ported. Again, one port
is dedicated to support snooping and the other two ports facilitate split line accesses
(simultaneously accessing upper half of one line and lower half of the next line).
The storage array in the data cache is single ported but interleaved on 4-byte boundaries to be
able to provide data for two simultaneous accesses to the same cache line.
Each of the caches are parity protected. In the instruction cache, there are parity bits on a
quarter line basis and there is one parity bit for each tag.
The data cache contains one parity bit for each tag and a parity bit per byte of data.
Cache Line P QW P QW P QW P QW DW DW DW DW DW DW DW DW
structure
------ Each DW has:
P Byte P Byte P Byte P Byte
32 bit address tag/page (20 Index (7 Byte (5bits) Tag/page Line Bank XX
interpretation bits) bits) (20 bits) (7 bits) select (3 (2 bits)
bits)
MICROPROCESSOR
Sejal M Chopra
Each of the caches are accessed with physical addresses and each cache has its own TLB
(translation lookaside buffer) to translate linear addresses to physical addresses. The TLBs associated with
the instruction cache are single ported whereas the data cache TLBs are fully dual ported to be able to
translate two independent linear addresses for two data references simultaneously.
The tag and data arrays of the TLBs are parity protected with a parity bit associated with each of
the tag and data entries in the TLBs.
The data cache of the Pentium processor has a 4-way set associative, 64-entry TLB for 4- Kbyte
pages and a separate 4-way set associative, 8-entry TLB to support 4-Mbyte pages.
The code cache has one 4-way set associative, 32-entry TLB for 4-Kbyte pages and 4-Mbyte pages
which are cached in 4-Kbyte increments.
Replacement in the TLBs is handled by a pseudo LRU mechanism (similar to the Intel486 CPU)
that requires 3 bits per set.
The other piece of L1 cache, the code side, supports a subset of the MESI protocol, the S (Shared) and I
(Invalid) states in order to prevent code from accidentally being corrupted since it is inherently write
protected.