al-azhar university lecture 4 - rabieramadan.orgrabieramadan.org/microprocessor/lectures/lecture...

34
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 4

Upload: others

Post on 30-Apr-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Microprocessor

Dr. Rabie A. RamadanAl-Azhar University

Lecture 4

Page 2: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Machine Cycles and Bus Timings

Microprocessor includes 158 different

instruction types.

• Each instruction has two parts:

• Operation code (known as opcode) and operand.

2

OUT (10H), A

Opcode to

output data

Operand to specify that the

byte should be sent from the

accumulator to port 10H

Page 3: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Machine Cycles and Bus Timings

Assume that the instruction is stored in 2 Bytes

The Z80 has to perform three operations:

• Read Byte 1 from the first memory location

• Read Byte 2 from the next memory location

• Send Data to port 10H

3

OUT (10H), A

Opcode to

output data

Operand to specify that the

byte should be sent from the

accumulator to port 10H

Page 4: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Machine Cycles and Bus Timings Instruction

• the time required to complete the execution of an instruction. The Z80

instruction cycle consists of one to six machine cycles or one to six

operations.

Machine Cycle

• The time required to complete one operation of accessing memory,

accessing I/O, or acknowledging an external request. This cycle may

consist of three to six T-states.

T-state

• One subdivision of operation performed in one clock period. These

subdivisions are internal states synchronized with the system clock and

each T-state is equal to one clock period.

4

Page 5: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Opcode Fetch Machine Cycle (M1)

Address Machine Code Instruction Comment

2002 010001112 (47H) LD B, A Copy A into B

5

Page 6: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Opcode Fetch Machine Cycle (M1)

6

Page 7: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Opcode Fetch Machine Cycle (M1)

7

Page 8: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

The Timing of the opcode Fetch Machine

8

Page 9: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

The Timing of the

opcode Fetch Machine

9

Page 10: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

10

The Timing of the

opcode Fetch

Machine

Page 11: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

11

The Timing of the

opcode Fetch

Machine

Page 12: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Memory Read Machine Cycle

The instruction consists of two bytes;

• Opcode and Data byte.

• The Z80 must first read these bytes from memory

• Requires at least two machine cycles.

• The machine cycle is opcode fetch, and

• the second machine cycle is Memory Read

12

Page 13: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

13

Page 14: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

14

Page 15: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

15

Page 16: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Memory Write Cycle

This is a one-byte instruction with two machine cycles:

• Opcode Fetch and Memory Write.

• Z80 fetches the code (77H) and

• it copies the byte 9FH from the accumulator into the memory

location 2350H.

16

Page 17: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

17

Page 18: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

18

Page 19: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

19

Page 20: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Memory Interfacing

20

Page 21: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Interfacing Memory

An address should be placed on the

address lines.

The low-order address lines are

decoded by the internal decoder of the

memory chip, and the addressed

register is identified.

The high-order address should be

decoded to generate a Chip Select

signal, and the memory chip is

selected by asserting the Chip Select

low.

21

CS

Page 22: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Interfacing Memory

To read from the addressed register, the

should be asserted low to enable the

output buffer, and then the data byte

from the register will be placed on the

I/O lines.

To write into the addressed register, the

should be asserted low to enable the

input buffer, and then data bits from the

data lines are stored into the register.

22

RD

WR

Page 23: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

How does the Z80 Read from or

Write into Memory?

23

Page 24: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Basic Concepts in Memory

Interfacing

Interface Function:

• Be able to select the chip

• Identify the register

• Enable the appropriate buffer.

24

Page 25: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Read from the Memory

25

Page 26: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Write into memory register

26

Page 27: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Address Decoding

3 input lines A0-A2 (Memory Select Buffer (MSB))

A3 – A7 are control lines since the address starts at F0H to F7H

3 lines enable only one o/p line

27

A7 A6 A5 A4 A3 A2 A1 A0

1 1 1 1 0 1 1 1= F7H

Page 28: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Example 1: Interfacing the 2764

EPROM

Used in industry to develop

microprocessor-based products.

8k (8192 8) memory chip with

8 data lines

Housed in a 28-pin package.

28

Page 29: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Chip Configuration

29

Page 30: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

What is the Memory Addresses Range?

30

A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1

0000H 1FFFH

Page 31: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Interfacing CMOS 6116 Static R/W

Memory

This is a 2k static memory chip

organized as 2048 x 8 format.

It has 11 address lines (A10-A0),

8 data lines

3 control signals:

31

Page 32: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Chip Configuration

32

Page 33: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Memory Interface

What is the addresses range? Assume A12 and A11 are do not care .

33

A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0

1 0 0 X X 0 0 0 0 0 0 0 0 0 0 0

1 0 0 X X 1 1 1 1 1 1 1 1 1 1 1

8000 87FF -- Address ranges may differ due to the do not care at A12 and A11

Page 34: Al-Azhar University Lecture 4 - rabieramadan.orgrabieramadan.org/Microprocessor/lectures/Lecture 4/Lecture 4.pdf · Memory Read Machine Cycle The instruction consists of two bytes;

Reading Assignment

Please Read

• Chapter 3

• Chapter 4

34