cpe/ee 421 microcomputers: motorola 68000 – the cpu...

28
Alex Milenkovich 1 CPE/EE 421 Microcomputers: Motorola 68000 – The CPU Hardware Model Instructor: Dr Aleksandar Milenkovic Lecture Notes CPE/EE 421/521 Microcomputers 2 Outline 68000 interface Timing diagram Minimal configuration using the 68000 Extensions Exception Processing CPE/EE 421/521 Microcomputers 3 68000 Interface M68000: 64 pins, arranged in 9 groups: Address Bus: A 01 –A 23 Data Bus: D 00 –D 15 Asynchronous bus control: AS*, R/W*, UDS*, LDS*, DTACK*, BERR* Synchronous bus control: E, VPA*, VMA* Bus arbitration control: BR*, BG*, BGACK* Function code: FC0, FC1, FC2 System control: CLK, RESET*, HALT* Interrupt control: IPL0*, IPL1*, IPL2* Miscellaneous: Vcc (2), Gnd (2) Legend: Type XX Input XX Output XX Input/Output CPE/EE 421/521 Microcomputers 4 68000 Interface, cont’d Classification of pins based on function SYSTEM SUPPORT PINS Essential in every 68000 system (power supply, clock, …) MEMORY AND PERIPHERAL INTERFACE PINS Connect the processor to an external memory subsystem SPECIAL-PURPOSE PINS (not needed in a minimal application of the processor) Provide functions beyond basic system functions Terminology Asterisk following a name: indicates the signal is active low “Signal is asserted” means signal is placed in its active state “Signal is negated” means signal is placed in its inactive state

Upload: doanmien

Post on 20-Feb-2019

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 1

CPE/EE 421 Microcomputers:Motorola 68000 –The CPU Hardware Model

Instructor: Dr Aleksandar MilenkovicLecture Notes

CPE/EE 421/521 Microcomputers 2

Outline

68000 interfaceTiming diagramMinimal configuration using the 68000ExtensionsException Processing

CPE/EE 421/521 Microcomputers 3

68000 Interface

M68000: 64 pins, arranged in 9 groups: Address Bus: A01 – A23Data Bus: D00 – D15Asynchronous bus control: AS*, R/W*, UDS*, LDS*,

DTACK*, BERR*Synchronous bus control: E, VPA*, VMA*Bus arbitration control: BR*, BG*, BGACK*Function code: FC0, FC1, FC2System control: CLK, RESET*, HALT*Interrupt control: IPL0*, IPL1*, IPL2*Miscellaneous: Vcc(2), Gnd(2)

Legend: TypeXX InputXX OutputXX Input/Output

CPE/EE 421/521 Microcomputers 4

68000 Interface, cont’d

Classification of pins based on functionSYSTEM SUPPORT PINS

Essential in every 68000 system (power supply, clock, …)MEMORY AND PERIPHERAL INTERFACE PINS

Connect the processor to an external memory subsystemSPECIAL-PURPOSE PINS (not needed in a minimal application of the processor)

Provide functions beyond basic system functions

TerminologyAsterisk following a name: indicates the signal is active low“Signal is asserted” means

signal is placed in its active state“Signal is negated” means

signal is placed in its inactive state

Page 2: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 2

CPE/EE 421/521 Microcomputers 5

System Support Pins

Power SupplySingle +5V power supply: 2 Vcc pins and 2 ground pins

ClockSingle-phase, TTL-compatible signalBus cycle: memory access, consists of a minimum 4 clock cyclesInstruction: consists of one or more bus cycles

RESET*Forces the 68000 into a known state on the initial application of power:

supervisor’s A7 is loaded from memory location $00 0000Program counter is loaded from address $00 0004

During power-up sequence must be asserted together with the HALT* input for at least 100 ms. Acts also as an output, when processor executes the instruction RESET (used to reset peripherals w/out resetting the 68000)

CPE/EE 421/521 Microcomputers 6

System Support Pins, cont’d

HALT*In simple 68000 systems can be connected together with RESET*Can be used:

