digital system design - simon fraser universitylshannon/courses/ensc350_09/lecture_set_15.pdf ·...

35
Digital System Design by by Dr. Lesley Shannon Email: [email protected] Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc350 Si F Ui i Si F Ui i Slide Set: 15 Date: March 30, 2009 Simon Fraser University Simon Fraser University

Upload: dothien

Post on 13-Mar-2018

220 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Digital System Design

byby Dr. Lesley Shannon

Email: [email protected] Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc350

Si F U i iSi F U i i Slide Set: 15Date: March 30, 2009

Simon Fraser UniversitySimon Fraser University

Page 2: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Slide Set Overview

• Buses• Buses– Most computing systems in service today use bus

based architectures– Therefore, it’s important to understand how they work– If you design a core, the two likely interfaces are a

b FIFObus or a FIFO• We’ve covered FIFOs and you’ve seen an example Bus

protocol for your lab, but we’re going to look another p y g gsimple bus protocol here

ENSC350: Lecture Set 17 Page 2

Page 3: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

IBM PC/XT Block Diagram

InterruptController

BusController

ControlBus

Address

InterfaceLogic

Controller Controller

8088CPUClock / 8

Addressbus 20

Data/I/OCardSlots

8087Socket

Databus

DMA Controller

Slots

Timer/Counter

Parallel I/O

SpeakerControlKeyboard

RAM

ROM (BIOS)

KeyboardControl

ENSC350: Lecture Set 15 Page 3

ROM (BIOS)http://www.techfest .com/hardware/bus/isa.htm

Page 4: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

8088 and 8086 memory and I/O address space

FFFFFh

1MMemoryAddressspace

64KI/OAddress

FFFFh

Used upTo 3FFh

space0000h

in AL, $300t AL $300

00000h

mov AX, $5555

ENSC350: Lecture Set 15 Page 4

out AL, $300Example data move instruction:

Page 5: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

PC/XT Memory Map

ENSC350: Lecture Set 17 Page 5

Page 6: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

PC/XT I/O Address Map

ENSC350: Lecture Set 17 Page 6

Page 7: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

PC/XT I/O Address Map

ENSC350: Lecture Set 17 Page 7

Page 8: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Industry Standard Architecture (ISA)

• The example bus we’re going to look at is the ISA

• It’s an older standard, and simpler than some of the standards used in modern PC design

• Peripheral card manufacturers must conform to the appropriate standards to maintain plug in compatibility

• ISA is an 8-bit or 16-bit bus standard designed for the IBM PC XT ATIBM PC, XT or AT

ENSC350: Lecture Set 15 Page 8

Page 9: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

8-bit PC and XT ISA Signal Lines

A19 - A0 -- 20 address lines used for memory access-- bottom 10 lines used for I/O access

ALE -- address latch enable, indicates a valid address present during a memory or I/O access

D7 - D0 -- 8 bidirectional data lines

IRQ7 - IRQ2 -- 6 maskable interrupt request linesIRQ7 - IRQ2 -- 6 maskable interrupt request lines

IOR_N, IOW_N -- I/O read and write control signals

SMEMR_N, SMEMW_N -- memory read and write control signals

IO CH RDY N -- used by a memory or peripheral board to

ENSC350: Lecture Set 15 Page 9

_ _ _ y y p pgenerate wait states

Page 10: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

8-bit PC and XT ISA Signal Lines

RESET -- system reset signal

CLK -- 4.77 to 8.33 MHz clock synchronized to read / write 33 yoperations

OSC -- A 14.318 MHz signal used by some video cards. NotOSC A 14.318 MHz signal used by some video cards. Not synchronized to rest of the bus.

DRQ3 - DRQ1 -- Direct Memory Access (DMA) request lines;DRQ3 DRQ1 Direct Memory Access (DMA) request lines;DRQ0 is used for DRAM refresh on the PC and the XT

DACK3 DACK1 DMA acknowledge linesDACK3 - DACK1 -- DMA acknowledge lines

0WS -- signal from the fast peripherals to instruct CPU remove wait states

