Top Banner
Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier
44

Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Jan 03, 2016

Download

Documents

Angelina Cross
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Lecture 14: Processors

CS 2011

Fall 2014, Dr. Rozier

Page 2: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

BOMB LAB STATUS

Page 3: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

MP2

Page 4: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Lab Phases: Recursive

• Phase 1 – Factorial

• Phase 2 - Fibonacci

Page 5: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Lab Phases: Arrays

• Phase 4 – Sum Array

• Phase 5 – Find Item

• Phase 6 – Bubble Sort

Page 6: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Lab Phases: Trees

Array representation: [1,2,3,4,5,6,7,0,0,0,0,0,0,0,0]

•Phase 7 – Tree Height

•Phase 8 – Tree Traversal[1,2,5,0,0,4,0,0,3,6,0,0,7,0,0]

1 2 3 4 5 6 7

Page 7: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

PROCESSORS

Page 8: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

What needs to be done to “Process” an Instruction?

• Check the PC• Fetch the instruction from memory• Decode the instruction and set control lines appropriately• Execute the instruction

– Use ALU– Access Memory– Branch

• Store Results• PC = PC + 4, or PC = branch target

Page 9: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

CPU Overview

Page 10: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

CPU Overview

Chapter 4 — The Processor — 10

Can’t just join wires together Use multiplexers

Page 11: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

CPU + Control

Page 12: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Logic Design Basics

• Information encoded in binary– Low voltage = 0, High voltage = 1– One wire per bit– Multi-bit data encoded on multi-wire buses

• Combinational element– Operate on data– Output is a function of input

• State (sequential) elements– Store information

Page 13: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Combinational Elements

• AND-gate– Y = A & BAB

Y

I0I1

YMux

S

Multiplexer Y = S ? I1 : I0

A

B

Y+

A

B

YALU

F

Adder Y = A + B

Arithmetic/Logic Unit Y = F(A, B)

Page 14: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Storing Data?

Page 15: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

S-R Latch

• S – set• R – reset

• Feedback keeps the bit “trapped”.

Page 16: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

S-R Latch

Characteristic Table Excitation TableS R Q_next Action Q Q_next S R

0 0 Q hold 0 0 0 X

0 1 0 reset 0 1 1 0

1 0 1 set 1 0 0 1

1 1 X N/A 1 1 X 0

Page 17: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

D Flip-Flop

• We can note in the S-R Latch that S is the complement of R in state changes

Page 18: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

D Flip-Flop

• Feed D and ~D to a gated S-R Latch to create a one input synchronous SR-Latch

We’ll call it a D Flip-Flop, just to be difficult.

Page 19: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

D Flip-Flop

• D – input signal• E – enable signal,

sometimes called clock or control

E/C D Q ~Q Notes

0 X Q_prev ~Q_prev

1 0 0 1

1 1 1 0

Page 20: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

D Flip-Flop

• D – input signal• E – enable signal,

sometimes called clock or control

E/C D Q ~Q Notes

0 X Q_prev ~Q_prev No change

1 0 0 1 Reset

1 1 1 0 Set

Page 21: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Adding the Clock

Page 22: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

More Realistic

Page 23: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Register File

Page 24: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Sequential Elements• Register: stores data in a circuit

– Uses a clock signal to determine when to update the stored value

– Edge-triggered: update when Clk changes from 0 to 1

D

Clk

QClk

D

Q

Page 25: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Sequential Elements• Register with write control

– Only updates on clock edge when write control input is 1

– Used when stored value is required later

D

Clk

Q

Write

Write

D

Q

Clk

Page 26: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Clocking Methodology• Combinational logic transforms data during

clock cycles– Between clock edges– Input from state elements, output to state

element– Longest delay determines clock period

Page 27: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Building a Datapath

• Datapath– Elements that process data and addresses

in the CPU• Registers, ALUs, mux’s, memories, …

• We will build a MIPS datapath incrementally– Refining the overview design

Page 28: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Pipeline

Fetch

Decode

IssueInteger

Multiply

Floating Point

Load Store

Write Back

Page 29: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Instruction Fetch

32-bit register

Increment by 4 for next instruction

Page 30: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

ALU• Read two register operands• Perform arithmetic/logical operation• Write register result

Page 31: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Load/Store Instructions• Read register operands• Calculate address• Load: Read memory and update register• Store: Write register value to memory

Page 32: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Branch Instructions?

Page 33: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Datapath With Control

Page 34: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

ALU Instruction

Page 35: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Load Instruction

Page 36: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Branch-on-Equal Instruction

Page 37: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Performance Issues

• Longest delay determines clock period– Critical path: load instruction– Instruction memory register file ALU data

memory register file

• Not feasible to vary period for different instructions

• Violates design principle– Making the common case fast

• We will improve performance by pipelining

Page 38: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Pipelining Analogy• Pipelined laundry: overlapping execution

– Parallelism improves performance

§4.5 An O

verview of P

ipelining Four loads: Speedup

= 8/3.5 = 2.3 Non-stop:

Speedup= 2n/0.5n + 1.5 ≈ 4= number of stages

Page 39: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

MIPS Pipeline

• Five stages, one step per stage1. IF: Instruction fetch from memory2. ID: Instruction decode & register read3. EX: Execute operation or calculate address4. MEM: Access memory operand5. WB: Write result back to register

Page 40: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Pipeline Performance• Assume time for stages is

– 100ps for register read or write– 200ps for other stages

• Compare pipelined datapath with single-cycle datapath

Instr Instr fetch Register read

ALU op Memory access

Register write

Total time

lw 200ps 100 ps 200ps 200ps 100 ps 800ps

sw 200ps 100 ps 200ps 200ps 700ps

R-format 200ps 100 ps 200ps 100 ps 600ps

beq 200ps 100 ps 200ps 500ps

Page 41: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Pipeline PerformanceSingle-cycle (Tc= 800ps)

Pipelined (Tc= 200ps)

Page 42: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

Pipeline Speedup

• If all stages are balanced– i.e., all take the same time

– Time between instructionspipelined

= Time between instructionsnonpipelined

Number of stages

• If not balanced, speedup is less• Speedup due to increased throughput

– Latency (time for each instruction) does not decrease

Page 43: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

WRAP UP

Page 44: Lecture 14: Processors CS 2011 Fall 2014, Dr. Rozier.

For next time

Homework Exercises: 3.4.2, 3.4.4

3.10.1 – 3.10.5

Due Tuesday 11/4

Read Chapter 4.1-4.4