by external devices to make the 68000 stop execution after current bus cycle (and to negate all control signals)to single-step (bus cycle by bus cycle) through program to rerun a failed bus cycle (if memory fails to respond correctly) in conjunction with the bus error pin, BERR*

It can be used as an output, to indicate that the 68000 found itself in situation from which it cannot recover (HALT* is asserted)

CPE/EE 421/521 Microcomputers 7

Memory and Peripheral Interface Pins

Address Bus23-bit address bus, permits 223 16-bit words to be addressedTri-state output pins (to permit devices other then the CPU to take a control over it)Auxiliary function:

supports vectored interruptsAddress lines A01, A02, A03 indicate the level of the interrupt being servicedAll other address lines are set to a high level

Data BusBi-directional 16-bit wide data bus

During a CPU read cycle acts as an inputDuring a CPU write cycle acts as an output

Byte operations: only D00-D07 or D08-D15 are activeInterrupting device identifies itself to the CPU by placing an interrupt vector number on D00-D07 during an interrupt acknowledge cycle CPE/EE 421/521 Microcomputers 8

Memory and Peripheral Interface Pins, cont’d

AS*When asserted, indicates that the content of the address bus is valid.

R/W*Determines the type of a memory access cycle

CPU is reading from memory: R/W* = 1CPU is writing to memory: R/W* = 0If CPU is performing internal operation, R/W* is always 1When CPU relinquishes control of its busses, R/W* is undefined

UDS* and LDS*Used to determine the size of the data being accessedIf both UDS* and LDS* are asserted, word is accessedR/W* UDS* LDS*

010: write lower byte (D00 – D07: data valid, replicated on D8-D15)011: write word (D00 – D15: data valid)101: read upper byte (D00 – D07: invalid, D8-D15 – data valid)

Page 3: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 3

CPE/EE 421/521 Microcomputers 9

Memory and Peripheral Interface Pins, cont’d

DTACK* (Data Transfer Acknowledge)Handshake signal generated by the device being accessedIndicates that the contents of the data bus is validIf DTACK* is not asserted, CPU generates wait-states until DTACK goes low or until an error state is declared. When DTACK* is asserted, CPU completes the current access and begins the next cycle

DTACK* has to be generated a certain time after the beginning of a valid memory access (timer supplied by the system designer).

CPE/EE 421/521 Microcomputers 10

Memory and Peripheral Interface Pins, cont’d

Figure 4.3

CPE/EE 421/521 Microcomputers 11

Special-Function Pins of the 68000

BERR* (Bus Error Control)Enables the 68000 to recover from errors within the memory system

BR*, BG*, BGACK* (Bus Arbitration Control)Used to implement multiprocessor systems based on M68000

FC0-FC2 (Function Code Output)Indicate the type of cycle currently being executedBecomes valid approximately half a clock cycle earlier than the contents of the address bus

IPL0*-IPL2* (Interrupt Control Interface)Used by an external device to indicate that it requires service3-bit code specifies one of eight levels of interrupt request

CPE/EE 421/521 Microcomputers 12

Special-Function Pins of the 68000Function Code Outputs

Function Code Output FC2 FC1 FC0 Processor Cycle Type

0 0 0 Undefined, reserved 0 0 1 User data 0 1 0 User program 0 1 1 Undefined, reserved 1 0 0 Undefined, reserved 1 0 1 Supervisor data 1 1 0 Supervisor program 1 1 1 CPU space (interrupt acknowledge)

Function Code Output FC2 FC1 FC0 Processor Cycle Type

0 0 0 Undefined, reserved 0 0 1 User data 0 1 0 User program 0 1 1 Undefined, reserved 1 0 0 Undefined, reserved 1 0 1 Supervisor data 1 1 0 Supervisor program 1 1 1 CPU space (interrupt acknowledge)

Page 4: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 4

CPE/EE 421/521 Microcomputers 13

Special-Function Pins of the 68000Using FC Outputs

User data memory

User program memory

Supervisor program and data memory

Figure 4.8

CPE/EE 421/521 Microcomputers 14