ENSC350: Lecture Set 15 Page 10

wait states

Page 11: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

8-bit PC and XT ISA Signal Lines

AEN -- address enable indication signal. Goes high during a DMA operation, stays low during a regular memory or I/O access This is asserted when a DMAC has control of the busaccess. This is asserted when a DMAC has control of the bus. This prevents an I/O device from responding to the I/O command lines during a DMA transfer.

TC -- terminal count, DMA controller indicates the requested number of memory transactions during a DMA operation until completion. It sends this signal to the requesting device and causes the device to generate an interrupt to the processor.

IO_CH_CHK_N -- alerts the processor to parity and other errors via a nonmaskable interrupt

ENSC350: Lecture Set 15 Page 11

+5V, -5V, +12V, -12V, GND -- supply voltages and ground

Page 12: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

8088 CPU memory bus read and write cycleT0 T1 T2 T3

CLKT4 T5 T6 T7

A19 - A0

ALE

Memory address valid Memory address valid

ALE

AEN

SMEMR_N

SMEMW NSMEMW_N

IO_CH_RDY_N Tac

Page 12D7 - D0

Data from memory valid Data to memory valid

Page 13: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

8088 CPU I/O port read and write cycleT0 T1 T2 T3

CLKT4 T5 T6 T7

A9 - A0

ALE

I/O port address valid I/O port address valid

ALE

AEN

IOR_N

IOW_N

IO_CH_RDY_N

Page 13D7 - D0Data from I/O device valid Data to I/O port valid

Page 14: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Simple 8-bit PC/XT digital input port design

C stom designed peripheral cardSignals on PC BUS

Decode/10

Custom designed peripheral card

A9 - A0

Signals on PC BUS

300h/A9 A0

ALE

Input port( ADC )

IOR_N

/8

/8

D7 - D0

ENSC350: Lecture Set 15 Page 14

Page 15: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Simple 8-bit PC/XT digital output port design

10

Custom designed peripheral cardSignals on PC BUS

Decode300h

/10

A9 - A0

ALE

IOW_N

latchEN

/8

/8

Output portD7 - D0 D Q

ENSC350: Lecture Set 15 Page 15

p p( eg DAC )

Page 16: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Simple 8-bit PC/XT digital input/output port design

10

Custom designed peripheral cardSignals on PC BUS

Decode300h/

10A9 - A0

ALE

ior_out

Input port( sensors signals )

IOR_N

IOW_N

/8

/8

D7 - D08

dio

