Unit 1
Unit 1
Unit 1
Microprocessor –silicon chip which includes ALU, register circuits & control circuits
Takes in Numbers: The microprocessor has a very narrow view on life. It only
understands binary numbers.
A binary digit is called a bit (which comes from binary digit). The microprocessor
recognizes and processes a group of bits together. This group of bits is called a
“word”.
Definition of the Microprocessor
Arithmetic and Logic Operations:
Every microprocessor has arithmetic operations such as add and subtract as part of its
instruction set.
Most microprocessors will have operations such as multiply and divide.
In addition, microprocessors have logic operations as well. Such as AND, OR, XOR,
shift left, shift right, etc.
Stored in memory :
Memory is the location where information is kept while not in current use.
Memory is a collection of storage devices. Usually, each storage device holds one bit.
Also, in most kinds of memory, these storage devices are grouped into groups of 8.
These 8 storage locations can only be accessed together. So, one can only read or
write in terms of bytes to and form memory.
It is measured in Kilos, Megas and lately Gigas.
This can be the monitor, a paper from the printer, a simple LED or many other forms.
Definition of the Microprocessor
The name Pentium was derived from the Greek pente, meaning ‘five’, and the Latin
ending -ium.
The term ‘Pentium processor’ refers to a family of microprocessors that share a
common architecture and instruction set.
The original Pentium processor was a 32-bit microprocessor produced by Intel. The
first Pentium processors, P5, were developed in 1993.
Intel Core 2 Extreme Quad-Core Processor QX6000 was introduced by Intel in 2007.
How Does the Microprocessor Work?
The instructions are stored sequentially in the memory.
The microprocessor fetches the first instruction from its memory sheet, decodes and
execute is continued until the microprocessor comes across an instruction to stop.
During the entire process, the microprocessor uses the system bus to fetch the binary
instructions and data from the memory. It uses register section to store data
temporarily and performs the computing function in the ALU section.
Finally it sends out the result in binary, using the same lines to the output (7 segment
display)
Microprocessor Instruction sets and
Computer languages
Each machine has its own set of instructions based on the design of its CPU or its
microprocessor .
To communicate with the computer, one must give instructions in binary language
(machine language)
Programmers can write programs called assembly language programs.
Due to the difficulty in writing a programs in set of 0 and 1 computer manufacturers
have devised English-like words to represent the binary instructions of a machine.
Microprocessor Instruction sets and
Computer languages
Machine Language
The number of bits in a word for a given machine is fixed and words are formed
through various combinations of these bits.
For example a machine with a word length of eight bits can have 256 (2^8)
combinations of eight bits.
The μp design engineer selects combinations of bit patterns and gives a specific
meaning to each combination by using electronic logic circuits; this is called an
instruction.
Instructions are made up of one word or several words.
Microprocessor Instruction sets and
Computer languages
8085 Machine Language
Microprocessor Instruction sets and
Computer languages
8085 Assembly Language
Microprocessor Instruction sets and
Computer languages
ASCII Code
The memory read/write and Input/Output read and write operations are performed as
part of communication between the microprocessor and memory or Input/Output
devices. Microprocessors communicate with the memory, and I/O devices through
address bus, data bus and control bus
For this communication, firstly the microprocessor identifies the peripheral devices by
proper addressing. Then it sends data and provides control signal for synchronization.
System Bus
The system bus is collection of wires which are used to transfer binary numbers, one bit
per wire.
The 8085 microprocessor communicates with memory and input and output devices
using three buses, namely, address bus, data bus and control bus
System Bus
A 16-bit binary number allows 2^16 different numbers, or 65536 different numbers,
i.e., 0000 0000 0000 0000 up to 1111 1111 1111 1111.
The Intel 8085 microprocessor has 65536 = 64K, (where 1K = 1024) memory for
locations and each memory location contains 1 byte of data.
The address bus is unidirectional. That means numbers can only be sent from
microprocessor to memory, and not the other way.
System Bus
Data BUS
The address/data bus sends data and addresses at different instant of time. Therefore, it
transmits either data or an address at a particular moment.
The AD-bus always operates in the time-shared mode.
System Bus
The microprocessor cannot function correctly without these vital control signals. The
control bus carries control signals, partly unidirectional, partly bi-directional.
Memory Read Operation
Figure shows the memory read operation.
Initially, the microprocessor places a 16-bit address on the address bus.
Then the external decoder logic circuit decodes the 16-bit address on the address bus
and the memory location is identified.
Thereafter, the microprocessor sends MEMR control signal which enables the
memory IC.
Analogy
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
The timing of data flow when the instruction code 0100 1111(4FH –MOV C, A)
stored in location 2005H, is being fetched
μP Communication and Bus Timings
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
μP Communication and Bus Timings
Figure shows the timing of how
a data Byte is transferred from
memory to the MPU.
The
After that,crossover
the content of thememory
of the lines location is placed on the data bus and also sent to the
indicates that a new byte is
microprocessor.
placed on the bus
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
μP Communication and Bus Timings
At T1
The high order memory address
20H is placed on the address
lines
IO/M
After barcontent
that, the signalof the
goes low location is placed on the data bus and also sent to the
memory
(memory read operation).
microprocessor.
μP Communication and Bus Timings
To fetch the byte following steps are required
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
μP Communication and Bus Timings
In step 2
Control signal RD bar is
activated for enabling the
memory chip
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
μP Communication and Bus Timings
To fetch the byte following steps are required
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
μP Communication and Bus Timings
In step 3
When memory is enabled,
The instruction byte (4FH) is
placed on the bus AD7-AD0
and transferred to the
microprocessor.
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
μP Communication and Bus Timings
In step 4
The machine code (4FH) is
decoded by the instruction
decoder, and the contents of the
accumulator are copied into
register C.
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
Demultiplexing the Bus AD0-AD7
Timing Figure shows that the
address on the high order
(20H) remains on the bus for
three clock periods.
While low order address
(05H) is lost after the one
period .
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
Demultiplexing the Bus AD0-AD7
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
Demultiplexing the Bus AD0-AD7
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
The 8085 Programmable Registers
Registers:
AfterFollowing
that, the content of are
registers the memory location
include in 8085 is placed on the data bus and also sent to the
microprocessor
microprocessor.
• One 8-bit accumulator (ACC) known as register A
• Six 8-bit general-purpose registers: B, C, D, E, H and L
• One 16-bit Stack Pointer (SP)
• One 16-bit Program Counter (PC)
• Flag register
The 8085 Programmable Registers
General-purpose registers :
The Intel 8085 has six general-purpose registers to store 8-bit data and these
registers are identified as B, C, D, E, H and L.
When two registers are combined, 16-bit data can be stored in a register pair. The
only possible combinations of register pairs are BC, DE and HL.
These register pairs are used to perform 16-bit operations.
Accumulator:
The accumulator is an 8-bit register, which is part of the Arithmetic Logic Unit
(ALU).
This is identified as register A or ACC.
It is used to store 8-bit data and to perform arithmetic as well as logic operations.
AfterThe
that,final result ofoftheanmemory
the content operation performed
location is placedin
on the ALUbusisand
the data also
alsostored
sent toin
thethe
microprocessor.
accumulator.
The 8085 Programmable Registers
Program counter :
The program counter is a 16-bit special-purpose register.
This is used to hold the memory address of the next instruction which will be
executed.
Actually, this register keeps track of memory locations of the instructions during
execution of program.
The microprocessor uses this register to execute instructions in sequence.
For this, the microprocessor increments the content of the program counter.
Stack pointer:
The stack pointer is a 16-bit register, which is used to point the memory location
called the stack.
AfterThe stack
that, is a sequence
the content of memory
of the memory locations
location in the
is placed on R/W memory.
the data bus and also sent to the
microprocessor.
The starting of the stack is defined by loading a 16-bit address into the stack pointer.
The 8085 Programmable Registers
Flag Registers:
The Arithmetic Logic Unit (ALU) includes five flip-flops, which are set or reset
after an ALU operation according to data conditions of the result in the accumulator
and other general-purpose registers.
The most commonly used flags are Carry(CY), Zero(Z) and Sign(S).
For example, after addition of two 8-bit numbers, if the sum in the accumulator is
Afterlarger
that, than eight bits,
the content of thethe flip-flop,
memory which
location is is usedon
placed to the
indicate a carry,
data bus is set
and also totoone.
sent the So
microprocessor.
the Carry flag (CY) is set to1.
If the result is zero after any arithmetic operation, the Zero (Z) flag is set to one.
The 8085 Programmable Registers
Figure shows an 8-bit register, which indicates bit positions of different flags.
Zero Flag: When an 8-bit ALU operation results in zero, the Zero (Z) flag is set;
otherwise it is reset.
The 8085 Programmable Registers
Sign Flag:
The sign flag has its importance only when a signed arithmetic operation is
performed.
In arithmetic operations of signed numbers where the bit D7 is used to indicate a
sign, this flag is set to indicate the sign of a number.
The most significant bit of an 8-bit data is the sign bit.
When a number is negative, the sign bit is 1. If the number is positive, the sign bit
is 0.
For an 8-bit signed operation, the remaining 7 bits are used to represent the
magnitude of a number.
After that, the content of the memory location is place on the data bus and also sent to the
microprocessor.
Internal Data Operations and the 8085 Registers
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
Internal Data Operations and the 8085 Registers
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
Internal Data Operations and the 8085 Registers
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
Peripheral or Externally Initiated Operations
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
Memory
After that, the content of the memory location is placed on the data bus and also sent to the
microprocessor.
Storage Element: Flip-Flop or Latch
In this latch the stored bit is always available on the output line Dout.
To avoid unintentional change in the input and control the availability of the output,
we use two tristate buffers on the latch.
By using these buffers we can write into the latch by enabling the input buffer and
read from it by enabling the output buffer.
Four such cells or latches grouped together this is a register, which has four input
lines and four output lines and can store four bits. Size becomes 4 bits.
Storage Element: Flip-Flop or Latch
Two chips with four registers each. There are total 8 registers therefore we need three
address lines, but one line should be used to select between the two chips.
The additional signal called chip select .
Storage Element: Flip-Flop or Latch
Assume we have available four address lines and two memory chips with four registers each.
Requirements of Memory Chip
Requirements of Memory Chip
Memory Map and Addresses
In 8 bit microprocessor, 16 address lines are available for memory.
It is capable of identifying 2^16 (65536) memory registers, each register with a16-
bit address
The entire memory addresses can range from 0000 to FFFF in Hex.
A memory map is a pictorial representation in which memory devices are located in
the entire range of address.
Memory addresses provide the locations of various memory devices in the system
Analogy
Memory Map and Addresses
Consider a memory chip with 256 registers.
For 256 registers we require8 address lines.
What is purpose of rest 8 address lines?
Remaining 8 address lines to assign fixed logic to generate a constant number.
Memory Map and Addresses
Memory Map and Addresses
Memory Map and Addresses
Example
How you divide the address lines for a memory 1K (1024X8).
Example
Memory Address lines
For a chip with 256 registers, we need 256 binary numbers to identify each register.
Each address line can assume only two logic states (0 and 1)
Therefore we need to find the power of 2 that will give us 256 combinations.
The presence of
diodes stores 1
and absence
stores 0
Memory Classification
Memory Classification
Input and Output Devices
Input and Output Devices
Tri-State Devices
Buffer
Decoder
Encoder
D Flip-Flop and Latch
Generating Control Signal
All Instructions are divided into few basic machine cycles and these machine cycles are
divided into precise system clock periods
The 8085 Machine Cycles and Bus Timings
When the instruction code 01001111 (4FH-MOV C,A) stored in the location 2005H
The 8085 Machine Cycles and Bus Timings
The 8085 Machine Cycles and Bus Timings
When the instruction code 01001111 (4FH-MOV C,A) stored in the location 2005H
The 8085 Machine Cycles and Bus Timings
Memory Read Cycle
The 8085 Machine Cycles and Bus Timings
Operation during T1-T4
The 8085 Machine Cycles and Bus Timings
The 8085 Machine Cycles and Bus Timings
The 8085 Machine Cycles and Bus Timings
How to recognize machine cycles
The 8085 Machine Cycles and Bus Timings
How to recognize machine cycles
Memory Interfacing
During the execution of program, the microprocessor needs to access memory
frequently to read instruction codes and data stored in memory the interfacing
circuit enables that access.
Memory has certain signal requirements to write into and read from its registers.
Similarly, the microprocessor initiates a set of signals when it wants to read from and
write into memory.
The interfacing process involves designing a circuit that will match the memory
requirements with the microprocessor signals.
Memory Interfacing
Memory Structure and its requirement
Figure shows a R/W memory chip it has 2048 registers and each register can store 8
bits indicating by 8 input and 8 output data lines.
The chip has 11 address lines, one chip select, and two control lines: RD bar to
enable the output buffer and WR bar to enable input buffer
Memory Interfacing
Memory Structure and its requirement
12 address lines are connected to the memory chip , and the remaining four address
lines (A15-A12) of the 8085 microprocessor must be decoded.
Memory Interfacing
Address Decoding
Two methods are used for decodeing these lines:
(1) By using a NAND gate
(2) By using a 3-to-8 decoder
Memory Interfacing
Interfacing Circuit
Memory Interfacing
Interfacing Circuit
Memory Interfacing
Interfacing Circuit
Memory Interfacing
Interfacing Circuit
Memory Interfacing
Address Decoding and Memory Addresses
Memory Interfacing
Address Decoding and Memory Addresses
When the 8085 asserts the RD bar signal, the output buffer is enabled and the
contents of the Register 0FFFH are placed on the data bus for the processor to read.
Memory Interfacing
Address Decoding and Memory Addresses
Interfacing the 8155 Memory Segment
Interfacing the 8155 Memory Segment
Interfacing the 8155 Memory Segment
Interfacing the 8155 Memory Segment
Example: Designing Memory for the MCTS
Now we will design an interfacing circuit for the microprocessor controlled
temperature system
Example: Designing Memory for the MCTS
Example: Designing Memory for the MCTS
Example: Designing Memory for the MCTS
Example: Designing Memory for the MCTS
Example: Designing Memory for the MCTS
Testing and Troubleshooting Memory Interfacing Ckts
In the peripheral I/O, the instructions IN/OUT are used for data transfer, and the
device is identified by an 8-bit address.
In the memory-mapped I/O, memory related instructions are used for data transfer,
and the device is identified by a 16-bit address.
Interfacing I/O Devices
Interfacing I/O Devices
Similarly, the instruction IN can be used to accept data from 256 different input ports
I/O Execution
OUT instruction 8085
The 8085 executes the OUT instruction in three machine cycles and it takes ten T-
states (clock periods) to complete the execution.
I/O Execution
OUT instruction 8085
I/O Execution
OUT instruction 8085
I/O Execution
IN instruction 8085
I/O Execution
IN instruction 8085
I/O Execution
I/O Execution
Device Selection and Data Transfer
The latch should be enabled when IO/M bar is high and WRbar is active low.
I/O Execution
Device Selection and Data Transfer
I/O Execution
Device Selection and Data Transfer
I/O Execution
Absolute vs Partial Decoding
In above figure all 8 address lines are decoded to generate one unique output pulse
the device will be selected only with address 01H. This called absolute decoding.
I/O Execution
Absolute vs Partial Decoding
The output port (latch) can be accessed by the Hex addresses 00, 01, 02 and03. The
partial decoding is a commonly used technique in small system.
Such multiple addresses will not cause any problems, provided these addresses are
not assigned to any other output ports
I/O Execution
Input Interfacing
I/O Execution
Interfacing I/O Using Decoders
Step2:
The second step is to combine
the decoded address with an
appropriate control signal to
generate the I/O select pulse.
The seven segments A through G, are usually connected to data line D0 through D6,
respectively.
If the decimal point segment is being used, data line D7 is connected to DP otherwise
it is left open.
The binary code required to display a digit is determined by the type of the 7 segment
LED (Common anode or common cathode)
Interfacing Output Displays
Illustration: Seven Segment LED Display as an output
Now we analyze the circuit used for interfacing eight DIP switches
The circuit includes the 74LS138 3 to 8 decoder to decode the low order bus and the
tri state octal buffer to interface the switches to the data bus.
Interfacing Input Devices
Interfacing Input Devices
Interfacing Circuit
Interfacing Input Devices
Interfacing Input Devices
When a switch is closed, it has logic 0 and when it is open, it is tied to+5V,
representing logic 1.
In Figure the switches S7-S0 are open and S2-S0 are closed; thus the input reading
will be F8H.
Interfacing Input Devices
Memory Mapped I/O
Memory Mapped I/O
The STA is a three byte instruction The first byte is the opcode and the second and
third bytes specify the memory address.
The 16 bit address 8000H is entered in the reverse order.
In this example, if an output device, instead of a memory register, is connected at
this address, the accumulator contents will be transferred to the output device,
This is called memory-mapped I/O technique.
Memory Mapped I/O
The instruction LDA (Load Accumulator Direct) transfers the data from a memory
location to the accumulator.
The LDA is also a 3 byte instruction: the second and thrid bytes specify the
memory location.
When the microprocessor executes the LDA instruction, the accumulator recives
data from the input device rather than from a memory location.
Memory Mapped I/O
Execution of Memory-Related Data Transfer Instructions
Memory Mapped I/O
Execution of Memory-Related Data Transfer Instructions
Memory Mapped I/O
Device selection and data transfer in memory-mapped I/O require three steps:
Memory Mapped I/O
Illustration: Safety Control System Using Memory-Mapped I/O
technique
Figure shows a schematic of interfacing I/O devices using the memory-mapped I/O
technique.
The circuits includes one input port with Eight DIP switches and one output port to
control various processes and gates (which are turned on/off by the microprocessor
according to the corresponding switch position)
Memory Mapped I/O
Illustration: Safety Control System Using Memory-Mapped I/O
technique
Memory Mapped I/O
Illustration: Safety Control System Using Memory-Mapped I/O
technique
Output Port and its Address
If an output bit of the
74LS373 is high, it activates
the corresponding relay and
turns on the process; the
process remains on until the
bit stays high.
The 74LS373 is a latch followed by a tri-state buffer is shown in Figure.
The latch and the buffer are controlled independently by the Latch Enable (LE)
and Output Enable (OE bar).
When LE is high, the data enter the latch, and when LE goes low, data are latched.
The latched data are available on the output lines of the 74LS373 if the buffer is
enabled by OE bar (active low).
If OE bar is high, the output lines go into the high impedance state.
Memory Mapped I/O
Illustration: Safety Control System Using Memory-Mapped I/O
technique
In figure OE bar is connected
to the ground (the latched data
will keep the relays on/off
according to the bit pattern).
When such algorithms are used in systems with processors that have support for
only integer math, significant overhead occurs both in terms of memory and
performance. For such processors, fixed point numbers are used.
Fixed-Point Notation
A K-bit fixed-point number can be interpreted as either:
an integer (i.e., 20645)
a fractional number (i.e., 0.75)
Fixed-Point Arithmetic
Integer Fixed-Point Representation
N-bit fixed point, 2’s complement integer representation
Rounding
• Magnitude of rounded number could be smaller or greater than the original
value
• Error tends to be minimized (positive and negative biases)
Example:
INT[251.2] = 251 (Truncate or floor)
ROUND [ 251.2] = 252 (Round or ceil)
ROUNDNEAREST [251.2] = 251
Fractional-Point Arithmetic
Q format Multiplication
Product of two Q15 numbers is Q30.
So we must remember that the 32-bit product has two bits in front of the binary
point.
Since NxN multiplication yields 2N-1 result
Addition MSB sign extension bit
Fractional-Point Arithmetic
General Fixed-Point Representation
Qm.n notation
• m bits for integer portion
• n bits for fractional portion
• Total number of bits N = m + n + 1, for signed numbers
Special cases:
16-bit integer number (N=16) => Q15.0 format
16-bit fractional number (N = 16) => Q0.15 format; also known as Q.15 or
Q15
Fractional-Point Arithmetic
General Fixed-Point Representation