The 68000 is not fully asynchronous because its actions are synchronized with a clock input

It can prolong a memory access until an ACK is received, but it has to be in increments of one clock cycle

Figure 4.11

Special-Function Pins of the 68000 Asynchronous Bus Control

CPE/EE 421/521 Microcomputers 15

Outline

68000 interfaceTiming diagramMinimal configuration using the 68000ExtensionsException Processing

CPE/EE 421/521 Microcomputers 16

Actual behavior of a D flip-flop

Data hold time

Data setup time

Max time for output to become valid after clock

Timing Diagram of a Simple Flip-FlopIdealized form of the timing diagram

Page 5: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 5

CPE/EE 421/521 Microcomputers 17

An alternative form of the timing diagram

General form of the timing diagram

CPE/EE 421/521 Microcomputers 18

The Clock

A microprocessor requires a clock that provides a stream of timing pulses to control its internal operationsA 68000 memory access takes a minimum of eight clock states numbered from clock state S0 to clock state S7

CPE/EE 421/521 Microcomputers 19

A memory access begins in clockstate S0 and ends in state S7

Bus Cycle

CPE/EE 421/521 Microcomputers 20

The most important parameterof the clock is the duration of a cycle,tCYC.

Bus Cycle

Page 6: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 6

CPE/EE 421/521 Microcomputers 21

At the start of a memory accessthe CPU sends the address of the locationit wishes to read to the memory

Bus Cycle

CPE/EE 421/521 Microcomputers 22

Address Timing

We are interested in when the 68000 generates a new address for use in the current memory accessThe next slide shows the relationship between the new address and the state of the 68000’s clock

CPE/EE 421/521 Microcomputers 23

Initially, in stateS0 the addressbus contains theold address

In state S1 a newaddress becomesvalid for the remainderof the memory access

Bus Cycle

CPE/EE 421/521 Microcomputers 24

The time at which the contentsof the address bus change can berelated to the edges of the clock.

Bus Cycle

Page 7: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 7

CPE/EE 421/521 Microcomputers 25

Address Timing

Let’s look at the sequence of events that govern the timing of the address busThe “old” address is removed in state S0The address bus is floated for a short time, and the CPU puts out a new address in state S1

CPE/EE 421/521 Microcomputers 26

The old address is removedin clock state S0 and theaddress bus floated

Bus Cycle

CPE/EE 421/521 Microcomputers 27

tCLAV

The designer is interested in the point atwhich the address first becomes valid. Thispoint is tCLAV seconds after the falling edgeof S0.

Bus Cycle

CPE/EE 421/521 Microcomputers 28

The memory needs to know whenthe address from the CPU is valid.An address strobe, AS*, is assertedto indicate that the address is valid.

Bus Cycle

Page 8: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 8

CPE/EE 421/521 Microcomputers 29

Address and Address Strobe

We are interested in the relationship between the time at which the address is valid and the time at which the address strobe, AS*, is assertedWhen AS* is active-low it indicates that the address is validWe now look at the timing of the clock, the address, and the address strobe

CPE/EE 421/521 Microcomputers 30

AS* goes active low afterthe address has become valid

AS* goes inactivehigh before the addresschanges

Bus Cycle

CPE/EE 421/521 Microcomputers 31

AS* goes low in clockstate S2

Bus Cycle

CPE/EE 421/521 Microcomputers 32

The Data Strobes

The 68000 has two data strobes LDS* and UDS*. These select the lower byte or the upper byte of a word during a memory accessTo keep things simple, we will use a single data strobe, DS*The timing of DS* in a read cycle is the same as the address strobe, AS*

Page 9: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 9

CPE/EE 421/521 Microcomputers 33

The data strobe, is assertedat the same time as AS*in a read cycle

Bus Cycle

CPE/EE 421/521 Microcomputers 34

The Data Bus

During a read cycle the memory provides the CPU with dataThe next slide shows the data bus and the timing of the data signalNote that valid data does not appear on the data bus until near the end of the read cycle

CPE/EE 421/521 Microcomputers 35

Data from the memoryappears near the end ofthe read cycle