Output port(output controlEN

D Q8/

ENSC350: Lecture Set 15 Page 16

(output control signals )

EN

Page 17: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Interrupt driven 8-bit PC/XT digital input port• Peripheral device has data ready to be read by CPU• Peripheral device has data ready to be read by CPU

• It places data on the input port ( 300h) and notify the CPU with an interruptsignal

• CPU handles the interrupt by reading the input data and reset theinterrupt flip flop at the same time

10

I t t

Decode300h

/A9 - A0

ALE

D7 - D0 /8

/8

Input port( sensors signals )IOR_N

D7 D0

IRQ7 DQ

CK

‘1’

Controlled by

Page 17

CKR

RESETInterrupt enable

Controlled by another Output port bit

Page 18: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

8088 CPU wait state timingT0 T1 T2 T3

CLKT4 T5 T6 T7

A9 - A0

ALE

I/O port address valid

ALE

AEN

IOR_N / IOW_N

IO_CH_RDY_N

Page 18D7 - D0 Data from

I/O device valid

Page 19: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Wait state generation logic10

D Q

CK RFF1

Decode300/301h

/10

A9 - A0ALE EN

IOR_NCK R

IOW_N

RESET

D Q

CK

D Q

CKCLK FF2 FF3CK

RCK

R

IO_CH_RDY_N

Page 19

Page 20: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Modes of Data Transfer between a CPU and a peripheral

Data can be transferred between a computer and an I/O device via a different mode of operation:

1. Programmed I/O -- the CPU constantly monitors the status of the interface and reads in (or supplies) the data as required.

I/OCPU

Interface

Data register

I/O busData bus

ReadyAddress bus

I/Odevice

CPU Data register

Statusregister F

Ready

AcknowledgeI/O readI/O write

Flag bit

Data transfer from I/O device to CPU

ENSC350: Lecture Set 15 Page 20

Data transfer from I/O device to CPUMano pp.594 – 597.

Page 21: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Sequence of Events

a. I/O device outputs data on the I/O bus and raises Ready line

b. Output data stored in Data register and Status bit F is set

c. Interface will assert Acknowledge signal

d. CPU polls the flag bit

e. If flag bit is set, the CPU will read contents from Data register, and , at the same time, clear the flag bit. Else, go to d

f. Acknowledge is dropped, I/O device can initiate another datatransfer cycle

In the program-controlled transfer, the CPU stays in a program loop untilthe I/O unit indicates that it is ready for data transfer; the CPU is kept( needlessly ) busy all the time so it won’t lose any data!

ENSC350: Lecture Set 15 Page 21

Page 22: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

2. Interrupt-initiated I/O -- the I/O device initiates a data transfer bydrawing the attention of the CPU using a hardware interrupt. TheCPU branches off from its normal operation to handle the datatransfer and subsequently return to its normal operation.

Input busData bus

I/Odevice

CPU InterfaceReady

Valid

Address bus

I/O writeInterrupt ReadInterrupt

Data transfer from CPU to I/O device using an interrupt

Read

a. I/O device, when ready to accept data, asserts Ready and triggers aninterrupt

C fb. CPU services the interrupt by writing a data byte to the interface,which removes the interrupt signal from the CPU and raises the Validline.

I/O d i d i d t d th b t V lidStill a fair amount of CPU

ENSC350: Lecture Set 15 Page 22

c. I/O device reads in data and thereby resets Valid overhead for every datatransfer!

Page 23: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

D Q D QData Data

Interface

Q

CK

D Q

CK

CPUV lid1

Address

Address EN

D Q

CK R

Valid

Read

1

Ready

decoder

I/O write

I/OdeviceEN

1DQ

Interrupt

Ready

t0 t1 t2 t3ENCKR Ready

Interrupt

I/O it* Example of a Computer Interface Design Using an Interrupt Driven by an I/O Device

I/O write

Valid

Read

ENSC350: Lecture Set 15 Page 23

ead

Page 24: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

3. Direct Memory Access (DMA) Mano pp.602 - 605

When a large amount of data is required to be transferred at a highrate, the operation usually involves memory access, e.g., hard disk, video display, etc.

If thi i th i it t t th CPU i l d i d tIf this is the case, is it necessary to get the CPU involved in every dataTransfer cycle?

In a direct memory access operation, the CPU (middle man) is removedy p , ( )from the data path (idling) when it puts its address, data, and controlbus in a high impedance state. The peripheral device, instead managesthese buses directly with the help of a DMA controller.

A CPU which supports the DMA operation will have to have thefollowing features:

Data bus

CPU

Bus request

Bus

Data bus

Address busRead

High-impedance(disable) whenBG is enabled

BR

BG

DBUSABUS

RD

ENSC350: Lecture Set 15 Page 24

Busgrant Write

BGWR

Page 25: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

The CPU uses 2 control signals to facilitate the DMA operation:

Bus request -- an input from the DMA controller to request the CPU togive up control of the bus

Bus grant – output from the CPU to indicate that the DMA controllercan take control over the bus (including address, data,

d it )read, write)

There are 2 modes of DMA transfer:

Burst – data words are transferred in a block

Cycle stealing – one word of data is transferred at a time; the CPUregains control after each cycle

ENSC350: Lecture Set 15 Page 25

Page 26: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Block diagram of DMA controllerAddress

Address bus3 state buffers

Data bustransceivers

Addressbus

Data bus3-state buffers

Address register

transceivers

DMA l tg

Word count

DMA select

Register select

Read

DS

RS

RD tern