Bus Cycle

CPE/EE 421/521 Microcomputers 36

Analyzing the Timing Diagram

We are going to redraw the timing diagram to remove clutterWe aren’t interested in the signal paths themselves, only in the relationship between the signals

Page 10: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 10

CPE/EE 421/521 Microcomputers 37

We are interested in the relationshipbetween the clock, AS*/DS* andthe data in a read cycle

Bus Cycle

CPE/EE 421/521 Microcomputers 38

The earliest time at which the memory canbegin to access data is measured from the pointat which the address is first valid

Bus Cycle

CPE/EE 421/521 Microcomputers 39

Addressbecomes valid

Databecomes valid

The time between address validand data valid is the memory’saccess time, tacc

Bus Cycle

CPE/EE 421/521 Microcomputers 40

Calculating the Access Time

We need to calculate the memory’s access timeBy knowing the access time, we can use the appropriate memory componentEqually, if we select a given memory component, we can calculate whether its access time is adequate for a particular system

Page 11: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 11

CPE/EE 421/521 Microcomputers 41

Data from the memory is latched intothe 68000 by the falling edge of theclock in state S6.

Bus Cycle

CPE/EE 421/521 Microcomputers 42

Data must be validtDICL seconds beforethe falling edge of S6

Bus Cycle

CPE/EE 421/521 Microcomputers 43

We know that the time between theaddress valid and data valid is tacc

Bus Cycle

CPE/EE 421/521 Microcomputers 44

The address becomesvalid tCLAV seconds afterthe falling edge of S0

Bus Cycle

Page 12: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 12

CPE/EE 421/521 Microcomputers 45

From the fallingedge of S0 to thefalling edge of S6:

•the address becomes valid•the data is accessed•the data is captured

Bus Cycle

CPE/EE 421/521 Microcomputers 46

The falling edge of S0 to the fallingedge of S6 is three clock cycles

Bus Cycle

CPE/EE 421/521 Microcomputers 47

3 tcyc = tCLAV + tacc + tDICL

Bus Cycle

CPE/EE 421/521 Microcomputers 48

Timing Example

68000 clock 8 MHz tCYC = 125 ns68000 CPU tCLAV = 70 ns68000 CPU tDICL = 15 nsWhat is the minimum tacc?3 tCYC = tCLAV + tacc + tDICL

375 = 70 + tacc + 15tacc = 290 ns

Page 13: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 13

CPE/EE 421/521 Microcomputers 49

Figure 4.14

A 68000 Read Cycle

CPE/EE 421/521 Microcomputers 50

Figure 4.15

Extended Read Cycle

DTACK* did not go low at least 20ns before the falling edge of state S4

Designer has to provide logic to control DTACK*

CPE/EE 421/521 Microcomputers 51

Figure 4.18

Memory Timing Diagram

The 6116 static memory component2K x 8bit memory – byte-oriented!Two 6116’s configured in parallel to allow word accessesEleven address inputs

CPE/EE 421/521 Microcomputers 52

Figure 4.17

Memory Timing Diagram, cont’d

Assumptions:R/W* is high for the duration of the read cycleOE* is low

(min 200ns – address stable)

(max 200ns)

(max 15ns)

Data is floating

(max 50ns)

(usually derived from UDS*/LDS*)

Page 14: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 14

CPE/EE 421/521 Microcomputers 53

D00

D07

D08

D15

A12

A23

A01

A11

A01

A11

A01

A11

Figure 4.19

Con

nect

ing

The

6116

R

AM

to a

680

00 C

PU

No operation111100Lower byte read010100Upper byte read101000

Word read000000No operation11XX1XNo operation11XXX1OperationCS2

*CS1*LDS*UDS*

RAMCS*AS*

OutputsInputs

CPE/EE 421/521 Microcomputers 54Figure 4.20C

onne

ctin

g Th

e 61

16 R

AM

to a

68

000

CPU

Tim

ing

Dia

gram

Turnoff time70+10+60 =

140ns

70ns

10ns

60ns

CPE/EE 421/521 Microcomputers 55

Timing Example

68000 clock 8 MHz tCYC = 125 ns68000 CPU tCLAV = 70 ns68000 CPU tDICL = 15 nsWhat is the minimum tacc?3 × tCYC > tCLAV + tacc + tDICL375 > 70 + tacc + 15tacc < 290 ns (or tAA from the timing diagram, access time)

For the 12.5MHz version of 68000 tCYC = 80 ns68000 CPU tCLAV = 55 ns68000 CPU tDICL = 10 ns3×80 > 55 + tacc + 10tacc < 175 ns

Remember, maximum tAA for the 6116 RAM was 200 nsCPE/EE 421/521 Microcomputers 56

68000 Write Cycle

68000 transmits a byte or a word to memory or a peripheralEssential differences:

The CPU provides data at the beginning of a write cycleOne of the bus slaves (see later) reads the data

In a read cycle DS* and AS* were asserted concurrentlyThis will be not a case here!Reason for that: 68000 asserts DS* only when the contents of data bus have stabilized

Therefore, memory can use UDS*/LDS* to latch data from the CPU

Page 15: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 15

CPE/EE 421/521 Microcomputers 57

Simplified write cycle timing diagram

In a write cycle: UDS*/LDS* is

asserted one cycle after AS*

Figure 4.22

CPE/EE 421/521 Microcomputers 58Figure 4.23

Follow this sequence of events in a write cycle:

Address stableAS* assertedR/W* brought lowData validDS* asserted

Write Cycle

CPE/EE 421/521 Microcomputers 59Figure 4.24

Write Cycle Timing Diagram of a 6116 RAM

Address setup time(min 20ns)

Address valid to end of write(min 120ns)

Write pulse width(min 90ns)

Write recovery time(min 10ns)

CPE/EE 421/521 Microcomputers 60

Write cycle ends with either CS* or WE* being negated (CS* and WE* internally combined)An address must be valid for at least tAS nanoseconds before WE* is assertedMust remain valid for at least tWR nanoseconds after WE* is negatedData from the CPU must be valid for at least tDW nanoseconds before WE* is negatedMust remain valid for at least tDH nanoseconds after the end of the cycle

Write Cycle Timing Diagram of a 6116 RAM, cont’d

Page 16: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 16

CPE/EE 421/521 Microcomputers 61

Designing a Memory Subsystem An Example

Design a M68000 memory subsystem usingTwo 32K × 8 RAM chips residing at address $00 8000Two 8K × 8 RAM chips residing in the consecutive windowLS 138 (3 to 8 decoder) and basic logic gates

Solution32K is 4 × 8K

=> Let’s split the address space into 8K modulesIn total, we have five (4+1) 8K windowsTo address each line in 8K window

=> 13 bits (23*210 = 213 = 8K)To address five modules we need 3 bitsDon’t forget that there is no A0, we will use LDS/UDS

CPE/EE 421/521 Microcomputers 62

A Q0

Q1

Q2

Q3

Q4

Q5

Q6

Q7

B

C

LS138

E1

E2

E3

A14

A16A15

AS*

LDS*

A17

A23

...

R1CSL*

RAM2*Vcc

RAM1*

UDS*

R2CSL*

R1CSU*

R2CSU*

A23 A22 A21 A20 A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A09 A08 A07 A06 A05 A04 A03 A02 A01 A00

address within 8K module module address

UDSLDS

0 0 8 0 0 0

Designing a Memory Subsystem An Example

CPE/EE 421/521 Microcomputers 63

RAM32Kx8

A0

A14

...

CE*OE*

D0

D7D6

D5

D4

D3

D2

D1

RAM32Kx8

A0

A14

...

CE*OE*

D0

D7D6

D5

D4

D3

D2

D1

RAM8Kx8

A0

A12

...

CE*OE*

D0

D7D6

D5

D4

D3

D2

D1

WE*

A13

A1

A15

A1

D7D6D5D4D3D2D1D0

A1..A23

A15

A1

D0..D15

R/W*

R1CSL* R1CSLU*

R2CSL* R2CSLU*