al b

us

registerWrite

Bus request

Controllogic

RD

WR

BR

Int

Control registerBus grant

InterruptBG

Interrupt DMA requestDMA acknowledge To I/O device

ENSC350: Lecture Set 15 Page 26

DMA acknowledge To I/O device

Page 27: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

DMA transfer in a computer system

MemoryCPU

Interrupt

BG

Read control

Memory

DataAddrWRRD

CPU

AddrBR

DataRD WR

Read controlWrite control

Address busData busData bus

Addressd d

DataAddrWRRD

Addressdecoder

DSI/O

Peripheraldevice

DMA request

decoder

DMAcontroller

RS

BR

DS

ENSC350: Lecture Set 15 Page 27

DMA acknowledgeBGInterrupt

Page 28: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

The sequence of operation in a DMA transfer:

• Under software control CPU configures DMA controller

• CPU sets up the I/O device for the desired operation

• I/O device sends DMA request when ready

• DMA controller activates Bus request

• CPU completes current instruction, relinquishes bus control,and issuesBus grantBus grant

• DMA controller gain control of the bus, and sends DMA acknowledge toI/O device requesting the transfer

• I/O device puts data on the data bus, DMA controller generates Reador Write signal to operate on memory at the address indicated by theinternal address registerg

• DMA request goes low at the end of each transfer cycle. This signal issampled by the controller to see if the word count is not zero. For aslower data transfer rate DMA controller may let CPU regain the busslower data transfer rate, DMA controller may let CPU regain the busfor a short while until DMA request is active again

• An interrupt is issued to the CPU when the word count register is zero

Page 29: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

DMA Timing DiagramDRQDRQ

BR

BG

DACKRD/WR Cycle

BG

Single cycle DMA data transfer mode

DRQ

BR

BG

RD/WR CycleDACK

ENSC350: Lecture Set 15 Page 29Burst DMA data transfer mode

Page 30: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Architecture of a Modern CPU system with a 33MHz PCI Bus

Processor

AGP FSB2X

GFXTVMonitor

PCI 33MHz

North Bridge(Intel 440)

Mainmemory

Memory bus

Arbiter

PCI-33MHz

Ethernet SCSIS th B id

HDDCDIDE

AvailablePCI slot

USB

South Bridge

ISA

SuperIO

Floppy

Printer

Keyboard

Mouse

Com

BootROM

ModemChip

AudioChip

ENSC350: Lecture Set 15 Page 30

PrinterComPCI Express Architecture

Page 31: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

PCI uses a centralized synchronous bus arbitration scheme to arbitraterequest of bus mastership by the various PCI devices in the system:

PCI Device PCI Device PCI Device PCI Device

PCI Arbiter

No particular arbitration algorithm has been specified by the PCI standard

Possible algorithms include : First Come First ServeRound robin

.

Page 31

.

PCI system designer has to ensure reasonable fairness in bus arbitration

Page 32: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Questions

• What is the difference between memory mapping and I/O mapping peripherals?mapping and I/O mapping peripherals?

• What does the acronym ISA stand for in ISA• What does the acronym ISA stand for in ISA bus?

ENSC350: Lecture Set 15 Page 32

Page 33: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Questions

• Given a base address and a memory footprint, you should be able design necessaryyou should be able design necessary input/output circuitry.

• What are the three different modes of dataWhat are the three different modes of data transfers between I/O peripherals and the CPU?

ENSC350: Lecture Set 15 Page 33

Page 34: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Questions

• What is the advantage of using a DMA?

• How does a DMA work?

ENSC350: Lecture Set 15 Page 34

Page 35: Digital System Design - Simon Fraser Universitylshannon/courses/ensc350_09/Lecture_Set_15.pdf · simple bus protocol ... Controller Bus Controller Control Bus Address Interface Logic

Questions

• What are the steps for a memory read/write by a CPU?CPU?

• Modern CPU systems have a• Modern CPU systems have a Northbridge/Southbridge architecture. Why?

ENSC350: Lecture Set 15 Page 35