RAM8Kx8

A0

A12

...

CE*OE*

D0

D7D6

D5

D4

D3

D2

D1

WE*

A13

A1

R/W*

WE*R/W* WE*R/W*

D7D6D5D4D3D2D1D0

D15D14D13D12D11D10D9D8

D15D14D13D12D11D10D9D8

Designing a Memory Subsystem An Example

CPE/EE 421/521 Microcomputers 64

Figure 4.9

Interrupt Control Interface (details later)

priority

low

high

Page 17: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 17

CPE/EE 421/521 Microcomputers 65

Data bus

Address bus

Control bus

Arbitration bus

Slave module

Memory

Master module

Local memory

CPU

I/O

Master module

Local memory

CPU

I/O

Bus Arbitration ControlWhen 68000 controls the address and data buses, we call it the bus masterThe 68000 may allow another 68000 or DMA controller to take control over busesIn the system with only one bus master, 68000 would have permanent control of the address and data buses

CPE/EE 421/521 Microcomputers 66

68000 must respond to BR* request (it cannot be masked) Assertion of BG* indicates that the bus will be given up at the end of present bus cycleRequesting device waits until AS*, DTACK*, and BGACK* have been negated, and only then asserts its own BGACK* outputOld master negates its BG*, and BR* can be asserted by another potential master

Bus Arbitration Control, cont’d

CPE/EE 421/521 Microcomputers 67Figure 4.27a

Data Bus Contention in Microcomputers

Situation where more than one device attempts to drive the bus simultaneouslyExample: Two memory modules, M1 selected during read cycle 1, M2 selected during read cycle 2Assumption:

M1 has data bus drivers with relatively long turn-off timesM2 has data bus drivers with relatively short turn-on times

CPE/EE 421/521 Microcomputers 68

Long turn-off time

Short turn-on time

Data Bus Contention in Microcomputers, cont’d

Page 18: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 18

CPE/EE 421/521 Microcomputers 69

Bus Contention and Data Bus Transceivers

Data bus transceiver – consists of a transmitter (driver) and a receiverDriver – tristate output, can be driven high, low, or internally disconnected form the rest of the circuitTwo control inputs: Enable (active low) and DIR (direction)Dynamic data bus contention

CPE/EE 421/521 Microcomputers 70

Outline

68000 interfaceTiming diagramMinimal configuration using the 68000ExtensionsException Processing

CPE/EE 421/521 Microcomputers 71

DESIGN CONSTRAINTS

Used in stand-alone modeClassroom teaching aid16 KB EPROM-based monitorSpeed is not importantAt least 4 KB RAM1 serial and 1 parallel portMemory expandableNo interrupts and multiple processors

CPE/EE 421/521 Microcomputers 72

MAJOR COMPONENTS

ROM – Two 8K × 8 componentsRAM – Two 2K × 8 componentsParallel – 6821 Peripheral Interface Adapter (PIA)Serial – 6850 Asynchronous Comm. Interface Adapter (ACIA)

Page 19: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 19

CPE/EE 421/521 Microcomputers 73

DESIGH CHOICES

Chose the location of ROM (16KB) and RAM (8 KB) within the address space (16 MB)

Unimportant, as long as the reset vectors are located at $00 0000

Chose the location of memory-mapped peripheralsControl of DTACK* (is delay applied or not?)

CPE/EE 421/521 Microcomputers 74

The 68000’s Reset Sequence

Fetch SSP fromaddress 0

RESET SEQUENCE

Set SR S bit to 1Set SR T bit to 0

Set SR mask to 111

Transfer longwordto SSP

Fetch initial PC fromaddress 4

Transfer longwordto PC

Begin processing inthe supervisor state

Bus erroroccurs?

Double buserror

Bus erroroccurs?

FATALERROR

CPE/EE 421/521 Microcomputers 75

REMEMBER

When the RESET* pin is asserted for the appropriate duration:

SR = $2700SSP is loaded with the longword @ $00 0000PC is loaded with the longword @ $00 0004

CPE/EE 421/521 Microcomputers 76Figure 4.43

Blo

ck D

iagr

am o

f a 6

8000

-ba

sed

mic

roco

mpu

ter

Page 20: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 20

CPE/EE 421/521 Microcomputers 77

Memory and Peripheral Components

We assigned address lines to address pins, and data lines to data pins. Before designing logic that will generate chip select signals, we have to decide about RAM/ROM location. To assure that the reset vector location is at $00 0000, let’s situate 16 KB of ROM at $00 0000

CPE/EE 421/521 Microcomputers 78

Mem

ory

and

Perip

hera

l C

ompo

nent

s

Figure 4.44

CPE/EE 421/521 Microcomputers 79

Control Section

We will divide the memory space $00 0000 - $01 FFFF into eight blocks of 16 KB (IC1a,b, IC2a, IC3)16 KBytes of ROM are at $00 0000 to $00 3FFFWhere is the RAM situated? Peripherals? Note: there is no delay applied to DTACK*. What will happen if we access non-decoded memory?

CPE/EE 421/521 Microcomputers 80

Control Section

Figure 4.45

Page 21: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 21

CPE/EE 421/521 Microcomputers 81

Different approaches to memory arrangement

Largest memory window (16 KB)[MEMORY GAPS]

A23 A17A16A15A14A13 A1

SELECT DECODER

DECODER

CPE/EE 421/521 Microcomputers 82

Different approaches to memory arrangement, cont’d

Smallest memory window (4 KB)[NO MEMORY GAPS]

A23 A15A14A13A12A11 A1

SELECT DECODER

DECODER

A Q0

Q1

Q2

Q3

Q4

Q5

Q6

Q7

B

C

E1

E2

E3

A12

A14A13

ROM (16 KB)4 Windows (Blocks)

RAM

A23...

AS*A15

Vcc

CPE/EE 421/521 Microcomputers 83

Outline

68000 interfaceTiming diagramMinimal configuration using the 68000ExtensionsException Processing

CPE/EE 421/521 Microcomputers 84

How can we make it better?

ROM is EPROM-based, and thus slowerWith EPROMs from the same generation, we’ll need wait states, maybe even with RAM componentsWatchdog for non-decoded memory addresses

Page 22: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 22

CPE/EE 421/521 Microcomputers 85

How can we make it better?

Figure 4.46

CPE/EE 421/521 Microcomputers 86

How can we make it better? Cont’d

CONTROL OF INTERRUPTSUse 74LS148 priority encoder to provide 7 levels of interrupt

EXTERNAL BUS INTERFACECPU can supply only the limited current to drive the busSOLUTION: Bus drivers (buffers)

CPE/EE 421/521 Microcomputers 87

DTACK* Generation

DTACK* generator based on a shift register

Figure 4.72

CPE/EE 421/521 Microcomputers 88

DTACK* Generation

Shift register and its timing diagram

Page 23: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 23

CPE/EE 421/521 Microcomputers 89

DTACK* GenerationShift register and its timing diagram

CPE/EE 421/521 Microcomputers 90

DTACK* Generation

DTACK* generator based on a counter

Figure 4.74

CPE/EE 421/521 Microcomputers 91

Outline

68000 interfaceTiming diagramMinimal configuration using the 68000ExtensionsException Processing

CPE/EE 421/521 Microcomputers 92

Interrupt Processing Mechanism

Interrupt is an asynchronous event When an interrupt occur, the computer can:

Service it Ignore it (for the time being)

Page 24: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 24

CPE/EE 421/521 Microcomputers 93

Figure 4.9

Interrupt Control Interface

priority

low

high

CPE/EE 421/521 Microcomputers 94

Interrupt processing mechanism, cont’d

Sequence of actions when an interrupt is being serviced:

1. The computer completes its current machine-level instruction2. The contents of PC is saved (on stack) 3. The state of the processor (status word) is saved on the stack4. Jump to the location of the interrupt handling routine

CPE/EE 421/521 Microcomputers 95

Interrupt processing mechanism, cont’d

The interrupt is transparent to the interrupted programInterrupt request:

Can be deferred or denied When it is deferred, it is said to be maskedSpecial one: nonmaskable interrupt request (NMI)The 68000 NMI: IRQ7 (MSP430: RST*/NMI pin)

Prioritized interrupts Vectored interrupts

Requesting peripheral identifies itself, CPU doesn’t have to poll the status of each device to discover the interrupter

CPE/EE 421/521 Microcomputers 96

The

6800

0 In

terr

upt

Inte

rfac

e

Page 25: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 25

CPE/EE 421/521 Microcomputers 97

The 68000 Interrupt Interface

CPE/EE 421/521 Microcomputers 98

The 68000 Interrupt Interface

Reset, bus error, address error, and trace exceptions take precedence over an interrupt A level 7 interrupt CAN interrupt level 7 interrupt

CPE/EE 421/521 Microcomputers 99

Proc

essi

ng th

e In

terr

upt

CPE/EE 421/521 Microcomputers 100

Interrupt Timing Diagram

Page 26: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 26

CPE/EE 421/521 Microcomputers 101

Vect

ored

Inte

rrup

ts

CPE/EE 421/521 Microcomputers 102

Exception Vectors

A vector is associated with each type of exception Vector is the 32-bit absolute address of the appropriate exception handling routine

256 exception vectors, 32 bits (4 bytes) each, extending from address $00 0000 to $00 03FFVectors 0-63 : EXCEPTIONSVectors 64-255 : INTERRUPT HANDLING ROUTINES Difference between the reset vector and all other exceptions:

It requires 2 longwords Located in SP space (FC = 110); others are in SD space (FC = 101)

CPE/EE 421/521 Microcomputers 103

Privileged States and the 68000

User programs operate only

CPE/EE 421/521 Microcomputers 104

Privileged States and the 68000, cont’d

An exception always forces the 68000 into the supervisor state

Page 27: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 27

CPE/EE 421/521 Microcomputers 105

The 68000 Exceptions

CPE/EE 421/521 Microcomputers 106

Interrupts and Real-time Processing

Multitasking (multiprogramming) concurrent executionmultiple tasks (processes)resource sharing (multiple users using the same printer)

Multiprocessingparallel execution multiple PROCESSORS!

CPE/EE 421/521 Microcomputers 107

Multitasking

Operating system (to schedule activities) Interrupt mechanism (to switch between tasks)

CPE/EE 421/521 Microcomputers 108

Real-Time Operating System

Real time - meaningful timefast enough to influence the system at that moment

space shuttle / chemical plant

Real-time systemOptimizes the response time to eventsTries to use resources efficiently

Multitasking systemOptimizes resource utilization Tries to provide a reasonable response time

Page 28: CPE/EE 421 Microcomputers: Motorola 68000 – The CPU …milenka/cpe323-07F/lectures/cpe421m68k_hw_4p1.pdf · Special-Function Pins of the 68000 Asynchronous Bus Control CPE/EE 421/521

Alex Milenkovich 28

CPE/EE 421/521 Microcomputers 109

Real-Time Kernel

Scheduler is the kernel, nucleus, of a real-time OSFunctions

a first-level interrupt handlerscheduler - the sequence in which tasks are executedinterprocess communication

Task StatesReadyRunningBlocked (dormant)

READY

RUNNING

BLOCKED

CPE/EE 421/521 Microcomputers 110

Tasks

Volatile portion (PC, status, registers)Task control block (TCB)

Task IDTask block pointer

PCSPstatus registerother registers

Task statusrun / ready / blckd

Task priorityTask time allocation

how many slots

Figure 6.25

CPE/EE 421/521 Microcomputers 111

Exception Handling and Tasks

Preemptive real-time OS: RTC generates periodic interrupts used by the kernel to locate and run the next task

How to deal with other interrupts? Service them independently, subject to priorityIntegrate them into the real-time task structure

Vectoredinterrupt

Real-time clockinterruptException

Turn on readyto run flag of

appropriate task

Turn on readyto run flag of

appropriate task

Call RT taskscheduler and switch tasks

RTE